typhoon.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625
  1. /* typhoon.h: chip info for the 3Com 3CR990 family of controllers */
  2. /*
  3. Written 2002-2003 by David Dillow <dave@thedillows.org>
  4. This software may be used and distributed according to the terms of
  5. the GNU General Public License (GPL), incorporated herein by reference.
  6. Drivers based on or derived from this code fall under the GPL and must
  7. retain the authorship, copyright and license notice. This file is not
  8. a complete program and may only be used when the entire operating
  9. system is licensed under the GPL.
  10. This software is available on a public web site. It may enable
  11. cryptographic capabilities of the 3Com hardware, and may be
  12. exported from the United States under License Exception "TSU"
  13. pursuant to 15 C.F.R. Section 740.13(e).
  14. This work was funded by the National Library of Medicine under
  15. the Department of Energy project number 0274DD06D1 and NLM project
  16. number Y1-LM-2015-01.
  17. */
  18. /* All Typhoon ring positions are specificed in bytes, and point to the
  19. * first "clean" entry in the ring -- ie the next entry we use for whatever
  20. * purpose.
  21. */
  22. /* The Typhoon basic ring
  23. * ringBase: where this ring lives (our virtual address)
  24. * lastWrite: the next entry we'll use
  25. */
  26. struct basic_ring {
  27. u8 *ringBase;
  28. u32 lastWrite;
  29. };
  30. /* The Typoon transmit ring -- same as a basic ring, plus:
  31. * lastRead: where we're at in regard to cleaning up the ring
  32. * writeRegister: register to use for writing (different for Hi & Lo rings)
  33. */
  34. struct transmit_ring {
  35. u8 *ringBase;
  36. u32 lastWrite;
  37. u32 lastRead;
  38. int writeRegister;
  39. };
  40. /* The host<->Typhoon ring index structure
  41. * This indicates the current positions in the rings
  42. *
  43. * All values must be in little endian format for the 3XP
  44. *
  45. * rxHiCleared: entry we've cleared to in the Hi receive ring
  46. * rxLoCleared: entry we've cleared to in the Lo receive ring
  47. * rxBuffReady: next entry we'll put a free buffer in
  48. * respCleared: entry we've cleared to in the response ring
  49. *
  50. * txLoCleared: entry the NIC has cleared to in the Lo transmit ring
  51. * txHiCleared: entry the NIC has cleared to in the Hi transmit ring
  52. * rxLoReady: entry the NIC has filled to in the Lo receive ring
  53. * rxBuffCleared: entry the NIC has cleared in the free buffer ring
  54. * cmdCleared: entry the NIC has cleared in the command ring
  55. * respReady: entry the NIC has filled to in the response ring
  56. * rxHiReady: entry the NIC has filled to in the Hi receive ring
  57. */
  58. struct typhoon_indexes {
  59. /* The first four are written by the host, and read by the NIC */
  60. volatile __le32 rxHiCleared;
  61. volatile __le32 rxLoCleared;
  62. volatile __le32 rxBuffReady;
  63. volatile __le32 respCleared;
  64. /* The remaining are written by the NIC, and read by the host */
  65. volatile __le32 txLoCleared;
  66. volatile __le32 txHiCleared;
  67. volatile __le32 rxLoReady;
  68. volatile __le32 rxBuffCleared;
  69. volatile __le32 cmdCleared;
  70. volatile __le32 respReady;
  71. volatile __le32 rxHiReady;
  72. } __packed;
  73. /* The host<->Typhoon interface
  74. * Our means of communicating where things are
  75. *
  76. * All values must be in little endian format for the 3XP
  77. *
  78. * ringIndex: 64 bit bus address of the index structure
  79. * txLoAddr: 64 bit bus address of the Lo transmit ring
  80. * txLoSize: size (in bytes) of the Lo transmit ring
  81. * txHi*: as above for the Hi priority transmit ring
  82. * rxLo*: as above for the Lo priority receive ring
  83. * rxBuff*: as above for the free buffer ring
  84. * cmd*: as above for the command ring
  85. * resp*: as above for the response ring
  86. * zeroAddr: 64 bit bus address of a zero word (for DMA)
  87. * rxHi*: as above for the Hi Priority receive ring
  88. *
  89. * While there is room for 64 bit addresses, current versions of the 3XP
  90. * only do 32 bit addresses, so the *Hi for each of the above will always
  91. * be zero.
  92. */
  93. struct typhoon_interface {
  94. __le32 ringIndex;
  95. __le32 ringIndexHi;
  96. __le32 txLoAddr;
  97. __le32 txLoAddrHi;
  98. __le32 txLoSize;
  99. __le32 txHiAddr;
  100. __le32 txHiAddrHi;
  101. __le32 txHiSize;
  102. __le32 rxLoAddr;
  103. __le32 rxLoAddrHi;
  104. __le32 rxLoSize;
  105. __le32 rxBuffAddr;
  106. __le32 rxBuffAddrHi;
  107. __le32 rxBuffSize;
  108. __le32 cmdAddr;
  109. __le32 cmdAddrHi;
  110. __le32 cmdSize;
  111. __le32 respAddr;
  112. __le32 respAddrHi;
  113. __le32 respSize;
  114. __le32 zeroAddr;
  115. __le32 zeroAddrHi;
  116. __le32 rxHiAddr;
  117. __le32 rxHiAddrHi;
  118. __le32 rxHiSize;
  119. } __packed;
  120. /* The Typhoon transmit/fragment descriptor
  121. *
  122. * A packet is described by a packet descriptor, followed by option descriptors,
  123. * if any, then one or more fragment descriptors.
  124. *
  125. * Packet descriptor:
  126. * flags: Descriptor type
  127. * len:i zero, or length of this packet
  128. * addr*: 8 bytes of opaque data to the firmware -- for skb pointer
  129. * processFlags: Determine offload tasks to perform on this packet.
  130. *
  131. * Fragment descriptor:
  132. * flags: Descriptor type
  133. * len:i length of this fragment
  134. * addr: low bytes of DMA address for this part of the packet
  135. * addrHi: hi bytes of DMA address for this part of the packet
  136. * processFlags: must be zero
  137. *
  138. * TYPHOON_DESC_VALID is not mentioned in their docs, but their Linux
  139. * driver uses it.
  140. */
  141. struct tx_desc {
  142. u8 flags;
  143. #define TYPHOON_TYPE_MASK 0x07
  144. #define TYPHOON_FRAG_DESC 0x00
  145. #define TYPHOON_TX_DESC 0x01
  146. #define TYPHOON_CMD_DESC 0x02
  147. #define TYPHOON_OPT_DESC 0x03
  148. #define TYPHOON_RX_DESC 0x04
  149. #define TYPHOON_RESP_DESC 0x05
  150. #define TYPHOON_OPT_TYPE_MASK 0xf0
  151. #define TYPHOON_OPT_IPSEC 0x00
  152. #define TYPHOON_OPT_TCP_SEG 0x10
  153. #define TYPHOON_CMD_RESPOND 0x40
  154. #define TYPHOON_RESP_ERROR 0x40
  155. #define TYPHOON_RX_ERROR 0x40
  156. #define TYPHOON_DESC_VALID 0x80
  157. u8 numDesc;
  158. __le16 len;
  159. union {
  160. struct {
  161. __le32 addr;
  162. __le32 addrHi;
  163. } frag;
  164. u64 tx_addr; /* opaque for hardware, for TX_DESC */
  165. };
  166. __le32 processFlags;
  167. #define TYPHOON_TX_PF_NO_CRC cpu_to_le32(0x00000001)
  168. #define TYPHOON_TX_PF_IP_CHKSUM cpu_to_le32(0x00000002)
  169. #define TYPHOON_TX_PF_TCP_CHKSUM cpu_to_le32(0x00000004)
  170. #define TYPHOON_TX_PF_TCP_SEGMENT cpu_to_le32(0x00000008)
  171. #define TYPHOON_TX_PF_INSERT_VLAN cpu_to_le32(0x00000010)
  172. #define TYPHOON_TX_PF_IPSEC cpu_to_le32(0x00000020)
  173. #define TYPHOON_TX_PF_VLAN_PRIORITY cpu_to_le32(0x00000040)
  174. #define TYPHOON_TX_PF_UDP_CHKSUM cpu_to_le32(0x00000080)
  175. #define TYPHOON_TX_PF_PAD_FRAME cpu_to_le32(0x00000100)
  176. #define TYPHOON_TX_PF_RESERVED cpu_to_le32(0x00000e00)
  177. #define TYPHOON_TX_PF_VLAN_MASK cpu_to_le32(0x0ffff000)
  178. #define TYPHOON_TX_PF_INTERNAL cpu_to_le32(0xf0000000)
  179. #define TYPHOON_TX_PF_VLAN_TAG_SHIFT 12
  180. } __packed;
  181. /* The TCP Segmentation offload option descriptor
  182. *
  183. * flags: descriptor type
  184. * numDesc: must be 1
  185. * mss_flags: bits 0-11 (little endian) are MSS, 12 is first TSO descriptor
  186. * 13 is list TSO descriptor, set both if only one TSO
  187. * respAddrLo: low bytes of address of the bytesTx field of this descriptor
  188. * bytesTx: total number of bytes in this TSO request
  189. * status: 0 on completion
  190. */
  191. struct tcpopt_desc {
  192. u8 flags;
  193. u8 numDesc;
  194. __le16 mss_flags;
  195. #define TYPHOON_TSO_FIRST cpu_to_le16(0x1000)
  196. #define TYPHOON_TSO_LAST cpu_to_le16(0x2000)
  197. __le32 respAddrLo;
  198. __le32 bytesTx;
  199. __le32 status;
  200. } __packed;
  201. /* The IPSEC Offload descriptor
  202. *
  203. * flags: descriptor type
  204. * numDesc: must be 1
  205. * ipsecFlags: bit 0: 0 -- generate IV, 1 -- use supplied IV
  206. * sa1, sa2: Security Association IDs for this packet
  207. * reserved: set to 0
  208. */
  209. struct ipsec_desc {
  210. u8 flags;
  211. u8 numDesc;
  212. __le16 ipsecFlags;
  213. #define TYPHOON_IPSEC_GEN_IV cpu_to_le16(0x0000)
  214. #define TYPHOON_IPSEC_USE_IV cpu_to_le16(0x0001)
  215. __le32 sa1;
  216. __le32 sa2;
  217. __le32 reserved;
  218. } __packed;
  219. /* The Typhoon receive descriptor (Updated by NIC)
  220. *
  221. * flags: Descriptor type, error indication
  222. * numDesc: Always zero
  223. * frameLen: the size of the packet received
  224. * addr: low 32 bytes of the virtual addr passed in for this buffer
  225. * addrHi: high 32 bytes of the virtual addr passed in for this buffer
  226. * rxStatus: Error if set in flags, otherwise result of offload processing
  227. * filterResults: results of filtering on packet, not used
  228. * ipsecResults: Results of IPSEC processing
  229. * vlanTag: the 801.2q TCI from the packet
  230. */
  231. struct rx_desc {
  232. u8 flags;
  233. u8 numDesc;
  234. __le16 frameLen;
  235. u32 addr; /* opaque, comes from virtAddr */
  236. u32 addrHi; /* opaque, comes from virtAddrHi */
  237. __le32 rxStatus;
  238. #define TYPHOON_RX_ERR_INTERNAL cpu_to_le32(0x00000000)
  239. #define TYPHOON_RX_ERR_FIFO_UNDERRUN cpu_to_le32(0x00000001)
  240. #define TYPHOON_RX_ERR_BAD_SSD cpu_to_le32(0x00000002)
  241. #define TYPHOON_RX_ERR_RUNT cpu_to_le32(0x00000003)
  242. #define TYPHOON_RX_ERR_CRC cpu_to_le32(0x00000004)
  243. #define TYPHOON_RX_ERR_OVERSIZE cpu_to_le32(0x00000005)
  244. #define TYPHOON_RX_ERR_ALIGN cpu_to_le32(0x00000006)
  245. #define TYPHOON_RX_ERR_DRIBBLE cpu_to_le32(0x00000007)
  246. #define TYPHOON_RX_PROTO_MASK cpu_to_le32(0x00000003)
  247. #define TYPHOON_RX_PROTO_UNKNOWN cpu_to_le32(0x00000000)
  248. #define TYPHOON_RX_PROTO_IP cpu_to_le32(0x00000001)
  249. #define TYPHOON_RX_PROTO_IPX cpu_to_le32(0x00000002)
  250. #define TYPHOON_RX_VLAN cpu_to_le32(0x00000004)
  251. #define TYPHOON_RX_IP_FRAG cpu_to_le32(0x00000008)
  252. #define TYPHOON_RX_IPSEC cpu_to_le32(0x00000010)
  253. #define TYPHOON_RX_IP_CHK_FAIL cpu_to_le32(0x00000020)
  254. #define TYPHOON_RX_TCP_CHK_FAIL cpu_to_le32(0x00000040)
  255. #define TYPHOON_RX_UDP_CHK_FAIL cpu_to_le32(0x00000080)
  256. #define TYPHOON_RX_IP_CHK_GOOD cpu_to_le32(0x00000100)
  257. #define TYPHOON_RX_TCP_CHK_GOOD cpu_to_le32(0x00000200)
  258. #define TYPHOON_RX_UDP_CHK_GOOD cpu_to_le32(0x00000400)
  259. __le16 filterResults;
  260. #define TYPHOON_RX_FILTER_MASK cpu_to_le16(0x7fff)
  261. #define TYPHOON_RX_FILTERED cpu_to_le16(0x8000)
  262. __le16 ipsecResults;
  263. #define TYPHOON_RX_OUTER_AH_GOOD cpu_to_le16(0x0001)
  264. #define TYPHOON_RX_OUTER_ESP_GOOD cpu_to_le16(0x0002)
  265. #define TYPHOON_RX_INNER_AH_GOOD cpu_to_le16(0x0004)
  266. #define TYPHOON_RX_INNER_ESP_GOOD cpu_to_le16(0x0008)
  267. #define TYPHOON_RX_OUTER_AH_FAIL cpu_to_le16(0x0010)
  268. #define TYPHOON_RX_OUTER_ESP_FAIL cpu_to_le16(0x0020)
  269. #define TYPHOON_RX_INNER_AH_FAIL cpu_to_le16(0x0040)
  270. #define TYPHOON_RX_INNER_ESP_FAIL cpu_to_le16(0x0080)
  271. #define TYPHOON_RX_UNKNOWN_SA cpu_to_le16(0x0100)
  272. #define TYPHOON_RX_ESP_FORMAT_ERR cpu_to_le16(0x0200)
  273. __be32 vlanTag;
  274. } __packed;
  275. /* The Typhoon free buffer descriptor, used to give a buffer to the NIC
  276. *
  277. * physAddr: low 32 bits of the bus address of the buffer
  278. * physAddrHi: high 32 bits of the bus address of the buffer, always zero
  279. * virtAddr: low 32 bits of the skb address
  280. * virtAddrHi: high 32 bits of the skb address, always zero
  281. *
  282. * the virt* address is basically two 32 bit cookies, just passed back
  283. * from the NIC
  284. */
  285. struct rx_free {
  286. __le32 physAddr;
  287. __le32 physAddrHi;
  288. u32 virtAddr;
  289. u32 virtAddrHi;
  290. } __packed;
  291. /* The Typhoon command descriptor, used for commands and responses
  292. *
  293. * flags: descriptor type
  294. * numDesc: number of descriptors following in this command/response,
  295. * ie, zero for a one descriptor command
  296. * cmd: the command
  297. * seqNo: sequence number (unused)
  298. * parm1: use varies by command
  299. * parm2: use varies by command
  300. * parm3: use varies by command
  301. */
  302. struct cmd_desc {
  303. u8 flags;
  304. u8 numDesc;
  305. __le16 cmd;
  306. #define TYPHOON_CMD_TX_ENABLE cpu_to_le16(0x0001)
  307. #define TYPHOON_CMD_TX_DISABLE cpu_to_le16(0x0002)
  308. #define TYPHOON_CMD_RX_ENABLE cpu_to_le16(0x0003)
  309. #define TYPHOON_CMD_RX_DISABLE cpu_to_le16(0x0004)
  310. #define TYPHOON_CMD_SET_RX_FILTER cpu_to_le16(0x0005)
  311. #define TYPHOON_CMD_READ_STATS cpu_to_le16(0x0007)
  312. #define TYPHOON_CMD_XCVR_SELECT cpu_to_le16(0x0013)
  313. #define TYPHOON_CMD_SET_MAX_PKT_SIZE cpu_to_le16(0x001a)
  314. #define TYPHOON_CMD_READ_MEDIA_STATUS cpu_to_le16(0x001b)
  315. #define TYPHOON_CMD_GOTO_SLEEP cpu_to_le16(0x0023)
  316. #define TYPHOON_CMD_SET_MULTICAST_HASH cpu_to_le16(0x0025)
  317. #define TYPHOON_CMD_SET_MAC_ADDRESS cpu_to_le16(0x0026)
  318. #define TYPHOON_CMD_READ_MAC_ADDRESS cpu_to_le16(0x0027)
  319. #define TYPHOON_CMD_VLAN_TYPE_WRITE cpu_to_le16(0x002b)
  320. #define TYPHOON_CMD_CREATE_SA cpu_to_le16(0x0034)
  321. #define TYPHOON_CMD_DELETE_SA cpu_to_le16(0x0035)
  322. #define TYPHOON_CMD_READ_VERSIONS cpu_to_le16(0x0043)
  323. #define TYPHOON_CMD_IRQ_COALESCE_CTRL cpu_to_le16(0x0045)
  324. #define TYPHOON_CMD_ENABLE_WAKE_EVENTS cpu_to_le16(0x0049)
  325. #define TYPHOON_CMD_SET_OFFLOAD_TASKS cpu_to_le16(0x004f)
  326. #define TYPHOON_CMD_HELLO_RESP cpu_to_le16(0x0057)
  327. #define TYPHOON_CMD_HALT cpu_to_le16(0x005d)
  328. #define TYPHOON_CMD_READ_IPSEC_INFO cpu_to_le16(0x005e)
  329. #define TYPHOON_CMD_GET_IPSEC_ENABLE cpu_to_le16(0x0067)
  330. #define TYPHOON_CMD_GET_CMD_LVL cpu_to_le16(0x0069)
  331. u16 seqNo;
  332. __le16 parm1;
  333. __le32 parm2;
  334. __le32 parm3;
  335. } __packed;
  336. /* The Typhoon response descriptor, see command descriptor for details
  337. */
  338. struct resp_desc {
  339. u8 flags;
  340. u8 numDesc;
  341. __le16 cmd;
  342. __le16 seqNo;
  343. __le16 parm1;
  344. __le32 parm2;
  345. __le32 parm3;
  346. } __packed;
  347. #define INIT_COMMAND_NO_RESPONSE(x, command) \
  348. do { struct cmd_desc *_ptr = (x); \
  349. memset(_ptr, 0, sizeof(struct cmd_desc)); \
  350. _ptr->flags = TYPHOON_CMD_DESC | TYPHOON_DESC_VALID; \
  351. _ptr->cmd = command; \
  352. } while(0)
  353. /* We set seqNo to 1 if we're expecting a response from this command */
  354. #define INIT_COMMAND_WITH_RESPONSE(x, command) \
  355. do { struct cmd_desc *_ptr = (x); \
  356. memset(_ptr, 0, sizeof(struct cmd_desc)); \
  357. _ptr->flags = TYPHOON_CMD_RESPOND | TYPHOON_CMD_DESC; \
  358. _ptr->flags |= TYPHOON_DESC_VALID; \
  359. _ptr->cmd = command; \
  360. _ptr->seqNo = 1; \
  361. } while(0)
  362. /* TYPHOON_CMD_SET_RX_FILTER filter bits (cmd.parm1)
  363. */
  364. #define TYPHOON_RX_FILTER_DIRECTED cpu_to_le16(0x0001)
  365. #define TYPHOON_RX_FILTER_ALL_MCAST cpu_to_le16(0x0002)
  366. #define TYPHOON_RX_FILTER_BROADCAST cpu_to_le16(0x0004)
  367. #define TYPHOON_RX_FILTER_PROMISCOUS cpu_to_le16(0x0008)
  368. #define TYPHOON_RX_FILTER_MCAST_HASH cpu_to_le16(0x0010)
  369. /* TYPHOON_CMD_READ_STATS response format
  370. */
  371. struct stats_resp {
  372. u8 flags;
  373. u8 numDesc;
  374. __le16 cmd;
  375. __le16 seqNo;
  376. __le16 unused;
  377. __le32 txPackets;
  378. __le64 txBytes;
  379. __le32 txDeferred;
  380. __le32 txLateCollisions;
  381. __le32 txCollisions;
  382. __le32 txCarrierLost;
  383. __le32 txMultipleCollisions;
  384. __le32 txExcessiveCollisions;
  385. __le32 txFifoUnderruns;
  386. __le32 txMulticastTxOverflows;
  387. __le32 txFiltered;
  388. __le32 rxPacketsGood;
  389. __le64 rxBytesGood;
  390. __le32 rxFifoOverruns;
  391. __le32 BadSSD;
  392. __le32 rxCrcErrors;
  393. __le32 rxOversized;
  394. __le32 rxBroadcast;
  395. __le32 rxMulticast;
  396. __le32 rxOverflow;
  397. __le32 rxFiltered;
  398. __le32 linkStatus;
  399. #define TYPHOON_LINK_STAT_MASK cpu_to_le32(0x00000001)
  400. #define TYPHOON_LINK_GOOD cpu_to_le32(0x00000001)
  401. #define TYPHOON_LINK_BAD cpu_to_le32(0x00000000)
  402. #define TYPHOON_LINK_SPEED_MASK cpu_to_le32(0x00000002)
  403. #define TYPHOON_LINK_100MBPS cpu_to_le32(0x00000002)
  404. #define TYPHOON_LINK_10MBPS cpu_to_le32(0x00000000)
  405. #define TYPHOON_LINK_DUPLEX_MASK cpu_to_le32(0x00000004)
  406. #define TYPHOON_LINK_FULL_DUPLEX cpu_to_le32(0x00000004)
  407. #define TYPHOON_LINK_HALF_DUPLEX cpu_to_le32(0x00000000)
  408. __le32 unused2;
  409. __le32 unused3;
  410. } __packed;
  411. /* TYPHOON_CMD_XCVR_SELECT xcvr values (resp.parm1)
  412. */
  413. #define TYPHOON_XCVR_10HALF cpu_to_le16(0x0000)
  414. #define TYPHOON_XCVR_10FULL cpu_to_le16(0x0001)
  415. #define TYPHOON_XCVR_100HALF cpu_to_le16(0x0002)
  416. #define TYPHOON_XCVR_100FULL cpu_to_le16(0x0003)
  417. #define TYPHOON_XCVR_AUTONEG cpu_to_le16(0x0004)
  418. /* TYPHOON_CMD_READ_MEDIA_STATUS (resp.parm1)
  419. */
  420. #define TYPHOON_MEDIA_STAT_CRC_STRIP_DISABLE cpu_to_le16(0x0004)
  421. #define TYPHOON_MEDIA_STAT_COLLISION_DETECT cpu_to_le16(0x0010)
  422. #define TYPHOON_MEDIA_STAT_CARRIER_SENSE cpu_to_le16(0x0020)
  423. #define TYPHOON_MEDIA_STAT_POLARITY_REV cpu_to_le16(0x0400)
  424. #define TYPHOON_MEDIA_STAT_NO_LINK cpu_to_le16(0x0800)
  425. /* TYPHOON_CMD_SET_MULTICAST_HASH enable values (cmd.parm1)
  426. */
  427. #define TYPHOON_MCAST_HASH_DISABLE cpu_to_le16(0x0000)
  428. #define TYPHOON_MCAST_HASH_ENABLE cpu_to_le16(0x0001)
  429. #define TYPHOON_MCAST_HASH_SET cpu_to_le16(0x0002)
  430. /* TYPHOON_CMD_CREATE_SA descriptor and settings
  431. */
  432. struct sa_descriptor {
  433. u8 flags;
  434. u8 numDesc;
  435. u16 cmd;
  436. u16 seqNo;
  437. u16 mode;
  438. #define TYPHOON_SA_MODE_NULL cpu_to_le16(0x0000)
  439. #define TYPHOON_SA_MODE_AH cpu_to_le16(0x0001)
  440. #define TYPHOON_SA_MODE_ESP cpu_to_le16(0x0002)
  441. u8 hashFlags;
  442. #define TYPHOON_SA_HASH_ENABLE 0x01
  443. #define TYPHOON_SA_HASH_SHA1 0x02
  444. #define TYPHOON_SA_HASH_MD5 0x04
  445. u8 direction;
  446. #define TYPHOON_SA_DIR_RX 0x00
  447. #define TYPHOON_SA_DIR_TX 0x01
  448. u8 encryptionFlags;
  449. #define TYPHOON_SA_ENCRYPT_ENABLE 0x01
  450. #define TYPHOON_SA_ENCRYPT_DES 0x02
  451. #define TYPHOON_SA_ENCRYPT_3DES 0x00
  452. #define TYPHOON_SA_ENCRYPT_3DES_2KEY 0x00
  453. #define TYPHOON_SA_ENCRYPT_3DES_3KEY 0x04
  454. #define TYPHOON_SA_ENCRYPT_CBC 0x08
  455. #define TYPHOON_SA_ENCRYPT_ECB 0x00
  456. u8 specifyIndex;
  457. #define TYPHOON_SA_SPECIFY_INDEX 0x01
  458. #define TYPHOON_SA_GENERATE_INDEX 0x00
  459. u32 SPI;
  460. u32 destAddr;
  461. u32 destMask;
  462. u8 integKey[20];
  463. u8 confKey[24];
  464. u32 index;
  465. u32 unused;
  466. u32 unused2;
  467. } __packed;
  468. /* TYPHOON_CMD_SET_OFFLOAD_TASKS bits (cmd.parm2 (Tx) & cmd.parm3 (Rx))
  469. * This is all for IPv4.
  470. */
  471. #define TYPHOON_OFFLOAD_TCP_CHKSUM cpu_to_le32(0x00000002)
  472. #define TYPHOON_OFFLOAD_UDP_CHKSUM cpu_to_le32(0x00000004)
  473. #define TYPHOON_OFFLOAD_IP_CHKSUM cpu_to_le32(0x00000008)
  474. #define TYPHOON_OFFLOAD_IPSEC cpu_to_le32(0x00000010)
  475. #define TYPHOON_OFFLOAD_BCAST_THROTTLE cpu_to_le32(0x00000020)
  476. #define TYPHOON_OFFLOAD_DHCP_PREVENT cpu_to_le32(0x00000040)
  477. #define TYPHOON_OFFLOAD_VLAN cpu_to_le32(0x00000080)
  478. #define TYPHOON_OFFLOAD_FILTERING cpu_to_le32(0x00000100)
  479. #define TYPHOON_OFFLOAD_TCP_SEGMENT cpu_to_le32(0x00000200)
  480. /* TYPHOON_CMD_ENABLE_WAKE_EVENTS bits (cmd.parm1)
  481. */
  482. #define TYPHOON_WAKE_MAGIC_PKT cpu_to_le16(0x01)
  483. #define TYPHOON_WAKE_LINK_EVENT cpu_to_le16(0x02)
  484. #define TYPHOON_WAKE_ICMP_ECHO cpu_to_le16(0x04)
  485. #define TYPHOON_WAKE_ARP cpu_to_le16(0x08)
  486. /* These are used to load the firmware image on the NIC
  487. */
  488. struct typhoon_file_header {
  489. u8 tag[8];
  490. __le32 version;
  491. __le32 numSections;
  492. __le32 startAddr;
  493. __le32 hmacDigest[5];
  494. } __packed;
  495. struct typhoon_section_header {
  496. __le32 len;
  497. u16 checksum;
  498. u16 reserved;
  499. __le32 startAddr;
  500. } __packed;
  501. /* The Typhoon Register offsets
  502. */
  503. #define TYPHOON_REG_SOFT_RESET 0x00
  504. #define TYPHOON_REG_INTR_STATUS 0x04
  505. #define TYPHOON_REG_INTR_ENABLE 0x08
  506. #define TYPHOON_REG_INTR_MASK 0x0c
  507. #define TYPHOON_REG_SELF_INTERRUPT 0x10
  508. #define TYPHOON_REG_HOST2ARM7 0x14
  509. #define TYPHOON_REG_HOST2ARM6 0x18
  510. #define TYPHOON_REG_HOST2ARM5 0x1c
  511. #define TYPHOON_REG_HOST2ARM4 0x20
  512. #define TYPHOON_REG_HOST2ARM3 0x24
  513. #define TYPHOON_REG_HOST2ARM2 0x28
  514. #define TYPHOON_REG_HOST2ARM1 0x2c
  515. #define TYPHOON_REG_HOST2ARM0 0x30
  516. #define TYPHOON_REG_ARM2HOST3 0x34
  517. #define TYPHOON_REG_ARM2HOST2 0x38
  518. #define TYPHOON_REG_ARM2HOST1 0x3c
  519. #define TYPHOON_REG_ARM2HOST0 0x40
  520. #define TYPHOON_REG_BOOT_DATA_LO TYPHOON_REG_HOST2ARM5
  521. #define TYPHOON_REG_BOOT_DATA_HI TYPHOON_REG_HOST2ARM4
  522. #define TYPHOON_REG_BOOT_DEST_ADDR TYPHOON_REG_HOST2ARM3
  523. #define TYPHOON_REG_BOOT_CHECKSUM TYPHOON_REG_HOST2ARM2
  524. #define TYPHOON_REG_BOOT_LENGTH TYPHOON_REG_HOST2ARM1
  525. #define TYPHOON_REG_DOWNLOAD_BOOT_ADDR TYPHOON_REG_HOST2ARM1
  526. #define TYPHOON_REG_DOWNLOAD_HMAC_0 TYPHOON_REG_HOST2ARM2
  527. #define TYPHOON_REG_DOWNLOAD_HMAC_1 TYPHOON_REG_HOST2ARM3
  528. #define TYPHOON_REG_DOWNLOAD_HMAC_2 TYPHOON_REG_HOST2ARM4
  529. #define TYPHOON_REG_DOWNLOAD_HMAC_3 TYPHOON_REG_HOST2ARM5
  530. #define TYPHOON_REG_DOWNLOAD_HMAC_4 TYPHOON_REG_HOST2ARM6
  531. #define TYPHOON_REG_BOOT_RECORD_ADDR_HI TYPHOON_REG_HOST2ARM2
  532. #define TYPHOON_REG_BOOT_RECORD_ADDR_LO TYPHOON_REG_HOST2ARM1
  533. #define TYPHOON_REG_TX_LO_READY TYPHOON_REG_HOST2ARM3
  534. #define TYPHOON_REG_CMD_READY TYPHOON_REG_HOST2ARM2
  535. #define TYPHOON_REG_TX_HI_READY TYPHOON_REG_HOST2ARM1
  536. #define TYPHOON_REG_COMMAND TYPHOON_REG_HOST2ARM0
  537. #define TYPHOON_REG_HEARTBEAT TYPHOON_REG_ARM2HOST3
  538. #define TYPHOON_REG_STATUS TYPHOON_REG_ARM2HOST0
  539. /* 3XP Reset values (TYPHOON_REG_SOFT_RESET)
  540. */
  541. #define TYPHOON_RESET_ALL 0x7f
  542. #define TYPHOON_RESET_NONE 0x00
  543. /* 3XP irq bits (TYPHOON_REG_INTR{STATUS,ENABLE,MASK})
  544. *
  545. * Some of these came from OpenBSD, as the 3Com docs have it wrong
  546. * (INTR_SELF) or don't list it at all (INTR_*_ABORT)
  547. *
  548. * Enabling irqs on the Heartbeat reg (ArmToHost3) gets you an irq
  549. * about every 8ms, so don't do it.
  550. */
  551. #define TYPHOON_INTR_HOST_INT 0x00000001
  552. #define TYPHOON_INTR_ARM2HOST0 0x00000002
  553. #define TYPHOON_INTR_ARM2HOST1 0x00000004
  554. #define TYPHOON_INTR_ARM2HOST2 0x00000008
  555. #define TYPHOON_INTR_ARM2HOST3 0x00000010
  556. #define TYPHOON_INTR_DMA0 0x00000020
  557. #define TYPHOON_INTR_DMA1 0x00000040
  558. #define TYPHOON_INTR_DMA2 0x00000080
  559. #define TYPHOON_INTR_DMA3 0x00000100
  560. #define TYPHOON_INTR_MASTER_ABORT 0x00000200
  561. #define TYPHOON_INTR_TARGET_ABORT 0x00000400
  562. #define TYPHOON_INTR_SELF 0x00000800
  563. #define TYPHOON_INTR_RESERVED 0xfffff000
  564. #define TYPHOON_INTR_BOOTCMD TYPHOON_INTR_ARM2HOST0
  565. #define TYPHOON_INTR_ENABLE_ALL 0xffffffef
  566. #define TYPHOON_INTR_ALL 0xffffffff
  567. #define TYPHOON_INTR_NONE 0x00000000
  568. /* The commands for the 3XP chip (TYPHOON_REG_COMMAND)
  569. */
  570. #define TYPHOON_BOOTCMD_BOOT 0x00
  571. #define TYPHOON_BOOTCMD_WAKEUP 0xfa
  572. #define TYPHOON_BOOTCMD_DNLD_COMPLETE 0xfb
  573. #define TYPHOON_BOOTCMD_SEG_AVAILABLE 0xfc
  574. #define TYPHOON_BOOTCMD_RUNTIME_IMAGE 0xfd
  575. #define TYPHOON_BOOTCMD_REG_BOOT_RECORD 0xff
  576. /* 3XP Status values (TYPHOON_REG_STATUS)
  577. */
  578. #define TYPHOON_STATUS_WAITING_FOR_BOOT 0x07
  579. #define TYPHOON_STATUS_SECOND_INIT 0x08
  580. #define TYPHOON_STATUS_RUNNING 0x09
  581. #define TYPHOON_STATUS_WAITING_FOR_HOST 0x0d
  582. #define TYPHOON_STATUS_WAITING_FOR_SEGMENT 0x10
  583. #define TYPHOON_STATUS_SLEEPING 0x11
  584. #define TYPHOON_STATUS_HALTED 0x14