aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSaeed Mahameed <saeedm@mellanox.com>2018-07-12 06:01:26 -0400
committerSaeed Mahameed <saeedm@mellanox.com>2018-08-13 15:50:17 -0400
commitec080045977073c5e69a7fddee3a8aef9bf62881 (patch)
tree126d3bb094a79c08adf2090dd2d7e05c5c596fbe
parentfe6d86b3c3165e6c55d6b0049a13d3b65371163a (diff)
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>
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/Kconfig8
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/Makefile3
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en.h61
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en/fs.h46
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c4
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/en_main.c14
6 files changed, 68 insertions, 68 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/Kconfig b/drivers/net/ethernet/mellanox/mlx5/core/Kconfig
index 1ff5f12ab12d..01f9ba1a2098 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/Kconfig
+++ b/drivers/net/ethernet/mellanox/mlx5/core/Kconfig
@@ -35,6 +35,14 @@ config MLX5_CORE_EN
35 ---help--- 35 ---help---
36 Ethernet support in Mellanox Technologies ConnectX-4 NIC. 36 Ethernet support in Mellanox Technologies ConnectX-4 NIC.
37 37
38config MLX5_EN_ARFS
39 bool "Mellanox MLX5 ethernet accelerated receive flow steering (ARFS) support"
40 depends on MLX5_CORE_EN && RFS_ACCEL
41 default y
42 ---help---
43 Mellanox MLX5 ethernet hardware-accelerated receive flow steering support,
44 Enables ethernet netdevice arfs support and ntuple filtering.
45
38config MLX5_EN_RXNFC 46config MLX5_EN_RXNFC
39 bool "Mellanox MLX5 ethernet rx nfc flow steering support" 47 bool "Mellanox MLX5 ethernet rx nfc flow steering support"
40 depends on MLX5_CORE_EN 48 depends on MLX5_CORE_EN
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/Makefile b/drivers/net/ethernet/mellanox/mlx5/core/Makefile
index 7b6f9d2c32c9..ae9da4b51487 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/Makefile
+++ b/drivers/net/ethernet/mellanox/mlx5/core/Makefile
@@ -15,8 +15,9 @@ mlx5_core-$(CONFIG_MLX5_FPGA) += fpga/cmd.o fpga/core.o fpga/conn.o fpga/sdk.o \
15 15
16mlx5_core-$(CONFIG_MLX5_CORE_EN) += en_main.o en_common.o en_fs.o en_ethtool.o \ 16mlx5_core-$(CONFIG_MLX5_CORE_EN) += en_main.o en_common.o en_fs.o en_ethtool.o \
17 en_tx.o en_rx.o en_dim.o en_txrx.o en/xdp.o en_stats.o \ 17 en_tx.o en_rx.o en_dim.o en_txrx.o en/xdp.o en_stats.o \
18 en_arfs.o en_selftest.o en/port.o lib/vxlan.o 18 en_selftest.o en/port.o lib/vxlan.o
19 19
20mlx5_core-$(CONFIG_MLX5_EN_ARFS) += en_arfs.o
20mlx5_core-$(CONFIG_MLX5_EN_RXNFC) += en_fs_ethtool.o 21mlx5_core-$(CONFIG_MLX5_EN_RXNFC) += en_fs_ethtool.o
21 22
22mlx5_core-$(CONFIG_MLX5_MPFS) += lib/mpfs.o 23mlx5_core-$(CONFIG_MLX5_MPFS) += lib/mpfs.o
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h
index 19728f9f25e7..8743bbe1baa2 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h
@@ -660,12 +660,6 @@ struct mlx5e_l2_rule {
660 struct mlx5_flow_handle *rule; 660 struct mlx5_flow_handle *rule;
661}; 661};
662 662
663struct mlx5e_flow_table {
664 int num_groups;
665 struct mlx5_flow_table *t;
666 struct mlx5_flow_group **g;
667};
668
669#define MLX5E_L2_ADDR_HASH_SIZE BIT(BITS_PER_BYTE) 663#define MLX5E_L2_ADDR_HASH_SIZE BIT(BITS_PER_BYTE)
670 664
671struct mlx5e_tc_table { 665struct mlx5e_tc_table {
@@ -708,38 +702,15 @@ struct mlx5e_ttc_table {
708 struct mlx5_flow_handle *tunnel_rules[MLX5E_NUM_TUNNEL_TT]; 702 struct mlx5_flow_handle *tunnel_rules[MLX5E_NUM_TUNNEL_TT];
709}; 703};
710 704
711#define ARFS_HASH_SHIFT BITS_PER_BYTE
712#define ARFS_HASH_SIZE BIT(BITS_PER_BYTE)
713struct arfs_table {
714 struct mlx5e_flow_table ft;
715 struct mlx5_flow_handle *default_rule;
716 struct hlist_head rules_hash[ARFS_HASH_SIZE];
717};
718
719enum arfs_type {
720 ARFS_IPV4_TCP,
721 ARFS_IPV6_TCP,
722 ARFS_IPV4_UDP,
723 ARFS_IPV6_UDP,
724 ARFS_NUM_TYPES,
725};
726
727struct mlx5e_arfs_tables {
728 struct arfs_table arfs_tables[ARFS_NUM_TYPES];
729 /* Protect aRFS rules list */
730 spinlock_t arfs_lock;
731 struct list_head rules;
732 int last_filter_id;
733 struct workqueue_struct *wq;
734};
735
736/* NIC prio FTS */ 705/* NIC prio FTS */
737enum { 706enum {
738 MLX5E_VLAN_FT_LEVEL = 0, 707 MLX5E_VLAN_FT_LEVEL = 0,
739 MLX5E_L2_FT_LEVEL, 708 MLX5E_L2_FT_LEVEL,
740 MLX5E_TTC_FT_LEVEL, 709 MLX5E_TTC_FT_LEVEL,
741 MLX5E_INNER_TTC_FT_LEVEL, 710 MLX5E_INNER_TTC_FT_LEVEL,
711#ifdef CONFIG_MLX5_EN_ARFS
742 MLX5E_ARFS_FT_LEVEL 712 MLX5E_ARFS_FT_LEVEL
713#endif
743}; 714};
744 715
745enum { 716enum {
@@ -757,7 +728,9 @@ struct mlx5e_flow_steering {
757 struct mlx5e_l2_table l2; 728 struct mlx5e_l2_table l2;
758 struct mlx5e_ttc_table ttc; 729 struct mlx5e_ttc_table ttc;
759 struct mlx5e_ttc_table inner_ttc; 730 struct mlx5e_ttc_table inner_ttc;
731#ifdef CONFIG_MLX5_EN_ARFS
760 struct mlx5e_arfs_tables arfs; 732 struct mlx5e_arfs_tables arfs;
733#endif
761}; 734};
762 735
763struct mlx5e_rqt { 736struct mlx5e_rqt {
@@ -1028,32 +1001,6 @@ void mlx5e_dcbnl_init_app(struct mlx5e_priv *priv);
1028void mlx5e_dcbnl_delete_app(struct mlx5e_priv *priv); 1001void mlx5e_dcbnl_delete_app(struct mlx5e_priv *priv);
1029#endif 1002#endif
1030 1003
1031#ifndef CONFIG_RFS_ACCEL
1032static inline int mlx5e_arfs_create_tables(struct mlx5e_priv *priv)
1033{
1034 return 0;
1035}
1036
1037static inline void mlx5e_arfs_destroy_tables(struct mlx5e_priv *priv) {}
1038
1039static inline int mlx5e_arfs_enable(struct mlx5e_priv *priv)
1040{
1041 return -EOPNOTSUPP;
1042}
1043
1044static inline int mlx5e_arfs_disable(struct mlx5e_priv *priv)
1045{
1046 return -EOPNOTSUPP;
1047}
1048#else
1049int mlx5e_arfs_create_tables(struct mlx5e_priv *priv);
1050void mlx5e_arfs_destroy_tables(struct mlx5e_priv *priv);
1051int mlx5e_arfs_enable(struct mlx5e_priv *priv);
1052int mlx5e_arfs_disable(struct mlx5e_priv *priv);
1053int mlx5e_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb,
1054 u16 rxq_index, u32 flow_id);
1055#endif
1056
1057int mlx5e_create_tir(struct mlx5_core_dev *mdev, 1004int mlx5e_create_tir(struct mlx5_core_dev *mdev,
1058 struct mlx5e_tir *tir, u32 *in, int inlen); 1005 struct mlx5e_tir *tir, u32 *in, int inlen);
1059void mlx5e_destroy_tir(struct mlx5_core_dev *mdev, 1006void mlx5e_destroy_tir(struct mlx5_core_dev *mdev,
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/fs.h b/drivers/net/ethernet/mellanox/mlx5/core/en/fs.h
index 50b0784787bc..adc00ae7e9e9 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/fs.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/fs.h
@@ -4,6 +4,12 @@
4#ifndef __MLX5E_FLOW_STEER_H__ 4#ifndef __MLX5E_FLOW_STEER_H__
5#define __MLX5E_FLOW_STEER_H__ 5#define __MLX5E_FLOW_STEER_H__
6 6
7struct mlx5e_flow_table {
8 int num_groups;
9 struct mlx5_flow_table *t;
10 struct mlx5_flow_group **g;
11};
12
7#ifdef CONFIG_MLX5_EN_RXNFC 13#ifdef CONFIG_MLX5_EN_RXNFC
8 14
9struct mlx5e_ethtool_table { 15struct mlx5e_ethtool_table {
@@ -31,5 +37,45 @@ static inline void mlx5e_ethtool_init_steering(struct mlx5e_priv *priv) { }
31static inline void mlx5e_ethtool_cleanup_steering(struct mlx5e_priv *priv) { } 37static inline void mlx5e_ethtool_cleanup_steering(struct mlx5e_priv *priv) { }
32#endif /* CONFIG_MLX5_EN_RXNFC */ 38#endif /* CONFIG_MLX5_EN_RXNFC */
33 39
40#ifdef CONFIG_MLX5_EN_ARFS
41#define ARFS_HASH_SHIFT BITS_PER_BYTE
42#define ARFS_HASH_SIZE BIT(BITS_PER_BYTE)
43
44struct arfs_table {
45 struct mlx5e_flow_table ft;
46 struct mlx5_flow_handle *default_rule;
47 struct hlist_head rules_hash[ARFS_HASH_SIZE];
48};
49
50enum arfs_type {
51 ARFS_IPV4_TCP,
52 ARFS_IPV6_TCP,
53 ARFS_IPV4_UDP,
54 ARFS_IPV6_UDP,
55 ARFS_NUM_TYPES,
56};
57
58struct mlx5e_arfs_tables {
59 struct arfs_table arfs_tables[ARFS_NUM_TYPES];
60 /* Protect aRFS rules list */
61 spinlock_t arfs_lock;
62 struct list_head rules;
63 int last_filter_id;
64 struct workqueue_struct *wq;
65};
66
67int mlx5e_arfs_create_tables(struct mlx5e_priv *priv);
68void mlx5e_arfs_destroy_tables(struct mlx5e_priv *priv);
69int mlx5e_arfs_enable(struct mlx5e_priv *priv);
70int mlx5e_arfs_disable(struct mlx5e_priv *priv);
71int mlx5e_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb,
72 u16 rxq_index, u32 flow_id);
73#else
74static inline int mlx5e_arfs_create_tables(struct mlx5e_priv *priv) { return 0; }
75static inline void mlx5e_arfs_destroy_tables(struct mlx5e_priv *priv) {}
76static inline int mlx5e_arfs_enable(struct mlx5e_priv *priv) { return -EOPNOTSUPP; }
77static inline int mlx5e_arfs_disable(struct mlx5e_priv *priv) { return -EOPNOTSUPP; }
78#endif
79
34#endif /* __MLX5E_FLOW_STEER_H__ */ 80#endif /* __MLX5E_FLOW_STEER_H__ */
35 81
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c b/drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c
index d258bb679271..45cdde694d20 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_arfs.c
@@ -30,8 +30,6 @@
30 * SOFTWARE. 30 * SOFTWARE.
31 */ 31 */
32 32
33#ifdef CONFIG_RFS_ACCEL
34
35#include <linux/hash.h> 33#include <linux/hash.h>
36#include <linux/mlx5/fs.h> 34#include <linux/mlx5/fs.h>
37#include <linux/ip.h> 35#include <linux/ip.h>
@@ -738,4 +736,4 @@ int mlx5e_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb,
738 spin_unlock_bh(&arfs->arfs_lock); 736 spin_unlock_bh(&arfs->arfs_lock);
739 return arfs_rule->filter_id; 737 return arfs_rule->filter_id;
740} 738}
741#endif 739
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 2731ba2d8049..e09086f41365 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -3624,7 +3624,7 @@ unlock:
3624 return err; 3624 return err;
3625} 3625}
3626 3626
3627#ifdef CONFIG_RFS_ACCEL 3627#ifdef CONFIG_MLX5_EN_ARFS
3628static int set_feature_arfs(struct net_device *netdev, bool enable) 3628static int set_feature_arfs(struct net_device *netdev, bool enable)
3629{ 3629{
3630 struct mlx5e_priv *priv = netdev_priv(netdev); 3630 struct mlx5e_priv *priv = netdev_priv(netdev);
@@ -3679,7 +3679,7 @@ static int mlx5e_set_features(struct net_device *netdev,
3679 err |= MLX5E_HANDLE_FEATURE(NETIF_F_RXALL, set_feature_rx_all); 3679 err |= MLX5E_HANDLE_FEATURE(NETIF_F_RXALL, set_feature_rx_all);
3680 err |= MLX5E_HANDLE_FEATURE(NETIF_F_RXFCS, set_feature_rx_fcs); 3680 err |= MLX5E_HANDLE_FEATURE(NETIF_F_RXFCS, set_feature_rx_fcs);
3681 err |= MLX5E_HANDLE_FEATURE(NETIF_F_HW_VLAN_CTAG_RX, set_feature_rx_vlan); 3681 err |= MLX5E_HANDLE_FEATURE(NETIF_F_HW_VLAN_CTAG_RX, set_feature_rx_vlan);
3682#ifdef CONFIG_RFS_ACCEL 3682#ifdef CONFIG_MLX5_EN_ARFS
3683 err |= MLX5E_HANDLE_FEATURE(NETIF_F_NTUPLE, set_feature_arfs); 3683 err |= MLX5E_HANDLE_FEATURE(NETIF_F_NTUPLE, set_feature_arfs);
3684#endif 3684#endif
3685 3685
@@ -4348,12 +4348,12 @@ static const struct net_device_ops mlx5e_netdev_ops = {
4348 .ndo_udp_tunnel_add = mlx5e_add_vxlan_port, 4348 .ndo_udp_tunnel_add = mlx5e_add_vxlan_port,
4349 .ndo_udp_tunnel_del = mlx5e_del_vxlan_port, 4349 .ndo_udp_tunnel_del = mlx5e_del_vxlan_port,
4350 .ndo_features_check = mlx5e_features_check, 4350 .ndo_features_check = mlx5e_features_check,
4351#ifdef CONFIG_RFS_ACCEL
4352 .ndo_rx_flow_steer = mlx5e_rx_flow_steer,
4353#endif
4354 .ndo_tx_timeout = mlx5e_tx_timeout, 4351 .ndo_tx_timeout = mlx5e_tx_timeout,
4355 .ndo_bpf = mlx5e_xdp, 4352 .ndo_bpf = mlx5e_xdp,
4356 .ndo_xdp_xmit = mlx5e_xdp_xmit, 4353 .ndo_xdp_xmit = mlx5e_xdp_xmit,
4354#ifdef CONFIG_MLX5_EN_ARFS
4355 .ndo_rx_flow_steer = mlx5e_rx_flow_steer,
4356#endif
4357#ifdef CONFIG_NET_POLL_CONTROLLER 4357#ifdef CONFIG_NET_POLL_CONTROLLER
4358 .ndo_poll_controller = mlx5e_netpoll, 4358 .ndo_poll_controller = mlx5e_netpoll,
4359#endif 4359#endif
@@ -4703,7 +4703,7 @@ static void mlx5e_build_nic_netdev(struct net_device *netdev)
4703 FT_CAP(identified_miss_table_mode) && 4703 FT_CAP(identified_miss_table_mode) &&
4704 FT_CAP(flow_table_modify)) { 4704 FT_CAP(flow_table_modify)) {
4705 netdev->hw_features |= NETIF_F_HW_TC; 4705 netdev->hw_features |= NETIF_F_HW_TC;
4706#ifdef CONFIG_RFS_ACCEL 4706#ifdef CONFIG_MLX5_EN_ARFS
4707 netdev->hw_features |= NETIF_F_NTUPLE; 4707 netdev->hw_features |= NETIF_F_NTUPLE;
4708#endif 4708#endif
4709 } 4709 }
@@ -4947,7 +4947,7 @@ struct net_device *mlx5e_create_netdev(struct mlx5_core_dev *mdev,
4947 return NULL; 4947 return NULL;
4948 } 4948 }
4949 4949
4950#ifdef CONFIG_RFS_ACCEL 4950#ifdef CONFIG_MLX5_EN_ARFS
4951 netdev->rx_cpu_rmap = mdev->rmap; 4951 netdev->rx_cpu_rmap = mdev->rmap;
4952#endif 4952#endif
4953 4953