myri10ge_mcp.h 13.6 KB
Newer Older
1 2 3 4 5 6 7 8
#ifndef __MYRI10GE_MCP_H__
#define __MYRI10GE_MCP_H__

#define MXGEFW_VERSION_MAJOR	1
#define MXGEFW_VERSION_MINOR	4

/* 8 Bytes */
struct mcp_dma_addr {
A
Al Viro 已提交
9 10
	__be32 high;
	__be32 low;
11 12
};

B
Brice Goglin 已提交
13
/* 4 Bytes */
14
struct mcp_slot {
A
Al Viro 已提交
15 16
	__sum16 checksum;
	__be16 length;
17 18 19 20
};

/* 64 Bytes */
struct mcp_cmd {
A
Al Viro 已提交
21 22
	__be32 cmd;
	__be32 data0;		/* will be low portion if data > 32 bits */
23
	/* 8 */
A
Al Viro 已提交
24 25
	__be32 data1;		/* will be high portion if data > 32 bits */
	__be32 data2;		/* currently unused.. */
26 27 28 29 30 31 32 33
	/* 16 */
	struct mcp_dma_addr response_addr;
	/* 24 */
	u8 pad[40];
};

/* 8 Bytes */
struct mcp_cmd_response {
A
Al Viro 已提交
34 35
	__be32 data;
	__be32 result;
36 37
};

38
/*
39
 * flags used in mcp_kreq_ether_send_t:
40
 *
41 42
 * The SMALL flag is only needed in the first segment. It is raised
 * for packets that are total less or equal 512 bytes.
43
 *
44
 * The CKSUM flag must be set in all segments.
45
 *
46 47
 * The PADDED flags is set if the packet needs to be padded, and it
 * must be set for all segments.
48
 *
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
 * The  MXGEFW_FLAGS_ALIGN_ODD must be set if the cumulative
 * length of all previous segments was odd.
 */

#define MXGEFW_FLAGS_SMALL      0x1
#define MXGEFW_FLAGS_TSO_HDR    0x1
#define MXGEFW_FLAGS_FIRST      0x2
#define MXGEFW_FLAGS_ALIGN_ODD  0x4
#define MXGEFW_FLAGS_CKSUM      0x8
#define MXGEFW_FLAGS_TSO_LAST   0x8
#define MXGEFW_FLAGS_NO_TSO     0x10
#define MXGEFW_FLAGS_TSO_CHOP   0x10
#define MXGEFW_FLAGS_TSO_PLD    0x20

#define MXGEFW_SEND_SMALL_SIZE  1520
#define MXGEFW_MAX_MTU          9400

union mcp_pso_or_cumlen {
	u16 pseudo_hdr_offset;
	u16 cum_len;
};

#define	MXGEFW_MAX_SEND_DESC 12
#define MXGEFW_PAD	    2

/* 16 Bytes */
struct mcp_kreq_ether_send {
A
Al Viro 已提交
76 77 78 79
	__be32 addr_high;
	__be32 addr_low;
	__be16 pseudo_hdr_offset;
	__be16 length;
80 81 82 83 84 85 86 87
	u8 pad;
	u8 rdma_count;
	u8 cksum_offset;	/* where to start computing cksum */
	u8 flags;		/* as defined above */
};

/* 8 Bytes */
struct mcp_kreq_ether_recv {
A
Al Viro 已提交
88 89
	__be32 addr_high;
	__be32 addr_low;
90 91 92 93
};

/* Commands */

94 95 96 97 98 99 100 101 102 103
#define	MXGEFW_BOOT_HANDOFF	0xfc0000
#define	MXGEFW_BOOT_DUMMY_RDMA	0xfc01c0

#define	MXGEFW_ETH_CMD		0xf80000
#define	MXGEFW_ETH_SEND_4	0x200000
#define	MXGEFW_ETH_SEND_1	0x240000
#define	MXGEFW_ETH_SEND_2	0x280000
#define	MXGEFW_ETH_SEND_3	0x2c0000
#define	MXGEFW_ETH_RECV_SMALL	0x300000
#define	MXGEFW_ETH_RECV_BIG	0x340000
B
Brice Goglin 已提交
104 105
#define	MXGEFW_ETH_SEND_GO	0x380000
#define	MXGEFW_ETH_SEND_STOP	0x3C0000
106 107 108

#define	MXGEFW_ETH_SEND(n)		(0x200000 + (((n) & 0x03) * 0x40000))
#define	MXGEFW_ETH_SEND_OFFSET(n)	(MXGEFW_ETH_SEND(n) - MXGEFW_ETH_SEND_4)
109 110 111 112 113

enum myri10ge_mcp_cmd_type {
	MXGEFW_CMD_NONE = 0,
	/* Reset the mcp, it is left in a safe state, waiting
	 * for the driver to set all its parameters */
114
	MXGEFW_CMD_RESET = 1,
115 116 117

	/* get the version number of the current firmware..
	 * (may be available in the eeprom strings..? */
118
	MXGEFW_GET_MCP_VERSION = 2,
119 120 121 122 123

	/* Parameters which must be set by the driver before it can
	 * issue MXGEFW_CMD_ETHERNET_UP. They persist until the next
	 * MXGEFW_CMD_RESET is issued */

124
	MXGEFW_CMD_SET_INTRQ_DMA = 3,
B
Brice Goglin 已提交
125 126 127 128 129
	/* data0 = LSW of the host address
	 * data1 = MSW of the host address
	 * data2 = slice number if multiple slices are used
	 */

130 131
	MXGEFW_CMD_SET_BIG_BUFFER_SIZE = 4,	/* in bytes, power of 2 */
	MXGEFW_CMD_SET_SMALL_BUFFER_SIZE = 5,	/* in bytes */
132

133
	/* Parameters which refer to lanai SRAM addresses where the
134 135
	 * driver must issue PIO writes for various things */

136 137 138
	MXGEFW_CMD_GET_SEND_OFFSET = 6,
	MXGEFW_CMD_GET_SMALL_RX_OFFSET = 7,
	MXGEFW_CMD_GET_BIG_RX_OFFSET = 8,
B
Brice Goglin 已提交
139 140
	/* data0 = slice number if multiple slices are used */

141 142
	MXGEFW_CMD_GET_IRQ_ACK_OFFSET = 9,
	MXGEFW_CMD_GET_IRQ_DEASSERT_OFFSET = 10,
143 144 145 146

	/* Parameters which refer to rings stored on the MCP,
	 * and whose size is controlled by the mcp */

147 148
	MXGEFW_CMD_GET_SEND_RING_SIZE = 11,	/* in bytes */
	MXGEFW_CMD_GET_RX_RING_SIZE = 12,	/* in bytes */
149 150 151

	/* Parameters which refer to rings stored in the host,
	 * and whose size is controlled by the host.  Note that
152
	 * all must be physically contiguous and must contain
153 154
	 * a power of 2 number of entries.  */

155
	MXGEFW_CMD_SET_INTRQ_SIZE = 13,	/* in bytes */
B
Brice Goglin 已提交
156
#define MXGEFW_CMD_SET_INTRQ_SIZE_FLAG_NO_STRICT_SIZE_CHECK  (1 << 31)
157 158 159 160

	/* command to bring ethernet interface up.  Above parameters
	 * (plus mtu & mac address) must have been exchanged prior
	 * to issuing this command  */
161
	MXGEFW_CMD_ETHERNET_UP = 14,
162 163 164 165 166 167

	/* command to bring ethernet interface down.  No further sends
	 * or receives may be processed until an MXGEFW_CMD_ETHERNET_UP
	 * is issued, and all interrupt queues must be flushed prior
	 * to ack'ing this command */

168
	MXGEFW_CMD_ETHERNET_DOWN = 15,
169 170 171 172 173 174 175

	/* commands the driver may issue live, without resetting
	 * the nic.  Note that increasing the mtu "live" should
	 * only be done if the driver has already supplied buffers
	 * sufficiently large to handle the new mtu.  Decreasing
	 * the mtu live is safe */

176 177 178 179
	MXGEFW_CMD_SET_MTU = 16,
	MXGEFW_CMD_GET_INTR_COAL_DELAY_OFFSET = 17,	/* in microseconds */
	MXGEFW_CMD_SET_STATS_INTERVAL = 18,	/* in microseconds */
	MXGEFW_CMD_SET_STATS_DMA_OBSOLETE = 19,	/* replaced by SET_STATS_DMA_V2 */
180

181 182 183
	MXGEFW_ENABLE_PROMISC = 20,
	MXGEFW_DISABLE_PROMISC = 21,
	MXGEFW_SET_MAC_ADDRESS = 22,
184

185 186
	MXGEFW_ENABLE_FLOW_CONTROL = 23,
	MXGEFW_DISABLE_FLOW_CONTROL = 24,
187 188 189 190 191 192

	/* do a DMA test
	 * data0,data1 = DMA address
	 * data2       = RDMA length (MSH), WDMA length (LSH)
	 * command return data = repetitions (MSH), 0.5-ms ticks (LSH)
	 */
193
	MXGEFW_DMA_TEST = 25,
194

195 196
	MXGEFW_ENABLE_ALLMULTI = 26,
	MXGEFW_DISABLE_ALLMULTI = 27,
197 198 199 200

	/* returns MXGEFW_CMD_ERROR_MULTICAST
	 * if there is no room in the cache
	 * data0,MSH(data1) = multicast group address */
201
	MXGEFW_JOIN_MULTICAST_GROUP = 28,
202 203 204 205
	/* returns MXGEFW_CMD_ERROR_MULTICAST
	 * if the address is not in the cache,
	 * or is equal to FF-FF-FF-FF-FF-FF
	 * data0,MSH(data1) = multicast group address */
206 207
	MXGEFW_LEAVE_MULTICAST_GROUP = 29,
	MXGEFW_LEAVE_ALL_MULTICAST_GROUPS = 30,
208

209
	MXGEFW_CMD_SET_STATS_DMA_V2 = 31,
210 211
	/* data0, data1 = bus addr,
	 * data2 = sizeof(struct mcp_irq_data) from driver point of view, allows
B
Brice Goglin 已提交
212 213 214 215 216 217
	 * adding new stuff to mcp_irq_data without changing the ABI
	 *
	 * If multiple slices are used, data2 contains both the size of the
	 * structure (in the lower 16 bits) and the slice number
	 * (in the upper 16 bits).
	 */
B
Brice Goglin 已提交
218

219
	MXGEFW_CMD_UNALIGNED_TEST = 32,
B
Brice Goglin 已提交
220 221 222
	/* same than DMA_TEST (same args) but abort with UNALIGNED on unaligned
	 * chipset */

223
	MXGEFW_CMD_UNALIGNED_STATUS = 33,
B
Brice Goglin 已提交
224 225
	/* return data = boolean, true if the chipset is known to be unaligned */

226
	MXGEFW_CMD_ALWAYS_USE_N_BIG_BUFFERS = 34,
B
Brice Goglin 已提交
227 228 229 230 231 232 233 234 235
	/* data0 = number of big buffers to use.  It must be 0 or a power of 2.
	 * 0 indicates that the NIC consumes as many buffers as they are required
	 * for packet. This is the default behavior.
	 * A power of 2 number indicates that the NIC always uses the specified
	 * number of buffers for each big receive packet.
	 * It is up to the driver to ensure that this value is big enough for
	 * the NIC to be able to receive maximum-sized packets.
	 */

236 237
	MXGEFW_CMD_GET_MAX_RSS_QUEUES = 35,
	MXGEFW_CMD_ENABLE_RSS_QUEUES = 36,
B
Brice Goglin 已提交
238
	/* data0 = number of slices n (0, 1, ..., n-1) to enable
B
Brice Goglin 已提交
239 240 241
	 * data1 = interrupt mode | use of multiple transmit queues.
	 * 0=share one INTx/MSI.
	 * 1=use one MSI-X per queue.
B
Brice Goglin 已提交
242 243
	 * If all queues share one interrupt, the driver must have set
	 * RSS_SHARED_INTERRUPT_DMA before enabling queues.
B
Brice Goglin 已提交
244 245 246
	 * 2=enable both receive and send queues.
	 * Without this bit set, only one send queue (slice 0's send queue)
	 * is enabled.  The receive queues are always enabled.
B
Brice Goglin 已提交
247
	 */
B
Brice Goglin 已提交
248 249 250
#define MXGEFW_SLICE_INTR_MODE_SHARED          0x0
#define MXGEFW_SLICE_INTR_MODE_ONE_PER_SLICE   0x1
#define MXGEFW_SLICE_ENABLE_MULTIPLE_TX_QUEUES 0x2
B
Brice Goglin 已提交
251

252 253
	MXGEFW_CMD_GET_RSS_SHARED_INTERRUPT_MASK_OFFSET = 37,
	MXGEFW_CMD_SET_RSS_SHARED_INTERRUPT_DMA = 38,
B
Brice Goglin 已提交
254
	/* data0, data1 = bus address lsw, msw */
255
	MXGEFW_CMD_GET_RSS_TABLE_OFFSET = 39,
B
Brice Goglin 已提交
256
	/* get the offset of the indirection table */
257
	MXGEFW_CMD_SET_RSS_TABLE_SIZE = 40,
B
Brice Goglin 已提交
258
	/* set the size of the indirection table */
259
	MXGEFW_CMD_GET_RSS_KEY_OFFSET = 41,
B
Brice Goglin 已提交
260
	/* get the offset of the secret key */
261
	MXGEFW_CMD_RSS_KEY_UPDATED = 42,
B
Brice Goglin 已提交
262
	/* tell nic that the secret key's been updated */
263
	MXGEFW_CMD_SET_RSS_ENABLE = 43,
B
Brice Goglin 已提交
264 265 266 267
	/* data0 = enable/disable rss
	 * 0: disable rss.  nic does not distribute receive packets.
	 * 1: enable rss.  nic distributes receive packets among queues.
	 * data1 = hash type
B
Brice Goglin 已提交
268 269 270 271
	 * 1: IPV4            (required by RSS)
	 * 2: TCP_IPV4        (required by RSS)
	 * 3: IPV4 | TCP_IPV4 (required by RSS)
	 * 4: source port
B
Brice Goglin 已提交
272
	 * 5: source port + destination port
B
Brice Goglin 已提交
273
	 */
B
Brice Goglin 已提交
274 275 276
#define MXGEFW_RSS_HASH_TYPE_IPV4      0x1
#define MXGEFW_RSS_HASH_TYPE_TCP_IPV4  0x2
#define MXGEFW_RSS_HASH_TYPE_SRC_PORT  0x4
B
Brice Goglin 已提交
277 278
#define MXGEFW_RSS_HASH_TYPE_SRC_DST_PORT 0x5
#define MXGEFW_RSS_HASH_TYPE_MAX 0x5
B
Brice Goglin 已提交
279

280
	MXGEFW_CMD_GET_MAX_TSO6_HDR_SIZE = 44,
B
Brice Goglin 已提交
281 282 283 284 285 286 287 288
	/* Return data = the max. size of the entire headers of a IPv6 TSO packet.
	 * If the header size of a IPv6 TSO packet is larger than the specified
	 * value, then the driver must not use TSO.
	 * This size restriction only applies to IPv6 TSO.
	 * For IPv4 TSO, the maximum size of the headers is fixed, and the NIC
	 * always has enough header buffer to store maximum-sized headers.
	 */

289
	MXGEFW_CMD_SET_TSO_MODE = 45,
B
Brice Goglin 已提交
290 291 292 293
	/* data0 = TSO mode.
	 * 0: Linux/FreeBSD style (NIC default)
	 * 1: NDIS/NetBSD style
	 */
B
Brice Goglin 已提交
294 295
#define MXGEFW_TSO_MODE_LINUX  0
#define MXGEFW_TSO_MODE_NDIS   1
B
Brice Goglin 已提交
296

297
	MXGEFW_CMD_MDIO_READ = 46,
B
Brice Goglin 已提交
298
	/* data0 = dev_addr (PMA/PMD or PCS ...), data1 = register/addr */
299
	MXGEFW_CMD_MDIO_WRITE = 47,
B
Brice Goglin 已提交
300 301
	/* data0 = dev_addr,  data1 = register/addr, data2 = value  */

302 303
	MXGEFW_CMD_I2C_READ = 48,
	/* Starts to get a fresh copy of one byte or of the module i2c table, the
B
Brice Goglin 已提交
304
	 * obtained data is cached inside the xaui-xfi chip :
305 306 307 308 309 310
	 *   data0 :  0 => get one byte, 1=> get 256 bytes
	 *   data1 :  If data0 == 0: location to refresh
	 *               bit 7:0  register location
	 *               bit 8:15 is the i2c slave addr (0 is interpreted as 0xA1)
	 *               bit 23:16 is the i2c bus number (for multi-port NICs)
	 *            If data0 == 1: unused
B
Brice Goglin 已提交
311
	 * The operation might take ~1ms for a single byte or ~65ms when refreshing all 256 bytes
312
	 * During the i2c operation,  MXGEFW_CMD_I2C_READ or MXGEFW_CMD_I2C_BYTE attempts
B
Brice Goglin 已提交
313 314
	 *  will return MXGEFW_CMD_ERROR_BUSY
	 */
315
	MXGEFW_CMD_I2C_BYTE = 49,
B
Brice Goglin 已提交
316
	/* Return the last obtained copy of a given byte in the xfp i2c table
317
	 * (copy cached during the last relevant MXGEFW_CMD_I2C_READ)
B
Brice Goglin 已提交
318 319 320 321
	 *   data0 : index of the desired table entry
	 *  Return data = the byte stored at the requested index in the table
	 */

322
	MXGEFW_CMD_GET_VPUMP_OFFSET = 50,
B
Brice Goglin 已提交
323
	/* Return data = NIC memory offset of mcp_vpump_public_global */
324
	MXGEFW_CMD_RESET_VPUMP = 51,
B
Brice Goglin 已提交
325
	/* Resets the VPUMP state */
B
Brice Goglin 已提交
326

327
	MXGEFW_CMD_SET_RSS_MCP_SLOT_TYPE = 52,
B
Brice Goglin 已提交
328 329 330 331 332 333 334
	/* data0 = mcp_slot type to use.
	 * 0 = the default 4B mcp_slot
	 * 1 = 8B mcp_slot_8
	 */
#define MXGEFW_RSS_MCP_SLOT_TYPE_MIN        0
#define MXGEFW_RSS_MCP_SLOT_TYPE_WITH_HASH  1

335
	MXGEFW_CMD_SET_THROTTLE_FACTOR = 53,
B
Brice Goglin 已提交
336 337 338 339 340 341 342 343 344 345 346 347 348 349 350
	/* set the throttle factor for ethp_z8e
	 * data0 = throttle_factor
	 * throttle_factor = 256 * pcie-raw-speed / tx_speed
	 * tx_speed = 256 * pcie-raw-speed / throttle_factor
	 *
	 * For PCI-E x8: pcie-raw-speed == 16Gb/s
	 * For PCI-E x4: pcie-raw-speed == 8Gb/s
	 *
	 * ex1: throttle_factor == 0x1a0 (416), tx_speed == 1.23GB/s == 9.846 Gb/s
	 * ex2: throttle_factor == 0x200 (512), tx_speed == 1.0GB/s == 8 Gb/s
	 *
	 * with tx_boundary == 2048, max-throttle-factor == 8191 => min-speed == 500Mb/s
	 * with tx_boundary == 4096, max-throttle-factor == 4095 => min-speed == 1Gb/s
	 */

351
	MXGEFW_CMD_VPUMP_UP = 54,
B
Brice Goglin 已提交
352
	/* Allocates VPump Connection, Send Request and Zero copy buffer address tables */
353
	MXGEFW_CMD_GET_VPUMP_CLK = 55,
B
Brice Goglin 已提交
354 355
	/* Get the lanai clock */

356
	MXGEFW_CMD_GET_DCA_OFFSET = 56,
B
Brice Goglin 已提交
357
	/* offset of dca control for WDMAs */
B
Brice Goglin 已提交
358 359

	/* VMWare NetQueue commands */
360 361
	MXGEFW_CMD_NETQ_GET_FILTERS_PER_QUEUE = 57,
	MXGEFW_CMD_NETQ_ADD_FILTER = 58,
B
Brice Goglin 已提交
362 363 364
	/* data0 = filter_id << 16 | queue << 8 | type */
	/* data1 = MS4 of MAC Addr */
	/* data2 = LS2_MAC << 16 | VLAN_tag */
365
	MXGEFW_CMD_NETQ_DEL_FILTER = 59,
B
Brice Goglin 已提交
366
	/* data0 = filter_id */
367 368 369 370 371 372 373 374 375 376
	MXGEFW_CMD_NETQ_QUERY1 = 60,
	MXGEFW_CMD_NETQ_QUERY2 = 61,
	MXGEFW_CMD_NETQ_QUERY3 = 62,
	MXGEFW_CMD_NETQ_QUERY4 = 63,

	MXGEFW_CMD_RELAX_RXBUFFER_ALIGNMENT = 64,
	/* When set, small receive buffers can cross page boundaries.
	 * Both small and big receive buffers may start at any address.
	 * This option has performance implications, so use with caution.
	 */
377 378 379 380
};

enum myri10ge_mcp_cmd_status {
	MXGEFW_CMD_OK = 0,
381 382 383 384 385 386 387 388 389 390 391 392 393 394
	MXGEFW_CMD_UNKNOWN = 1,
	MXGEFW_CMD_ERROR_RANGE = 2,
	MXGEFW_CMD_ERROR_BUSY = 3,
	MXGEFW_CMD_ERROR_EMPTY = 4,
	MXGEFW_CMD_ERROR_CLOSED = 5,
	MXGEFW_CMD_ERROR_HASH_ERROR = 6,
	MXGEFW_CMD_ERROR_BAD_PORT = 7,
	MXGEFW_CMD_ERROR_RESOURCES = 8,
	MXGEFW_CMD_ERROR_MULTICAST = 9,
	MXGEFW_CMD_ERROR_UNALIGNED = 10,
	MXGEFW_CMD_ERROR_NO_MDIO = 11,
	MXGEFW_CMD_ERROR_I2C_FAILURE = 12,
	MXGEFW_CMD_ERROR_I2C_ABSENT = 13,
	MXGEFW_CMD_ERROR_BAD_PCIE_LINK = 14
395 396
};

397 398
#define MXGEFW_OLD_IRQ_DATA_LEN 40

399
struct mcp_irq_data {
400
	/* add new counters at the beginning */
401 402 403 404 405
	__be32 future_use[1];
	__be32 dropped_pause;
	__be32 dropped_unicast_filtered;
	__be32 dropped_bad_crc32;
	__be32 dropped_bad_phy;
A
Al Viro 已提交
406
	__be32 dropped_multicast_filtered;
407
	/* 40 Bytes */
A
Al Viro 已提交
408 409
	__be32 send_done_count;

B
Brice Goglin 已提交
410 411 412 413
#define MXGEFW_LINK_DOWN 0
#define MXGEFW_LINK_UP 1
#define MXGEFW_LINK_MYRINET 2
#define MXGEFW_LINK_UNKNOWN 3
A
Al Viro 已提交
414 415 416 417 418 419 420 421
	__be32 link_up;
	__be32 dropped_link_overflow;
	__be32 dropped_link_error_or_filtered;
	__be32 dropped_runt;
	__be32 dropped_overrun;
	__be32 dropped_no_small_buffer;
	__be32 dropped_no_big_buffer;
	__be32 rdma_tags_available;
422 423 424 425 426 427 428

	u8 tx_stopped;
	u8 link_down;
	u8 stats_updated;
	u8 valid;
};

B
Brice Goglin 已提交
429 430 431 432 433 434
/* definitions for NETQ filter type */
#define MXGEFW_NETQ_FILTERTYPE_NONE 0
#define MXGEFW_NETQ_FILTERTYPE_MACADDR 1
#define MXGEFW_NETQ_FILTERTYPE_VLAN 2
#define MXGEFW_NETQ_FILTERTYPE_VLANMACADDR 3

435
#endif				/* __MYRI10GE_MCP_H__ */