Skip to content

Commit 35b7c70

Browse files
jahurleydavem330
authored andcommitted
nfp: flower: offload MPLS pop action
Recent additions to the kernel include a TC action module to manipulate MPLS headers on packets. Such actions are available to offload via the flow_offload intermediate representation API. Modify the NFP driver to allow the offload of MPLS pop actions to firmware. The act_mpls TC module enforces that the next protocol is supplied along with the pop action. Passing this to firmware allows it to properly rebuild the underlying packet after the pop. Signed-off-by: John Hurley <[email protected]> Reviewed-by: Simon Horman <[email protected]> Reviewed-by: Jakub Kicinski <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a6eb181 commit 35b7c70

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,17 @@ nfp_fl_push_mpls(struct nfp_fl_push_mpls *push_mpls,
5959
return 0;
6060
}
6161

62+
static void
63+
nfp_fl_pop_mpls(struct nfp_fl_pop_mpls *pop_mpls,
64+
const struct flow_action_entry *act)
65+
{
66+
size_t act_size = sizeof(struct nfp_fl_pop_mpls);
67+
68+
pop_mpls->head.jump_id = NFP_FL_ACTION_OPCODE_POP_MPLS;
69+
pop_mpls->head.len_lw = act_size >> NFP_FL_LW_SIZ;
70+
pop_mpls->ethtype = act->mpls_pop.proto;
71+
}
72+
6273
static void nfp_fl_pop_vlan(struct nfp_fl_pop_vlan *pop_vlan)
6374
{
6475
size_t act_size = sizeof(struct nfp_fl_pop_vlan);
@@ -905,6 +916,7 @@ nfp_flower_loop_action(struct nfp_app *app, const struct flow_action_entry *act,
905916
struct nfp_fl_push_vlan *psh_v;
906917
struct nfp_fl_push_mpls *psh_m;
907918
struct nfp_fl_pop_vlan *pop_v;
919+
struct nfp_fl_pop_mpls *pop_m;
908920
int err;
909921

910922
switch (act->id) {
@@ -1025,6 +1037,19 @@ nfp_flower_loop_action(struct nfp_app *app, const struct flow_action_entry *act,
10251037
return err;
10261038
*a_len += sizeof(struct nfp_fl_push_mpls);
10271039
break;
1040+
case FLOW_ACTION_MPLS_POP:
1041+
if (*a_len +
1042+
sizeof(struct nfp_fl_pop_mpls) > NFP_FL_MAX_A_SIZ) {
1043+
NL_SET_ERR_MSG_MOD(extack, "unsupported offload: maximum allowed action list size exceeded at pop MPLS");
1044+
return -EOPNOTSUPP;
1045+
}
1046+
1047+
pop_m = (struct nfp_fl_pop_mpls *)&nfp_fl->action_data[*a_len];
1048+
nfp_fl->meta.shortcut = cpu_to_be32(NFP_FL_SC_ACT_NULL);
1049+
1050+
nfp_fl_pop_mpls(pop_m, act);
1051+
*a_len += sizeof(struct nfp_fl_pop_mpls);
1052+
break;
10281053
default:
10291054
/* Currently we do not handle any other actions. */
10301055
NL_SET_ERR_MSG_MOD(extack, "unsupported offload: unsupported action in action list");

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
#define NFP_FL_ACTION_OPCODE_PUSH_VLAN 1
7070
#define NFP_FL_ACTION_OPCODE_POP_VLAN 2
7171
#define NFP_FL_ACTION_OPCODE_PUSH_MPLS 3
72+
#define NFP_FL_ACTION_OPCODE_POP_MPLS 4
7273
#define NFP_FL_ACTION_OPCODE_SET_IPV4_TUNNEL 6
7374
#define NFP_FL_ACTION_OPCODE_SET_ETHERNET 7
7475
#define NFP_FL_ACTION_OPCODE_SET_IPV4_ADDRS 9
@@ -239,6 +240,11 @@ struct nfp_fl_push_mpls {
239240
__be32 lse;
240241
};
241242

243+
struct nfp_fl_pop_mpls {
244+
struct nfp_fl_act_head head;
245+
__be16 ethtype;
246+
};
247+
242248
/* Metadata with L2 (1W/4B)
243249
* ----------------------------------------------------------------
244250
* 3 2 1

0 commit comments

Comments
 (0)