net/mlx5e: Expand WQE stride when CQE compression is enabled
[cascardo/linux.git] / drivers / net / ethernet / mellanox / mlx5 / core / en.h
index 5c8e98c..e05abad 100644 (file)
@@ -48,6 +48,8 @@
 #include "mlx5_core.h"
 #include "en_stats.h"
 
+#define MLX5_SET_CFG(p, f, v) MLX5_SET(create_flow_group_in, p, f, v)
+
 #define MLX5E_MAX_NUM_TC       8
 
 #define MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE                0x6
 #define MLX5E_PARAMS_DEFAULT_LOG_RQ_SIZE_MPW            0x4
 #define MLX5E_PARAMS_MAXIMUM_LOG_RQ_SIZE_MPW            0x6
 
-#define MLX5_MPWRQ_LOG_NUM_STRIDES             11 /* >= 9, HW restriction */
 #define MLX5_MPWRQ_LOG_STRIDE_SIZE             6  /* >= 6, HW restriction */
-#define MLX5_MPWRQ_NUM_STRIDES                 BIT(MLX5_MPWRQ_LOG_NUM_STRIDES)
-#define MLX5_MPWRQ_STRIDE_SIZE                 BIT(MLX5_MPWRQ_LOG_STRIDE_SIZE)
-#define MLX5_MPWRQ_LOG_WQE_SZ                  (MLX5_MPWRQ_LOG_NUM_STRIDES +\
-                                                MLX5_MPWRQ_LOG_STRIDE_SIZE)
+#define MLX5_MPWRQ_LOG_STRIDE_SIZE_CQE_COMPRESS        8  /* >= 6, HW restriction */
+#define MLX5_MPWRQ_LOG_WQE_SZ                  17
 #define MLX5_MPWRQ_WQE_PAGE_ORDER  (MLX5_MPWRQ_LOG_WQE_SZ - PAGE_SHIFT > 0 ? \
                                    MLX5_MPWRQ_LOG_WQE_SZ - PAGE_SHIFT : 0)
 #define MLX5_MPWRQ_PAGES_PER_WQE               BIT(MLX5_MPWRQ_WQE_PAGE_ORDER)
@@ -152,9 +151,13 @@ struct mlx5e_umr_wqe {
 struct mlx5e_params {
        u8  log_sq_size;
        u8  rq_wq_type;
+       u8  mpwqe_log_stride_sz;
+       u8  mpwqe_log_num_strides;
        u8  log_rq_size;
        u16 num_channels;
        u8  num_tc;
+       bool rx_cqe_compress_admin;
+       bool rx_cqe_compress;
        u16 rx_cq_moderation_usec;
        u16 rx_cq_moderation_pkts;
        u16 tx_cq_moderation_usec;
@@ -200,6 +203,13 @@ struct mlx5e_cq {
        struct mlx5e_channel      *channel;
        struct mlx5e_priv         *priv;
 
+       /* cqe decompression */
+       struct mlx5_cqe64          title;
+       struct mlx5_mini_cqe8      mini_arr[MLX5_MINI_CQE_ARRAY_SIZE];
+       u8                         mini_arr_idx;
+       u16                        decmprs_left;
+       u16                        decmprs_wqe_counter;
+
        /* control */
        struct mlx5_wq_ctrl        wq_ctrl;
 } ____cacheline_aligned_in_smp;
@@ -238,6 +248,8 @@ struct mlx5e_rq {
        /* control */
        struct mlx5_wq_ctrl    wq_ctrl;
        u8                     wq_type;
+       u32                    mpwqe_stride_sz;
+       u32                    mpwqe_num_strides;
        u32                    rqn;
        struct mlx5e_channel  *channel;
        struct mlx5e_priv     *priv;
@@ -261,7 +273,7 @@ struct mlx5e_mpw_info {
        void (*dma_pre_sync)(struct device *pdev,
                             struct mlx5e_mpw_info *wi,
                             u32 wqe_offset, u32 len);
-       void (*add_skb_frag)(struct device *pdev,
+       void (*add_skb_frag)(struct mlx5e_rq *rq,
                             struct sk_buff *skb,
                             struct mlx5e_mpw_info *wi,
                             u32 page_idx, u32 frag_offset, u32 len);
@@ -388,62 +400,104 @@ enum mlx5e_traffic_types {
        MLX5E_NUM_INDIR_TIRS = MLX5E_TT_ANY,
 };
 
-struct mlx5e_eth_addr_info {
-       u8  addr[ETH_ALEN + 2];
-       u32 tt_vec;
-       struct mlx5_flow_rule *ft_rule[MLX5E_NUM_TT];
-};
-
-#define MLX5E_ETH_ADDR_HASH_SIZE (1 << BITS_PER_BYTE)
-
-struct mlx5e_eth_addr_db {
-       struct hlist_head          netdev_uc[MLX5E_ETH_ADDR_HASH_SIZE];
-       struct hlist_head          netdev_mc[MLX5E_ETH_ADDR_HASH_SIZE];
-       struct mlx5e_eth_addr_info broadcast;
-       struct mlx5e_eth_addr_info allmulti;
-       struct mlx5e_eth_addr_info promisc;
-       bool                       broadcast_enabled;
-       bool                       allmulti_enabled;
-       bool                       promisc_enabled;
-};
-
 enum {
        MLX5E_STATE_ASYNC_EVENTS_ENABLE,
        MLX5E_STATE_OPENED,
        MLX5E_STATE_DESTROYING,
 };
 
-struct mlx5e_vlan_db {
-       unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
-       struct mlx5_flow_rule   *active_vlans_rule[VLAN_N_VID];
-       struct mlx5_flow_rule   *untagged_rule;
-       struct mlx5_flow_rule   *any_vlan_rule;
-       bool          filter_disabled;
-};
-
 struct mlx5e_vxlan_db {
        spinlock_t                      lock; /* protect vxlan table */
        struct radix_tree_root          tree;
 };
 
+struct mlx5e_l2_rule {
+       u8  addr[ETH_ALEN + 2];
+       struct mlx5_flow_rule *rule;
+};
+
 struct mlx5e_flow_table {
        int num_groups;
-       struct mlx5_flow_table          *t;
-       struct mlx5_flow_group          **g;
+       struct mlx5_flow_table *t;
+       struct mlx5_flow_group **g;
 };
 
-struct mlx5e_tc_flow_table {
+#define MLX5E_L2_ADDR_HASH_SIZE BIT(BITS_PER_BYTE)
+
+struct mlx5e_tc_table {
        struct mlx5_flow_table          *t;
 
        struct rhashtable_params        ht_params;
        struct rhashtable               ht;
 };
 
-struct mlx5e_flow_tables {
-       struct mlx5_flow_namespace      *ns;
-       struct mlx5e_tc_flow_table      tc;
-       struct mlx5e_flow_table         vlan;
-       struct mlx5e_flow_table         main;
+struct mlx5e_vlan_table {
+       struct mlx5e_flow_table         ft;
+       unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
+       struct mlx5_flow_rule   *active_vlans_rule[VLAN_N_VID];
+       struct mlx5_flow_rule   *untagged_rule;
+       struct mlx5_flow_rule   *any_vlan_rule;
+       bool          filter_disabled;
+};
+
+struct mlx5e_l2_table {
+       struct mlx5e_flow_table    ft;
+       struct hlist_head          netdev_uc[MLX5E_L2_ADDR_HASH_SIZE];
+       struct hlist_head          netdev_mc[MLX5E_L2_ADDR_HASH_SIZE];
+       struct mlx5e_l2_rule       broadcast;
+       struct mlx5e_l2_rule       allmulti;
+       struct mlx5e_l2_rule       promisc;
+       bool                       broadcast_enabled;
+       bool                       allmulti_enabled;
+       bool                       promisc_enabled;
+};
+
+/* L3/L4 traffic type classifier */
+struct mlx5e_ttc_table {
+       struct mlx5e_flow_table  ft;
+       struct mlx5_flow_rule    *rules[MLX5E_NUM_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_rule    *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_ARFS_FT_LEVEL
+};
+
+struct mlx5e_flow_steering {
+       struct mlx5_flow_namespace      *ns;
+       struct mlx5e_tc_table           tc;
+       struct mlx5e_vlan_table         vlan;
+       struct mlx5e_l2_table           l2;
+       struct mlx5e_ttc_table          ttc;
+       struct mlx5e_arfs_tables        arfs;
 };
 
 struct mlx5e_direct_tir {
@@ -451,6 +505,11 @@ struct mlx5e_direct_tir {
        u32              rqtn;
 };
 
+enum {
+       MLX5E_TC_PRIO = 0,
+       MLX5E_NIC_PRIO
+};
+
 struct mlx5e_priv {
        /* priv data path fields - start */
        struct mlx5e_sq            **txq_to_sq_map;
@@ -472,12 +531,11 @@ struct mlx5e_priv {
        u32                        indir_tirn[MLX5E_NUM_INDIR_TIRS];
        struct mlx5e_direct_tir    direct_tir[MLX5E_MAX_NUM_CHANNELS];
 
-       struct mlx5e_flow_tables   fts;
-       struct mlx5e_eth_addr_db   eth_addr;
-       struct mlx5e_vlan_db       vlan;
+       struct mlx5e_flow_steering fs;
        struct mlx5e_vxlan_db      vxlan;
 
        struct mlx5e_params        params;
+       struct workqueue_struct    *wq;
        struct work_struct         update_carrier_work;
        struct work_struct         set_rx_mode_work;
        struct delayed_work        update_stats_work;
@@ -556,9 +614,10 @@ struct mlx5_cqe64 *mlx5e_get_cqe(struct mlx5e_cq *cq);
 
 void mlx5e_update_stats(struct mlx5e_priv *priv);
 
-int mlx5e_create_flow_tables(struct mlx5e_priv *priv);
-void mlx5e_destroy_flow_tables(struct mlx5e_priv *priv);
-void mlx5e_init_eth_addr(struct mlx5e_priv *priv);
+int mlx5e_create_flow_steering(struct mlx5e_priv *priv);
+void mlx5e_destroy_flow_steering(struct mlx5e_priv *priv);
+void mlx5e_init_l2_addr(struct mlx5e_priv *priv);
+void mlx5e_destroy_flow_table(struct mlx5e_flow_table *ft);
 void mlx5e_set_rx_mode_work(struct work_struct *work);
 
 void mlx5e_fill_hwstamp(struct mlx5e_tstamp *clock, u64 timestamp,
@@ -567,6 +626,7 @@ void mlx5e_timestamp_init(struct mlx5e_priv *priv);
 void mlx5e_timestamp_cleanup(struct mlx5e_priv *priv);
 int mlx5e_hwstamp_set(struct net_device *dev, struct ifreq *ifr);
 int mlx5e_hwstamp_get(struct net_device *dev, struct ifreq *ifr);
+void mlx5e_modify_rx_cqe_compression(struct mlx5e_priv *priv, bool val);
 
 int mlx5e_vlan_rx_add_vid(struct net_device *dev, __always_unused __be16 proto,
                          u16 vid);
@@ -635,6 +695,32 @@ extern const struct dcbnl_rtnl_ops mlx5e_dcbnl_ops;
 int mlx5e_dcbnl_ieee_setets_core(struct mlx5e_priv *priv, struct ieee_ets *ets);
 #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 -ENOTSUPP;
+}
+
+static inline int mlx5e_arfs_disable(struct mlx5e_priv *priv)
+{
+       return -ENOTSUPP;
+}
+#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
+
 u16 mlx5e_get_max_inline_cap(struct mlx5_core_dev *mdev);
 
 #endif /* __MLX5_EN_H__ */