]> CyberLeo.Net >> Repos - FreeBSD/releng/10.3.git/blob - sys/dev/ixl/ixl.h
- Copy stable/10@296371 to releng/10.3 in preparation for 10.3-RC1
[FreeBSD/releng/10.3.git] / sys / dev / ixl / ixl.h
1 /******************************************************************************
2
3   Copyright (c) 2013-2015, Intel Corporation 
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. Redistributions in binary form must reproduce the above copyright 
13       notice, this list of conditions and the following disclaimer in the 
14       documentation and/or other materials provided with the distribution.
15   
16    3. Neither the name of the Intel Corporation nor the names of its 
17       contributors may be used to endorse or promote products derived from 
18       this software without specific prior written permission.
19   
20   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
22   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
23   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
24   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
25   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
26   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
27   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
28   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
29   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30   POSSIBILITY OF SUCH DAMAGE.
31
32 ******************************************************************************/
33 /*$FreeBSD$*/
34
35
36 #ifndef _IXL_H_
37 #define _IXL_H_
38
39
40 #include <sys/param.h>
41 #include <sys/systm.h>
42 #include <sys/buf_ring.h>
43 #include <sys/mbuf.h>
44 #include <sys/protosw.h>
45 #include <sys/socket.h>
46 #include <sys/malloc.h>
47 #include <sys/kernel.h>
48 #include <sys/module.h>
49 #include <sys/sockio.h>
50 #include <sys/eventhandler.h>
51
52 #include <net/if.h>
53 #include <net/if_var.h>
54 #include <net/if_arp.h>
55 #include <net/bpf.h>
56 #include <net/ethernet.h>
57 #include <net/if_dl.h>
58 #include <net/if_media.h>
59
60 #include <net/bpf.h>
61 #include <net/if_types.h>
62 #include <net/if_vlan_var.h>
63
64 #include <netinet/in_systm.h>
65 #include <netinet/in.h>
66 #include <netinet/if_ether.h>
67 #include <netinet/ip.h>
68 #include <netinet/ip6.h>
69 #include <netinet/tcp.h>
70 #include <netinet/tcp_lro.h>
71 #include <netinet/udp.h>
72 #include <netinet/sctp.h>
73
74 #include <machine/in_cksum.h>
75
76 #include <sys/bus.h>
77 #include <machine/bus.h>
78 #include <sys/rman.h>
79 #include <machine/resource.h>
80 #include <vm/vm.h>
81 #include <vm/pmap.h>
82 #include <machine/clock.h>
83 #include <dev/pci/pcivar.h>
84 #include <dev/pci/pcireg.h>
85 #include <sys/proc.h>
86 #include <sys/sysctl.h>
87 #include <sys/endian.h>
88 #include <sys/taskqueue.h>
89 #include <sys/pcpu.h>
90 #include <sys/smp.h>
91 #include <machine/smp.h>
92
93 #ifdef PCI_IOV
94 #include <sys/nv.h>
95 #include <sys/iov_schema.h>
96 #endif
97
98 #include "i40e_type.h"
99 #include "i40e_prototype.h"
100
101 #if defined(IXL_DEBUG) || defined(IXL_DEBUG_SYSCTL)
102 #include <sys/sbuf.h>
103
104 #define MAC_FORMAT "%02x:%02x:%02x:%02x:%02x:%02x"
105 #define MAC_FORMAT_ARGS(mac_addr) \
106         (mac_addr)[0], (mac_addr)[1], (mac_addr)[2], (mac_addr)[3], \
107         (mac_addr)[4], (mac_addr)[5]
108 #define ON_OFF_STR(is_set) ((is_set) ? "On" : "Off")
109 #endif /* IXL_DEBUG || IXL_DEBUG_SYSCTL */
110
111 #ifdef IXL_DEBUG
112 /* Enable debug sysctls */
113 #ifndef IXL_DEBUG_SYSCTL
114 #define IXL_DEBUG_SYSCTL 1
115 #endif
116
117 #define _DBG_PRINTF(S, ...)             printf("%s: " S "\n", __func__, ##__VA_ARGS__)
118 #define _DEV_DBG_PRINTF(dev, S, ...)    device_printf(dev, "%s: " S "\n", __func__, ##__VA_ARGS__)
119 #define _IF_DBG_PRINTF(ifp, S, ...)     if_printf(ifp, "%s: " S "\n", __func__, ##__VA_ARGS__)
120
121 /* Defines for printing generic debug information */
122 #define DPRINTF(...)                    _DBG_PRINTF(__VA_ARGS__)
123 #define DDPRINTF(...)                   _DEV_DBG_PRINTF(__VA_ARGS__)
124 #define IDPRINTF(...)                   _IF_DBG_PRINTF(__VA_ARGS__)
125
126 /* Defines for printing specific debug information */
127 #define DEBUG_INIT  1
128 #define DEBUG_IOCTL 1
129 #define DEBUG_HW    1
130
131 #define INIT_DEBUGOUT(...)              if (DEBUG_INIT) _DBG_PRINTF(__VA_ARGS__)
132 #define INIT_DBG_DEV(...)               if (DEBUG_INIT) _DEV_DBG_PRINTF(__VA_ARGS__)
133 #define INIT_DBG_IF(...)                if (DEBUG_INIT) _IF_DBG_PRINTF(__VA_ARGS__)
134
135 #define IOCTL_DEBUGOUT(...)             if (DEBUG_IOCTL) _DBG_PRINTF(__VA_ARGS__)
136 #define IOCTL_DBG_IF2(ifp, S, ...)      if (DEBUG_IOCTL) \
137                                             if_printf(ifp, S "\n", ##__VA_ARGS__)
138 #define IOCTL_DBG_IF(...)               if (DEBUG_IOCTL) _IF_DBG_PRINTF(__VA_ARGS__)
139
140 #define HW_DEBUGOUT(...)                if (DEBUG_HW) _DBG_PRINTF(__VA_ARGS__)
141
142 #else /* no IXL_DEBUG */
143 #define DEBUG_INIT  0
144 #define DEBUG_IOCTL 0
145 #define DEBUG_HW    0
146
147 #define DPRINTF(...)
148 #define DDPRINTF(...)
149 #define IDPRINTF(...)
150
151 #define INIT_DEBUGOUT(...)
152 #define INIT_DBG_DEV(...)
153 #define INIT_DBG_IF(...)
154 #define IOCTL_DEBUGOUT(...)
155 #define IOCTL_DBG_IF2(...)
156 #define IOCTL_DBG_IF(...)
157 #define HW_DEBUGOUT(...)
158 #endif /* IXL_DEBUG */
159
160 /* Tunables */
161
162 /*
163  * Ring Descriptors Valid Range: 32-4096 Default Value: 1024 This value is the
164  * number of tx/rx descriptors allocated by the driver. Increasing this
165  * value allows the driver to queue more operations. Each descriptor is 16
166  * or 32 bytes (configurable in FVL)
167  */
168 #define DEFAULT_RING    1024
169 #define PERFORM_RING    2048
170 #define MAX_RING        4096
171 #define MIN_RING        32
172
173 /*
174 ** Default number of entries in Tx queue buf_ring.
175 */
176 #define SMALL_TXBRSZ 4096
177 /* This may require mbuf cluster tuning */
178 #define DEFAULT_TXBRSZ (SMALL_TXBRSZ * SMALL_TXBRSZ)
179
180 /* Alignment for rings */
181 #define DBA_ALIGN       128
182
183 /*
184  * This parameter controls the maximum no of times the driver will loop in
185  * the isr. Minimum Value = 1
186  */
187 #define MAX_LOOP        10
188
189 /*
190  * This is the max watchdog interval, ie. the time that can
191  * pass between any two TX clean operations, such only happening
192  * when the TX hardware is functioning.
193  */
194 #define IXL_WATCHDOG                   (10 * hz)
195
196 /*
197  * This parameters control when the driver calls the routine to reclaim
198  * transmit descriptors.
199  */
200 #define IXL_TX_CLEANUP_THRESHOLD        (que->num_desc / 8)
201 #define IXL_TX_OP_THRESHOLD             (que->num_desc / 32)
202
203 /* Flow control constants */
204 #define IXL_FC_PAUSE            0xFFFF
205 #define IXL_FC_HI               0x20000
206 #define IXL_FC_LO               0x10000
207
208 #define MAX_MULTICAST_ADDR      128
209
210 #define IXL_BAR                 3
211 #define IXL_ADM_LIMIT           2
212 #define IXL_TSO_SIZE            65535
213 #define IXL_TX_BUF_SZ           ((u32) 1514)
214 #define IXL_AQ_BUF_SZ           ((u32) 4096)
215 #define IXL_RX_HDR              128
216 /* Controls the length of the Admin Queue */
217 #define IXL_AQ_LEN              256
218 #define IXL_AQ_LEN_MAX          1024
219 #define IXL_AQ_BUFSZ            4096
220 #define IXL_RX_LIMIT            512
221 #define IXL_RX_ITR              0
222 #define IXL_TX_ITR              1
223 #define IXL_ITR_NONE            3
224 #define IXL_QUEUE_EOL           0x7FF
225 #define IXL_MAX_FRAME           0x2600
226 #define IXL_MAX_TX_SEGS         8
227 #define IXL_MAX_TSO_SEGS        66 
228 #define IXL_SPARSE_CHAIN        6
229 #define IXL_QUEUE_HUNG          0x80000000
230 #define IXL_KEYSZ               10
231
232 #define IXL_VF_MAX_BUFFER       0x3F80
233 #define IXL_VF_MAX_HDR_BUFFER   0x840
234 #define IXL_VF_MAX_FRAME        0x3FFF
235
236 /* ERJ: hardware can support ~1.5k filters between all functions */
237 #define IXL_MAX_FILTERS 256
238 #define IXL_MAX_TX_BUSY 10
239
240 #define IXL_NVM_VERSION_LO_SHIFT        0
241 #define IXL_NVM_VERSION_LO_MASK         (0xff << IXL_NVM_VERSION_LO_SHIFT)
242 #define IXL_NVM_VERSION_HI_SHIFT        12
243 #define IXL_NVM_VERSION_HI_MASK         (0xf << IXL_NVM_VERSION_HI_SHIFT)
244
245
246 /*
247  * Interrupt Moderation parameters 
248  */
249 #define IXL_MAX_ITR             0x07FF
250 #define IXL_ITR_100K            0x0005
251 #define IXL_ITR_20K             0x0019
252 #define IXL_ITR_8K              0x003E
253 #define IXL_ITR_4K              0x007A
254 #define IXL_ITR_DYNAMIC         0x8000
255 #define IXL_LOW_LATENCY         0
256 #define IXL_AVE_LATENCY         1
257 #define IXL_BULK_LATENCY        2
258
259 /* MacVlan Flags */
260 #define IXL_FILTER_USED         (u16)(1 << 0)
261 #define IXL_FILTER_VLAN         (u16)(1 << 1)
262 #define IXL_FILTER_ADD          (u16)(1 << 2)
263 #define IXL_FILTER_DEL          (u16)(1 << 3)
264 #define IXL_FILTER_MC           (u16)(1 << 4)
265
266 /* used in the vlan field of the filter when not a vlan */
267 #define IXL_VLAN_ANY            -1
268
269 #define CSUM_OFFLOAD_IPV4       (CSUM_IP|CSUM_TCP|CSUM_UDP|CSUM_SCTP)
270 #define CSUM_OFFLOAD_IPV6       (CSUM_TCP_IPV6|CSUM_UDP_IPV6|CSUM_SCTP_IPV6)
271 #define CSUM_OFFLOAD            (CSUM_OFFLOAD_IPV4|CSUM_OFFLOAD_IPV6|CSUM_TSO)
272
273 /* Misc flags for ixl_vsi.flags */
274 #define IXL_FLAGS_KEEP_TSO4     (1 << 0)
275 #define IXL_FLAGS_KEEP_TSO6     (1 << 1)
276
277 #define IXL_VF_RESET_TIMEOUT    100
278
279 #define IXL_VSI_DATA_PORT       0x01
280
281 #define IXLV_MAX_QUEUES         16
282 #define IXL_MAX_VSI_QUEUES      (2 * (I40E_VSILAN_QTABLE_MAX_INDEX + 1))
283
284 #define IXL_RX_CTX_BASE_UNITS   128
285 #define IXL_TX_CTX_BASE_UNITS   128
286
287 #define IXL_VPINT_LNKLSTN_REG(hw, vector, vf_num) \
288         I40E_VPINT_LNKLSTN(((vector) - 1) + \
289             (((hw)->func_caps.num_msix_vectors_vf - 1) * (vf_num)))
290
291 #define IXL_VFINT_DYN_CTLN_REG(hw, vector, vf_num) \
292         I40E_VFINT_DYN_CTLN(((vector) - 1) + \
293             (((hw)->func_caps.num_msix_vectors_vf - 1) * (vf_num)))
294
295 #define IXL_PF_PCI_CIAA_VF_DEVICE_STATUS        0xAA
296
297 #define IXL_PF_PCI_CIAD_VF_TRANS_PENDING_MASK   0x20
298
299 #define IXL_GLGEN_VFLRSTAT_INDEX(glb_vf)        ((glb_vf) / 32)
300 #define IXL_GLGEN_VFLRSTAT_MASK(glb_vf) (1 << ((glb_vf) % 32))
301
302 #define IXL_MAX_ITR_IDX         3
303
304 #define IXL_END_OF_INTR_LNKLST  0x7FF
305
306 #define IXL_TX_LOCK(_sc)                mtx_lock(&(_sc)->mtx)
307 #define IXL_TX_UNLOCK(_sc)              mtx_unlock(&(_sc)->mtx)
308 #define IXL_TX_LOCK_DESTROY(_sc)        mtx_destroy(&(_sc)->mtx)
309 #define IXL_TX_TRYLOCK(_sc)             mtx_trylock(&(_sc)->mtx)
310 #define IXL_TX_LOCK_ASSERT(_sc)         mtx_assert(&(_sc)->mtx, MA_OWNED)
311
312 #define IXL_RX_LOCK(_sc)                mtx_lock(&(_sc)->mtx)
313 #define IXL_RX_UNLOCK(_sc)              mtx_unlock(&(_sc)->mtx)
314 #define IXL_RX_LOCK_DESTROY(_sc)        mtx_destroy(&(_sc)->mtx)
315
316 #if __FreeBSD_version >= 1100036
317 #define IXL_SET_IPACKETS(vsi, count)    (vsi)->ipackets = (count)
318 #define IXL_SET_IERRORS(vsi, count)     (vsi)->ierrors = (count)
319 #define IXL_SET_OPACKETS(vsi, count)    (vsi)->opackets = (count)
320 #define IXL_SET_OERRORS(vsi, count)     (vsi)->oerrors = (count)
321 #define IXL_SET_COLLISIONS(vsi, count)  /* Do nothing; collisions is always 0. */
322 #define IXL_SET_IBYTES(vsi, count)      (vsi)->ibytes = (count)
323 #define IXL_SET_OBYTES(vsi, count)      (vsi)->obytes = (count)
324 #define IXL_SET_IMCASTS(vsi, count)     (vsi)->imcasts = (count)
325 #define IXL_SET_OMCASTS(vsi, count)     (vsi)->omcasts = (count)
326 #define IXL_SET_IQDROPS(vsi, count)     (vsi)->iqdrops = (count)
327 #define IXL_SET_OQDROPS(vsi, count)     (vsi)->iqdrops = (count)
328 #define IXL_SET_NOPROTO(vsi, count)     (vsi)->noproto = (count)
329 #else
330 #define IXL_SET_IPACKETS(vsi, count)    (vsi)->ifp->if_ipackets = (count)
331 #define IXL_SET_IERRORS(vsi, count)     (vsi)->ifp->if_ierrors = (count)
332 #define IXL_SET_OPACKETS(vsi, count)    (vsi)->ifp->if_opackets = (count)
333 #define IXL_SET_OERRORS(vsi, count)     (vsi)->ifp->if_oerrors = (count)
334 #define IXL_SET_COLLISIONS(vsi, count)  (vsi)->ifp->if_collisions = (count)
335 #define IXL_SET_IBYTES(vsi, count)      (vsi)->ifp->if_ibytes = (count)
336 #define IXL_SET_OBYTES(vsi, count)      (vsi)->ifp->if_obytes = (count)
337 #define IXL_SET_IMCASTS(vsi, count)     (vsi)->ifp->if_imcasts = (count)
338 #define IXL_SET_OMCASTS(vsi, count)     (vsi)->ifp->if_omcasts = (count)
339 #define IXL_SET_IQDROPS(vsi, count)     (vsi)->ifp->if_iqdrops = (count)
340 #define IXL_SET_OQDROPS(vsi, odrops)    (vsi)->ifp->if_snd.ifq_drops = (odrops)
341 #define IXL_SET_NOPROTO(vsi, count)     (vsi)->noproto = (count)
342 #endif
343
344 /*
345  *****************************************************************************
346  * vendor_info_array
347  * 
348  * This array contains the list of Subvendor/Subdevice IDs on which the driver
349  * should load.
350  * 
351  *****************************************************************************
352  */
353 typedef struct _ixl_vendor_info_t {
354         unsigned int    vendor_id;
355         unsigned int    device_id;
356         unsigned int    subvendor_id;
357         unsigned int    subdevice_id;
358         unsigned int    index;
359 } ixl_vendor_info_t;
360
361
362 struct ixl_tx_buf {
363         u32             eop_index;
364         struct mbuf     *m_head;
365         bus_dmamap_t    map;
366         bus_dma_tag_t   tag;
367 };
368
369 struct ixl_rx_buf {
370         struct mbuf     *m_head;
371         struct mbuf     *m_pack;
372         struct mbuf     *fmp;
373         bus_dmamap_t    hmap;
374         bus_dmamap_t    pmap;
375 };
376
377 /*
378 ** This struct has multiple uses, multicast
379 ** addresses, vlans, and mac filters all use it.
380 */
381 struct ixl_mac_filter {
382         SLIST_ENTRY(ixl_mac_filter) next;
383         u8      macaddr[ETHER_ADDR_LEN];
384         s16     vlan;
385         u16     flags;
386 };
387
388
389 /*
390  * The Transmit ring control struct
391  */
392 struct tx_ring {
393         struct ixl_queue        *que;
394         struct mtx              mtx;
395         u32                     tail;
396         struct i40e_tx_desc     *base;
397         struct i40e_dma_mem     dma;
398         u16                     next_avail;
399         u16                     next_to_clean;
400         u16                     atr_rate;
401         u16                     atr_count;
402         u16                     itr;
403         u16                     latency;
404         struct ixl_tx_buf       *buffers;
405         volatile u16            avail;
406         u32                     cmd;
407         bus_dma_tag_t           tx_tag;
408         bus_dma_tag_t           tso_tag;
409         char                    mtx_name[16];
410         struct buf_ring         *br;
411
412         /* Used for Dynamic ITR calculation */
413         u32                     packets;
414         u32                     bytes;
415
416         /* Soft Stats */
417         u64                     tx_bytes;
418         u64                     no_desc;
419         u64                     total_packets;
420 };
421
422
423 /*
424  * The Receive ring control struct
425  */
426 struct rx_ring {
427         struct ixl_queue        *que;
428         struct mtx              mtx;
429         union i40e_rx_desc      *base;
430         struct i40e_dma_mem     dma;
431         struct lro_ctrl         lro;
432         bool                    lro_enabled;
433         bool                    hdr_split;
434         bool                    discard;
435         u16                     next_refresh;
436         u16                     next_check;
437         u16                     itr;
438         u16                     latency;
439         char                    mtx_name[16];
440         struct ixl_rx_buf       *buffers;
441         u32                     mbuf_sz;
442         u32                     tail;
443         bus_dma_tag_t           htag;
444         bus_dma_tag_t           ptag;
445
446         /* Used for Dynamic ITR calculation */
447         u32                     packets;
448         u32                     bytes;
449
450         /* Soft stats */
451         u64                     split;
452         u64                     rx_packets;
453         u64                     rx_bytes;
454         u64                     discarded;
455         u64                     not_done;
456 };
457
458 /*
459 ** Driver queue struct: this is the interrupt container
460 **  for the associated tx and rx ring pair.
461 */
462 struct ixl_queue {
463         struct ixl_vsi          *vsi;
464         u32                     me;
465         u32                     msix;           /* This queue's MSIX vector */
466         u32                     eims;           /* This queue's EIMS bit */
467         struct resource         *res;
468         void                    *tag;
469         int                     num_desc;       /* both tx and rx */
470         int                     busy;
471         struct tx_ring          txr;
472         struct rx_ring          rxr;
473         struct task             task;
474         struct task             tx_task;
475         struct taskqueue        *tq;
476
477         /* Queue stats */
478         u64                     irqs;
479         u64                     tso;
480         u64                     mbuf_defrag_failed;
481         u64                     mbuf_hdr_failed;
482         u64                     mbuf_pkt_failed;
483         u64                     tx_map_avail;
484         u64                     tx_dma_setup;
485         u64                     dropped_pkts;
486 };
487
488 /*
489 ** Virtual Station interface: 
490 **      there would be one of these per traffic class/type
491 **      for now just one, and its embedded in the pf
492 */
493 SLIST_HEAD(ixl_ftl_head, ixl_mac_filter);
494 struct ixl_vsi {
495         void                    *back;
496         struct ifnet            *ifp;
497         struct device           *dev;
498         struct i40e_hw          *hw;
499         struct ifmedia          media;
500         u64                     que_mask;
501         int                     id;
502         u16                     vsi_num;
503         u16                     msix_base;      /* station base MSIX vector */
504         u16                     first_queue;
505         u16                     num_queues;
506         u16                     rx_itr_setting;
507         u16                     tx_itr_setting;
508         struct ixl_queue        *queues;        /* head of queues */
509         bool                    link_active;
510         u16                     seid;
511         u16                     uplink_seid;
512         u16                     downlink_seid;
513         u16                     max_frame_size;
514
515         /* MAC/VLAN Filter list */
516         struct ixl_ftl_head ftl;
517         u16                     num_macs;
518
519         struct i40e_aqc_vsi_properties_data info;
520
521         eventhandler_tag        vlan_attach;
522         eventhandler_tag        vlan_detach;
523         u16                     num_vlans;
524
525         /* Per-VSI stats from hardware */
526         struct i40e_eth_stats   eth_stats;
527         struct i40e_eth_stats   eth_stats_offsets;
528         bool                    stat_offsets_loaded;
529         /* VSI stat counters */
530         u64                     ipackets;
531         u64                     ierrors;
532         u64                     opackets;
533         u64                     oerrors;
534         u64                     ibytes;
535         u64                     obytes;
536         u64                     imcasts;
537         u64                     omcasts;
538         u64                     iqdrops;
539         u64                     oqdrops;
540         u64                     noproto;
541
542         /* Driver statistics */
543         u64                     hw_filters_del;
544         u64                     hw_filters_add;
545
546         /* Misc. */
547         u64                     active_queues;
548         u64                     flags;
549         struct sysctl_oid       *vsi_node;
550 };
551
552 /*
553 ** Find the number of unrefreshed RX descriptors
554 */
555 static inline u16
556 ixl_rx_unrefreshed(struct ixl_queue *que)
557 {       
558         struct rx_ring  *rxr = &que->rxr;
559         
560         if (rxr->next_check > rxr->next_refresh)
561                 return (rxr->next_check - rxr->next_refresh - 1);
562         else
563                 return ((que->num_desc + rxr->next_check) -
564                     rxr->next_refresh - 1);
565 }       
566
567 /*
568 ** Find the next available unused filter
569 */
570 static inline struct ixl_mac_filter *
571 ixl_get_filter(struct ixl_vsi *vsi)
572 {
573         struct ixl_mac_filter  *f;
574
575         /* create a new empty filter */
576         f = malloc(sizeof(struct ixl_mac_filter),
577             M_DEVBUF, M_NOWAIT | M_ZERO);
578         if (f)
579                 SLIST_INSERT_HEAD(&vsi->ftl, f, next);
580
581         return (f);
582 }
583
584 /*
585 ** Compare two ethernet addresses
586 */
587 static inline bool
588 cmp_etheraddr(const u8 *ea1, const u8 *ea2)
589 {       
590         bool cmp = FALSE;
591
592         if ((ea1[0] == ea2[0]) && (ea1[1] == ea2[1]) &&
593             (ea1[2] == ea2[2]) && (ea1[3] == ea2[3]) &&
594             (ea1[4] == ea2[4]) && (ea1[5] == ea2[5])) 
595                 cmp = TRUE;
596
597         return (cmp);
598 }       
599
600 /*
601  * Info for stats sysctls
602  */
603 struct ixl_sysctl_info {
604         u64     *stat;
605         char    *name;
606         char    *description;
607 };
608
609 extern int ixl_atr_rate;
610
611 /*
612 ** ixl_fw_version_str - format the FW and NVM version strings
613 */
614 static inline char *
615 ixl_fw_version_str(struct i40e_hw *hw)
616 {
617         static char buf[32];
618
619         snprintf(buf, sizeof(buf),
620             "f%d.%d a%d.%d n%02x.%02x e%08x",
621             hw->aq.fw_maj_ver, hw->aq.fw_min_ver,
622             hw->aq.api_maj_ver, hw->aq.api_min_ver,
623             (hw->nvm.version & IXL_NVM_VERSION_HI_MASK) >>
624             IXL_NVM_VERSION_HI_SHIFT,
625             (hw->nvm.version & IXL_NVM_VERSION_LO_MASK) >>
626             IXL_NVM_VERSION_LO_SHIFT,
627             hw->nvm.eetrack);
628         return buf;
629 }
630
631 /*********************************************************************
632  *  TXRX Function prototypes
633  *********************************************************************/
634 int     ixl_allocate_tx_data(struct ixl_queue *);
635 int     ixl_allocate_rx_data(struct ixl_queue *);
636 void    ixl_init_tx_ring(struct ixl_queue *);
637 int     ixl_init_rx_ring(struct ixl_queue *);
638 bool    ixl_rxeof(struct ixl_queue *, int);
639 bool    ixl_txeof(struct ixl_queue *);
640 int     ixl_mq_start(struct ifnet *, struct mbuf *);
641 int     ixl_mq_start_locked(struct ifnet *, struct tx_ring *);
642 void    ixl_deferred_mq_start(void *, int);
643 void    ixl_qflush(struct ifnet *);
644 void    ixl_free_vsi(struct ixl_vsi *);
645 void    ixl_free_que_tx(struct ixl_queue *);
646 void    ixl_free_que_rx(struct ixl_queue *);
647 #ifdef IXL_FDIR
648 void    ixl_atr(struct ixl_queue *, struct tcphdr *, int);
649 #endif
650 #if __FreeBSD_version >= 1100000
651 uint64_t ixl_get_counter(if_t ifp, ift_counter cnt);
652 #endif
653
654 #endif /* _IXL_H_ */