This source file includes following definitions.
- bnxt_tc_flower_enabled
- bnxt_tc_setup_flower
- bnxt_init_tc
- bnxt_shutdown_tc
- bnxt_tc_flow_stats_work
- bnxt_tc_flower_enabled
1
2
3
4
5
6
7
8
9
10 #ifndef BNXT_TC_H
11 #define BNXT_TC_H
12
13 #ifdef CONFIG_BNXT_FLOWER_OFFLOAD
14
15 #include <net/ip_tunnels.h>
16
17
18
19 struct bnxt_tc_l2_key {
20 u8 dmac[ETH_ALEN];
21 u8 smac[ETH_ALEN];
22 __be16 inner_vlan_tpid;
23 __be16 inner_vlan_tci;
24 __be16 ether_type;
25 u8 num_vlans;
26 u8 dir;
27 #define BNXT_DIR_RX 1
28 #define BNXT_DIR_TX 0
29 };
30
31 struct bnxt_tc_l3_key {
32 union {
33 struct {
34 struct in_addr daddr;
35 struct in_addr saddr;
36 } ipv4;
37 struct {
38 struct in6_addr daddr;
39 struct in6_addr saddr;
40 } ipv6;
41 };
42 };
43
44 struct bnxt_tc_l4_key {
45 u8 ip_proto;
46 union {
47 struct {
48 __be16 sport;
49 __be16 dport;
50 } ports;
51 struct {
52 u8 type;
53 u8 code;
54 } icmp;
55 };
56 };
57
58 struct bnxt_tc_tunnel_key {
59 struct bnxt_tc_l2_key l2;
60 struct bnxt_tc_l3_key l3;
61 struct bnxt_tc_l4_key l4;
62 __be32 id;
63 };
64
65 struct bnxt_tc_actions {
66 u32 flags;
67 #define BNXT_TC_ACTION_FLAG_FWD BIT(0)
68 #define BNXT_TC_ACTION_FLAG_FWD_VXLAN BIT(1)
69 #define BNXT_TC_ACTION_FLAG_PUSH_VLAN BIT(3)
70 #define BNXT_TC_ACTION_FLAG_POP_VLAN BIT(4)
71 #define BNXT_TC_ACTION_FLAG_DROP BIT(5)
72 #define BNXT_TC_ACTION_FLAG_TUNNEL_ENCAP BIT(6)
73 #define BNXT_TC_ACTION_FLAG_TUNNEL_DECAP BIT(7)
74
75 u16 dst_fid;
76 struct net_device *dst_dev;
77 __be16 push_vlan_tpid;
78 __be16 push_vlan_tci;
79
80
81 struct ip_tunnel_key tun_encap_key;
82 };
83
84 struct bnxt_tc_flow {
85 u32 flags;
86 #define BNXT_TC_FLOW_FLAGS_ETH_ADDRS BIT(1)
87 #define BNXT_TC_FLOW_FLAGS_IPV4_ADDRS BIT(2)
88 #define BNXT_TC_FLOW_FLAGS_IPV6_ADDRS BIT(3)
89 #define BNXT_TC_FLOW_FLAGS_PORTS BIT(4)
90 #define BNXT_TC_FLOW_FLAGS_ICMP BIT(5)
91 #define BNXT_TC_FLOW_FLAGS_TUNL_ETH_ADDRS BIT(6)
92 #define BNXT_TC_FLOW_FLAGS_TUNL_IPV4_ADDRS BIT(7)
93 #define BNXT_TC_FLOW_FLAGS_TUNL_IPV6_ADDRS BIT(8)
94 #define BNXT_TC_FLOW_FLAGS_TUNL_PORTS BIT(9)
95 #define BNXT_TC_FLOW_FLAGS_TUNL_ID BIT(10)
96 #define BNXT_TC_FLOW_FLAGS_TUNNEL (BNXT_TC_FLOW_FLAGS_TUNL_ETH_ADDRS | \
97 BNXT_TC_FLOW_FLAGS_TUNL_IPV4_ADDRS | \
98 BNXT_TC_FLOW_FLAGS_TUNL_IPV6_ADDRS |\
99 BNXT_TC_FLOW_FLAGS_TUNL_PORTS |\
100 BNXT_TC_FLOW_FLAGS_TUNL_ID)
101
102
103 u16 src_fid;
104 struct bnxt_tc_l2_key l2_key;
105 struct bnxt_tc_l2_key l2_mask;
106 struct bnxt_tc_l3_key l3_key;
107 struct bnxt_tc_l3_key l3_mask;
108 struct bnxt_tc_l4_key l4_key;
109 struct bnxt_tc_l4_key l4_mask;
110 struct ip_tunnel_key tun_key;
111 struct ip_tunnel_key tun_mask;
112
113 struct bnxt_tc_actions actions;
114
115
116 struct bnxt_tc_flow_stats stats;
117
118 struct bnxt_tc_flow_stats prev_stats;
119 unsigned long lastused;
120
121
122
123 spinlock_t stats_lock;
124 };
125
126
127
128
129
130
131
132 struct bnxt_tc_tunnel_node {
133 struct ip_tunnel_key key;
134 struct rhash_head node;
135
136
137 struct bnxt_tc_l2_key l2_info;
138
139 #define INVALID_TUNNEL_HANDLE cpu_to_le32(0xffffffff)
140
141 __le32 tunnel_handle;
142
143 u32 refcount;
144 struct rcu_head rcu;
145 };
146
147
148
149
150
151
152
153
154 struct bnxt_tc_l2_node {
155
156 #define BNXT_TC_L2_KEY_LEN 16
157 struct bnxt_tc_l2_key key;
158 struct rhash_head node;
159
160
161 struct list_head common_l2_flows;
162
163
164 u16 refcount;
165
166 struct rcu_head rcu;
167 };
168
169 struct bnxt_tc_flow_node {
170
171 unsigned long cookie;
172 struct rhash_head node;
173
174 struct bnxt_tc_flow flow;
175
176 __le64 ext_flow_handle;
177 __le16 flow_handle;
178 __le32 flow_id;
179
180
181 struct bnxt_tc_l2_node *l2_node;
182
183 struct list_head l2_list_node;
184
185
186 struct bnxt_tc_tunnel_node *encap_node;
187
188
189 struct bnxt_tc_tunnel_node *decap_node;
190
191 struct bnxt_tc_l2_node *decap_l2_node;
192
193 struct list_head decap_l2_list_node;
194
195 struct rcu_head rcu;
196 };
197
198 int bnxt_tc_setup_flower(struct bnxt *bp, u16 src_fid,
199 struct flow_cls_offload *cls_flower);
200 int bnxt_init_tc(struct bnxt *bp);
201 void bnxt_shutdown_tc(struct bnxt *bp);
202 void bnxt_tc_flow_stats_work(struct bnxt *bp);
203
204 static inline bool bnxt_tc_flower_enabled(struct bnxt *bp)
205 {
206 return bp->tc_info && bp->tc_info->enabled;
207 }
208
209 #else
210
211 static inline int bnxt_tc_setup_flower(struct bnxt *bp, u16 src_fid,
212 struct flow_cls_offload *cls_flower)
213 {
214 return -EOPNOTSUPP;
215 }
216
217 static inline int bnxt_init_tc(struct bnxt *bp)
218 {
219 return 0;
220 }
221
222 static inline void bnxt_shutdown_tc(struct bnxt *bp)
223 {
224 }
225
226 static inline void bnxt_tc_flow_stats_work(struct bnxt *bp)
227 {
228 }
229
230 static inline bool bnxt_tc_flower_enabled(struct bnxt *bp)
231 {
232 return false;
233 }
234 #endif
235 #endif