1 /*******************************************************************************
3 Copyright (c) 2006-2009, 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 > 800000 && __FreeBSD_version < 800005) \
43 || __FreeBSD_version < 700111)
44 #define MXGE_VIRT_JUMBOS 1
46 #define MXGE_VIRT_JUMBOS 0
49 #if (__FreeBSD_version > 800082)
50 #define IFNET_BUF_RING 1
53 #ifndef VLAN_CAPABILITIES
54 #define VLAN_CAPABILITIES(ifp)
55 #define mxge_vlans_active(sc) (sc)->ifp->if_nvlans
57 #define mxge_vlans_active(sc) (sc)->ifp->if_vlantrunk
60 #ifndef VLAN_TAG_VALUE
61 #define MXGE_NEW_VLAN_API
104 struct mxge_rx_buffer_state {
109 struct mxge_tx_buffer_state {
117 volatile mcp_kreq_ether_recv_t *lanai; /* lanai ptr for recv ring */
118 mcp_kreq_ether_recv_t *shadow; /* host shadow of recv ring */
119 struct mxge_rx_buffer_state *info;
121 bus_dmamap_t extra_map;
126 int mask; /* number of rx slots -1 */
133 #ifdef IFNET_BUF_RING
136 volatile mcp_kreq_ether_send_t *lanai; /* lanai ptr for sendq */
137 volatile uint32_t *send_go; /* doorbell for sendq */
138 volatile uint32_t *send_stop; /* doorbell for sendq */
139 mcp_kreq_ether_send_t *req_list; /* host shadow of sendq */
141 bus_dma_segment_t *seg_list;
142 struct mxge_tx_buffer_state *info;
144 int req; /* transmits submitted */
145 int mask; /* number of transmit slots -1 */
146 int done; /* transmits completed */
147 int pkt_done; /* packets completed */
148 int max_desc; /* max descriptors per xmit */
149 int queue_active; /* fw currently polling this queue*/
152 int stall; /* #times hw queue exhausted */
153 int wake; /* #times irq re-enabled xmit */
154 int watchdog_req; /* cache of req */
155 int watchdog_done; /* cache of done */
156 int watchdog_rx_pause; /* cache of pause rq recvd */
164 SLIST_ENTRY(lro_entry) next;
178 uint16_t source_port;
184 SLIST_HEAD(lro_head, lro_entry);
187 typedef struct mxge_softc mxge_softc_t;
189 struct mxge_slice_state {
191 mxge_tx_ring_t tx; /* transmit ring */
192 mxge_rx_ring_t rx_small;
193 mxge_rx_ring_t rx_big;
194 mxge_rx_done_t rx_done;
195 mcp_irq_data_t *fw_stats;
196 volatile uint32_t *irq_claim;
203 struct lro_head lro_active;
204 struct lro_head lro_free;
208 mxge_dma_t fw_stats_dma;
209 struct sysctl_oid *sysctl_tree;
210 struct sysctl_ctx_list sysctl_ctx;
216 struct mxge_slice_state *ss;
217 int csum_flag; /* rx_csums? */
218 int tx_boundary; /* boundary transmits cannot cross*/
220 bus_dma_tag_t parent_dmat;
221 volatile uint8_t *sram;
223 volatile uint32_t *irq_deassert;
224 mcp_cmd_response_t *cmd;
226 mxge_dma_t zeropad_dma;
227 struct pci_dev *pdev;
230 unsigned int rdma_tags_available;
232 volatile uint32_t *intr_coal_delay_ptr;
235 struct mtx driver_mtx;
240 int watchdog_countdown;
242 struct resource *mem_res;
243 struct resource *irq_res;
244 struct resource **msix_irq_res;
245 struct resource *msix_table_res;
246 struct resource *msix_pba_res;
250 char eeprom_strings[MXGE_EEPROM_STRINGS_SIZE];
251 char fw_version[128];
255 int adopted_rx_filter_bug;
257 struct ifmedia media;
261 int fw_multicast_support;
266 int need_media_probe;
270 mxge_dma_t dmabench_dma;
271 struct callout co_hdl;
272 struct sysctl_oid *slice_sysctl_tree;
273 struct sysctl_ctx_list slice_sysctl_ctx;
274 char *mac_addr_string;
275 uint8_t mac_addr[6]; /* eeprom mac address */
276 char product_code_string[64];
277 char serial_number_string[64];
278 char cmd_mtx_name[16];
279 char driver_mtx_name[16];
282 #define MXGE_PCI_VENDOR_MYRICOM 0x14c1
283 #define MXGE_PCI_DEVICE_Z8E 0x0008
284 #define MXGE_PCI_DEVICE_Z8E_9 0x0009
285 #define MXGE_PCI_REV_Z8E 0
286 #define MXGE_PCI_REV_Z8ES 1
287 #define MXGE_XFP_COMPLIANCE_BYTE 131
288 #define MXGE_SFP_COMPLIANCE_BYTE 3
290 #define MXGE_HIGHPART_TO_U32(X) \
291 (sizeof (X) == 8) ? ((uint32_t)((uint64_t)(X) >> 32)) : (0)
292 #define MXGE_LOWPART_TO_U32(X) ((uint32_t)(X))
294 struct mxge_media_type
301 /* implement our own memory barriers, since bus_space_barrier
302 cannot handle write-combining regions */
304 #if __FreeBSD_version < 800053
306 #if defined (__GNUC__)
307 #if #cpu(i386) || defined __i386 || defined i386 || defined __i386__ || #cpu(x86_64) || defined __x86_64__
308 #define wmb() __asm__ __volatile__ ("sfence;": : :"memory")
309 #elif #cpu(sparc64) || defined sparc64 || defined __sparcv9
310 #define wmb() __asm__ __volatile__ ("membar #MemIssue": : :"memory")
311 #elif #cpu(sparc) || defined sparc || defined __sparc__
312 #define wmb() __asm__ __volatile__ ("stbar;": : :"memory")
314 #define wmb() /* XXX just to make this compile */
317 #error "unknown compiler"
323 mxge_pio_copy(volatile void *to_v, void *from_v, size_t size)
325 register volatile uintptr_t *to;
326 volatile uintptr_t *from;
329 to = (volatile uintptr_t *) to_v;
331 for (i = (size / sizeof (uintptr_t)); i; i--) {
339 void mxge_lro_flush(struct mxge_slice_state *ss, struct lro_entry *lro);
340 int mxge_lro_rx(struct mxge_slice_state *ss, struct mbuf *m_head,
346 This file uses Myri10GE driver indentation.