mxge_mcp.h revision 169376
1261287Sdes/*******************************************************************************
2261287Sdes
3261287SdesCopyright (c) 2006, Myricom Inc.
4261287SdesAll rights reserved.
5261287Sdes
6261287SdesRedistribution and use in source and binary forms, with or without
7261287Sdesmodification, are permitted provided that the following conditions are met:
8261287Sdes
9261287Sdes 1. Redistributions of source code must retain the above copyright notice,
10261287Sdes    this list of conditions and the following disclaimer.
11261287Sdes
12261287Sdes 2. Redistributions in binary form must reproduce the above copyright
13261287Sdes    notice, this list of conditions and the following disclaimer in the
14261287Sdes    documentation and/or other materials provided with the distribution.
15261287Sdes
16261287Sdes 3. Neither the name of the Myricom Inc, nor the names of its
17261287Sdes    contributors may be used to endorse or promote products derived from
18261287Sdes    this software without specific prior written permission.
19261287Sdes
20261287SdesTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21261287SdesAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22261287SdesIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23261287SdesARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24261287SdesLIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25261287SdesCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26261287SdesSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27261287SdesINTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28261287SdesCONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29261287SdesARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30261287SdesPOSSIBILITY OF SUCH DAMAGE.
31261287Sdes
32261287Sdes$FreeBSD: head/sys/dev/mxge/mxge_mcp.h 169376 2007-05-08 14:19:43Z gallatin $
33261287Sdes***************************************************************************/
34261287Sdes
35261287Sdes#ifndef _myri10ge_mcp_h
36261287Sdes#define _myri10ge_mcp_h
37261287Sdes
38261287Sdes#define MXGEFW_VERSION_MAJOR	1
39261287Sdes#define MXGEFW_VERSION_MINOR	4
40261287Sdes
41261287Sdes#ifdef MXGEFW
42261287Sdestypedef signed char          int8_t;
43261287Sdestypedef signed short        int16_t;
44261287Sdestypedef signed int          int32_t;
45261287Sdestypedef signed long long    int64_t;
46261287Sdestypedef unsigned char       uint8_t;
47261287Sdestypedef unsigned short     uint16_t;
48261287Sdestypedef unsigned int       uint32_t;
49261287Sdestypedef unsigned long long uint64_t;
50261287Sdes#endif
51261287Sdes
52261287Sdes/* 8 Bytes */
53261287Sdesstruct mcp_dma_addr {
54261287Sdes  uint32_t high;
55261287Sdes  uint32_t low;
56261287Sdes};
57261287Sdestypedef struct mcp_dma_addr mcp_dma_addr_t;
58261287Sdes
59261287Sdes/* 4 Bytes */
60261287Sdesstruct mcp_slot {
61261287Sdes  uint16_t checksum;
62261287Sdes  uint16_t length;
63261287Sdes};
64261287Sdestypedef struct mcp_slot mcp_slot_t;
65261287Sdes
66261287Sdes/* 64 Bytes */
67261287Sdesstruct mcp_cmd {
68261287Sdes  uint32_t cmd;
69261287Sdes  uint32_t data0;	/* will be low portion if data > 32 bits */
70261287Sdes  /* 8 */
71261287Sdes  uint32_t data1;	/* will be high portion if data > 32 bits */
72261287Sdes  uint32_t data2;	/* currently unused.. */
73261287Sdes  /* 16 */
74261287Sdes  struct mcp_dma_addr response_addr;
75261287Sdes  /* 24 */
76261287Sdes  uint8_t pad[40];
77261287Sdes};
78261287Sdestypedef struct mcp_cmd mcp_cmd_t;
79261287Sdes
80261287Sdes/* 8 Bytes */
81261287Sdesstruct mcp_cmd_response {
82261287Sdes  uint32_t data;
83261287Sdes  uint32_t result;
84261287Sdes};
85261287Sdestypedef struct mcp_cmd_response mcp_cmd_response_t;
86261287Sdes
87261287Sdes
88261287Sdes
89261287Sdes/*
90261287Sdes   flags used in mcp_kreq_ether_send_t:
91261287Sdes
92261287Sdes   The SMALL flag is only needed in the first segment. It is raised
93261287Sdes   for packets that are total less or equal 512 bytes.
94261287Sdes
95261287Sdes   The CKSUM flag must be set in all segments.
96261287Sdes
97261287Sdes   The PADDED flags is set if the packet needs to be padded, and it
98261287Sdes   must be set for all segments.
99261287Sdes
100261287Sdes   The  MXGEFW_FLAGS_ALIGN_ODD must be set if the cumulative
101261287Sdes   length of all previous segments was odd.
102261287Sdes*/
103261287Sdes
104261287Sdes
105261287Sdes#define MXGEFW_FLAGS_SMALL      0x1
106261287Sdes#define MXGEFW_FLAGS_TSO_HDR    0x1
107261287Sdes#define MXGEFW_FLAGS_FIRST      0x2
108261287Sdes#define MXGEFW_FLAGS_ALIGN_ODD  0x4
109261287Sdes#define MXGEFW_FLAGS_CKSUM      0x8
110261287Sdes#define MXGEFW_FLAGS_TSO_LAST   0x8
111261287Sdes#define MXGEFW_FLAGS_NO_TSO     0x10
112261287Sdes#define MXGEFW_FLAGS_TSO_CHOP   0x10
113261287Sdes#define MXGEFW_FLAGS_TSO_PLD    0x20
114261287Sdes
115261287Sdes#define MXGEFW_SEND_SMALL_SIZE  1520
116261287Sdes#define MXGEFW_MAX_MTU          9400
117261287Sdes
118261287Sdesunion mcp_pso_or_cumlen {
119261287Sdes  uint16_t pseudo_hdr_offset;
120261287Sdes  uint16_t cum_len;
121261287Sdes};
122261287Sdestypedef union mcp_pso_or_cumlen mcp_pso_or_cumlen_t;
123261287Sdes
124261287Sdes#define	MXGEFW_MAX_SEND_DESC 12
125261287Sdes#define MXGEFW_PAD	    2
126261287Sdes
127/* 16 Bytes */
128struct mcp_kreq_ether_send {
129  uint32_t addr_high;
130  uint32_t addr_low;
131  uint16_t pseudo_hdr_offset;
132  uint16_t length;
133  uint8_t  pad;
134  uint8_t  rdma_count;
135  uint8_t  cksum_offset; 	/* where to start computing cksum */
136  uint8_t  flags;	       	/* as defined above */
137};
138typedef struct mcp_kreq_ether_send mcp_kreq_ether_send_t;
139
140/* 8 Bytes */
141struct mcp_kreq_ether_recv {
142  uint32_t addr_high;
143  uint32_t addr_low;
144};
145typedef struct mcp_kreq_ether_recv mcp_kreq_ether_recv_t;
146
147
148/* Commands */
149
150#define	MXGEFW_BOOT_HANDOFF	0xfc0000
151#define	MXGEFW_BOOT_DUMMY_RDMA	0xfc01c0
152
153#define	MXGEFW_ETH_CMD		0xf80000
154#define	MXGEFW_ETH_SEND_4	0x200000
155#define	MXGEFW_ETH_SEND_1	0x240000
156#define	MXGEFW_ETH_SEND_2	0x280000
157#define	MXGEFW_ETH_SEND_3	0x2c0000
158#define	MXGEFW_ETH_RECV_SMALL	0x300000
159#define	MXGEFW_ETH_RECV_BIG	0x340000
160
161#define	MXGEFW_ETH_SEND(n)		(0x200000 + (((n) & 0x03) * 0x40000))
162#define	MXGEFW_ETH_SEND_OFFSET(n)	(MXGEFW_ETH_SEND(n) - MXGEFW_ETH_SEND_4)
163
164enum myri10ge_mcp_cmd_type {
165  MXGEFW_CMD_NONE = 0,
166  /* Reset the mcp, it is left in a safe state, waiting
167     for the driver to set all its parameters */
168  MXGEFW_CMD_RESET,
169
170  /* get the version number of the current firmware..
171     (may be available in the eeprom strings..? */
172  MXGEFW_GET_MCP_VERSION,
173
174
175  /* Parameters which must be set by the driver before it can
176     issue MXGEFW_CMD_ETHERNET_UP. They persist until the next
177     MXGEFW_CMD_RESET is issued */
178
179  MXGEFW_CMD_SET_INTRQ_DMA,
180  MXGEFW_CMD_SET_BIG_BUFFER_SIZE,	/* in bytes, power of 2 */
181  MXGEFW_CMD_SET_SMALL_BUFFER_SIZE,	/* in bytes */
182
183
184  /* Parameters which refer to lanai SRAM addresses where the
185     driver must issue PIO writes for various things */
186
187  MXGEFW_CMD_GET_SEND_OFFSET,
188  MXGEFW_CMD_GET_SMALL_RX_OFFSET,
189  MXGEFW_CMD_GET_BIG_RX_OFFSET,
190  MXGEFW_CMD_GET_IRQ_ACK_OFFSET,
191  MXGEFW_CMD_GET_IRQ_DEASSERT_OFFSET,
192
193  /* Parameters which refer to rings stored on the MCP,
194     and whose size is controlled by the mcp */
195
196  MXGEFW_CMD_GET_SEND_RING_SIZE,	/* in bytes */
197  MXGEFW_CMD_GET_RX_RING_SIZE,		/* in bytes */
198
199  /* Parameters which refer to rings stored in the host,
200     and whose size is controlled by the host.  Note that
201     all must be physically contiguous and must contain
202     a power of 2 number of entries.  */
203
204  MXGEFW_CMD_SET_INTRQ_SIZE, 	/* in bytes */
205
206  /* command to bring ethernet interface up.  Above parameters
207     (plus mtu & mac address) must have been exchanged prior
208     to issuing this command  */
209  MXGEFW_CMD_ETHERNET_UP,
210
211  /* command to bring ethernet interface down.  No further sends
212     or receives may be processed until an MXGEFW_CMD_ETHERNET_UP
213     is issued, and all interrupt queues must be flushed prior
214     to ack'ing this command */
215
216  MXGEFW_CMD_ETHERNET_DOWN,
217
218  /* commands the driver may issue live, without resetting
219     the nic.  Note that increasing the mtu "live" should
220     only be done if the driver has already supplied buffers
221     sufficiently large to handle the new mtu.  Decreasing
222     the mtu live is safe */
223
224  MXGEFW_CMD_SET_MTU,
225  MXGEFW_CMD_GET_INTR_COAL_DELAY_OFFSET,  /* in microseconds */
226  MXGEFW_CMD_SET_STATS_INTERVAL,   /* in microseconds */
227  MXGEFW_CMD_SET_STATS_DMA_OBSOLETE, /* replaced by SET_STATS_DMA_V2 */
228
229  MXGEFW_ENABLE_PROMISC,
230  MXGEFW_DISABLE_PROMISC,
231  MXGEFW_SET_MAC_ADDRESS,
232
233  MXGEFW_ENABLE_FLOW_CONTROL,
234  MXGEFW_DISABLE_FLOW_CONTROL,
235
236  /* do a DMA test
237     data0,data1 = DMA address
238     data2       = RDMA length (MSH), WDMA length (LSH)
239     command return data = repetitions (MSH), 0.5-ms ticks (LSH)
240  */
241  MXGEFW_DMA_TEST,
242
243  MXGEFW_ENABLE_ALLMULTI,
244  MXGEFW_DISABLE_ALLMULTI,
245
246  /* returns MXGEFW_CMD_ERROR_MULTICAST
247     if there is no room in the cache
248     data0,MSH(data1) = multicast group address */
249  MXGEFW_JOIN_MULTICAST_GROUP,
250  /* returns MXGEFW_CMD_ERROR_MULTICAST
251     if the address is not in the cache,
252     or is equal to FF-FF-FF-FF-FF-FF
253     data0,MSH(data1) = multicast group address */
254  MXGEFW_LEAVE_MULTICAST_GROUP,
255  MXGEFW_LEAVE_ALL_MULTICAST_GROUPS,
256
257  MXGEFW_CMD_SET_STATS_DMA_V2,
258  /* data0, data1 = bus addr,
259     data2 = sizeof(struct mcp_irq_data) from driver point of view, allows
260     adding new stuff to mcp_irq_data without changing the ABI */
261
262  MXGEFW_CMD_UNALIGNED_TEST,
263  /* same than DMA_TEST (same args) but abort with UNALIGNED on unaligned
264     chipset */
265
266  MXGEFW_CMD_UNALIGNED_STATUS
267  /* return data = boolean, true if the chipset is known to be unaligned */
268};
269typedef enum myri10ge_mcp_cmd_type myri10ge_mcp_cmd_type_t;
270
271
272enum myri10ge_mcp_cmd_status {
273  MXGEFW_CMD_OK = 0,
274  MXGEFW_CMD_UNKNOWN,
275  MXGEFW_CMD_ERROR_RANGE,
276  MXGEFW_CMD_ERROR_BUSY,
277  MXGEFW_CMD_ERROR_EMPTY,
278  MXGEFW_CMD_ERROR_CLOSED,
279  MXGEFW_CMD_ERROR_HASH_ERROR,
280  MXGEFW_CMD_ERROR_BAD_PORT,
281  MXGEFW_CMD_ERROR_RESOURCES,
282  MXGEFW_CMD_ERROR_MULTICAST,
283  MXGEFW_CMD_ERROR_UNALIGNED
284};
285typedef enum myri10ge_mcp_cmd_status myri10ge_mcp_cmd_status_t;
286
287
288#define MXGEFW_OLD_IRQ_DATA_LEN 40
289
290struct mcp_irq_data {
291  /* add new counters at the beginning */
292  uint32_t future_use[1];
293  uint32_t dropped_pause;
294  uint32_t dropped_unicast_filtered;
295  uint32_t dropped_bad_crc32;
296  uint32_t dropped_bad_phy;
297  uint32_t dropped_multicast_filtered;
298/* 40 Bytes */
299  uint32_t send_done_count;
300
301#define MXGEFW_LINK_DOWN 0
302#define MXGEFW_LINK_UP 1
303#define MXGEFW_LINK_MYRINET 2
304#define MXGEFW_LINK_UNKNOWN 3
305  uint32_t link_up;
306  uint32_t dropped_link_overflow;
307  uint32_t dropped_link_error_or_filtered;
308  uint32_t dropped_runt;
309  uint32_t dropped_overrun;
310  uint32_t dropped_no_small_buffer;
311  uint32_t dropped_no_big_buffer;
312  uint32_t rdma_tags_available;
313
314  uint8_t tx_stopped;
315  uint8_t link_down;
316  uint8_t stats_updated;
317  uint8_t valid;
318};
319typedef struct mcp_irq_data mcp_irq_data_t;
320
321
322#endif /* _myri10ge_mcp_h */
323