Annotation of src/sys/dev/pci/ixgbe/ixgbe.h, Revision 1.32.2.6
1.32.2.6! pgoyette 1: /* $NetBSD: ixgbe.h,v 1.48 2018/05/18 10:09:02 msaitoh Exp $ */
1.26 msaitoh 2:
1.1 dyoung 3: /******************************************************************************
1.29 msaitoh 4: SPDX-License-Identifier: BSD-3-Clause
1.1 dyoung 5:
1.26 msaitoh 6: Copyright (c) 2001-2017, Intel Corporation
1.1 dyoung 7: All rights reserved.
1.26 msaitoh 8:
9: Redistribution and use in source and binary forms, with or without
1.1 dyoung 10: modification, are permitted provided that the following conditions are met:
1.26 msaitoh 11:
12: 1. Redistributions of source code must retain the above copyright notice,
1.1 dyoung 13: this list of conditions and the following disclaimer.
1.26 msaitoh 14:
15: 2. Redistributions in binary form must reproduce the above copyright
16: notice, this list of conditions and the following disclaimer in the
1.1 dyoung 17: documentation and/or other materials provided with the distribution.
1.26 msaitoh 18:
19: 3. Neither the name of the Intel Corporation nor the names of its
20: contributors may be used to endorse or promote products derived from
1.1 dyoung 21: this software without specific prior written permission.
1.26 msaitoh 22:
1.1 dyoung 23: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1.26 msaitoh 24: AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25: IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26: ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27: LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28: CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29: SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30: INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31: CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1.1 dyoung 32: ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33: POSSIBILITY OF SUCH DAMAGE.
34:
35: ******************************************************************************/
1.32.2.3 pgoyette 36: /*$FreeBSD: head/sys/dev/ixgbe/ixgbe.h 327031 2017-12-20 18:15:06Z erj $*/
1.26 msaitoh 37:
1.1 dyoung 38: /*
39: * Copyright (c) 2011 The NetBSD Foundation, Inc.
40: * All rights reserved.
41: *
42: * This code is derived from software contributed to The NetBSD Foundation
43: * by Coyote Point Systems, Inc.
44: *
45: * Redistribution and use in source and binary forms, with or without
46: * modification, are permitted provided that the following conditions
47: * are met:
48: * 1. Redistributions of source code must retain the above copyright
49: * notice, this list of conditions and the following disclaimer.
50: * 2. Redistributions in binary form must reproduce the above copyright
51: * notice, this list of conditions and the following disclaimer in the
52: * documentation and/or other materials provided with the distribution.
53: *
54: * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
55: * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
56: * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
57: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
58: * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
59: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
60: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
61: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
62: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
63: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
64: * POSSIBILITY OF SUCH DAMAGE.
65: */
66:
67:
68: #ifndef _IXGBE_H_
69: #define _IXGBE_H_
70:
71:
72: #include <sys/param.h>
73: #include <sys/reboot.h>
74: #include <sys/systm.h>
1.22 msaitoh 75: #include <sys/pcq.h>
1.1 dyoung 76: #include <sys/mbuf.h>
77: #include <sys/protosw.h>
78: #include <sys/socket.h>
79: #include <sys/malloc.h>
80: #include <sys/kernel.h>
81: #include <sys/module.h>
82: #include <sys/sockio.h>
1.32 knakahar 83: #include <sys/percpu.h>
1.1 dyoung 84:
85: #include <net/if.h>
86: #include <net/if_arp.h>
87: #include <net/bpf.h>
88: #include <net/if_ether.h>
89: #include <net/if_dl.h>
90: #include <net/if_media.h>
91:
92: #include <net/bpf.h>
93: #include <net/if_types.h>
94: #include <net/if_vlanvar.h>
95:
96: #include <netinet/in_systm.h>
97: #include <netinet/in.h>
98: #include <netinet/ip.h>
99: #include <netinet/ip6.h>
100: #include <netinet/tcp.h>
101: #include <netinet/udp.h>
102:
103: #include <sys/bus.h>
104: #include <dev/pci/pcivar.h>
105: #include <dev/pci/pcireg.h>
106: #include <sys/proc.h>
107: #include <sys/sysctl.h>
108: #include <sys/endian.h>
109: #include <sys/workqueue.h>
1.7 msaitoh 110: #include <sys/cpu.h>
1.9 knakahar 111: #include <sys/interrupt.h>
1.22 msaitoh 112: #include <sys/bitops.h>
1.1 dyoung 113:
114: #include "ixgbe_netbsd.h"
115: #include "ixgbe_api.h"
1.12 msaitoh 116: #include "ixgbe_common.h"
1.10 msaitoh 117: #include "ixgbe_vf.h"
1.26 msaitoh 118: #include "ixgbe_features.h"
1.1 dyoung 119:
120: /* Tunables */
121:
122: /*
123: * TxDescriptors Valid Range: 64-4096 Default Value: 256 This value is the
124: * number of transmit descriptors allocated by the driver. Increasing this
125: * value allows the driver to queue more transmits. Each descriptor is 16
126: * bytes. Performance tests have show the 2K value to be optimal for top
127: * performance.
128: */
129: #define DEFAULT_TXD 1024
130: #define PERFORM_TXD 2048
131: #define MAX_TXD 4096
132: #define MIN_TXD 64
133:
134: /*
135: * RxDescriptors Valid Range: 64-4096 Default Value: 256 This value is the
136: * number of receive descriptors allocated for each RX queue. Increasing this
137: * value allows the driver to buffer more incoming packets. Each descriptor
138: * is 16 bytes. A receive buffer is also allocated for each descriptor.
139: *
140: * Note: with 8 rings and a dual port card, it is possible to bump up
141: * against the system mbuf pool limit, you can tune nmbclusters
142: * to adjust for this.
143: */
144: #define DEFAULT_RXD 1024
145: #define PERFORM_RXD 2048
146: #define MAX_RXD 4096
147: #define MIN_RXD 64
148:
149: /* Alignment for rings */
150: #define DBA_ALIGN 128
151:
152: /*
153: * This is the max watchdog interval, ie. the time that can
154: * pass between any two TX clean operations, such only happening
155: * when the TX hardware is functioning.
156: */
1.26 msaitoh 157: #define IXGBE_WATCHDOG (10 * hz)
1.1 dyoung 158:
159: /*
160: * This parameters control when the driver calls the routine to reclaim
161: * transmit descriptors.
162: */
1.26 msaitoh 163: #define IXGBE_TX_CLEANUP_THRESHOLD(_a) ((_a)->num_tx_desc / 8)
164: #define IXGBE_TX_OP_THRESHOLD(_a) ((_a)->num_tx_desc / 32)
1.1 dyoung 165:
1.12 msaitoh 166: /* These defines are used in MTU calculations */
1.26 msaitoh 167: #define IXGBE_MAX_FRAME_SIZE 9728
168: #define IXGBE_MTU_HDR (ETHER_HDR_LEN + ETHER_CRC_LEN)
169: #define IXGBE_MTU_HDR_VLAN (ETHER_HDR_LEN + ETHER_CRC_LEN + \
170: ETHER_VLAN_ENCAP_LEN)
171: #define IXGBE_MAX_MTU (IXGBE_MAX_FRAME_SIZE - IXGBE_MTU_HDR)
172: #define IXGBE_MAX_MTU_VLAN (IXGBE_MAX_FRAME_SIZE - IXGBE_MTU_HDR_VLAN)
1.1 dyoung 173:
174: /* Flow control constants */
1.26 msaitoh 175: #define IXGBE_FC_PAUSE 0xFFFF
1.1 dyoung 176:
1.6 msaitoh 177: /*
178: * Used for optimizing small rx mbufs. Effort is made to keep the copy
179: * small and aligned for the CPU L1 cache.
1.26 msaitoh 180: *
1.6 msaitoh 181: * MHLEN is typically 168 bytes, giving us 8-byte alignment. Getting
182: * 32 byte alignment needed for the fast bcopy results in 8 bytes being
183: * wasted. Getting 64 byte alignment, which _should_ be ideal for
184: * modern Intel CPUs, results in 40 bytes wasted and a significant drop
185: * in observed efficiency of the optimization, 97.9% -> 81.8%.
186: */
1.8 msaitoh 187: #define MPKTHSIZE (offsetof(struct _mbuf_dummy, m_pktdat))
1.26 msaitoh 188: #define IXGBE_RX_COPY_HDR_PADDED ((((MPKTHSIZE - 1) / 32) + 1) * 32)
189: #define IXGBE_RX_COPY_LEN (MSIZE - IXGBE_RX_COPY_HDR_PADDED)
190: #define IXGBE_RX_COPY_ALIGN (IXGBE_RX_COPY_HDR_PADDED - MPKTHSIZE)
1.6 msaitoh 191:
1.1 dyoung 192: /* Keep older OS drivers building... */
193: #if !defined(SYSCTL_ADD_UQUAD)
194: #define SYSCTL_ADD_UQUAD SYSCTL_ADD_QUAD
195: #endif
196:
197: /* Defines for printing debug information */
198: #define DEBUG_INIT 0
199: #define DEBUG_IOCTL 0
200: #define DEBUG_HW 0
201:
202: #define INIT_DEBUGOUT(S) if (DEBUG_INIT) printf(S "\n")
203: #define INIT_DEBUGOUT1(S, A) if (DEBUG_INIT) printf(S "\n", A)
204: #define INIT_DEBUGOUT2(S, A, B) if (DEBUG_INIT) printf(S "\n", A, B)
205: #define IOCTL_DEBUGOUT(S) if (DEBUG_IOCTL) printf(S "\n")
206: #define IOCTL_DEBUGOUT1(S, A) if (DEBUG_IOCTL) printf(S "\n", A)
207: #define IOCTL_DEBUGOUT2(S, A, B) if (DEBUG_IOCTL) printf(S "\n", A, B)
208: #define HW_DEBUGOUT(S) if (DEBUG_HW) printf(S "\n")
209: #define HW_DEBUGOUT1(S, A) if (DEBUG_HW) printf(S "\n", A)
210: #define HW_DEBUGOUT2(S, A, B) if (DEBUG_HW) printf(S "\n", A, B)
211:
212: #define MAX_NUM_MULTICAST_ADDRESSES 128
1.26 msaitoh 213: #define IXGBE_82598_SCATTER 100
214: #define IXGBE_82599_SCATTER 32
215: #define MSIX_82598_BAR 3
216: #define MSIX_82599_BAR 4
217: #define IXGBE_TSO_SIZE 262140
218: #define IXGBE_RX_HDR 128
219: #define IXGBE_VFTA_SIZE 128
220: #define IXGBE_BR_SIZE 4096
221: #define IXGBE_QUEUE_MIN_FREE 32
222: #define IXGBE_MAX_TX_BUSY 10
223: #define IXGBE_QUEUE_HUNG 0x80000000
1.11 msaitoh 224:
1.26 msaitoh 225: #define IXGBE_EITR_DEFAULT 128
1.11 msaitoh 226:
1.7 msaitoh 227: /* IOCTL define to gather SFP+ Diagnostic data */
228: #define SIOCGI2C SIOCGIFGENERIC
229:
1.1 dyoung 230: /* Offload bits in mbuf flag */
231: #define M_CSUM_OFFLOAD \
232: (M_CSUM_IPv4|M_CSUM_UDPv4|M_CSUM_TCPv4|M_CSUM_UDPv6|M_CSUM_TCPv6)
233:
1.11 msaitoh 234: /* Backward compatibility items for very old versions */
235: #ifndef pci_find_cap
236: #define pci_find_cap pci_find_extcap
237: #endif
238:
239: #ifndef DEVMETHOD_END
240: #define DEVMETHOD_END { NULL, NULL }
241: #endif
242:
1.1 dyoung 243: /*
244: * Interrupt Moderation parameters
245: */
246: #define IXGBE_LOW_LATENCY 128
247: #define IXGBE_AVE_LATENCY 400
248: #define IXGBE_BULK_LATENCY 1200
1.16 msaitoh 249:
250: /* Using 1FF (the max value), the interval is ~1.05ms */
1.26 msaitoh 251: #define IXGBE_LINK_ITR_QUANTA 0x1FF
252: #define IXGBE_LINK_ITR ((IXGBE_LINK_ITR_QUANTA << 3) & \
253: IXGBE_EITR_ITR_INT_MASK)
1.13 msaitoh 254:
255:
1.26 msaitoh 256: /************************************************************************
1.1 dyoung 257: * vendor_info_array
1.26 msaitoh 258: *
259: * Contains the list of Subvendor/Subdevice IDs on
260: * which the driver should load.
261: ************************************************************************/
1.1 dyoung 262: typedef struct _ixgbe_vendor_info_t {
1.26 msaitoh 263: unsigned int vendor_id;
264: unsigned int device_id;
265: unsigned int subvendor_id;
266: unsigned int subdevice_id;
267: unsigned int index;
1.1 dyoung 268: } ixgbe_vendor_info_t;
269:
1.7 msaitoh 270: /* This is used to get SFP+ module data */
271: struct ixgbe_i2c_req {
272: u8 dev_addr;
273: u8 offset;
274: u8 len;
275: u8 data[8];
276: };
1.1 dyoung 277:
1.26 msaitoh 278: struct ixgbe_bp_data {
279: u32 low;
280: u32 high;
281: u32 log;
282: };
1.13 msaitoh 283:
1.1 dyoung 284: struct ixgbe_tx_buf {
1.7 msaitoh 285: union ixgbe_adv_tx_desc *eop;
1.26 msaitoh 286: struct mbuf *m_head;
287: bus_dmamap_t map;
1.1 dyoung 288: };
289:
290: struct ixgbe_rx_buf {
1.26 msaitoh 291: struct mbuf *buf;
292: struct mbuf *fmp;
293: bus_dmamap_t pmap;
294: u_int flags;
295: #define IXGBE_RX_COPY 0x01
296: uint64_t addr;
1.1 dyoung 297: };
298:
299: /*
1.26 msaitoh 300: * Bus dma allocation structure used by ixgbe_dma_malloc and ixgbe_dma_free
1.1 dyoung 301: */
302: struct ixgbe_dma_alloc {
1.26 msaitoh 303: bus_addr_t dma_paddr;
304: void *dma_vaddr;
305: ixgbe_dma_tag_t *dma_tag;
306: bus_dmamap_t dma_map;
307: bus_dma_segment_t dma_seg;
308: bus_size_t dma_size;
1.1 dyoung 309: };
310:
1.13 msaitoh 311: struct ixgbe_mc_addr {
1.26 msaitoh 312: u8 addr[IXGBE_ETH_LENGTH_OF_ADDRESS];
1.13 msaitoh 313: u32 vmdq;
314: };
315:
1.1 dyoung 316: /*
1.26 msaitoh 317: * Driver queue struct: this is the interrupt container
318: * for the associated tx and rx ring.
319: */
1.1 dyoung 320: struct ix_queue {
1.26 msaitoh 321: struct adapter *adapter;
322: u32 msix; /* This queue's MSI-X vector */
323: u32 eitr_setting;
324: u32 me;
325: struct resource *res;
326: int busy;
327: struct tx_ring *txr;
328: struct rx_ring *rxr;
1.32.2.1 pgoyette 329: struct work wq_cookie;
1.26 msaitoh 330: void *que_si;
1.32.2.1 pgoyette 331: /* Per queue event conters */
332: struct evcnt irqs; /* Hardware interrupt */
333: struct evcnt handleq; /* software_interrupt */
334: struct evcnt req; /* deferred */
1.26 msaitoh 335: char namebuf[32];
336: char evnamebuf[32];
1.31 knakahar 337:
1.32.2.2 pgoyette 338: kmutex_t dc_mtx; /* lock for disabled_count and this queue's EIMS/EIMC bit */
339: int disabled_count;/*
340: * means
341: * 0 : this queue is enabled
342: * > 0 : this queue is disabled
343: * the value is ixgbe_disable_queue() called count
344: */
1.32.2.4 pgoyette 345: bool txrx_use_workqueue;
1.1 dyoung 346: };
347:
348: /*
349: * The transmit ring, one per queue
350: */
351: struct tx_ring {
352: struct adapter *adapter;
353: kmutex_t tx_mtx;
354: u32 me;
1.11 msaitoh 355: u32 tail;
356: int busy;
1.7 msaitoh 357: union ixgbe_adv_tx_desc *tx_base;
358: struct ixgbe_tx_buf *tx_buffers;
359: struct ixgbe_dma_alloc txdma;
360: volatile u16 tx_avail;
361: u16 next_avail_desc;
362: u16 next_to_clean;
363: u16 num_desc;
1.1 dyoung 364: ixgbe_dma_tag_t *txtag;
1.32.2.4 pgoyette 365: #if 0
366: char mtx_name[16]; /* NetBSD has no mutex name */
367: #endif
1.22 msaitoh 368: pcq_t *txr_interq;
1.32.2.1 pgoyette 369: struct work wq_cookie;
1.22 msaitoh 370: void *txr_si;
1.26 msaitoh 371:
372: /* Flow Director */
1.1 dyoung 373: u16 atr_sample;
374: u16 atr_count;
1.26 msaitoh 375:
1.32.2.2 pgoyette 376: u64 bytes; /* used for AIM */
377: u64 packets;
1.1 dyoung 378: /* Soft Stats */
1.7 msaitoh 379: struct evcnt tso_tx;
1.1 dyoung 380: struct evcnt no_desc_avail;
381: struct evcnt total_packets;
1.22 msaitoh 382: struct evcnt pcq_drops;
1.32.2.1 pgoyette 383: /* Per queue conters. The adapter total is in struct adapter */
384: u64 q_efbig_tx_dma_setup;
385: u64 q_mbuf_defrag_failed;
386: u64 q_efbig2_tx_dma_setup;
387: u64 q_einval_tx_dma_setup;
388: u64 q_other_tx_dma_setup;
389: u64 q_eagain_tx_dma_setup;
390: u64 q_enomem_tx_dma_setup;
391: u64 q_tso_err;
1.1 dyoung 392: };
393:
394:
395: /*
396: * The Receive ring, one per rx queue
397: */
398: struct rx_ring {
399: struct adapter *adapter;
400: kmutex_t rx_mtx;
401: u32 me;
1.11 msaitoh 402: u32 tail;
1.1 dyoung 403: union ixgbe_adv_rx_desc *rx_base;
404: struct ixgbe_dma_alloc rxdma;
405: #ifdef LRO
406: struct lro_ctrl lro;
407: #endif /* LRO */
408: bool lro_enabled;
409: bool hw_rsc;
1.4 msaitoh 410: bool vtag_strip;
1.7 msaitoh 411: u16 next_to_refresh;
412: u16 next_to_check;
413: u16 num_desc;
414: u16 mbuf_sz;
1.32.2.4 pgoyette 415: #if 0
416: char mtx_name[16]; /* NetBSD has no mutex name */
417: #endif
1.1 dyoung 418: struct ixgbe_rx_buf *rx_buffers;
1.7 msaitoh 419: ixgbe_dma_tag_t *ptag;
1.1 dyoung 420:
1.32.2.2 pgoyette 421: u64 bytes; /* Used for AIM calc */
422: u64 packets;
1.1 dyoung 423:
424: /* Soft stats */
1.6 msaitoh 425: struct evcnt rx_copies;
1.1 dyoung 426: struct evcnt rx_packets;
427: struct evcnt rx_bytes;
428: struct evcnt rx_discarded;
429: struct evcnt no_jmbuf;
430: u64 rsc_num;
1.26 msaitoh 431:
432: /* Flow Director */
1.1 dyoung 433: u64 flm;
434: };
435:
1.13 msaitoh 436: #define IXGBE_MAX_VF_MC 30 /* Max number of multicast entries */
437:
438: struct ixgbe_vf {
1.26 msaitoh 439: u_int pool;
440: u_int rar_index;
441: u_int max_frame_size;
442: uint32_t flags;
443: uint8_t ether_addr[ETHER_ADDR_LEN];
444: uint16_t mc_hash[IXGBE_MAX_VF_MC];
445: uint16_t num_mc_hashes;
446: uint16_t default_vlan;
447: uint16_t vlan_tag;
448: uint16_t api_ver;
1.13 msaitoh 449: };
450:
1.1 dyoung 451: /* Our adapter structure */
452: struct adapter {
453: struct ixgbe_hw hw;
1.16 msaitoh 454: struct ixgbe_osdep osdep;
1.1 dyoung 455:
456: device_t dev;
1.16 msaitoh 457: struct ifnet *ifp;
1.24 msaitoh 458: struct if_percpuq *ipq; /* softint-based input queues */
1.1 dyoung 459:
460: struct resource *pci_mem;
461: struct resource *msix_mem;
462:
1.32.2.4 pgoyette 463: /* NetBSD: Interrupt resources are in osdep */
1.1 dyoung 464:
465: struct ifmedia media;
466: callout_t timer;
467: int if_flags;
468:
469: kmutex_t core_mtx;
470:
471: unsigned int num_queues;
472:
473: /*
1.26 msaitoh 474: * Shadow VFTA table, this is needed because
475: * the real vlan filter table gets cleared during
476: * a soft reset and the driver needs to be able
477: * to repopulate it.
478: */
1.1 dyoung 479: u32 shadow_vfta[IXGBE_VFTA_SIZE];
480:
481: /* Info about the interface */
482: int advertise; /* link speeds */
1.18 msaitoh 483: bool enable_aim; /* adaptive interrupt moderation */
1.1 dyoung 484: bool link_active;
485: u16 max_frame_size;
486: u16 num_segs;
487: u32 link_speed;
488: bool link_up;
1.11 msaitoh 489: u32 vector;
1.12 msaitoh 490: u16 dmac;
1.13 msaitoh 491: u32 phy_layer;
1.12 msaitoh 492:
493: /* Power management-related */
494: bool wol_support;
495: u32 wufc;
1.1 dyoung 496:
497: /* Mbuf cluster size */
498: u32 rx_mbuf_sz;
499:
500: /* Support for pluggable optics */
501: bool sfp_probe;
502: void *link_si; /* Link tasklet */
503: void *mod_si; /* SFP tasklet */
504: void *msf_si; /* Multispeed Fiber */
1.13 msaitoh 505: void *mbx_si; /* VF -> PF mailbox interrupt */
1.26 msaitoh 506:
507: /* Flow Director */
1.1 dyoung 508: int fdir_reinit;
509: void *fdir_si;
1.26 msaitoh 510:
1.12 msaitoh 511: void *phy_si; /* PHY intr tasklet */
1.1 dyoung 512:
1.32 knakahar 513: bool txrx_use_workqueue;
514: struct workqueue *que_wq; /* workqueue for ixgbe_handle_que_work() */
515: /*
516: * que_wq's "enqueued flag" is not required,
517: * because twice workqueue_enqueue() for
518: * ixgbe_handle_que_work() is avoided by masking
519: * the queue's interrupt by EIMC.
520: * See also ixgbe_msix_que().
521: */
522: struct workqueue *txr_wq; /* workqueue for ixgbe_deferred_mq_start_work() */
523: percpu_t *txr_wq_enqueued;
524:
1.1 dyoung 525: /*
1.26 msaitoh 526: * Queues:
527: * This is the irq holder, it has
528: * and RX/TX pair or rings associated
529: * with it.
530: */
1.1 dyoung 531: struct ix_queue *queues;
532:
533: /*
1.26 msaitoh 534: * Transmit rings
535: * Allocated at run time, an array of rings
1.1 dyoung 536: */
537: struct tx_ring *tx_rings;
1.7 msaitoh 538: u32 num_tx_desc;
1.15 msaitoh 539: u32 tx_process_limit;
1.1 dyoung 540:
541: /*
1.26 msaitoh 542: * Receive rings
543: * Allocated at run time, an array of rings
1.1 dyoung 544: */
545: struct rx_ring *rx_rings;
1.11 msaitoh 546: u64 active_queues;
1.7 msaitoh 547: u32 num_rx_desc;
1.15 msaitoh 548: u32 rx_process_limit;
1.1 dyoung 549:
550: /* Multicast array memory */
1.13 msaitoh 551: struct ixgbe_mc_addr *mta;
1.26 msaitoh 552:
553: /* SR-IOV */
554: int iov_mode;
1.13 msaitoh 555: int num_vfs;
556: int pool;
557: struct ixgbe_vf *vfs;
1.26 msaitoh 558:
559: /* Bypass */
560: struct ixgbe_bp_data bypass;
561:
562: /* Netmap */
1.15 msaitoh 563: void (*init_locked)(struct adapter *);
564: void (*stop_locked)(void *);
1.8 msaitoh 565:
1.1 dyoung 566: /* Misc stats maintained by the driver */
567: struct evcnt efbig_tx_dma_setup;
1.32.2.1 pgoyette 568: struct evcnt mbuf_defrag_failed;
1.1 dyoung 569: struct evcnt efbig2_tx_dma_setup;
570: struct evcnt einval_tx_dma_setup;
571: struct evcnt other_tx_dma_setup;
572: struct evcnt eagain_tx_dma_setup;
573: struct evcnt enomem_tx_dma_setup;
1.21 msaitoh 574: struct evcnt tso_err;
1.1 dyoung 575: struct evcnt watchdog_events;
1.12 msaitoh 576: struct evcnt link_irq;
1.32.2.2 pgoyette 577: struct evcnt link_sicount;
578: struct evcnt mod_sicount;
579: struct evcnt msf_sicount;
580: struct evcnt phy_sicount;
1.1 dyoung 581:
1.11 msaitoh 582: union {
583: struct ixgbe_hw_stats pf;
584: struct ixgbevf_hw_stats vf;
585: } stats;
586: #if __FreeBSD_version >= 1100036
587: /* counter(9) stats */
588: u64 ipackets;
589: u64 ierrors;
590: u64 opackets;
591: u64 oerrors;
592: u64 ibytes;
593: u64 obytes;
594: u64 imcasts;
595: u64 omcasts;
596: u64 iqdrops;
597: u64 noproto;
598: #endif
1.26 msaitoh 599: /* Feature capable/enabled flags. See ixgbe_features.h */
600: u32 feat_cap;
601: u32 feat_en;
602:
1.1 dyoung 603: struct sysctllog *sysctllog;
1.19 msaitoh 604: const struct sysctlnode *sysctltop;
1.1 dyoung 605: ixgbe_extmem_head_t jcl_head;
606: };
607:
608: /* Precision Time Sync (IEEE 1588) defines */
609: #define ETHERTYPE_IEEE1588 0x88F7
610: #define PICOSECS_PER_TICK 20833
611: #define TSYNC_UDP_PORT 319 /* UDP port for the protocol */
1.26 msaitoh 612: #define IXGBE_ADVTXD_TSTAMP 0x00080000
1.1 dyoung 613:
614:
615: #define IXGBE_CORE_LOCK_INIT(_sc, _name) \
1.2 msaitoh 616: mutex_init(&(_sc)->core_mtx, MUTEX_DEFAULT, IPL_SOFTNET)
1.1 dyoung 617: #define IXGBE_CORE_LOCK_DESTROY(_sc) mutex_destroy(&(_sc)->core_mtx)
618: #define IXGBE_TX_LOCK_DESTROY(_sc) mutex_destroy(&(_sc)->tx_mtx)
619: #define IXGBE_RX_LOCK_DESTROY(_sc) mutex_destroy(&(_sc)->rx_mtx)
620: #define IXGBE_CORE_LOCK(_sc) mutex_enter(&(_sc)->core_mtx)
621: #define IXGBE_TX_LOCK(_sc) mutex_enter(&(_sc)->tx_mtx)
622: #define IXGBE_TX_TRYLOCK(_sc) mutex_tryenter(&(_sc)->tx_mtx)
623: #define IXGBE_RX_LOCK(_sc) mutex_enter(&(_sc)->rx_mtx)
624: #define IXGBE_CORE_UNLOCK(_sc) mutex_exit(&(_sc)->core_mtx)
625: #define IXGBE_TX_UNLOCK(_sc) mutex_exit(&(_sc)->tx_mtx)
626: #define IXGBE_RX_UNLOCK(_sc) mutex_exit(&(_sc)->rx_mtx)
1.3 msaitoh 627: #define IXGBE_CORE_LOCK_ASSERT(_sc) KASSERT(mutex_owned(&(_sc)->core_mtx))
1.1 dyoung 628: #define IXGBE_TX_LOCK_ASSERT(_sc) KASSERT(mutex_owned(&(_sc)->tx_mtx))
629:
1.11 msaitoh 630: /* Stats macros */
631: #if __FreeBSD_version >= 1100036
632: #define IXGBE_SET_IPACKETS(sc, count) (sc)->ipackets = (count)
633: #define IXGBE_SET_IERRORS(sc, count) (sc)->ierrors = (count)
634: #define IXGBE_SET_OPACKETS(sc, count) (sc)->opackets = (count)
635: #define IXGBE_SET_OERRORS(sc, count) (sc)->oerrors = (count)
636: #define IXGBE_SET_COLLISIONS(sc, count)
637: #define IXGBE_SET_IBYTES(sc, count) (sc)->ibytes = (count)
638: #define IXGBE_SET_OBYTES(sc, count) (sc)->obytes = (count)
639: #define IXGBE_SET_IMCASTS(sc, count) (sc)->imcasts = (count)
640: #define IXGBE_SET_OMCASTS(sc, count) (sc)->omcasts = (count)
641: #define IXGBE_SET_IQDROPS(sc, count) (sc)->iqdrops = (count)
642: #else
643: #define IXGBE_SET_IPACKETS(sc, count) (sc)->ifp->if_ipackets = (count)
644: #define IXGBE_SET_IERRORS(sc, count) (sc)->ifp->if_ierrors = (count)
645: #define IXGBE_SET_OPACKETS(sc, count) (sc)->ifp->if_opackets = (count)
646: #define IXGBE_SET_OERRORS(sc, count) (sc)->ifp->if_oerrors = (count)
647: #define IXGBE_SET_COLLISIONS(sc, count) (sc)->ifp->if_collisions = (count)
648: #define IXGBE_SET_IBYTES(sc, count) (sc)->ifp->if_ibytes = (count)
649: #define IXGBE_SET_OBYTES(sc, count) (sc)->ifp->if_obytes = (count)
650: #define IXGBE_SET_IMCASTS(sc, count) (sc)->ifp->if_imcasts = (count)
651: #define IXGBE_SET_OMCASTS(sc, count) (sc)->ifp->if_omcasts = (count)
652: #define IXGBE_SET_IQDROPS(sc, count) (sc)->ifp->if_iqdrops = (count)
653: #endif
654:
1.12 msaitoh 655: /* External PHY register addresses */
656: #define IXGBE_PHY_CURRENT_TEMP 0xC820
657: #define IXGBE_PHY_OVERTEMP_STATUS 0xC830
658:
1.11 msaitoh 659: /* Sysctl help messages; displayed with sysctl -d */
660: #define IXGBE_SYSCTL_DESC_ADV_SPEED \
661: "\nControl advertised link speed using these flags:\n" \
1.27 msaitoh 662: "\t0x01 - advertise 100M\n" \
663: "\t0x02 - advertise 1G\n" \
664: "\t0x04 - advertise 10G\n" \
665: "\t0x08 - advertise 10M\n" \
666: "\t0x10 - advertise 2.5G\n" \
667: "\t0x20 - advertise 5G\n\n" \
668: "\t5G, 2.5G, 100M and 10M are only supported on certain adapters."
1.11 msaitoh 669:
670: #define IXGBE_SYSCTL_DESC_SET_FC \
671: "\nSet flow control mode using these values:\n" \
672: "\t0 - off\n" \
673: "\t1 - rx pause\n" \
674: "\t2 - tx pause\n" \
675: "\t3 - tx and rx pause"
676:
1.1 dyoung 677: /* Workaround to make 8.0 buildable */
678: #if __FreeBSD_version >= 800000 && __FreeBSD_version < 800504
679: static __inline int
680: drbr_needs_enqueue(struct ifnet *ifp, struct buf_ring *br)
681: {
682: #ifdef ALTQ
1.32.2.1 pgoyette 683: if (ALTQ_IS_ENABLED(&ifp->if_snd))
684: return (1);
1.1 dyoung 685: #endif
1.32.2.1 pgoyette 686: return (!buf_ring_empty(br));
1.1 dyoung 687: }
688: #endif
689:
690: /*
1.26 msaitoh 691: * Find the number of unrefreshed RX descriptors
692: */
1.32.2.4 pgoyette 693: static __inline u16
1.1 dyoung 694: ixgbe_rx_unrefreshed(struct rx_ring *rxr)
1.26 msaitoh 695: {
1.1 dyoung 696: if (rxr->next_to_check > rxr->next_to_refresh)
697: return (rxr->next_to_check - rxr->next_to_refresh - 1);
698: else
1.7 msaitoh 699: return ((rxr->num_desc + rxr->next_to_check) -
1.1 dyoung 700: rxr->next_to_refresh - 1);
1.11 msaitoh 701: }
702:
1.32.2.4 pgoyette 703: static __inline int
1.26 msaitoh 704: ixgbe_legacy_ring_empty(struct ifnet *ifp, pcq_t *dummy)
1.13 msaitoh 705: {
1.26 msaitoh 706: UNREFERENCED_1PARAMETER(dummy);
1.13 msaitoh 707:
1.26 msaitoh 708: return IFQ_IS_EMPTY(&ifp->if_snd);
1.13 msaitoh 709: }
710:
1.32.2.4 pgoyette 711: static __inline int
1.26 msaitoh 712: ixgbe_mq_ring_empty(struct ifnet *dummy, pcq_t *interq)
1.13 msaitoh 713: {
1.26 msaitoh 714: UNREFERENCED_1PARAMETER(dummy);
1.13 msaitoh 715:
1.26 msaitoh 716: return (pcq_peek(interq) == NULL);
1.13 msaitoh 717: }
718:
1.26 msaitoh 719: /*
720: * This checks for a zero mac addr, something that will be likely
721: * unless the Admin on the Host has created one.
722: */
1.32.2.4 pgoyette 723: static __inline bool
1.26 msaitoh 724: ixv_check_ether_addr(u8 *addr)
1.13 msaitoh 725: {
1.26 msaitoh 726: bool status = TRUE;
1.13 msaitoh 727:
1.26 msaitoh 728: if ((addr[0] == 0 && addr[1]== 0 && addr[2] == 0 &&
729: addr[3] == 0 && addr[4]== 0 && addr[5] == 0))
730: status = FALSE;
1.13 msaitoh 731:
1.26 msaitoh 732: return (status);
1.13 msaitoh 733: }
734:
1.26 msaitoh 735: /* Shared Prototypes */
736: void ixgbe_legacy_start(struct ifnet *);
737: int ixgbe_legacy_start_locked(struct ifnet *, struct tx_ring *);
738: int ixgbe_mq_start(struct ifnet *, struct mbuf *);
739: int ixgbe_mq_start_locked(struct ifnet *, struct tx_ring *);
740: void ixgbe_deferred_mq_start(void *);
1.32 knakahar 741: void ixgbe_deferred_mq_start_work(struct work *, void *);
1.32.2.3 pgoyette 742: void ixgbe_drain_all(struct adapter *);
1.26 msaitoh 743:
744: int ixgbe_allocate_queues(struct adapter *);
745: int ixgbe_setup_transmit_structures(struct adapter *);
746: void ixgbe_free_transmit_structures(struct adapter *);
747: int ixgbe_setup_receive_structures(struct adapter *);
748: void ixgbe_free_receive_structures(struct adapter *);
1.30 msaitoh 749: bool ixgbe_txeof(struct tx_ring *);
1.26 msaitoh 750: bool ixgbe_rxeof(struct ix_queue *);
751:
1.28 msaitoh 752: const struct sysctlnode *ixgbe_sysctl_instance(struct adapter *);
753:
1.32.2.5 pgoyette 754: /* For NetBSD */
755: void ixgbe_jcl_reinit(struct adapter *, bus_dma_tag_t, int, size_t);
756:
1.26 msaitoh 757: #include "ixgbe_bypass.h"
758: #include "ixgbe_fdir.h"
759: #include "ixgbe_rss.h"
760: #include "ixgbe_netmap.h"
1.13 msaitoh 761:
1.1 dyoung 762: #endif /* _IXGBE_H_ */
CVSweb <webmaster@jp.NetBSD.org>