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 #ifdef MYRI10GE_MCP 39 typedef signed char int8_t; 40 typedef signed short int16_t; 41 typedef signed int int32_t; 42 typedef signed long long int64_t; 43 typedef unsigned char uint8_t; 44 typedef unsigned short uint16_t; 45 typedef unsigned int uint32_t; 46 typedef unsigned long long uint64_t; 47 #endif 48 49 /* 8 Bytes */ 50 typedef struct 51 { 52 uint32_t high; 53 uint32_t low; 54 } mcp_dma_addr_t; 55 56 /* 16 Bytes */ 57 typedef struct 58 { 59 uint32_t data0; 60 uint32_t data1; 61 uint32_t seqnum; 62 uint16_t index; 63 uint8_t flag; 64 uint8_t type; 65 } mcp_slot_t; 66 67 /* 64 Bytes */ 68 typedef struct 69 { 70 uint32_t cmd; 71 uint32_t data0; /* will be low portion if data > 32 bits */ 72 /* 8 */ 73 uint32_t data1; /* will be high portion if data > 32 bits */ 74 uint32_t data2; /* currently unused.. */ 75 /* 16 */ 76 mcp_dma_addr_t response_addr; 77 /* 24 */ 78 uint8_t pad[40]; 79 } mcp_cmd_t; 80 81 /* 8 Bytes */ 82 typedef struct 83 { 84 uint32_t data; 85 uint32_t result; 86 } mcp_cmd_response_t; 87 88 89 90 /* 91 flags used in mcp_kreq_ether_send_t: 92 93 The SMALL flag is only needed in the first segment. It is raised 94 for packets that are total less or equal 512 bytes. 95 96 The CKSUM flag must be set in all segments. 97 98 The PADDED flags is set if the packet needs to be padded, and it 99 must be set for all segments. 100 101 The MYRI10GE_MCP_ETHER_FLAGS_ALIGN_ODD must be set if the cumulative 102 length of all previous segments was odd. 103 */ 104 105 106 #define MYRI10GE_MCP_ETHER_FLAGS_VALID 0x1 107 #define MYRI10GE_MCP_ETHER_FLAGS_FIRST 0x2 108 #define MYRI10GE_MCP_ETHER_FLAGS_ALIGN_ODD 0x4 109 #define MYRI10GE_MCP_ETHER_FLAGS_CKSUM 0x8 110 #define MYRI10GE_MCP_ETHER_FLAGS_SMALL 0x10 111 #define MYRI10GE_MCP_ETHER_FLAGS_NOT_LAST 0x100 112 #define MYRI10GE_MCP_ETHER_FLAGS_TSO_HDR 0x200 113 #define MYRI10GE_MCP_ETHER_FLAGS_TSO 0x400 114 115 #define MYRI10GE_MCP_ETHER_SEND_SMALL_SIZE 1520 116 #define MYRI10GE_MCP_ETHER_MAX_MTU 9400 117 118 typedef union mcp_pso_or_cumlen 119 { 120 uint16_t pseudo_hdr_offset; 121 uint16_t cum_len; 122 } mcp_pso_or_cumlen_t; 123 124 #define MYRI10GE_MCP_ETHER_MAX_SEND_DESC 12 125 #define MYRI10GE_MCP_ETHER_PAD 2 126 127 /* 16 Bytes */ 128 typedef struct 129 { 130 uint32_t addr_high; 131 uint32_t addr_low; 132 uint16_t length; 133 uint8_t pad; 134 uint8_t cksum_offset; /* where to start computing cksum */ 135 uint16_t pseudo_hdr_offset; 136 uint16_t flags; /* as defined above */ 137 } mcp_kreq_ether_send_t; 138 139 /* 8 Bytes */ 140 typedef struct 141 { 142 uint32_t addr_high; 143 uint32_t addr_low; 144 } mcp_kreq_ether_recv_t; 145 146 147 /* Commands */ 148 149 #define MYRI10GE_MCP_CMD_OFFSET 0xf80000 150 151 typedef enum { 152 MYRI10GE_MCP_CMD_NONE = 0, 153 /* Reset the mcp, it is left in a safe state, waiting 154 for the driver to set all its parameters */ 155 MYRI10GE_MCP_CMD_RESET, 156 157 /* get the version number of the current firmware.. 158 (may be available in the eeprom strings..? */ 159 MYRI10GE_MCP_GET_MCP_VERSION, 160 161 162 /* Parameters which must be set by the driver before it can 163 issue MYRI10GE_MCP_CMD_ETHERNET_UP. They persist until the next 164 MYRI10GE_MCP_CMD_RESET is issued */ 165 166 MYRI10GE_MCP_CMD_SET_INTRQ0_DMA, 167 MYRI10GE_MCP_CMD_SET_INTRQ1_DMA, 168 MYRI10GE_MCP_CMD_SET_BIG_BUFFER_SIZE, /* in bytes, power of 2 */ 169 MYRI10GE_MCP_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 MYRI10GE_MCP_CMD_GET_SEND_OFFSET, 176 MYRI10GE_MCP_CMD_GET_SMALL_RX_OFFSET, 177 MYRI10GE_MCP_CMD_GET_BIG_RX_OFFSET, 178 MYRI10GE_MCP_CMD_GET_IRQ_ACK_OFFSET, 179 MYRI10GE_MCP_CMD_GET_IRQ_DEASSERT_OFFSET, 180 MYRI10GE_MCP_CMD_GET_IRQ_ACK_DEASSERT_OFFSET, 181 182 /* Parameters which refer to rings stored on the MCP, 183 and whose size is controlled by the mcp */ 184 185 MYRI10GE_MCP_CMD_GET_SEND_RING_SIZE, /* in bytes */ 186 MYRI10GE_MCP_CMD_GET_RX_RING_SIZE, /* in bytes */ 187 188 /* Parameters which refer to rings stored in the host, 189 and whose size is controlled by the host. Note that 190 all must be physically contiguous and must contain 191 a power of 2 number of entries. */ 192 193 MYRI10GE_MCP_CMD_SET_INTRQ_SIZE, /* in bytes */ 194 195 /* command to bring ethernet interface up. Above parameters 196 (plus mtu & mac address) must have been exchanged prior 197 to issuing this command */ 198 MYRI10GE_MCP_CMD_ETHERNET_UP, 199 200 /* command to bring ethernet interface down. No further sends 201 or receives may be processed until an MYRI10GE_MCP_CMD_ETHERNET_UP 202 is issued, and all interrupt queues must be flushed prior 203 to ack'ing this command */ 204 205 MYRI10GE_MCP_CMD_ETHERNET_DOWN, 206 207 /* commands the driver may issue live, without resetting 208 the nic. Note that increasing the mtu "live" should 209 only be done if the driver has already supplied buffers 210 sufficiently large to handle the new mtu. Decreasing 211 the mtu live is safe */ 212 213 MYRI10GE_MCP_CMD_SET_MTU, 214 MYRI10GE_MCP_CMD_SET_INTR_COAL_DELAY, /* in microseconds */ 215 MYRI10GE_MCP_CMD_SET_STATS_INTERVAL, /* in microseconds */ 216 MYRI10GE_MCP_CMD_SET_STATS_DMA, 217 218 MYRI10GE_MCP_ENABLE_PROMISC, 219 MYRI10GE_MCP_DISABLE_PROMISC, 220 MYRI10GE_MCP_SET_MAC_ADDRESS, 221 222 MYRI10GE_MCP_ENABLE_FLOW_CONTROL, 223 MYRI10GE_MCP_DISABLE_FLOW_CONTROL 224 } myri10ge_mcp_cmd_type_t; 225 226 227 typedef enum { 228 MYRI10GE_MCP_CMD_OK = 0, 229 MYRI10GE_MCP_CMD_UNKNOWN, 230 MYRI10GE_MCP_CMD_ERROR_RANGE, 231 MYRI10GE_MCP_CMD_ERROR_BUSY, 232 MYRI10GE_MCP_CMD_ERROR_EMPTY, 233 MYRI10GE_MCP_CMD_ERROR_CLOSED, 234 MYRI10GE_MCP_CMD_ERROR_HASH_ERROR, 235 MYRI10GE_MCP_CMD_ERROR_BAD_PORT, 236 MYRI10GE_MCP_CMD_ERROR_RESOURCES 237 } myri10ge_mcp_cmd_status_t; 238 239 typedef enum { 240 MYRI10GE_MCP_INTR_NONE = 0, 241 MYRI10GE_MCP_INTR_ETHER_SEND_DONE, 242 MYRI10GE_MCP_INTR_ETHER_RECV_SMALL, 243 MYRI10GE_MCP_INTR_ETHER_RECV_BIG, 244 MYRI10GE_MCP_INTR_LINK_CHANGE, 245 MYRI10GE_MCP_INTR_STATS_UPDATE, 246 MYRI10GE_MCP_INTR_ETHER_DOWN 247 } myri10ge_mcp_intr_type_t; 248 249 250 /* 32 Bytes */ 251 typedef struct 252 { 253 uint32_t link_up; 254 uint32_t dropped_link_overflow; 255 uint32_t dropped_link_error_or_filtered; 256 uint32_t dropped_runt; 257 uint32_t dropped_overrun; 258 uint32_t dropped_no_small_buffer; 259 uint32_t dropped_no_big_buffer; 260 uint32_t dropped_interrupt_busy; 261 uint32_t rdma_tags_available; 262 } mcp_stats_t; 263 264 265 #endif /* _myri10ge_mcp_h */ 266