1 /*******************************************************************************
3 Copyright (c) 2006-2013, 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.
28 $FreeBSD: head/sys/dev/mxge/if_mxge_var.h 247160 2013-02-22 19:23:33Z gallatin $
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 #define MXGE_INTR_COAL_DELAY 150
45 typedef struct mxge_softc mxge_softc_t;
53 struct mxge_rx_buffer_state {
58 struct mxge_tx_buffer_state {
66 volatile mcp_kreq_ether_recv_t *lanai; /* lanai ptr for recv ring */
67 mcp_kreq_ether_recv_t *shadow; /* host shadow of recv ring */
68 struct mxge_rx_buffer_state *info;
70 bus_dmamap_t extra_map;
74 int mask; /* number of rx slots -1 */
79 mxge_rx_ring_t *rx_small;
80 mxge_rx_ring_t *rx_big;
90 volatile mcp_kreq_ether_send_t *lanai; /* lanai ptr for sendq */
91 volatile uint32_t *send_go; /* doorbell for sendq */
92 volatile uint32_t *send_stop; /* doorbell for sendq */
93 mcp_kreq_ether_send_t *req_list; /* host shadow of sendq */
94 bus_dma_segment_t *seg_list;
95 struct mxge_tx_buffer_state *info;
97 int req; /* transmits submitted */
98 int mask; /* number of transmit slots -1 */
99 int done; /* transmits completed */
100 int pkt_done; /* packets completed */
101 int max_desc; /* max descriptors per xmit */
102 int queue_active; /* fw currently polling this queue*/
105 int watchdog_rx_pause; /* cache of pause rq recvd */
108 struct mxge_slice_state {
110 mxge_tx_ring_t tx; /* transmit ring */
111 mxge_rx_ring_t rx_small;
112 mxge_rx_ring_t rx_big;
113 mxge_rx_done_t rx_done;
114 mcp_irq_data_t *fw_stats;
115 volatile uint32_t *irq_claim;
116 bus_dmamem_t fw_stats_dma;
117 struct sysctl_oid *sysctl_tree;
118 struct sysctl_ctx_list sysctl_ctx;
122 struct arpcom arpcom;
123 struct ifnet* ifp; /* points to arpcom.ac_if */
124 struct mxge_slice_state *ss;
125 int tx_boundary; /* boundary transmits cannot cross*/
126 bus_dma_tag_t parent_dmat;
127 volatile uint8_t *sram;
129 volatile uint32_t *irq_deassert;
130 mcp_cmd_response_t *cmd;
131 bus_dmamem_t cmd_dma;
132 bus_dmamem_t zeropad_dma;
133 struct pci_dev *pdev;
137 unsigned int rdma_tags_available;
139 volatile uint32_t *intr_coal_delay_ptr;
146 struct resource *mem_res;
147 struct resource *irq_res;
148 struct resource **msix_irq_res;
149 struct resource *msix_table_res;
150 struct resource *msix_pba_res;
154 char eeprom_strings[MXGE_EEPROM_STRINGS_SIZE];
155 char fw_version[128];
159 int adopted_rx_filter_bug;
161 struct ifmedia media;
165 int fw_multicast_support;
170 int need_media_probe;
176 bus_dmamem_t dmabench_dma;
177 struct callout co_hdl;
178 u_long opackets; /* saved ifnet.opackets */
179 u_long ipackets; /* saved ifnet.ipackets */
180 struct sysctl_ctx_list sysctl_ctx;
181 struct sysctl_oid *sysctl_tree;
182 struct sysctl_oid *slice_sysctl_tree;
183 struct sysctl_ctx_list slice_sysctl_ctx;
184 uint8_t mac_addr[6]; /* eeprom mac address */
185 uint16_t pectl; /* save PCIe CTL state */
186 char product_code_string[64];
187 char serial_number_string[64];
190 #define MXGE_PCI_VENDOR_MYRICOM 0x14c1
191 #define MXGE_PCI_DEVICE_Z8E 0x0008
192 #define MXGE_PCI_DEVICE_Z8E_9 0x0009
193 #define MXGE_PCI_REV_Z8E 0
194 #define MXGE_PCI_REV_Z8ES 1
196 #define MXGE_XFP_COMPLIANCE_BYTE 131
197 #define MXGE_SFP_COMPLIANCE_BYTE 3
199 #define MXGE_MIN_THROTTLE 416
200 #define MXGE_MAX_THROTTLE 4096
202 /* Types of connectors on NICs supported by this driver */
208 #define MXGE_HIGHPART_TO_U32(X) \
209 (sizeof (X) == 8) ? ((uint32_t)((uint64_t)(X) >> 32)) : (0)
210 #define MXGE_LOWPART_TO_U32(X) ((uint32_t)(X))
212 struct mxge_media_type {
218 #if defined(__GNUC__)
219 #if defined(__i386__) || defined(__x86_64__)
220 #define wmb() __asm__ __volatile__ ("sfence;": : :"memory")
222 #error "unknown arch"
225 #error "unknown compiler"
229 mxge_pio_copy(volatile void *to_v, void *from_v, size_t size)
231 register volatile uintptr_t *to;
232 volatile uintptr_t *from;
235 to = (volatile uintptr_t *)to_v;
237 for (i = (size / sizeof(uintptr_t)); i; i--) {