xref: /freebsd/sys/dev/hyperv/netvsc/if_hnvar.h (revision 289ba6b870f79d8dbd9e8022c4fa23469be11a73)
1127d6d1aSSepherosa Ziehau /*-
293b4e111SSepherosa Ziehau  * Copyright (c) 2016-2017 Microsoft Corp.
3127d6d1aSSepherosa Ziehau  * All rights reserved.
4127d6d1aSSepherosa Ziehau  *
5127d6d1aSSepherosa Ziehau  * Redistribution and use in source and binary forms, with or without
6127d6d1aSSepherosa Ziehau  * modification, are permitted provided that the following conditions
7127d6d1aSSepherosa Ziehau  * are met:
8127d6d1aSSepherosa Ziehau  * 1. Redistributions of source code must retain the above copyright
9127d6d1aSSepherosa Ziehau  *    notice unmodified, this list of conditions, and the following
10127d6d1aSSepherosa Ziehau  *    disclaimer.
11127d6d1aSSepherosa Ziehau  * 2. Redistributions in binary form must reproduce the above copyright
12127d6d1aSSepherosa Ziehau  *    notice, this list of conditions and the following disclaimer in the
13127d6d1aSSepherosa Ziehau  *    documentation and/or other materials provided with the distribution.
14127d6d1aSSepherosa Ziehau  *
15127d6d1aSSepherosa Ziehau  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16127d6d1aSSepherosa Ziehau  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17127d6d1aSSepherosa Ziehau  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18127d6d1aSSepherosa Ziehau  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19127d6d1aSSepherosa Ziehau  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20127d6d1aSSepherosa Ziehau  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21127d6d1aSSepherosa Ziehau  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22127d6d1aSSepherosa Ziehau  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23127d6d1aSSepherosa Ziehau  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24127d6d1aSSepherosa Ziehau  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25127d6d1aSSepherosa Ziehau  */
26127d6d1aSSepherosa Ziehau 
27127d6d1aSSepherosa Ziehau #ifndef _IF_HNVAR_H_
28127d6d1aSSepherosa Ziehau #define _IF_HNVAR_H_
29127d6d1aSSepherosa Ziehau 
3019b2340aSSepherosa Ziehau #define HN_USE_TXDESC_BUFRING
315ac4acb2SSepherosa Ziehau 
3219b2340aSSepherosa Ziehau #define HN_CHIM_SIZE			(15 * 1024 * 1024)
33127d6d1aSSepherosa Ziehau 
34a491581fSWei Hu #define HN_RXBUF_SIZE			(31 * 1024 * 1024)
3519b2340aSSepherosa Ziehau #define HN_RXBUF_SIZE_COMPAT		(15 * 1024 * 1024)
3619b2340aSSepherosa Ziehau 
37d74831eeSSepherosa Ziehau #define HN_MTU_MAX			(65535 - ETHER_ADDR_LEN)
3819b2340aSSepherosa Ziehau 
3919b2340aSSepherosa Ziehau #define HN_TXBR_SIZE			(128 * PAGE_SIZE)
4019b2340aSSepherosa Ziehau #define HN_RXBR_SIZE			(128 * PAGE_SIZE)
4119b2340aSSepherosa Ziehau 
4219b2340aSSepherosa Ziehau #define HN_XACT_REQ_PGCNT		2
4319b2340aSSepherosa Ziehau #define HN_XACT_RESP_PGCNT		2
4419b2340aSSepherosa Ziehau #define HN_XACT_REQ_SIZE		(HN_XACT_REQ_PGCNT * PAGE_SIZE)
4519b2340aSSepherosa Ziehau #define HN_XACT_RESP_SIZE		(HN_XACT_RESP_PGCNT * PAGE_SIZE)
4619b2340aSSepherosa Ziehau 
4719b2340aSSepherosa Ziehau #define HN_GPACNT_MAX			32
48127d6d1aSSepherosa Ziehau 
4919b2340aSSepherosa Ziehau struct hn_txdesc;
5019b2340aSSepherosa Ziehau #ifndef HN_USE_TXDESC_BUFRING
5119b2340aSSepherosa Ziehau SLIST_HEAD(hn_txdesc_list, hn_txdesc);
5219b2340aSSepherosa Ziehau #else
5319b2340aSSepherosa Ziehau struct buf_ring;
5419b2340aSSepherosa Ziehau #endif
5519b2340aSSepherosa Ziehau struct hn_tx_ring;
5619b2340aSSepherosa Ziehau 
57a491581fSWei Hu #define	HN_NVS_RSC_MAX		562	/* Max RSC frags in one vmbus packet */
58a491581fSWei Hu 
59a491581fSWei Hu struct hn_rx_rsc {
60a491581fSWei Hu 	const uint32_t		*vlan_info;
61a491581fSWei Hu 	const uint32_t		*csum_info;
62a491581fSWei Hu 	const uint32_t		*hash_info;
63a491581fSWei Hu 	const uint32_t		*hash_value;
64a491581fSWei Hu 	uint32_t		cnt;		/* fragment count */
65a491581fSWei Hu 	uint32_t		pktlen;		/* full packet length */
66a491581fSWei Hu 	uint8_t			is_last;	/* last fragment */
67a491581fSWei Hu 	const void		*frag_data[HN_NVS_RSC_MAX];
68a491581fSWei Hu 	uint32_t		frag_len[HN_NVS_RSC_MAX];
69a491581fSWei Hu };
70a491581fSWei Hu 
7119b2340aSSepherosa Ziehau struct hn_rx_ring {
724db5958aSJustin Hibbits 	if_t		hn_ifp;
734db5958aSJustin Hibbits 	if_t		hn_rxvf_ifp;	/* SR-IOV VF for RX */
7419b2340aSSepherosa Ziehau 	struct hn_tx_ring *hn_txr;
7519b2340aSSepherosa Ziehau 	void		*hn_pktbuf;
768ff20a73SSepherosa Ziehau 	int		hn_pktbuf_len;
77a97fff19SSepherosa Ziehau 	int		hn_rx_flags;	/* HN_RX_FLAG_ */
78642ec226SSepherosa Ziehau 	uint32_t	hn_mbuf_hash;	/* NDIS_HASH_ */
7919b2340aSSepherosa Ziehau 	uint8_t		*hn_rxbuf;	/* shadow sc->hn_rxbuf */
8019b2340aSSepherosa Ziehau 	int		hn_rx_idx;
81a491581fSWei Hu 	struct hn_rx_rsc rsc;
8219b2340aSSepherosa Ziehau 
8319b2340aSSepherosa Ziehau 	/* Trust csum verification on host side */
8419b2340aSSepherosa Ziehau 	int		hn_trust_hcsum;	/* HN_TRUST_HCSUM_ */
8519b2340aSSepherosa Ziehau 	struct lro_ctrl	hn_lro;
8619b2340aSSepherosa Ziehau 
8719b2340aSSepherosa Ziehau 	u_long		hn_csum_ip;
8819b2340aSSepherosa Ziehau 	u_long		hn_csum_tcp;
8919b2340aSSepherosa Ziehau 	u_long		hn_csum_udp;
9019b2340aSSepherosa Ziehau 	u_long		hn_csum_trusted;
9119b2340aSSepherosa Ziehau 	u_long		hn_lro_tried;
9219b2340aSSepherosa Ziehau 	u_long		hn_small_pkts;
9319b2340aSSepherosa Ziehau 	u_long		hn_pkts;
9419b2340aSSepherosa Ziehau 	u_long		hn_rss_pkts;
957ccc20daSSepherosa Ziehau 	u_long		hn_ack_failed;
96a491581fSWei Hu 	u_long		hn_rsc_pkts;
97a491581fSWei Hu 	u_long		hn_rsc_drop;
9819b2340aSSepherosa Ziehau 
9919b2340aSSepherosa Ziehau 	/* Rarely used stuffs */
10019b2340aSSepherosa Ziehau 	struct sysctl_oid *hn_rx_sysctl_tree;
10119b2340aSSepherosa Ziehau 
10219b2340aSSepherosa Ziehau 	void		*hn_br;		/* TX/RX bufring */
1033ab0fea1SDexuan Cui 
1043ab0fea1SDexuan Cui 	struct vmbus_channel *hn_chan;
10519b2340aSSepherosa Ziehau } __aligned(CACHE_LINE_SIZE);
10619b2340aSSepherosa Ziehau 
10719b2340aSSepherosa Ziehau #define HN_TRUST_HCSUM_IP	0x0001
10819b2340aSSepherosa Ziehau #define HN_TRUST_HCSUM_TCP	0x0002
10919b2340aSSepherosa Ziehau #define HN_TRUST_HCSUM_UDP	0x0004
11019b2340aSSepherosa Ziehau 
1112494d735SSepherosa Ziehau #define HN_RX_FLAG_ATTACHED	0x0001
1122494d735SSepherosa Ziehau #define HN_RX_FLAG_BR_REF	0x0002
113a97fff19SSepherosa Ziehau #define HN_RX_FLAG_XPNT_VF	0x0004
114db76829bSSepherosa Ziehau #define HN_RX_FLAG_UDP_HASH	0x0008
11519b2340aSSepherosa Ziehau 
11619b2340aSSepherosa Ziehau struct hn_tx_ring {
11719b2340aSSepherosa Ziehau #ifndef HN_USE_TXDESC_BUFRING
11819b2340aSSepherosa Ziehau 	struct mtx	hn_txlist_spin;
11919b2340aSSepherosa Ziehau 	struct hn_txdesc_list hn_txlist;
12019b2340aSSepherosa Ziehau #else
12119b2340aSSepherosa Ziehau 	struct buf_ring	*hn_txdesc_br;
12219b2340aSSepherosa Ziehau #endif
12319b2340aSSepherosa Ziehau 	int		hn_txdesc_cnt;
12419b2340aSSepherosa Ziehau 	int		hn_txdesc_avail;
12519b2340aSSepherosa Ziehau 	u_short		hn_has_txeof;
12619b2340aSSepherosa Ziehau 	u_short		hn_txdone_cnt;
12719b2340aSSepherosa Ziehau 
12819b2340aSSepherosa Ziehau 	int		hn_sched_tx;
12919b2340aSSepherosa Ziehau 	void		(*hn_txeof)(struct hn_tx_ring *);
13019b2340aSSepherosa Ziehau 	struct taskqueue *hn_tx_taskq;
13119b2340aSSepherosa Ziehau 	struct task	hn_tx_task;
13219b2340aSSepherosa Ziehau 	struct task	hn_txeof_task;
13319b2340aSSepherosa Ziehau 
13419b2340aSSepherosa Ziehau 	struct buf_ring	*hn_mbuf_br;
13519b2340aSSepherosa Ziehau 	int		hn_oactive;
13619b2340aSSepherosa Ziehau 	int		hn_tx_idx;
13719b2340aSSepherosa Ziehau 	int		hn_tx_flags;
13819b2340aSSepherosa Ziehau 
13919b2340aSSepherosa Ziehau 	struct mtx	hn_tx_lock;
14019b2340aSSepherosa Ziehau 	struct hn_softc	*hn_sc;
14119b2340aSSepherosa Ziehau 	struct vmbus_channel *hn_chan;
14219b2340aSSepherosa Ziehau 
14319b2340aSSepherosa Ziehau 	int		hn_direct_tx_size;
14419b2340aSSepherosa Ziehau 	int		hn_chim_size;
14519b2340aSSepherosa Ziehau 	bus_dma_tag_t	hn_tx_data_dtag;
14619b2340aSSepherosa Ziehau 	uint64_t	hn_csum_assist;
14719b2340aSSepherosa Ziehau 
148dc13fee6SSepherosa Ziehau 	/* Applied packet transmission aggregation limits. */
149dc13fee6SSepherosa Ziehau 	int		hn_agg_szmax;
150dc13fee6SSepherosa Ziehau 	short		hn_agg_pktmax;
151dc13fee6SSepherosa Ziehau 	short		hn_agg_align;
152dc13fee6SSepherosa Ziehau 
153dc13fee6SSepherosa Ziehau 	/* Packet transmission aggregation states. */
154dc13fee6SSepherosa Ziehau 	struct hn_txdesc *hn_agg_txd;
155dc13fee6SSepherosa Ziehau 	int		hn_agg_szleft;
156dc13fee6SSepherosa Ziehau 	short		hn_agg_pktleft;
157dc13fee6SSepherosa Ziehau 	struct rndis_packet_msg *hn_agg_prevpkt;
158dc13fee6SSepherosa Ziehau 
159dc13fee6SSepherosa Ziehau 	/* Temporary stats for each sends. */
160dc13fee6SSepherosa Ziehau 	int		hn_stat_size;
161dc13fee6SSepherosa Ziehau 	short		hn_stat_pkts;
162dc13fee6SSepherosa Ziehau 	short		hn_stat_mcasts;
163dc13fee6SSepherosa Ziehau 
16419b2340aSSepherosa Ziehau 	int		(*hn_sendpkt)(struct hn_tx_ring *, struct hn_txdesc *);
16519b2340aSSepherosa Ziehau 	int		hn_suspended;
16619b2340aSSepherosa Ziehau 	int		hn_gpa_cnt;
16719b2340aSSepherosa Ziehau 	struct vmbus_gpa hn_gpa[HN_GPACNT_MAX];
16819b2340aSSepherosa Ziehau 
16919b2340aSSepherosa Ziehau 	u_long		hn_no_txdescs;
17019b2340aSSepherosa Ziehau 	u_long		hn_send_failed;
17119b2340aSSepherosa Ziehau 	u_long		hn_txdma_failed;
17219b2340aSSepherosa Ziehau 	u_long		hn_tx_collapsed;
17319b2340aSSepherosa Ziehau 	u_long		hn_tx_chimney_tried;
17419b2340aSSepherosa Ziehau 	u_long		hn_tx_chimney;
17519b2340aSSepherosa Ziehau 	u_long		hn_pkts;
176dc13fee6SSepherosa Ziehau 	u_long		hn_sends;
177dc13fee6SSepherosa Ziehau 	u_long		hn_flush_failed;
17819b2340aSSepherosa Ziehau 
17919b2340aSSepherosa Ziehau 	/* Rarely used stuffs */
18019b2340aSSepherosa Ziehau 	struct hn_txdesc *hn_txdesc;
18119b2340aSSepherosa Ziehau 	bus_dma_tag_t	hn_tx_rndis_dtag;
18219b2340aSSepherosa Ziehau 	struct sysctl_oid *hn_tx_sysctl_tree;
18319b2340aSSepherosa Ziehau } __aligned(CACHE_LINE_SIZE);
18419b2340aSSepherosa Ziehau 
1852494d735SSepherosa Ziehau #define HN_TX_FLAG_ATTACHED	0x0001
1862494d735SSepherosa Ziehau #define HN_TX_FLAG_HASHVAL	0x0002	/* support HASHVAL pktinfo */
18719b2340aSSepherosa Ziehau 
18819b2340aSSepherosa Ziehau /*
18919b2340aSSepherosa Ziehau  * Device-specific softc structure
19019b2340aSSepherosa Ziehau  */
19119b2340aSSepherosa Ziehau struct hn_softc {
1924db5958aSJustin Hibbits 	if_t		hn_ifp;
19319b2340aSSepherosa Ziehau 	struct ifmedia	hn_media;
19419b2340aSSepherosa Ziehau 	device_t        hn_dev;
19519b2340aSSepherosa Ziehau 	int             hn_if_flags;
19619b2340aSSepherosa Ziehau 	struct sx	hn_lock;
19719b2340aSSepherosa Ziehau 	struct vmbus_channel *hn_prichan;
19819b2340aSSepherosa Ziehau 
19919b2340aSSepherosa Ziehau 	int		hn_rx_ring_cnt;
20019b2340aSSepherosa Ziehau 	int		hn_rx_ring_inuse;
20119b2340aSSepherosa Ziehau 	struct hn_rx_ring *hn_rx_ring;
20219b2340aSSepherosa Ziehau 
2039c6cae24SSepherosa Ziehau 	struct rmlock	hn_vf_lock;
2044db5958aSJustin Hibbits 	if_t		hn_vf_ifp;	/* SR-IOV VF */
2059c6cae24SSepherosa Ziehau 	uint32_t	hn_xvf_flags;	/* transparent VF flags */
2069c6cae24SSepherosa Ziehau 
20719b2340aSSepherosa Ziehau 	int		hn_tx_ring_cnt;
20819b2340aSSepherosa Ziehau 	int		hn_tx_ring_inuse;
20919b2340aSSepherosa Ziehau 	struct hn_tx_ring *hn_tx_ring;
21019b2340aSSepherosa Ziehau 
21119b2340aSSepherosa Ziehau 	uint8_t		*hn_chim;
21219b2340aSSepherosa Ziehau 	u_long		*hn_chim_bmap;
21319b2340aSSepherosa Ziehau 	int		hn_chim_bmap_cnt;
21419b2340aSSepherosa Ziehau 	int		hn_chim_cnt;
21519b2340aSSepherosa Ziehau 	int		hn_chim_szmax;
21619b2340aSSepherosa Ziehau 
21719b2340aSSepherosa Ziehau 	int		hn_cpu;
218fdd0222aSSepherosa Ziehau 	struct taskqueue **hn_tx_taskqs;
21919b2340aSSepherosa Ziehau 	struct sysctl_oid *hn_tx_sysctl_tree;
22019b2340aSSepherosa Ziehau 	struct sysctl_oid *hn_rx_sysctl_tree;
22119b2340aSSepherosa Ziehau 	struct vmbus_xact_ctx *hn_xact;
22219b2340aSSepherosa Ziehau 	uint32_t	hn_nvs_ver;
22319b2340aSSepherosa Ziehau 	uint32_t	hn_rx_filter;
22419b2340aSSepherosa Ziehau 
225dc13fee6SSepherosa Ziehau 	/* Packet transmission aggregation user settings. */
226dc13fee6SSepherosa Ziehau 	int			hn_agg_size;
227dc13fee6SSepherosa Ziehau 	int			hn_agg_pkts;
228dc13fee6SSepherosa Ziehau 
22919b2340aSSepherosa Ziehau 	struct taskqueue	*hn_mgmt_taskq;
23019b2340aSSepherosa Ziehau 	struct taskqueue	*hn_mgmt_taskq0;
23119b2340aSSepherosa Ziehau 	struct task		hn_link_task;
23219b2340aSSepherosa Ziehau 	struct task		hn_netchg_init;
23319b2340aSSepherosa Ziehau 	struct timeout_task	hn_netchg_status;
23419b2340aSSepherosa Ziehau 	uint32_t		hn_link_flags;	/* HN_LINK_FLAG_ */
23519b2340aSSepherosa Ziehau 
23619b2340aSSepherosa Ziehau 	uint32_t		hn_caps;	/* HN_CAP_ */
23719b2340aSSepherosa Ziehau 	uint32_t		hn_flags;	/* HN_FLAG_ */
2386c1204dfSSepherosa Ziehau 	u_int			hn_pollhz;
2396c1204dfSSepherosa Ziehau 
24019b2340aSSepherosa Ziehau 	void			*hn_rxbuf;
24119b2340aSSepherosa Ziehau 	uint32_t		hn_rxbuf_gpadl;
24219b2340aSSepherosa Ziehau 
24319b2340aSSepherosa Ziehau 	uint32_t		hn_chim_gpadl;
24419b2340aSSepherosa Ziehau 
24519b2340aSSepherosa Ziehau 	uint32_t		hn_rndis_rid;
24619b2340aSSepherosa Ziehau 	uint32_t		hn_ndis_ver;
24719b2340aSSepherosa Ziehau 	int			hn_ndis_tso_szmax;
24819b2340aSSepherosa Ziehau 	int			hn_ndis_tso_sgmin;
249dc13fee6SSepherosa Ziehau 	uint32_t		hn_rndis_agg_size;
250dc13fee6SSepherosa Ziehau 	uint32_t		hn_rndis_agg_pkts;
251dc13fee6SSepherosa Ziehau 	uint32_t		hn_rndis_agg_align;
25219b2340aSSepherosa Ziehau 
25319b2340aSSepherosa Ziehau 	int			hn_rss_ind_size;
254642ec226SSepherosa Ziehau 	uint32_t		hn_rss_hash;	/* setting, NDIS_HASH_ */
255642ec226SSepherosa Ziehau 	uint32_t		hn_rss_hcap;	/* caps, NDIS_HASH_ */
25619b2340aSSepherosa Ziehau 	struct ndis_rssprm_toeplitz hn_rss;
2575bdfd3fdSDexuan Cui 
2585bdfd3fdSDexuan Cui 	eventhandler_tag	hn_ifaddr_evthand;
2595bdfd3fdSDexuan Cui 	eventhandler_tag	hn_ifnet_evthand;
260499c3e17SSepherosa Ziehau 	eventhandler_tag	hn_ifnet_atthand;
261499c3e17SSepherosa Ziehau 	eventhandler_tag	hn_ifnet_dethand;
2629c6cae24SSepherosa Ziehau 	eventhandler_tag	hn_ifnet_lnkhand;
2639c6cae24SSepherosa Ziehau 
2649c6cae24SSepherosa Ziehau 	/*
2659c6cae24SSepherosa Ziehau 	 * Transparent VF delayed initialization.
2669c6cae24SSepherosa Ziehau 	 */
2679c6cae24SSepherosa Ziehau 	int			hn_vf_rdytick;	/* ticks, 0 == ready */
2689c6cae24SSepherosa Ziehau 	struct taskqueue	*hn_vf_taskq;
2699c6cae24SSepherosa Ziehau 	struct timeout_task	hn_vf_init;
2709c6cae24SSepherosa Ziehau 
2719c6cae24SSepherosa Ziehau 	/*
2729c6cae24SSepherosa Ziehau 	 * Saved information for VF under transparent mode.
2739c6cae24SSepherosa Ziehau 	 */
2749c6cae24SSepherosa Ziehau 	void			(*hn_vf_input)
2754db5958aSJustin Hibbits 				(if_t, struct mbuf *);
2769c6cae24SSepherosa Ziehau 	int			hn_saved_caps;
2779c6cae24SSepherosa Ziehau 	u_int			hn_saved_tsomax;
2789c6cae24SSepherosa Ziehau 	u_int			hn_saved_tsosegcnt;
2799c6cae24SSepherosa Ziehau 	u_int			hn_saved_tsosegsz;
280*289ba6b8SWei Hu 	u_int			hn_saved_capenable;
281*289ba6b8SWei Hu 	u_int			hn_saved_hwassist;
28280c3eb7bSWei Hu 
28380c3eb7bSWei Hu 	/*
28480c3eb7bSWei Hu 	 * RSC switch, default off
28580c3eb7bSWei Hu 	 */
28680c3eb7bSWei Hu 	u_int			hn_rsc_ctrl;
28719b2340aSSepherosa Ziehau };
28819b2340aSSepherosa Ziehau 
28919b2340aSSepherosa Ziehau #define HN_FLAG_RXBUF_CONNECTED		0x0001
29019b2340aSSepherosa Ziehau #define HN_FLAG_CHIM_CONNECTED		0x0002
29119b2340aSSepherosa Ziehau #define HN_FLAG_HAS_RSSKEY		0x0004
29219b2340aSSepherosa Ziehau #define HN_FLAG_HAS_RSSIND		0x0008
29319b2340aSSepherosa Ziehau #define HN_FLAG_SYNTH_ATTACHED		0x0010
294fdc4f478SSepherosa Ziehau #define HN_FLAG_NO_SLEEPING		0x0020
2952494d735SSepherosa Ziehau #define HN_FLAG_RXBUF_REF		0x0040
2962494d735SSepherosa Ziehau #define HN_FLAG_CHIM_REF		0x0080
297962f0357SSepherosa Ziehau #define HN_FLAG_RXVF			0x0100
2982494d735SSepherosa Ziehau 
2992494d735SSepherosa Ziehau #define HN_FLAG_ERRORS			(HN_FLAG_RXBUF_REF | HN_FLAG_CHIM_REF)
300fdc4f478SSepherosa Ziehau 
3019c6cae24SSepherosa Ziehau #define HN_XVFFLAG_ENABLED		0x0001
3029c6cae24SSepherosa Ziehau #define HN_XVFFLAG_ACCBPF		0x0002
3039c6cae24SSepherosa Ziehau 
304fdc4f478SSepherosa Ziehau #define HN_NO_SLEEPING(sc)			\
305fdc4f478SSepherosa Ziehau do {						\
306fdc4f478SSepherosa Ziehau 	(sc)->hn_flags |= HN_FLAG_NO_SLEEPING;	\
307fdc4f478SSepherosa Ziehau } while (0)
308fdc4f478SSepherosa Ziehau 
309fdc4f478SSepherosa Ziehau #define HN_SLEEPING_OK(sc)			\
310fdc4f478SSepherosa Ziehau do {						\
311fdc4f478SSepherosa Ziehau 	(sc)->hn_flags &= ~HN_FLAG_NO_SLEEPING;	\
312fdc4f478SSepherosa Ziehau } while (0)
313fdc4f478SSepherosa Ziehau 
314fdc4f478SSepherosa Ziehau #define HN_CAN_SLEEP(sc)		\
315fdc4f478SSepherosa Ziehau 	(((sc)->hn_flags & HN_FLAG_NO_SLEEPING) == 0)
31619b2340aSSepherosa Ziehau 
31719b2340aSSepherosa Ziehau #define HN_CAP_VLAN			0x0001
31819b2340aSSepherosa Ziehau #define HN_CAP_MTU			0x0002
31919b2340aSSepherosa Ziehau #define HN_CAP_IPCS			0x0004
32019b2340aSSepherosa Ziehau #define HN_CAP_TCP4CS			0x0008
32119b2340aSSepherosa Ziehau #define HN_CAP_TCP6CS			0x0010
32219b2340aSSepherosa Ziehau #define HN_CAP_UDP4CS			0x0020
32319b2340aSSepherosa Ziehau #define HN_CAP_UDP6CS			0x0040
32419b2340aSSepherosa Ziehau #define HN_CAP_TSO4			0x0080
32519b2340aSSepherosa Ziehau #define HN_CAP_TSO6			0x0100
32619b2340aSSepherosa Ziehau #define HN_CAP_HASHVAL			0x0200
327db76829bSSepherosa Ziehau #define HN_CAP_UDPHASH			0x0400
32819b2340aSSepherosa Ziehau 
32919b2340aSSepherosa Ziehau /* Capability description for use with printf(9) %b identifier. */
33019b2340aSSepherosa Ziehau #define HN_CAP_BITS				\
33119b2340aSSepherosa Ziehau 	"\020\1VLAN\2MTU\3IPCS\4TCP4CS\5TCP6CS"	\
332db76829bSSepherosa Ziehau 	"\6UDP4CS\7UDP6CS\10TSO4\11TSO6\12HASHVAL\13UDPHASH"
33319b2340aSSepherosa Ziehau 
33419b2340aSSepherosa Ziehau #define HN_LINK_FLAG_LINKUP		0x0001
33519b2340aSSepherosa Ziehau #define HN_LINK_FLAG_NETCHG		0x0002
336127d6d1aSSepherosa Ziehau 
337127d6d1aSSepherosa Ziehau #endif	/* !_IF_HNVAR_H_ */
338