This source file includes following definitions.
- slic_read
- slic_write
- slic_flush_write
1
2
3 #ifndef _SLIC_H
4 #define _SLIC_H
5
6 #include <linux/types.h>
7 #include <linux/netdevice.h>
8 #include <linux/spinlock_types.h>
9 #include <linux/dma-mapping.h>
10 #include <linux/pci.h>
11 #include <linux/list.h>
12 #include <linux/u64_stats_sync.h>
13
14 #define SLIC_VGBSTAT_XPERR 0x40000000
15 #define SLIC_VGBSTAT_XERRSHFT 25
16 #define SLIC_VGBSTAT_XCSERR 0x23
17 #define SLIC_VGBSTAT_XUFLOW 0x22
18 #define SLIC_VGBSTAT_XHLEN 0x20
19 #define SLIC_VGBSTAT_NETERR 0x01000000
20 #define SLIC_VGBSTAT_NERRSHFT 16
21 #define SLIC_VGBSTAT_NERRMSK 0x1ff
22 #define SLIC_VGBSTAT_NCSERR 0x103
23 #define SLIC_VGBSTAT_NUFLOW 0x102
24 #define SLIC_VGBSTAT_NHLEN 0x100
25 #define SLIC_VGBSTAT_LNKERR 0x00000080
26 #define SLIC_VGBSTAT_LERRMSK 0xff
27 #define SLIC_VGBSTAT_LDEARLY 0x86
28 #define SLIC_VGBSTAT_LBOFLO 0x85
29 #define SLIC_VGBSTAT_LCODERR 0x84
30 #define SLIC_VGBSTAT_LDBLNBL 0x83
31 #define SLIC_VGBSTAT_LCRCERR 0x82
32 #define SLIC_VGBSTAT_LOFLO 0x81
33 #define SLIC_VGBSTAT_LUFLO 0x80
34
35 #define SLIC_IRHDDR_FLEN_MSK 0x0000ffff
36 #define SLIC_IRHDDR_SVALID 0x80000000
37 #define SLIC_IRHDDR_ERR 0x10000000
38
39 #define SLIC_VRHSTAT_802OE 0x80000000
40 #define SLIC_VRHSTAT_TPOFLO 0x10000000
41 #define SLIC_VRHSTATB_802UE 0x80000000
42 #define SLIC_VRHSTATB_RCVE 0x40000000
43 #define SLIC_VRHSTATB_BUFF 0x20000000
44 #define SLIC_VRHSTATB_CARRE 0x08000000
45 #define SLIC_VRHSTATB_LONGE 0x02000000
46 #define SLIC_VRHSTATB_PREA 0x01000000
47 #define SLIC_VRHSTATB_CRC 0x00800000
48 #define SLIC_VRHSTATB_DRBL 0x00400000
49 #define SLIC_VRHSTATB_CODE 0x00200000
50 #define SLIC_VRHSTATB_TPCSUM 0x00100000
51 #define SLIC_VRHSTATB_TPHLEN 0x00080000
52 #define SLIC_VRHSTATB_IPCSUM 0x00040000
53 #define SLIC_VRHSTATB_IPLERR 0x00020000
54 #define SLIC_VRHSTATB_IPHERR 0x00010000
55
56 #define SLIC_CMD_XMT_REQ 0x01
57 #define SLIC_CMD_TYPE_DUMB 3
58
59 #define SLIC_RESET_MAGIC 0xDEAD
60 #define SLIC_ICR_INT_OFF 0
61 #define SLIC_ICR_INT_ON 1
62 #define SLIC_ICR_INT_MASK 2
63
64 #define SLIC_ISR_ERR 0x80000000
65 #define SLIC_ISR_RCV 0x40000000
66 #define SLIC_ISR_CMD 0x20000000
67 #define SLIC_ISR_IO 0x60000000
68 #define SLIC_ISR_UPC 0x10000000
69 #define SLIC_ISR_LEVENT 0x08000000
70 #define SLIC_ISR_RMISS 0x02000000
71 #define SLIC_ISR_UPCERR 0x01000000
72 #define SLIC_ISR_XDROP 0x00800000
73 #define SLIC_ISR_UPCBSY 0x00020000
74
75 #define SLIC_ISR_PING_MASK 0x00700000
76 #define SLIC_ISR_UPCERR_MASK (SLIC_ISR_UPCERR | SLIC_ISR_UPCBSY)
77 #define SLIC_ISR_UPC_MASK (SLIC_ISR_UPC | SLIC_ISR_UPCERR_MASK)
78 #define SLIC_WCS_START 0x80000000
79 #define SLIC_WCS_COMPARE 0x40000000
80 #define SLIC_RCVWCS_BEGIN 0x40000000
81 #define SLIC_RCVWCS_FINISH 0x80000000
82
83 #define SLIC_MIICR_REG_16 0x00100000
84 #define SLIC_MRV_REG16_XOVERON 0x0068
85
86 #define SLIC_GIG_LINKUP 0x0001
87 #define SLIC_GIG_FULLDUPLEX 0x0002
88 #define SLIC_GIG_SPEED_MASK 0x000C
89 #define SLIC_GIG_SPEED_1000 0x0008
90 #define SLIC_GIG_SPEED_100 0x0004
91 #define SLIC_GIG_SPEED_10 0x0000
92
93 #define SLIC_GMCR_RESET 0x80000000
94 #define SLIC_GMCR_GBIT 0x20000000
95 #define SLIC_GMCR_FULLD 0x10000000
96 #define SLIC_GMCR_GAPBB_SHIFT 14
97 #define SLIC_GMCR_GAPR1_SHIFT 7
98 #define SLIC_GMCR_GAPR2_SHIFT 0
99 #define SLIC_GMCR_GAPBB_1000 0x60
100 #define SLIC_GMCR_GAPR1_1000 0x2C
101 #define SLIC_GMCR_GAPR2_1000 0x40
102 #define SLIC_GMCR_GAPBB_100 0x70
103 #define SLIC_GMCR_GAPR1_100 0x2C
104 #define SLIC_GMCR_GAPR2_100 0x40
105
106 #define SLIC_XCR_RESET 0x80000000
107 #define SLIC_XCR_XMTEN 0x40000000
108 #define SLIC_XCR_PAUSEEN 0x20000000
109 #define SLIC_XCR_LOADRNG 0x10000000
110
111 #define SLIC_GXCR_RESET 0x80000000
112 #define SLIC_GXCR_XMTEN 0x40000000
113 #define SLIC_GXCR_PAUSEEN 0x20000000
114
115 #define SLIC_GRCR_RESET 0x80000000
116 #define SLIC_GRCR_RCVEN 0x40000000
117 #define SLIC_GRCR_RCVALL 0x20000000
118 #define SLIC_GRCR_RCVBAD 0x10000000
119 #define SLIC_GRCR_CTLEN 0x08000000
120 #define SLIC_GRCR_ADDRAEN 0x02000000
121 #define SLIC_GRCR_HASHSIZE_SHIFT 17
122 #define SLIC_GRCR_HASHSIZE 14
123
124
125 #define SLIC_REG_RESET 0x0000
126
127 #define SLIC_REG_ICR 0x0008
128
129 #define SLIC_REG_ISP 0x0010
130
131 #define SLIC_REG_ISR 0x0018
132
133
134
135
136
137 #define SLIC_REG_HBAR 0x0020
138
139
140
141 #define SLIC_REG_DBAR 0x0028
142
143
144
145
146
147
148 #define SLIC_REG_CBAR 0x0030
149
150 #define SLIC_REG_WCS 0x0034
151
152
153
154
155
156 #define SLIC_REG_RBAR 0x0038
157
158 #define SLIC_REG_RSTAT 0x0040
159
160 #define SLIC_REG_LSTAT 0x0048
161
162 #define SLIC_REG_WMCFG 0x0050
163
164 #define SLIC_REG_WPHY 0x0058
165
166 #define SLIC_REG_RCBAR 0x0060
167
168 #define SLIC_REG_RCONFIG 0x0068
169
170 #define SLIC_REG_INTAGG 0x0070
171
172 #define SLIC_REG_WXCFG 0x0078
173
174 #define SLIC_REG_WRCFG 0x0080
175
176 #define SLIC_REG_WRADDRAL 0x0088
177
178 #define SLIC_REG_WRADDRAH 0x0090
179
180 #define SLIC_REG_WRADDRBL 0x0098
181
182 #define SLIC_REG_WRADDRBH 0x00a0
183
184 #define SLIC_REG_MCASTLOW 0x00a8
185
186 #define SLIC_REG_MCASTHIGH 0x00b0
187
188 #define SLIC_REG_PING 0x00b8
189
190 #define SLIC_REG_DUMP_CMD 0x00c0
191
192 #define SLIC_REG_DUMP_DATA 0x00c8
193
194 #define SLIC_REG_PCISTATUS 0x00d0
195
196 #define SLIC_REG_WRHOSTID 0x00d8
197
198 #define SLIC_REG_LOW_POWER 0x00e0
199
200 #define SLIC_REG_QUIESCE 0x00e8
201
202 #define SLIC_REG_RESET_IFACE 0x00f0
203
204
205
206 #define SLIC_REG_ADDR_UPPER 0x00f8
207
208 #define SLIC_REG_HBAR64 0x0100
209
210 #define SLIC_REG_DBAR64 0x0108
211
212 #define SLIC_REG_CBAR64 0x0110
213
214 #define SLIC_REG_RBAR64 0x0118
215
216 #define SLIC_REG_RCBAR64 0x0120
217
218 #define SLIC_REG_RSTAT64 0x0128
219
220 #define SLIC_REG_RCV_WCS 0x0130
221
222 #define SLIC_REG_WRVLANID 0x0138
223
224 #define SLIC_REG_READ_XF_INFO 0x0140
225
226 #define SLIC_REG_WRITE_XF_INFO 0x0148
227
228 #define SLIC_REG_TICKS_PER_SEC 0x0170
229 #define SLIC_REG_HOSTID 0x1554
230
231 #define PCI_VENDOR_ID_ALACRITECH 0x139A
232 #define PCI_DEVICE_ID_ALACRITECH_MOJAVE 0x0005
233 #define PCI_SUBDEVICE_ID_ALACRITECH_1000X1 0x0005
234 #define PCI_SUBDEVICE_ID_ALACRITECH_1000X1_2 0x0006
235 #define PCI_SUBDEVICE_ID_ALACRITECH_1000X1F 0x0007
236 #define PCI_SUBDEVICE_ID_ALACRITECH_CICADA 0x0008
237 #define PCI_SUBDEVICE_ID_ALACRITECH_SES1001T 0x2006
238 #define PCI_SUBDEVICE_ID_ALACRITECH_SES1001F 0x2007
239 #define PCI_DEVICE_ID_ALACRITECH_OASIS 0x0007
240 #define PCI_SUBDEVICE_ID_ALACRITECH_SEN2002XT 0x000B
241 #define PCI_SUBDEVICE_ID_ALACRITECH_SEN2002XF 0x000C
242 #define PCI_SUBDEVICE_ID_ALACRITECH_SEN2001XT 0x000D
243 #define PCI_SUBDEVICE_ID_ALACRITECH_SEN2001XF 0x000E
244 #define PCI_SUBDEVICE_ID_ALACRITECH_SEN2104EF 0x000F
245 #define PCI_SUBDEVICE_ID_ALACRITECH_SEN2104ET 0x0010
246 #define PCI_SUBDEVICE_ID_ALACRITECH_SEN2102EF 0x0011
247 #define PCI_SUBDEVICE_ID_ALACRITECH_SEN2102ET 0x0012
248
249
250 #define SLIC_NUM_RX_LES 256
251 #define SLIC_RX_BUFF_SIZE 2048
252 #define SLIC_RX_BUFF_ALIGN 256
253 #define SLIC_RX_BUFF_HDR_SIZE 34
254 #define SLIC_MAX_REQ_RX_DESCS 1
255
256 #define SLIC_NUM_TX_DESCS 256
257 #define SLIC_TX_DESC_ALIGN 32
258 #define SLIC_MIN_TX_WAKEUP_DESCS 10
259 #define SLIC_MAX_REQ_TX_DESCS 1
260 #define SLIC_MAX_TX_COMPLETIONS 100
261
262 #define SLIC_NUM_STAT_DESCS 128
263 #define SLIC_STATS_DESC_ALIGN 256
264
265 #define SLIC_NUM_STAT_DESC_ARRAYS 4
266 #define SLIC_INVALID_STAT_DESC_IDX 0xffffffff
267
268 #define SLIC_NAPI_WEIGHT 64
269
270 #define SLIC_UPR_LSTAT 0
271 #define SLIC_UPR_CONFIG 1
272
273 #define SLIC_EEPROM_SIZE 128
274 #define SLIC_EEPROM_MAGIC 0xa5a5
275
276 #define SLIC_FIRMWARE_MOJAVE "slicoss/gbdownload.sys"
277 #define SLIC_FIRMWARE_OASIS "slicoss/oasisdownload.sys"
278 #define SLIC_RCV_FIRMWARE_MOJAVE "slicoss/gbrcvucode.sys"
279 #define SLIC_RCV_FIRMWARE_OASIS "slicoss/oasisrcvucode.sys"
280 #define SLIC_FIRMWARE_MIN_SIZE 64
281 #define SLIC_FIRMWARE_MAX_SECTIONS 3
282
283 #define SLIC_MODEL_MOJAVE 0
284 #define SLIC_MODEL_OASIS 1
285
286 #define SLIC_INC_STATS_COUNTER(st, counter) \
287 do { \
288 u64_stats_update_begin(&(st)->syncp); \
289 (st)->counter++; \
290 u64_stats_update_end(&(st)->syncp); \
291 } while (0)
292
293 #define SLIC_GET_STATS_COUNTER(newst, st, counter) \
294 { \
295 unsigned int start; \
296 do { \
297 start = u64_stats_fetch_begin_irq(&(st)->syncp); \
298 newst = (st)->counter; \
299 } while (u64_stats_fetch_retry_irq(&(st)->syncp, start)); \
300 }
301
302 struct slic_upr {
303 dma_addr_t paddr;
304 unsigned int type;
305 struct list_head list;
306 };
307
308 struct slic_upr_list {
309 bool pending;
310 struct list_head list;
311
312 spinlock_t lock;
313 };
314
315
316 struct slic_mojave_eeprom {
317 __le16 id;
318 __le16 eeprom_code_size;
319 __le16 flash_size;
320 __le16 eeprom_size;
321 __le16 vendor_id;
322 __le16 dev_id;
323 u8 rev_id;
324 u8 class_code[3];
325 u8 irqpin_dbg;
326 u8 irqpin;
327 u8 min_grant;
328 u8 max_lat;
329 __le16 pci_stat;
330 __le16 sub_vendor_id;
331 __le16 sub_id;
332 __le16 dev_id_dbg;
333 __le16 ramrom;
334 __le16 dram_size2pci;
335 __le16 rom_size2pci;
336 u8 pad[2];
337 u8 freetime;
338 u8 ifctrl;
339 __le16 dram_size;
340 u8 mac[ETH_ALEN];
341 u8 mac2[ETH_ALEN];
342 u8 pad2[6];
343 u16 dev_id2;
344 u8 irqpin2;
345 u8 class_code2[3];
346 u16 cfg_byte6;
347 u16 pme_cap;
348 u16 nwclk_ctrl;
349 u8 fru_format;
350 u8 fru_assembly[6];
351 u8 fru_rev[2];
352 u8 fru_serial[14];
353 u8 fru_pad[3];
354 u8 oem_fru[28];
355 u8 pad3[4];
356
357
358
359 };
360
361
362 struct slic_oasis_eeprom {
363 __le16 id;
364 __le16 eeprom_code_size;
365 __le16 spidev0_cfg;
366 __le16 spidev1_cfg;
367 __le16 vendor_id;
368 __le16 dev_id;
369 u8 rev_id;
370 u8 class_code0[3];
371 u8 irqpin1;
372 u8 class_code1[3];
373 u8 irqpin2;
374 u8 irqpin0;
375 u8 min_grant;
376 u8 max_lat;
377 __le16 sub_vendor_id;
378 __le16 sub_id;
379 __le16 flash_size;
380 __le16 dram_size2pci;
381 __le16 rom_size2pci;
382
383
384 __le16 dev_id1;
385 __le16 dev_id2;
386 __le16 dev_stat_cfg;
387 __le16 pme_cap;
388 u8 msi_cap;
389 u8 clock_div;
390 __le16 pci_stat_lo;
391 __le16 pci_stat_hi;
392 __le16 dram_cfg_lo;
393 __le16 dram_cfg_hi;
394 __le16 dram_size;
395 __le16 gpio_tbi_ctrl;
396 __le16 eeprom_size;
397 u8 mac[ETH_ALEN];
398 u8 mac2[ETH_ALEN];
399 u8 fru_format;
400 u8 fru_assembly[6];
401 u8 fru_rev[2];
402 u8 fru_serial[14];
403 u8 fru_pad[3];
404 u8 oem_fru[28];
405 u8 pad[4];
406
407
408
409 };
410
411 struct slic_stats {
412 u64 rx_packets;
413 u64 rx_bytes;
414 u64 rx_mcasts;
415 u64 rx_errors;
416 u64 tx_packets;
417 u64 tx_bytes;
418
419 u64 rx_buff_miss;
420 u64 tx_dropped;
421 u64 irq_errs;
422
423 u64 rx_tpcsum;
424 u64 rx_tpoflow;
425 u64 rx_tphlen;
426
427 u64 rx_ipcsum;
428 u64 rx_iplen;
429 u64 rx_iphlen;
430
431 u64 rx_early;
432 u64 rx_buffoflow;
433 u64 rx_lcode;
434 u64 rx_drbl;
435 u64 rx_crc;
436 u64 rx_oflow802;
437 u64 rx_uflow802;
438
439 u64 tx_carrier;
440 struct u64_stats_sync syncp;
441 };
442
443 struct slic_shmem_data {
444 __le32 isr;
445 __le32 link;
446 };
447
448 struct slic_shmem {
449 dma_addr_t isr_paddr;
450 dma_addr_t link_paddr;
451 struct slic_shmem_data *shmem_data;
452 };
453
454 struct slic_rx_info_oasis {
455 __le32 frame_status;
456 __le32 frame_status_b;
457 __le32 time_stamp;
458 __le32 checksum;
459 };
460
461 struct slic_rx_info_mojave {
462 __le32 frame_status;
463 __le16 byte_cnt;
464 __le16 tp_chksum;
465 __le16 ctx_hash;
466 __le16 mac_hash;
467 __le16 buff_lnk;
468 };
469
470 struct slic_stat_desc {
471 __le32 hnd;
472 __u8 pad[8];
473 __le32 status;
474 __u8 pad2[16];
475 };
476
477 struct slic_stat_queue {
478 struct slic_stat_desc *descs[SLIC_NUM_STAT_DESC_ARRAYS];
479 dma_addr_t paddr[SLIC_NUM_STAT_DESC_ARRAYS];
480 unsigned int addr_offset[SLIC_NUM_STAT_DESC_ARRAYS];
481 unsigned int active_array;
482 unsigned int len;
483 unsigned int done_idx;
484 size_t mem_size;
485 };
486
487 struct slic_tx_desc {
488 __le32 hnd;
489 __le32 rsvd;
490 u8 cmd;
491 u8 flags;
492 __le16 rsvd2;
493 __le32 totlen;
494 __le32 paddrl;
495 __le32 paddrh;
496 __le32 len;
497 __le32 type;
498 };
499
500 struct slic_tx_buffer {
501 struct sk_buff *skb;
502 DEFINE_DMA_UNMAP_ADDR(map_addr);
503 DEFINE_DMA_UNMAP_LEN(map_len);
504 struct slic_tx_desc *desc;
505 dma_addr_t desc_paddr;
506 };
507
508 struct slic_tx_queue {
509 struct dma_pool *dma_pool;
510 struct slic_tx_buffer *txbuffs;
511 unsigned int len;
512 unsigned int put_idx;
513 unsigned int done_idx;
514 };
515
516 struct slic_rx_desc {
517 u8 pad[16];
518 __le32 buffer;
519 __le32 length;
520 __le32 status;
521 };
522
523 struct slic_rx_buffer {
524 struct sk_buff *skb;
525 DEFINE_DMA_UNMAP_ADDR(map_addr);
526 DEFINE_DMA_UNMAP_LEN(map_len);
527 unsigned int addr_offset;
528 };
529
530 struct slic_rx_queue {
531 struct slic_rx_buffer *rxbuffs;
532 unsigned int len;
533 unsigned int done_idx;
534 unsigned int put_idx;
535 };
536
537 struct slic_device {
538 struct pci_dev *pdev;
539 struct net_device *netdev;
540 void __iomem *regs;
541
542 spinlock_t upper_lock;
543 struct slic_shmem shmem;
544 struct napi_struct napi;
545 struct slic_rx_queue rxq;
546 struct slic_tx_queue txq;
547 struct slic_stat_queue stq;
548 struct slic_stats stats;
549 struct slic_upr_list upr_list;
550
551 spinlock_t link_lock;
552 bool promisc;
553 int speed;
554 unsigned int duplex;
555 bool is_fiber;
556 unsigned char model;
557 };
558
559 static inline u32 slic_read(struct slic_device *sdev, unsigned int reg)
560 {
561 return ioread32(sdev->regs + reg);
562 }
563
564 static inline void slic_write(struct slic_device *sdev, unsigned int reg,
565 u32 val)
566 {
567 iowrite32(val, sdev->regs + reg);
568 }
569
570 static inline void slic_flush_write(struct slic_device *sdev)
571 {
572 (void)ioread32(sdev->regs + SLIC_REG_HOSTID);
573 }
574
575 #endif