acenic.h 16 KB

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