slic.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  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. struct slic_spinlock {
  55. spinlock_t lock;
  56. unsigned long flags;
  57. };
  58. #define SLIC_RSPQ_PAGES_GB 10
  59. #define SLIC_RSPQ_BUFSINPAGE (PAGE_SIZE / SLIC_RSPBUF_SIZE)
  60. struct slic_rspqueue {
  61. u32 offset;
  62. u32 pageindex;
  63. u32 num_pages;
  64. struct slic_rspbuf *rspbuf;
  65. u32 *vaddr[SLIC_RSPQ_PAGES_GB];
  66. dma_addr_t paddr[SLIC_RSPQ_PAGES_GB];
  67. };
  68. #define SLIC_RCVQ_EXPANSION 1
  69. #define SLIC_RCVQ_ENTRIES (256 * SLIC_RCVQ_EXPANSION)
  70. #define SLIC_RCVQ_MINENTRIES (SLIC_RCVQ_ENTRIES / 2)
  71. #define SLIC_RCVQ_MAX_PROCESS_ISR ((SLIC_RCVQ_ENTRIES * 4))
  72. #define SLIC_RCVQ_RCVBUFSIZE 2048
  73. #define SLIC_RCVQ_FILLENTRIES (16 * SLIC_RCVQ_EXPANSION)
  74. #define SLIC_RCVQ_FILLTHRESH (SLIC_RCVQ_ENTRIES - SLIC_RCVQ_FILLENTRIES)
  75. struct slic_rcvqueue {
  76. struct sk_buff *head;
  77. struct sk_buff *tail;
  78. u32 count;
  79. u32 size;
  80. u32 errors;
  81. };
  82. struct slic_rcvbuf_info {
  83. u32 id;
  84. u32 starttime;
  85. u32 stoptime;
  86. u32 slicworld;
  87. u32 lasttime;
  88. u32 lastid;
  89. };
  90. /*
  91. SLIC Handle structure. Used to restrict handle values to
  92. 32 bits by using an index rather than an address.
  93. Simplifies ucode in 64-bit systems
  94. */
  95. struct slic_handle_word {
  96. union {
  97. struct {
  98. ushort index;
  99. ushort bottombits; /* to denote num bufs to card */
  100. } parts;
  101. u32 whole;
  102. } handle;
  103. };
  104. struct slic_handle {
  105. struct slic_handle_word token; /* token passed between host and card*/
  106. ushort type;
  107. void *address; /* actual address of the object*/
  108. ushort offset;
  109. struct slic_handle *other_handle;
  110. struct slic_handle *next;
  111. };
  112. #define SLIC_HANDLE_FREE 0x0000
  113. #define SLIC_HANDLE_DATA 0x0001
  114. #define SLIC_HANDLE_CMD 0x0002
  115. #define SLIC_HANDLE_CONTEXT 0x0003
  116. #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
  120. #define SLIC_HOSTCMD_SIZE 512
  121. struct slic_hostcmd {
  122. struct slic_host64_cmd cmd64;
  123. u32 type;
  124. struct sk_buff *skb;
  125. u32 paddrl;
  126. u32 paddrh;
  127. u32 busy;
  128. u32 cmdsize;
  129. ushort numbufs;
  130. struct slic_handle *pslic_handle;/* handle associated with command */
  131. struct slic_hostcmd *next;
  132. struct slic_hostcmd *next_all;
  133. };
  134. #define SLIC_CMDQ_CMDSINPAGE (PAGE_SIZE / SLIC_HOSTCMD_SIZE)
  135. #define SLIC_CMD_DUMB 3
  136. #define SLIC_CMDQ_INITCMDS 256
  137. #define SLIC_CMDQ_MAXCMDS 256
  138. #define SLIC_CMDQ_MAXOUTSTAND SLIC_CMDQ_MAXCMDS
  139. #define SLIC_CMDQ_MAXPAGES (SLIC_CMDQ_MAXCMDS / SLIC_CMDQ_CMDSINPAGE)
  140. #define SLIC_CMDQ_INITPAGES (SLIC_CMDQ_INITCMDS / SLIC_CMDQ_CMDSINPAGE)
  141. struct slic_cmdqmem {
  142. int pagecnt;
  143. u32 *pages[SLIC_CMDQ_MAXPAGES];
  144. dma_addr_t dma_pages[SLIC_CMDQ_MAXPAGES];
  145. };
  146. struct slic_cmdqueue {
  147. struct slic_hostcmd *head;
  148. struct slic_hostcmd *tail;
  149. int count;
  150. struct slic_spinlock lock;
  151. };
  152. #define SLIC_MAX_CARDS 32
  153. #define SLIC_MAX_PORTS 4 /* Max # of ports per card */
  154. struct mcast_address {
  155. unsigned char address[6];
  156. struct mcast_address *next;
  157. };
  158. #define CARD_DOWN 0x00000000
  159. #define CARD_UP 0x00000001
  160. #define CARD_FAIL 0x00000002
  161. #define CARD_DIAG 0x00000003
  162. #define CARD_SLEEP 0x00000004
  163. #define ADAPT_DOWN 0x00
  164. #define ADAPT_UP 0x01
  165. #define ADAPT_FAIL 0x02
  166. #define ADAPT_RESET 0x03
  167. #define ADAPT_SLEEP 0x04
  168. #define ADAPT_FLAGS_BOOTTIME 0x0001
  169. #define ADAPT_FLAGS_IS64BIT 0x0002
  170. #define ADAPT_FLAGS_PENDINGLINKDOWN 0x0004
  171. #define ADAPT_FLAGS_FIBERMEDIA 0x0008
  172. #define ADAPT_FLAGS_LOCKS_ALLOCED 0x0010
  173. #define ADAPT_FLAGS_INT_REGISTERED 0x0020
  174. #define ADAPT_FLAGS_LOAD_TIMER_SET 0x0040
  175. #define ADAPT_FLAGS_STATS_TIMER_SET 0x0080
  176. #define ADAPT_FLAGS_RESET_TIMER_SET 0x0100
  177. #define LINK_DOWN 0x00
  178. #define LINK_CONFIG 0x01
  179. #define LINK_UP 0x02
  180. #define LINK_10MB 0x00
  181. #define LINK_100MB 0x01
  182. #define LINK_AUTOSPEED 0x02
  183. #define LINK_1000MB 0x03
  184. #define LINK_10000MB 0x04
  185. #define LINK_HALFD 0x00
  186. #define LINK_FULLD 0x01
  187. #define LINK_AUTOD 0x02
  188. #define MAC_DIRECTED 0x00000001
  189. #define MAC_BCAST 0x00000002
  190. #define MAC_MCAST 0x00000004
  191. #define MAC_PROMISC 0x00000008
  192. #define MAC_LOOPBACK 0x00000010
  193. #define MAC_ALLMCAST 0x00000020
  194. #define SLIC_DUPLEX(x) ((x == LINK_FULLD) ? "FDX" : "HDX")
  195. #define SLIC_SPEED(x) ((x == LINK_100MB) ? "100Mb" : ((x == LINK_1000MB) ?\
  196. "1000Mb" : " 10Mb"))
  197. #define SLIC_LINKSTATE(x) ((x == LINK_DOWN) ? "Down" : "Up ")
  198. #define SLIC_ADAPTER_STATE(x) ((x == ADAPT_UP) ? "UP" : "Down")
  199. #define SLIC_CARD_STATE(x) ((x == CARD_UP) ? "UP" : "Down")
  200. struct slic_iface_stats {
  201. /*
  202. * Stats
  203. */
  204. u64 xmt_bytes;
  205. u64 xmt_ucast;
  206. u64 xmt_mcast;
  207. u64 xmt_bcast;
  208. u64 xmt_errors;
  209. u64 xmt_discards;
  210. u64 xmit_collisions;
  211. u64 xmit_excess_xmit_collisions;
  212. u64 rcv_bytes;
  213. u64 rcv_ucast;
  214. u64 rcv_mcast;
  215. u64 rcv_bcast;
  216. u64 rcv_errors;
  217. u64 rcv_discards;
  218. };
  219. struct sliccp_stats {
  220. u64 xmit_tcp_segs;
  221. u64 xmit_tcp_bytes;
  222. u64 rcv_tcp_segs;
  223. u64 rcv_tcp_bytes;
  224. };
  225. struct slicnet_stats {
  226. struct sliccp_stats tcp;
  227. struct slic_iface_stats iface;
  228. };
  229. #define SLIC_LOADTIMER_PERIOD 1
  230. #define SLIC_INTAGG_DEFAULT 200
  231. #define SLIC_LOAD_0 0
  232. #define SLIC_INTAGG_0 0
  233. #define SLIC_LOAD_1 8000
  234. #define SLIC_LOAD_2 10000
  235. #define SLIC_LOAD_3 12000
  236. #define SLIC_LOAD_4 14000
  237. #define SLIC_LOAD_5 16000
  238. #define SLIC_INTAGG_1 50
  239. #define SLIC_INTAGG_2 100
  240. #define SLIC_INTAGG_3 150
  241. #define SLIC_INTAGG_4 200
  242. #define SLIC_INTAGG_5 250
  243. #define SLIC_LOAD_1GB 3000
  244. #define SLIC_LOAD_2GB 6000
  245. #define SLIC_LOAD_3GB 12000
  246. #define SLIC_LOAD_4GB 24000
  247. #define SLIC_LOAD_5GB 48000
  248. #define SLIC_INTAGG_1GB 50
  249. #define SLIC_INTAGG_2GB 75
  250. #define SLIC_INTAGG_3GB 100
  251. #define SLIC_INTAGG_4GB 100
  252. #define SLIC_INTAGG_5GB 100
  253. struct ether_header {
  254. unsigned char ether_dhost[6];
  255. unsigned char ether_shost[6];
  256. ushort ether_type;
  257. };
  258. struct sliccard {
  259. uint busnumber;
  260. uint slotnumber;
  261. uint state;
  262. uint cardnum;
  263. uint card_size;
  264. uint adapters_activated;
  265. uint adapters_allocated;
  266. uint adapters_sleeping;
  267. uint gennumber;
  268. u32 events;
  269. u32 loadlevel_current;
  270. u32 load;
  271. uint reset_in_progress;
  272. u32 pingstatus;
  273. u32 bad_pingstatus;
  274. struct timer_list loadtimer;
  275. u32 loadtimerset;
  276. uint config_set;
  277. struct slic_config config;
  278. struct dentry *debugfs_dir;
  279. struct dentry *debugfs_cardinfo;
  280. struct adapter *master;
  281. struct adapter *adapter[SLIC_MAX_PORTS];
  282. struct sliccard *next;
  283. u32 error_interrupts;
  284. u32 error_rmiss_interrupts;
  285. u32 rcv_interrupts;
  286. u32 xmit_interrupts;
  287. u32 num_isrs;
  288. u32 false_interrupts;
  289. u32 max_isr_rcvs;
  290. u32 max_isr_xmits;
  291. u32 rcv_interrupt_yields;
  292. u32 tx_packets;
  293. u32 debug_ix;
  294. ushort reg_type[32];
  295. ushort reg_offset[32];
  296. u32 reg_value[32];
  297. u32 reg_valueh[32];
  298. };
  299. #define NUM_CFG_SPACES 2
  300. #define NUM_CFG_REGS 64
  301. #define NUM_CFG_REG_ULONGS (NUM_CFG_REGS / sizeof(u32))
  302. struct physcard {
  303. struct adapter *adapter[SLIC_MAX_PORTS];
  304. struct physcard *next;
  305. uint adapters_allocd;
  306. /* the following is not currently needed
  307. u32 bridge_busnum;
  308. u32 bridge_cfg[NUM_CFG_SPACES][NUM_CFG_REG_ULONGS];
  309. */
  310. };
  311. struct base_driver {
  312. struct slic_spinlock driver_lock;
  313. u32 num_slic_cards;
  314. u32 num_slic_ports;
  315. u32 num_slic_ports_active;
  316. u32 dynamic_intagg;
  317. struct sliccard *slic_card;
  318. struct physcard *phys_card;
  319. uint cardnuminuse[SLIC_MAX_CARDS];
  320. };
  321. struct slic_shmem {
  322. volatile u32 isr;
  323. volatile u32 linkstatus;
  324. volatile struct slic_stats inicstats;
  325. };
  326. struct slic_reg_params {
  327. u32 linkspeed;
  328. u32 linkduplex;
  329. u32 fail_on_bad_eeprom;
  330. };
  331. struct slic_upr {
  332. uint adapter;
  333. u32 upr_request;
  334. u32 upr_data;
  335. u32 upr_data_h;
  336. u32 upr_buffer;
  337. u32 upr_buffer_h;
  338. struct slic_upr *next;
  339. };
  340. struct slic_ifevents {
  341. uint oflow802;
  342. uint uflow802;
  343. uint Tprtoflow;
  344. uint rcvearly;
  345. uint Bufov;
  346. uint Carre;
  347. uint Longe;
  348. uint Invp;
  349. uint Crc;
  350. uint Drbl;
  351. uint Code;
  352. uint IpHlen;
  353. uint IpLen;
  354. uint IpCsum;
  355. uint TpCsum;
  356. uint TpHlen;
  357. };
  358. struct adapter {
  359. void *ifp;
  360. struct sliccard *card;
  361. uint port;
  362. struct physcard *physcard;
  363. uint physport;
  364. uint cardindex;
  365. uint card_size;
  366. uint chipid;
  367. struct net_device *netdev;
  368. struct net_device *next_netdevice;
  369. struct slic_spinlock adapter_lock;
  370. struct slic_spinlock reset_lock;
  371. struct pci_dev *pcidev;
  372. uint busnumber;
  373. uint slotnumber;
  374. uint functionnumber;
  375. ushort vendid;
  376. ushort devid;
  377. ushort subsysid;
  378. u32 irq;
  379. void __iomem *memorybase;
  380. u32 memorylength;
  381. u32 drambase;
  382. u32 dramlength;
  383. uint queues_initialized;
  384. uint allocated;
  385. uint activated;
  386. u32 intrregistered;
  387. uint isp_initialized;
  388. uint gennumber;
  389. u32 curaddrupper;
  390. struct slic_shmem *pshmem;
  391. dma_addr_t phys_shmem;
  392. u32 isrcopy;
  393. __iomem struct slic_regs *slic_regs;
  394. unsigned char state;
  395. unsigned char linkstate;
  396. unsigned char linkspeed;
  397. unsigned char linkduplex;
  398. uint flags;
  399. unsigned char macaddr[6];
  400. unsigned char currmacaddr[6];
  401. u32 macopts;
  402. ushort devflags_prev;
  403. u64 mcastmask;
  404. struct mcast_address *mcastaddrs;
  405. struct slic_upr *upr_list;
  406. uint upr_busy;
  407. struct timer_list pingtimer;
  408. u32 pingtimerset;
  409. struct timer_list loadtimer;
  410. u32 loadtimerset;
  411. struct dentry *debugfs_entry;
  412. struct slic_spinlock upr_lock;
  413. struct slic_spinlock bit64reglock;
  414. struct slic_rspqueue rspqueue;
  415. struct slic_rcvqueue rcvqueue;
  416. struct slic_cmdqueue cmdq_free;
  417. struct slic_cmdqueue cmdq_done;
  418. struct slic_cmdqueue cmdq_all;
  419. struct slic_cmdqmem cmdqmem;
  420. /*
  421. * SLIC Handles
  422. */
  423. struct slic_handle slic_handles[SLIC_CMDQ_MAXCMDS+1]; /* Object handles*/
  424. struct slic_handle *pfree_slic_handles; /* Free object handles*/
  425. struct slic_spinlock handle_lock; /* Object handle list lock*/
  426. ushort slic_handle_ix;
  427. u32 xmitq_full;
  428. u32 all_reg_writes;
  429. u32 icr_reg_writes;
  430. u32 isr_reg_writes;
  431. u32 error_interrupts;
  432. u32 error_rmiss_interrupts;
  433. u32 rx_errors;
  434. u32 rcv_drops;
  435. u32 rcv_interrupts;
  436. u32 xmit_interrupts;
  437. u32 linkevent_interrupts;
  438. u32 upr_interrupts;
  439. u32 num_isrs;
  440. u32 false_interrupts;
  441. u32 tx_packets;
  442. u32 xmit_completes;
  443. u32 tx_drops;
  444. u32 rcv_broadcasts;
  445. u32 rcv_multicasts;
  446. u32 rcv_unicasts;
  447. u32 max_isr_rcvs;
  448. u32 max_isr_xmits;
  449. u32 rcv_interrupt_yields;
  450. u32 intagg_period;
  451. struct inicpm_state *inicpm_info;
  452. void *pinicpm_info;
  453. struct slic_reg_params reg_params;
  454. struct slic_ifevents if_events;
  455. struct slic_stats inicstats_prev;
  456. struct slicnet_stats slic_stats;
  457. };
  458. #define UPDATE_STATS(largestat, newstat, oldstat) \
  459. { \
  460. if ((newstat) < (oldstat)) \
  461. (largestat) += ((newstat) + (0xFFFFFFFF - oldstat + 1)); \
  462. else \
  463. (largestat) += ((newstat) - (oldstat)); \
  464. }
  465. #define UPDATE_STATS_GB(largestat, newstat, oldstat) \
  466. { \
  467. (largestat) += ((newstat) - (oldstat)); \
  468. }
  469. #if BITS_PER_LONG == 64
  470. #define SLIC_GET_ADDR_LOW(_addr) (u32)((u64)(_addr) & \
  471. 0x00000000FFFFFFFF)
  472. #define SLIC_GET_ADDR_HIGH(_addr) (u32)(((u64)(_addr) >> 32) & \
  473. 0x00000000FFFFFFFF)
  474. #elif BITS_PER_LONG == 32
  475. #define SLIC_GET_ADDR_LOW(_addr) (u32)(_addr)
  476. #define SLIC_GET_ADDR_HIGH(_addr) (u32)0
  477. #else
  478. #error BITS_PER_LONG must be 32 or 64
  479. #endif
  480. #define FLUSH true
  481. #define DONT_FLUSH false
  482. #define SIOCSLICDUMPCARD (SIOCDEVPRIVATE+9)
  483. #define SIOCSLICSETINTAGG (SIOCDEVPRIVATE+10)
  484. #define SIOCSLICTRACEDUMP (SIOCDEVPRIVATE+11)
  485. #endif /* __SLIC_DRIVER_H__ */