Skip to content

Commit e03e47a

Browse files
jahurleydavem330
authored andcommitted
nfp: flower: offload MPLS set 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 set actions to firmware. Set actions update the outermost MPLS header. The offload includes a mask to specify which fields should be set. 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 35b7c70 commit e03e47a

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

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

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,37 @@ nfp_fl_pop_mpls(struct nfp_fl_pop_mpls *pop_mpls,
7070
pop_mpls->ethtype = act->mpls_pop.proto;
7171
}
7272

73+
static void
74+
nfp_fl_set_mpls(struct nfp_fl_set_mpls *set_mpls,
75+
const struct flow_action_entry *act)
76+
{
77+
size_t act_size = sizeof(struct nfp_fl_set_mpls);
78+
u32 mpls_lse = 0, mpls_mask = 0;
79+
80+
set_mpls->head.jump_id = NFP_FL_ACTION_OPCODE_SET_MPLS;
81+
set_mpls->head.len_lw = act_size >> NFP_FL_LW_SIZ;
82+
83+
if (act->mpls_mangle.label != ACT_MPLS_LABEL_NOT_SET) {
84+
mpls_lse |= act->mpls_mangle.label << MPLS_LS_LABEL_SHIFT;
85+
mpls_mask |= MPLS_LS_LABEL_MASK;
86+
}
87+
if (act->mpls_mangle.tc != ACT_MPLS_TC_NOT_SET) {
88+
mpls_lse |= act->mpls_mangle.tc << MPLS_LS_TC_SHIFT;
89+
mpls_mask |= MPLS_LS_TC_MASK;
90+
}
91+
if (act->mpls_mangle.bos != ACT_MPLS_BOS_NOT_SET) {
92+
mpls_lse |= act->mpls_mangle.bos << MPLS_LS_S_SHIFT;
93+
mpls_mask |= MPLS_LS_S_MASK;
94+
}
95+
if (act->mpls_mangle.ttl) {
96+
mpls_lse |= act->mpls_mangle.ttl << MPLS_LS_TTL_SHIFT;
97+
mpls_mask |= MPLS_LS_TTL_MASK;
98+
}
99+
100+
set_mpls->lse = cpu_to_be32(mpls_lse);
101+
set_mpls->lse_mask = cpu_to_be32(mpls_mask);
102+
}
103+
73104
static void nfp_fl_pop_vlan(struct nfp_fl_pop_vlan *pop_vlan)
74105
{
75106
size_t act_size = sizeof(struct nfp_fl_pop_vlan);
@@ -917,6 +948,7 @@ nfp_flower_loop_action(struct nfp_app *app, const struct flow_action_entry *act,
917948
struct nfp_fl_push_mpls *psh_m;
918949
struct nfp_fl_pop_vlan *pop_v;
919950
struct nfp_fl_pop_mpls *pop_m;
951+
struct nfp_fl_set_mpls *set_m;
920952
int err;
921953

922954
switch (act->id) {
@@ -1050,6 +1082,19 @@ nfp_flower_loop_action(struct nfp_app *app, const struct flow_action_entry *act,
10501082
nfp_fl_pop_mpls(pop_m, act);
10511083
*a_len += sizeof(struct nfp_fl_pop_mpls);
10521084
break;
1085+
case FLOW_ACTION_MPLS_MANGLE:
1086+
if (*a_len +
1087+
sizeof(struct nfp_fl_set_mpls) > NFP_FL_MAX_A_SIZ) {
1088+
NL_SET_ERR_MSG_MOD(extack, "unsupported offload: maximum allowed action list size exceeded at set MPLS");
1089+
return -EOPNOTSUPP;
1090+
}
1091+
1092+
set_m = (struct nfp_fl_set_mpls *)&nfp_fl->action_data[*a_len];
1093+
nfp_fl->meta.shortcut = cpu_to_be32(NFP_FL_SC_ACT_NULL);
1094+
1095+
nfp_fl_set_mpls(set_m, act);
1096+
*a_len += sizeof(struct nfp_fl_set_mpls);
1097+
break;
10531098
default:
10541099
/* Currently we do not handle any other actions. */
10551100
NL_SET_ERR_MSG_MOD(extack, "unsupported offload: unsupported action in action list");

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
#define NFP_FL_ACTION_OPCODE_POP_MPLS 4
7373
#define NFP_FL_ACTION_OPCODE_SET_IPV4_TUNNEL 6
7474
#define NFP_FL_ACTION_OPCODE_SET_ETHERNET 7
75+
#define NFP_FL_ACTION_OPCODE_SET_MPLS 8
7576
#define NFP_FL_ACTION_OPCODE_SET_IPV4_ADDRS 9
7677
#define NFP_FL_ACTION_OPCODE_SET_IPV4_TTL_TOS 10
7778
#define NFP_FL_ACTION_OPCODE_SET_IPV6_SRC 11
@@ -245,6 +246,13 @@ struct nfp_fl_pop_mpls {
245246
__be16 ethtype;
246247
};
247248

249+
struct nfp_fl_set_mpls {
250+
struct nfp_fl_act_head head;
251+
__be16 reserved;
252+
__be32 lse_mask;
253+
__be32 lse;
254+
};
255+
248256
/* Metadata with L2 (1W/4B)
249257
* ----------------------------------------------------------------
250258
* 3 2 1

0 commit comments

Comments
 (0)