1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun * Copyright 2008 Cisco Systems, Inc. All rights reserved.
3*4882a593Smuzhiyun * Copyright 2007 Nuova Systems, Inc. All rights reserved.
4*4882a593Smuzhiyun *
5*4882a593Smuzhiyun * This program is free software; you may redistribute it and/or modify
6*4882a593Smuzhiyun * it under the terms of the GNU General Public License as published by
7*4882a593Smuzhiyun * the Free Software Foundation; version 2 of the License.
8*4882a593Smuzhiyun *
9*4882a593Smuzhiyun * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
10*4882a593Smuzhiyun * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
11*4882a593Smuzhiyun * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
12*4882a593Smuzhiyun * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
13*4882a593Smuzhiyun * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
14*4882a593Smuzhiyun * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
15*4882a593Smuzhiyun * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
16*4882a593Smuzhiyun * SOFTWARE.
17*4882a593Smuzhiyun */
18*4882a593Smuzhiyun #ifndef _VNIC_NIC_H_
19*4882a593Smuzhiyun #define _VNIC_NIC_H_
20*4882a593Smuzhiyun
21*4882a593Smuzhiyun /*
22*4882a593Smuzhiyun * These defines avoid symbol clash between fnic and enic (Cisco 10G Eth
23*4882a593Smuzhiyun * Driver) when both are built with CONFIG options =y
24*4882a593Smuzhiyun */
25*4882a593Smuzhiyun #define vnic_set_nic_cfg fnic_set_nic_cfg
26*4882a593Smuzhiyun
27*4882a593Smuzhiyun #define NIC_CFG_RSS_DEFAULT_CPU_MASK_FIELD 0xffUL
28*4882a593Smuzhiyun #define NIC_CFG_RSS_DEFAULT_CPU_SHIFT 0
29*4882a593Smuzhiyun #define NIC_CFG_RSS_HASH_TYPE (0xffUL << 8)
30*4882a593Smuzhiyun #define NIC_CFG_RSS_HASH_TYPE_MASK_FIELD 0xffUL
31*4882a593Smuzhiyun #define NIC_CFG_RSS_HASH_TYPE_SHIFT 8
32*4882a593Smuzhiyun #define NIC_CFG_RSS_HASH_BITS (7UL << 16)
33*4882a593Smuzhiyun #define NIC_CFG_RSS_HASH_BITS_MASK_FIELD 7UL
34*4882a593Smuzhiyun #define NIC_CFG_RSS_HASH_BITS_SHIFT 16
35*4882a593Smuzhiyun #define NIC_CFG_RSS_BASE_CPU (7UL << 19)
36*4882a593Smuzhiyun #define NIC_CFG_RSS_BASE_CPU_MASK_FIELD 7UL
37*4882a593Smuzhiyun #define NIC_CFG_RSS_BASE_CPU_SHIFT 19
38*4882a593Smuzhiyun #define NIC_CFG_RSS_ENABLE (1UL << 22)
39*4882a593Smuzhiyun #define NIC_CFG_RSS_ENABLE_MASK_FIELD 1UL
40*4882a593Smuzhiyun #define NIC_CFG_RSS_ENABLE_SHIFT 22
41*4882a593Smuzhiyun #define NIC_CFG_TSO_IPID_SPLIT_EN (1UL << 23)
42*4882a593Smuzhiyun #define NIC_CFG_TSO_IPID_SPLIT_EN_MASK_FIELD 1UL
43*4882a593Smuzhiyun #define NIC_CFG_TSO_IPID_SPLIT_EN_SHIFT 23
44*4882a593Smuzhiyun #define NIC_CFG_IG_VLAN_STRIP_EN (1UL << 24)
45*4882a593Smuzhiyun #define NIC_CFG_IG_VLAN_STRIP_EN_MASK_FIELD 1UL
46*4882a593Smuzhiyun #define NIC_CFG_IG_VLAN_STRIP_EN_SHIFT 24
47*4882a593Smuzhiyun
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)48*4882a593Smuzhiyun static inline void vnic_set_nic_cfg(u32 *nic_cfg,
49*4882a593Smuzhiyun u8 rss_default_cpu, u8 rss_hash_type,
50*4882a593Smuzhiyun u8 rss_hash_bits, u8 rss_base_cpu,
51*4882a593Smuzhiyun u8 rss_enable, u8 tso_ipid_split_en,
52*4882a593Smuzhiyun u8 ig_vlan_strip_en)
53*4882a593Smuzhiyun {
54*4882a593Smuzhiyun *nic_cfg = (rss_default_cpu & NIC_CFG_RSS_DEFAULT_CPU_MASK_FIELD) |
55*4882a593Smuzhiyun ((rss_hash_type & NIC_CFG_RSS_HASH_TYPE_MASK_FIELD)
56*4882a593Smuzhiyun << NIC_CFG_RSS_HASH_TYPE_SHIFT) |
57*4882a593Smuzhiyun ((rss_hash_bits & NIC_CFG_RSS_HASH_BITS_MASK_FIELD)
58*4882a593Smuzhiyun << NIC_CFG_RSS_HASH_BITS_SHIFT) |
59*4882a593Smuzhiyun ((rss_base_cpu & NIC_CFG_RSS_BASE_CPU_MASK_FIELD)
60*4882a593Smuzhiyun << NIC_CFG_RSS_BASE_CPU_SHIFT) |
61*4882a593Smuzhiyun ((rss_enable & NIC_CFG_RSS_ENABLE_MASK_FIELD)
62*4882a593Smuzhiyun << NIC_CFG_RSS_ENABLE_SHIFT) |
63*4882a593Smuzhiyun ((tso_ipid_split_en & NIC_CFG_TSO_IPID_SPLIT_EN_MASK_FIELD)
64*4882a593Smuzhiyun << NIC_CFG_TSO_IPID_SPLIT_EN_SHIFT) |
65*4882a593Smuzhiyun ((ig_vlan_strip_en & NIC_CFG_IG_VLAN_STRIP_EN_MASK_FIELD)
66*4882a593Smuzhiyun << NIC_CFG_IG_VLAN_STRIP_EN_SHIFT);
67*4882a593Smuzhiyun }
68*4882a593Smuzhiyun
69*4882a593Smuzhiyun #endif /* _VNIC_NIC_H_ */
70