1 /*******************************************************************************
3 Copyright (c) 2006-2007, Myricom Inc.
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are met:
9 1. Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer.
12 2. Neither the name of the Myricom Inc, nor the names of its
13 contributors may be used to endorse or promote products derived from
14 this software without specific prior written permission.
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 POSSIBILITY OF SUCH DAMAGE.
30 ***************************************************************************/
32 #define MXGE_ETH_STOPPED 0
33 #define MXGE_ETH_STOPPING 1
34 #define MXGE_ETH_STARTING 2
35 #define MXGE_ETH_RUNNING 3
36 #define MXGE_ETH_OPEN_FAILED 4
38 #define MXGE_FW_OFFSET 1024*1024
39 #define MXGE_EEPROM_STRINGS_SIZE 256
40 #define MXGE_MAX_SEND_DESC 128
42 #if (__FreeBSD_version < 800005)
43 #define MXGE_VIRT_JUMBOS 1
45 #define MXGE_VIRT_JUMBOS 0
48 #ifndef VLAN_CAPABILITIES
49 #define VLAN_CAPABILITIES(ifp)
50 #define mxge_vlans_active(sc) (sc)->ifp->if_nvlans
52 #define mxge_vlans_active(sc) (sc)->ifp->if_vlantrunk
55 #ifndef VLAN_TAG_VALUE
56 #define MXGE_NEW_VLAN_API
99 struct mxge_rx_buffer_state {
104 struct mxge_tx_buffer_state {
112 volatile mcp_kreq_ether_recv_t *lanai; /* lanai ptr for recv ring */
113 mcp_kreq_ether_recv_t *shadow; /* host shadow of recv ring */
114 struct mxge_rx_buffer_state *info;
116 bus_dmamap_t extra_map;
121 int mask; /* number of rx slots -1 */
127 volatile mcp_kreq_ether_send_t *lanai; /* lanai ptr for sendq */
128 mcp_kreq_ether_send_t *req_list; /* host shadow of sendq */
130 bus_dma_segment_t *seg_list;
131 struct mxge_tx_buffer_state *info;
133 int req; /* transmits submitted */
134 int mask; /* number of transmit slots -1 */
135 int done; /* transmits completed */
136 int pkt_done; /* packets completed */
137 int max_desc; /* max descriptors per xmit */
138 int stall; /* #times hw queue exhausted */
139 int wake; /* #times irq re-enabled xmit */
140 int watchdog_req; /* cache of req */
141 int watchdog_done; /* cache of done */
142 int watchdog_rx_pause; /* cache of pause rq recvd */
150 SLIST_ENTRY(lro_entry) next;
164 uint16_t source_port;
170 SLIST_HEAD(lro_head, lro_entry);
173 typedef struct mxge_softc mxge_softc_t;
175 struct mxge_slice_state {
177 mxge_tx_ring_t tx; /* transmit ring */
178 mxge_rx_ring_t rx_small;
179 mxge_rx_ring_t rx_big;
180 mxge_rx_done_t rx_done;
181 mcp_irq_data_t *fw_stats;
182 volatile uint32_t *irq_claim;
184 struct lro_head lro_active;
185 struct lro_head lro_free;
189 mxge_dma_t fw_stats_dma;
190 struct sysctl_oid *sysctl_tree;
191 struct sysctl_ctx_list sysctl_ctx;
197 struct mxge_slice_state *ss;
198 int csum_flag; /* rx_csums? */
199 int tx_boundary; /* boundary transmits cannot cross*/
201 bus_dma_tag_t parent_dmat;
202 volatile uint8_t *sram;
204 volatile uint32_t *irq_deassert;
205 mcp_cmd_response_t *cmd;
207 mxge_dma_t zeropad_dma;
208 struct pci_dev *pdev;
211 unsigned int rdma_tags_available;
213 volatile uint32_t *intr_coal_delay_ptr;
216 struct mtx driver_mtx;
221 int watchdog_countdown;
223 struct resource *mem_res;
224 struct resource *irq_res;
225 struct resource **msix_irq_res;
226 struct resource *msix_table_res;
227 struct resource *msix_pba_res;
231 char eeprom_strings[MXGE_EEPROM_STRINGS_SIZE];
232 char fw_version[128];
236 int adopted_rx_filter_bug;
238 struct ifmedia media;
242 int fw_multicast_support;
247 int need_media_probe;
250 mxge_dma_t dmabench_dma;
251 struct callout co_hdl;
252 struct sysctl_oid *slice_sysctl_tree;
253 struct sysctl_ctx_list slice_sysctl_ctx;
254 char *mac_addr_string;
255 uint8_t mac_addr[6]; /* eeprom mac address */
256 char product_code_string[64];
257 char serial_number_string[64];
258 char cmd_mtx_name[16];
259 char driver_mtx_name[16];
262 #define MXGE_PCI_VENDOR_MYRICOM 0x14c1
263 #define MXGE_PCI_DEVICE_Z8E 0x0008
264 #define MXGE_PCI_DEVICE_Z8E_9 0x0009
265 #define MXGE_XFP_COMPLIANCE_BYTE 131
267 #define MXGE_HIGHPART_TO_U32(X) \
268 (sizeof (X) == 8) ? ((uint32_t)((uint64_t)(X) >> 32)) : (0)
269 #define MXGE_LOWPART_TO_U32(X) ((uint32_t)(X))
271 struct mxge_media_type
278 /* implement our own memory barriers, since bus_space_barrier
279 cannot handle write-combining regions */
281 #if defined (__GNUC__)
282 #if #cpu(i386) || defined __i386 || defined i386 || defined __i386__ || #cpu(x86_64) || defined __x86_64__
283 #define mb() __asm__ __volatile__ ("sfence;": : :"memory")
284 #elif #cpu(sparc64) || defined sparc64 || defined __sparcv9
285 #define mb() __asm__ __volatile__ ("membar #MemIssue": : :"memory")
286 #elif #cpu(sparc) || defined sparc || defined __sparc__
287 #define mb() __asm__ __volatile__ ("stbar;": : :"memory")
289 #define mb() /* XXX just to make this compile */
292 #error "unknown compiler"
296 mxge_pio_copy(volatile void *to_v, void *from_v, size_t size)
298 register volatile uintptr_t *to;
299 volatile uintptr_t *from;
302 to = (volatile uintptr_t *) to_v;
304 for (i = (size / sizeof (uintptr_t)); i; i--) {
312 void mxge_lro_flush(struct mxge_slice_state *ss, struct lro_entry *lro);
313 int mxge_lro_rx(struct mxge_slice_state *ss, struct mbuf *m_head,
319 This file uses Myri10GE driver indentation.