Go to the documentation of this file.
14 #include <linux/module.h>
15 #include <linux/kernel.h>
16 #include <linux/netdevice.h>
18 #include <linux/pci.h>
20 #include <linux/ethtool.h>
21 #include <linux/mii.h>
26 #include <linux/tcp.h>
27 #include <linux/sched.h>
28 #include <linux/tty.h>
29 #include <linux/if_vlan.h>
33 #include <asm/byteorder.h>
35 #include <linux/slab.h>
41 #define BDX_DELAY_WPTR
45 #if !defined CONFIG_PCI_MSI
49 #define BDX_DEF_MSG_ENABLE (NETIF_MSG_DRV | \
55 #define BDX_OP_WRITE 2
58 #define BDX_COPYBREAK 257
60 #define DRIVER_AUTHOR "Tehuti Networks(R)"
61 #define BDX_DRV_DESC "Tehuti Networks(R) Network Driver"
62 #define BDX_DRV_NAME "tehuti"
63 #define BDX_NIC_NAME "Tehuti 10 Giga TOE SmartNIC"
64 #define BDX_NIC2PORT_NAME "Tehuti 2-Port 10 Giga TOE SmartNIC"
65 #define BDX_DRV_VERSION "7.29.3"
68 # define BDX_MSI_STRING "msi "
70 # define BDX_MSI_STRING ""
75 #define BDX_NDEV_TXQ_LEN 3000
77 #define FIFO_SIZE 4096
78 #define FIFO_EXTRA_SPACE 1024
80 #if BITS_PER_LONG == 64
81 # define H32_64(x) (u32) ((u64)(x) >> 32)
82 # define L32_64(x) (u32) ((u64)(x) & 0xffffffff)
83 #elif BITS_PER_LONG == 32
85 # define L32_64(x) ((u32) (x))
87 # error BITS_PER_LONG is undefined. Must be 64 or 32
91 # define CPU_CHIP_SWAP32(x) swab32(x)
92 # define CPU_CHIP_SWAP16(x) swab16(x)
94 # define CPU_CHIP_SWAP32(x) (x)
95 # define CPU_CHIP_SWAP16(x) (x)
98 #define READ_REG(pp, reg) readl(pp->pBdxRegs + reg)
99 #define WRITE_REG(pp, reg, val) writel(val, pp->pBdxRegs + reg)
102 # define NET_IP_ALIGN 2
106 # define NETDEV_TX_OK 0
109 #define LUXOR_MAX_PORT 2
110 #define BDX_MAX_RX_DONE 150
111 #define BDX_TXF_DESC_SZ 16
112 #define BDX_MAX_TX_LEVEL (priv->txd_fifo0.m.memsz - 16)
113 #define BDX_MIN_TX_LEVEL 256
114 #define BDX_NO_UPD_PACKETS 40
125 #define PCK_TH_MULT 128
126 #define INT_COAL_MULT 2
128 #define BITS_MASK(nbits) ((1<<nbits)-1)
129 #define GET_BITS_SHIFT(x, nbits, nshift) (((x)>>nshift)&BITS_MASK(nbits))
130 #define BITS_SHIFT_MASK(nbits, nshift) (BITS_MASK(nbits)<<nshift)
131 #define BITS_SHIFT_VAL(x, nbits, nshift) (((x)&BITS_MASK(nbits))<<nshift)
132 #define BITS_SHIFT_CLEAR(x, nbits, nshift) \
133 ((x)&(~BITS_SHIFT_MASK(nbits, nshift)))
135 #define GET_INT_COAL(x) GET_BITS_SHIFT(x, 15, 0)
136 #define GET_INT_COAL_RC(x) GET_BITS_SHIFT(x, 1, 15)
137 #define GET_RXF_TH(x) GET_BITS_SHIFT(x, 4, 16)
138 #define GET_PCK_TH(x) GET_BITS_SHIFT(x, 4, 20)
140 #define INT_REG_VAL(coal, coal_rc, rxf_th, pck_th) \
141 ((coal)|((coal_rc)<<15)|((rxf_th)<<16)|((pck_th)<<20))
260 #ifdef BDX_DELAY_WPTR
293 #define GET_RXD_BC(x) GET_BITS_SHIFT((x), 5, 0)
294 #define GET_RXD_RXFQ(x) GET_BITS_SHIFT((x), 2, 8)
295 #define GET_RXD_TO(x) GET_BITS_SHIFT((x), 1, 15)
296 #define GET_RXD_TYPE(x) GET_BITS_SHIFT((x), 4, 16)
297 #define GET_RXD_ERR(x) GET_BITS_SHIFT((x), 6, 21)
298 #define GET_RXD_RXP(x) GET_BITS_SHIFT((x), 1, 27)
299 #define GET_RXD_PKT_ID(x) GET_BITS_SHIFT((x), 3, 28)
300 #define GET_RXD_VTAG(x) GET_BITS_SHIFT((x), 1, 31)
301 #define GET_RXD_VLAN_ID(x) GET_BITS_SHIFT((x), 12, 0)
302 #define GET_RXD_VLAN_TCI(x) GET_BITS_SHIFT((x), 16, 0)
303 #define GET_RXD_CFI(x) GET_BITS_SHIFT((x), 1, 12)
304 #define GET_RXD_PRIO(x) GET_BITS_SHIFT((x), 3, 13)
324 #define TXD_W1_VAL(bc, checksum, vtag, lgsnd, vlan_id) \
325 ((bc) | ((checksum)<<5) | ((vtag)<<8) | \
326 ((lgsnd)<<9) | (0x30000) | ((vlan_id)<<20))
338 #define BDX_REGS_SIZE 0x1000
341 #define regTXD_CFG1_0 0x4000
342 #define regRXF_CFG1_0 0x4010
343 #define regRXD_CFG1_0 0x4020
344 #define regTXF_CFG1_0 0x4030
345 #define regTXD_CFG0_0 0x4040
346 #define regRXF_CFG0_0 0x4050
347 #define regRXD_CFG0_0 0x4060
348 #define regTXF_CFG0_0 0x4070
349 #define regTXD_WPTR_0 0x4080
350 #define regRXF_WPTR_0 0x4090
351 #define regRXD_WPTR_0 0x40A0
352 #define regTXF_WPTR_0 0x40B0
353 #define regTXD_RPTR_0 0x40C0
354 #define regRXF_RPTR_0 0x40D0
355 #define regRXD_RPTR_0 0x40E0
356 #define regTXF_RPTR_0 0x40F0
357 #define regTXF_RPTR_3 0x40FC
360 #define FW_VER 0x5010
361 #define SROM_VER 0x5020
362 #define FPGA_VER 0x5030
363 #define FPGA_SEED 0x5040
366 #define regISR regISR0
367 #define regISR0 0x5100
369 #define regIMR regIMR0
370 #define regIMR0 0x5110
372 #define regRDINTCM0 0x5120
373 #define regRDINTCM2 0x5128
375 #define regTDINTCM0 0x5130
377 #define regISR_MSK0 0x5140
379 #define regINIT_SEMAPHORE 0x5170
380 #define regINIT_STATUS 0x5180
382 #define regMAC_LNK_STAT 0x0200
383 #define MAC_LINK_STAT 0x4
385 #define regGMAC_RXF_A 0x1240
387 #define regUNC_MAC0_A 0x1250
388 #define regUNC_MAC1_A 0x1260
389 #define regUNC_MAC2_A 0x1270
391 #define regVLAN_0 0x1800
393 #define regMAX_FRAME_A 0x12C0
395 #define regRX_MAC_MCST0 0x1A80
396 #define regRX_MAC_MCST1 0x1A84
397 #define MAC_MCST_NUM 15
398 #define regRX_MCST_HASH0 0x1A00
399 #define MAC_MCST_HASH_NUM 8
401 #define regVPC 0x2300
402 #define regVIC 0x2320
403 #define regVGLB 0x2340
405 #define regCLKPLL 0x5000
408 #define regREVISION 0x6000
409 #define regSCRATCH 0x6004
410 #define regCTRLST 0x6008
411 #define regMAC_ADDR_0 0x600C
412 #define regMAC_ADDR_1 0x6010
413 #define regFRM_LENGTH 0x6014
414 #define regPAUSE_QUANT 0x6018
415 #define regRX_FIFO_SECTION 0x601C
416 #define regTX_FIFO_SECTION 0x6020
417 #define regRX_FULLNESS 0x6024
418 #define regTX_FULLNESS 0x6028
419 #define regHASHTABLE 0x602C
420 #define regMDIO_ST 0x6030
421 #define regMDIO_CTL 0x6034
422 #define regMDIO_DATA 0x6038
423 #define regMDIO_ADDR 0x603C
425 #define regRST_PORT 0x7000
426 #define regDIS_PORT 0x7010
427 #define regRST_QU 0x7020
428 #define regDIS_QU 0x7030
430 #define regCTRLST_TX_ENA 0x0001
431 #define regCTRLST_RX_ENA 0x0002
432 #define regCTRLST_PRM_ENA 0x0010
433 #define regCTRLST_PAD_ENA 0x0020
435 #define regCTRLST_BASE (regCTRLST_PAD_ENA|regCTRLST_PRM_ENA)
437 #define regRX_FLT 0x1400
440 #define TX_RX_CFG1_BASE 0xffffffff
441 #define TX_RX_CFG0_BASE 0xfffff000
442 #define TX_RX_CFG0_RSVD 0x0ffc
443 #define TX_RX_CFG0_SIZE 0x0003
446 #define TXF_WPTR_WR_PTR 0x7ff8
449 #define TXF_RPTR_RD_PTR 0x7ff8
451 #define TXF_WPTR_MASK 0x7ff0
456 #define IMR_INPROG 0x80000000
457 #define IR_LNKCHG1 0x10000000
458 #define IR_LNKCHG0 0x08000000
459 #define IR_GPIO 0x04000000
460 #define IR_RFRSH 0x02000000
461 #define IR_RSVD 0x01000000
462 #define IR_SWI 0x00800000
463 #define IR_RX_FREE_3 0x00400000
464 #define IR_RX_FREE_2 0x00200000
465 #define IR_RX_FREE_1 0x00100000
466 #define IR_RX_FREE_0 0x00080000
467 #define IR_TX_FREE_3 0x00040000
468 #define IR_TX_FREE_2 0x00020000
469 #define IR_TX_FREE_1 0x00010000
470 #define IR_TX_FREE_0 0x00008000
471 #define IR_RX_DESC_3 0x00004000
472 #define IR_RX_DESC_2 0x00002000
473 #define IR_RX_DESC_1 0x00001000
474 #define IR_RX_DESC_0 0x00000800
475 #define IR_PSE 0x00000400
476 #define IR_TMR3 0x00000200
477 #define IR_TMR2 0x00000100
478 #define IR_TMR1 0x00000080
479 #define IR_TMR0 0x00000040
480 #define IR_VNT 0x00000020
481 #define IR_RxFL 0x00000010
482 #define IR_SDPERR 0x00000008
483 #define IR_TR 0x00000004
484 #define IR_PCIE_LINK 0x00000002
485 #define IR_PCIE_TOUT 0x00000001
487 #define IR_EXTRA (IR_RX_FREE_0 | IR_LNKCHG0 | IR_PSE | \
488 IR_TMR0 | IR_PCIE_LINK | IR_PCIE_TOUT)
489 #define IR_RUN (IR_EXTRA | IR_RX_DESC_0 | IR_TX_FREE_0)
490 #define IR_ALL 0xfdfffff7
492 #define IR_LNKCHG0_ofst 27
494 #define GMAC_RX_FILTER_OSEN 0x1000
495 #define GMAC_RX_FILTER_TXFC 0x0400
496 #define GMAC_RX_FILTER_RSV0 0x0200
497 #define GMAC_RX_FILTER_FDA 0x0100
498 #define GMAC_RX_FILTER_AOF 0x0080
499 #define GMAC_RX_FILTER_ACF 0x0040
500 #define GMAC_RX_FILTER_ARUNT 0x0020
501 #define GMAC_RX_FILTER_ACRC 0x0010
502 #define GMAC_RX_FILTER_AM 0x0008
503 #define GMAC_RX_FILTER_AB 0x0004
504 #define GMAC_RX_FILTER_PRM 0x0001
506 #define MAX_FRAME_AB_VAL 0x3fff
508 #define CLKPLL_PLLLKD 0x0200
509 #define CLKPLL_RSTEND 0x0100
510 #define CLKPLL_SFTRST 0x0001
512 #define CLKPLL_LKD (CLKPLL_PLLLKD|CLKPLL_RSTEND)
518 #define PCI_DEV_CTRL_REG 0x88
519 #define GET_DEV_CTRL_MAXPL(x) GET_BITS_SHIFT(x, 3, 5)
520 #define GET_DEV_CTRL_MRRS(x) GET_BITS_SHIFT(x, 3, 12)
526 #define PCI_LINK_STATUS_REG 0x92
527 #define GET_LINK_STATUS_LANES(x) GET_BITS_SHIFT(x, 6, 4)
531 #define DBG2(fmt, args...) \
532 pr_err("%s:%-5d: " fmt, __func__, __LINE__, ## args)
534 #define BDX_ASSERT(x) BUG_ON(x)
540 pr_err("%s:%-5d: ENTER\n", __func__, __LINE__); \
543 #define RET(args...) \
545 pr_err("%s:%-5d: RETURN\n", __func__, __LINE__); \
549 #define DBG(fmt, args...) \
550 pr_err("%s:%-5d: " fmt, __func__, __LINE__, ## args)
552 #define ENTER do { } while (0)
553 #define RET(args...) return args
554 #define DBG(fmt, args...) \
557 pr_err(fmt, ##args); \