162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Copyright 2008 Cisco Systems, Inc.  All rights reserved.
462306a36Sopenharmony_ci * Copyright 2007 Nuova Systems, Inc.  All rights reserved.
562306a36Sopenharmony_ci */
662306a36Sopenharmony_ci#ifndef _VNIC_NIC_H_
762306a36Sopenharmony_ci#define _VNIC_NIC_H_
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci/*
1062306a36Sopenharmony_ci * These defines avoid symbol clash between fnic and enic (Cisco 10G Eth
1162306a36Sopenharmony_ci * Driver) when both are built with CONFIG options =y
1262306a36Sopenharmony_ci */
1362306a36Sopenharmony_ci#define vnic_set_nic_cfg fnic_set_nic_cfg
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci#define NIC_CFG_RSS_DEFAULT_CPU_MASK_FIELD	0xffUL
1662306a36Sopenharmony_ci#define NIC_CFG_RSS_DEFAULT_CPU_SHIFT		0
1762306a36Sopenharmony_ci#define NIC_CFG_RSS_HASH_TYPE			(0xffUL << 8)
1862306a36Sopenharmony_ci#define NIC_CFG_RSS_HASH_TYPE_MASK_FIELD	0xffUL
1962306a36Sopenharmony_ci#define NIC_CFG_RSS_HASH_TYPE_SHIFT		8
2062306a36Sopenharmony_ci#define NIC_CFG_RSS_HASH_BITS			(7UL << 16)
2162306a36Sopenharmony_ci#define NIC_CFG_RSS_HASH_BITS_MASK_FIELD	7UL
2262306a36Sopenharmony_ci#define NIC_CFG_RSS_HASH_BITS_SHIFT		16
2362306a36Sopenharmony_ci#define NIC_CFG_RSS_BASE_CPU			(7UL << 19)
2462306a36Sopenharmony_ci#define NIC_CFG_RSS_BASE_CPU_MASK_FIELD		7UL
2562306a36Sopenharmony_ci#define NIC_CFG_RSS_BASE_CPU_SHIFT		19
2662306a36Sopenharmony_ci#define NIC_CFG_RSS_ENABLE			(1UL << 22)
2762306a36Sopenharmony_ci#define NIC_CFG_RSS_ENABLE_MASK_FIELD		1UL
2862306a36Sopenharmony_ci#define NIC_CFG_RSS_ENABLE_SHIFT		22
2962306a36Sopenharmony_ci#define NIC_CFG_TSO_IPID_SPLIT_EN		(1UL << 23)
3062306a36Sopenharmony_ci#define NIC_CFG_TSO_IPID_SPLIT_EN_MASK_FIELD	1UL
3162306a36Sopenharmony_ci#define NIC_CFG_TSO_IPID_SPLIT_EN_SHIFT		23
3262306a36Sopenharmony_ci#define NIC_CFG_IG_VLAN_STRIP_EN		(1UL << 24)
3362306a36Sopenharmony_ci#define NIC_CFG_IG_VLAN_STRIP_EN_MASK_FIELD	1UL
3462306a36Sopenharmony_ci#define NIC_CFG_IG_VLAN_STRIP_EN_SHIFT		24
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_cistatic inline void vnic_set_nic_cfg(u32 *nic_cfg,
3762306a36Sopenharmony_ci	u8 rss_default_cpu, u8 rss_hash_type,
3862306a36Sopenharmony_ci	u8 rss_hash_bits, u8 rss_base_cpu,
3962306a36Sopenharmony_ci	u8 rss_enable, u8 tso_ipid_split_en,
4062306a36Sopenharmony_ci	u8 ig_vlan_strip_en)
4162306a36Sopenharmony_ci{
4262306a36Sopenharmony_ci	*nic_cfg = (rss_default_cpu & NIC_CFG_RSS_DEFAULT_CPU_MASK_FIELD) |
4362306a36Sopenharmony_ci		((rss_hash_type & NIC_CFG_RSS_HASH_TYPE_MASK_FIELD)
4462306a36Sopenharmony_ci			<< NIC_CFG_RSS_HASH_TYPE_SHIFT) |
4562306a36Sopenharmony_ci		((rss_hash_bits & NIC_CFG_RSS_HASH_BITS_MASK_FIELD)
4662306a36Sopenharmony_ci			<< NIC_CFG_RSS_HASH_BITS_SHIFT) |
4762306a36Sopenharmony_ci		((rss_base_cpu & NIC_CFG_RSS_BASE_CPU_MASK_FIELD)
4862306a36Sopenharmony_ci			<< NIC_CFG_RSS_BASE_CPU_SHIFT) |
4962306a36Sopenharmony_ci		((rss_enable & NIC_CFG_RSS_ENABLE_MASK_FIELD)
5062306a36Sopenharmony_ci			<< NIC_CFG_RSS_ENABLE_SHIFT) |
5162306a36Sopenharmony_ci		((tso_ipid_split_en & NIC_CFG_TSO_IPID_SPLIT_EN_MASK_FIELD)
5262306a36Sopenharmony_ci			<< NIC_CFG_TSO_IPID_SPLIT_EN_SHIFT) |
5362306a36Sopenharmony_ci		((ig_vlan_strip_en & NIC_CFG_IG_VLAN_STRIP_EN_MASK_FIELD)
5462306a36Sopenharmony_ci			<< NIC_CFG_IG_VLAN_STRIP_EN_SHIFT);
5562306a36Sopenharmony_ci}
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ci#endif /* _VNIC_NIC_H_ */
58