slic.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518
  1. /**************************************************************************
  2. *
  3. * Copyright (c) 2000-2002 Alacritech, Inc. All rights reserved.
  4. *
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above
  13. * copyright notice, this list of conditions and the following
  14. * disclaimer in the documentation and/or other materials provided
  15. * with the distribution.
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY ALACRITECH, INC. ``AS IS'' AND ANY
  18. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  20. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ALACRITECH, INC. OR
  21. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  22. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  23. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  24. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  25. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  26. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  27. * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  28. * SUCH DAMAGE.
  29. *
  30. * The views and conclusions contained in the software and documentation
  31. * are those of the authors and should not be interpreted as representing
  32. * official policies, either expressed or implied, of Alacritech, Inc.
  33. *
  34. **************************************************************************/
  35. /*
  36. * FILENAME: slic.h
  37. *
  38. * This is the base set of header definitions for the SLICOSS driver.
  39. */
  40. #ifndef __SLIC_DRIVER_H__
  41. #define __SLIC_DRIVER_H__
  42. /* firmware stuff */
  43. #define OASIS_UCODE_VERS_STRING "1.2"
  44. #define OASIS_UCODE_VERS_DATE "2006/03/27 15:10:37"
  45. #define OASIS_UCODE_HOSTIF_ID 3
  46. #define MOJAVE_UCODE_VERS_STRING "1.2"
  47. #define MOJAVE_UCODE_VERS_DATE "2006/03/27 15:12:22"
  48. #define MOJAVE_UCODE_HOSTIF_ID 3
  49. #define GB_RCVUCODE_VERS_STRING "1.2"
  50. #define GB_RCVUCODE_VERS_DATE "2006/03/27 15:12:15"
  51. static u32 OasisRcvUCodeLen = 512;
  52. static u32 GBRcvUCodeLen = 512;
  53. #define SECTION_SIZE 65536
  54. #define SLIC_RSPQ_PAGES_GB 10
  55. #define SLIC_RSPQ_BUFSINPAGE (PAGE_SIZE / SLIC_RSPBUF_SIZE)
  56. struct slic_rspqueue {
  57. u32 offset;
  58. u32 pageindex;
  59. u32 num_pages;
  60. struct slic_rspbuf *rspbuf;
  61. u32 *vaddr[SLIC_RSPQ_PAGES_GB];
  62. dma_addr_t paddr[SLIC_RSPQ_PAGES_GB];
  63. };
  64. #define SLIC_RCVQ_EXPANSION 1
  65. #define SLIC_RCVQ_ENTRIES (256 * SLIC_RCVQ_EXPANSION)
  66. #define SLIC_RCVQ_MINENTRIES (SLIC_RCVQ_ENTRIES / 2)
  67. #define SLIC_RCVQ_MAX_PROCESS_ISR ((SLIC_RCVQ_ENTRIES * 4))
  68. #define SLIC_RCVQ_RCVBUFSIZE 2048
  69. #define SLIC_RCVQ_FILLENTRIES (16 * SLIC_RCVQ_EXPANSION)
  70. #define SLIC_RCVQ_FILLTHRESH (SLIC_RCVQ_ENTRIES - SLIC_RCVQ_FILLENTRIES)
  71. struct slic_rcvqueue {
  72. struct sk_buff *head;
  73. struct sk_buff *tail;
  74. u32 count;
  75. u32 size;
  76. u32 errors;
  77. };
  78. struct slic_rcvbuf_info {
  79. u32 id;
  80. u32 starttime;
  81. u32 stoptime;
  82. u32 slicworld;
  83. u32 lasttime;
  84. u32 lastid;
  85. };
  86. /*
  87. * SLIC Handle structure. Used to restrict handle values to
  88. * 32 bits by using an index rather than an address.
  89. * Simplifies ucode in 64-bit systems
  90. */
  91. struct slic_handle_word {
  92. union {
  93. struct {
  94. ushort index;
  95. ushort bottombits; /* to denote num bufs to card */
  96. } parts;
  97. u32 whole;
  98. } handle;
  99. };
  100. struct slic_handle {
  101. struct slic_handle_word token; /* token passed between host and card*/
  102. ushort type;
  103. void *address; /* actual address of the object*/
  104. ushort offset;
  105. struct slic_handle *other_handle;
  106. struct slic_handle *next;
  107. };
  108. #define SLIC_HANDLE_FREE 0x0000
  109. #define SLIC_HANDLE_DATA 0x0001
  110. #define SLIC_HANDLE_CMD 0x0002
  111. #define SLIC_HANDLE_CONTEXT 0x0003
  112. #define SLIC_HANDLE_TEAM 0x0004
  113. #define handle_index handle.parts.index
  114. #define handle_bottom handle.parts.bottombits
  115. #define handle_token handle.whole
  116. #define SLIC_HOSTCMD_SIZE 512
  117. struct slic_hostcmd {
  118. struct slic_host64_cmd cmd64;
  119. u32 type;
  120. struct sk_buff *skb;
  121. u32 paddrl;
  122. u32 paddrh;
  123. u32 busy;
  124. u32 cmdsize;
  125. ushort numbufs;
  126. struct slic_handle *pslic_handle;/* handle associated with command */
  127. struct slic_hostcmd *next;
  128. struct slic_hostcmd *next_all;
  129. };
  130. #define SLIC_CMDQ_CMDSINPAGE (PAGE_SIZE / SLIC_HOSTCMD_SIZE)
  131. #define SLIC_CMD_DUMB 3
  132. #define SLIC_CMDQ_INITCMDS 256
  133. #define SLIC_CMDQ_MAXCMDS 256
  134. #define SLIC_CMDQ_MAXOUTSTAND SLIC_CMDQ_MAXCMDS
  135. #define SLIC_CMDQ_MAXPAGES (SLIC_CMDQ_MAXCMDS / SLIC_CMDQ_CMDSINPAGE)
  136. #define SLIC_CMDQ_INITPAGES (SLIC_CMDQ_INITCMDS / SLIC_CMDQ_CMDSINPAGE)
  137. struct slic_cmdqmem {
  138. int pagecnt;
  139. u32 *pages[SLIC_CMDQ_MAXPAGES];
  140. dma_addr_t dma_pages[SLIC_CMDQ_MAXPAGES];
  141. };
  142. struct slic_cmdqueue {
  143. struct slic_hostcmd *head;
  144. struct slic_hostcmd *tail;
  145. int count;
  146. spinlock_t lock;
  147. };
  148. #define SLIC_MAX_CARDS 32
  149. #define SLIC_MAX_PORTS 4 /* Max # of ports per card */
  150. struct mcast_address {
  151. unsigned char address[6];
  152. struct mcast_address *next;
  153. };
  154. #define CARD_DOWN 0x00000000
  155. #define CARD_UP 0x00000001
  156. #define CARD_FAIL 0x00000002
  157. #define CARD_DIAG 0x00000003
  158. #define CARD_SLEEP 0x00000004
  159. #define ADAPT_DOWN 0x00
  160. #define ADAPT_UP 0x01
  161. #define ADAPT_FAIL 0x02
  162. #define ADAPT_RESET 0x03
  163. #define ADAPT_SLEEP 0x04
  164. #define ADAPT_FLAGS_BOOTTIME 0x0001
  165. #define ADAPT_FLAGS_IS64BIT 0x0002
  166. #define ADAPT_FLAGS_PENDINGLINKDOWN 0x0004
  167. #define ADAPT_FLAGS_FIBERMEDIA 0x0008
  168. #define ADAPT_FLAGS_LOCKS_ALLOCED 0x0010
  169. #define ADAPT_FLAGS_INT_REGISTERED 0x0020
  170. #define ADAPT_FLAGS_LOAD_TIMER_SET 0x0040
  171. #define ADAPT_FLAGS_STATS_TIMER_SET 0x0080
  172. #define ADAPT_FLAGS_RESET_TIMER_SET 0x0100
  173. #define LINK_DOWN 0x00
  174. #define LINK_CONFIG 0x01
  175. #define LINK_UP 0x02
  176. #define LINK_10MB 0x00
  177. #define LINK_100MB 0x01
  178. #define LINK_AUTOSPEED 0x02
  179. #define LINK_1000MB 0x03
  180. #define LINK_10000MB 0x04
  181. #define LINK_HALFD 0x00
  182. #define LINK_FULLD 0x01
  183. #define LINK_AUTOD 0x02
  184. #define MAC_DIRECTED 0x00000001
  185. #define MAC_BCAST 0x00000002
  186. #define MAC_MCAST 0x00000004
  187. #define MAC_PROMISC 0x00000008
  188. #define MAC_LOOPBACK 0x00000010
  189. #define MAC_ALLMCAST 0x00000020
  190. #define SLIC_DUPLEX(x) ((x == LINK_FULLD) ? "FDX" : "HDX")
  191. #define SLIC_SPEED(x) ((x == LINK_100MB) ? "100Mb" : ((x == LINK_1000MB) ?\
  192. "1000Mb" : " 10Mb"))
  193. #define SLIC_LINKSTATE(x) ((x == LINK_DOWN) ? "Down" : "Up ")
  194. #define SLIC_ADAPTER_STATE(x) ((x == ADAPT_UP) ? "UP" : "Down")
  195. #define SLIC_CARD_STATE(x) ((x == CARD_UP) ? "UP" : "Down")
  196. struct slic_iface_stats {
  197. /*
  198. * Stats
  199. */
  200. u64 xmt_bytes;
  201. u64 xmt_ucast;
  202. u64 xmt_mcast;
  203. u64 xmt_bcast;
  204. u64 xmt_errors;
  205. u64 xmt_discards;
  206. u64 xmit_collisions;
  207. u64 xmit_excess_xmit_collisions;
  208. u64 rcv_bytes;
  209. u64 rcv_ucast;
  210. u64 rcv_mcast;
  211. u64 rcv_bcast;
  212. u64 rcv_errors;
  213. u64 rcv_discards;
  214. };
  215. struct sliccp_stats {
  216. u64 xmit_tcp_segs;
  217. u64 xmit_tcp_bytes;
  218. u64 rcv_tcp_segs;
  219. u64 rcv_tcp_bytes;
  220. };
  221. struct slicnet_stats {
  222. struct sliccp_stats tcp;
  223. struct slic_iface_stats iface;
  224. };
  225. #define SLIC_LOADTIMER_PERIOD 1
  226. #define SLIC_INTAGG_DEFAULT 200
  227. #define SLIC_LOAD_0 0
  228. #define SLIC_INTAGG_0 0
  229. #define SLIC_LOAD_1 8000
  230. #define SLIC_LOAD_2 10000
  231. #define SLIC_LOAD_3 12000
  232. #define SLIC_LOAD_4 14000
  233. #define SLIC_LOAD_5 16000
  234. #define SLIC_INTAGG_1 50
  235. #define SLIC_INTAGG_2 100
  236. #define SLIC_INTAGG_3 150
  237. #define SLIC_INTAGG_4 200
  238. #define SLIC_INTAGG_5 250
  239. #define SLIC_LOAD_1GB 3000
  240. #define SLIC_LOAD_2GB 6000
  241. #define SLIC_LOAD_3GB 12000
  242. #define SLIC_LOAD_4GB 24000
  243. #define SLIC_LOAD_5GB 48000
  244. #define SLIC_INTAGG_1GB 50
  245. #define SLIC_INTAGG_2GB 75
  246. #define SLIC_INTAGG_3GB 100
  247. #define SLIC_INTAGG_4GB 100
  248. #define SLIC_INTAGG_5GB 100
  249. struct ether_header {
  250. unsigned char ether_dhost[6];
  251. unsigned char ether_shost[6];
  252. ushort ether_type;
  253. };
  254. struct sliccard {
  255. uint busnumber;
  256. uint slotnumber;
  257. uint state;
  258. uint cardnum;
  259. uint card_size;
  260. uint adapters_activated;
  261. uint adapters_allocated;
  262. uint adapters_sleeping;
  263. uint gennumber;
  264. u32 events;
  265. u32 loadlevel_current;
  266. u32 load;
  267. uint reset_in_progress;
  268. u32 pingstatus;
  269. u32 bad_pingstatus;
  270. struct timer_list loadtimer;
  271. u32 loadtimerset;
  272. uint config_set;
  273. struct slic_config config;
  274. struct adapter *master;
  275. struct adapter *adapter[SLIC_MAX_PORTS];
  276. struct sliccard *next;
  277. u32 error_interrupts;
  278. u32 error_rmiss_interrupts;
  279. u32 rcv_interrupts;
  280. u32 xmit_interrupts;
  281. u32 num_isrs;
  282. u32 false_interrupts;
  283. u32 max_isr_rcvs;
  284. u32 max_isr_xmits;
  285. u32 rcv_interrupt_yields;
  286. u32 tx_packets;
  287. u32 debug_ix;
  288. ushort reg_type[32];
  289. ushort reg_offset[32];
  290. u32 reg_value[32];
  291. u32 reg_valueh[32];
  292. };
  293. #define NUM_CFG_SPACES 2
  294. #define NUM_CFG_REGS 64
  295. #define NUM_CFG_REG_ULONGS (NUM_CFG_REGS / sizeof(u32))
  296. struct physcard {
  297. struct adapter *adapter[SLIC_MAX_PORTS];
  298. struct physcard *next;
  299. uint adapters_allocd;
  300. /*
  301. * the following is not currently needed
  302. * u32 bridge_busnum;
  303. * u32 bridge_cfg[NUM_CFG_SPACES][NUM_CFG_REG_ULONGS];
  304. */
  305. };
  306. struct base_driver {
  307. spinlock_t driver_lock;
  308. u32 num_slic_cards;
  309. u32 num_slic_ports;
  310. u32 num_slic_ports_active;
  311. u32 dynamic_intagg;
  312. struct sliccard *slic_card;
  313. struct physcard *phys_card;
  314. uint cardnuminuse[SLIC_MAX_CARDS];
  315. };
  316. struct slic_shmem {
  317. volatile u32 isr;
  318. volatile u32 linkstatus;
  319. volatile struct slic_stats inicstats;
  320. };
  321. struct slic_upr {
  322. uint adapter;
  323. u32 upr_request;
  324. u32 upr_data;
  325. u32 upr_data_h;
  326. u32 upr_buffer;
  327. u32 upr_buffer_h;
  328. struct slic_upr *next;
  329. };
  330. struct slic_ifevents {
  331. uint oflow802;
  332. uint uflow802;
  333. uint Tprtoflow;
  334. uint rcvearly;
  335. uint Bufov;
  336. uint Carre;
  337. uint Longe;
  338. uint Invp;
  339. uint Crc;
  340. uint Drbl;
  341. uint Code;
  342. uint IpHlen;
  343. uint IpLen;
  344. uint IpCsum;
  345. uint TpCsum;
  346. uint TpHlen;
  347. };
  348. struct adapter {
  349. void *ifp;
  350. struct sliccard *card;
  351. uint port;
  352. struct physcard *physcard;
  353. uint physport;
  354. uint cardindex;
  355. uint card_size;
  356. uint chipid;
  357. struct net_device *netdev;
  358. spinlock_t adapter_lock;
  359. spinlock_t reset_lock;
  360. struct pci_dev *pcidev;
  361. uint busnumber;
  362. uint slotnumber;
  363. uint functionnumber;
  364. ushort vendid;
  365. ushort devid;
  366. ushort subsysid;
  367. u32 irq;
  368. u32 drambase;
  369. u32 dramlength;
  370. uint queues_initialized;
  371. uint allocated;
  372. uint activated;
  373. u32 intrregistered;
  374. uint isp_initialized;
  375. uint gennumber;
  376. struct slic_shmem *pshmem;
  377. dma_addr_t phys_shmem;
  378. u32 isrcopy;
  379. __iomem struct slic_regs *slic_regs;
  380. unsigned char state;
  381. unsigned char linkstate;
  382. unsigned char linkspeed;
  383. unsigned char linkduplex;
  384. uint flags;
  385. unsigned char macaddr[6];
  386. unsigned char currmacaddr[6];
  387. u32 macopts;
  388. ushort devflags_prev;
  389. u64 mcastmask;
  390. struct mcast_address *mcastaddrs;
  391. struct slic_upr *upr_list;
  392. uint upr_busy;
  393. struct timer_list pingtimer;
  394. u32 pingtimerset;
  395. struct timer_list loadtimer;
  396. u32 loadtimerset;
  397. spinlock_t upr_lock;
  398. spinlock_t bit64reglock;
  399. struct slic_rspqueue rspqueue;
  400. struct slic_rcvqueue rcvqueue;
  401. struct slic_cmdqueue cmdq_free;
  402. struct slic_cmdqueue cmdq_done;
  403. struct slic_cmdqueue cmdq_all;
  404. struct slic_cmdqmem cmdqmem;
  405. /*
  406. * SLIC Handles
  407. */
  408. /* Object handles*/
  409. struct slic_handle slic_handles[SLIC_CMDQ_MAXCMDS + 1];
  410. /* Free object handles*/
  411. struct slic_handle *pfree_slic_handles;
  412. /* Object handle list lock*/
  413. spinlock_t handle_lock;
  414. ushort slic_handle_ix;
  415. u32 xmitq_full;
  416. u32 all_reg_writes;
  417. u32 icr_reg_writes;
  418. u32 isr_reg_writes;
  419. u32 error_interrupts;
  420. u32 error_rmiss_interrupts;
  421. u32 rx_errors;
  422. u32 rcv_drops;
  423. u32 rcv_interrupts;
  424. u32 xmit_interrupts;
  425. u32 linkevent_interrupts;
  426. u32 upr_interrupts;
  427. u32 num_isrs;
  428. u32 false_interrupts;
  429. u32 tx_packets;
  430. u32 xmit_completes;
  431. u32 tx_drops;
  432. u32 rcv_broadcasts;
  433. u32 rcv_multicasts;
  434. u32 rcv_unicasts;
  435. u32 max_isr_rcvs;
  436. u32 max_isr_xmits;
  437. u32 rcv_interrupt_yields;
  438. u32 intagg_period;
  439. struct inicpm_state *inicpm_info;
  440. void *pinicpm_info;
  441. struct slic_ifevents if_events;
  442. struct slic_stats inicstats_prev;
  443. struct slicnet_stats slic_stats;
  444. };
  445. #define UPDATE_STATS(largestat, newstat, oldstat) \
  446. { \
  447. if ((newstat) < (oldstat)) \
  448. (largestat) += ((newstat) + (0xFFFFFFFF - oldstat + 1)); \
  449. else \
  450. (largestat) += ((newstat) - (oldstat)); \
  451. }
  452. #define UPDATE_STATS_GB(largestat, newstat, oldstat) \
  453. { \
  454. (largestat) += ((newstat) - (oldstat)); \
  455. }
  456. #if BITS_PER_LONG == 64
  457. #define SLIC_GET_ADDR_LOW(_addr) (u32)((u64)(_addr) & \
  458. 0x00000000FFFFFFFF)
  459. #define SLIC_GET_ADDR_HIGH(_addr) (u32)(((u64)(_addr) >> 32) & \
  460. 0x00000000FFFFFFFF)
  461. #elif BITS_PER_LONG == 32
  462. #define SLIC_GET_ADDR_LOW(_addr) (u32)(_addr)
  463. #define SLIC_GET_ADDR_HIGH(_addr) (u32)0
  464. #else
  465. #error BITS_PER_LONG must be 32 or 64
  466. #endif
  467. #define FLUSH true
  468. #define DONT_FLUSH false
  469. #define SIOCSLICSETINTAGG (SIOCDEVPRIVATE + 10)
  470. #endif /* __SLIC_DRIVER_H__ */