xref: /freebsd/sys/dev/enic/vnic_nic.h (revision 9c067b844f85a224f0416e6eb46ba3ef82aec5c4)
1*9c067b84SDoug Ambrisko /* SPDX-License-Identifier: BSD-3-Clause
2*9c067b84SDoug Ambrisko  * Copyright 2008-2017 Cisco Systems, Inc.  All rights reserved.
3*9c067b84SDoug Ambrisko  * Copyright 2007 Nuova Systems, Inc.  All rights reserved.
4*9c067b84SDoug Ambrisko  */
5*9c067b84SDoug Ambrisko 
6*9c067b84SDoug Ambrisko #ifndef _VNIC_NIC_H_
7*9c067b84SDoug Ambrisko #define _VNIC_NIC_H_
8*9c067b84SDoug Ambrisko 
9*9c067b84SDoug Ambrisko #define NIC_CFG_RSS_DEFAULT_CPU_MASK_FIELD	0xffUL
10*9c067b84SDoug Ambrisko #define NIC_CFG_RSS_DEFAULT_CPU_SHIFT		0
11*9c067b84SDoug Ambrisko #define NIC_CFG_RSS_HASH_TYPE			(0xffUL << 8)
12*9c067b84SDoug Ambrisko #define NIC_CFG_RSS_HASH_TYPE_MASK_FIELD	0xffUL
13*9c067b84SDoug Ambrisko #define NIC_CFG_RSS_HASH_TYPE_SHIFT		8
14*9c067b84SDoug Ambrisko #define NIC_CFG_RSS_HASH_BITS			(7UL << 16)
15*9c067b84SDoug Ambrisko #define NIC_CFG_RSS_HASH_BITS_MASK_FIELD	7UL
16*9c067b84SDoug Ambrisko #define NIC_CFG_RSS_HASH_BITS_SHIFT		16
17*9c067b84SDoug Ambrisko #define NIC_CFG_RSS_BASE_CPU			(7UL << 19)
18*9c067b84SDoug Ambrisko #define NIC_CFG_RSS_BASE_CPU_MASK_FIELD		7UL
19*9c067b84SDoug Ambrisko #define NIC_CFG_RSS_BASE_CPU_SHIFT		19
20*9c067b84SDoug Ambrisko #define NIC_CFG_RSS_ENABLE			(1UL << 22)
21*9c067b84SDoug Ambrisko #define NIC_CFG_RSS_ENABLE_MASK_FIELD		1UL
22*9c067b84SDoug Ambrisko #define NIC_CFG_RSS_ENABLE_SHIFT		22
23*9c067b84SDoug Ambrisko #define NIC_CFG_TSO_IPID_SPLIT_EN		(1UL << 23)
24*9c067b84SDoug Ambrisko #define NIC_CFG_TSO_IPID_SPLIT_EN_MASK_FIELD	1UL
25*9c067b84SDoug Ambrisko #define NIC_CFG_TSO_IPID_SPLIT_EN_SHIFT		23
26*9c067b84SDoug Ambrisko #define NIC_CFG_IG_VLAN_STRIP_EN		(1UL << 24)
27*9c067b84SDoug Ambrisko #define NIC_CFG_IG_VLAN_STRIP_EN_MASK_FIELD	1UL
28*9c067b84SDoug Ambrisko #define NIC_CFG_IG_VLAN_STRIP_EN_SHIFT		24
29*9c067b84SDoug Ambrisko 
30*9c067b84SDoug Ambrisko #define NIC_CFG_RSS_HASH_TYPE_UDP_IPV4		(1 << 0)
31*9c067b84SDoug Ambrisko #define NIC_CFG_RSS_HASH_TYPE_IPV4		(1 << 1)
32*9c067b84SDoug Ambrisko #define NIC_CFG_RSS_HASH_TYPE_TCP_IPV4		(1 << 2)
33*9c067b84SDoug Ambrisko #define NIC_CFG_RSS_HASH_TYPE_IPV6		(1 << 3)
34*9c067b84SDoug Ambrisko #define NIC_CFG_RSS_HASH_TYPE_TCP_IPV6		(1 << 4)
35*9c067b84SDoug Ambrisko #define NIC_CFG_RSS_HASH_TYPE_RSVD1		(1 << 5)
36*9c067b84SDoug Ambrisko #define NIC_CFG_RSS_HASH_TYPE_RSVD2		(1 << 6)
37*9c067b84SDoug Ambrisko #define NIC_CFG_RSS_HASH_TYPE_UDP_IPV6		(1 << 7)
38*9c067b84SDoug Ambrisko 
vnic_set_nic_cfg(u32 * nic_cfg,u8 rss_default_cpu,u8 rss_hash_type,u8 rss_hash_bits,u8 rss_base_cpu,u8 rss_enable,u8 tso_ipid_split_en,u8 ig_vlan_strip_en)39*9c067b84SDoug Ambrisko static inline void vnic_set_nic_cfg(u32 *nic_cfg,
40*9c067b84SDoug Ambrisko 	u8 rss_default_cpu, u8 rss_hash_type,
41*9c067b84SDoug Ambrisko 	u8 rss_hash_bits, u8 rss_base_cpu,
42*9c067b84SDoug Ambrisko 	u8 rss_enable, u8 tso_ipid_split_en,
43*9c067b84SDoug Ambrisko 	u8 ig_vlan_strip_en)
44*9c067b84SDoug Ambrisko {
45*9c067b84SDoug Ambrisko 	*nic_cfg = (rss_default_cpu & NIC_CFG_RSS_DEFAULT_CPU_MASK_FIELD) |
46*9c067b84SDoug Ambrisko 		((rss_hash_type & NIC_CFG_RSS_HASH_TYPE_MASK_FIELD)
47*9c067b84SDoug Ambrisko 		    << NIC_CFG_RSS_HASH_TYPE_SHIFT) |
48*9c067b84SDoug Ambrisko 		((rss_hash_bits & NIC_CFG_RSS_HASH_BITS_MASK_FIELD)
49*9c067b84SDoug Ambrisko 		    << NIC_CFG_RSS_HASH_BITS_SHIFT) |
50*9c067b84SDoug Ambrisko 		((rss_base_cpu & NIC_CFG_RSS_BASE_CPU_MASK_FIELD)
51*9c067b84SDoug Ambrisko 		    << NIC_CFG_RSS_BASE_CPU_SHIFT) |
52*9c067b84SDoug Ambrisko 		((rss_enable & NIC_CFG_RSS_ENABLE_MASK_FIELD)
53*9c067b84SDoug Ambrisko 		    << NIC_CFG_RSS_ENABLE_SHIFT) |
54*9c067b84SDoug Ambrisko 		((tso_ipid_split_en & NIC_CFG_TSO_IPID_SPLIT_EN_MASK_FIELD)
55*9c067b84SDoug Ambrisko 		    << NIC_CFG_TSO_IPID_SPLIT_EN_SHIFT) |
56*9c067b84SDoug Ambrisko 		((ig_vlan_strip_en & NIC_CFG_IG_VLAN_STRIP_EN_MASK_FIELD)
57*9c067b84SDoug Ambrisko 		    << NIC_CFG_IG_VLAN_STRIP_EN_SHIFT);
58*9c067b84SDoug Ambrisko }
59*9c067b84SDoug Ambrisko 
60*9c067b84SDoug Ambrisko #endif /* _VNIC_NIC_H_ */
61