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