mxge: Remove unused stats
[dragonfly.git] / sys / dev / netif / mxge / if_mxge_var.h
1 /*******************************************************************************
2
3 Copyright (c) 2006-2013, 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. 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.
15
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.
27
28 $FreeBSD: head/sys/dev/mxge/if_mxge_var.h 247160 2013-02-22 19:23:33Z gallatin $
29
30 ***************************************************************************/
31
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
37
38 #define MXGE_FW_OFFSET                  (1024*1024)
39 #define MXGE_EEPROM_STRINGS_SIZE        256
40 #define MXGE_MAX_SEND_DESC              128
41
42 #define MXGE_INTR_COAL_DELAY            150
43
44 struct mxge_softc;
45 typedef struct mxge_softc mxge_softc_t;
46
47 typedef struct {
48         uint32_t data0;
49         uint32_t data1;
50         uint32_t data2;
51 } mxge_cmd_t;
52
53 struct mxge_rx_buffer_state {
54         struct mbuf *m;
55         bus_dmamap_t map;
56 };
57
58 struct mxge_tx_buffer_state {
59         struct mbuf *m;
60         bus_dmamap_t map;
61         int flag;
62 };
63
64 typedef struct {
65         mxge_softc_t *sc;
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;
69         bus_dma_tag_t dmat;
70         bus_dmamap_t extra_map;
71         int cnt;
72         int cl_size;
73         int mask;                       /* number of rx slots -1 */
74         int mlen;
75 } mxge_rx_ring_t;
76
77 typedef struct {
78         mxge_rx_ring_t *rx_small;
79         mxge_rx_ring_t *rx_big;
80         mcp_slot_t *entry;
81         bus_dmamem_t dma;
82         int cnt;
83         int idx;
84         int mask;
85 } mxge_rx_done_t;
86
87 typedef struct {
88         struct lwkt_serialize tx_serialize;
89         mxge_softc_t *sc;
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;
96         bus_dma_tag_t dmat;
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*/
103         int activate;
104         int deactivate;
105         int watchdog_rx_pause;          /* cache of pause rq recvd */
106 } mxge_tx_ring_t;
107
108 struct mxge_rx_data {
109         struct lwkt_serialize rx_serialize;
110         mxge_rx_done_t rx_done;
111         mxge_rx_ring_t rx_small;
112         mxge_rx_ring_t rx_big;
113 };
114
115 struct mxge_slice_state {
116         struct mxge_rx_data rx_data;
117         mxge_tx_ring_t tx;              /* transmit ring */
118         mxge_softc_t *sc;
119         mcp_irq_data_t *fw_stats;
120         volatile uint32_t *irq_claim;
121         bus_dmamem_t fw_stats_dma;
122         struct sysctl_oid *sysctl_tree;
123         struct sysctl_ctx_list sysctl_ctx;
124 };
125
126 struct mxge_softc {
127         struct arpcom arpcom;
128         struct ifnet* ifp;              /* points to arpcom.ac_if */
129         struct lwkt_serialize main_serialize;
130         int nserialize;
131         struct lwkt_serialize **serializes;
132         struct mxge_slice_state *ss;
133         int tx_boundary;                /* boundary transmits cannot cross*/
134         bus_dma_tag_t parent_dmat;
135         volatile uint8_t *sram;
136         int sram_size;
137         volatile uint32_t *irq_deassert;
138         mcp_cmd_response_t *cmd;
139         bus_dmamem_t cmd_dma;
140         bus_dmamem_t zeropad_dma;
141         struct pci_dev *pdev;
142         int irq_rid;
143         int irq_type;
144         int link_state;
145         unsigned int rdma_tags_available;
146         int intr_coal_delay;
147         volatile uint32_t *intr_coal_delay_ptr;
148         int wc;
149         int wake_queue;
150         int stop_queue;
151         int down_cnt;
152         int watchdog_resets;
153         int pause;
154         struct resource *mem_res;
155         struct resource *irq_res;
156         struct resource **msix_irq_res;
157         struct resource *msix_table_res;
158         struct resource *msix_pba_res;
159         void *ih; 
160         void **msix_ih;
161         const char *fw_name;
162         char eeprom_strings[MXGE_EEPROM_STRINGS_SIZE];
163         char fw_version[128];
164         int fw_ver_major;
165         int fw_ver_minor;
166         int fw_ver_tiny;
167         int adopted_rx_filter_bug;
168         device_t dev;
169         struct ifmedia media;
170         int read_dma;
171         int write_dma;
172         int read_write_dma;
173         int fw_multicast_support;
174         int link_width;
175         int max_mtu;
176         int throttle;
177         int media_flags;
178         int need_media_probe;
179         int num_slices;
180         int rx_ring_size;
181         int dying;
182         int connector;
183         int current_media;
184         bus_dmamem_t dmabench_dma;
185         struct callout co_hdl;
186         u_long opackets;                /* saved ifnet.opackets */
187         u_long ipackets;                /* saved ifnet.ipackets */
188         struct sysctl_ctx_list sysctl_ctx;
189         struct sysctl_oid *sysctl_tree;
190         struct sysctl_oid *slice_sysctl_tree;
191         struct sysctl_ctx_list slice_sysctl_ctx;
192         uint8_t mac_addr[6];            /* eeprom mac address */
193         uint16_t pectl;                 /* save PCIe CTL state */
194         char product_code_string[64];
195         char serial_number_string[64];
196 };
197
198 #define MXGE_PCI_VENDOR_MYRICOM         0x14c1
199 #define MXGE_PCI_DEVICE_Z8E             0x0008
200 #define MXGE_PCI_DEVICE_Z8E_9           0x0009
201 #define MXGE_PCI_REV_Z8E                0
202 #define MXGE_PCI_REV_Z8ES               1
203
204 #define MXGE_XFP_COMPLIANCE_BYTE        131
205 #define MXGE_SFP_COMPLIANCE_BYTE        3
206
207 #define MXGE_MIN_THROTTLE               416
208 #define MXGE_MAX_THROTTLE               4096
209
210 /* Types of connectors on NICs supported by this driver */
211 #define MXGE_CX4 0
212 #define MXGE_XFP 1
213 #define MXGE_SFP 2
214 #define MXGE_QRF 3
215
216 #define MXGE_HIGHPART_TO_U32(X) \
217         (sizeof (X) == 8) ? ((uint32_t)((uint64_t)(X) >> 32)) : (0)
218 #define MXGE_LOWPART_TO_U32(X) ((uint32_t)(X))
219
220 struct mxge_media_type {
221         int flag;
222         uint8_t bitmask;
223         char *name;
224 };
225
226 #if defined(__GNUC__)
227 #if defined(__i386__) || defined(__x86_64__)
228 #define wmb()  __asm__ __volatile__ ("sfence;": : :"memory")
229 #else
230 #error "unknown arch"
231 #endif
232 #else
233 #error "unknown compiler"
234 #endif
235
236 static __inline void
237 mxge_pio_copy(volatile void *to_v, void *from_v, size_t size)
238 {
239         register volatile uintptr_t *to;
240         volatile uintptr_t *from;
241         size_t i;
242
243         to = (volatile uintptr_t *)to_v;
244         from = from_v;
245         for (i = (size / sizeof(uintptr_t)); i; i--) {
246                 *to = *from;
247                 to++;
248                 from++;
249         }
250 }