Skip to content

Commit ef68de5

Browse files
committed
Merge branch 'Support-tunnels-over-VLAN-in-NFP'
John Hurley says: ==================== Support tunnels over VLAN in NFP This patchset deals with tunnel encap and decap when the end-point IP address is on an internal port (for example and OvS VLAN port). Tunnel encap without VLAN is already supported in the NFP driver. This patchset extends that to include a push VLAN along with tunnel header push. Patches 1-4 extend the flow_offload IR API to include actions that use skbedit to set the ptype of an SKB and that send a packet to port ingress from the act_mirred module. Such actions are used in flower rules that forward tunnel packets to internal ports where they can be decapsulated. OvS and its TC API is an example of a user-space app that produces such rules. Patch 5 modifies the encap offload code to allow the pushing of a VLAN header after a tunnel header push. Patches 6-10 deal with tunnel decap when the end-point is on an internal port. They detect 'pre-tunnel rules' which do not deal with tunnels themselves but, rather, forward packets to internal ports where they can be decapped if required. Such rules are offloaded to a table in HW along with an indication of whether packets need to be passed to this table of not (based on their destination MAC address). Matching against this table prior to decapsulation in HW allows the correct parsing and handling of outer VLANs on tunnelled packets and the correct updating of stats for said 'pre-tunnel' rules. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 55a47dc + 2e0bc7f commit ef68de5

10 files changed

Lines changed: 476 additions & 32 deletions

File tree

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

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ nfp_fl_output(struct nfp_app *app, struct nfp_fl_output *output,
173173
struct nfp_fl_payload *nfp_flow,
174174
bool last, struct net_device *in_dev,
175175
enum nfp_flower_tun_type tun_type, int *tun_out_cnt,
176-
struct netlink_ext_ack *extack)
176+
bool pkt_host, struct netlink_ext_ack *extack)
177177
{
178178
size_t act_size = sizeof(struct nfp_fl_output);
179179
struct nfp_flower_priv *priv = app->priv;
@@ -218,6 +218,20 @@ nfp_fl_output(struct nfp_app *app, struct nfp_fl_output *output,
218218
return gid;
219219
}
220220
output->port = cpu_to_be32(NFP_FL_LAG_OUT | gid);
221+
} else if (nfp_flower_internal_port_can_offload(app, out_dev)) {
222+
if (!(priv->flower_ext_feats & NFP_FL_FEATS_PRE_TUN_RULES)) {
223+
NL_SET_ERR_MSG_MOD(extack, "unsupported offload: pre-tunnel rules not supported in loaded firmware");
224+
return -EOPNOTSUPP;
225+
}
226+
227+
if (nfp_flow->pre_tun_rule.dev || !pkt_host) {
228+
NL_SET_ERR_MSG_MOD(extack, "unsupported offload: pre-tunnel rules require single egress dev and ptype HOST action");
229+
return -EOPNOTSUPP;
230+
}
231+
232+
nfp_flow->pre_tun_rule.dev = out_dev;
233+
234+
return 0;
221235
} else {
222236
/* Set action output parameters. */
223237
output->flags = cpu_to_be16(tmp_flags);
@@ -885,7 +899,7 @@ nfp_flower_output_action(struct nfp_app *app,
885899
struct nfp_fl_payload *nfp_fl, int *a_len,
886900
struct net_device *netdev, bool last,
887901
enum nfp_flower_tun_type *tun_type, int *tun_out_cnt,
888-
int *out_cnt, u32 *csum_updated,
902+
int *out_cnt, u32 *csum_updated, bool pkt_host,
889903
struct netlink_ext_ack *extack)
890904
{
891905
struct nfp_flower_priv *priv = app->priv;
@@ -907,7 +921,7 @@ nfp_flower_output_action(struct nfp_app *app,
907921

908922
output = (struct nfp_fl_output *)&nfp_fl->action_data[*a_len];
909923
err = nfp_fl_output(app, output, act, nfp_fl, last, netdev, *tun_type,
910-
tun_out_cnt, extack);
924+
tun_out_cnt, pkt_host, extack);
911925
if (err)
912926
return err;
913927

@@ -939,7 +953,7 @@ nfp_flower_loop_action(struct nfp_app *app, const struct flow_action_entry *act,
939953
struct net_device *netdev,
940954
enum nfp_flower_tun_type *tun_type, int *tun_out_cnt,
941955
int *out_cnt, u32 *csum_updated,
942-
struct nfp_flower_pedit_acts *set_act,
956+
struct nfp_flower_pedit_acts *set_act, bool *pkt_host,
943957
struct netlink_ext_ack *extack, int act_idx)
944958
{
945959
struct nfp_fl_set_ipv4_tun *set_tun;
@@ -955,17 +969,21 @@ nfp_flower_loop_action(struct nfp_app *app, const struct flow_action_entry *act,
955969
case FLOW_ACTION_DROP:
956970
nfp_fl->meta.shortcut = cpu_to_be32(NFP_FL_SC_ACT_DROP);
957971
break;
972+
case FLOW_ACTION_REDIRECT_INGRESS:
958973
case FLOW_ACTION_REDIRECT:
959974
err = nfp_flower_output_action(app, act, nfp_fl, a_len, netdev,
960975
true, tun_type, tun_out_cnt,
961-
out_cnt, csum_updated, extack);
976+
out_cnt, csum_updated, *pkt_host,
977+
extack);
962978
if (err)
963979
return err;
964980
break;
981+
case FLOW_ACTION_MIRRED_INGRESS:
965982
case FLOW_ACTION_MIRRED:
966983
err = nfp_flower_output_action(app, act, nfp_fl, a_len, netdev,
967984
false, tun_type, tun_out_cnt,
968-
out_cnt, csum_updated, extack);
985+
out_cnt, csum_updated, *pkt_host,
986+
extack);
969987
if (err)
970988
return err;
971989
break;
@@ -1095,6 +1113,13 @@ nfp_flower_loop_action(struct nfp_app *app, const struct flow_action_entry *act,
10951113
nfp_fl_set_mpls(set_m, act);
10961114
*a_len += sizeof(struct nfp_fl_set_mpls);
10971115
break;
1116+
case FLOW_ACTION_PTYPE:
1117+
/* TC ptype skbedit sets PACKET_HOST for ingress redirect. */
1118+
if (act->ptype != PACKET_HOST)
1119+
return -EOPNOTSUPP;
1120+
1121+
*pkt_host = true;
1122+
break;
10981123
default:
10991124
/* Currently we do not handle any other actions. */
11001125
NL_SET_ERR_MSG_MOD(extack, "unsupported offload: unsupported action in action list");
@@ -1150,6 +1175,7 @@ int nfp_flower_compile_action(struct nfp_app *app,
11501175
struct nfp_flower_pedit_acts set_act;
11511176
enum nfp_flower_tun_type tun_type;
11521177
struct flow_action_entry *act;
1178+
bool pkt_host = false;
11531179
u32 csum_updated = 0;
11541180

11551181
memset(nfp_flow->action_data, 0, NFP_FL_MAX_A_SIZ);
@@ -1166,7 +1192,7 @@ int nfp_flower_compile_action(struct nfp_app *app,
11661192
err = nfp_flower_loop_action(app, act, flow, nfp_flow, &act_len,
11671193
netdev, &tun_type, &tun_out_cnt,
11681194
&out_cnt, &csum_updated,
1169-
&set_act, extack, i);
1195+
&set_act, &pkt_host, extack, i);
11701196
if (err)
11711197
return err;
11721198
act_cnt++;

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,8 @@ struct nfp_fl_set_ipv4_tun {
220220
__be16 tun_flags;
221221
u8 ttl;
222222
u8 tos;
223-
__be32 extra;
223+
__be16 outer_vlan_tpid;
224+
__be16 outer_vlan_tci;
224225
u8 tun_len;
225226
u8 res2;
226227
__be16 tun_proto;
@@ -483,6 +484,7 @@ enum nfp_flower_cmsg_type_port {
483484
NFP_FLOWER_CMSG_TYPE_QOS_MOD = 18,
484485
NFP_FLOWER_CMSG_TYPE_QOS_DEL = 19,
485486
NFP_FLOWER_CMSG_TYPE_QOS_STATS = 20,
487+
NFP_FLOWER_CMSG_TYPE_PRE_TUN_RULE = 21,
486488
NFP_FLOWER_CMSG_TYPE_MAX = 32,
487489
};
488490

‎drivers/net/ethernet/netronome/nfp/flower/main.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,7 @@ static int nfp_flower_init(struct nfp_app *app)
781781

782782
INIT_LIST_HEAD(&app_priv->indr_block_cb_priv);
783783
INIT_LIST_HEAD(&app_priv->non_repr_priv);
784+
app_priv->pre_tun_rule_cnt = 0;
784785

785786
return 0;
786787

‎drivers/net/ethernet/netronome/nfp/flower/main.h‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ struct nfp_app;
4242
#define NFP_FL_FEATS_VLAN_PCP BIT(3)
4343
#define NFP_FL_FEATS_VF_RLIM BIT(4)
4444
#define NFP_FL_FEATS_FLOW_MOD BIT(5)
45+
#define NFP_FL_FEATS_PRE_TUN_RULES BIT(6)
4546
#define NFP_FL_FEATS_FLOW_MERGE BIT(30)
4647
#define NFP_FL_FEATS_LAG BIT(31)
4748

@@ -162,6 +163,7 @@ struct nfp_fl_internal_ports {
162163
* @qos_stats_work: Workqueue for qos stats processing
163164
* @qos_rate_limiters: Current active qos rate limiters
164165
* @qos_stats_lock: Lock on qos stats updates
166+
* @pre_tun_rule_cnt: Number of pre-tunnel rules offloaded
165167
*/
166168
struct nfp_flower_priv {
167169
struct nfp_app *app;
@@ -193,6 +195,7 @@ struct nfp_flower_priv {
193195
struct delayed_work qos_stats_work;
194196
unsigned int qos_rate_limiters;
195197
spinlock_t qos_stats_lock; /* Protect the qos stats */
198+
int pre_tun_rule_cnt;
196199
};
197200

198201
/**
@@ -218,6 +221,7 @@ struct nfp_fl_qos {
218221
* @block_shared: Flag indicating if offload applies to shared blocks
219222
* @mac_list: List entry of reprs that share the same offloaded MAC
220223
* @qos_table: Stored info on filters implementing qos
224+
* @on_bridge: Indicates if the repr is attached to a bridge
221225
*/
222226
struct nfp_flower_repr_priv {
223227
struct nfp_repr *nfp_repr;
@@ -227,6 +231,7 @@ struct nfp_flower_repr_priv {
227231
bool block_shared;
228232
struct list_head mac_list;
229233
struct nfp_fl_qos qos_table;
234+
bool on_bridge;
230235
};
231236

232237
/**
@@ -280,6 +285,11 @@ struct nfp_fl_payload {
280285
char *action_data;
281286
struct list_head linked_flows;
282287
bool in_hw;
288+
struct {
289+
struct net_device *dev;
290+
__be16 vlan_tci;
291+
__be16 port_idx;
292+
} pre_tun_rule;
283293
};
284294

285295
struct nfp_fl_payload_link {
@@ -333,6 +343,11 @@ static inline bool nfp_flower_is_merge_flow(struct nfp_fl_payload *flow_pay)
333343
return flow_pay->tc_flower_cookie == (unsigned long)flow_pay;
334344
}
335345

346+
static inline bool nfp_flower_is_supported_bridge(struct net_device *netdev)
347+
{
348+
return netif_is_ovs_master(netdev);
349+
}
350+
336351
int nfp_flower_metadata_init(struct nfp_app *app, u64 host_ctx_count,
337352
unsigned int host_ctx_split);
338353
void nfp_flower_metadata_cleanup(struct nfp_app *app);
@@ -415,4 +430,8 @@ void
415430
nfp_flower_non_repr_priv_put(struct nfp_app *app, struct net_device *netdev);
416431
u32 nfp_flower_get_port_id_from_netdev(struct nfp_app *app,
417432
struct net_device *netdev);
433+
int nfp_flower_xmit_pre_tun_flow(struct nfp_app *app,
434+
struct nfp_fl_payload *flow);
435+
int nfp_flower_xmit_pre_tun_del_flow(struct nfp_app *app,
436+
struct nfp_fl_payload *flow);
418437
#endif

0 commit comments

Comments
 (0)