1 /*
2  * Copyright (c) 2007 Mellanox Technologies. All rights reserved.
3  *
4  * This software is available to you under a choice of one of two
5  * licenses.  You may choose to be licensed under the terms of the GNU
6  * General Public License (GPL) Version 2, available from the file
7  * COPYING in the main directory of this source tree, or the
8  * OpenIB.org BSD license below:
9  *
10  *     Redistribution and use in source and binary forms, with or
11  *     without modification, are permitted provided that the following
12  *     conditions are met:
13  *
14  *      - Redistributions of source code must retain the above
15  *        copyright notice, this list of conditions and the following
16  *        disclaimer.
17  *
18  *      - Redistributions in binary form must reproduce the above
19  *        copyright notice, this list of conditions and the following
20  *        disclaimer in the documentation and/or other materials
21  *        provided with the distribution.
22  *
23  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30  * SOFTWARE.
31  *
32  */
33 
34 #ifndef _MLX4_EN_PORT_H_
35 #define _MLX4_EN_PORT_H_
36 
37 
38 #define SET_PORT_PROMISC_SHIFT	31
39 #define SET_PORT_MC_PROMISC_SHIFT	30
40 
41 #define MLX4_EN_NUM_TC		8
42 
43 #define VLAN_FLTR_SIZE	128
44 struct mlx4_set_vlan_fltr_mbox {
45 	__be32 entry[VLAN_FLTR_SIZE];
46 };
47 
48 
49 enum {
50 	MLX4_MCAST_CONFIG       = 0,
51 	MLX4_MCAST_DISABLE      = 1,
52 	MLX4_MCAST_ENABLE       = 2,
53 };
54 
55 enum mlx4_link_mode {
56 	MLX4_1000BASE_CX_SGMII	 = 0,
57 	MLX4_1000BASE_KX	 = 1,
58 	MLX4_10GBASE_CX4	 = 2,
59 	MLX4_10GBASE_KX4	 = 3,
60 	MLX4_10GBASE_KR		 = 4,
61 	MLX4_20GBASE_KR2	 = 5,
62 	MLX4_40GBASE_CR4	 = 6,
63 	MLX4_40GBASE_KR4	 = 7,
64 	MLX4_56GBASE_KR4	 = 8,
65 	MLX4_10GBASE_CR		 = 12,
66 	MLX4_10GBASE_SR		 = 13,
67 	MLX4_40GBASE_SR4	 = 15,
68 	MLX4_56GBASE_CR4	 = 17,
69 	MLX4_56GBASE_SR4	 = 18,
70 	MLX4_100BASE_TX		 = 24,
71 	MLX4_1000BASE_T		 = 25,
72 	MLX4_10GBASE_T		 = 26,
73 };
74 
75 #define MLX4_PROT_MASK(link_mode) (1<<link_mode)
76 
77 enum {
78 	MLX4_EN_100M_SPEED	= 0x04,
79 	MLX4_EN_10G_SPEED_XAUI	= 0x00,
80 	MLX4_EN_10G_SPEED_XFI	= 0x01,
81 	MLX4_EN_1G_SPEED	= 0x02,
82 	MLX4_EN_20G_SPEED	= 0x08,
83 	MLX4_EN_40G_SPEED	= 0x40,
84 	MLX4_EN_56G_SPEED	= 0x20,
85 	MLX4_EN_OTHER_SPEED	= 0x0f,
86 };
87 
88 struct mlx4_en_query_port_context {
89 	u8 link_up;
90 #define MLX4_EN_LINK_UP_MASK	0x80
91 #define MLX4_EN_ANC_MASK	0x40
92 	u8 autoneg;
93 #define MLX4_EN_AUTONEG_MASK	0x80
94 	__be16 mtu;
95 	u8 reserved2;
96 	u8 link_speed;
97 #define MLX4_EN_SPEED_MASK	0x6f
98 	u16 reserved3[5];
99 	__be64 mac;
100 	u8 transceiver;
101 };
102 
103 
104 struct mlx4_en_stat_out_mbox {
105 	/* Received frames with a length of 64 octets */
106 	__be64 R64_prio_0;
107 	__be64 R64_prio_1;
108 	__be64 R64_prio_2;
109 	__be64 R64_prio_3;
110 	__be64 R64_prio_4;
111 	__be64 R64_prio_5;
112 	__be64 R64_prio_6;
113 	__be64 R64_prio_7;
114 	__be64 R64_novlan;
115 	/* Received frames with a length of 127 octets */
116 	__be64 R127_prio_0;
117 	__be64 R127_prio_1;
118 	__be64 R127_prio_2;
119 	__be64 R127_prio_3;
120 	__be64 R127_prio_4;
121 	__be64 R127_prio_5;
122 	__be64 R127_prio_6;
123 	__be64 R127_prio_7;
124 	__be64 R127_novlan;
125 	/* Received frames with a length of 255 octets */
126 	__be64 R255_prio_0;
127 	__be64 R255_prio_1;
128 	__be64 R255_prio_2;
129 	__be64 R255_prio_3;
130 	__be64 R255_prio_4;
131 	__be64 R255_prio_5;
132 	__be64 R255_prio_6;
133 	__be64 R255_prio_7;
134 	__be64 R255_novlan;
135 	/* Received frames with a length of 511 octets */
136 	__be64 R511_prio_0;
137 	__be64 R511_prio_1;
138 	__be64 R511_prio_2;
139 	__be64 R511_prio_3;
140 	__be64 R511_prio_4;
141 	__be64 R511_prio_5;
142 	__be64 R511_prio_6;
143 	__be64 R511_prio_7;
144 	__be64 R511_novlan;
145 	/* Received frames with a length of 1023 octets */
146 	__be64 R1023_prio_0;
147 	__be64 R1023_prio_1;
148 	__be64 R1023_prio_2;
149 	__be64 R1023_prio_3;
150 	__be64 R1023_prio_4;
151 	__be64 R1023_prio_5;
152 	__be64 R1023_prio_6;
153 	__be64 R1023_prio_7;
154 	__be64 R1023_novlan;
155 	/* Received frames with a length of 1518 octets */
156 	__be64 R1518_prio_0;
157 	__be64 R1518_prio_1;
158 	__be64 R1518_prio_2;
159 	__be64 R1518_prio_3;
160 	__be64 R1518_prio_4;
161 	__be64 R1518_prio_5;
162 	__be64 R1518_prio_6;
163 	__be64 R1518_prio_7;
164 	__be64 R1518_novlan;
165 	/* Received frames with a length of 1522 octets */
166 	__be64 R1522_prio_0;
167 	__be64 R1522_prio_1;
168 	__be64 R1522_prio_2;
169 	__be64 R1522_prio_3;
170 	__be64 R1522_prio_4;
171 	__be64 R1522_prio_5;
172 	__be64 R1522_prio_6;
173 	__be64 R1522_prio_7;
174 	__be64 R1522_novlan;
175 	/* Received frames with a length of 1548 octets */
176 	__be64 R1548_prio_0;
177 	__be64 R1548_prio_1;
178 	__be64 R1548_prio_2;
179 	__be64 R1548_prio_3;
180 	__be64 R1548_prio_4;
181 	__be64 R1548_prio_5;
182 	__be64 R1548_prio_6;
183 	__be64 R1548_prio_7;
184 	__be64 R1548_novlan;
185 	/* Received frames with a length of 1548 < octets < MTU */
186 	__be64 R2MTU_prio_0;
187 	__be64 R2MTU_prio_1;
188 	__be64 R2MTU_prio_2;
189 	__be64 R2MTU_prio_3;
190 	__be64 R2MTU_prio_4;
191 	__be64 R2MTU_prio_5;
192 	__be64 R2MTU_prio_6;
193 	__be64 R2MTU_prio_7;
194 	__be64 R2MTU_novlan;
195 	/* Received frames with a length of MTU< octets and good CRC */
196 	__be64 RGIANT_prio_0;
197 	__be64 RGIANT_prio_1;
198 	__be64 RGIANT_prio_2;
199 	__be64 RGIANT_prio_3;
200 	__be64 RGIANT_prio_4;
201 	__be64 RGIANT_prio_5;
202 	__be64 RGIANT_prio_6;
203 	__be64 RGIANT_prio_7;
204 	__be64 RGIANT_novlan;
205 	/* Received broadcast frames with good CRC */
206 	__be64 RBCAST_prio_0;
207 	__be64 RBCAST_prio_1;
208 	__be64 RBCAST_prio_2;
209 	__be64 RBCAST_prio_3;
210 	__be64 RBCAST_prio_4;
211 	__be64 RBCAST_prio_5;
212 	__be64 RBCAST_prio_6;
213 	__be64 RBCAST_prio_7;
214 	__be64 RBCAST_novlan;
215 	/* Received multicast frames with good CRC */
216 	__be64 MCAST_prio_0;
217 	__be64 MCAST_prio_1;
218 	__be64 MCAST_prio_2;
219 	__be64 MCAST_prio_3;
220 	__be64 MCAST_prio_4;
221 	__be64 MCAST_prio_5;
222 	__be64 MCAST_prio_6;
223 	__be64 MCAST_prio_7;
224 	__be64 MCAST_novlan;
225 	/* Received unicast not short or GIANT frames with good CRC */
226 	__be64 RTOTG_prio_0;
227 	__be64 RTOTG_prio_1;
228 	__be64 RTOTG_prio_2;
229 	__be64 RTOTG_prio_3;
230 	__be64 RTOTG_prio_4;
231 	__be64 RTOTG_prio_5;
232 	__be64 RTOTG_prio_6;
233 	__be64 RTOTG_prio_7;
234 	__be64 RTOTG_novlan;
235 
236 	/* Count of total octets of received frames, includes framing characters */
237 	__be64 RTTLOCT_prio_0;
238 	/* Count of total octets of received frames, not including framing
239 	   characters */
240 	__be64 RTTLOCT_NOFRM_prio_0;
241 	/* Count of Total number of octets received
242 	   (only for frames without errors) */
243 	__be64 ROCT_prio_0;
244 
245 	__be64 RTTLOCT_prio_1;
246 	__be64 RTTLOCT_NOFRM_prio_1;
247 	__be64 ROCT_prio_1;
248 
249 	__be64 RTTLOCT_prio_2;
250 	__be64 RTTLOCT_NOFRM_prio_2;
251 	__be64 ROCT_prio_2;
252 
253 	__be64 RTTLOCT_prio_3;
254 	__be64 RTTLOCT_NOFRM_prio_3;
255 	__be64 ROCT_prio_3;
256 
257 	__be64 RTTLOCT_prio_4;
258 	__be64 RTTLOCT_NOFRM_prio_4;
259 	__be64 ROCT_prio_4;
260 
261 	__be64 RTTLOCT_prio_5;
262 	__be64 RTTLOCT_NOFRM_prio_5;
263 	__be64 ROCT_prio_5;
264 
265 	__be64 RTTLOCT_prio_6;
266 	__be64 RTTLOCT_NOFRM_prio_6;
267 	__be64 ROCT_prio_6;
268 
269 	__be64 RTTLOCT_prio_7;
270 	__be64 RTTLOCT_NOFRM_prio_7;
271 	__be64 ROCT_prio_7;
272 
273 	__be64 RTTLOCT_novlan;
274 	__be64 RTTLOCT_NOFRM_novlan;
275 	__be64 ROCT_novlan;
276 
277 	/* Count of Total received frames including bad frames */
278 	__be64 RTOT_prio_0;
279 	/* Count of  Total number of received frames with 802.1Q encapsulation */
280 	__be64 R1Q_prio_0;
281 	__be64 reserved1;
282 
283 	__be64 RTOT_prio_1;
284 	__be64 R1Q_prio_1;
285 	__be64 reserved2;
286 
287 	__be64 RTOT_prio_2;
288 	__be64 R1Q_prio_2;
289 	__be64 reserved3;
290 
291 	__be64 RTOT_prio_3;
292 	__be64 R1Q_prio_3;
293 	__be64 reserved4;
294 
295 	__be64 RTOT_prio_4;
296 	__be64 R1Q_prio_4;
297 	__be64 reserved5;
298 
299 	__be64 RTOT_prio_5;
300 	__be64 R1Q_prio_5;
301 	__be64 reserved6;
302 
303 	__be64 RTOT_prio_6;
304 	__be64 R1Q_prio_6;
305 	__be64 reserved7;
306 
307 	__be64 RTOT_prio_7;
308 	__be64 R1Q_prio_7;
309 	__be64 reserved8;
310 
311 	__be64 RTOT_novlan;
312 	__be64 R1Q_novlan;
313 	__be64 reserved9;
314 
315 	/* Total number of Successfully Received Control Frames */
316 	__be64 RCNTL;
317 	__be64 reserved10;
318 	__be64 reserved11;
319 	__be64 reserved12;
320 	/* Count of received frames with a length/type field  value between 46
321 	   (42 for VLANtagged frames) and 1500 (also 1500 for VLAN-tagged frames),
322 	   inclusive */
323 	__be64 RInRangeLengthErr;
324 	/* Count of received frames with length/type field between 1501 and 1535
325 	   decimal, inclusive */
326 	__be64 ROutRangeLengthErr;
327 	/* Count of received frames that are longer than max allowed size for
328 	   802.3 frames (1518/1522) */
329 	__be64 RFrmTooLong;
330 	/* Count frames received with PCS error */
331 	__be64 PCS;
332 
333 	/* Transmit frames with a length of 64 octets */
334 	__be64 T64_prio_0;
335 	__be64 T64_prio_1;
336 	__be64 T64_prio_2;
337 	__be64 T64_prio_3;
338 	__be64 T64_prio_4;
339 	__be64 T64_prio_5;
340 	__be64 T64_prio_6;
341 	__be64 T64_prio_7;
342 	__be64 T64_novlan;
343 	__be64 T64_loopbk;
344 	/* Transmit frames with a length of 65 to 127 octets. */
345 	__be64 T127_prio_0;
346 	__be64 T127_prio_1;
347 	__be64 T127_prio_2;
348 	__be64 T127_prio_3;
349 	__be64 T127_prio_4;
350 	__be64 T127_prio_5;
351 	__be64 T127_prio_6;
352 	__be64 T127_prio_7;
353 	__be64 T127_novlan;
354 	__be64 T127_loopbk;
355 	/* Transmit frames with a length of 128 to 255 octets */
356 	__be64 T255_prio_0;
357 	__be64 T255_prio_1;
358 	__be64 T255_prio_2;
359 	__be64 T255_prio_3;
360 	__be64 T255_prio_4;
361 	__be64 T255_prio_5;
362 	__be64 T255_prio_6;
363 	__be64 T255_prio_7;
364 	__be64 T255_novlan;
365 	__be64 T255_loopbk;
366 	/* Transmit frames with a length of 256 to 511 octets */
367 	__be64 T511_prio_0;
368 	__be64 T511_prio_1;
369 	__be64 T511_prio_2;
370 	__be64 T511_prio_3;
371 	__be64 T511_prio_4;
372 	__be64 T511_prio_5;
373 	__be64 T511_prio_6;
374 	__be64 T511_prio_7;
375 	__be64 T511_novlan;
376 	__be64 T511_loopbk;
377 	/* Transmit frames with a length of 512 to 1023 octets */
378 	__be64 T1023_prio_0;
379 	__be64 T1023_prio_1;
380 	__be64 T1023_prio_2;
381 	__be64 T1023_prio_3;
382 	__be64 T1023_prio_4;
383 	__be64 T1023_prio_5;
384 	__be64 T1023_prio_6;
385 	__be64 T1023_prio_7;
386 	__be64 T1023_novlan;
387 	__be64 T1023_loopbk;
388 	/* Transmit frames with a length of 1024 to 1518 octets */
389 	__be64 T1518_prio_0;
390 	__be64 T1518_prio_1;
391 	__be64 T1518_prio_2;
392 	__be64 T1518_prio_3;
393 	__be64 T1518_prio_4;
394 	__be64 T1518_prio_5;
395 	__be64 T1518_prio_6;
396 	__be64 T1518_prio_7;
397 	__be64 T1518_novlan;
398 	__be64 T1518_loopbk;
399 	/* Counts transmit frames with a length of 1519 to 1522 bytes */
400 	__be64 T1522_prio_0;
401 	__be64 T1522_prio_1;
402 	__be64 T1522_prio_2;
403 	__be64 T1522_prio_3;
404 	__be64 T1522_prio_4;
405 	__be64 T1522_prio_5;
406 	__be64 T1522_prio_6;
407 	__be64 T1522_prio_7;
408 	__be64 T1522_novlan;
409 	__be64 T1522_loopbk;
410 	/* Transmit frames with a length of 1523 to 1548 octets */
411 	__be64 T1548_prio_0;
412 	__be64 T1548_prio_1;
413 	__be64 T1548_prio_2;
414 	__be64 T1548_prio_3;
415 	__be64 T1548_prio_4;
416 	__be64 T1548_prio_5;
417 	__be64 T1548_prio_6;
418 	__be64 T1548_prio_7;
419 	__be64 T1548_novlan;
420 	__be64 T1548_loopbk;
421 	/* Counts transmit frames with a length of 1549 to MTU bytes */
422 	__be64 T2MTU_prio_0;
423 	__be64 T2MTU_prio_1;
424 	__be64 T2MTU_prio_2;
425 	__be64 T2MTU_prio_3;
426 	__be64 T2MTU_prio_4;
427 	__be64 T2MTU_prio_5;
428 	__be64 T2MTU_prio_6;
429 	__be64 T2MTU_prio_7;
430 	__be64 T2MTU_novlan;
431 	__be64 T2MTU_loopbk;
432 	/* Transmit frames with a length greater than MTU octets and a good CRC. */
433 	__be64 TGIANT_prio_0;
434 	__be64 TGIANT_prio_1;
435 	__be64 TGIANT_prio_2;
436 	__be64 TGIANT_prio_3;
437 	__be64 TGIANT_prio_4;
438 	__be64 TGIANT_prio_5;
439 	__be64 TGIANT_prio_6;
440 	__be64 TGIANT_prio_7;
441 	__be64 TGIANT_novlan;
442 	__be64 TGIANT_loopbk;
443 	/* Transmit broadcast frames with a good CRC */
444 	__be64 TBCAST_prio_0;
445 	__be64 TBCAST_prio_1;
446 	__be64 TBCAST_prio_2;
447 	__be64 TBCAST_prio_3;
448 	__be64 TBCAST_prio_4;
449 	__be64 TBCAST_prio_5;
450 	__be64 TBCAST_prio_6;
451 	__be64 TBCAST_prio_7;
452 	__be64 TBCAST_novlan;
453 	__be64 TBCAST_loopbk;
454 	/* Transmit multicast frames with a good CRC */
455 	__be64 TMCAST_prio_0;
456 	__be64 TMCAST_prio_1;
457 	__be64 TMCAST_prio_2;
458 	__be64 TMCAST_prio_3;
459 	__be64 TMCAST_prio_4;
460 	__be64 TMCAST_prio_5;
461 	__be64 TMCAST_prio_6;
462 	__be64 TMCAST_prio_7;
463 	__be64 TMCAST_novlan;
464 	__be64 TMCAST_loopbk;
465 	/* Transmit good frames that are neither broadcast nor multicast */
466 	__be64 TTOTG_prio_0;
467 	__be64 TTOTG_prio_1;
468 	__be64 TTOTG_prio_2;
469 	__be64 TTOTG_prio_3;
470 	__be64 TTOTG_prio_4;
471 	__be64 TTOTG_prio_5;
472 	__be64 TTOTG_prio_6;
473 	__be64 TTOTG_prio_7;
474 	__be64 TTOTG_novlan;
475 	__be64 TTOTG_loopbk;
476 
477 	/* total octets of transmitted frames, including framing characters */
478 	__be64 TTTLOCT_prio_0;
479 	/* total octets of transmitted frames, not including framing characters */
480 	__be64 TTTLOCT_NOFRM_prio_0;
481 	/* ifOutOctets */
482 	__be64 TOCT_prio_0;
483 
484 	__be64 TTTLOCT_prio_1;
485 	__be64 TTTLOCT_NOFRM_prio_1;
486 	__be64 TOCT_prio_1;
487 
488 	__be64 TTTLOCT_prio_2;
489 	__be64 TTTLOCT_NOFRM_prio_2;
490 	__be64 TOCT_prio_2;
491 
492 	__be64 TTTLOCT_prio_3;
493 	__be64 TTTLOCT_NOFRM_prio_3;
494 	__be64 TOCT_prio_3;
495 
496 	__be64 TTTLOCT_prio_4;
497 	__be64 TTTLOCT_NOFRM_prio_4;
498 	__be64 TOCT_prio_4;
499 
500 	__be64 TTTLOCT_prio_5;
501 	__be64 TTTLOCT_NOFRM_prio_5;
502 	__be64 TOCT_prio_5;
503 
504 	__be64 TTTLOCT_prio_6;
505 	__be64 TTTLOCT_NOFRM_prio_6;
506 	__be64 TOCT_prio_6;
507 
508 	__be64 TTTLOCT_prio_7;
509 	__be64 TTTLOCT_NOFRM_prio_7;
510 	__be64 TOCT_prio_7;
511 
512 	__be64 TTTLOCT_novlan;
513 	__be64 TTTLOCT_NOFRM_novlan;
514 	__be64 TOCT_novlan;
515 
516 	__be64 TTTLOCT_loopbk;
517 	__be64 TTTLOCT_NOFRM_loopbk;
518 	__be64 TOCT_loopbk;
519 
520 	/* Total frames transmitted with a good CRC that are not aborted  */
521 	__be64 TTOT_prio_0;
522 	/* Total number of frames transmitted with 802.1Q encapsulation */
523 	__be64 T1Q_prio_0;
524 	__be64 reserved13;
525 
526 	__be64 TTOT_prio_1;
527 	__be64 T1Q_prio_1;
528 	__be64 reserved14;
529 
530 	__be64 TTOT_prio_2;
531 	__be64 T1Q_prio_2;
532 	__be64 reserved15;
533 
534 	__be64 TTOT_prio_3;
535 	__be64 T1Q_prio_3;
536 	__be64 reserved16;
537 
538 	__be64 TTOT_prio_4;
539 	__be64 T1Q_prio_4;
540 	__be64 reserved17;
541 
542 	__be64 TTOT_prio_5;
543 	__be64 T1Q_prio_5;
544 	__be64 reserved18;
545 
546 	__be64 TTOT_prio_6;
547 	__be64 T1Q_prio_6;
548 	__be64 reserved19;
549 
550 	__be64 TTOT_prio_7;
551 	__be64 T1Q_prio_7;
552 	__be64 reserved20;
553 
554 	__be64 TTOT_novlan;
555 	__be64 T1Q_novlan;
556 	__be64 reserved21;
557 
558 	__be64 TTOT_loopbk;
559 	__be64 T1Q_loopbk;
560 	__be64 reserved22;
561 
562 	/* Received frames with a length greater than MTU octets and a bad CRC */
563 	__be32 RJBBR;
564 	/* Received frames with a bad CRC that are not runts, jabbers,
565 	   or alignment errors */
566 	__be32 RCRC;
567 	/* Received frames with SFD with a length of less than 64 octets and a
568 	   bad CRC */
569 	__be32 RRUNT;
570 	/* Received frames with a length less than 64 octets and a good CRC */
571 	__be32 RSHORT;
572 	/* Total Number of Received Packets Dropped */
573 	__be32 RDROP;
574 	/* Drop due to overflow  */
575 	__be32 RdropOvflw;
576 	/* Drop due to overflow */
577 	__be32 RdropLength;
578 	/* Total of good frames. Does not include frames received with
579 	   frame-too-long, FCS, or length errors */
580 	__be32 RTOTFRMS;
581 	/* Total dropped Xmited packets */
582 	__be32 TDROP;
583 };
584 
585 
586 #endif
587