slic.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _SLIC_H
  3. #define _SLIC_H
  4. #include <linux/types.h>
  5. #include <linux/netdevice.h>
  6. #include <linux/spinlock_types.h>
  7. #include <linux/dma-mapping.h>
  8. #include <linux/pci.h>
  9. #include <linux/list.h>
  10. #include <linux/u64_stats_sync.h>
  11. #define SLIC_VGBSTAT_XPERR 0x40000000
  12. #define SLIC_VGBSTAT_XERRSHFT 25
  13. #define SLIC_VGBSTAT_XCSERR 0x23
  14. #define SLIC_VGBSTAT_XUFLOW 0x22
  15. #define SLIC_VGBSTAT_XHLEN 0x20
  16. #define SLIC_VGBSTAT_NETERR 0x01000000
  17. #define SLIC_VGBSTAT_NERRSHFT 16
  18. #define SLIC_VGBSTAT_NERRMSK 0x1ff
  19. #define SLIC_VGBSTAT_NCSERR 0x103
  20. #define SLIC_VGBSTAT_NUFLOW 0x102
  21. #define SLIC_VGBSTAT_NHLEN 0x100
  22. #define SLIC_VGBSTAT_LNKERR 0x00000080
  23. #define SLIC_VGBSTAT_LERRMSK 0xff
  24. #define SLIC_VGBSTAT_LDEARLY 0x86
  25. #define SLIC_VGBSTAT_LBOFLO 0x85
  26. #define SLIC_VGBSTAT_LCODERR 0x84
  27. #define SLIC_VGBSTAT_LDBLNBL 0x83
  28. #define SLIC_VGBSTAT_LCRCERR 0x82
  29. #define SLIC_VGBSTAT_LOFLO 0x81
  30. #define SLIC_VGBSTAT_LUFLO 0x80
  31. #define SLIC_IRHDDR_FLEN_MSK 0x0000ffff
  32. #define SLIC_IRHDDR_SVALID 0x80000000
  33. #define SLIC_IRHDDR_ERR 0x10000000
  34. #define SLIC_VRHSTAT_802OE 0x80000000
  35. #define SLIC_VRHSTAT_TPOFLO 0x10000000
  36. #define SLIC_VRHSTATB_802UE 0x80000000
  37. #define SLIC_VRHSTATB_RCVE 0x40000000
  38. #define SLIC_VRHSTATB_BUFF 0x20000000
  39. #define SLIC_VRHSTATB_CARRE 0x08000000
  40. #define SLIC_VRHSTATB_LONGE 0x02000000
  41. #define SLIC_VRHSTATB_PREA 0x01000000
  42. #define SLIC_VRHSTATB_CRC 0x00800000
  43. #define SLIC_VRHSTATB_DRBL 0x00400000
  44. #define SLIC_VRHSTATB_CODE 0x00200000
  45. #define SLIC_VRHSTATB_TPCSUM 0x00100000
  46. #define SLIC_VRHSTATB_TPHLEN 0x00080000
  47. #define SLIC_VRHSTATB_IPCSUM 0x00040000
  48. #define SLIC_VRHSTATB_IPLERR 0x00020000
  49. #define SLIC_VRHSTATB_IPHERR 0x00010000
  50. #define SLIC_CMD_XMT_REQ 0x01
  51. #define SLIC_CMD_TYPE_DUMB 3
  52. #define SLIC_RESET_MAGIC 0xDEAD
  53. #define SLIC_ICR_INT_OFF 0
  54. #define SLIC_ICR_INT_ON 1
  55. #define SLIC_ICR_INT_MASK 2
  56. #define SLIC_ISR_ERR 0x80000000
  57. #define SLIC_ISR_RCV 0x40000000
  58. #define SLIC_ISR_CMD 0x20000000
  59. #define SLIC_ISR_IO 0x60000000
  60. #define SLIC_ISR_UPC 0x10000000
  61. #define SLIC_ISR_LEVENT 0x08000000
  62. #define SLIC_ISR_RMISS 0x02000000
  63. #define SLIC_ISR_UPCERR 0x01000000
  64. #define SLIC_ISR_XDROP 0x00800000
  65. #define SLIC_ISR_UPCBSY 0x00020000
  66. #define SLIC_ISR_PING_MASK 0x00700000
  67. #define SLIC_ISR_UPCERR_MASK (SLIC_ISR_UPCERR | SLIC_ISR_UPCBSY)
  68. #define SLIC_ISR_UPC_MASK (SLIC_ISR_UPC | SLIC_ISR_UPCERR_MASK)
  69. #define SLIC_WCS_START 0x80000000
  70. #define SLIC_WCS_COMPARE 0x40000000
  71. #define SLIC_RCVWCS_BEGIN 0x40000000
  72. #define SLIC_RCVWCS_FINISH 0x80000000
  73. #define SLIC_MIICR_REG_16 0x00100000
  74. #define SLIC_MRV_REG16_XOVERON 0x0068
  75. #define SLIC_GIG_LINKUP 0x0001
  76. #define SLIC_GIG_FULLDUPLEX 0x0002
  77. #define SLIC_GIG_SPEED_MASK 0x000C
  78. #define SLIC_GIG_SPEED_1000 0x0008
  79. #define SLIC_GIG_SPEED_100 0x0004
  80. #define SLIC_GIG_SPEED_10 0x0000
  81. #define SLIC_GMCR_RESET 0x80000000
  82. #define SLIC_GMCR_GBIT 0x20000000
  83. #define SLIC_GMCR_FULLD 0x10000000
  84. #define SLIC_GMCR_GAPBB_SHIFT 14
  85. #define SLIC_GMCR_GAPR1_SHIFT 7
  86. #define SLIC_GMCR_GAPR2_SHIFT 0
  87. #define SLIC_GMCR_GAPBB_1000 0x60
  88. #define SLIC_GMCR_GAPR1_1000 0x2C
  89. #define SLIC_GMCR_GAPR2_1000 0x40
  90. #define SLIC_GMCR_GAPBB_100 0x70
  91. #define SLIC_GMCR_GAPR1_100 0x2C
  92. #define SLIC_GMCR_GAPR2_100 0x40
  93. #define SLIC_XCR_RESET 0x80000000
  94. #define SLIC_XCR_XMTEN 0x40000000
  95. #define SLIC_XCR_PAUSEEN 0x20000000
  96. #define SLIC_XCR_LOADRNG 0x10000000
  97. #define SLIC_GXCR_RESET 0x80000000
  98. #define SLIC_GXCR_XMTEN 0x40000000
  99. #define SLIC_GXCR_PAUSEEN 0x20000000
  100. #define SLIC_GRCR_RESET 0x80000000
  101. #define SLIC_GRCR_RCVEN 0x40000000
  102. #define SLIC_GRCR_RCVALL 0x20000000
  103. #define SLIC_GRCR_RCVBAD 0x10000000
  104. #define SLIC_GRCR_CTLEN 0x08000000
  105. #define SLIC_GRCR_ADDRAEN 0x02000000
  106. #define SLIC_GRCR_HASHSIZE_SHIFT 17
  107. #define SLIC_GRCR_HASHSIZE 14
  108. /* Reset Register */
  109. #define SLIC_REG_RESET 0x0000
  110. /* Interrupt Control Register */
  111. #define SLIC_REG_ICR 0x0008
  112. /* Interrupt status pointer */
  113. #define SLIC_REG_ISP 0x0010
  114. /* Interrupt status */
  115. #define SLIC_REG_ISR 0x0018
  116. /* Header buffer address reg
  117. * 31-8 - phy addr of set of contiguous hdr buffers
  118. * 7-0 - number of buffers passed
  119. * Buffers are 256 bytes long on 256-byte boundaries.
  120. */
  121. #define SLIC_REG_HBAR 0x0020
  122. /* Data buffer handle & address reg
  123. * 4 sets of registers; Buffers are 2K bytes long 2 per 4K page.
  124. */
  125. #define SLIC_REG_DBAR 0x0028
  126. /* Xmt Cmd buf addr regs.
  127. * 1 per XMT interface
  128. * 31-5 - phy addr of host command buffer
  129. * 4-0 - length of cmd in multiples of 32 bytes
  130. * Buffers are 32 bytes up to 512 bytes long
  131. */
  132. #define SLIC_REG_CBAR 0x0030
  133. /* Write control store */
  134. #define SLIC_REG_WCS 0x0034
  135. /*Response buffer address reg.
  136. * 31-8 - phy addr of set of contiguous response buffers
  137. * 7-0 - number of buffers passed
  138. * Buffers are 32 bytes long on 32-byte boundaries.
  139. */
  140. #define SLIC_REG_RBAR 0x0038
  141. /* Read statistics (UPR) */
  142. #define SLIC_REG_RSTAT 0x0040
  143. /* Read link status */
  144. #define SLIC_REG_LSTAT 0x0048
  145. /* Write Mac Config */
  146. #define SLIC_REG_WMCFG 0x0050
  147. /* Write phy register */
  148. #define SLIC_REG_WPHY 0x0058
  149. /* Rcv Cmd buf addr reg */
  150. #define SLIC_REG_RCBAR 0x0060
  151. /* Read SLIC Config*/
  152. #define SLIC_REG_RCONFIG 0x0068
  153. /* Interrupt aggregation time */
  154. #define SLIC_REG_INTAGG 0x0070
  155. /* Write XMIT config reg */
  156. #define SLIC_REG_WXCFG 0x0078
  157. /* Write RCV config reg */
  158. #define SLIC_REG_WRCFG 0x0080
  159. /* Write rcv addr a low */
  160. #define SLIC_REG_WRADDRAL 0x0088
  161. /* Write rcv addr a high */
  162. #define SLIC_REG_WRADDRAH 0x0090
  163. /* Write rcv addr b low */
  164. #define SLIC_REG_WRADDRBL 0x0098
  165. /* Write rcv addr b high */
  166. #define SLIC_REG_WRADDRBH 0x00a0
  167. /* Low bits of mcast mask */
  168. #define SLIC_REG_MCASTLOW 0x00a8
  169. /* High bits of mcast mask */
  170. #define SLIC_REG_MCASTHIGH 0x00b0
  171. /* Ping the card */
  172. #define SLIC_REG_PING 0x00b8
  173. /* Dump command */
  174. #define SLIC_REG_DUMP_CMD 0x00c0
  175. /* Dump data pointer */
  176. #define SLIC_REG_DUMP_DATA 0x00c8
  177. /* Read card's pci_status register */
  178. #define SLIC_REG_PCISTATUS 0x00d0
  179. /* Write hostid field */
  180. #define SLIC_REG_WRHOSTID 0x00d8
  181. /* Put card in a low power state */
  182. #define SLIC_REG_LOW_POWER 0x00e0
  183. /* Force slic into quiescent state before soft reset */
  184. #define SLIC_REG_QUIESCE 0x00e8
  185. /* Reset interface queues */
  186. #define SLIC_REG_RESET_IFACE 0x00f0
  187. /* Register is only written when it has changed.
  188. * Bits 63-32 for host i/f addrs.
  189. */
  190. #define SLIC_REG_ADDR_UPPER 0x00f8
  191. /* 64 bit Header buffer address reg */
  192. #define SLIC_REG_HBAR64 0x0100
  193. /* 64 bit Data buffer handle & address reg */
  194. #define SLIC_REG_DBAR64 0x0108
  195. /* 64 bit Xmt Cmd buf addr regs. */
  196. #define SLIC_REG_CBAR64 0x0110
  197. /* 64 bit Response buffer address reg.*/
  198. #define SLIC_REG_RBAR64 0x0118
  199. /* 64 bit Rcv Cmd buf addr reg*/
  200. #define SLIC_REG_RCBAR64 0x0120
  201. /* Read statistics (64 bit UPR) */
  202. #define SLIC_REG_RSTAT64 0x0128
  203. /* Download Gigabit RCV sequencer ucode */
  204. #define SLIC_REG_RCV_WCS 0x0130
  205. /* Write VlanId field */
  206. #define SLIC_REG_WRVLANID 0x0138
  207. /* Read Transformer info */
  208. #define SLIC_REG_READ_XF_INFO 0x0140
  209. /* Write Transformer info */
  210. #define SLIC_REG_WRITE_XF_INFO 0x0148
  211. /* Write card ticks per second */
  212. #define SLIC_REG_TICKS_PER_SEC 0x0170
  213. #define SLIC_REG_HOSTID 0x1554
  214. #define PCI_VENDOR_ID_ALACRITECH 0x139A
  215. #define PCI_DEVICE_ID_ALACRITECH_MOJAVE 0x0005
  216. #define PCI_SUBDEVICE_ID_ALACRITECH_1000X1 0x0005
  217. #define PCI_SUBDEVICE_ID_ALACRITECH_1000X1_2 0x0006
  218. #define PCI_SUBDEVICE_ID_ALACRITECH_1000X1F 0x0007
  219. #define PCI_SUBDEVICE_ID_ALACRITECH_CICADA 0x0008
  220. #define PCI_SUBDEVICE_ID_ALACRITECH_SES1001T 0x2006
  221. #define PCI_SUBDEVICE_ID_ALACRITECH_SES1001F 0x2007
  222. #define PCI_DEVICE_ID_ALACRITECH_OASIS 0x0007
  223. #define PCI_SUBDEVICE_ID_ALACRITECH_SEN2002XT 0x000B
  224. #define PCI_SUBDEVICE_ID_ALACRITECH_SEN2002XF 0x000C
  225. #define PCI_SUBDEVICE_ID_ALACRITECH_SEN2001XT 0x000D
  226. #define PCI_SUBDEVICE_ID_ALACRITECH_SEN2001XF 0x000E
  227. #define PCI_SUBDEVICE_ID_ALACRITECH_SEN2104EF 0x000F
  228. #define PCI_SUBDEVICE_ID_ALACRITECH_SEN2104ET 0x0010
  229. #define PCI_SUBDEVICE_ID_ALACRITECH_SEN2102EF 0x0011
  230. #define PCI_SUBDEVICE_ID_ALACRITECH_SEN2102ET 0x0012
  231. /* Note: power of two required for number descriptors */
  232. #define SLIC_NUM_RX_LES 256
  233. #define SLIC_RX_BUFF_SIZE 2048
  234. #define SLIC_RX_BUFF_ALIGN 256
  235. #define SLIC_RX_BUFF_HDR_SIZE 34
  236. #define SLIC_MAX_REQ_RX_DESCS 1
  237. #define SLIC_NUM_TX_DESCS 256
  238. #define SLIC_TX_DESC_ALIGN 32
  239. #define SLIC_MIN_TX_WAKEUP_DESCS 10
  240. #define SLIC_MAX_REQ_TX_DESCS 1
  241. #define SLIC_MAX_TX_COMPLETIONS 100
  242. #define SLIC_NUM_STAT_DESCS 128
  243. #define SLIC_STATS_DESC_ALIGN 256
  244. #define SLIC_NUM_STAT_DESC_ARRAYS 4
  245. #define SLIC_INVALID_STAT_DESC_IDX 0xffffffff
  246. #define SLIC_NAPI_WEIGHT 64
  247. #define SLIC_UPR_LSTAT 0
  248. #define SLIC_UPR_CONFIG 1
  249. #define SLIC_EEPROM_SIZE 128
  250. #define SLIC_EEPROM_MAGIC 0xa5a5
  251. #define SLIC_FIRMWARE_MOJAVE "slicoss/gbdownload.sys"
  252. #define SLIC_FIRMWARE_OASIS "slicoss/oasisdownload.sys"
  253. #define SLIC_RCV_FIRMWARE_MOJAVE "slicoss/gbrcvucode.sys"
  254. #define SLIC_RCV_FIRMWARE_OASIS "slicoss/oasisrcvucode.sys"
  255. #define SLIC_FIRMWARE_MIN_SIZE 64
  256. #define SLIC_FIRMWARE_MAX_SECTIONS 3
  257. #define SLIC_MODEL_MOJAVE 0
  258. #define SLIC_MODEL_OASIS 1
  259. #define SLIC_INC_STATS_COUNTER(st, counter) \
  260. do { \
  261. u64_stats_update_begin(&(st)->syncp); \
  262. (st)->counter++; \
  263. u64_stats_update_end(&(st)->syncp); \
  264. } while (0)
  265. #define SLIC_GET_STATS_COUNTER(newst, st, counter) \
  266. { \
  267. unsigned int start; \
  268. do { \
  269. start = u64_stats_fetch_begin_irq(&(st)->syncp); \
  270. newst = (st)->counter; \
  271. } while (u64_stats_fetch_retry_irq(&(st)->syncp, start)); \
  272. }
  273. struct slic_upr {
  274. dma_addr_t paddr;
  275. unsigned int type;
  276. struct list_head list;
  277. };
  278. struct slic_upr_list {
  279. bool pending;
  280. struct list_head list;
  281. /* upr list lock */
  282. spinlock_t lock;
  283. };
  284. /* SLIC EEPROM structure for Mojave */
  285. struct slic_mojave_eeprom {
  286. __le16 id; /* 00 EEPROM/FLASH Magic code 'A5A5'*/
  287. __le16 eeprom_code_size;/* 01 Size of EEPROM Codes (bytes * 4)*/
  288. __le16 flash_size; /* 02 Flash size */
  289. __le16 eeprom_size; /* 03 EEPROM Size */
  290. __le16 vendor_id; /* 04 Vendor ID */
  291. __le16 dev_id; /* 05 Device ID */
  292. u8 rev_id; /* 06 Revision ID */
  293. u8 class_code[3]; /* 07 Class Code */
  294. u8 irqpin_dbg; /* 08 Debug Interrupt pin */
  295. u8 irqpin; /* Network Interrupt Pin */
  296. u8 min_grant; /* 09 Minimum grant */
  297. u8 max_lat; /* Maximum Latency */
  298. __le16 pci_stat; /* 10 PCI Status */
  299. __le16 sub_vendor_id; /* 11 Subsystem Vendor Id */
  300. __le16 sub_id; /* 12 Subsystem ID */
  301. __le16 dev_id_dbg; /* 13 Debug Device Id */
  302. __le16 ramrom; /* 14 Dram/Rom function */
  303. __le16 dram_size2pci; /* 15 DRAM size to PCI (bytes * 64K) */
  304. __le16 rom_size2pci; /* 16 ROM extension size to PCI (bytes * 4k) */
  305. u8 pad[2]; /* 17 Padding */
  306. u8 freetime; /* 18 FreeTime setting */
  307. u8 ifctrl; /* 10-bit interface control (Mojave only) */
  308. __le16 dram_size; /* 19 DRAM size (bytes * 64k) */
  309. u8 mac[ETH_ALEN]; /* 20 MAC addresses */
  310. u8 mac2[ETH_ALEN];
  311. u8 pad2[6];
  312. u16 dev_id2; /* Device ID for 2nd PCI function */
  313. u8 irqpin2; /* Interrupt pin for 2nd PCI function */
  314. u8 class_code2[3]; /* Class Code for 2nd PCI function */
  315. u16 cfg_byte6; /* Config Byte 6 */
  316. u16 pme_cap; /* Power Mgment capabilities */
  317. u16 nwclk_ctrl; /* NetworkClockControls */
  318. u8 fru_format; /* Alacritech FRU format type */
  319. u8 fru_assembly[6]; /* Alacritech FRU information */
  320. u8 fru_rev[2];
  321. u8 fru_serial[14];
  322. u8 fru_pad[3];
  323. u8 oem_fru[28]; /* optional OEM FRU format type */
  324. u8 pad3[4]; /* Pad to 128 bytes - includes 2 cksum bytes
  325. * (if OEM FRU info exists) and two unusable
  326. * bytes at the end
  327. */
  328. };
  329. /* SLIC EEPROM structure for Oasis */
  330. struct slic_oasis_eeprom {
  331. __le16 id; /* 00 EEPROM/FLASH Magic code 'A5A5' */
  332. __le16 eeprom_code_size;/* 01 Size of EEPROM Codes (bytes * 4)*/
  333. __le16 spidev0_cfg; /* 02 Flash Config for SPI device 0 */
  334. __le16 spidev1_cfg; /* 03 Flash Config for SPI device 1 */
  335. __le16 vendor_id; /* 04 Vendor ID */
  336. __le16 dev_id; /* 05 Device ID (function 0) */
  337. u8 rev_id; /* 06 Revision ID */
  338. u8 class_code0[3]; /* 07 Class Code for PCI function 0 */
  339. u8 irqpin1; /* 08 Interrupt pin for PCI function 1*/
  340. u8 class_code1[3]; /* 09 Class Code for PCI function 1 */
  341. u8 irqpin2; /* 10 Interrupt pin for PCI function 2*/
  342. u8 irqpin0; /* Interrupt pin for PCI function 0*/
  343. u8 min_grant; /* 11 Minimum grant */
  344. u8 max_lat; /* Maximum Latency */
  345. __le16 sub_vendor_id; /* 12 Subsystem Vendor Id */
  346. __le16 sub_id; /* 13 Subsystem ID */
  347. __le16 flash_size; /* 14 Flash size (bytes / 4K) */
  348. __le16 dram_size2pci; /* 15 DRAM size to PCI (bytes / 64K) */
  349. __le16 rom_size2pci; /* 16 Flash (ROM extension) size to PCI
  350. * (bytes / 4K)
  351. */
  352. __le16 dev_id1; /* 17 Device Id (function 1) */
  353. __le16 dev_id2; /* 18 Device Id (function 2) */
  354. __le16 dev_stat_cfg; /* 19 Device Status Config Bytes 6-7 */
  355. __le16 pme_cap; /* 20 Power Mgment capabilities */
  356. u8 msi_cap; /* 21 MSI capabilities */
  357. u8 clock_div; /* Clock divider */
  358. __le16 pci_stat_lo; /* 22 PCI Status bits 15:0 */
  359. __le16 pci_stat_hi; /* 23 PCI Status bits 31:16 */
  360. __le16 dram_cfg_lo; /* 24 DRAM Configuration bits 15:0 */
  361. __le16 dram_cfg_hi; /* 25 DRAM Configuration bits 31:16 */
  362. __le16 dram_size; /* 26 DRAM size (bytes / 64K) */
  363. __le16 gpio_tbi_ctrl; /* 27 GPIO/TBI controls for functions 1/0 */
  364. __le16 eeprom_size; /* 28 EEPROM Size */
  365. u8 mac[ETH_ALEN]; /* 29 MAC addresses (2 ports) */
  366. u8 mac2[ETH_ALEN];
  367. u8 fru_format; /* 35 Alacritech FRU format type */
  368. u8 fru_assembly[6]; /* Alacritech FRU information */
  369. u8 fru_rev[2];
  370. u8 fru_serial[14];
  371. u8 fru_pad[3];
  372. u8 oem_fru[28]; /* optional OEM FRU information */
  373. u8 pad[4]; /* Pad to 128 bytes - includes 2 checksum bytes
  374. * (if OEM FRU info exists) and two unusable
  375. * bytes at the end
  376. */
  377. };
  378. struct slic_stats {
  379. u64 rx_packets;
  380. u64 rx_bytes;
  381. u64 rx_mcasts;
  382. u64 rx_errors;
  383. u64 tx_packets;
  384. u64 tx_bytes;
  385. /* HW STATS */
  386. u64 rx_buff_miss;
  387. u64 tx_dropped;
  388. u64 irq_errs;
  389. /* transport layer */
  390. u64 rx_tpcsum;
  391. u64 rx_tpoflow;
  392. u64 rx_tphlen;
  393. /* ip layer */
  394. u64 rx_ipcsum;
  395. u64 rx_iplen;
  396. u64 rx_iphlen;
  397. /* link layer */
  398. u64 rx_early;
  399. u64 rx_buffoflow;
  400. u64 rx_lcode;
  401. u64 rx_drbl;
  402. u64 rx_crc;
  403. u64 rx_oflow802;
  404. u64 rx_uflow802;
  405. /* oasis only */
  406. u64 tx_carrier;
  407. struct u64_stats_sync syncp;
  408. };
  409. struct slic_shmem_data {
  410. __le32 isr;
  411. __le32 link;
  412. };
  413. struct slic_shmem {
  414. dma_addr_t isr_paddr;
  415. dma_addr_t link_paddr;
  416. struct slic_shmem_data *shmem_data;
  417. };
  418. struct slic_rx_info_oasis {
  419. __le32 frame_status;
  420. __le32 frame_status_b;
  421. __le32 time_stamp;
  422. __le32 checksum;
  423. };
  424. struct slic_rx_info_mojave {
  425. __le32 frame_status;
  426. __le16 byte_cnt;
  427. __le16 tp_chksum;
  428. __le16 ctx_hash;
  429. __le16 mac_hash;
  430. __le16 buff_lnk;
  431. };
  432. struct slic_stat_desc {
  433. __le32 hnd;
  434. __u8 pad[8];
  435. __le32 status;
  436. __u8 pad2[16];
  437. };
  438. struct slic_stat_queue {
  439. struct slic_stat_desc *descs[SLIC_NUM_STAT_DESC_ARRAYS];
  440. dma_addr_t paddr[SLIC_NUM_STAT_DESC_ARRAYS];
  441. unsigned int addr_offset[SLIC_NUM_STAT_DESC_ARRAYS];
  442. unsigned int active_array;
  443. unsigned int len;
  444. unsigned int done_idx;
  445. size_t mem_size;
  446. };
  447. struct slic_tx_desc {
  448. __le32 hnd;
  449. __le32 rsvd;
  450. u8 cmd;
  451. u8 flags;
  452. __le16 rsvd2;
  453. __le32 totlen;
  454. __le32 paddrl;
  455. __le32 paddrh;
  456. __le32 len;
  457. __le32 type;
  458. };
  459. struct slic_tx_buffer {
  460. struct sk_buff *skb;
  461. DEFINE_DMA_UNMAP_ADDR(map_addr);
  462. DEFINE_DMA_UNMAP_LEN(map_len);
  463. struct slic_tx_desc *desc;
  464. dma_addr_t desc_paddr;
  465. };
  466. struct slic_tx_queue {
  467. struct dma_pool *dma_pool;
  468. struct slic_tx_buffer *txbuffs;
  469. unsigned int len;
  470. unsigned int put_idx;
  471. unsigned int done_idx;
  472. };
  473. struct slic_rx_desc {
  474. u8 pad[16];
  475. __le32 buffer;
  476. __le32 length;
  477. __le32 status;
  478. };
  479. struct slic_rx_buffer {
  480. struct sk_buff *skb;
  481. DEFINE_DMA_UNMAP_ADDR(map_addr);
  482. DEFINE_DMA_UNMAP_LEN(map_len);
  483. unsigned int addr_offset;
  484. };
  485. struct slic_rx_queue {
  486. struct slic_rx_buffer *rxbuffs;
  487. unsigned int len;
  488. unsigned int done_idx;
  489. unsigned int put_idx;
  490. };
  491. struct slic_device {
  492. struct pci_dev *pdev;
  493. struct net_device *netdev;
  494. void __iomem *regs;
  495. /* upper address setting lock */
  496. spinlock_t upper_lock;
  497. struct slic_shmem shmem;
  498. struct napi_struct napi;
  499. struct slic_rx_queue rxq;
  500. struct slic_tx_queue txq;
  501. struct slic_stat_queue stq;
  502. struct slic_stats stats;
  503. struct slic_upr_list upr_list;
  504. /* link configuration lock */
  505. spinlock_t link_lock;
  506. bool promisc;
  507. int speed;
  508. unsigned int duplex;
  509. bool is_fiber;
  510. unsigned char model;
  511. };
  512. static inline u32 slic_read(struct slic_device *sdev, unsigned int reg)
  513. {
  514. return ioread32(sdev->regs + reg);
  515. }
  516. static inline void slic_write(struct slic_device *sdev, unsigned int reg,
  517. u32 val)
  518. {
  519. iowrite32(val, sdev->regs + reg);
  520. }
  521. static inline void slic_flush_write(struct slic_device *sdev)
  522. {
  523. (void)ioread32(sdev->regs + SLIC_REG_HOSTID);
  524. }
  525. #endif /* _SLIC_H */