Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fccac580 authored by Pieter Jansen van Vuuren's avatar Pieter Jansen van Vuuren Committed by David S. Miller
Browse files

nfp: flower: add GRE encap action support



Add new GRE encapsulation support, which allows offload of filters
using tunnel_key set action in combination with actions that egress
to GRE type ports.

Signed-off-by: default avatarPieter Jansen van Vuuren <pieter.jansenvanvuuren@netronome.com>
Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: default avatarJohn Hurley <john.hurley@netronome.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e3a6aba0
Loading
Loading
Loading
Loading
+28 −5
Original line number Diff line number Diff line
@@ -170,13 +170,36 @@ nfp_fl_output(struct nfp_app *app, struct nfp_fl_output *output,
	return 0;
}

static bool
nfp_flower_tun_is_gre(struct tc_cls_flower_offload *flow, int start_idx)
{
	struct flow_action_entry *act = flow->rule->action.entries;
	int num_act = flow->rule->action.num_entries;
	int act_idx;

	/* Preparse action list for next mirred or redirect action */
	for (act_idx = start_idx + 1; act_idx < num_act; act_idx++)
		if (act[act_idx].id == FLOW_ACTION_REDIRECT ||
		    act[act_idx].id == FLOW_ACTION_MIRRED)
			return netif_is_gretap(act[act_idx].dev);

	return false;
}

static enum nfp_flower_tun_type
nfp_fl_get_tun_from_act(struct nfp_app *app,
			const struct flow_action_entry *act)
			struct tc_cls_flower_offload *flow,
			const struct flow_action_entry *act, int act_idx)
{
	const struct ip_tunnel_info *tun = act->tunnel;
	struct nfp_flower_priv *priv = app->priv;

	/* Determine the tunnel type based on the egress netdev
	 * in the mirred action for tunnels without l4.
	 */
	if (nfp_flower_tun_is_gre(flow, act_idx))
		return NFP_FL_TUNNEL_GRE;

	switch (tun->key.tp_dst) {
	case htons(IANA_VXLAN_UDP_PORT):
		return NFP_FL_TUNNEL_VXLAN;
@@ -841,7 +864,7 @@ nfp_flower_loop_action(struct nfp_app *app, const struct flow_action_entry *act,
		       enum nfp_flower_tun_type *tun_type, int *tun_out_cnt,
		       int *out_cnt, u32 *csum_updated,
		       struct nfp_flower_pedit_acts *set_act,
		       struct netlink_ext_ack *extack)
		       struct netlink_ext_ack *extack, int act_idx)
{
	struct nfp_fl_set_ipv4_tun *set_tun;
	struct nfp_fl_pre_tunnel *pre_tun;
@@ -896,7 +919,7 @@ nfp_flower_loop_action(struct nfp_app *app, const struct flow_action_entry *act,
	case FLOW_ACTION_TUNNEL_ENCAP: {
		const struct ip_tunnel_info *ip_tun = act->tunnel;

		*tun_type = nfp_fl_get_tun_from_act(app, act);
		*tun_type = nfp_fl_get_tun_from_act(app, flow, act, act_idx);
		if (*tun_type == NFP_FL_TUNNEL_NONE) {
			NL_SET_ERR_MSG_MOD(extack, "unsupported offload: unsupported tunnel type in action list");
			return -EOPNOTSUPP;
@@ -1022,8 +1045,8 @@ int nfp_flower_compile_action(struct nfp_app *app,
			memset(&set_act, 0, sizeof(set_act));
		err = nfp_flower_loop_action(app, act, flow, nfp_flow, &act_len,
					     netdev, &tun_type, &tun_out_cnt,
					     &out_cnt, &csum_updated, &set_act,
					     extack);
					     &out_cnt, &csum_updated,
					     &set_act, extack, i);
		if (err)
			return err;
		act_cnt++;