xref: /freebsd/sys/dev/ixl/ixl.h (revision 8ef24a0d4b28fe230e20637f56869cc4148cd2ca)
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 <sys/sbuf.h>
92 #include <machine/smp.h>
93 
94 #ifdef PCI_IOV
95 #include <sys/nv.h>
96 #include <sys/iov_schema.h>
97 #include <dev/pci/pci_iov.h>
98 #endif
99 
100 #include "i40e_type.h"
101 #include "i40e_prototype.h"
102 
103 #if defined(IXL_DEBUG) || defined(IXL_DEBUG_SYSCTL)
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.
166  *
167  * Tx descriptors are always 16 bytes, but Rx descriptors can be 32 bytes.
168  * The driver currently always uses 32 byte Rx descriptors.
169  */
170 #define DEFAULT_RING	1024
171 #define PERFORM_RING	2048
172 #define MAX_RING	4096
173 #define MIN_RING	32
174 
175 /*
176 ** Default number of entries in Tx queue buf_ring.
177 */
178 #define SMALL_TXBRSZ 4096
179 /* This may require mbuf cluster tuning */
180 #define DEFAULT_TXBRSZ (SMALL_TXBRSZ * SMALL_TXBRSZ)
181 
182 /* Alignment for rings */
183 #define DBA_ALIGN	128
184 
185 /*
186  * This is the max watchdog interval, ie. the time that can
187  * pass between any two TX clean operations, such only happening
188  * when the TX hardware is functioning.
189  */
190 #define IXL_WATCHDOG                   (10 * hz)
191 
192 /*
193  * This parameters control when the driver calls the routine to reclaim
194  * transmit descriptors.
195  */
196 #define IXL_TX_CLEANUP_THRESHOLD	(que->num_desc / 8)
197 #define IXL_TX_OP_THRESHOLD		(que->num_desc / 32)
198 
199 /* Flow control constants */
200 #define IXL_FC_PAUSE		0xFFFF
201 #define IXL_FC_HI		0x20000
202 #define IXL_FC_LO		0x10000
203 
204 #define MAX_MULTICAST_ADDR	128
205 
206 #define IXL_BAR			3
207 #define IXL_ADM_LIMIT		2
208 #define IXL_TSO_SIZE		65535
209 #define IXL_AQ_BUF_SZ		((u32) 4096)
210 #define IXL_RX_HDR		128
211 /* Controls the length of the Admin Queue */
212 #define IXL_AQ_LEN		256
213 #define IXL_AQ_LEN_MAX		1024
214 #define IXL_AQ_BUFSZ		4096
215 #define IXL_RX_LIMIT		512
216 #define IXL_RX_ITR		0
217 #define IXL_TX_ITR		1
218 #define IXL_ITR_NONE		3
219 #define IXL_QUEUE_EOL		0x7FF
220 #define IXL_MAX_FRAME		9728
221 #define IXL_MAX_TX_SEGS		8
222 #define IXL_MAX_TSO_SEGS	66
223 #define IXL_SPARSE_CHAIN	6
224 #define IXL_QUEUE_HUNG		0x80000000
225 #define IXL_KEYSZ		10
226 
227 #define IXL_VF_MAX_BUFFER	0x3F80
228 #define IXL_VF_MAX_HDR_BUFFER	0x840
229 #define IXL_VF_MAX_FRAME	0x3FFF
230 
231 /* ERJ: hardware can support ~1.5k filters between all functions */
232 #define IXL_MAX_FILTERS	256
233 #define IXL_MAX_TX_BUSY	10
234 
235 #define IXL_NVM_VERSION_LO_SHIFT	0
236 #define IXL_NVM_VERSION_LO_MASK		(0xff << IXL_NVM_VERSION_LO_SHIFT)
237 #define IXL_NVM_VERSION_HI_SHIFT	12
238 #define IXL_NVM_VERSION_HI_MASK		(0xf << IXL_NVM_VERSION_HI_SHIFT)
239 
240 
241 /*
242  * Interrupt Moderation parameters
243  */
244 #define IXL_MAX_ITR		0x07FF
245 #define IXL_ITR_100K		0x0005
246 #define IXL_ITR_20K		0x0019
247 #define IXL_ITR_8K		0x003E
248 #define IXL_ITR_4K		0x007A
249 #define IXL_ITR_DYNAMIC		0x8000
250 #define IXL_LOW_LATENCY		0
251 #define IXL_AVE_LATENCY		1
252 #define IXL_BULK_LATENCY	2
253 
254 /* MacVlan Flags */
255 #define IXL_FILTER_USED		(u16)(1 << 0)
256 #define IXL_FILTER_VLAN		(u16)(1 << 1)
257 #define IXL_FILTER_ADD		(u16)(1 << 2)
258 #define IXL_FILTER_DEL		(u16)(1 << 3)
259 #define IXL_FILTER_MC		(u16)(1 << 4)
260 
261 /* used in the vlan field of the filter when not a vlan */
262 #define IXL_VLAN_ANY		-1
263 
264 #define CSUM_OFFLOAD_IPV4	(CSUM_IP|CSUM_TCP|CSUM_UDP|CSUM_SCTP)
265 #define CSUM_OFFLOAD_IPV6	(CSUM_TCP_IPV6|CSUM_UDP_IPV6|CSUM_SCTP_IPV6)
266 #define CSUM_OFFLOAD		(CSUM_OFFLOAD_IPV4|CSUM_OFFLOAD_IPV6|CSUM_TSO)
267 
268 /* Misc flags for ixl_vsi.flags */
269 #define IXL_FLAGS_KEEP_TSO4	(1 << 0)
270 #define IXL_FLAGS_KEEP_TSO6	(1 << 1)
271 
272 #define IXL_VF_RESET_TIMEOUT	100
273 
274 #define IXL_VSI_DATA_PORT	0x01
275 
276 #define IXLV_MAX_QUEUES		16
277 #define IXL_MAX_VSI_QUEUES	(2 * (I40E_VSILAN_QTABLE_MAX_INDEX + 1))
278 
279 #define IXL_RX_CTX_BASE_UNITS	128
280 #define IXL_TX_CTX_BASE_UNITS	128
281 
282 #define IXL_VPINT_LNKLSTN_REG(hw, vector, vf_num) \
283 	I40E_VPINT_LNKLSTN(((vector) - 1) + \
284 	    (((hw)->func_caps.num_msix_vectors_vf - 1) * (vf_num)))
285 
286 #define IXL_VFINT_DYN_CTLN_REG(hw, vector, vf_num) \
287 	I40E_VFINT_DYN_CTLN(((vector) - 1) + \
288 	    (((hw)->func_caps.num_msix_vectors_vf - 1) * (vf_num)))
289 
290 #define IXL_PF_PCI_CIAA_VF_DEVICE_STATUS	0xAA
291 
292 #define IXL_PF_PCI_CIAD_VF_TRANS_PENDING_MASK	0x20
293 
294 #define IXL_GLGEN_VFLRSTAT_INDEX(glb_vf)	((glb_vf) / 32)
295 #define IXL_GLGEN_VFLRSTAT_MASK(glb_vf)	(1 << ((glb_vf) % 32))
296 
297 #define IXL_MAX_ITR_IDX		3
298 
299 #define IXL_END_OF_INTR_LNKLST	0x7FF
300 
301 #define IXL_TX_LOCK(_sc)                mtx_lock(&(_sc)->mtx)
302 #define IXL_TX_UNLOCK(_sc)              mtx_unlock(&(_sc)->mtx)
303 #define IXL_TX_LOCK_DESTROY(_sc)        mtx_destroy(&(_sc)->mtx)
304 #define IXL_TX_TRYLOCK(_sc)             mtx_trylock(&(_sc)->mtx)
305 #define IXL_TX_LOCK_ASSERT(_sc)         mtx_assert(&(_sc)->mtx, MA_OWNED)
306 
307 #define IXL_RX_LOCK(_sc)                mtx_lock(&(_sc)->mtx)
308 #define IXL_RX_UNLOCK(_sc)              mtx_unlock(&(_sc)->mtx)
309 #define IXL_RX_LOCK_DESTROY(_sc)        mtx_destroy(&(_sc)->mtx)
310 
311 /* Pre-11 counter(9) compatibility */
312 #if __FreeBSD_version >= 1100036
313 #define IXL_SET_IPACKETS(vsi, count)	(vsi)->ipackets = (count)
314 #define IXL_SET_IERRORS(vsi, count)	(vsi)->ierrors = (count)
315 #define IXL_SET_OPACKETS(vsi, count)	(vsi)->opackets = (count)
316 #define IXL_SET_OERRORS(vsi, count)	(vsi)->oerrors = (count)
317 #define IXL_SET_COLLISIONS(vsi, count)	/* Do nothing; collisions is always 0. */
318 #define IXL_SET_IBYTES(vsi, count)	(vsi)->ibytes = (count)
319 #define IXL_SET_OBYTES(vsi, count)	(vsi)->obytes = (count)
320 #define IXL_SET_IMCASTS(vsi, count)	(vsi)->imcasts = (count)
321 #define IXL_SET_OMCASTS(vsi, count)	(vsi)->omcasts = (count)
322 #define IXL_SET_IQDROPS(vsi, count)	(vsi)->iqdrops = (count)
323 #define IXL_SET_OQDROPS(vsi, count)	(vsi)->oqdrops = (count)
324 #define IXL_SET_NOPROTO(vsi, count)	(vsi)->noproto = (count)
325 #else
326 #define IXL_SET_IPACKETS(vsi, count)	(vsi)->ifp->if_ipackets = (count)
327 #define IXL_SET_IERRORS(vsi, count)	(vsi)->ifp->if_ierrors = (count)
328 #define IXL_SET_OPACKETS(vsi, count)	(vsi)->ifp->if_opackets = (count)
329 #define IXL_SET_OERRORS(vsi, count)	(vsi)->ifp->if_oerrors = (count)
330 #define IXL_SET_COLLISIONS(vsi, count)	(vsi)->ifp->if_collisions = (count)
331 #define IXL_SET_IBYTES(vsi, count)	(vsi)->ifp->if_ibytes = (count)
332 #define IXL_SET_OBYTES(vsi, count)	(vsi)->ifp->if_obytes = (count)
333 #define IXL_SET_IMCASTS(vsi, count)	(vsi)->ifp->if_imcasts = (count)
334 #define IXL_SET_OMCASTS(vsi, count)	(vsi)->ifp->if_omcasts = (count)
335 #define IXL_SET_IQDROPS(vsi, count)	(vsi)->ifp->if_iqdrops = (count)
336 #define IXL_SET_OQDROPS(vsi, odrops)	(vsi)->ifp->if_snd.ifq_drops = (odrops)
337 #define IXL_SET_NOPROTO(vsi, count)	(vsi)->noproto = (count)
338 #endif
339 
340 /* Pre-10.2 media type compatibility */
341 #if __FreeBSD_version < 1002000
342 #define IFM_OTHER	IFM_UNKNOWN
343 #endif
344 
345 /*
346  *****************************************************************************
347  * vendor_info_array
348  *
349  * This array contains the list of Subvendor/Subdevice IDs on which the driver
350  * should load.
351  *
352  *****************************************************************************
353  */
354 typedef struct _ixl_vendor_info_t {
355 	unsigned int    vendor_id;
356 	unsigned int    device_id;
357 	unsigned int    subvendor_id;
358 	unsigned int    subdevice_id;
359 	unsigned int    index;
360 } ixl_vendor_info_t;
361 
362 
363 struct ixl_tx_buf {
364 	u32		eop_index;
365 	struct mbuf	*m_head;
366 	bus_dmamap_t	map;
367 	bus_dma_tag_t	tag;
368 };
369 
370 struct ixl_rx_buf {
371 	struct mbuf	*m_head;
372 	struct mbuf	*m_pack;
373 	struct mbuf	*fmp;
374 	bus_dmamap_t	hmap;
375 	bus_dmamap_t	pmap;
376 };
377 
378 /*
379 ** This struct has multiple uses, multicast
380 ** addresses, vlans, and mac filters all use it.
381 */
382 struct ixl_mac_filter {
383 	SLIST_ENTRY(ixl_mac_filter) next;
384 	u8	macaddr[ETHER_ADDR_LEN];
385 	s16	vlan;
386 	u16	flags;
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 	u32			itr;
403 	u32			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         u32			next_refresh;
436         u32 			next_check;
437 	u32			itr;
438 	u32			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 			desc_errs;
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 	enum i40e_vsi_type	type;
501 	u64			que_mask;
502 	int			id;
503 	u16			vsi_num;
504 	u16			msix_base;	/* station base MSIX vector */
505 	u16			first_queue;
506 	u16			num_queues;
507 	u32			rx_itr_setting;
508 	u32			tx_itr_setting;
509 	struct ixl_queue	*queues;	/* head of queues */
510 	bool			link_active;
511 	u16			seid;
512 	u16			uplink_seid;
513 	u16			downlink_seid;
514 	u16			max_frame_size;
515 	u16			rss_table_size;
516 	u16			rss_size;
517 
518 	/* MAC/VLAN Filter list */
519 	struct ixl_ftl_head	ftl;
520 	u16			num_macs;
521 
522 	struct i40e_aqc_vsi_properties_data info;
523 
524 	eventhandler_tag 	vlan_attach;
525 	eventhandler_tag 	vlan_detach;
526 	u16			num_vlans;
527 
528 	/* Per-VSI stats from hardware */
529 	struct i40e_eth_stats	eth_stats;
530 	struct i40e_eth_stats	eth_stats_offsets;
531 	bool 			stat_offsets_loaded;
532 	/* VSI stat counters */
533 	u64			ipackets;
534 	u64			ierrors;
535 	u64			opackets;
536 	u64			oerrors;
537 	u64			ibytes;
538 	u64			obytes;
539 	u64			imcasts;
540 	u64			omcasts;
541 	u64			iqdrops;
542 	u64			oqdrops;
543 	u64			noproto;
544 
545 	/* Driver statistics */
546 	u64			hw_filters_del;
547 	u64			hw_filters_add;
548 
549 	/* Misc. */
550 	u64 			active_queues;
551 	u64 			flags;
552 	struct sysctl_oid	*vsi_node;
553 };
554 
555 /*
556 ** Find the number of unrefreshed RX descriptors
557 */
558 static inline u16
559 ixl_rx_unrefreshed(struct ixl_queue *que)
560 {
561         struct rx_ring	*rxr = &que->rxr;
562 
563 	if (rxr->next_check > rxr->next_refresh)
564 		return (rxr->next_check - rxr->next_refresh - 1);
565 	else
566 		return ((que->num_desc + rxr->next_check) -
567 		    rxr->next_refresh - 1);
568 }
569 
570 /*
571 ** Find the next available unused filter
572 */
573 static inline struct ixl_mac_filter *
574 ixl_get_filter(struct ixl_vsi *vsi)
575 {
576 	struct ixl_mac_filter  *f;
577 
578 	/* create a new empty filter */
579 	f = malloc(sizeof(struct ixl_mac_filter),
580 	    M_DEVBUF, M_NOWAIT | M_ZERO);
581 	if (f)
582 		SLIST_INSERT_HEAD(&vsi->ftl, f, next);
583 
584 	return (f);
585 }
586 
587 /*
588 ** Compare two ethernet addresses
589 */
590 static inline bool
591 cmp_etheraddr(const u8 *ea1, const u8 *ea2)
592 {
593 	bool cmp = FALSE;
594 
595 	if ((ea1[0] == ea2[0]) && (ea1[1] == ea2[1]) &&
596 	    (ea1[2] == ea2[2]) && (ea1[3] == ea2[3]) &&
597 	    (ea1[4] == ea2[4]) && (ea1[5] == ea2[5]))
598 		cmp = TRUE;
599 
600 	return (cmp);
601 }
602 
603 /*
604  * Info for stats sysctls
605  */
606 struct ixl_sysctl_info {
607 	u64	*stat;
608 	char	*name;
609 	char	*description;
610 };
611 
612 extern int ixl_atr_rate;
613 
614 /*********************************************************************
615  *  TXRX Function prototypes
616  *********************************************************************/
617 int	ixl_allocate_tx_data(struct ixl_queue *);
618 int	ixl_allocate_rx_data(struct ixl_queue *);
619 void	ixl_init_tx_ring(struct ixl_queue *);
620 int	ixl_init_rx_ring(struct ixl_queue *);
621 bool	ixl_rxeof(struct ixl_queue *, int);
622 bool	ixl_txeof(struct ixl_queue *);
623 int	ixl_mq_start(struct ifnet *, struct mbuf *);
624 int	ixl_mq_start_locked(struct ifnet *, struct tx_ring *);
625 void	ixl_deferred_mq_start(void *, int);
626 void	ixl_qflush(struct ifnet *);
627 void	ixl_free_vsi(struct ixl_vsi *);
628 void	ixl_free_que_tx(struct ixl_queue *);
629 void	ixl_free_que_rx(struct ixl_queue *);
630 #ifdef IXL_FDIR
631 void	ixl_atr(struct ixl_queue *, struct tcphdr *, int);
632 #endif
633 #if __FreeBSD_version >= 1100000
634 uint64_t ixl_get_counter(if_t ifp, ift_counter cnt);
635 #endif
636 
637 #endif /* _IXL_H_ */
638