Annotation of src/sys/dev/pci/ixgbe/ixgbe.h, Revision 1.72
1.72 ! knakahar 1: /* $NetBSD: ixgbe.h,v 1.71 2020/08/31 11:19:54 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.41 msaitoh 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/if_types.h>
93: #include <net/if_vlanvar.h>
94:
95: #include <netinet/in_systm.h>
96: #include <netinet/in.h>
97: #include <netinet/ip.h>
98: #include <netinet/ip6.h>
99: #include <netinet/tcp.h>
100: #include <netinet/udp.h>
101:
102: #include <sys/bus.h>
103: #include <dev/pci/pcivar.h>
104: #include <dev/pci/pcireg.h>
105: #include <sys/proc.h>
106: #include <sys/sysctl.h>
107: #include <sys/endian.h>
108: #include <sys/workqueue.h>
1.7 msaitoh 109: #include <sys/cpu.h>
1.9 knakahar 110: #include <sys/interrupt.h>
1.22 msaitoh 111: #include <sys/bitops.h>
1.1 dyoung 112:
113: #include "ixgbe_netbsd.h"
114: #include "ixgbe_api.h"
1.12 msaitoh 115: #include "ixgbe_common.h"
1.10 msaitoh 116: #include "ixgbe_vf.h"
1.26 msaitoh 117: #include "ixgbe_features.h"
1.1 dyoung 118:
119: /* Tunables */
120:
121: /*
122: * TxDescriptors Valid Range: 64-4096 Default Value: 256 This value is the
123: * number of transmit descriptors allocated by the driver. Increasing this
124: * value allows the driver to queue more transmits. Each descriptor is 16
125: * bytes. Performance tests have show the 2K value to be optimal for top
126: * performance.
127: */
128: #define DEFAULT_TXD 1024
129: #define PERFORM_TXD 2048
130: #define MAX_TXD 4096
131: #define MIN_TXD 64
132:
133: /*
134: * RxDescriptors Valid Range: 64-4096 Default Value: 256 This value is the
135: * number of receive descriptors allocated for each RX queue. Increasing this
136: * value allows the driver to buffer more incoming packets. Each descriptor
1.60 msaitoh 137: * is 16 bytes. A receive buffer is also allocated for each descriptor.
138: *
139: * Note: with 8 rings and a dual port card, it is possible to bump up
1.1 dyoung 140: * against the system mbuf pool limit, you can tune nmbclusters
141: * to adjust for this.
142: */
143: #define DEFAULT_RXD 1024
144: #define PERFORM_RXD 2048
145: #define MAX_RXD 4096
146: #define MIN_RXD 64
147:
148: /* Alignment for rings */
149: #define DBA_ALIGN 128
150:
151: /*
152: * This is the max watchdog interval, ie. the time that can
153: * pass between any two TX clean operations, such only happening
154: * when the TX hardware is functioning.
155: */
1.48 msaitoh 156: #define IXGBE_WATCHDOG (10 * hz)
1.1 dyoung 157:
158: /*
159: * This parameters control when the driver calls the routine to reclaim
160: * transmit descriptors.
161: */
1.26 msaitoh 162: #define IXGBE_TX_CLEANUP_THRESHOLD(_a) ((_a)->num_tx_desc / 8)
163: #define IXGBE_TX_OP_THRESHOLD(_a) ((_a)->num_tx_desc / 32)
1.1 dyoung 164:
1.12 msaitoh 165: /* These defines are used in MTU calculations */
1.26 msaitoh 166: #define IXGBE_MAX_FRAME_SIZE 9728
167: #define IXGBE_MTU_HDR (ETHER_HDR_LEN + ETHER_CRC_LEN)
168: #define IXGBE_MTU_HDR_VLAN (ETHER_HDR_LEN + ETHER_CRC_LEN + \
169: ETHER_VLAN_ENCAP_LEN)
170: #define IXGBE_MAX_MTU (IXGBE_MAX_FRAME_SIZE - IXGBE_MTU_HDR)
171: #define IXGBE_MAX_MTU_VLAN (IXGBE_MAX_FRAME_SIZE - IXGBE_MTU_HDR_VLAN)
1.1 dyoung 172:
173: /* Flow control constants */
1.26 msaitoh 174: #define IXGBE_FC_PAUSE 0xFFFF
1.1 dyoung 175:
1.6 msaitoh 176: /*
177: * Used for optimizing small rx mbufs. Effort is made to keep the copy
178: * small and aligned for the CPU L1 cache.
1.26 msaitoh 179: *
1.6 msaitoh 180: * MHLEN is typically 168 bytes, giving us 8-byte alignment. Getting
181: * 32 byte alignment needed for the fast bcopy results in 8 bytes being
182: * wasted. Getting 64 byte alignment, which _should_ be ideal for
183: * modern Intel CPUs, results in 40 bytes wasted and a significant drop
184: * in observed efficiency of the optimization, 97.9% -> 81.8%.
185: */
1.8 msaitoh 186: #define MPKTHSIZE (offsetof(struct _mbuf_dummy, m_pktdat))
1.26 msaitoh 187: #define IXGBE_RX_COPY_HDR_PADDED ((((MPKTHSIZE - 1) / 32) + 1) * 32)
188: #define IXGBE_RX_COPY_LEN (MSIZE - IXGBE_RX_COPY_HDR_PADDED)
189: #define IXGBE_RX_COPY_ALIGN (IXGBE_RX_COPY_HDR_PADDED - MPKTHSIZE)
1.6 msaitoh 190:
1.1 dyoung 191: /* Keep older OS drivers building... */
192: #if !defined(SYSCTL_ADD_UQUAD)
193: #define SYSCTL_ADD_UQUAD SYSCTL_ADD_QUAD
194: #endif
195:
196: /* Defines for printing debug information */
197: #define DEBUG_INIT 0
198: #define DEBUG_IOCTL 0
199: #define DEBUG_HW 0
200:
201: #define INIT_DEBUGOUT(S) if (DEBUG_INIT) printf(S "\n")
202: #define INIT_DEBUGOUT1(S, A) if (DEBUG_INIT) printf(S "\n", A)
203: #define INIT_DEBUGOUT2(S, A, B) if (DEBUG_INIT) printf(S "\n", A, B)
204: #define IOCTL_DEBUGOUT(S) if (DEBUG_IOCTL) printf(S "\n")
205: #define IOCTL_DEBUGOUT1(S, A) if (DEBUG_IOCTL) printf(S "\n", A)
206: #define IOCTL_DEBUGOUT2(S, A, B) if (DEBUG_IOCTL) printf(S "\n", A, B)
207: #define HW_DEBUGOUT(S) if (DEBUG_HW) printf(S "\n")
208: #define HW_DEBUGOUT1(S, A) if (DEBUG_HW) printf(S "\n", A)
209: #define HW_DEBUGOUT2(S, A, B) if (DEBUG_HW) printf(S "\n", A, B)
210:
211: #define MAX_NUM_MULTICAST_ADDRESSES 128
1.26 msaitoh 212: #define IXGBE_82598_SCATTER 100
213: #define IXGBE_82599_SCATTER 32
214: #define MSIX_82598_BAR 3
215: #define MSIX_82599_BAR 4
216: #define IXGBE_TSO_SIZE 262140
217: #define IXGBE_RX_HDR 128
218: #define IXGBE_VFTA_SIZE 128
219: #define IXGBE_BR_SIZE 4096
220: #define IXGBE_QUEUE_MIN_FREE 32
1.48 msaitoh 221: #define IXGBE_MAX_TX_BUSY 10
222: #define IXGBE_QUEUE_HUNG 0x80000000
1.11 msaitoh 223:
1.26 msaitoh 224: #define IXGBE_EITR_DEFAULT 128
1.11 msaitoh 225:
1.7 msaitoh 226: /* IOCTL define to gather SFP+ Diagnostic data */
227: #define SIOCGI2C SIOCGIFGENERIC
228:
1.1 dyoung 229: /* Offload bits in mbuf flag */
230: #define M_CSUM_OFFLOAD \
231: (M_CSUM_IPv4|M_CSUM_UDPv4|M_CSUM_TCPv4|M_CSUM_UDPv6|M_CSUM_TCPv6)
232:
1.11 msaitoh 233: /* Backward compatibility items for very old versions */
234: #ifndef pci_find_cap
235: #define pci_find_cap pci_find_extcap
236: #endif
237:
238: #ifndef DEVMETHOD_END
239: #define DEVMETHOD_END { NULL, NULL }
240: #endif
241:
1.1 dyoung 242: /*
1.55 msaitoh 243: * Interrupt Moderation parameters
1.1 dyoung 244: */
245: #define IXGBE_LOW_LATENCY 128
246: #define IXGBE_AVE_LATENCY 400
247: #define IXGBE_BULK_LATENCY 1200
1.16 msaitoh 248:
249: /* Using 1FF (the max value), the interval is ~1.05ms */
1.26 msaitoh 250: #define IXGBE_LINK_ITR_QUANTA 0x1FF
251: #define IXGBE_LINK_ITR ((IXGBE_LINK_ITR_QUANTA << 3) & \
252: IXGBE_EITR_ITR_INT_MASK)
1.13 msaitoh 253:
254:
1.26 msaitoh 255: /************************************************************************
1.1 dyoung 256: * vendor_info_array
1.26 msaitoh 257: *
258: * Contains the list of Subvendor/Subdevice IDs on
259: * which the driver should load.
260: ************************************************************************/
1.1 dyoung 261: typedef struct _ixgbe_vendor_info_t {
1.26 msaitoh 262: unsigned int vendor_id;
263: unsigned int device_id;
264: unsigned int subvendor_id;
265: unsigned int subdevice_id;
266: unsigned int index;
1.1 dyoung 267: } ixgbe_vendor_info_t;
268:
1.7 msaitoh 269: /* This is used to get SFP+ module data */
270: struct ixgbe_i2c_req {
1.66 msaitoh 271: u8 dev_addr;
272: u8 offset;
273: u8 len;
274: u8 data[8];
1.7 msaitoh 275: };
1.1 dyoung 276:
1.26 msaitoh 277: struct ixgbe_bp_data {
278: u32 low;
279: u32 high;
280: u32 log;
281: };
1.13 msaitoh 282:
1.1 dyoung 283: struct ixgbe_tx_buf {
1.7 msaitoh 284: union ixgbe_adv_tx_desc *eop;
1.26 msaitoh 285: struct mbuf *m_head;
286: bus_dmamap_t map;
1.1 dyoung 287: };
288:
289: struct ixgbe_rx_buf {
1.26 msaitoh 290: struct mbuf *buf;
291: struct mbuf *fmp;
292: bus_dmamap_t pmap;
293: u_int flags;
294: #define IXGBE_RX_COPY 0x01
295: uint64_t addr;
1.1 dyoung 296: };
297:
298: /*
1.26 msaitoh 299: * Bus dma allocation structure used by ixgbe_dma_malloc and ixgbe_dma_free
1.1 dyoung 300: */
301: struct ixgbe_dma_alloc {
1.26 msaitoh 302: bus_addr_t dma_paddr;
303: void *dma_vaddr;
304: ixgbe_dma_tag_t *dma_tag;
305: bus_dmamap_t dma_map;
306: bus_dma_segment_t dma_seg;
307: bus_size_t dma_size;
1.1 dyoung 308: };
309:
1.13 msaitoh 310: struct ixgbe_mc_addr {
1.26 msaitoh 311: u8 addr[IXGBE_ETH_LENGTH_OF_ADDRESS];
1.13 msaitoh 312: u32 vmdq;
313: };
314:
1.1 dyoung 315: /*
1.26 msaitoh 316: * Driver queue struct: this is the interrupt container
317: * for the associated tx and rx ring.
318: */
1.1 dyoung 319: struct ix_queue {
1.26 msaitoh 320: struct adapter *adapter;
321: u32 msix; /* This queue's MSI-X vector */
322: u32 eitr_setting;
323: u32 me;
324: struct resource *res;
1.48 msaitoh 325: int busy;
1.26 msaitoh 326: struct tx_ring *txr;
327: struct rx_ring *rxr;
1.33 msaitoh 328: struct work wq_cookie;
1.26 msaitoh 329: void *que_si;
1.35 msaitoh 330: /* Per queue event conters */
331: struct evcnt irqs; /* Hardware interrupt */
332: struct evcnt handleq; /* software_interrupt */
333: struct evcnt req; /* deferred */
1.26 msaitoh 334: char namebuf[32];
335: char evnamebuf[32];
1.31 knakahar 336:
1.66 msaitoh 337: /* Lock for disabled_count and this queue's EIMS/EIMC bit */
338: kmutex_t dc_mtx;
339: /*
340: * disabled_count means:
341: * 0 : this queue is enabled
342: * > 0 : this queue is disabled
343: * the value is ixgbe_disable_queue() called count
344: */
345: int disabled_count;
1.42 knakahar 346: bool txrx_use_workqueue;
1.1 dyoung 347: };
348:
349: /*
350: * The transmit ring, one per queue
351: */
352: struct tx_ring {
1.55 msaitoh 353: struct adapter *adapter;
1.1 dyoung 354: kmutex_t tx_mtx;
355: u32 me;
1.11 msaitoh 356: u32 tail;
1.48 msaitoh 357: int busy;
1.7 msaitoh 358: union ixgbe_adv_tx_desc *tx_base;
359: struct ixgbe_tx_buf *tx_buffers;
360: struct ixgbe_dma_alloc txdma;
361: volatile u16 tx_avail;
362: u16 next_avail_desc;
363: u16 next_to_clean;
364: u16 num_desc;
1.1 dyoung 365: ixgbe_dma_tag_t *txtag;
1.43 msaitoh 366: #if 0
367: char mtx_name[16]; /* NetBSD has no mutex name */
368: #endif
1.22 msaitoh 369: pcq_t *txr_interq;
1.33 msaitoh 370: struct work wq_cookie;
1.22 msaitoh 371: void *txr_si;
1.49 msaitoh 372: bool txr_no_space; /* Like IFF_OACTIVE */
1.26 msaitoh 373:
374: /* Flow Director */
1.1 dyoung 375: u16 atr_sample;
376: u16 atr_count;
1.26 msaitoh 377:
1.66 msaitoh 378: u64 bytes; /* Used for AIM */
1.38 knakahar 379: u64 packets;
1.1 dyoung 380: /* Soft Stats */
1.66 msaitoh 381: struct evcnt tso_tx;
1.1 dyoung 382: struct evcnt no_desc_avail;
383: struct evcnt total_packets;
1.22 msaitoh 384: struct evcnt pcq_drops;
1.35 msaitoh 385: /* Per queue conters. The adapter total is in struct adapter */
386: u64 q_efbig_tx_dma_setup;
387: u64 q_mbuf_defrag_failed;
388: u64 q_efbig2_tx_dma_setup;
389: u64 q_einval_tx_dma_setup;
390: u64 q_other_tx_dma_setup;
391: u64 q_eagain_tx_dma_setup;
392: u64 q_enomem_tx_dma_setup;
393: u64 q_tso_err;
1.1 dyoung 394: };
395:
396:
397: /*
398: * The Receive ring, one per rx queue
399: */
400: struct rx_ring {
1.55 msaitoh 401: struct adapter *adapter;
1.1 dyoung 402: kmutex_t rx_mtx;
403: u32 me;
1.11 msaitoh 404: u32 tail;
1.1 dyoung 405: union ixgbe_adv_rx_desc *rx_base;
406: struct ixgbe_dma_alloc rxdma;
407: #ifdef LRO
408: struct lro_ctrl lro;
409: #endif /* LRO */
410: bool lro_enabled;
411: bool hw_rsc;
1.4 msaitoh 412: bool vtag_strip;
1.55 msaitoh 413: u16 next_to_refresh;
1.66 msaitoh 414: u16 next_to_check;
1.7 msaitoh 415: u16 num_desc;
416: u16 mbuf_sz;
1.43 msaitoh 417: #if 0
418: char mtx_name[16]; /* NetBSD has no mutex name */
419: #endif
1.1 dyoung 420: struct ixgbe_rx_buf *rx_buffers;
1.7 msaitoh 421: ixgbe_dma_tag_t *ptag;
1.66 msaitoh 422: u16 last_rx_mbuf_sz;
423: u32 last_num_rx_desc;
1.51 msaitoh 424: ixgbe_extmem_head_t jcl_head;
1.1 dyoung 425:
1.38 knakahar 426: u64 bytes; /* Used for AIM calc */
427: u64 packets;
1.1 dyoung 428:
429: /* Soft stats */
1.6 msaitoh 430: struct evcnt rx_copies;
1.1 dyoung 431: struct evcnt rx_packets;
1.66 msaitoh 432: struct evcnt rx_bytes;
433: struct evcnt rx_discarded;
434: struct evcnt no_jmbuf;
435: u64 rsc_num;
1.26 msaitoh 436:
437: /* Flow Director */
1.1 dyoung 438: u64 flm;
439: };
440:
1.13 msaitoh 441: struct ixgbe_vf {
1.26 msaitoh 442: u_int pool;
443: u_int rar_index;
444: u_int max_frame_size;
445: uint32_t flags;
446: uint8_t ether_addr[ETHER_ADDR_LEN];
447: uint16_t mc_hash[IXGBE_MAX_VF_MC];
448: uint16_t num_mc_hashes;
449: uint16_t default_vlan;
450: uint16_t vlan_tag;
451: uint16_t api_ver;
1.13 msaitoh 452: };
453:
1.52 msaitoh 454: /*
455: * NetBSD: For trafic class
456: * Crrently, the following structure is only for statistics.
457: */
458: struct ixgbe_tc {
459: char evnamebuf[32];
460: };
461:
1.1 dyoung 462: /* Our adapter structure */
463: struct adapter {
464: struct ixgbe_hw hw;
1.16 msaitoh 465: struct ixgbe_osdep osdep;
1.1 dyoung 466:
467: device_t dev;
1.16 msaitoh 468: struct ifnet *ifp;
1.24 msaitoh 469: struct if_percpuq *ipq; /* softint-based input queues */
1.1 dyoung 470:
471: struct resource *pci_mem;
472: struct resource *msix_mem;
473:
1.43 msaitoh 474: /* NetBSD: Interrupt resources are in osdep */
1.1 dyoung 475:
476: struct ifmedia media;
477: callout_t timer;
1.67 msaitoh 478: struct workqueue *timer_wq;
479: struct work timer_wc;
480: u_int timer_pending;
481:
1.58 msaitoh 482: u_short if_flags; /* saved ifp->if_flags */
1.56 msaitoh 483: int ec_capenable; /* saved ec->ec_capenable */
1.1 dyoung 484:
485: kmutex_t core_mtx;
486:
487: unsigned int num_queues;
488:
489: /*
1.26 msaitoh 490: * Shadow VFTA table, this is needed because
491: * the real vlan filter table gets cleared during
492: * a soft reset and the driver needs to be able
493: * to repopulate it.
494: */
1.1 dyoung 495: u32 shadow_vfta[IXGBE_VFTA_SIZE];
496:
497: /* Info about the interface */
498: int advertise; /* link speeds */
1.18 msaitoh 499: bool enable_aim; /* adaptive interrupt moderation */
1.54 msaitoh 500: int link_active; /* Use LINK_STATE_* value */
1.1 dyoung 501: u16 max_frame_size;
502: u16 num_segs;
503: u32 link_speed;
504: bool link_up;
1.66 msaitoh 505: u32 vector;
1.12 msaitoh 506: u16 dmac;
1.13 msaitoh 507: u32 phy_layer;
1.12 msaitoh 508:
509: /* Power management-related */
510: bool wol_support;
511: u32 wufc;
1.1 dyoung 512:
513: /* Mbuf cluster size */
514: u32 rx_mbuf_sz;
515:
1.63 thorpej 516: bool schedule_wqs_ok;
517:
1.26 msaitoh 518: /* Flow Director */
1.1 dyoung 519: int fdir_reinit;
1.26 msaitoh 520:
1.67 msaitoh 521: /* Admin task */
522: struct workqueue *admin_wq; /* Link, SFP, PHY and FDIR */
523: struct work admin_wc;
524: u_int admin_pending;
525: volatile u32 task_requests;
1.72 ! knakahar 526: kmutex_t admin_mtx; /* lock for admin_pending, task_request */
! 527: /*
! 528: * Don't acquire this mutex while
! 529: * holding rx_mtx or tx_mtx, and
! 530: * vice versa.
! 531: */
1.1 dyoung 532:
1.32 knakahar 533: bool txrx_use_workqueue;
1.66 msaitoh 534:
535: /*
536: * Workqueue for ixgbe_handle_que_work().
537: *
538: * que_wq's "enqueued flag" is not required, because twice
539: * workqueue_enqueue() for ixgbe_handle_que_work() is avoided by
540: * masking the queue's interrupt by EIMC. See also ixgbe_msix_que().
541: */
542: struct workqueue *que_wq;
543: /* Workqueue for ixgbe_deferred_mq_start_work() */
544: struct workqueue *txr_wq;
1.32 knakahar 545: percpu_t *txr_wq_enqueued;
546:
1.1 dyoung 547: /*
1.26 msaitoh 548: * Queues:
549: * This is the irq holder, it has
550: * and RX/TX pair or rings associated
551: * with it.
552: */
1.1 dyoung 553: struct ix_queue *queues;
554:
555: /*
1.26 msaitoh 556: * Transmit rings
557: * Allocated at run time, an array of rings
1.1 dyoung 558: */
559: struct tx_ring *tx_rings;
1.7 msaitoh 560: u32 num_tx_desc;
1.15 msaitoh 561: u32 tx_process_limit;
1.1 dyoung 562:
563: /*
1.26 msaitoh 564: * Receive rings
565: * Allocated at run time, an array of rings
1.1 dyoung 566: */
567: struct rx_ring *rx_rings;
1.11 msaitoh 568: u64 active_queues;
1.7 msaitoh 569: u32 num_rx_desc;
1.15 msaitoh 570: u32 rx_process_limit;
1.1 dyoung 571:
572: /* Multicast array memory */
1.13 msaitoh 573: struct ixgbe_mc_addr *mta;
1.26 msaitoh 574:
575: /* SR-IOV */
576: int iov_mode;
1.13 msaitoh 577: int num_vfs;
578: int pool;
579: struct ixgbe_vf *vfs;
1.26 msaitoh 580:
581: /* Bypass */
582: struct ixgbe_bp_data bypass;
583:
584: /* Netmap */
1.66 msaitoh 585: void (*init_locked)(struct adapter *);
586: void (*stop_locked)(void *);
1.8 msaitoh 587:
1.53 msaitoh 588: /* Firmware error check */
589: u_int recovery_mode;
1.67 msaitoh 590: callout_t recovery_mode_timer;
591: struct workqueue *recovery_mode_timer_wq;
592: struct work recovery_mode_timer_wc;
593: u_int recovery_mode_timer_pending;
1.53 msaitoh 594:
1.1 dyoung 595: /* Misc stats maintained by the driver */
1.66 msaitoh 596: struct evcnt efbig_tx_dma_setup;
597: struct evcnt mbuf_defrag_failed;
598: struct evcnt efbig2_tx_dma_setup;
599: struct evcnt einval_tx_dma_setup;
600: struct evcnt other_tx_dma_setup;
601: struct evcnt eagain_tx_dma_setup;
602: struct evcnt enomem_tx_dma_setup;
603: struct evcnt tso_err;
604: struct evcnt watchdog_events;
1.67 msaitoh 605: struct evcnt admin_irqev;
606: struct evcnt link_workev;
607: struct evcnt mod_workev;
608: struct evcnt msf_workev;
609: struct evcnt phy_workev;
1.1 dyoung 610:
1.11 msaitoh 611: union {
612: struct ixgbe_hw_stats pf;
613: struct ixgbevf_hw_stats vf;
614: } stats;
615: #if __FreeBSD_version >= 1100036
616: /* counter(9) stats */
617: u64 ipackets;
618: u64 ierrors;
619: u64 opackets;
620: u64 oerrors;
621: u64 ibytes;
622: u64 obytes;
623: u64 imcasts;
624: u64 omcasts;
625: u64 iqdrops;
626: u64 noproto;
627: #endif
1.26 msaitoh 628: /* Feature capable/enabled flags. See ixgbe_features.h */
629: u32 feat_cap;
630: u32 feat_en;
631:
1.52 msaitoh 632: /* Traffic classes */
633: struct ixgbe_tc tcs[IXGBE_DCB_MAX_TRAFFIC_CLASS];
634:
1.1 dyoung 635: struct sysctllog *sysctllog;
1.19 msaitoh 636: const struct sysctlnode *sysctltop;
1.1 dyoung 637: };
638:
639: /* Precision Time Sync (IEEE 1588) defines */
640: #define ETHERTYPE_IEEE1588 0x88F7
641: #define PICOSECS_PER_TICK 20833
642: #define TSYNC_UDP_PORT 319 /* UDP port for the protocol */
1.26 msaitoh 643: #define IXGBE_ADVTXD_TSTAMP 0x00080000
1.1 dyoung 644:
645:
646: #define IXGBE_CORE_LOCK_INIT(_sc, _name) \
1.66 msaitoh 647: mutex_init(&(_sc)->core_mtx, MUTEX_DEFAULT, IPL_SOFTNET)
1.1 dyoung 648: #define IXGBE_CORE_LOCK_DESTROY(_sc) mutex_destroy(&(_sc)->core_mtx)
649: #define IXGBE_TX_LOCK_DESTROY(_sc) mutex_destroy(&(_sc)->tx_mtx)
650: #define IXGBE_RX_LOCK_DESTROY(_sc) mutex_destroy(&(_sc)->rx_mtx)
651: #define IXGBE_CORE_LOCK(_sc) mutex_enter(&(_sc)->core_mtx)
652: #define IXGBE_TX_LOCK(_sc) mutex_enter(&(_sc)->tx_mtx)
653: #define IXGBE_TX_TRYLOCK(_sc) mutex_tryenter(&(_sc)->tx_mtx)
654: #define IXGBE_RX_LOCK(_sc) mutex_enter(&(_sc)->rx_mtx)
655: #define IXGBE_CORE_UNLOCK(_sc) mutex_exit(&(_sc)->core_mtx)
656: #define IXGBE_TX_UNLOCK(_sc) mutex_exit(&(_sc)->tx_mtx)
657: #define IXGBE_RX_UNLOCK(_sc) mutex_exit(&(_sc)->rx_mtx)
1.3 msaitoh 658: #define IXGBE_CORE_LOCK_ASSERT(_sc) KASSERT(mutex_owned(&(_sc)->core_mtx))
1.1 dyoung 659: #define IXGBE_TX_LOCK_ASSERT(_sc) KASSERT(mutex_owned(&(_sc)->tx_mtx))
660:
1.12 msaitoh 661: /* External PHY register addresses */
662: #define IXGBE_PHY_CURRENT_TEMP 0xC820
663: #define IXGBE_PHY_OVERTEMP_STATUS 0xC830
664:
1.11 msaitoh 665: /* Sysctl help messages; displayed with sysctl -d */
666: #define IXGBE_SYSCTL_DESC_ADV_SPEED \
667: "\nControl advertised link speed using these flags:\n" \
1.27 msaitoh 668: "\t0x01 - advertise 100M\n" \
669: "\t0x02 - advertise 1G\n" \
1.55 msaitoh 670: "\t0x04 - advertise 10G\n" \
671: "\t0x08 - advertise 10M\n" \
672: "\t0x10 - advertise 2.5G\n" \
673: "\t0x20 - advertise 5G\n\n" \
674: "\t5G, 2.5G, 100M and 10M are only supported on certain adapters."
1.11 msaitoh 675:
676: #define IXGBE_SYSCTL_DESC_SET_FC \
677: "\nSet flow control mode using these values:\n" \
678: "\t0 - off\n" \
679: "\t1 - rx pause\n" \
680: "\t2 - tx pause\n" \
681: "\t3 - tx and rx pause"
682:
1.1 dyoung 683: /* Workaround to make 8.0 buildable */
684: #if __FreeBSD_version >= 800000 && __FreeBSD_version < 800504
685: static __inline int
686: drbr_needs_enqueue(struct ifnet *ifp, struct buf_ring *br)
687: {
688: #ifdef ALTQ
1.36 msaitoh 689: if (ALTQ_IS_ENABLED(&ifp->if_snd))
690: return (1);
1.1 dyoung 691: #endif
1.36 msaitoh 692: return (!buf_ring_empty(br));
1.1 dyoung 693: }
694: #endif
695:
696: /*
1.26 msaitoh 697: * Find the number of unrefreshed RX descriptors
698: */
1.45 christos 699: static __inline u16
1.1 dyoung 700: ixgbe_rx_unrefreshed(struct rx_ring *rxr)
1.26 msaitoh 701: {
1.1 dyoung 702: if (rxr->next_to_check > rxr->next_to_refresh)
703: return (rxr->next_to_check - rxr->next_to_refresh - 1);
704: else
1.7 msaitoh 705: return ((rxr->num_desc + rxr->next_to_check) -
1.1 dyoung 706: rxr->next_to_refresh - 1);
1.11 msaitoh 707: }
708:
1.45 christos 709: static __inline int
1.26 msaitoh 710: ixgbe_legacy_ring_empty(struct ifnet *ifp, pcq_t *dummy)
1.13 msaitoh 711: {
1.26 msaitoh 712: UNREFERENCED_1PARAMETER(dummy);
1.13 msaitoh 713:
1.26 msaitoh 714: return IFQ_IS_EMPTY(&ifp->if_snd);
1.13 msaitoh 715: }
716:
1.45 christos 717: static __inline int
1.26 msaitoh 718: ixgbe_mq_ring_empty(struct ifnet *dummy, pcq_t *interq)
1.13 msaitoh 719: {
1.26 msaitoh 720: UNREFERENCED_1PARAMETER(dummy);
1.13 msaitoh 721:
1.26 msaitoh 722: return (pcq_peek(interq) == NULL);
1.13 msaitoh 723: }
724:
1.26 msaitoh 725: /*
726: * This checks for a zero mac addr, something that will be likely
727: * unless the Admin on the Host has created one.
728: */
1.45 christos 729: static __inline bool
1.26 msaitoh 730: ixv_check_ether_addr(u8 *addr)
1.13 msaitoh 731: {
1.26 msaitoh 732: bool status = TRUE;
1.13 msaitoh 733:
1.26 msaitoh 734: if ((addr[0] == 0 && addr[1]== 0 && addr[2] == 0 &&
735: addr[3] == 0 && addr[4]== 0 && addr[5] == 0))
736: status = FALSE;
1.13 msaitoh 737:
1.26 msaitoh 738: return (status);
1.13 msaitoh 739: }
740:
1.53 msaitoh 741: /*
742: * This checks the adapter->recovery_mode software flag which is
743: * set by ixgbe_fw_recovery_mode().
744: *
745: */
746: static inline bool
747: ixgbe_fw_recovery_mode_swflag(struct adapter *adapter)
748: {
749: return (adapter->feat_en & IXGBE_FEATURE_RECOVERY_MODE) &&
750: atomic_load_acq_uint(&adapter->recovery_mode);
751: }
752:
1.26 msaitoh 753: /* Shared Prototypes */
754: void ixgbe_legacy_start(struct ifnet *);
755: int ixgbe_legacy_start_locked(struct ifnet *, struct tx_ring *);
756: int ixgbe_mq_start(struct ifnet *, struct mbuf *);
757: int ixgbe_mq_start_locked(struct ifnet *, struct tx_ring *);
758: void ixgbe_deferred_mq_start(void *);
1.32 knakahar 759: void ixgbe_deferred_mq_start_work(struct work *, void *);
1.40 knakahar 760: void ixgbe_drain_all(struct adapter *);
1.26 msaitoh 761:
762: int ixgbe_allocate_queues(struct adapter *);
1.62 msaitoh 763: void ixgbe_free_queues(struct adapter *);
1.26 msaitoh 764: int ixgbe_setup_transmit_structures(struct adapter *);
765: void ixgbe_free_transmit_structures(struct adapter *);
766: int ixgbe_setup_receive_structures(struct adapter *);
767: void ixgbe_free_receive_structures(struct adapter *);
1.30 msaitoh 768: bool ixgbe_txeof(struct tx_ring *);
1.26 msaitoh 769: bool ixgbe_rxeof(struct ix_queue *);
770:
1.67 msaitoh 771: #define IXGBE_REQUEST_TASK_MOD 0x01
772: #define IXGBE_REQUEST_TASK_MSF 0x02
773: #define IXGBE_REQUEST_TASK_MBX 0x04
774: #define IXGBE_REQUEST_TASK_FDIR 0x08
775: #define IXGBE_REQUEST_TASK_PHY 0x10
776: #define IXGBE_REQUEST_TASK_LSC 0x20
1.69 msaitoh 777: #define IXGBE_REQUEST_TASK_NEED_ACKINTR 0x80
1.28 msaitoh 778:
1.46 msaitoh 779: /* For NetBSD */
1.67 msaitoh 780: const struct sysctlnode *ixgbe_sysctl_instance(struct adapter *);
1.51 msaitoh 781: void ixgbe_jcl_reinit(struct adapter *, bus_dma_tag_t, struct rx_ring *,
782: int, size_t);
1.61 msaitoh 783: void ixgbe_jcl_destroy(struct adapter *, struct rx_ring *);
1.46 msaitoh 784:
1.26 msaitoh 785: #include "ixgbe_bypass.h"
786: #include "ixgbe_fdir.h"
787: #include "ixgbe_rss.h"
788: #include "ixgbe_netmap.h"
1.13 msaitoh 789:
1.1 dyoung 790: #endif /* _IXGBE_H_ */
CVSweb <webmaster@jp.NetBSD.org>