net/mlx5e: Add CONFIG_MLX5_EN_ARFS for accelerated flow steering support
Add new mlx5 Kconfig flag to allow selecting accelerated flow steering support, and compile out en_arfs.c if not selected. Move arfs declarations and definitions to en/fs.h header file. Signed-off-by: Saeed Mahameed <saeedm@mellanox.com> Reviewed-by: Moshe Shemesh <moshe@mellanox.com>
This commit is contained in:
parent
fe6d86b3c3
commit
ec08004597
|
@ -35,6 +35,14 @@ config MLX5_CORE_EN
|
|||
---help---
|
||||
Ethernet support in Mellanox Technologies ConnectX-4 NIC.
|
||||
|
||||
config MLX5_EN_ARFS
|
||||
bool "Mellanox MLX5 ethernet accelerated receive flow steering (ARFS) support"
|
||||
depends on MLX5_CORE_EN && RFS_ACCEL
|
||||
default y
|
||||
---help---
|
||||
Mellanox MLX5 ethernet hardware-accelerated receive flow steering support,
|
||||
Enables ethernet netdevice arfs support and ntuple filtering.
|
||||
|
||||
config MLX5_EN_RXNFC
|
||||
bool "Mellanox MLX5 ethernet rx nfc flow steering support"
|
||||
depends on MLX5_CORE_EN
|
||||
|
|
|
@ -15,8 +15,9 @@ mlx5_core-$(CONFIG_MLX5_FPGA) += fpga/cmd.o fpga/core.o fpga/conn.o fpga/sdk.o \
|
|||
|
||||
mlx5_core-$(CONFIG_MLX5_CORE_EN) += en_main.o en_common.o en_fs.o en_ethtool.o \
|
||||
en_tx.o en_rx.o en_dim.o en_txrx.o en/xdp.o en_stats.o \
|
||||
en_arfs.o en_selftest.o en/port.o lib/vxlan.o
|
||||
en_selftest.o en/port.o lib/vxlan.o
|
||||
|
||||
mlx5_core-$(CONFIG_MLX5_EN_ARFS) += en_arfs.o
|
||||
mlx5_core-$(CONFIG_MLX5_EN_RXNFC) += en_fs_ethtool.o
|
||||
|
||||
mlx5_core-$(CONFIG_MLX5_MPFS) += lib/mpfs.o
|
||||
|
|
|
@ -660,12 +660,6 @@ struct mlx5e_l2_rule {
|
|||
struct mlx5_flow_handle *rule;
|
||||
};
|
||||
|
||||
struct mlx5e_flow_table {
|
||||
int num_groups;
|
||||
struct mlx5_flow_table *t;
|
||||
struct mlx5_flow_group **g;
|
||||
};
|
||||
|
||||
#define MLX5E_L2_ADDR_HASH_SIZE BIT(BITS_PER_BYTE)
|
||||
|
||||
struct mlx5e_tc_table {
|
||||
|
@ -708,38 +702,15 @@ struct mlx5e_ttc_table {
|
|||
struct mlx5_flow_handle *tunnel_rules[MLX5E_NUM_TUNNEL_TT];
|
||||
};
|
||||
|
||||
#define ARFS_HASH_SHIFT BITS_PER_BYTE
|
||||
#define ARFS_HASH_SIZE BIT(BITS_PER_BYTE)
|
||||
struct arfs_table {
|
||||
struct mlx5e_flow_table ft;
|
||||
struct mlx5_flow_handle *default_rule;
|
||||
struct hlist_head rules_hash[ARFS_HASH_SIZE];
|
||||
};
|
||||
|
||||
enum arfs_type {
|
||||
ARFS_IPV4_TCP,
|
||||
ARFS_IPV6_TCP,
|
||||
ARFS_IPV4_UDP,
|
||||
ARFS_IPV6_UDP,
|
||||
ARFS_NUM_TYPES,
|
||||
};
|
||||
|
||||
struct mlx5e_arfs_tables {
|
||||
struct arfs_table arfs_tables[ARFS_NUM_TYPES];
|
||||
/* Protect aRFS rules list */
|
||||
spinlock_t arfs_lock;
|
||||
struct list_head rules;
|
||||
int last_filter_id;
|
||||
struct workqueue_struct *wq;
|
||||
};
|
||||
|
||||
/* NIC prio FTS */
|
||||
enum {
|
||||
MLX5E_VLAN_FT_LEVEL = 0,
|
||||
MLX5E_L2_FT_LEVEL,
|
||||
MLX5E_TTC_FT_LEVEL,
|
||||
MLX5E_INNER_TTC_FT_LEVEL,
|
||||
#ifdef CONFIG_MLX5_EN_ARFS
|
||||
MLX5E_ARFS_FT_LEVEL
|
||||
#endif
|
||||
};
|
||||
|
||||
enum {
|
||||
|
@ -757,7 +728,9 @@ struct mlx5e_flow_steering {
|
|||
struct mlx5e_l2_table l2;
|
||||
struct mlx5e_ttc_table ttc;
|
||||
struct mlx5e_ttc_table inner_ttc;
|
||||
#ifdef CONFIG_MLX5_EN_ARFS
|
||||
struct mlx5e_arfs_tables arfs;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct mlx5e_rqt {
|
||||
|
@ -1028,32 +1001,6 @@ void mlx5e_dcbnl_init_app(struct mlx5e_priv *priv);
|
|||
void mlx5e_dcbnl_delete_app(struct mlx5e_priv *priv);
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_RFS_ACCEL
|
||||
static inline int mlx5e_arfs_create_tables(struct mlx5e_priv *priv)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void mlx5e_arfs_destroy_tables(struct mlx5e_priv *priv) {}
|
||||
|
||||
static inline int mlx5e_arfs_enable(struct mlx5e_priv *priv)
|
||||
{
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
static inline int mlx5e_arfs_disable(struct mlx5e_priv *priv)
|
||||
{
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
#else
|
||||
int mlx5e_arfs_create_tables(struct mlx5e_priv *priv);
|
||||
void mlx5e_arfs_destroy_tables(struct mlx5e_priv *priv);
|
||||
int mlx5e_arfs_enable(struct mlx5e_priv *priv);
|
||||
int mlx5e_arfs_disable(struct mlx5e_priv *priv);
|
||||
int mlx5e_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb,
|
||||
u16 rxq_index, u32 flow_id);
|
||||
#endif
|
||||
|
||||
int mlx5e_create_tir(struct mlx5_core_dev *mdev,
|
||||
struct mlx5e_tir *tir, u32 *in, int inlen);
|
||||
void mlx5e_destroy_tir(struct mlx5_core_dev *mdev,
|
||||
|
|
|
@ -4,6 +4,12 @@
|
|||
#ifndef __MLX5E_FLOW_STEER_H__
|
||||
#define __MLX5E_FLOW_STEER_H__
|
||||
|
||||
struct mlx5e_flow_table {
|
||||
int num_groups;
|
||||
struct mlx5_flow_table *t;
|
||||
struct mlx5_flow_group **g;
|
||||
};
|
||||
|
||||
#ifdef CONFIG_MLX5_EN_RXNFC
|
||||
|
||||
struct mlx5e_ethtool_table {
|
||||
|
@ -31,5 +37,45 @@ static inline void mlx5e_ethtool_init_steering(struct mlx5e_priv *priv) { }
|
|||
static inline void mlx5e_ethtool_cleanup_steering(struct mlx5e_priv *priv) { }
|
||||
#endif /* CONFIG_MLX5_EN_RXNFC */
|
||||
|
||||
#ifdef CONFIG_MLX5_EN_ARFS
|
||||
#define ARFS_HASH_SHIFT BITS_PER_BYTE
|
||||
#define ARFS_HASH_SIZE BIT(BITS_PER_BYTE)
|
||||
|
||||
struct arfs_table {
|
||||
struct mlx5e_flow_table ft;
|
||||
struct mlx5_flow_handle *default_rule;
|
||||
struct hlist_head rules_hash[ARFS_HASH_SIZE];
|
||||
};
|
||||
|
||||
enum arfs_type {
|
||||
ARFS_IPV4_TCP,
|
||||
ARFS_IPV6_TCP,
|
||||
ARFS_IPV4_UDP,
|
||||
ARFS_IPV6_UDP,
|
||||
ARFS_NUM_TYPES,
|
||||
};
|
||||
|
||||
struct mlx5e_arfs_tables {
|
||||
struct arfs_table arfs_tables[ARFS_NUM_TYPES];
|
||||
/* Protect aRFS rules list */
|
||||
spinlock_t arfs_lock;
|
||||
struct list_head rules;
|
||||
int last_filter_id;
|
||||
struct workqueue_struct *wq;
|
||||
};
|
||||
|
||||
int mlx5e_arfs_create_tables(struct mlx5e_priv *priv);
|
||||
void mlx5e_arfs_destroy_tables(struct mlx5e_priv *priv);
|
||||
int mlx5e_arfs_enable(struct mlx5e_priv *priv);
|
||||
int mlx5e_arfs_disable(struct mlx5e_priv *priv);
|
||||
int mlx5e_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb,
|
||||
u16 rxq_index, u32 flow_id);
|
||||
#else
|
||||
static inline int mlx5e_arfs_create_tables(struct mlx5e_priv *priv) { return 0; }
|
||||
static inline void mlx5e_arfs_destroy_tables(struct mlx5e_priv *priv) {}
|
||||
static inline int mlx5e_arfs_enable(struct mlx5e_priv *priv) { return -EOPNOTSUPP; }
|
||||
static inline int mlx5e_arfs_disable(struct mlx5e_priv *priv) { return -EOPNOTSUPP; }
|
||||
#endif
|
||||
|
||||
#endif /* __MLX5E_FLOW_STEER_H__ */
|
||||
|
||||
|
|
|
@ -30,8 +30,6 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_RFS_ACCEL
|
||||
|
||||
#include <linux/hash.h>
|
||||
#include <linux/mlx5/fs.h>
|
||||
#include <linux/ip.h>
|
||||
|
@ -738,4 +736,4 @@ int mlx5e_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb,
|
|||
spin_unlock_bh(&arfs->arfs_lock);
|
||||
return arfs_rule->filter_id;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -3624,7 +3624,7 @@ unlock:
|
|||
return err;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_RFS_ACCEL
|
||||
#ifdef CONFIG_MLX5_EN_ARFS
|
||||
static int set_feature_arfs(struct net_device *netdev, bool enable)
|
||||
{
|
||||
struct mlx5e_priv *priv = netdev_priv(netdev);
|
||||
|
@ -3679,7 +3679,7 @@ static int mlx5e_set_features(struct net_device *netdev,
|
|||
err |= MLX5E_HANDLE_FEATURE(NETIF_F_RXALL, set_feature_rx_all);
|
||||
err |= MLX5E_HANDLE_FEATURE(NETIF_F_RXFCS, set_feature_rx_fcs);
|
||||
err |= MLX5E_HANDLE_FEATURE(NETIF_F_HW_VLAN_CTAG_RX, set_feature_rx_vlan);
|
||||
#ifdef CONFIG_RFS_ACCEL
|
||||
#ifdef CONFIG_MLX5_EN_ARFS
|
||||
err |= MLX5E_HANDLE_FEATURE(NETIF_F_NTUPLE, set_feature_arfs);
|
||||
#endif
|
||||
|
||||
|
@ -4348,12 +4348,12 @@ static const struct net_device_ops mlx5e_netdev_ops = {
|
|||
.ndo_udp_tunnel_add = mlx5e_add_vxlan_port,
|
||||
.ndo_udp_tunnel_del = mlx5e_del_vxlan_port,
|
||||
.ndo_features_check = mlx5e_features_check,
|
||||
#ifdef CONFIG_RFS_ACCEL
|
||||
.ndo_rx_flow_steer = mlx5e_rx_flow_steer,
|
||||
#endif
|
||||
.ndo_tx_timeout = mlx5e_tx_timeout,
|
||||
.ndo_bpf = mlx5e_xdp,
|
||||
.ndo_xdp_xmit = mlx5e_xdp_xmit,
|
||||
#ifdef CONFIG_MLX5_EN_ARFS
|
||||
.ndo_rx_flow_steer = mlx5e_rx_flow_steer,
|
||||
#endif
|
||||
#ifdef CONFIG_NET_POLL_CONTROLLER
|
||||
.ndo_poll_controller = mlx5e_netpoll,
|
||||
#endif
|
||||
|
@ -4703,7 +4703,7 @@ static void mlx5e_build_nic_netdev(struct net_device *netdev)
|
|||
FT_CAP(identified_miss_table_mode) &&
|
||||
FT_CAP(flow_table_modify)) {
|
||||
netdev->hw_features |= NETIF_F_HW_TC;
|
||||
#ifdef CONFIG_RFS_ACCEL
|
||||
#ifdef CONFIG_MLX5_EN_ARFS
|
||||
netdev->hw_features |= NETIF_F_NTUPLE;
|
||||
#endif
|
||||
}
|
||||
|
@ -4947,7 +4947,7 @@ struct net_device *mlx5e_create_netdev(struct mlx5_core_dev *mdev,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_RFS_ACCEL
|
||||
#ifdef CONFIG_MLX5_EN_ARFS
|
||||
netdev->rx_cpu_rmap = mdev->rmap;
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue