net/mlx5e: Add RSS support for hairpin
[sfrench/cifs-2.6.git] / drivers / net / ethernet / mellanox / mlx5 / core / en.h
index 543060c305a073c0457cc31ae7318f425a0e7c49..a3536e051052b46a9a3b6d2035e56c48a766c58c 100644 (file)
 #include <linux/mlx5/port.h>
 #include <linux/mlx5/vport.h>
 #include <linux/mlx5/transobj.h>
+#include <linux/mlx5/fs.h>
 #include <linux/rhashtable.h>
 #include <net/switchdev.h>
+#include <net/xdp.h>
+#include <linux/net_dim.h>
 #include "wq.h"
 #include "mlx5_core.h"
 #include "en_stats.h"
@@ -226,12 +229,6 @@ enum mlx5e_priv_flag {
 #define MLX5E_MAX_BW_ALLOC 100 /* Max percentage of BW allocation */
 #endif
 
-struct mlx5e_cq_moder {
-       u16 usec;
-       u16 pkts;
-       u8 cq_period_mode;
-};
-
 struct mlx5e_params {
        u8  log_sq_size;
        u8  rq_wq_type;
@@ -242,8 +239,8 @@ struct mlx5e_params {
        u16 num_channels;
        u8  num_tc;
        bool rx_cqe_compress_def;
-       struct mlx5e_cq_moder rx_cq_moderation;
-       struct mlx5e_cq_moder tx_cq_moderation;
+       struct net_dim_cq_moder rx_cq_moderation;
+       struct net_dim_cq_moder tx_cq_moderation;
        bool lro_en;
        u32 lro_wqe_sz;
        u16 tx_max_inline;
@@ -253,7 +250,7 @@ struct mlx5e_params {
        u32 indirection_rqt[MLX5E_INDIR_RQT_SIZE];
        bool vlan_strip_disable;
        bool scatter_fcs_en;
-       bool rx_am_enabled;
+       bool rx_dim_enabled;
        u32 lro_timeout;
        u32 pflags;
        struct bpf_prog *xdp_prog;
@@ -472,32 +469,6 @@ struct mlx5e_mpw_info {
        u16 skbs_frags[MLX5_MPWRQ_PAGES_PER_WQE];
 };
 
-struct mlx5e_rx_am_stats {
-       int ppms; /* packets per msec */
-       int bpms; /* bytes per msec */
-       int epms; /* events per msec */
-};
-
-struct mlx5e_rx_am_sample {
-       ktime_t time;
-       u32     pkt_ctr;
-       u32     byte_ctr;
-       u16     event_ctr;
-};
-
-struct mlx5e_rx_am { /* Adaptive Moderation */
-       u8                                      state;
-       struct mlx5e_rx_am_stats                prev_stats;
-       struct mlx5e_rx_am_sample               start_sample;
-       struct work_struct                      work;
-       u8                                      profile_ix;
-       u8                                      mode;
-       u8                                      tune_state;
-       u8                                      steps_right;
-       u8                                      steps_left;
-       u8                                      tired;
-};
-
 /* a single cache unit is capable to serve one napi call (for non-striding rq)
  * or a MPWQE (for striding rq).
  */
@@ -558,7 +529,7 @@ struct mlx5e_rq {
        unsigned long          state;
        int                    ix;
 
-       struct mlx5e_rx_am     am; /* Adaptive Moderation */
+       struct net_dim         dim; /* Dynamic Interrupt Moderation */
 
        /* XDP */
        struct bpf_prog       *xdp_prog;
@@ -571,6 +542,9 @@ struct mlx5e_rq {
        u32                    rqn;
        struct mlx5_core_dev  *mdev;
        struct mlx5_core_mkey  umr_mkey;
+
+       /* XDP read-mostly */
+       struct xdp_rxq_info    xdp_rxq;
 } ____cacheline_aligned_in_smp;
 
 struct mlx5e_channel {
@@ -655,6 +629,7 @@ struct mlx5e_tc_table {
        struct rhashtable               ht;
 
        DECLARE_HASHTABLE(mod_hdr_tbl, 8);
+       DECLARE_HASHTABLE(hairpin_tbl, 8);
 };
 
 struct mlx5e_vlan_table {
@@ -722,6 +697,11 @@ enum {
        MLX5E_ARFS_FT_LEVEL
 };
 
+enum {
+       MLX5E_TC_FT_LEVEL = 0,
+       MLX5E_TC_TTC_FT_LEVEL,
+};
+
 struct mlx5e_ethtool_table {
        struct mlx5_flow_table *ft;
        int                    num_rules;
@@ -860,10 +840,6 @@ void mlx5e_dealloc_rx_wqe(struct mlx5e_rq *rq, u16 ix);
 void mlx5e_dealloc_rx_mpwqe(struct mlx5e_rq *rq, u16 ix);
 void mlx5e_free_rx_mpwqe(struct mlx5e_rq *rq, struct mlx5e_mpw_info *wi);
 
-void mlx5e_rx_am(struct mlx5e_rq *rq);
-void mlx5e_rx_am_work(struct work_struct *work);
-struct mlx5e_cq_moder mlx5e_am_get_def_profile(u8 rx_cq_period_mode);
-
 void mlx5e_update_stats(struct mlx5e_priv *priv, bool full);
 
 int mlx5e_create_flow_steering(struct mlx5e_priv *priv);
@@ -895,7 +871,7 @@ int mlx5e_vlan_rx_kill_vid(struct net_device *dev, __always_unused __be16 proto,
                           u16 vid);
 void mlx5e_enable_cvlan_filter(struct mlx5e_priv *priv);
 void mlx5e_disable_cvlan_filter(struct mlx5e_priv *priv);
-void mlx5e_timestamp_set(struct mlx5e_priv *priv);
+void mlx5e_timestamp_init(struct mlx5e_priv *priv);
 
 struct mlx5e_redirect_rqt_param {
        bool is_rss;
@@ -1054,11 +1030,26 @@ int mlx5e_create_direct_tirs(struct mlx5e_priv *priv);
 void mlx5e_destroy_direct_tirs(struct mlx5e_priv *priv);
 void mlx5e_destroy_rqt(struct mlx5e_priv *priv, struct mlx5e_rqt *rqt);
 
-int mlx5e_create_ttc_table(struct mlx5e_priv *priv);
-void mlx5e_destroy_ttc_table(struct mlx5e_priv *priv);
+struct ttc_params {
+       struct mlx5_flow_table_attr ft_attr;
+       u32 any_tt_tirn;
+       u32 indir_tirn[MLX5E_NUM_INDIR_TIRS];
+       struct mlx5e_ttc_table *inner_ttc;
+};
+
+void mlx5e_set_ttc_basic_params(struct mlx5e_priv *priv, struct ttc_params *ttc_params);
+void mlx5e_set_ttc_ft_params(struct ttc_params *ttc_params);
+void mlx5e_set_inner_ttc_ft_params(struct ttc_params *ttc_params);
 
-int mlx5e_create_inner_ttc_table(struct mlx5e_priv *priv);
-void mlx5e_destroy_inner_ttc_table(struct mlx5e_priv *priv);
+int mlx5e_create_ttc_table(struct mlx5e_priv *priv, struct ttc_params *params,
+                          struct mlx5e_ttc_table *ttc);
+void mlx5e_destroy_ttc_table(struct mlx5e_priv *priv,
+                            struct mlx5e_ttc_table *ttc);
+
+int mlx5e_create_inner_ttc_table(struct mlx5e_priv *priv, struct ttc_params *params,
+                                struct mlx5e_ttc_table *ttc);
+void mlx5e_destroy_inner_ttc_table(struct mlx5e_priv *priv,
+                                  struct mlx5e_ttc_table *ttc);
 
 int mlx5e_create_tis(struct mlx5_core_dev *mdev, int tc,
                     u32 underlay_qpn, u32 *tisn);
@@ -1071,6 +1062,8 @@ int mlx5e_open(struct net_device *netdev);
 void mlx5e_update_stats_work(struct work_struct *work);
 u32 mlx5e_choose_lro_timeout(struct mlx5_core_dev *mdev, u32 wanted_timeout);
 
+int mlx5e_bits_invert(unsigned long a, int size);
+
 /* ethtool helpers */
 void mlx5e_ethtool_get_drvinfo(struct mlx5e_priv *priv,
                               struct ethtool_drvinfo *drvinfo);
@@ -1110,4 +1103,5 @@ void mlx5e_build_nic_params(struct mlx5_core_dev *mdev,
                            struct mlx5e_params *params,
                            u16 max_channels);
 u8 mlx5e_params_calculate_tx_min_inline(struct mlx5_core_dev *mdev);
+void mlx5e_rx_dim_work(struct work_struct *work);
 #endif /* __MLX5_EN_H__ */