myri10ge_mcp.h 14 KB

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