net/mlx5e: Add csum to tc action infra

Add parsing support by implementing struct mlx5e_tc_act
for this action.

Signed-off-by: Roi Dayan <roid@nvidia.com>
Reviewed-by: Oz Shlomo <ozsh@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
This commit is contained in:
Roi Dayan 2021-07-21 10:30:40 +03:00 коммит произвёл Saeed Mahameed
Родитель c65686d79c
Коммит 9ca1bb2cf6
5 изменённых файлов: 67 добавлений и 45 удалений

Просмотреть файл

@ -49,7 +49,7 @@ mlx5_core-$(CONFIG_MLX5_CLS_ACT) += en_tc.o en/rep/tc.o en/rep/neigh.o \
mlx5_core-$(CONFIG_MLX5_CLS_ACT) += en/tc/act/act.o en/tc/act/drop.o en/tc/act/trap.o \
en/tc/act/accept.o en/tc/act/mark.o en/tc/act/goto.o \
en/tc/act/tun.o
en/tc/act/tun.o en/tc/act/csum.o
mlx5_core-$(CONFIG_MLX5_TC_CT) += en/tc_ct.o
mlx5_core-$(CONFIG_MLX5_TC_SAMPLE) += en/tc/sample.o

Просмотреть файл

@ -20,6 +20,9 @@ static struct mlx5e_tc_act *tc_acts_fdb[NUM_FLOW_ACTIONS] = {
NULL, /* FLOW_ACTION_VLAN_MANGLE, */
&mlx5e_tc_act_tun_encap,
&mlx5e_tc_act_tun_decap,
NULL, /* FLOW_ACTION_MANGLE, */
NULL, /* FLOW_ACTION_ADD, */
&mlx5e_tc_act_csum,
};
/* Must be aligned with enum flow_action_id. */
@ -39,7 +42,7 @@ static struct mlx5e_tc_act *tc_acts_nic[NUM_FLOW_ACTIONS] = {
NULL, /* FLOW_ACTION_TUNNEL_DECAP, */
NULL, /* FLOW_ACTION_MANGLE, */
NULL, /* FLOW_ACTION_ADD, */
NULL, /* FLOW_ACTION_CSUM, */
&mlx5e_tc_act_csum,
&mlx5e_tc_act_mark,
};

Просмотреть файл

@ -37,6 +37,7 @@ extern struct mlx5e_tc_act mlx5e_tc_act_mark;
extern struct mlx5e_tc_act mlx5e_tc_act_goto;
extern struct mlx5e_tc_act mlx5e_tc_act_tun_encap;
extern struct mlx5e_tc_act mlx5e_tc_act_tun_decap;
extern struct mlx5e_tc_act mlx5e_tc_act_csum;
struct mlx5e_tc_act *
mlx5e_tc_act_get(enum flow_action_id act_id,

Просмотреть файл

@ -0,0 +1,61 @@
// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
// Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#include <linux/tc_act/tc_csum.h>
#include "act.h"
#include "en/tc_priv.h"
static bool
csum_offload_supported(struct mlx5e_priv *priv,
u32 action,
u32 update_flags,
struct netlink_ext_ack *extack)
{
u32 prot_flags = TCA_CSUM_UPDATE_FLAG_IPV4HDR | TCA_CSUM_UPDATE_FLAG_TCP |
TCA_CSUM_UPDATE_FLAG_UDP;
/* The HW recalcs checksums only if re-writing headers */
if (!(action & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR)) {
NL_SET_ERR_MSG_MOD(extack,
"TC csum action is only offloaded with pedit");
netdev_warn(priv->netdev,
"TC csum action is only offloaded with pedit\n");
return false;
}
if (update_flags & ~prot_flags) {
NL_SET_ERR_MSG_MOD(extack,
"can't offload TC csum action for some header/s");
netdev_warn(priv->netdev,
"can't offload TC csum action for some header/s - flags %#x\n",
update_flags);
return false;
}
return true;
}
static bool
tc_act_can_offload_csum(struct mlx5e_tc_act_parse_state *parse_state,
const struct flow_action_entry *act,
int act_index)
{
struct mlx5e_tc_flow *flow = parse_state->flow;
return csum_offload_supported(flow->priv, flow->attr->action,
act->csum_flags, parse_state->extack);
}
static int
tc_act_parse_csum(struct mlx5e_tc_act_parse_state *parse_state,
const struct flow_action_entry *act,
struct mlx5e_priv *priv,
struct mlx5_flow_attr *attr)
{
return 0;
}
struct mlx5e_tc_act mlx5e_tc_act_csum = {
.can_offload = tc_act_can_offload_csum,
.parse_action = tc_act_parse_csum,
};

Просмотреть файл

@ -41,7 +41,6 @@
#include <linux/completion.h>
#include <linux/if_macvlan.h>
#include <net/tc_act/tc_pedit.h>
#include <net/tc_act/tc_csum.h>
#include <net/psample.h>
#include <net/arp.h>
#include <net/ipv6_stubs.h>
@ -3008,35 +3007,6 @@ out_dealloc_parsed_actions:
return err;
}
static bool csum_offload_supported(struct mlx5e_priv *priv,
u32 action,
u32 update_flags,
struct netlink_ext_ack *extack)
{
u32 prot_flags = TCA_CSUM_UPDATE_FLAG_IPV4HDR | TCA_CSUM_UPDATE_FLAG_TCP |
TCA_CSUM_UPDATE_FLAG_UDP;
/* The HW recalcs checksums only if re-writing headers */
if (!(action & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR)) {
NL_SET_ERR_MSG_MOD(extack,
"TC csum action is only offloaded with pedit");
netdev_warn(priv->netdev,
"TC csum action is only offloaded with pedit\n");
return false;
}
if (update_flags & ~prot_flags) {
NL_SET_ERR_MSG_MOD(extack,
"can't offload TC csum action for some header/s");
netdev_warn(priv->netdev,
"can't offload TC csum action for some header/s - flags %#x\n",
update_flags);
return false;
}
return true;
}
struct ip_ttl_word {
__u8 ttl;
__u8 protocol;
@ -3457,13 +3427,6 @@ parse_tc_nic_actions(struct mlx5e_priv *priv,
return err;
break;
case FLOW_ACTION_CSUM:
if (csum_offload_supported(priv, attr->action,
act->csum_flags,
extack))
break;
return -EOPNOTSUPP;
case FLOW_ACTION_REDIRECT: {
struct net_device *peer_dev = act->dev;
@ -3894,12 +3857,6 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv,
esw_attr->split_count = esw_attr->out_count;
}
break;
case FLOW_ACTION_CSUM:
if (csum_offload_supported(priv, attr->action,
act->csum_flags, extack))
break;
return -EOPNOTSUPP;
case FLOW_ACTION_REDIRECT_INGRESS: {
struct net_device *out_dev;