acenic.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790
  1. #ifndef _ACENIC_H_
  2. #define _ACENIC_H_
  3. #include <linux/interrupt.h>
  4. /*
  5. * Generate TX index update each time, when TX ring is closed.
  6. * Normally, this is not useful, because results in more dma (and irqs
  7. * without TX_COAL_INTS_ONLY).
  8. */
  9. #define USE_TX_COAL_NOW 0
  10. /*
  11. * Addressing:
  12. *
  13. * The Tigon uses 64-bit host addresses, regardless of their actual
  14. * length, and it expects a big-endian format. For 32 bit systems the
  15. * upper 32 bits of the address are simply ignored (zero), however for
  16. * little endian 64 bit systems (Alpha) this looks strange with the
  17. * two parts of the address word being swapped.
  18. *
  19. * The addresses are split in two 32 bit words for all architectures
  20. * as some of them are in PCI shared memory and it is necessary to use
  21. * readl/writel to access them.
  22. *
  23. * The addressing code is derived from Pete Wyckoff's work, but
  24. * modified to deal properly with readl/writel usage.
  25. */
  26. struct ace_regs {
  27. u32 pad0[16]; /* PCI control registers */
  28. u32 HostCtrl; /* 0x40 */
  29. u32 LocalCtrl;
  30. u32 pad1[2];
  31. u32 MiscCfg; /* 0x50 */
  32. u32 pad2[2];
  33. u32 PciState;
  34. u32 pad3[2]; /* 0x60 */
  35. u32 WinBase;
  36. u32 WinData;
  37. u32 pad4[12]; /* 0x70 */
  38. u32 DmaWriteState; /* 0xa0 */
  39. u32 pad5[3];
  40. u32 DmaReadState; /* 0xb0 */
  41. u32 pad6[26];
  42. u32 AssistState;
  43. u32 pad7[8]; /* 0x120 */
  44. u32 CpuCtrl; /* 0x140 */
  45. u32 Pc;
  46. u32 pad8[3];
  47. u32 SramAddr; /* 0x154 */
  48. u32 SramData;
  49. u32 pad9[49];
  50. u32 MacRxState; /* 0x220 */
  51. u32 pad10[7];
  52. u32 CpuBCtrl; /* 0x240 */
  53. u32 PcB;
  54. u32 pad11[3];
  55. u32 SramBAddr; /* 0x254 */
  56. u32 SramBData;
  57. u32 pad12[105];
  58. u32 pad13[32]; /* 0x400 */
  59. u32 Stats[32];
  60. u32 Mb0Hi; /* 0x500 */
  61. u32 Mb0Lo;
  62. u32 Mb1Hi;
  63. u32 CmdPrd;
  64. u32 Mb2Hi;
  65. u32 TxPrd;
  66. u32 Mb3Hi;
  67. u32 RxStdPrd;
  68. u32 Mb4Hi;
  69. u32 RxJumboPrd;
  70. u32 Mb5Hi;
  71. u32 RxMiniPrd;
  72. u32 Mb6Hi;
  73. u32 Mb6Lo;
  74. u32 Mb7Hi;
  75. u32 Mb7Lo;
  76. u32 Mb8Hi;
  77. u32 Mb8Lo;
  78. u32 Mb9Hi;
  79. u32 Mb9Lo;
  80. u32 MbAHi;
  81. u32 MbALo;
  82. u32 MbBHi;
  83. u32 MbBLo;
  84. u32 MbCHi;
  85. u32 MbCLo;
  86. u32 MbDHi;
  87. u32 MbDLo;
  88. u32 MbEHi;
  89. u32 MbELo;
  90. u32 MbFHi;
  91. u32 MbFLo;
  92. u32 pad14[32];
  93. u32 MacAddrHi; /* 0x600 */
  94. u32 MacAddrLo;
  95. u32 InfoPtrHi;
  96. u32 InfoPtrLo;
  97. u32 MultiCastHi; /* 0x610 */
  98. u32 MultiCastLo;
  99. u32 ModeStat;
  100. u32 DmaReadCfg;
  101. u32 DmaWriteCfg; /* 0x620 */
  102. u32 TxBufRat;
  103. u32 EvtCsm;
  104. u32 CmdCsm;
  105. u32 TuneRxCoalTicks;/* 0x630 */
  106. u32 TuneTxCoalTicks;
  107. u32 TuneStatTicks;
  108. u32 TuneMaxTxDesc;
  109. u32 TuneMaxRxDesc; /* 0x640 */
  110. u32 TuneTrace;
  111. u32 TuneLink;
  112. u32 TuneFastLink;
  113. u32 TracePtr; /* 0x650 */
  114. u32 TraceStrt;
  115. u32 TraceLen;
  116. u32 IfIdx;
  117. u32 IfMtu; /* 0x660 */
  118. u32 MaskInt;
  119. u32 GigLnkState;
  120. u32 FastLnkState;
  121. u32 pad16[4]; /* 0x670 */
  122. u32 RxRetCsm; /* 0x680 */
  123. u32 pad17[31];
  124. u32 CmdRng[64]; /* 0x700 */
  125. u32 Window[0x200];
  126. };
  127. typedef struct {
  128. u32 addrhi;
  129. u32 addrlo;
  130. } aceaddr;
  131. #define ACE_WINDOW_SIZE 0x800
  132. #define ACE_JUMBO_MTU 9000
  133. #define ACE_STD_MTU 1500
  134. #define ACE_TRACE_SIZE 0x8000
  135. /*
  136. * Host control register bits.
  137. */
  138. #define IN_INT 0x01
  139. #define CLR_INT 0x02
  140. #define HW_RESET 0x08
  141. #define BYTE_SWAP 0x10
  142. #define WORD_SWAP 0x20
  143. #define MASK_INTS 0x40
  144. /*
  145. * Local control register bits.
  146. */
  147. #define EEPROM_DATA_IN 0x800000
  148. #define EEPROM_DATA_OUT 0x400000
  149. #define EEPROM_WRITE_ENABLE 0x200000
  150. #define EEPROM_CLK_OUT 0x100000
  151. #define EEPROM_BASE 0xa0000000
  152. #define EEPROM_WRITE_SELECT 0xa0
  153. #define EEPROM_READ_SELECT 0xa1
  154. #define SRAM_BANK_512K 0x200
  155. /*
  156. * udelay() values for when clocking the eeprom
  157. */
  158. #define ACE_SHORT_DELAY 2
  159. #define ACE_LONG_DELAY 4
  160. /*
  161. * Misc Config bits
  162. */
  163. #define SYNC_SRAM_TIMING 0x100000
  164. /*
  165. * CPU state bits.
  166. */
  167. #define CPU_RESET 0x01
  168. #define CPU_TRACE 0x02
  169. #define CPU_PROM_FAILED 0x10
  170. #define CPU_HALT 0x00010000
  171. #define CPU_HALTED 0xffff0000
  172. /*
  173. * PCI State bits.
  174. */
  175. #define DMA_READ_MAX_4 0x04
  176. #define DMA_READ_MAX_16 0x08
  177. #define DMA_READ_MAX_32 0x0c
  178. #define DMA_READ_MAX_64 0x10
  179. #define DMA_READ_MAX_128 0x14
  180. #define DMA_READ_MAX_256 0x18
  181. #define DMA_READ_MAX_1K 0x1c
  182. #define DMA_WRITE_MAX_4 0x20
  183. #define DMA_WRITE_MAX_16 0x40
  184. #define DMA_WRITE_MAX_32 0x60
  185. #define DMA_WRITE_MAX_64 0x80
  186. #define DMA_WRITE_MAX_128 0xa0
  187. #define DMA_WRITE_MAX_256 0xc0
  188. #define DMA_WRITE_MAX_1K 0xe0
  189. #define DMA_READ_WRITE_MASK 0xfc
  190. #define MEM_READ_MULTIPLE 0x00020000
  191. #define PCI_66MHZ 0x00080000
  192. #define PCI_32BIT 0x00100000
  193. #define DMA_WRITE_ALL_ALIGN 0x00800000
  194. #define READ_CMD_MEM 0x06000000
  195. #define WRITE_CMD_MEM 0x70000000
  196. /*
  197. * Mode status
  198. */
  199. #define ACE_BYTE_SWAP_BD 0x02
  200. #define ACE_WORD_SWAP_BD 0x04 /* not actually used */
  201. #define ACE_WARN 0x08
  202. #define ACE_BYTE_SWAP_DMA 0x10
  203. #define ACE_NO_JUMBO_FRAG 0x200
  204. #define ACE_FATAL 0x40000000
  205. /*
  206. * DMA config
  207. */
  208. #define DMA_THRESH_1W 0x10
  209. #define DMA_THRESH_2W 0x20
  210. #define DMA_THRESH_4W 0x40
  211. #define DMA_THRESH_8W 0x80
  212. #define DMA_THRESH_16W 0x100
  213. #define DMA_THRESH_32W 0x0 /* not described in doc, but exists. */
  214. /*
  215. * Tuning parameters
  216. */
  217. #define TICKS_PER_SEC 1000000
  218. /*
  219. * Link bits
  220. */
  221. #define LNK_PREF 0x00008000
  222. #define LNK_10MB 0x00010000
  223. #define LNK_100MB 0x00020000
  224. #define LNK_1000MB 0x00040000
  225. #define LNK_FULL_DUPLEX 0x00080000
  226. #define LNK_HALF_DUPLEX 0x00100000
  227. #define LNK_TX_FLOW_CTL_Y 0x00200000
  228. #define LNK_NEG_ADVANCED 0x00400000
  229. #define LNK_RX_FLOW_CTL_Y 0x00800000
  230. #define LNK_NIC 0x01000000
  231. #define LNK_JAM 0x02000000
  232. #define LNK_JUMBO 0x04000000
  233. #define LNK_ALTEON 0x08000000
  234. #define LNK_NEG_FCTL 0x10000000
  235. #define LNK_NEGOTIATE 0x20000000
  236. #define LNK_ENABLE 0x40000000
  237. #define LNK_UP 0x80000000
  238. /*
  239. * Event definitions
  240. */
  241. #define EVT_RING_ENTRIES 256
  242. #define EVT_RING_SIZE (EVT_RING_ENTRIES * sizeof(struct event))
  243. struct event {
  244. #ifdef __LITTLE_ENDIAN_BITFIELD
  245. u32 idx:12;
  246. u32 code:12;
  247. u32 evt:8;
  248. #else
  249. u32 evt:8;
  250. u32 code:12;
  251. u32 idx:12;
  252. #endif
  253. u32 pad;
  254. };
  255. /*
  256. * Events
  257. */
  258. #define E_FW_RUNNING 0x01
  259. #define E_STATS_UPDATED 0x04
  260. #define E_STATS_UPDATE 0x04
  261. #define E_LNK_STATE 0x06
  262. #define E_C_LINK_UP 0x01
  263. #define E_C_LINK_DOWN 0x02
  264. #define E_C_LINK_10_100 0x03
  265. #define E_ERROR 0x07
  266. #define E_C_ERR_INVAL_CMD 0x01
  267. #define E_C_ERR_UNIMP_CMD 0x02
  268. #define E_C_ERR_BAD_CFG 0x03
  269. #define E_MCAST_LIST 0x08
  270. #define E_C_MCAST_ADDR_ADD 0x01
  271. #define E_C_MCAST_ADDR_DEL 0x02
  272. #define E_RESET_JUMBO_RNG 0x09
  273. /*
  274. * Commands
  275. */
  276. #define CMD_RING_ENTRIES 64
  277. struct cmd {
  278. #ifdef __LITTLE_ENDIAN_BITFIELD
  279. u32 idx:12;
  280. u32 code:12;
  281. u32 evt:8;
  282. #else
  283. u32 evt:8;
  284. u32 code:12;
  285. u32 idx:12;
  286. #endif
  287. };
  288. #define C_HOST_STATE 0x01
  289. #define C_C_STACK_UP 0x01
  290. #define C_C_STACK_DOWN 0x02
  291. #define C_FDR_FILTERING 0x02
  292. #define C_C_FDR_FILT_ENABLE 0x01
  293. #define C_C_FDR_FILT_DISABLE 0x02
  294. #define C_SET_RX_PRD_IDX 0x03
  295. #define C_UPDATE_STATS 0x04
  296. #define C_RESET_JUMBO_RNG 0x05
  297. #define C_ADD_MULTICAST_ADDR 0x08
  298. #define C_DEL_MULTICAST_ADDR 0x09
  299. #define C_SET_PROMISC_MODE 0x0a
  300. #define C_C_PROMISC_ENABLE 0x01
  301. #define C_C_PROMISC_DISABLE 0x02
  302. #define C_LNK_NEGOTIATION 0x0b
  303. #define C_C_NEGOTIATE_BOTH 0x00
  304. #define C_C_NEGOTIATE_GIG 0x01
  305. #define C_C_NEGOTIATE_10_100 0x02
  306. #define C_SET_MAC_ADDR 0x0c
  307. #define C_CLEAR_PROFILE 0x0d
  308. #define C_SET_MULTICAST_MODE 0x0e
  309. #define C_C_MCAST_ENABLE 0x01
  310. #define C_C_MCAST_DISABLE 0x02
  311. #define C_CLEAR_STATS 0x0f
  312. #define C_SET_RX_JUMBO_PRD_IDX 0x10
  313. #define C_REFRESH_STATS 0x11
  314. /*
  315. * Descriptor flags
  316. */
  317. #define BD_FLG_TCP_UDP_SUM 0x01
  318. #define BD_FLG_IP_SUM 0x02
  319. #define BD_FLG_END 0x04
  320. #define BD_FLG_MORE 0x08
  321. #define BD_FLG_JUMBO 0x10
  322. #define BD_FLG_UCAST 0x20
  323. #define BD_FLG_MCAST 0x40
  324. #define BD_FLG_BCAST 0x60
  325. #define BD_FLG_TYP_MASK 0x60
  326. #define BD_FLG_IP_FRAG 0x80
  327. #define BD_FLG_IP_FRAG_END 0x100
  328. #define BD_FLG_VLAN_TAG 0x200
  329. #define BD_FLG_FRAME_ERROR 0x400
  330. #define BD_FLG_COAL_NOW 0x800
  331. #define BD_FLG_MINI 0x1000
  332. /*
  333. * Ring Control block flags
  334. */
  335. #define RCB_FLG_TCP_UDP_SUM 0x01
  336. #define RCB_FLG_IP_SUM 0x02
  337. #define RCB_FLG_NO_PSEUDO_HDR 0x08
  338. #define RCB_FLG_VLAN_ASSIST 0x10
  339. #define RCB_FLG_COAL_INT_ONLY 0x20
  340. #define RCB_FLG_TX_HOST_RING 0x40
  341. #define RCB_FLG_IEEE_SNAP_SUM 0x80
  342. #define RCB_FLG_EXT_RX_BD 0x100
  343. #define RCB_FLG_RNG_DISABLE 0x200
  344. /*
  345. * TX ring - maximum TX ring entries for Tigon I's is 128
  346. */
  347. #define MAX_TX_RING_ENTRIES 256
  348. #define TIGON_I_TX_RING_ENTRIES 128
  349. #define TX_RING_SIZE (MAX_TX_RING_ENTRIES * sizeof(struct tx_desc))
  350. #define TX_RING_BASE 0x3800
  351. struct tx_desc{
  352. aceaddr addr;
  353. u32 flagsize;
  354. #if 0
  355. /*
  356. * This is in PCI shared mem and must be accessed with readl/writel
  357. * real layout is:
  358. */
  359. #if __LITTLE_ENDIAN
  360. u16 flags;
  361. u16 size;
  362. u16 vlan;
  363. u16 reserved;
  364. #else
  365. u16 size;
  366. u16 flags;
  367. u16 reserved;
  368. u16 vlan;
  369. #endif
  370. #endif
  371. u32 vlanres;
  372. };
  373. #define RX_STD_RING_ENTRIES 512
  374. #define RX_STD_RING_SIZE (RX_STD_RING_ENTRIES * sizeof(struct rx_desc))
  375. #define RX_JUMBO_RING_ENTRIES 256
  376. #define RX_JUMBO_RING_SIZE (RX_JUMBO_RING_ENTRIES *sizeof(struct rx_desc))
  377. #define RX_MINI_RING_ENTRIES 1024
  378. #define RX_MINI_RING_SIZE (RX_MINI_RING_ENTRIES *sizeof(struct rx_desc))
  379. #define RX_RETURN_RING_ENTRIES 2048
  380. #define RX_RETURN_RING_SIZE (RX_MAX_RETURN_RING_ENTRIES * \
  381. sizeof(struct rx_desc))
  382. struct rx_desc{
  383. aceaddr addr;
  384. #ifdef __LITTLE_ENDIAN
  385. u16 size;
  386. u16 idx;
  387. #else
  388. u16 idx;
  389. u16 size;
  390. #endif
  391. #ifdef __LITTLE_ENDIAN
  392. u16 flags;
  393. u16 type;
  394. #else
  395. u16 type;
  396. u16 flags;
  397. #endif
  398. #ifdef __LITTLE_ENDIAN
  399. u16 tcp_udp_csum;
  400. u16 ip_csum;
  401. #else
  402. u16 ip_csum;
  403. u16 tcp_udp_csum;
  404. #endif
  405. #ifdef __LITTLE_ENDIAN
  406. u16 vlan;
  407. u16 err_flags;
  408. #else
  409. u16 err_flags;
  410. u16 vlan;
  411. #endif
  412. u32 reserved;
  413. u32 opague;
  414. };
  415. /*
  416. * This struct is shared with the NIC firmware.
  417. */
  418. struct ring_ctrl {
  419. aceaddr rngptr;
  420. #ifdef __LITTLE_ENDIAN
  421. u16 flags;
  422. u16 max_len;
  423. #else
  424. u16 max_len;
  425. u16 flags;
  426. #endif
  427. u32 pad;
  428. };
  429. struct ace_mac_stats {
  430. u32 excess_colls;
  431. u32 coll_1;
  432. u32 coll_2;
  433. u32 coll_3;
  434. u32 coll_4;
  435. u32 coll_5;
  436. u32 coll_6;
  437. u32 coll_7;
  438. u32 coll_8;
  439. u32 coll_9;
  440. u32 coll_10;
  441. u32 coll_11;
  442. u32 coll_12;
  443. u32 coll_13;
  444. u32 coll_14;
  445. u32 coll_15;
  446. u32 late_coll;
  447. u32 defers;
  448. u32 crc_err;
  449. u32 underrun;
  450. u32 crs_err;
  451. u32 pad[3];
  452. u32 drop_ula;
  453. u32 drop_mc;
  454. u32 drop_fc;
  455. u32 drop_space;
  456. u32 coll;
  457. u32 kept_bc;
  458. u32 kept_mc;
  459. u32 kept_uc;
  460. };
  461. struct ace_info {
  462. union {
  463. u32 stats[256];
  464. } s;
  465. struct ring_ctrl evt_ctrl;
  466. struct ring_ctrl cmd_ctrl;
  467. struct ring_ctrl tx_ctrl;
  468. struct ring_ctrl rx_std_ctrl;
  469. struct ring_ctrl rx_jumbo_ctrl;
  470. struct ring_ctrl rx_mini_ctrl;
  471. struct ring_ctrl rx_return_ctrl;
  472. aceaddr evt_prd_ptr;
  473. aceaddr rx_ret_prd_ptr;
  474. aceaddr tx_csm_ptr;
  475. aceaddr stats2_ptr;
  476. };
  477. struct ring_info {
  478. struct sk_buff *skb;
  479. DEFINE_DMA_UNMAP_ADDR(mapping);
  480. };
  481. /*
  482. * Funny... As soon as we add maplen on alpha, it starts to work
  483. * much slower. Hmm... is it because struct does not fit to one cacheline?
  484. * So, split tx_ring_info.
  485. */
  486. struct tx_ring_info {
  487. struct sk_buff *skb;
  488. DEFINE_DMA_UNMAP_ADDR(mapping);
  489. DEFINE_DMA_UNMAP_LEN(maplen);
  490. };
  491. /*
  492. * struct ace_skb holding the rings of skb's. This is an awful lot of
  493. * pointers, but I don't see any other smart mode to do this in an
  494. * efficient manner ;-(
  495. */
  496. struct ace_skb
  497. {
  498. struct tx_ring_info tx_skbuff[MAX_TX_RING_ENTRIES];
  499. struct ring_info rx_std_skbuff[RX_STD_RING_ENTRIES];
  500. struct ring_info rx_mini_skbuff[RX_MINI_RING_ENTRIES];
  501. struct ring_info rx_jumbo_skbuff[RX_JUMBO_RING_ENTRIES];
  502. };
  503. /*
  504. * Struct private for the AceNIC.
  505. *
  506. * Elements are grouped so variables used by the tx handling goes
  507. * together, and will go into the same cache lines etc. in order to
  508. * avoid cache line contention between the rx and tx handling on SMP.
  509. *
  510. * Frequently accessed variables are put at the beginning of the
  511. * struct to help the compiler generate better/shorter code.
  512. */
  513. struct ace_private
  514. {
  515. struct ace_info *info;
  516. struct ace_regs __iomem *regs; /* register base */
  517. struct ace_skb *skb;
  518. dma_addr_t info_dma; /* 32/64 bit */
  519. int version, link;
  520. int promisc, mcast_all;
  521. /*
  522. * TX elements
  523. */
  524. struct tx_desc *tx_ring;
  525. u32 tx_prd;
  526. volatile u32 tx_ret_csm;
  527. int tx_ring_entries;
  528. /*
  529. * RX elements
  530. */
  531. unsigned long std_refill_busy
  532. __attribute__ ((aligned (SMP_CACHE_BYTES)));
  533. unsigned long mini_refill_busy, jumbo_refill_busy;
  534. atomic_t cur_rx_bufs;
  535. atomic_t cur_mini_bufs;
  536. atomic_t cur_jumbo_bufs;
  537. u32 rx_std_skbprd, rx_mini_skbprd, rx_jumbo_skbprd;
  538. u32 cur_rx;
  539. struct rx_desc *rx_std_ring;
  540. struct rx_desc *rx_jumbo_ring;
  541. struct rx_desc *rx_mini_ring;
  542. struct rx_desc *rx_return_ring;
  543. int tasklet_pending, jumbo;
  544. struct tasklet_struct ace_tasklet;
  545. struct event *evt_ring;
  546. volatile u32 *evt_prd, *rx_ret_prd, *tx_csm;
  547. dma_addr_t tx_ring_dma; /* 32/64 bit */
  548. dma_addr_t rx_ring_base_dma;
  549. dma_addr_t evt_ring_dma;
  550. dma_addr_t evt_prd_dma, rx_ret_prd_dma, tx_csm_dma;
  551. unsigned char *trace_buf;
  552. struct pci_dev *pdev;
  553. struct net_device *next;
  554. volatile int fw_running;
  555. int board_idx;
  556. u16 pci_command;
  557. u8 pci_latency;
  558. const char *name;
  559. #ifdef INDEX_DEBUG
  560. spinlock_t debug_lock
  561. __attribute__ ((aligned (SMP_CACHE_BYTES)));
  562. u32 last_tx, last_std_rx, last_mini_rx;
  563. #endif
  564. int pci_using_dac;
  565. u8 firmware_major;
  566. u8 firmware_minor;
  567. u8 firmware_fix;
  568. u32 firmware_start;
  569. };
  570. #define TX_RESERVED MAX_SKB_FRAGS
  571. static inline int tx_space (struct ace_private *ap, u32 csm, u32 prd)
  572. {
  573. return (csm - prd - 1) & (ACE_TX_RING_ENTRIES(ap) - 1);
  574. }
  575. #define tx_free(ap) tx_space((ap)->tx_ret_csm, (ap)->tx_prd, ap)
  576. #define tx_ring_full(ap, csm, prd) (tx_space(ap, csm, prd) <= TX_RESERVED)
  577. static inline void set_aceaddr(aceaddr *aa, dma_addr_t addr)
  578. {
  579. u64 baddr = (u64) addr;
  580. aa->addrlo = baddr & 0xffffffff;
  581. aa->addrhi = baddr >> 32;
  582. wmb();
  583. }
  584. static inline void ace_set_txprd(struct ace_regs __iomem *regs,
  585. struct ace_private *ap, u32 value)
  586. {
  587. #ifdef INDEX_DEBUG
  588. unsigned long flags;
  589. spin_lock_irqsave(&ap->debug_lock, flags);
  590. writel(value, &regs->TxPrd);
  591. if (value == ap->last_tx)
  592. printk(KERN_ERR "AceNIC RACE ALERT! writing identical value "
  593. "to tx producer (%i)\n", value);
  594. ap->last_tx = value;
  595. spin_unlock_irqrestore(&ap->debug_lock, flags);
  596. #else
  597. writel(value, &regs->TxPrd);
  598. #endif
  599. wmb();
  600. }
  601. static inline void ace_mask_irq(struct net_device *dev)
  602. {
  603. struct ace_private *ap = netdev_priv(dev);
  604. struct ace_regs __iomem *regs = ap->regs;
  605. if (ACE_IS_TIGON_I(ap))
  606. writel(1, &regs->MaskInt);
  607. else
  608. writel(readl(&regs->HostCtrl) | MASK_INTS, &regs->HostCtrl);
  609. ace_sync_irq(dev->irq);
  610. }
  611. static inline void ace_unmask_irq(struct net_device *dev)
  612. {
  613. struct ace_private *ap = netdev_priv(dev);
  614. struct ace_regs __iomem *regs = ap->regs;
  615. if (ACE_IS_TIGON_I(ap))
  616. writel(0, &regs->MaskInt);
  617. else
  618. writel(readl(&regs->HostCtrl) & ~MASK_INTS, &regs->HostCtrl);
  619. }
  620. /*
  621. * Prototypes
  622. */
  623. static int ace_init(struct net_device *dev);
  624. static void ace_load_std_rx_ring(struct net_device *dev, int nr_bufs);
  625. static void ace_load_mini_rx_ring(struct net_device *dev, int nr_bufs);
  626. static void ace_load_jumbo_rx_ring(struct net_device *dev, int nr_bufs);
  627. static irqreturn_t ace_interrupt(int irq, void *dev_id);
  628. static int ace_load_firmware(struct net_device *dev);
  629. static int ace_open(struct net_device *dev);
  630. static netdev_tx_t ace_start_xmit(struct sk_buff *skb,
  631. struct net_device *dev);
  632. static int ace_close(struct net_device *dev);
  633. static void ace_tasklet(unsigned long dev);
  634. static void ace_dump_trace(struct ace_private *ap);
  635. static void ace_set_multicast_list(struct net_device *dev);
  636. static int ace_change_mtu(struct net_device *dev, int new_mtu);
  637. static int ace_set_mac_addr(struct net_device *dev, void *p);
  638. static void ace_set_rxtx_parms(struct net_device *dev, int jumbo);
  639. static int ace_allocate_descriptors(struct net_device *dev);
  640. static void ace_free_descriptors(struct net_device *dev);
  641. static void ace_init_cleanup(struct net_device *dev);
  642. static struct net_device_stats *ace_get_stats(struct net_device *dev);
  643. static int read_eeprom_byte(struct net_device *dev, unsigned long offset);
  644. #endif /* _ACENIC_H_ */