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