Commit d956873f authored by Vlad Buslov's avatar Vlad Buslov Committed by Saeed Mahameed
Browse files

net/mlx5e: Introduce kconfig var for TC support



In order to improve code maintainability and readability, introduce new
CONFIG_MLX5_CLS_ACT kconfig variable to control compilation of TC hardware
offloads implementation. This allows distinguishing between features that
require TC support (MPLSoUDP, etc.) and features that just rely on
representor functionality (rep_bond for live migration, etc.).

Modify rep_tc.h, rep_neigh.h, en_tc.h and chains.h files to provide stubs
for functions that are called from generic code.

Signed-off-by: default avatarVlad Buslov <vladbu@mellanox.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
parent e2394a61
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -78,9 +78,24 @@ config MLX5_ESWITCH
	        Legacy SRIOV mode (L2 mac vlan steering based).
	        Switchdev mode (eswitch offloads).

config MLX5_CLS_ACT
	bool "MLX5 TC classifier action support"
	depends on MLX5_ESWITCH && NET_CLS_ACT
	default y
	help
	  mlx5 ConnectX offloads support for TC classifier action (NET_CLS_ACT),
	  works in both native NIC mdoe and Switchdev SRIOV mode.
	  Actions get attached to a Hardware offloaded classifiers and are
	  invoked after a successful classification. Actions are used to
	  overwrite the classification result, instantly drop or redirect and/or
	  reformat packets in wire speeds without involving the host cpu.

	  If set to N, TC offloads in both NIC and switchdev modes will be disabled.
	  If unsure, set to Y

config MLX5_TC_CT
	bool "MLX5 TC connection tracking offload support"
	depends on MLX5_CORE_EN && NET_SWITCHDEV && NF_FLOW_TABLE && NET_ACT_CT && NET_TC_SKB_EXT
	depends on MLX5_CLS_ACT && NF_FLOW_TABLE && NET_ACT_CT && NET_TC_SKB_EXT
	default y
	help
	  Say Y here if you want to support offloading connection tracking rules
+6 −5
Original line number Diff line number Diff line
@@ -33,18 +33,19 @@ mlx5_core-$(CONFIG_MLX5_CORE_EN) += en_main.o en_common.o en_fs.o en_ethtool.o \
mlx5_core-$(CONFIG_MLX5_EN_ARFS)     += en_arfs.o
mlx5_core-$(CONFIG_MLX5_EN_RXNFC)    += en_fs_ethtool.o
mlx5_core-$(CONFIG_MLX5_CORE_EN_DCB) += en_dcbnl.o en/port_buffer.o
mlx5_core-$(CONFIG_MLX5_ESWITCH)     += en_rep.o en_tc.o en/rep/tc.o en/rep/neigh.o en/tc_tun.o lib/port_tun.o \
					lag_mp.o \
					lib/geneve.o en/mapping.o en/tc_tun_vxlan.o en/tc_tun_gre.o \
					en/tc_tun_geneve.o diag/en_tc_tracepoint.o
mlx5_core-$(CONFIG_PCI_HYPERV_INTERFACE) += en/hv_vhca_stats.o
mlx5_core-$(CONFIG_MLX5_ESWITCH)     += en_rep.o lib/geneve.o lib/port_tun.o lag_mp.o
mlx5_core-$(CONFIG_MLX5_CLS_ACT)     += en_tc.o en/rep/tc.o en/rep/neigh.o \
					en/mapping.o esw/chains.o en/tc_tun.o \
					en/tc_tun_vxlan.o en/tc_tun_gre.o en/tc_tun_geneve.o \
					diag/en_tc_tracepoint.o
mlx5_core-$(CONFIG_MLX5_TC_CT)	     += en/tc_ct.o

#
# Core extra
#
mlx5_core-$(CONFIG_MLX5_ESWITCH)   += eswitch.o eswitch_offloads.o eswitch_offloads_termtbl.o \
				      ecpf.o rdma.o esw/chains.o
				      ecpf.o rdma.o
mlx5_core-$(CONFIG_MLX5_MPFS)      += lib/mpfs.o
mlx5_core-$(CONFIG_VXLAN)          += lib/vxlan.o
mlx5_core-$(CONFIG_PTP_1588_CLOCK) += lib/clock.o
+11 −0
Original line number Diff line number Diff line
@@ -7,6 +7,8 @@
#include "en.h"
#include "en_rep.h"

#if IS_ENABLED(CONFIG_MLX5_CLS_ACT)

int mlx5e_rep_neigh_init(struct mlx5e_rep_priv *rpriv);
void mlx5e_rep_neigh_cleanup(struct mlx5e_rep_priv *rpriv);

@@ -20,4 +22,13 @@ void mlx5e_rep_neigh_entry_release(struct mlx5e_neigh_hash_entry *nhe);

void mlx5e_rep_queue_neigh_stats_work(struct mlx5e_priv *priv);

#else /* CONFIG_MLX5_CLS_ACT */

static inline int
mlx5e_rep_neigh_init(struct mlx5e_rep_priv *rpriv) { return 0; }
static inline void
mlx5e_rep_neigh_cleanup(struct mlx5e_rep_priv *rpriv) {}

#endif /* CONFIG_MLX5_CLS_ACT */

#endif /* __MLX5_EN_REP_NEIGH__ */
+40 −4
Original line number Diff line number Diff line
@@ -5,11 +5,11 @@
#define __MLX5_EN_REP_TC_H__

#include <linux/skbuff.h>
#include "en.h"
#include "en_tc.h"
#include "en_rep.h"

struct mlx5e_rep_priv;
#if IS_ENABLED(CONFIG_MLX5_CLS_ACT)

int mlx5e_rep_tc_init(struct mlx5e_rep_priv *rpriv);
void mlx5e_rep_tc_cleanup(struct mlx5e_rep_priv *rpriv);

@@ -21,7 +21,6 @@ void mlx5e_rep_tc_disable(struct mlx5e_priv *priv);

int mlx5e_rep_tc_event_port_affinity(struct mlx5e_priv *priv);

struct mlx5e_encap_entry;
void mlx5e_rep_update_flows(struct mlx5e_priv *priv,
			    struct mlx5e_encap_entry *e,
			    bool neigh_connected,
@@ -36,10 +35,47 @@ int mlx5e_rep_setup_tc(struct net_device *dev, enum tc_setup_type type,
		       void *type_data);
void mlx5e_rep_indr_clean_block_privs(struct mlx5e_rep_priv *rpriv);

struct mlx5e_tc_update_priv;
bool mlx5e_rep_tc_update_skb(struct mlx5_cqe64 *cqe,
			     struct sk_buff *skb,
			     struct mlx5e_tc_update_priv *tc_priv);
void mlx5_rep_tc_post_napi_receive(struct mlx5e_tc_update_priv *tc_priv);

#else /* CONFIG_MLX5_CLS_ACT */

struct mlx5e_rep_priv;
static inline int
mlx5e_rep_tc_init(struct mlx5e_rep_priv *rpriv) { return 0; }
static inline void
mlx5e_rep_tc_cleanup(struct mlx5e_rep_priv *rpriv) {}

static inline int
mlx5e_rep_tc_netdevice_event_register(struct mlx5e_rep_priv *rpriv) { return 0; }
static inline void
mlx5e_rep_tc_netdevice_event_unregister(struct mlx5e_rep_priv *rpriv) {}

static inline void
mlx5e_rep_tc_enable(struct mlx5e_priv *priv) {}
static inline void
mlx5e_rep_tc_disable(struct mlx5e_priv *priv) {}

static inline int
mlx5e_rep_tc_event_port_affinity(struct mlx5e_priv *priv) { return NOTIFY_DONE; }

static inline int
mlx5e_rep_setup_tc(struct net_device *dev, enum tc_setup_type type,
		   void *type_data) { return -EOPNOTSUPP; }

static inline void
mlx5e_rep_indr_clean_block_privs(struct mlx5e_rep_priv *rpriv) {}

struct mlx5e_tc_update_priv;
static inline bool
mlx5e_rep_tc_update_skb(struct mlx5_cqe64 *cqe,
			struct sk_buff *skb,
			struct mlx5e_tc_update_priv *tc_priv) { return true; }
static inline void
mlx5_rep_tc_post_napi_receive(struct mlx5e_tc_update_priv *tc_priv) {}

#endif /* CONFIG_MLX5_CLS_ACT */

#endif /* __MLX5_EN_REP_TC_H__ */
+2 −2
Original line number Diff line number Diff line
@@ -3728,7 +3728,7 @@ static int set_feature_cvlan_filter(struct net_device *netdev, bool enable)
	return 0;
}

#ifdef CONFIG_MLX5_ESWITCH
#if IS_ENABLED(CONFIG_MLX5_CLS_ACT)
static int set_feature_tc_num_filters(struct net_device *netdev, bool enable)
{
	struct mlx5e_priv *priv = netdev_priv(netdev);
@@ -3839,7 +3839,7 @@ int mlx5e_set_features(struct net_device *netdev, netdev_features_t features)
	err |= MLX5E_HANDLE_FEATURE(NETIF_F_LRO, set_feature_lro);
	err |= MLX5E_HANDLE_FEATURE(NETIF_F_HW_VLAN_CTAG_FILTER,
				    set_feature_cvlan_filter);
#ifdef CONFIG_MLX5_ESWITCH
#if IS_ENABLED(CONFIG_MLX5_CLS_ACT)
	err |= MLX5E_HANDLE_FEATURE(NETIF_F_HW_TC, set_feature_tc_num_filters);
#endif
	err |= MLX5E_HANDLE_FEATURE(NETIF_F_RXALL, set_feature_rx_all);
Loading