2 * Copyright 2008-2010 Cisco Systems, Inc. All rights reserved.
3 * Copyright 2007 Nuova Systems, Inc. All rights reserved.
5 * Copyright (c) 2014, Cisco Systems, Inc.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
38 #define NIC_CFG_RSS_DEFAULT_CPU_MASK_FIELD 0xffUL
39 #define NIC_CFG_RSS_DEFAULT_CPU_SHIFT 0
40 #define NIC_CFG_RSS_HASH_TYPE (0xffUL << 8)
41 #define NIC_CFG_RSS_HASH_TYPE_MASK_FIELD 0xffUL
42 #define NIC_CFG_RSS_HASH_TYPE_SHIFT 8
43 #define NIC_CFG_RSS_HASH_BITS (7UL << 16)
44 #define NIC_CFG_RSS_HASH_BITS_MASK_FIELD 7UL
45 #define NIC_CFG_RSS_HASH_BITS_SHIFT 16
46 #define NIC_CFG_RSS_BASE_CPU (7UL << 19)
47 #define NIC_CFG_RSS_BASE_CPU_MASK_FIELD 7UL
48 #define NIC_CFG_RSS_BASE_CPU_SHIFT 19
49 #define NIC_CFG_RSS_ENABLE (1UL << 22)
50 #define NIC_CFG_RSS_ENABLE_MASK_FIELD 1UL
51 #define NIC_CFG_RSS_ENABLE_SHIFT 22
52 #define NIC_CFG_TSO_IPID_SPLIT_EN (1UL << 23)
53 #define NIC_CFG_TSO_IPID_SPLIT_EN_MASK_FIELD 1UL
54 #define NIC_CFG_TSO_IPID_SPLIT_EN_SHIFT 23
55 #define NIC_CFG_IG_VLAN_STRIP_EN (1UL << 24)
56 #define NIC_CFG_IG_VLAN_STRIP_EN_MASK_FIELD 1UL
57 #define NIC_CFG_IG_VLAN_STRIP_EN_SHIFT 24
59 #define NIC_CFG_RSS_HASH_TYPE_IPV4 (1 << 1)
60 #define NIC_CFG_RSS_HASH_TYPE_TCP_IPV4 (1 << 2)
61 #define NIC_CFG_RSS_HASH_TYPE_IPV6 (1 << 3)
62 #define NIC_CFG_RSS_HASH_TYPE_TCP_IPV6 (1 << 4)
63 #define NIC_CFG_RSS_HASH_TYPE_IPV6_EX (1 << 5)
64 #define NIC_CFG_RSS_HASH_TYPE_TCP_IPV6_EX (1 << 6)
66 static inline void vnic_set_nic_cfg(u32 *nic_cfg,
67 u8 rss_default_cpu, u8 rss_hash_type,
68 u8 rss_hash_bits, u8 rss_base_cpu,
69 u8 rss_enable, u8 tso_ipid_split_en,
72 *nic_cfg = (rss_default_cpu & NIC_CFG_RSS_DEFAULT_CPU_MASK_FIELD) |
73 ((rss_hash_type & NIC_CFG_RSS_HASH_TYPE_MASK_FIELD)
74 << NIC_CFG_RSS_HASH_TYPE_SHIFT) |
75 ((rss_hash_bits & NIC_CFG_RSS_HASH_BITS_MASK_FIELD)
76 << NIC_CFG_RSS_HASH_BITS_SHIFT) |
77 ((rss_base_cpu & NIC_CFG_RSS_BASE_CPU_MASK_FIELD)
78 << NIC_CFG_RSS_BASE_CPU_SHIFT) |
79 ((rss_enable & NIC_CFG_RSS_ENABLE_MASK_FIELD)
80 << NIC_CFG_RSS_ENABLE_SHIFT) |
81 ((tso_ipid_split_en & NIC_CFG_TSO_IPID_SPLIT_EN_MASK_FIELD)
82 << NIC_CFG_TSO_IPID_SPLIT_EN_SHIFT) |
83 ((ig_vlan_strip_en & NIC_CFG_IG_VLAN_STRIP_EN_MASK_FIELD)
84 << NIC_CFG_IG_VLAN_STRIP_EN_SHIFT);
87 #endif /* _VNIC_NIC_H_ */