1 /******************************************************************************* 2 3 Copyright (c) 2006, Myricom Inc. 4 All rights reserved. 5 6 Redistribution and use in source and binary forms, with or without 7 modification, are permitted provided that the following conditions are met: 8 9 1. Redistributions of source code must retain the above copyright notice, 10 this list of conditions and the following disclaimer. 11 12 2. Redistributions in binary form must reproduce the above copyright 13 notice, this list of conditions and the following disclaimer in the 14 documentation and/or other materials provided with the distribution. 15 16 3. Neither the name of the Myricom Inc, nor the names of its 17 contributors may be used to endorse or promote products derived from 18 this software without specific prior written permission. 19 20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 24 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 POSSIBILITY OF SUCH DAMAGE. 31 32 $FreeBSD$ 33 ***************************************************************************/ 34 35 #ifndef _myri10ge_mcp_h 36 #define _myri10ge_mcp_h 37 38 #define MXGEFW_VERSION_MAJOR 1 39 #define MXGEFW_VERSION_MINOR 4 40 41 #ifdef MXGEFW 42 typedef signed char int8_t; 43 typedef signed short int16_t; 44 typedef signed int int32_t; 45 typedef signed long long int64_t; 46 typedef unsigned char uint8_t; 47 typedef unsigned short uint16_t; 48 typedef unsigned int uint32_t; 49 typedef unsigned long long uint64_t; 50 #endif 51 52 /* 8 Bytes */ 53 struct mcp_dma_addr { 54 uint32_t high; 55 uint32_t low; 56 }; 57 typedef struct mcp_dma_addr mcp_dma_addr_t; 58 59 /* 4 Bytes */ 60 struct mcp_slot { 61 uint16_t checksum; 62 uint16_t length; 63 }; 64 typedef struct mcp_slot mcp_slot_t; 65 66 /* 64 Bytes */ 67 struct mcp_cmd { 68 uint32_t cmd; 69 uint32_t data0; /* will be low portion if data > 32 bits */ 70 /* 8 */ 71 uint32_t data1; /* will be high portion if data > 32 bits */ 72 uint32_t data2; /* currently unused.. */ 73 /* 16 */ 74 struct mcp_dma_addr response_addr; 75 /* 24 */ 76 uint8_t pad[40]; 77 }; 78 typedef struct mcp_cmd mcp_cmd_t; 79 80 /* 8 Bytes */ 81 struct mcp_cmd_response { 82 uint32_t data; 83 uint32_t result; 84 }; 85 typedef struct mcp_cmd_response mcp_cmd_response_t; 86 87 88 89 /* 90 flags used in mcp_kreq_ether_send_t: 91 92 The SMALL flag is only needed in the first segment. It is raised 93 for packets that are total less or equal 512 bytes. 94 95 The CKSUM flag must be set in all segments. 96 97 The PADDED flags is set if the packet needs to be padded, and it 98 must be set for all segments. 99 100 The MXGEFW_FLAGS_ALIGN_ODD must be set if the cumulative 101 length of all previous segments was odd. 102 */ 103 104 105 #define MXGEFW_FLAGS_SMALL 0x1 106 #define MXGEFW_FLAGS_TSO_HDR 0x1 107 #define MXGEFW_FLAGS_FIRST 0x2 108 #define MXGEFW_FLAGS_ALIGN_ODD 0x4 109 #define MXGEFW_FLAGS_CKSUM 0x8 110 #define MXGEFW_FLAGS_TSO_LAST 0x8 111 #define MXGEFW_FLAGS_NO_TSO 0x10 112 #define MXGEFW_FLAGS_TSO_CHOP 0x10 113 #define MXGEFW_FLAGS_TSO_PLD 0x20 114 115 #define MXGEFW_SEND_SMALL_SIZE 1520 116 #define MXGEFW_MAX_MTU 9400 117 118 union mcp_pso_or_cumlen { 119 uint16_t pseudo_hdr_offset; 120 uint16_t cum_len; 121 }; 122 typedef union mcp_pso_or_cumlen mcp_pso_or_cumlen_t; 123 124 #define MXGEFW_MAX_SEND_DESC 12 125 #define MXGEFW_PAD 2 126 127 /* 16 Bytes */ 128 struct 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 }; 138 typedef struct mcp_kreq_ether_send mcp_kreq_ether_send_t; 139 140 /* 8 Bytes */ 141 struct mcp_kreq_ether_recv { 142 uint32_t addr_high; 143 uint32_t addr_low; 144 }; 145 typedef struct mcp_kreq_ether_recv mcp_kreq_ether_recv_t; 146 147 148 /* Commands */ 149 150 #define MXGEFW_CMD_OFFSET 0xf80000 151 152 enum myri10ge_mcp_cmd_type { 153 MXGEFW_CMD_NONE = 0, 154 /* Reset the mcp, it is left in a safe state, waiting 155 for the driver to set all its parameters */ 156 MXGEFW_CMD_RESET, 157 158 /* get the version number of the current firmware.. 159 (may be available in the eeprom strings..? */ 160 MXGEFW_GET_MCP_VERSION, 161 162 163 /* Parameters which must be set by the driver before it can 164 issue MXGEFW_CMD_ETHERNET_UP. They persist until the next 165 MXGEFW_CMD_RESET is issued */ 166 167 MXGEFW_CMD_SET_INTRQ_DMA, 168 MXGEFW_CMD_SET_BIG_BUFFER_SIZE, /* in bytes, power of 2 */ 169 MXGEFW_CMD_SET_SMALL_BUFFER_SIZE, /* in bytes */ 170 171 172 /* Parameters which refer to lanai SRAM addresses where the 173 driver must issue PIO writes for various things */ 174 175 MXGEFW_CMD_GET_SEND_OFFSET, 176 MXGEFW_CMD_GET_SMALL_RX_OFFSET, 177 MXGEFW_CMD_GET_BIG_RX_OFFSET, 178 MXGEFW_CMD_GET_IRQ_ACK_OFFSET, 179 MXGEFW_CMD_GET_IRQ_DEASSERT_OFFSET, 180 181 /* Parameters which refer to rings stored on the MCP, 182 and whose size is controlled by the mcp */ 183 184 MXGEFW_CMD_GET_SEND_RING_SIZE, /* in bytes */ 185 MXGEFW_CMD_GET_RX_RING_SIZE, /* in bytes */ 186 187 /* Parameters which refer to rings stored in the host, 188 and whose size is controlled by the host. Note that 189 all must be physically contiguous and must contain 190 a power of 2 number of entries. */ 191 192 MXGEFW_CMD_SET_INTRQ_SIZE, /* in bytes */ 193 194 /* command to bring ethernet interface up. Above parameters 195 (plus mtu & mac address) must have been exchanged prior 196 to issuing this command */ 197 MXGEFW_CMD_ETHERNET_UP, 198 199 /* command to bring ethernet interface down. No further sends 200 or receives may be processed until an MXGEFW_CMD_ETHERNET_UP 201 is issued, and all interrupt queues must be flushed prior 202 to ack'ing this command */ 203 204 MXGEFW_CMD_ETHERNET_DOWN, 205 206 /* commands the driver may issue live, without resetting 207 the nic. Note that increasing the mtu "live" should 208 only be done if the driver has already supplied buffers 209 sufficiently large to handle the new mtu. Decreasing 210 the mtu live is safe */ 211 212 MXGEFW_CMD_SET_MTU, 213 MXGEFW_CMD_GET_INTR_COAL_DELAY_OFFSET, /* in microseconds */ 214 MXGEFW_CMD_SET_STATS_INTERVAL, /* in microseconds */ 215 MXGEFW_CMD_SET_STATS_DMA, 216 217 MXGEFW_ENABLE_PROMISC, 218 MXGEFW_DISABLE_PROMISC, 219 MXGEFW_SET_MAC_ADDRESS, 220 221 MXGEFW_ENABLE_FLOW_CONTROL, 222 MXGEFW_DISABLE_FLOW_CONTROL, 223 224 /* do a DMA test 225 data0,data1 = DMA address 226 data2 = RDMA length (MSH), WDMA length (LSH) 227 command return data = repetitions (MSH), 0.5-ms ticks (LSH) 228 */ 229 MXGEFW_DMA_TEST 230 }; 231 typedef enum myri10ge_mcp_cmd_type myri10ge_mcp_cmd_type_t; 232 233 234 enum myri10ge_mcp_cmd_status { 235 MXGEFW_CMD_OK = 0, 236 MXGEFW_CMD_UNKNOWN, 237 MXGEFW_CMD_ERROR_RANGE, 238 MXGEFW_CMD_ERROR_BUSY, 239 MXGEFW_CMD_ERROR_EMPTY, 240 MXGEFW_CMD_ERROR_CLOSED, 241 MXGEFW_CMD_ERROR_HASH_ERROR, 242 MXGEFW_CMD_ERROR_BAD_PORT, 243 MXGEFW_CMD_ERROR_RESOURCES 244 }; 245 typedef enum myri10ge_mcp_cmd_status myri10ge_mcp_cmd_status_t; 246 247 248 /* 40 Bytes */ 249 struct mcp_irq_data { 250 uint32_t send_done_count; 251 252 uint32_t link_up; 253 uint32_t dropped_link_overflow; 254 uint32_t dropped_link_error_or_filtered; 255 uint32_t dropped_runt; 256 uint32_t dropped_overrun; 257 uint32_t dropped_no_small_buffer; 258 uint32_t dropped_no_big_buffer; 259 uint32_t rdma_tags_available; 260 261 uint8_t tx_stopped; 262 uint8_t link_down; 263 uint8_t stats_updated; 264 uint8_t valid; 265 }; 266 typedef struct mcp_irq_data mcp_irq_data_t; 267 268 269 #endif /* _myri10ge_mcp_h */ 270