Skip to content

Commit 1c976a8

Browse files
committed
Merge branch 'nfp-flower-add-ip-fragmentation-offloading-support'
Pieter Jansen van Vuuren says: ==================== nfp: flower: add ip fragmentation offloading support This set allows offloading IP fragmentation classification. It Implements ip fragmentation match offloading for both IPv4 and IPv6 and offloads frag, nofrag, first and nofirstfrag classification. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 90c00f8 + 71ea534 commit 1c976a8

File tree

3 files changed

+68
-42
lines changed

3 files changed

+68
-42
lines changed

drivers/net/ethernet/netronome/nfp/flower/cmsg.h

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@
6161
#define NFP_FLOWER_MASK_MPLS_BOS BIT(8)
6262
#define NFP_FLOWER_MASK_MPLS_Q BIT(0)
6363

64+
#define NFP_FL_IP_FRAG_FIRST BIT(7)
65+
#define NFP_FL_IP_FRAGMENTED BIT(6)
66+
6467
/* Compressed HW representation of TCP Flags */
6568
#define NFP_FL_TCP_FLAG_URG BIT(4)
6669
#define NFP_FL_TCP_FLAG_PSH BIT(3)
@@ -260,6 +263,13 @@ struct nfp_flower_tp_ports {
260263
__be16 port_dst;
261264
};
262265

266+
struct nfp_flower_ip_ext {
267+
u8 tos;
268+
u8 proto;
269+
u8 ttl;
270+
u8 flags;
271+
};
272+
263273
/* L3 IPv4 details (3W/12B)
264274
* 3 2 1
265275
* 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
@@ -272,10 +282,7 @@ struct nfp_flower_tp_ports {
272282
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
273283
*/
274284
struct nfp_flower_ipv4 {
275-
u8 tos;
276-
u8 proto;
277-
u8 ttl;
278-
u8 flags;
285+
struct nfp_flower_ip_ext ip_ext;
279286
__be32 ipv4_src;
280287
__be32 ipv4_dst;
281288
};
@@ -284,7 +291,7 @@ struct nfp_flower_ipv4 {
284291
* 3 2 1
285292
* 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
286293
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
287-
* | DSCP |ECN| protocol | reserved |
294+
* | DSCP |ECN| protocol | ttl | flags |
288295
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
289296
* | ipv6_exthdr | res | ipv6_flow_label |
290297
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -306,10 +313,7 @@ struct nfp_flower_ipv4 {
306313
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
307314
*/
308315
struct nfp_flower_ipv6 {
309-
u8 tos;
310-
u8 proto;
311-
u8 ttl;
312-
u8 reserved;
316+
struct nfp_flower_ip_ext ip_ext;
313317
__be32 ipv6_flow_label_exthdr;
314318
struct in6_addr ipv6_src;
315319
struct in6_addr ipv6_dst;

drivers/net/ethernet/netronome/nfp/flower/match.c

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -146,26 +146,15 @@ nfp_flower_compile_tport(struct nfp_flower_tp_ports *frame,
146146
}
147147

148148
static void
149-
nfp_flower_compile_ipv4(struct nfp_flower_ipv4 *frame,
150-
struct tc_cls_flower_offload *flow,
151-
bool mask_version)
149+
nfp_flower_compile_ip_ext(struct nfp_flower_ip_ext *frame,
150+
struct tc_cls_flower_offload *flow,
151+
bool mask_version)
152152
{
153153
struct fl_flow_key *target = mask_version ? flow->mask : flow->key;
154-
struct flow_dissector_key_ipv4_addrs *addr;
155-
struct flow_dissector_key_basic *basic;
156-
157-
memset(frame, 0, sizeof(struct nfp_flower_ipv4));
158-
159-
if (dissector_uses_key(flow->dissector,
160-
FLOW_DISSECTOR_KEY_IPV4_ADDRS)) {
161-
addr = skb_flow_dissector_target(flow->dissector,
162-
FLOW_DISSECTOR_KEY_IPV4_ADDRS,
163-
target);
164-
frame->ipv4_src = addr->src;
165-
frame->ipv4_dst = addr->dst;
166-
}
167154

168155
if (dissector_uses_key(flow->dissector, FLOW_DISSECTOR_KEY_BASIC)) {
156+
struct flow_dissector_key_basic *basic;
157+
169158
basic = skb_flow_dissector_target(flow->dissector,
170159
FLOW_DISSECTOR_KEY_BASIC,
171160
target);
@@ -201,6 +190,40 @@ nfp_flower_compile_ipv4(struct nfp_flower_ipv4 *frame,
201190
if (tcp_flags & TCPHDR_URG)
202191
frame->flags |= NFP_FL_TCP_FLAG_URG;
203192
}
193+
194+
if (dissector_uses_key(flow->dissector, FLOW_DISSECTOR_KEY_CONTROL)) {
195+
struct flow_dissector_key_control *key;
196+
197+
key = skb_flow_dissector_target(flow->dissector,
198+
FLOW_DISSECTOR_KEY_CONTROL,
199+
target);
200+
if (key->flags & FLOW_DIS_IS_FRAGMENT)
201+
frame->flags |= NFP_FL_IP_FRAGMENTED;
202+
if (key->flags & FLOW_DIS_FIRST_FRAG)
203+
frame->flags |= NFP_FL_IP_FRAG_FIRST;
204+
}
205+
}
206+
207+
static void
208+
nfp_flower_compile_ipv4(struct nfp_flower_ipv4 *frame,
209+
struct tc_cls_flower_offload *flow,
210+
bool mask_version)
211+
{
212+
struct fl_flow_key *target = mask_version ? flow->mask : flow->key;
213+
struct flow_dissector_key_ipv4_addrs *addr;
214+
215+
memset(frame, 0, sizeof(struct nfp_flower_ipv4));
216+
217+
if (dissector_uses_key(flow->dissector,
218+
FLOW_DISSECTOR_KEY_IPV4_ADDRS)) {
219+
addr = skb_flow_dissector_target(flow->dissector,
220+
FLOW_DISSECTOR_KEY_IPV4_ADDRS,
221+
target);
222+
frame->ipv4_src = addr->src;
223+
frame->ipv4_dst = addr->dst;
224+
}
225+
226+
nfp_flower_compile_ip_ext(&frame->ip_ext, flow, mask_version);
204227
}
205228

206229
static void
@@ -210,7 +233,6 @@ nfp_flower_compile_ipv6(struct nfp_flower_ipv6 *frame,
210233
{
211234
struct fl_flow_key *target = mask_version ? flow->mask : flow->key;
212235
struct flow_dissector_key_ipv6_addrs *addr;
213-
struct flow_dissector_key_basic *basic;
214236

215237
memset(frame, 0, sizeof(struct nfp_flower_ipv6));
216238

@@ -223,22 +245,7 @@ nfp_flower_compile_ipv6(struct nfp_flower_ipv6 *frame,
223245
frame->ipv6_dst = addr->dst;
224246
}
225247

226-
if (dissector_uses_key(flow->dissector, FLOW_DISSECTOR_KEY_BASIC)) {
227-
basic = skb_flow_dissector_target(flow->dissector,
228-
FLOW_DISSECTOR_KEY_BASIC,
229-
target);
230-
frame->proto = basic->ip_proto;
231-
}
232-
233-
if (dissector_uses_key(flow->dissector, FLOW_DISSECTOR_KEY_IP)) {
234-
struct flow_dissector_key_ip *flow_ip;
235-
236-
flow_ip = skb_flow_dissector_target(flow->dissector,
237-
FLOW_DISSECTOR_KEY_IP,
238-
target);
239-
frame->tos = flow_ip->tos;
240-
frame->ttl = flow_ip->ttl;
241-
}
248+
nfp_flower_compile_ip_ext(&frame->ip_ext, flow, mask_version);
242249
}
243250

244251
static void

drivers/net/ethernet/netronome/nfp/flower/offload.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@
4848
(TCPHDR_FIN | TCPHDR_SYN | TCPHDR_RST | \
4949
TCPHDR_PSH | TCPHDR_URG)
5050

51+
#define NFP_FLOWER_SUPPORTED_CTLFLAGS \
52+
(FLOW_DIS_IS_FRAGMENT | \
53+
FLOW_DIS_FIRST_FRAG)
54+
5155
#define NFP_FLOWER_WHITELIST_DISSECTOR \
5256
(BIT(FLOW_DISSECTOR_KEY_CONTROL) | \
5357
BIT(FLOW_DISSECTOR_KEY_BASIC) | \
@@ -322,6 +326,17 @@ nfp_flower_calculate_key_layers(struct nfp_app *app,
322326
}
323327
}
324328

329+
if (dissector_uses_key(flow->dissector, FLOW_DISSECTOR_KEY_CONTROL)) {
330+
struct flow_dissector_key_control *key_ctl;
331+
332+
key_ctl = skb_flow_dissector_target(flow->dissector,
333+
FLOW_DISSECTOR_KEY_CONTROL,
334+
flow->key);
335+
336+
if (key_ctl->flags & ~NFP_FLOWER_SUPPORTED_CTLFLAGS)
337+
return -EOPNOTSUPP;
338+
}
339+
325340
ret_key_ls->key_layer = key_layer;
326341
ret_key_ls->key_layer_two = key_layer_two;
327342
ret_key_ls->key_size = key_size;

0 commit comments

Comments
 (0)