xref: /dpdk/drivers/net/enic/base/vnic_nic.h (revision 04e8ec74192ae4bc537e4854410551255bf85cf5)
12e99ea80SHyong Youb Kim /* SPDX-License-Identifier: BSD-3-Clause
22e99ea80SHyong Youb Kim  * Copyright 2008-2017 Cisco Systems, Inc.  All rights reserved.
372f3de30SBruce Richardson  * Copyright 2007 Nuova Systems, Inc.  All rights reserved.
472f3de30SBruce Richardson  */
572f3de30SBruce Richardson 
672f3de30SBruce Richardson #ifndef _VNIC_NIC_H_
772f3de30SBruce Richardson #define _VNIC_NIC_H_
872f3de30SBruce Richardson 
972f3de30SBruce Richardson #define NIC_CFG_RSS_DEFAULT_CPU_MASK_FIELD	0xffUL
1072f3de30SBruce Richardson #define NIC_CFG_RSS_DEFAULT_CPU_SHIFT		0
1172f3de30SBruce Richardson #define NIC_CFG_RSS_HASH_TYPE			(0xffUL << 8)
1272f3de30SBruce Richardson #define NIC_CFG_RSS_HASH_TYPE_MASK_FIELD	0xffUL
1372f3de30SBruce Richardson #define NIC_CFG_RSS_HASH_TYPE_SHIFT		8
1472f3de30SBruce Richardson #define NIC_CFG_RSS_HASH_BITS			(7UL << 16)
1572f3de30SBruce Richardson #define NIC_CFG_RSS_HASH_BITS_MASK_FIELD	7UL
1672f3de30SBruce Richardson #define NIC_CFG_RSS_HASH_BITS_SHIFT		16
1772f3de30SBruce Richardson #define NIC_CFG_RSS_BASE_CPU			(7UL << 19)
1872f3de30SBruce Richardson #define NIC_CFG_RSS_BASE_CPU_MASK_FIELD		7UL
1972f3de30SBruce Richardson #define NIC_CFG_RSS_BASE_CPU_SHIFT		19
2072f3de30SBruce Richardson #define NIC_CFG_RSS_ENABLE			(1UL << 22)
2172f3de30SBruce Richardson #define NIC_CFG_RSS_ENABLE_MASK_FIELD		1UL
2272f3de30SBruce Richardson #define NIC_CFG_RSS_ENABLE_SHIFT		22
2372f3de30SBruce Richardson #define NIC_CFG_TSO_IPID_SPLIT_EN		(1UL << 23)
2472f3de30SBruce Richardson #define NIC_CFG_TSO_IPID_SPLIT_EN_MASK_FIELD	1UL
2572f3de30SBruce Richardson #define NIC_CFG_TSO_IPID_SPLIT_EN_SHIFT		23
2672f3de30SBruce Richardson #define NIC_CFG_IG_VLAN_STRIP_EN		(1UL << 24)
2772f3de30SBruce Richardson #define NIC_CFG_IG_VLAN_STRIP_EN_MASK_FIELD	1UL
2872f3de30SBruce Richardson #define NIC_CFG_IG_VLAN_STRIP_EN_SHIFT		24
2972f3de30SBruce Richardson 
3094c35189SHyong Youb Kim #define NIC_CFG_RSS_HASH_TYPE_UDP_IPV4		(1 << 0)
3172f3de30SBruce Richardson #define NIC_CFG_RSS_HASH_TYPE_IPV4		(1 << 1)
3272f3de30SBruce Richardson #define NIC_CFG_RSS_HASH_TYPE_TCP_IPV4		(1 << 2)
3372f3de30SBruce Richardson #define NIC_CFG_RSS_HASH_TYPE_IPV6		(1 << 3)
3472f3de30SBruce Richardson #define NIC_CFG_RSS_HASH_TYPE_TCP_IPV6		(1 << 4)
355bc989e6SHyong Youb Kim #define NIC_CFG_RSS_HASH_TYPE_RSVD1		(1 << 5)
365bc989e6SHyong Youb Kim #define NIC_CFG_RSS_HASH_TYPE_RSVD2		(1 << 6)
3794c35189SHyong Youb Kim #define NIC_CFG_RSS_HASH_TYPE_UDP_IPV6		(1 << 7)
3872f3de30SBruce Richardson 
vnic_set_nic_cfg(uint32_t * nic_cfg,uint8_t rss_default_cpu,uint8_t rss_hash_type,uint8_t rss_hash_bits,uint8_t rss_base_cpu,uint8_t rss_enable,uint8_t tso_ipid_split_en,uint8_t ig_vlan_strip_en)39*04e8ec74SJohn Daley static inline void vnic_set_nic_cfg(uint32_t *nic_cfg,
40*04e8ec74SJohn Daley 	uint8_t rss_default_cpu, uint8_t rss_hash_type,
41*04e8ec74SJohn Daley 	uint8_t rss_hash_bits, uint8_t rss_base_cpu,
42*04e8ec74SJohn Daley 	uint8_t rss_enable, uint8_t tso_ipid_split_en,
43*04e8ec74SJohn Daley 	uint8_t ig_vlan_strip_en)
4472f3de30SBruce Richardson {
4572f3de30SBruce Richardson 	*nic_cfg = (rss_default_cpu & NIC_CFG_RSS_DEFAULT_CPU_MASK_FIELD) |
4672f3de30SBruce Richardson 		((rss_hash_type & NIC_CFG_RSS_HASH_TYPE_MASK_FIELD)
4772f3de30SBruce Richardson 			<< NIC_CFG_RSS_HASH_TYPE_SHIFT) |
4872f3de30SBruce Richardson 		((rss_hash_bits & NIC_CFG_RSS_HASH_BITS_MASK_FIELD)
4972f3de30SBruce Richardson 			<< NIC_CFG_RSS_HASH_BITS_SHIFT) |
5072f3de30SBruce Richardson 		((rss_base_cpu & NIC_CFG_RSS_BASE_CPU_MASK_FIELD)
5172f3de30SBruce Richardson 			<< NIC_CFG_RSS_BASE_CPU_SHIFT) |
5272f3de30SBruce Richardson 		((rss_enable & NIC_CFG_RSS_ENABLE_MASK_FIELD)
5372f3de30SBruce Richardson 			<< NIC_CFG_RSS_ENABLE_SHIFT) |
5472f3de30SBruce Richardson 		((tso_ipid_split_en & NIC_CFG_TSO_IPID_SPLIT_EN_MASK_FIELD)
5572f3de30SBruce Richardson 			<< NIC_CFG_TSO_IPID_SPLIT_EN_SHIFT) |
5672f3de30SBruce Richardson 		((ig_vlan_strip_en & NIC_CFG_IG_VLAN_STRIP_EN_MASK_FIELD)
5772f3de30SBruce Richardson 			<< NIC_CFG_IG_VLAN_STRIP_EN_SHIFT);
5872f3de30SBruce Richardson }
5972f3de30SBruce Richardson 
6072f3de30SBruce Richardson #endif /* _VNIC_NIC_H_ */
61