Commit 35b7c70c authored by John Hurley's avatar John Hurley Committed by David S. Miller

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: default avatarJohn Hurley <john.hurley@netronome.com>
Reviewed-by: default avatarSimon Horman <simon.horman@netronome.com>
Reviewed-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a6eb1817
...@@ -59,6 +59,17 @@ nfp_fl_push_mpls(struct nfp_fl_push_mpls *push_mpls, ...@@ -59,6 +59,17 @@ nfp_fl_push_mpls(struct nfp_fl_push_mpls *push_mpls,
return 0; return 0;
} }
static void
nfp_fl_pop_mpls(struct nfp_fl_pop_mpls *pop_mpls,
const struct flow_action_entry *act)
{
size_t act_size = sizeof(struct nfp_fl_pop_mpls);
pop_mpls->head.jump_id = NFP_FL_ACTION_OPCODE_POP_MPLS;
pop_mpls->head.len_lw = act_size >> NFP_FL_LW_SIZ;
pop_mpls->ethtype = act->mpls_pop.proto;
}
static void nfp_fl_pop_vlan(struct nfp_fl_pop_vlan *pop_vlan) static void nfp_fl_pop_vlan(struct nfp_fl_pop_vlan *pop_vlan)
{ {
size_t act_size = sizeof(struct nfp_fl_pop_vlan); 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, ...@@ -905,6 +916,7 @@ nfp_flower_loop_action(struct nfp_app *app, const struct flow_action_entry *act,
struct nfp_fl_push_vlan *psh_v; struct nfp_fl_push_vlan *psh_v;
struct nfp_fl_push_mpls *psh_m; struct nfp_fl_push_mpls *psh_m;
struct nfp_fl_pop_vlan *pop_v; struct nfp_fl_pop_vlan *pop_v;
struct nfp_fl_pop_mpls *pop_m;
int err; int err;
switch (act->id) { switch (act->id) {
...@@ -1025,6 +1037,19 @@ nfp_flower_loop_action(struct nfp_app *app, const struct flow_action_entry *act, ...@@ -1025,6 +1037,19 @@ nfp_flower_loop_action(struct nfp_app *app, const struct flow_action_entry *act,
return err; return err;
*a_len += sizeof(struct nfp_fl_push_mpls); *a_len += sizeof(struct nfp_fl_push_mpls);
break; break;
case FLOW_ACTION_MPLS_POP:
if (*a_len +
sizeof(struct nfp_fl_pop_mpls) > NFP_FL_MAX_A_SIZ) {
NL_SET_ERR_MSG_MOD(extack, "unsupported offload: maximum allowed action list size exceeded at pop MPLS");
return -EOPNOTSUPP;
}
pop_m = (struct nfp_fl_pop_mpls *)&nfp_fl->action_data[*a_len];
nfp_fl->meta.shortcut = cpu_to_be32(NFP_FL_SC_ACT_NULL);
nfp_fl_pop_mpls(pop_m, act);
*a_len += sizeof(struct nfp_fl_pop_mpls);
break;
default: default:
/* Currently we do not handle any other actions. */ /* Currently we do not handle any other actions. */
NL_SET_ERR_MSG_MOD(extack, "unsupported offload: unsupported action in action list"); NL_SET_ERR_MSG_MOD(extack, "unsupported offload: unsupported action in action list");
......
...@@ -69,6 +69,7 @@ ...@@ -69,6 +69,7 @@
#define NFP_FL_ACTION_OPCODE_PUSH_VLAN 1 #define NFP_FL_ACTION_OPCODE_PUSH_VLAN 1
#define NFP_FL_ACTION_OPCODE_POP_VLAN 2 #define NFP_FL_ACTION_OPCODE_POP_VLAN 2
#define NFP_FL_ACTION_OPCODE_PUSH_MPLS 3 #define NFP_FL_ACTION_OPCODE_PUSH_MPLS 3
#define NFP_FL_ACTION_OPCODE_POP_MPLS 4
#define NFP_FL_ACTION_OPCODE_SET_IPV4_TUNNEL 6 #define NFP_FL_ACTION_OPCODE_SET_IPV4_TUNNEL 6
#define NFP_FL_ACTION_OPCODE_SET_ETHERNET 7 #define NFP_FL_ACTION_OPCODE_SET_ETHERNET 7
#define NFP_FL_ACTION_OPCODE_SET_IPV4_ADDRS 9 #define NFP_FL_ACTION_OPCODE_SET_IPV4_ADDRS 9
...@@ -239,6 +240,11 @@ struct nfp_fl_push_mpls { ...@@ -239,6 +240,11 @@ struct nfp_fl_push_mpls {
__be32 lse; __be32 lse;
}; };
struct nfp_fl_pop_mpls {
struct nfp_fl_act_head head;
__be16 ethtype;
};
/* Metadata with L2 (1W/4B) /* Metadata with L2 (1W/4B)
* ---------------------------------------------------------------- * ----------------------------------------------------------------
* 3 2 1 * 3 2 1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment