myri10ge_mcp.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  1. #ifndef __MYRI10GE_MCP_H__
  2. #define __MYRI10GE_MCP_H__
  3. #define MXGEFW_VERSION_MAJOR 1
  4. #define MXGEFW_VERSION_MINOR 4
  5. /* 8 Bytes */
  6. struct mcp_dma_addr {
  7. __be32 high;
  8. __be32 low;
  9. };
  10. /* 4 Bytes */
  11. struct mcp_slot {
  12. __sum16 checksum;
  13. __be16 length;
  14. };
  15. /* 64 Bytes */
  16. struct mcp_cmd {
  17. __be32 cmd;
  18. __be32 data0; /* will be low portion if data > 32 bits */
  19. /* 8 */
  20. __be32 data1; /* will be high portion if data > 32 bits */
  21. __be32 data2; /* currently unused.. */
  22. /* 16 */
  23. struct mcp_dma_addr response_addr;
  24. /* 24 */
  25. u8 pad[40];
  26. };
  27. /* 8 Bytes */
  28. struct mcp_cmd_response {
  29. __be32 data;
  30. __be32 result;
  31. };
  32. /*
  33. * flags used in mcp_kreq_ether_send_t:
  34. *
  35. * The SMALL flag is only needed in the first segment. It is raised
  36. * for packets that are total less or equal 512 bytes.
  37. *
  38. * The CKSUM flag must be set in all segments.
  39. *
  40. * The PADDED flags is set if the packet needs to be padded, and it
  41. * must be set for all segments.
  42. *
  43. * The MXGEFW_FLAGS_ALIGN_ODD must be set if the cumulative
  44. * length of all previous segments was odd.
  45. */
  46. #define MXGEFW_FLAGS_SMALL 0x1
  47. #define MXGEFW_FLAGS_TSO_HDR 0x1
  48. #define MXGEFW_FLAGS_FIRST 0x2
  49. #define MXGEFW_FLAGS_ALIGN_ODD 0x4
  50. #define MXGEFW_FLAGS_CKSUM 0x8
  51. #define MXGEFW_FLAGS_TSO_LAST 0x8
  52. #define MXGEFW_FLAGS_NO_TSO 0x10
  53. #define MXGEFW_FLAGS_TSO_CHOP 0x10
  54. #define MXGEFW_FLAGS_TSO_PLD 0x20
  55. #define MXGEFW_SEND_SMALL_SIZE 1520
  56. #define MXGEFW_MAX_MTU 9400
  57. union mcp_pso_or_cumlen {
  58. u16 pseudo_hdr_offset;
  59. u16 cum_len;
  60. };
  61. #define MXGEFW_MAX_SEND_DESC 12
  62. #define MXGEFW_PAD 2
  63. /* 16 Bytes */
  64. struct mcp_kreq_ether_send {
  65. __be32 addr_high;
  66. __be32 addr_low;
  67. __be16 pseudo_hdr_offset;
  68. __be16 length;
  69. u8 pad;
  70. u8 rdma_count;
  71. u8 cksum_offset; /* where to start computing cksum */
  72. u8 flags; /* as defined above */
  73. };
  74. /* 8 Bytes */
  75. struct mcp_kreq_ether_recv {
  76. __be32 addr_high;
  77. __be32 addr_low;
  78. };
  79. /* Commands */
  80. #define MXGEFW_BOOT_HANDOFF 0xfc0000
  81. #define MXGEFW_BOOT_DUMMY_RDMA 0xfc01c0
  82. #define MXGEFW_ETH_CMD 0xf80000
  83. #define MXGEFW_ETH_SEND_4 0x200000
  84. #define MXGEFW_ETH_SEND_1 0x240000
  85. #define MXGEFW_ETH_SEND_2 0x280000
  86. #define MXGEFW_ETH_SEND_3 0x2c0000
  87. #define MXGEFW_ETH_RECV_SMALL 0x300000
  88. #define MXGEFW_ETH_RECV_BIG 0x340000
  89. #define MXGEFW_ETH_SEND(n) (0x200000 + (((n) & 0x03) * 0x40000))
  90. #define MXGEFW_ETH_SEND_OFFSET(n) (MXGEFW_ETH_SEND(n) - MXGEFW_ETH_SEND_4)
  91. enum myri10ge_mcp_cmd_type {
  92. MXGEFW_CMD_NONE = 0,
  93. /* Reset the mcp, it is left in a safe state, waiting
  94. * for the driver to set all its parameters */
  95. MXGEFW_CMD_RESET,
  96. /* get the version number of the current firmware..
  97. * (may be available in the eeprom strings..? */
  98. MXGEFW_GET_MCP_VERSION,
  99. /* Parameters which must be set by the driver before it can
  100. * issue MXGEFW_CMD_ETHERNET_UP. They persist until the next
  101. * MXGEFW_CMD_RESET is issued */
  102. MXGEFW_CMD_SET_INTRQ_DMA,
  103. MXGEFW_CMD_SET_BIG_BUFFER_SIZE, /* in bytes, power of 2 */
  104. MXGEFW_CMD_SET_SMALL_BUFFER_SIZE, /* in bytes */
  105. /* Parameters which refer to lanai SRAM addresses where the
  106. * driver must issue PIO writes for various things */
  107. MXGEFW_CMD_GET_SEND_OFFSET,
  108. MXGEFW_CMD_GET_SMALL_RX_OFFSET,
  109. MXGEFW_CMD_GET_BIG_RX_OFFSET,
  110. MXGEFW_CMD_GET_IRQ_ACK_OFFSET,
  111. MXGEFW_CMD_GET_IRQ_DEASSERT_OFFSET,
  112. /* Parameters which refer to rings stored on the MCP,
  113. * and whose size is controlled by the mcp */
  114. MXGEFW_CMD_GET_SEND_RING_SIZE, /* in bytes */
  115. MXGEFW_CMD_GET_RX_RING_SIZE, /* in bytes */
  116. /* Parameters which refer to rings stored in the host,
  117. * and whose size is controlled by the host. Note that
  118. * all must be physically contiguous and must contain
  119. * a power of 2 number of entries. */
  120. MXGEFW_CMD_SET_INTRQ_SIZE, /* in bytes */
  121. #define MXGEFW_CMD_SET_INTRQ_SIZE_FLAG_NO_STRICT_SIZE_CHECK (1 << 31)
  122. /* command to bring ethernet interface up. Above parameters
  123. * (plus mtu & mac address) must have been exchanged prior
  124. * to issuing this command */
  125. MXGEFW_CMD_ETHERNET_UP,
  126. /* command to bring ethernet interface down. No further sends
  127. * or receives may be processed until an MXGEFW_CMD_ETHERNET_UP
  128. * is issued, and all interrupt queues must be flushed prior
  129. * to ack'ing this command */
  130. MXGEFW_CMD_ETHERNET_DOWN,
  131. /* commands the driver may issue live, without resetting
  132. * the nic. Note that increasing the mtu "live" should
  133. * only be done if the driver has already supplied buffers
  134. * sufficiently large to handle the new mtu. Decreasing
  135. * the mtu live is safe */
  136. MXGEFW_CMD_SET_MTU,
  137. MXGEFW_CMD_GET_INTR_COAL_DELAY_OFFSET, /* in microseconds */
  138. MXGEFW_CMD_SET_STATS_INTERVAL, /* in microseconds */
  139. MXGEFW_CMD_SET_STATS_DMA_OBSOLETE, /* replaced by SET_STATS_DMA_V2 */
  140. MXGEFW_ENABLE_PROMISC,
  141. MXGEFW_DISABLE_PROMISC,
  142. MXGEFW_SET_MAC_ADDRESS,
  143. MXGEFW_ENABLE_FLOW_CONTROL,
  144. MXGEFW_DISABLE_FLOW_CONTROL,
  145. /* do a DMA test
  146. * data0,data1 = DMA address
  147. * data2 = RDMA length (MSH), WDMA length (LSH)
  148. * command return data = repetitions (MSH), 0.5-ms ticks (LSH)
  149. */
  150. MXGEFW_DMA_TEST,
  151. MXGEFW_ENABLE_ALLMULTI,
  152. MXGEFW_DISABLE_ALLMULTI,
  153. /* returns MXGEFW_CMD_ERROR_MULTICAST
  154. * if there is no room in the cache
  155. * data0,MSH(data1) = multicast group address */
  156. MXGEFW_JOIN_MULTICAST_GROUP,
  157. /* returns MXGEFW_CMD_ERROR_MULTICAST
  158. * if the address is not in the cache,
  159. * or is equal to FF-FF-FF-FF-FF-FF
  160. * data0,MSH(data1) = multicast group address */
  161. MXGEFW_LEAVE_MULTICAST_GROUP,
  162. MXGEFW_LEAVE_ALL_MULTICAST_GROUPS,
  163. MXGEFW_CMD_SET_STATS_DMA_V2,
  164. /* data0, data1 = bus addr,
  165. * data2 = sizeof(struct mcp_irq_data) from driver point of view, allows
  166. * adding new stuff to mcp_irq_data without changing the ABI */
  167. MXGEFW_CMD_UNALIGNED_TEST,
  168. /* same than DMA_TEST (same args) but abort with UNALIGNED on unaligned
  169. * chipset */
  170. MXGEFW_CMD_UNALIGNED_STATUS,
  171. /* return data = boolean, true if the chipset is known to be unaligned */
  172. MXGEFW_CMD_ALWAYS_USE_N_BIG_BUFFERS,
  173. /* data0 = number of big buffers to use. It must be 0 or a power of 2.
  174. * 0 indicates that the NIC consumes as many buffers as they are required
  175. * for packet. This is the default behavior.
  176. * A power of 2 number indicates that the NIC always uses the specified
  177. * number of buffers for each big receive packet.
  178. * It is up to the driver to ensure that this value is big enough for
  179. * the NIC to be able to receive maximum-sized packets.
  180. */
  181. MXGEFW_CMD_GET_MAX_RSS_QUEUES,
  182. MXGEFW_CMD_ENABLE_RSS_QUEUES,
  183. /* data0 = number of slices n (0, 1, ..., n-1) to enable
  184. * data1 = interrupt mode.
  185. * 0=share one INTx/MSI, 1=use one MSI-X per queue.
  186. * If all queues share one interrupt, the driver must have set
  187. * RSS_SHARED_INTERRUPT_DMA before enabling queues.
  188. */
  189. #define MXGEFW_SLICE_INTR_MODE_SHARED 0
  190. #define MXGEFW_SLICE_INTR_MODE_ONE_PER_SLICE 1
  191. MXGEFW_CMD_GET_RSS_SHARED_INTERRUPT_MASK_OFFSET,
  192. MXGEFW_CMD_SET_RSS_SHARED_INTERRUPT_DMA,
  193. /* data0, data1 = bus address lsw, msw */
  194. MXGEFW_CMD_GET_RSS_TABLE_OFFSET,
  195. /* get the offset of the indirection table */
  196. MXGEFW_CMD_SET_RSS_TABLE_SIZE,
  197. /* set the size of the indirection table */
  198. MXGEFW_CMD_GET_RSS_KEY_OFFSET,
  199. /* get the offset of the secret key */
  200. MXGEFW_CMD_RSS_KEY_UPDATED,
  201. /* tell nic that the secret key's been updated */
  202. MXGEFW_CMD_SET_RSS_ENABLE,
  203. /* data0 = enable/disable rss
  204. * 0: disable rss. nic does not distribute receive packets.
  205. * 1: enable rss. nic distributes receive packets among queues.
  206. * data1 = hash type
  207. * 1: IPV4 (required by RSS)
  208. * 2: TCP_IPV4 (required by RSS)
  209. * 3: IPV4 | TCP_IPV4 (required by RSS)
  210. * 4: source port
  211. */
  212. #define MXGEFW_RSS_HASH_TYPE_IPV4 0x1
  213. #define MXGEFW_RSS_HASH_TYPE_TCP_IPV4 0x2
  214. #define MXGEFW_RSS_HASH_TYPE_SRC_PORT 0x4
  215. MXGEFW_CMD_GET_MAX_TSO6_HDR_SIZE,
  216. /* Return data = the max. size of the entire headers of a IPv6 TSO packet.
  217. * If the header size of a IPv6 TSO packet is larger than the specified
  218. * value, then the driver must not use TSO.
  219. * This size restriction only applies to IPv6 TSO.
  220. * For IPv4 TSO, the maximum size of the headers is fixed, and the NIC
  221. * always has enough header buffer to store maximum-sized headers.
  222. */
  223. MXGEFW_CMD_SET_TSO_MODE,
  224. /* data0 = TSO mode.
  225. * 0: Linux/FreeBSD style (NIC default)
  226. * 1: NDIS/NetBSD style
  227. */
  228. #define MXGEFW_TSO_MODE_LINUX 0
  229. #define MXGEFW_TSO_MODE_NDIS 1
  230. MXGEFW_CMD_MDIO_READ,
  231. /* data0 = dev_addr (PMA/PMD or PCS ...), data1 = register/addr */
  232. MXGEFW_CMD_MDIO_WRITE,
  233. /* data0 = dev_addr, data1 = register/addr, data2 = value */
  234. MXGEFW_CMD_XFP_I2C_READ,
  235. /* Starts to get a fresh copy of one byte or of the whole xfp i2c table, the
  236. * obtained data is cached inside the xaui-xfi chip :
  237. * data0 : "all" flag : 0 => get one byte, 1=> get 256 bytes,
  238. * data1 : if (data0 == 0): index of byte to refresh [ not used otherwise ]
  239. * The operation might take ~1ms for a single byte or ~65ms when refreshing all 256 bytes
  240. * During the i2c operation, MXGEFW_CMD_XFP_I2C_READ or MXGEFW_CMD_XFP_BYTE attempts
  241. * will return MXGEFW_CMD_ERROR_BUSY
  242. */
  243. MXGEFW_CMD_XFP_BYTE,
  244. /* Return the last obtained copy of a given byte in the xfp i2c table
  245. * (copy cached during the last relevant MXGEFW_CMD_XFP_I2C_READ)
  246. * data0 : index of the desired table entry
  247. * Return data = the byte stored at the requested index in the table
  248. */
  249. MXGEFW_CMD_GET_VPUMP_OFFSET,
  250. /* Return data = NIC memory offset of mcp_vpump_public_global */
  251. MXGEFW_CMD_RESET_VPUMP,
  252. /* Resets the VPUMP state */
  253. MXGEFW_CMD_SET_RSS_MCP_SLOT_TYPE,
  254. /* data0 = mcp_slot type to use.
  255. * 0 = the default 4B mcp_slot
  256. * 1 = 8B mcp_slot_8
  257. */
  258. #define MXGEFW_RSS_MCP_SLOT_TYPE_MIN 0
  259. #define MXGEFW_RSS_MCP_SLOT_TYPE_WITH_HASH 1
  260. MXGEFW_CMD_SET_THROTTLE_FACTOR,
  261. /* set the throttle factor for ethp_z8e
  262. * data0 = throttle_factor
  263. * throttle_factor = 256 * pcie-raw-speed / tx_speed
  264. * tx_speed = 256 * pcie-raw-speed / throttle_factor
  265. *
  266. * For PCI-E x8: pcie-raw-speed == 16Gb/s
  267. * For PCI-E x4: pcie-raw-speed == 8Gb/s
  268. *
  269. * ex1: throttle_factor == 0x1a0 (416), tx_speed == 1.23GB/s == 9.846 Gb/s
  270. * ex2: throttle_factor == 0x200 (512), tx_speed == 1.0GB/s == 8 Gb/s
  271. *
  272. * with tx_boundary == 2048, max-throttle-factor == 8191 => min-speed == 500Mb/s
  273. * with tx_boundary == 4096, max-throttle-factor == 4095 => min-speed == 1Gb/s
  274. */
  275. MXGEFW_CMD_VPUMP_UP,
  276. /* Allocates VPump Connection, Send Request and Zero copy buffer address tables */
  277. MXGEFW_CMD_GET_VPUMP_CLK,
  278. /* Get the lanai clock */
  279. MXGEFW_CMD_GET_DCA_OFFSET,
  280. /* offset of dca control for WDMAs */
  281. };
  282. enum myri10ge_mcp_cmd_status {
  283. MXGEFW_CMD_OK = 0,
  284. MXGEFW_CMD_UNKNOWN,
  285. MXGEFW_CMD_ERROR_RANGE,
  286. MXGEFW_CMD_ERROR_BUSY,
  287. MXGEFW_CMD_ERROR_EMPTY,
  288. MXGEFW_CMD_ERROR_CLOSED,
  289. MXGEFW_CMD_ERROR_HASH_ERROR,
  290. MXGEFW_CMD_ERROR_BAD_PORT,
  291. MXGEFW_CMD_ERROR_RESOURCES,
  292. MXGEFW_CMD_ERROR_MULTICAST,
  293. MXGEFW_CMD_ERROR_UNALIGNED,
  294. MXGEFW_CMD_ERROR_NO_MDIO,
  295. MXGEFW_CMD_ERROR_XFP_FAILURE,
  296. MXGEFW_CMD_ERROR_XFP_ABSENT,
  297. MXGEFW_CMD_ERROR_BAD_PCIE_LINK
  298. };
  299. #define MXGEFW_OLD_IRQ_DATA_LEN 40
  300. struct mcp_irq_data {
  301. /* add new counters at the beginning */
  302. __be32 future_use[1];
  303. __be32 dropped_pause;
  304. __be32 dropped_unicast_filtered;
  305. __be32 dropped_bad_crc32;
  306. __be32 dropped_bad_phy;
  307. __be32 dropped_multicast_filtered;
  308. /* 40 Bytes */
  309. __be32 send_done_count;
  310. #define MXGEFW_LINK_DOWN 0
  311. #define MXGEFW_LINK_UP 1
  312. #define MXGEFW_LINK_MYRINET 2
  313. #define MXGEFW_LINK_UNKNOWN 3
  314. __be32 link_up;
  315. __be32 dropped_link_overflow;
  316. __be32 dropped_link_error_or_filtered;
  317. __be32 dropped_runt;
  318. __be32 dropped_overrun;
  319. __be32 dropped_no_small_buffer;
  320. __be32 dropped_no_big_buffer;
  321. __be32 rdma_tags_available;
  322. u8 tx_stopped;
  323. u8 link_down;
  324. u8 stats_updated;
  325. u8 valid;
  326. };
  327. #endif /* __MYRI10GE_MCP_H__ */