Go to the documentation of this file.
27 #include <linux/types.h>
28 #include <linux/errno.h>
29 #include <linux/module.h>
30 #include <linux/pci.h>
31 #include <linux/netdevice.h>
35 #include <linux/slab.h>
36 #include <linux/list.h>
38 #include <linux/sched.h>
41 #include <linux/ipv6.h>
42 #include <linux/udp.h>
43 #include <linux/mii.h>
47 #include <linux/tcp.h>
48 #include <linux/ethtool.h>
49 #include <linux/if_vlan.h>
57 #define AT_WUFC_LNKC 0x00000001
58 #define AT_WUFC_MAG 0x00000002
59 #define AT_WUFC_EX 0x00000004
60 #define AT_WUFC_MC 0x00000008
61 #define AT_WUFC_BC 0x00000010
63 #define AT_VLAN_TO_TAG(_vlan, _tag) \
64 _tag = ((((_vlan) >> 8) & 0xFF) |\
65 (((_vlan) & 0xFF) << 8))
67 #define AT_TAG_TO_VLAN(_tag, _vlan) \
68 _vlan = ((((_tag) >> 8) & 0xFF) |\
69 (((_tag) & 0xFF) << 8))
71 #define SPEED_0 0xffff
75 #define AT_RX_BUF_SIZE (ETH_FRAME_LEN + VLAN_HLEN + ETH_FCS_LEN)
76 #define MAX_JUMBO_FRAME_SIZE (6*1024)
78 #define AT_MAX_RECEIVE_QUEUE 4
79 #define AT_DEF_RECEIVE_QUEUE 1
80 #define AT_MAX_TRANSMIT_QUEUE 2
82 #define AT_DMA_HI_ADDR_MASK 0xffffffff00000000ULL
83 #define AT_DMA_LO_ADDR_MASK 0x00000000ffffffffULL
85 #define AT_TX_WATCHDOG (5 * HZ)
86 #define AT_MAX_INT_WORK 5
87 #define AT_TWSI_EEPROM_TIMEOUT 100
88 #define AT_HW_MAX_IDLE_DELAY 10
89 #define AT_SUSPEND_LINK_TIMEOUT 100
91 #define AT_ASPM_L0S_TIMER 6
92 #define AT_ASPM_L1_TIMER 12
93 #define AT_LCKDET_TIMER 12
95 #define ATL1C_PCIE_L0S_L1_DISABLE 0x01
96 #define ATL1C_PCIE_PHY_RESET 0x02
98 #define ATL1C_ASPM_L0s_ENABLE 0x0001
99 #define ATL1C_ASPM_L1_ENABLE 0x0002
101 #define AT_REGS_LEN (74 * sizeof(u32))
102 #define AT_EEPROM_LEN 512
104 #define ATL1C_GET_DESC(R, i, type) (&(((type *)((R)->desc))[i]))
105 #define ATL1C_RFD_DESC(R, i) ATL1C_GET_DESC(R, i, struct atl1c_rx_free_desc)
106 #define ATL1C_TPD_DESC(R, i) ATL1C_GET_DESC(R, i, struct atl1c_tpd_desc)
107 #define ATL1C_RRD_DESC(R, i) ATL1C_GET_DESC(R, i, struct atl1c_recv_ret_status)
110 #define TPD_L4HDR_OFFSET_MASK 0x00FF
111 #define TPD_L4HDR_OFFSET_SHIFT 0
114 #define TPD_TCPHDR_OFFSET_MASK 0x00FF
115 #define TPD_TCPHDR_OFFSET_SHIFT 0
118 #define TPD_PLOADOFFSET_MASK 0x00FF
119 #define TPD_PLOADOFFSET_SHIFT 0
122 #define TPD_CCSUM_EN_MASK 0x0001
123 #define TPD_CCSUM_EN_SHIFT 8
124 #define TPD_IP_CSUM_MASK 0x0001
125 #define TPD_IP_CSUM_SHIFT 9
126 #define TPD_TCP_CSUM_MASK 0x0001
127 #define TPD_TCP_CSUM_SHIFT 10
128 #define TPD_UDP_CSUM_MASK 0x0001
129 #define TPD_UDP_CSUM_SHIFT 11
130 #define TPD_LSO_EN_MASK 0x0001
131 #define TPD_LSO_EN_SHIFT 12
132 #define TPD_LSO_VER_MASK 0x0001
133 #define TPD_LSO_VER_SHIFT 13
134 #define TPD_CON_VTAG_MASK 0x0001
135 #define TPD_CON_VTAG_SHIFT 14
136 #define TPD_INS_VTAG_MASK 0x0001
137 #define TPD_INS_VTAG_SHIFT 15
138 #define TPD_IPV4_PACKET_MASK 0x0001
139 #define TPD_IPV4_PACKET_SHIFT 16
140 #define TPD_ETH_TYPE_MASK 0x0001
141 #define TPD_ETH_TYPE_SHIFT 17
144 #define TPD_CCSUM_OFFSET_MASK 0x00FF
145 #define TPD_CCSUM_OFFSET_SHIFT 18
146 #define TPD_CCSUM_EPAD_MASK 0x0001
147 #define TPD_CCSUM_EPAD_SHIFT 30
150 #define TPD_MSS_MASK 0x1FFF
151 #define TPD_MSS_SHIFT 18
153 #define TPD_EOP_MASK 0x0001
154 #define TPD_EOP_SHIFT 31
170 #define RRS_RX_CSUM_MASK 0xFFFF
171 #define RRS_RX_CSUM_SHIFT 0
172 #define RRS_RX_RFD_CNT_MASK 0x000F
173 #define RRS_RX_RFD_CNT_SHIFT 16
174 #define RRS_RX_RFD_INDEX_MASK 0x0FFF
175 #define RRS_RX_RFD_INDEX_SHIFT 20
178 #define RRS_HEAD_LEN_MASK 0x00FF
179 #define RRS_HEAD_LEN_SHIFT 0
180 #define RRS_HDS_TYPE_MASK 0x0003
181 #define RRS_HDS_TYPE_SHIFT 8
182 #define RRS_CPU_NUM_MASK 0x0003
183 #define RRS_CPU_NUM_SHIFT 10
184 #define RRS_HASH_FLG_MASK 0x000F
185 #define RRS_HASH_FLG_SHIFT 12
187 #define RRS_HDS_TYPE_HEAD 1
188 #define RRS_HDS_TYPE_DATA 2
190 #define RRS_IS_NO_HDS_TYPE(flag) \
191 ((((flag) >> (RRS_HDS_TYPE_SHIFT)) & RRS_HDS_TYPE_MASK) == 0)
193 #define RRS_IS_HDS_HEAD(flag) \
194 ((((flag) >> (RRS_HDS_TYPE_SHIFT)) & RRS_HDS_TYPE_MASK) == \
197 #define RRS_IS_HDS_DATA(flag) \
198 ((((flag) >> (RRS_HDS_TYPE_SHIFT)) & RRS_HDS_TYPE_MASK) == \
202 #define RRS_PKT_SIZE_MASK 0x3FFF
203 #define RRS_PKT_SIZE_SHIFT 0
204 #define RRS_ERR_L4_CSUM_MASK 0x0001
205 #define RRS_ERR_L4_CSUM_SHIFT 14
206 #define RRS_ERR_IP_CSUM_MASK 0x0001
207 #define RRS_ERR_IP_CSUM_SHIFT 15
208 #define RRS_VLAN_INS_MASK 0x0001
209 #define RRS_VLAN_INS_SHIFT 16
210 #define RRS_PROT_ID_MASK 0x0007
211 #define RRS_PROT_ID_SHIFT 17
212 #define RRS_RX_ERR_SUM_MASK 0x0001
213 #define RRS_RX_ERR_SUM_SHIFT 20
214 #define RRS_RX_ERR_CRC_MASK 0x0001
215 #define RRS_RX_ERR_CRC_SHIFT 21
216 #define RRS_RX_ERR_FAE_MASK 0x0001
217 #define RRS_RX_ERR_FAE_SHIFT 22
218 #define RRS_RX_ERR_TRUNC_MASK 0x0001
219 #define RRS_RX_ERR_TRUNC_SHIFT 23
220 #define RRS_RX_ERR_RUNC_MASK 0x0001
221 #define RRS_RX_ERR_RUNC_SHIFT 24
222 #define RRS_RX_ERR_ICMP_MASK 0x0001
223 #define RRS_RX_ERR_ICMP_SHIFT 25
224 #define RRS_PACKET_BCAST_MASK 0x0001
225 #define RRS_PACKET_BCAST_SHIFT 26
226 #define RRS_PACKET_MCAST_MASK 0x0001
227 #define RRS_PACKET_MCAST_SHIFT 27
228 #define RRS_PACKET_TYPE_MASK 0x0001
229 #define RRS_PACKET_TYPE_SHIFT 28
230 #define RRS_FIFO_FULL_MASK 0x0001
231 #define RRS_FIFO_FULL_SHIFT 29
232 #define RRS_802_3_LEN_ERR_MASK 0x0001
233 #define RRS_802_3_LEN_ERR_SHIFT 30
234 #define RRS_RXD_UPDATED_MASK 0x0001
235 #define RRS_RXD_UPDATED_SHIFT 31
237 #define RRS_ERR_L4_CSUM 0x00004000
238 #define RRS_ERR_IP_CSUM 0x00008000
239 #define RRS_VLAN_INS 0x00010000
240 #define RRS_RX_ERR_SUM 0x00100000
241 #define RRS_RX_ERR_CRC 0x00200000
242 #define RRS_802_3_LEN_ERR 0x40000000
243 #define RRS_RXD_UPDATED 0x80000000
245 #define RRS_PACKET_TYPE_802_3 1
246 #define RRS_PACKET_TYPE_ETH 0
247 #define RRS_PACKET_IS_ETH(word) \
248 ((((word) >> RRS_PACKET_TYPE_SHIFT) & RRS_PACKET_TYPE_MASK) == \
250 #define RRS_RXD_IS_VALID(word) \
251 ((((word) >> RRS_RXD_UPDATED_SHIFT) & RRS_RXD_UPDATED_MASK) == 1)
253 #define RRS_PACKET_PROT_IS_IPV4_ONLY(word) \
254 ((((word) >> RRS_PROT_ID_SHIFT) & RRS_PROT_ID_MASK) == 1)
255 #define RRS_PACKET_PROT_IS_IPV6_ONLY(word) \
256 ((((word) >> RRS_PROT_ID_SHIFT) & RRS_PROT_ID_MASK) == 6)
394 #define MEDIA_TYPE_AUTO_SENSOR 0
395 #define MEDIA_TYPE_100M_FULL 1
396 #define MEDIA_TYPE_100M_HALF 2
397 #define MEDIA_TYPE_10M_FULL 3
398 #define MEDIA_TYPE_10M_HALF 4
408 #define ATL1C_INTR_CLEAR_ON_READ 0x0001
409 #define ATL1C_INTR_MODRT_ENABLE 0x0002
410 #define ATL1C_CMB_ENABLE 0x0004
411 #define ATL1C_SMB_ENABLE 0x0010
412 #define ATL1C_TXQ_MODE_ENHANCE 0x0020
413 #define ATL1C_RX_IPV6_CHKSUM 0x0040
414 #define ATL1C_ASPM_L0S_SUPPORT 0x0080
415 #define ATL1C_ASPM_L1_SUPPORT 0x0100
416 #define ATL1C_ASPM_CTRL_MON 0x0200
417 #define ATL1C_HIB_DISABLE 0x0400
418 #define ATL1C_APS_MODE_ENABLE 0x0800
419 #define ATL1C_LINK_EXT_SYNC 0x1000
420 #define ATL1C_CLK_GATING_EN 0x2000
421 #define ATL1C_FPGA_VERSION 0x8000
423 #define ATL1C_LINK_CAP_1000M 0x0001
460 #define ATL1C_BUFFER_FREE 0x0001
461 #define ATL1C_BUFFER_BUSY 0x0002
462 #define ATL1C_BUFFER_STATE_MASK 0x0003
464 #define ATL1C_PCIMAP_SINGLE 0x0004
465 #define ATL1C_PCIMAP_PAGE 0x0008
466 #define ATL1C_PCIMAP_TYPE_MASK 0x000C
468 #define ATL1C_PCIMAP_TODEVICE 0x0010
469 #define ATL1C_PCIMAP_FROMDEVICE 0x0020
470 #define ATL1C_PCIMAP_DIRECTION_MASK 0x0030
474 #define ATL1C_SET_BUFFER_STATE(buff, state) do { \
475 ((buff)->flags) &= ~ATL1C_BUFFER_STATE_MASK; \
476 ((buff)->flags) |= (state); \
479 #define ATL1C_SET_PCIMAP_TYPE(buff, type, direction) do { \
480 ((buff)->flags) &= ~ATL1C_PCIMAP_TYPE_MASK; \
481 ((buff)->flags) |= (type); \
482 ((buff)->flags) &= ~ATL1C_PCIMAP_DIRECTION_MASK; \
483 ((buff)->flags) |= (direction); \
529 #define __AT_TESTING 0x0001
530 #define __AT_RESETTING 0x0002
531 #define __AT_DOWN 0x0003
533 #define ATL1C_WORK_EVENT_RESET 0
534 #define ATL1C_WORK_EVENT_LINK_CHANGE 1
558 #define AT_WRITE_REG(a, reg, value) ( \
559 writel((value), ((a)->hw_addr + reg)))
561 #define AT_WRITE_FLUSH(a) (\
564 #define AT_READ_REG(a, reg, pdata) do { \
565 if (unlikely((a)->hibernate)) { \
566 readl((a)->hw_addr + reg); \
567 *(u32 *)pdata = readl((a)->hw_addr + reg); \
569 *(u32 *)pdata = readl((a)->hw_addr + reg); \
573 #define AT_WRITE_REGB(a, reg, value) (\
574 writeb((value), ((a)->hw_addr + reg)))
576 #define AT_READ_REGB(a, reg) (\
577 readb((a)->hw_addr + reg))
579 #define AT_WRITE_REGW(a, reg, value) (\
580 writew((value), ((a)->hw_addr + reg)))
582 #define AT_READ_REGW(a, reg, pdata) do { \
583 if (unlikely((a)->hibernate)) { \
584 readw((a)->hw_addr + reg); \
585 *(u16 *)pdata = readw((a)->hw_addr + reg); \
587 *(u16 *)pdata = readw((a)->hw_addr + reg); \
591 #define AT_WRITE_REG_ARRAY(a, reg, offset, value) ( \
592 writel((value), (((a)->hw_addr + reg) + ((offset) << 2))))
594 #define AT_READ_REG_ARRAY(a, reg, offset) ( \
595 readl(((a)->hw_addr + reg) + ((offset) << 2)))