1 /**************************************************************************
3 * Copyright (c) 2000-2002 Alacritech, Inc. All rights reserved.
5 * $Id: slic.h,v 1.3 2006/07/14 16:43:02 mook Exp $
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY ALACRITECH, INC. ``AS IS'' AND ANY
19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ALACRITECH, INC. OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
25 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
28 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * The views and conclusions contained in the software and documentation
32 * are those of the authors and should not be interpreted as representing
33 * official policies, either expressed or implied, of Alacritech, Inc.
35 **************************************************************************/
40 * This is the base set of header definitions for the SLICOSS driver.
42 #ifndef __SLIC_DRIVER_H__
43 #define __SLIC_DRIVER_H__
46 struct slic_spinlock {
51 #define SLIC_RSPQ_PAGES_GB 10
52 #define SLIC_RSPQ_BUFSINPAGE (PAGE_SIZE / SLIC_RSPBUF_SIZE)
54 typedef struct _slic_rspqueue_t {
58 p_slic_rspbuf_t rspbuf;
59 pulong32 vaddr[SLIC_RSPQ_PAGES_GB];
60 dma_addr_t paddr[SLIC_RSPQ_PAGES_GB];
61 } slic_rspqueue_t, *p_slic_rspqueue_t;
63 #define SLIC_RCVQ_EXPANSION 1
64 #define SLIC_RCVQ_ENTRIES (256 * SLIC_RCVQ_EXPANSION)
65 #define SLIC_RCVQ_MINENTRIES (SLIC_RCVQ_ENTRIES / 2)
66 #define SLIC_RCVQ_MAX_PROCESS_ISR ((SLIC_RCVQ_ENTRIES * 4))
67 #define SLIC_RCVQ_RCVBUFSIZE 2048
68 #define SLIC_RCVQ_FILLENTRIES (16 * SLIC_RCVQ_EXPANSION)
69 #define SLIC_RCVQ_FILLTHRESH (SLIC_RCVQ_ENTRIES - SLIC_RCVQ_FILLENTRIES)
71 typedef struct _slic_rcvqueue_t {
77 } slic_rcvqueue_t, *p_slic_rcvqueue_t;
79 typedef struct _slic_rcvbuf_info_t {
86 } slic_rcvbuf_info_t, *pslic_rcvbuf_info_t;
88 SLIC Handle structure. Used to restrict handle values to
89 32 bits by using an index rather than an address.
90 Simplifies ucode in 64-bit systems
92 typedef struct _slic_handle_word_t {
96 ushort bottombits; /* to denote num bufs to card */
100 } slic_handle_word_t, *pslic_handle_word_t;
102 typedef struct _slic_handle_t {
103 slic_handle_word_t token; /* token passed between host and card*/
105 pvoid address; /* actual address of the object*/
107 struct _slic_handle_t *other_handle;
108 struct _slic_handle_t *next;
109 } slic_handle_t, *pslic_handle_t;
111 #define SLIC_HANDLE_FREE 0x0000
112 #define SLIC_HANDLE_DATA 0x0001
113 #define SLIC_HANDLE_CMD 0x0002
114 #define SLIC_HANDLE_CONTEXT 0x0003
115 #define SLIC_HANDLE_TEAM 0x0004
117 #define handle_index handle.parts.index
118 #define handle_bottom handle.parts.bottombits
119 #define handle_token handle.whole
121 #define SLIC_HOSTCMD_SIZE 512
123 typedef struct _slic_hostcmd_t {
124 slic_host64_cmd_t cmd64;
132 pslic_handle_t pslic_handle;/* handle associated with command */
133 struct _slic_hostcmd_t *next;
134 struct _slic_hostcmd_t *next_all;
135 } slic_hostcmd_t, *p_slic_hostcmd_t;
137 #define SLIC_CMDQ_CMDSINPAGE (PAGE_SIZE / SLIC_HOSTCMD_SIZE)
138 #define SLIC_CMD_DUMB 3
139 #define SLIC_CMDQ_INITCMDS 256
140 #define SLIC_CMDQ_MAXCMDS 256
141 #define SLIC_CMDQ_MAXOUTSTAND SLIC_CMDQ_MAXCMDS
142 #define SLIC_CMDQ_MAXPAGES (SLIC_CMDQ_MAXCMDS / SLIC_CMDQ_CMDSINPAGE)
143 #define SLIC_CMDQ_INITPAGES (SLIC_CMDQ_INITCMDS / SLIC_CMDQ_CMDSINPAGE)
145 typedef struct _slic_cmdqmem_t {
147 pulong32 pages[SLIC_CMDQ_MAXPAGES];
148 dma_addr_t dma_pages[SLIC_CMDQ_MAXPAGES];
149 } slic_cmdqmem_t, *p_slic_cmdqmem_t;
151 typedef struct _slic_cmdqueue_t {
152 p_slic_hostcmd_t head;
153 p_slic_hostcmd_t tail;
155 struct slic_spinlock lock;
156 } slic_cmdqueue_t, *p_slic_cmdqueue_t;
158 #ifdef STATUS_SUCCESS
159 #undef STATUS_SUCCESS
162 #define STATUS_SUCCESS 0
163 #define STATUS_PENDING 0
164 #define STATUS_FAILURE -1
165 #define STATUS_ERROR -2
166 #define STATUS_NOT_SUPPORTED -3
167 #define STATUS_BUFFER_TOO_SHORT -4
169 #define SLIC_MAX_CARDS 32
170 #define SLIC_MAX_PORTS 4 /* Max # of ports per card */
171 #if SLIC_DUMP_ENABLED
175 This cannot be bigger than the max DMA size the card supports,
176 given the current code structure in the host and ucode.
177 Mojave supports 16K, Oasis supports 16K-1, so
178 just set this at 15K, shouldnt make that much of a diff.
180 #define DUMP_BUF_SIZE 0x3C00
184 typedef struct _mcast_address_t {
186 struct _mcast_address_t *next;
187 } mcast_address_t, *p_mcast_address_t;
189 #define CARD_DOWN 0x00000000
190 #define CARD_UP 0x00000001
191 #define CARD_FAIL 0x00000002
192 #define CARD_DIAG 0x00000003
193 #define CARD_SLEEP 0x00000004
195 #define ADAPT_DOWN 0x00
196 #define ADAPT_UP 0x01
197 #define ADAPT_FAIL 0x02
198 #define ADAPT_RESET 0x03
199 #define ADAPT_SLEEP 0x04
201 #define ADAPT_FLAGS_BOOTTIME 0x0001
202 #define ADAPT_FLAGS_IS64BIT 0x0002
203 #define ADAPT_FLAGS_PENDINGLINKDOWN 0x0004
204 #define ADAPT_FLAGS_FIBERMEDIA 0x0008
205 #define ADAPT_FLAGS_LOCKS_ALLOCED 0x0010
206 #define ADAPT_FLAGS_INT_REGISTERED 0x0020
207 #define ADAPT_FLAGS_LOAD_TIMER_SET 0x0040
208 #define ADAPT_FLAGS_STATS_TIMER_SET 0x0080
209 #define ADAPT_FLAGS_RESET_TIMER_SET 0x0100
211 #define LINK_DOWN 0x00
212 #define LINK_CONFIG 0x01
215 #define LINK_10MB 0x00
216 #define LINK_100MB 0x01
217 #define LINK_AUTOSPEED 0x02
218 #define LINK_1000MB 0x03
219 #define LINK_10000MB 0x04
221 #define LINK_HALFD 0x00
222 #define LINK_FULLD 0x01
223 #define LINK_AUTOD 0x02
225 #define MAC_DIRECTED 0x00000001
226 #define MAC_BCAST 0x00000002
227 #define MAC_MCAST 0x00000004
228 #define MAC_PROMISC 0x00000008
229 #define MAC_LOOPBACK 0x00000010
230 #define MAC_ALLMCAST 0x00000020
232 #define SLIC_DUPLEX(x) ((x == LINK_FULLD) ? "FDX" : "HDX")
233 #define SLIC_SPEED(x) ((x == LINK_100MB) ? "100Mb" : ((x == LINK_1000MB) ?\
235 #define SLIC_LINKSTATE(x) ((x == LINK_DOWN) ? "Down" : "Up ")
236 #define SLIC_ADAPTER_STATE(x) ((x == ADAPT_UP) ? "UP" : "Down")
237 #define SLIC_CARD_STATE(x) ((x == CARD_UP) ? "UP" : "Down")
239 typedef struct _slic_iface_stats {
248 ulong64 xmt_discards;
249 ulong64 xmit_collisions;
250 ulong64 xmit_excess_xmit_collisions;
256 ulong64 rcv_discards;
257 } slic_iface_stats_t, *p_slic_iface_stats_t;
259 typedef struct _slic_tcp_stats {
260 ulong64 xmit_tcp_segs;
261 ulong64 xmit_tcp_bytes;
262 ulong64 rcv_tcp_segs;
263 ulong64 rcv_tcp_bytes;
264 } slic_tcp_stats_t, *p_slic_tcp_stats_t;
266 typedef struct _slicnet_stats {
267 slic_tcp_stats_t tcp;
268 slic_iface_stats_t iface;
270 } slicnet_stats_t, *p_slicnet_stats_t;
272 #define SLIC_LOADTIMER_PERIOD 1
273 #define SLIC_INTAGG_DEFAULT 200
274 #define SLIC_LOAD_0 0
275 #define SLIC_INTAGG_0 0
276 #define SLIC_LOAD_1 8000
277 #define SLIC_LOAD_2 10000
278 #define SLIC_LOAD_3 12000
279 #define SLIC_LOAD_4 14000
280 #define SLIC_LOAD_5 16000
281 #define SLIC_INTAGG_1 50
282 #define SLIC_INTAGG_2 100
283 #define SLIC_INTAGG_3 150
284 #define SLIC_INTAGG_4 200
285 #define SLIC_INTAGG_5 250
286 #define SLIC_LOAD_1GB 3000
287 #define SLIC_LOAD_2GB 6000
288 #define SLIC_LOAD_3GB 12000
289 #define SLIC_LOAD_4GB 24000
290 #define SLIC_LOAD_5GB 48000
291 #define SLIC_INTAGG_1GB 50
292 #define SLIC_INTAGG_2GB 75
293 #define SLIC_INTAGG_3GB 100
294 #define SLIC_INTAGG_4GB 100
295 #define SLIC_INTAGG_5GB 100
297 typedef struct _ether_header {
298 uchar ether_dhost[6];
299 uchar ether_shost[6];
301 } ether_header, *p_ether_header;
303 typedef struct _sliccard_t {
309 uint adapters_activated;
310 uint adapters_allocated;
311 uint adapters_sleeping;
314 ulong32 loadlevel_current;
316 uint reset_in_progress;
318 ulong32 bad_pingstatus;
319 struct timer_list loadtimer;
320 ulong32 loadtimerset;
322 slic_config_t config;
323 struct dentry *debugfs_dir;
324 struct dentry *debugfs_cardinfo;
325 struct _adapter_t *master;
326 struct _adapter_t *adapter[SLIC_MAX_PORTS];
327 struct _sliccard_t *next;
328 ulong32 error_interrupts;
329 ulong32 error_rmiss_interrupts;
330 ulong32 rcv_interrupts;
331 ulong32 xmit_interrupts;
333 ulong32 false_interrupts;
334 ulong32 max_isr_rcvs;
335 ulong32 max_isr_xmits;
336 ulong32 rcv_interrupt_yields;
338 #if SLIC_DUMP_ENABLED
339 ulong32 dumpstatus; /* Result of dump UPR */
342 ulong cmdbuffer_phys;
343 ulong32 cmdbuffer_physl;
344 ulong32 cmdbuffer_physh;
347 struct task_struct *dump_task_id;
348 ulong32 dump_wait_count;
349 uint dumpthread_running; /* has a dump thread been init'd */
350 uint dump_requested; /* 0 no, 1 = reqstd 2=curr 3=done */
351 ulong32 dumptime_start;
352 ulong32 dumptime_complete;
353 ulong32 dumptime_delta;
355 ulong dumpbuffer_phys;
356 ulong32 dumpbuffer_physl;
357 ulong32 dumpbuffer_physh;
358 wait_queue_head_t dump_wq;
359 struct file *dumphandle;
360 mm_segment_t dumpfile_fs;
364 ushort reg_offset[32];
365 ulong32 reg_value[32];
366 ulong32 reg_valueh[32];
367 } sliccard_t, *p_sliccard_t;
369 #define NUM_CFG_SPACES 2
370 #define NUM_CFG_REGS 64
371 #define NUM_CFG_REG_ULONGS (NUM_CFG_REGS / sizeof(ulong32))
373 typedef struct _physcard_t {
374 struct _adapter_t *adapter[SLIC_MAX_PORTS];
375 struct _physcard_t *next;
376 uint adapters_allocd;
378 /* the following is not currently needed
379 ulong32 bridge_busnum;
380 ulong32 bridge_cfg[NUM_CFG_SPACES][NUM_CFG_REG_ULONGS];
382 } physcard_t, *p_physcard_t;
384 typedef struct _base_driver {
385 struct slic_spinlock driver_lock;
386 ulong32 num_slic_cards;
387 ulong32 num_slic_ports;
388 ulong32 num_slic_ports_active;
389 ulong32 dynamic_intagg;
390 p_sliccard_t slic_card;
391 p_physcard_t phys_card;
392 uint cardnuminuse[SLIC_MAX_CARDS];
393 } base_driver_t, *p_base_driver_t;
395 extern base_driver_t slic_global;
397 typedef struct _slic_shmem_t {
398 volatile ulong32 isr;
399 volatile ulong32 linkstatus;
400 volatile slic_stats_t inicstats;
401 } slic_shmem_t, *p_slic_shmem_t;
403 typedef struct _slic_reg_params_t {
406 ulong32 fail_on_bad_eeprom;
407 } slic_reg_params_t, *p_reg_params_t;
409 typedef struct _slic_upr_t {
415 ulong32 upr_buffer_h;
416 struct _slic_upr_t *next;
418 } slic_upr_t, *p_slic_upr_t;
420 typedef struct _slic_ifevents_ti {
439 typedef struct _adapter_t {
443 p_physcard_t physcard;
448 struct net_device *netdev;
449 struct net_device *next_netdevice;
450 struct slic_spinlock adapter_lock;
451 struct slic_spinlock reset_lock;
452 struct pci_dev *pcidev;
460 void __iomem *memorybase;
461 ulong32 memorylength;
464 uint queues_initialized;
467 ulong32 intrregistered;
468 uint isp_initialized;
470 ulong32 curaddrupper;
471 p_slic_shmem_t pshmem;
472 dma_addr_t phys_shmem;
474 p_slic_regs_t slic_regs;
481 uchar currmacaddr[6];
483 ushort devflags_prev;
485 p_mcast_address_t mcastaddrs;
486 p_slic_upr_t upr_list;
488 struct timer_list pingtimer;
489 ulong32 pingtimerset;
490 struct timer_list statstimer;
491 ulong32 statstimerset;
492 struct timer_list loadtimer;
493 ulong32 loadtimerset;
494 struct dentry *debugfs_entry;
495 struct slic_spinlock upr_lock;
496 struct slic_spinlock bit64reglock;
497 slic_rspqueue_t rspqueue;
498 slic_rcvqueue_t rcvqueue;
499 slic_cmdqueue_t cmdq_free;
500 slic_cmdqueue_t cmdq_done;
501 slic_cmdqueue_t cmdq_all;
502 slic_cmdqmem_t cmdqmem;
506 slic_handle_t slic_handles[SLIC_CMDQ_MAXCMDS+1]; /* Object handles*/
507 pslic_handle_t pfree_slic_handles; /* Free object handles*/
508 struct slic_spinlock handle_lock; /* Object handle list lock*/
509 ushort slic_handle_ix;
512 ulong32 all_reg_writes;
513 ulong32 icr_reg_writes;
514 ulong32 isr_reg_writes;
515 ulong32 error_interrupts;
516 ulong32 error_rmiss_interrupts;
519 ulong32 rcv_interrupts;
520 ulong32 xmit_interrupts;
521 ulong32 linkevent_interrupts;
522 ulong32 upr_interrupts;
524 ulong32 false_interrupts;
526 ulong32 xmit_completes;
528 ulong32 rcv_broadcasts;
529 ulong32 rcv_multicasts;
530 ulong32 rcv_unicasts;
531 ulong32 max_isr_rcvs;
532 ulong32 max_isr_xmits;
533 ulong32 rcv_interrupt_yields;
534 ulong32 intagg_period;
535 p_inicpm_state_t inicpm_info;
537 slic_reg_params_t reg_params;
538 slic_ifevents_t if_events;
539 slic_stats_t inicstats_prev;
540 slicnet_stats_t slic_stats;
541 struct net_device_stats stats;
542 } adapter_t, *p_adapter_t;
544 #if SLIC_DUMP_ENABLED
545 #define SLIC_DUMP_REQUESTED 1
546 #define SLIC_DUMP_IN_PROGRESS 2
547 #define SLIC_DUMP_DONE 3
549 /****************************************************************************
551 * Microcode crash information structure. This
552 * structure is written out to the card's SRAM when the microcode panic's.
554 ****************************************************************************/
555 typedef struct _slic_crash_info {
558 } slic_crash_info, *p_slic_crash_info;
560 #define CRASH_INFO_OFFSET 0x155C
564 #define UPDATE_STATS(largestat, newstat, oldstat) \
566 if ((newstat) < (oldstat)) \
567 (largestat) += ((newstat) + (0xFFFFFFFF - oldstat + 1)); \
569 (largestat) += ((newstat) - (oldstat)); \
572 #define UPDATE_STATS_GB(largestat, newstat, oldstat) \
574 (largestat) += ((newstat) - (oldstat)); \
577 #define ETHER_EQ_ADDR(_AddrA, _AddrB, _Result) \
580 if (*(pulong32)(_AddrA) != *(pulong32)(_AddrB)) \
582 if (*(pushort)(&((_AddrA)[4])) != *(pushort)(&((_AddrB)[4]))) \
586 #if defined(CONFIG_X86_64) || defined(CONFIG_IA64)
587 #define SLIC_GET_ADDR_LOW(_addr) (ulong32)((ulong64)(_addr) & \
589 #define SLIC_GET_ADDR_HIGH(_addr) (ulong32)(((ulong64)(_addr) >> 32) & \
592 #define SLIC_GET_ADDR_LOW(_addr) (ulong32)_addr
593 #define SLIC_GET_ADDR_HIGH(_addr) (ulong32)0
597 #define DONT_FLUSH FALSE
599 #define SIOCSLICDUMPCARD (SIOCDEVPRIVATE+9)
600 #define SIOCSLICSETINTAGG (SIOCDEVPRIVATE+10)
601 #define SIOCSLICTRACEDUMP (SIOCDEVPRIVATE+11)
603 #endif /* __SLIC_DRIVER_H__ */