17 #define s2BIT(loc) (0x8000000000000000ULL >> (loc))
18 #define vBIT(val, loc, sz) (((u64)val) << (64-loc-sz))
19 #define INV(d) ((d&0xff)<<24) | (((d>>8)&0xff)<<16) | (((d>>16)&0xff)<<8)| ((d>>24)&0xff)
24 #define S2IO_MINUS_ONE 0xFFFFFFFFFFFFFFFFULL
25 #define S2IO_DISABLE_MAC_ENTRY 0xFFFFFFFFFFFFULL
26 #define S2IO_MAX_PCI_CONFIG_SPACE_REINIT 100
27 #define S2IO_BIT_RESET 1
28 #define S2IO_BIT_SET 2
29 #define CHECKBIT(value, nbit) (value & (1 << nbit))
32 #define MAX_FLICKER_TIME 60000
45 #define XENA_MAX_OUTSTANDING_SPLITS(n) (n << 4)
48 #define WATCH_DOG_TIMEOUT 15*HZ
50 #define ALIGN_SIZE 127
51 #define PCIX_COMMAND_REGISTER 0x62
64 static int debug_level =
ERR_DBG;
67 #define DBG_PRINT(dbg_level, fmt, args...) do { \
68 if (dbg_level <= debug_level) \
69 pr_info(fmt, ##args); \
73 #define L3_CKSUM_OK 0xFFFF
74 #define L4_CKSUM_OK 0xFFFF
75 #define S2IO_JUMBO_SIZE 9600
343 #define NO_STRIP_IN_PROMISC 2
350 #define MAX_TX_FIFOS 8
351 #define MAX_RX_RINGS 8
353 #define FIFO_DEFAULT_NUM 5
354 #define FIFO_UDP_MAX_NUM 2
355 #define FIFO_OTHER_MAX_NUM 1
358 #define MAX_RX_DESC_1 (MAX_RX_RINGS * MAX_RX_BLOCKS_PER_RING * 128)
359 #define MAX_RX_DESC_2 (MAX_RX_RINGS * MAX_RX_BLOCKS_PER_RING * 86)
360 #define MAX_TX_DESC (MAX_AVAILABLE_TXDS)
364 {0, 0, 0, 0, 0, 0, 0, 0},
365 {0, 0, 0, 0, 1, 1, 1, 1},
366 {0, 0, 0, 1, 1, 1, 2, 2},
367 {0, 0, 1, 1, 2, 2, 3, 3},
368 {0, 0, 1, 1, 2, 2, 3, 4},
369 {0, 0, 1, 1, 2, 3, 4, 5},
370 {0, 0, 1, 2, 3, 4, 5, 6},
371 {0, 1, 2, 3, 4, 5, 6, 7},
374 static const u16 fifo_selector[
MAX_TX_FIFOS] = {0, 1, 3, 3, 7, 7, 7, 7};
378 #define MAX_AVAILABLE_TXDS 8192
381 #define TX_FIFO_PRI_0 0
382 #define TX_FIFO_PRI_1 1
383 #define TX_FIFO_PRI_2 2
384 #define TX_FIFO_PRI_3 3
385 #define TX_FIFO_PRI_4 4
386 #define TX_FIFO_PRI_5 5
387 #define TX_FIFO_PRI_6 6
388 #define TX_FIFO_PRI_7 7
392 #define NO_SNOOP_TXD 0x01
393 #define NO_SNOOP_TXD_BUFFER 0x02
400 #define RX_RING_PRI_0 0
401 #define RX_RING_PRI_1 1
402 #define RX_RING_PRI_2 2
403 #define RX_RING_PRI_3 3
404 #define RX_RING_PRI_4 4
405 #define RX_RING_PRI_5 5
406 #define RX_RING_PRI_6 6
407 #define RX_RING_PRI_7 7
412 #define RING_ORG_BUFF1 0x01
413 #define RX_RING_ORG_BUFF3 0x03
414 #define RX_RING_ORG_BUFF5 0x05
417 #define NO_SNOOP_RXD 0x01
418 #define NO_SNOOP_RXD_BUFFER 0x02
429 #define NO_STEERING 0
430 #define TX_PRIORITY_STEERING 0x1
431 #define TX_DEFAULT_STEERING 0x2
447 #define MAX_RX_BLOCKS_PER_RING 150
451 #define HEADER_ETHERNET_II_802_3_SIZE 14
452 #define HEADER_802_2_SIZE 3
453 #define HEADER_SNAP_SIZE 5
454 #define HEADER_VLAN_SIZE 4
457 #define MAX_PYLD 1500
458 #define MAX_MTU (MAX_PYLD+18)
459 #define MAX_MTU_VLAN (MAX_PYLD+22)
460 #define MAX_PYLD_JUMBO 9600
461 #define MAX_MTU_JUMBO (MAX_PYLD_JUMBO+18)
462 #define MAX_MTU_JUMBO_VLAN (MAX_PYLD_JUMBO+22)
482 #define TX_FIFO_LAST_TXD_NUM( val) vBIT(val,0,8)
483 #define TX_FIFO_FIRST_LIST s2BIT(14)
484 #define TX_FIFO_LAST_LIST s2BIT(15)
485 #define TX_FIFO_FIRSTNLAST_LIST vBIT(3,14,2)
486 #define TX_FIFO_SPECIAL_FUNC s2BIT(23)
487 #define TX_FIFO_DS_NO_SNOOP s2BIT(31)
488 #define TX_FIFO_BUFF_NO_SNOOP s2BIT(30)
495 #define TXD_LIST_OWN_XENA s2BIT(7)
496 #define TXD_T_CODE (s2BIT(12)|s2BIT(13)|s2BIT(14)|s2BIT(15))
497 #define TXD_T_CODE_OK(val) (|(val & TXD_T_CODE))
498 #define GET_TXD_T_CODE(val) ((val & TXD_T_CODE)<<12)
499 #define TXD_GATHER_CODE (s2BIT(22) | s2BIT(23))
500 #define TXD_GATHER_CODE_FIRST s2BIT(22)
501 #define TXD_GATHER_CODE_LAST s2BIT(23)
502 #define TXD_TCP_LSO_EN s2BIT(30)
503 #define TXD_UDP_COF_EN s2BIT(31)
504 #define TXD_UFO_EN s2BIT(31) | s2BIT(30)
505 #define TXD_TCP_LSO_MSS(val) vBIT(val,34,14)
506 #define TXD_UFO_MSS(val) vBIT(val,34,14)
507 #define TXD_BUFFER0_SIZE(val) vBIT(val,48,16)
510 #define TXD_TX_CKO_CONTROL (s2BIT(5)|s2BIT(6)|s2BIT(7))
511 #define TXD_TX_CKO_IPV4_EN s2BIT(5)
512 #define TXD_TX_CKO_TCP_EN s2BIT(6)
513 #define TXD_TX_CKO_UDP_EN s2BIT(7)
514 #define TXD_VLAN_ENABLE s2BIT(15)
515 #define TXD_VLAN_TAG(val) vBIT(val,16,16)
516 #define TXD_INT_NUMBER(val) vBIT(val,34,6)
517 #define TXD_INT_TYPE_PER_LIST s2BIT(47)
518 #define TXD_INT_TYPE_UTILZ s2BIT(46)
519 #define TXD_SET_MARKER vBIT(0x6,0,4)
535 #define RXD_OWN_XENA s2BIT(7)
536 #define RXD_T_CODE (s2BIT(12)|s2BIT(13)|s2BIT(14)|s2BIT(15))
537 #define RXD_FRAME_PROTO vBIT(0xFFFF,24,8)
538 #define RXD_FRAME_VLAN_TAG s2BIT(24)
539 #define RXD_FRAME_PROTO_IPV4 s2BIT(27)
540 #define RXD_FRAME_PROTO_IPV6 s2BIT(28)
541 #define RXD_FRAME_IP_FRAG s2BIT(29)
542 #define RXD_FRAME_PROTO_TCP s2BIT(30)
543 #define RXD_FRAME_PROTO_UDP s2BIT(31)
544 #define TCP_OR_UDP_FRAME (RXD_FRAME_PROTO_TCP | RXD_FRAME_PROTO_UDP)
545 #define RXD_GET_L3_CKSUM(val) ((u16)(val>> 16) & 0xFFFF)
546 #define RXD_GET_L4_CKSUM(val) ((u16)(val) & 0xFFFF)
549 #define THE_RXD_MARK 0x3
550 #define SET_RXD_MARKER vBIT(THE_RXD_MARK, 0, 2)
551 #define GET_RXD_MARKER(ctrl) ((ctrl & SET_RXD_MARKER) >> 62)
553 #define MASK_VLAN_TAG vBIT(0xFFFF,48,16)
554 #define SET_VLAN_TAG(val) vBIT(val,48,16)
555 #define SET_NUM_TAG(val) vBIT(val,16,32)
563 #define MASK_BUFFER0_SIZE_1 vBIT(0x3FFF,2,14)
564 #define SET_BUFFER0_SIZE_1(val) vBIT(val,2,14)
565 #define RXD_GET_BUFFER0_SIZE_1(_Control_2) \
566 (u16)((_Control_2 & MASK_BUFFER0_SIZE_1) >> 48)
574 #define MASK_BUFFER0_SIZE_3 vBIT(0xFF,2,14)
575 #define MASK_BUFFER1_SIZE_3 vBIT(0xFFFF,16,16)
576 #define MASK_BUFFER2_SIZE_3 vBIT(0xFFFF,32,16)
577 #define SET_BUFFER0_SIZE_3(val) vBIT(val,8,8)
578 #define SET_BUFFER1_SIZE_3(val) vBIT(val,16,16)
579 #define SET_BUFFER2_SIZE_3(val) vBIT(val,32,16)
580 #define RXD_GET_BUFFER0_SIZE_3(Control_2) \
581 (u8)((Control_2 & MASK_BUFFER0_SIZE_3) >> 48)
582 #define RXD_GET_BUFFER1_SIZE_3(Control_2) \
583 (u16)((Control_2 & MASK_BUFFER1_SIZE_3) >> 32)
584 #define RXD_GET_BUFFER2_SIZE_3(Control_2) \
585 (u16)((Control_2 & MASK_BUFFER2_SIZE_3) >> 16)
599 #define MAX_RXDS_PER_BLOCK_1 127
603 #define END_OF_BLOCK 0xFEFFFFFFFFFFFFFFULL
612 #define SIZE_OF_BLOCK 4096
615 #define RXD_MODE_3B 1
698 #define MAX_LRO_SESSIONS 32
771 #define FIFO_QUEUE_START 0
772 #define FIFO_QUEUE_STOP 1
819 #define DEFAULT_FIFO_0_LEN 4096
820 #define DEFAULT_FIFO_1_7_LEN 512
821 #define SMALL_BLK_CNT 30
822 #define LARGE_BLK_CNT 100
828 #define MAX_REQUESTED_MSI_X 9
836 #define MSIX_ALARM_TYPE 1
837 #define MSIX_RING_TYPE 2
840 #define MSIX_REGISTERED_SUCCESS 0xAA
869 #define MAX_MAC_SUPPORTED 16
870 #define MAX_SUPPORTED_MULTICASTS MAX_MAC_SUPPORTED
889 #define MAX_ADDRS_SUPPORTED 64
943 #define MSIX_FLG 0xA5
955 #define XFRAME_I_DEVICE 1
956 #define XFRAME_II_DEVICE 2
965 #define VPD_STRING_LEN 80
970 #define RESET_ERROR 1
978 ret =
readl(addr + 4);
1002 static inline void SPECIAL_REG_WRITE(
u64 val,
void __iomem *addr,
int order)
1019 #define ENABLE_INTRS 1
1020 #define DISABLE_INTRS 2
1023 #define TX_PIC_INTR (0x0001<<0)
1024 #define TX_DMA_INTR (0x0001<<1)
1025 #define TX_MAC_INTR (0x0001<<2)
1026 #define TX_XGXS_INTR (0x0001<<3)
1027 #define TX_TRAFFIC_INTR (0x0001<<4)
1028 #define RX_PIC_INTR (0x0001<<5)
1029 #define RX_DMA_INTR (0x0001<<6)
1030 #define RX_MAC_INTR (0x0001<<7)
1031 #define RX_XGXS_INTR (0x0001<<8)
1032 #define RX_TRAFFIC_INTR (0x0001<<9)
1033 #define MC_INTR (0x0001<<10)
1034 #define ENA_ALL_INTRS ( TX_PIC_INTR | \
1047 #define DISABLE_ALL_INTRS 0xFFFFFFFFFFFFFFFFULL
1049 #define TXPIC_INT_M s2BIT(0)
1050 #define TXDMA_INT_M s2BIT(1)
1051 #define TXMAC_INT_M s2BIT(2)
1052 #define TXXGXS_INT_M s2BIT(3)
1053 #define TXTRAFFIC_INT_M s2BIT(8)
1054 #define PIC_RX_INT_M s2BIT(32)
1055 #define RXDMA_INT_M s2BIT(33)
1056 #define RXMAC_INT_M s2BIT(34)
1057 #define MC_INT_M s2BIT(35)
1058 #define RXXGXS_INT_M s2BIT(36)
1059 #define RXTRAFFIC_INT_M s2BIT(40)
1064 #define TXDMA_PFC_INT_M s2BIT(0)
1065 #define TXDMA_PCC_INT_M s2BIT(2)
1068 #define PFC_MISC_ERR_1 s2BIT(0)
1071 #define PCC_FB_ECC_ERR vBIT(0xff, 16, 8)
1074 #define RXD_GET_VLAN_TAG(Control_2) (u16)(Control_2 & MASK_VLAN_TAG)
1081 static int init_shared_mem(
struct s2io_nic *
sp);
1082 static void free_shared_mem(
struct s2io_nic *
sp);
1083 static int init_nic(
struct s2io_nic *nic);
1085 static void s2io_txpic_intr_handle(
struct s2io_nic *
sp);
1086 static void tx_intr_handler(
struct fifo_info *fifo_data);
1087 static void s2io_handle_errors(
void *
dev_id);
1089 static int s2io_starter(
void);
1090 static void s2io_closer(
void);
1095 static void s2io_reset(
struct s2io_nic *
sp);
1098 static void s2io_init_pci(
struct s2io_nic *
sp);
1100 static void s2io_alarm_handle(
unsigned long data);
1102 s2io_msix_ring_handle(
int irq,
void *
dev_id);
1104 s2io_msix_fifo_handle(
int irq,
void *
dev_id);
1106 static int verify_xena_quiescence(
struct s2io_nic *
sp);
1107 static const struct ethtool_ops netdev_ethtool_ops;
1109 static int s2io_set_swapper(
struct s2io_nic *
sp);
1110 static void s2io_card_down(
struct s2io_nic *nic);
1111 static int s2io_card_up(
struct s2io_nic *nic);
1112 static int wait_for_cmd_complete(
void __iomem *addr,
u64 busy_bit,
1114 static int s2io_add_isr(
struct s2io_nic *
sp);
1115 static void s2io_rem_isr(
struct s2io_nic *
sp);
1117 static void restore_xmsi_data(
struct s2io_nic *nic);
1118 static void do_s2io_store_unicast_mc(
struct s2io_nic *
sp);
1119 static void do_s2io_restore_unicast_mc(
struct s2io_nic *
sp);
1121 static int do_s2io_add_mc(
struct s2io_nic *
sp,
u8 *addr);
1123 static int do_s2io_delete_unicast_mc(
struct s2io_nic *
sp,
u64 addr);
1128 static void clear_lro_session(
struct lro *
lro);
1129 static void queue_rx_frame(
struct sk_buff *
skb,
u16 vlan_tag);
1138 static void s2io_io_resume(
struct pci_dev *pdev);
1140 #define s2io_tcp_mss(skb) skb_shinfo(skb)->gso_size
1141 #define s2io_udp_mss(skb) skb_shinfo(skb)->gso_size
1142 #define s2io_offload_type(skb) skb_shinfo(skb)->gso_type
1144 #define S2IO_PARM_INT(X, def_val) \
1145 static unsigned int X = def_val;\
1146 module_param(X , uint, 0);