]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - drivers/net/ethernet/mellanox/mlx5/core/en_main.c
net/mlx5e: Extendable vport representor netdev private data
[mirror_ubuntu-bionic-kernel.git] / drivers / net / ethernet / mellanox / mlx5 / core / en_main.c
index 66c133757a5ee8daae122e93322306b1c5c44336..1afaca96a30d83afa47b084ac829c86a34176a04 100644 (file)
  */
 
 #include <net/tc_act/tc_gact.h>
-#include <linux/crash_dump.h>
 #include <net/pkt_cls.h>
 #include <linux/mlx5/fs.h>
 #include <net/vxlan.h>
 #include <linux/bpf.h>
+#include "eswitch.h"
 #include "en.h"
 #include "en_tc.h"
-#include "eswitch.h"
+#include "en_rep.h"
 #include "vxlan.h"
 
 struct mlx5e_rq_param {
        u32                     rqc[MLX5_ST_SZ_DW(rqc)];
        struct mlx5_wq_param    wq;
-       bool                    am_enabled;
 };
 
 struct mlx5e_sq_param {
        u32                        sqc[MLX5_ST_SZ_DW(sqc)];
        struct mlx5_wq_param       wq;
-       u16                        max_inline;
-       u8                         min_inline_mode;
-       enum mlx5e_sq_type         type;
 };
 
 struct mlx5e_cq_param {
@@ -79,49 +75,47 @@ static bool mlx5e_check_fragmented_striding_rq_cap(struct mlx5_core_dev *mdev)
                MLX5_CAP_ETH(mdev, reg_umr_sq);
 }
 
-void mlx5e_set_rq_type_params(struct mlx5e_priv *priv, u8 rq_type)
+void mlx5e_set_rq_type_params(struct mlx5_core_dev *mdev,
+                             struct mlx5e_params *params, u8 rq_type)
 {
-       priv->params.rq_wq_type = rq_type;
-       priv->params.lro_wqe_sz = MLX5E_PARAMS_DEFAULT_LRO_WQE_SZ;
-       switch (priv->params.rq_wq_type) {
+       params->rq_wq_type = rq_type;
+       params->lro_wqe_sz = MLX5E_PARAMS_DEFAULT_LRO_WQE_SZ;
+       switch (params->rq_wq_type) {
        case MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ:
-               priv->params.log_rq_size = is_kdump_kernel() ?
+               params->log_rq_size = is_kdump_kernel() ?
                        MLX5E_PARAMS_MINIMUM_LOG_RQ_SIZE_MPW :
                        MLX5E_PARAMS_DEFAULT_LOG_RQ_SIZE_MPW;
-               priv->params.mpwqe_log_stride_sz =
-                       MLX5E_GET_PFLAG(priv, MLX5E_PFLAG_RX_CQE_COMPRESS) ?
-                       MLX5_MPWRQ_CQE_CMPRS_LOG_STRIDE_SZ(priv->mdev) :
-                       MLX5_MPWRQ_DEF_LOG_STRIDE_SZ(priv->mdev);
-               priv->params.mpwqe_log_num_strides = MLX5_MPWRQ_LOG_WQE_SZ -
-                       priv->params.mpwqe_log_stride_sz;
+               params->mpwqe_log_stride_sz =
+                       MLX5E_GET_PFLAG(params, MLX5E_PFLAG_RX_CQE_COMPRESS) ?
+                       MLX5_MPWRQ_CQE_CMPRS_LOG_STRIDE_SZ(mdev) :
+                       MLX5_MPWRQ_DEF_LOG_STRIDE_SZ(mdev);
+               params->mpwqe_log_num_strides = MLX5_MPWRQ_LOG_WQE_SZ -
+                       params->mpwqe_log_stride_sz;
                break;
        default: /* MLX5_WQ_TYPE_LINKED_LIST */
-               priv->params.log_rq_size = is_kdump_kernel() ?
+               params->log_rq_size = is_kdump_kernel() ?
                        MLX5E_PARAMS_MINIMUM_LOG_RQ_SIZE :
                        MLX5E_PARAMS_DEFAULT_LOG_RQ_SIZE;
 
                /* Extra room needed for build_skb */
-               priv->params.lro_wqe_sz -= MLX5_RX_HEADROOM +
+               params->lro_wqe_sz -= MLX5_RX_HEADROOM +
                        SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
        }
-       priv->params.min_rx_wqes = mlx5_min_rx_wqes(priv->params.rq_wq_type,
-                                              BIT(priv->params.log_rq_size));
 
-       mlx5_core_info(priv->mdev,
-                      "MLX5E: StrdRq(%d) RqSz(%ld) StrdSz(%ld) RxCqeCmprss(%d)\n",
-                      priv->params.rq_wq_type == MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ,
-                      BIT(priv->params.log_rq_size),
-                      BIT(priv->params.mpwqe_log_stride_sz),
-                      MLX5E_GET_PFLAG(priv, MLX5E_PFLAG_RX_CQE_COMPRESS));
+       mlx5_core_info(mdev, "MLX5E: StrdRq(%d) RqSz(%ld) StrdSz(%ld) RxCqeCmprss(%d)\n",
+                      params->rq_wq_type == MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ,
+                      BIT(params->log_rq_size),
+                      BIT(params->mpwqe_log_stride_sz),
+                      MLX5E_GET_PFLAG(params, MLX5E_PFLAG_RX_CQE_COMPRESS));
 }
 
-static void mlx5e_set_rq_priv_params(struct mlx5e_priv *priv)
+static void mlx5e_set_rq_params(struct mlx5_core_dev *mdev, struct mlx5e_params *params)
 {
-       u8 rq_type = mlx5e_check_fragmented_striding_rq_cap(priv->mdev) &&
-                   !priv->xdp_prog ?
+       u8 rq_type = mlx5e_check_fragmented_striding_rq_cap(mdev) &&
+                   !params->xdp_prog ?
                    MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ :
                    MLX5_WQ_TYPE_LINKED_LIST;
-       mlx5e_set_rq_type_params(priv, rq_type);
+       mlx5e_set_rq_type_params(mdev, params, rq_type);
 }
 
 static void mlx5e_update_carrier(struct mlx5e_priv *priv)
@@ -174,15 +168,17 @@ unlock:
 
 static void mlx5e_update_sw_counters(struct mlx5e_priv *priv)
 {
-       struct mlx5e_sw_stats *s = &priv->stats.sw;
+       struct mlx5e_sw_stats temp, *s = &temp;
        struct mlx5e_rq_stats *rq_stats;
        struct mlx5e_sq_stats *sq_stats;
        u64 tx_offload_none = 0;
        int i, j;
 
        memset(s, 0, sizeof(*s));
-       for (i = 0; i < priv->params.num_channels; i++) {
-               rq_stats = &priv->channel[i]->rq.stats;
+       for (i = 0; i < priv->channels.num; i++) {
+               struct mlx5e_channel *c = priv->channels.c[i];
+
+               rq_stats = &c->rq.stats;
 
                s->rx_packets   += rq_stats->packets;
                s->rx_bytes     += rq_stats->bytes;
@@ -204,8 +200,8 @@ static void mlx5e_update_sw_counters(struct mlx5e_priv *priv)
                s->rx_cache_empty += rq_stats->cache_empty;
                s->rx_cache_busy  += rq_stats->cache_busy;
 
-               for (j = 0; j < priv->params.num_tc; j++) {
-                       sq_stats = &priv->channel[i]->sq[j].stats;
+               for (j = 0; j < priv->channels.params.num_tc; j++) {
+                       sq_stats = &c->sq[j].stats;
 
                        s->tx_packets           += sq_stats->packets;
                        s->tx_bytes             += sq_stats->bytes;
@@ -229,6 +225,7 @@ static void mlx5e_update_sw_counters(struct mlx5e_priv *priv)
        s->link_down_events_phy = MLX5_GET(ppcnt_reg,
                                priv->stats.pport.phy_counters,
                                counter_set.phys_layer_cntrs.link_down_events);
+       memcpy(&priv->stats.sw, s, sizeof(*s));
 }
 
 static void mlx5e_update_vport_counters(struct mlx5e_priv *priv)
@@ -243,7 +240,6 @@ static void mlx5e_update_vport_counters(struct mlx5e_priv *priv)
        MLX5_SET(query_vport_counter_in, in, op_mod, 0);
        MLX5_SET(query_vport_counter_in, in, other_vport, 0);
 
-       memset(out, 0, outlen);
        mlx5_cmd_exec(mdev, in, sizeof(in), out, outlen);
 }
 
@@ -402,8 +398,10 @@ static inline int mlx5e_get_wqe_mtt_sz(void)
                     MLX5_UMR_MTT_ALIGNMENT);
 }
 
-static inline void mlx5e_build_umr_wqe(struct mlx5e_rq *rq, struct mlx5e_sq *sq,
-                                      struct mlx5e_umr_wqe *wqe, u16 ix)
+static inline void mlx5e_build_umr_wqe(struct mlx5e_rq *rq,
+                                      struct mlx5e_icosq *sq,
+                                      struct mlx5e_umr_wqe *wqe,
+                                      u16 ix)
 {
        struct mlx5_wqe_ctrl_seg      *cseg = &wqe->ctrl;
        struct mlx5_wqe_umr_ctrl_seg *ucseg = &wqe->uctrl;
@@ -493,11 +491,10 @@ static void mlx5e_rq_free_mpwqe_info(struct mlx5e_rq *rq)
        kfree(rq->mpwqe.info);
 }
 
-static int mlx5e_create_umr_mkey(struct mlx5e_priv *priv,
+static int mlx5e_create_umr_mkey(struct mlx5_core_dev *mdev,
                                 u64 npages, u8 page_shift,
                                 struct mlx5_core_mkey *umr_mkey)
 {
-       struct mlx5_core_dev *mdev = priv->mdev;
        int inlen = MLX5_ST_SZ_BYTES(create_mkey_in);
        void *mkc;
        u32 *in;
@@ -531,21 +528,20 @@ static int mlx5e_create_umr_mkey(struct mlx5e_priv *priv,
        return err;
 }
 
-static int mlx5e_create_rq_umr_mkey(struct mlx5e_rq *rq)
+static int mlx5e_create_rq_umr_mkey(struct mlx5_core_dev *mdev, struct mlx5e_rq *rq)
 {
-       struct mlx5e_priv *priv = rq->priv;
-       u64 num_mtts = MLX5E_REQUIRED_MTTS(BIT(priv->params.log_rq_size));
+       u64 num_mtts = MLX5E_REQUIRED_MTTS(mlx5_wq_ll_get_size(&rq->wq));
 
-       return mlx5e_create_umr_mkey(priv, num_mtts, PAGE_SHIFT, &rq->umr_mkey);
+       return mlx5e_create_umr_mkey(mdev, num_mtts, PAGE_SHIFT, &rq->umr_mkey);
 }
 
-static int mlx5e_create_rq(struct mlx5e_channel *c,
-                          struct mlx5e_rq_param *param,
-                          struct mlx5e_rq *rq)
+static int mlx5e_alloc_rq(struct mlx5e_channel *c,
+                         struct mlx5e_params *params,
+                         struct mlx5e_rq_param *rqp,
+                         struct mlx5e_rq *rq)
 {
-       struct mlx5e_priv *priv = c->priv;
-       struct mlx5_core_dev *mdev = priv->mdev;
-       void *rqc = param->rqc;
+       struct mlx5_core_dev *mdev = c->mdev;
+       void *rqc = rqp->rqc;
        void *rqc_wq = MLX5_ADDR_OF(rqc, rqc, wq);
        u32 byte_count;
        u32 frag_sz;
@@ -554,9 +550,9 @@ static int mlx5e_create_rq(struct mlx5e_channel *c,
        int err;
        int i;
 
-       param->wq.db_numa_node = cpu_to_node(c->cpu);
+       rqp->wq.db_numa_node = cpu_to_node(c->cpu);
 
-       err = mlx5_wq_ll_create(mdev, &param->wq, rqc_wq, &rq->wq,
+       err = mlx5_wq_ll_create(mdev, &rqp->wq, rqc_wq, &rq->wq,
                                &rq->wq_ctrl);
        if (err)
                return err;
@@ -565,15 +561,15 @@ static int mlx5e_create_rq(struct mlx5e_channel *c,
 
        wq_sz = mlx5_wq_ll_get_size(&rq->wq);
 
-       rq->wq_type = priv->params.rq_wq_type;
+       rq->wq_type = params->rq_wq_type;
        rq->pdev    = c->pdev;
        rq->netdev  = c->netdev;
-       rq->tstamp  = &priv->tstamp;
+       rq->tstamp  = c->tstamp;
        rq->channel = c;
        rq->ix      = c->ix;
-       rq->priv    = c->priv;
+       rq->mdev    = mdev;
 
-       rq->xdp_prog = priv->xdp_prog ? bpf_prog_inc(priv->xdp_prog) : NULL;
+       rq->xdp_prog = params->xdp_prog ? bpf_prog_inc(params->xdp_prog) : NULL;
        if (IS_ERR(rq->xdp_prog)) {
                err = PTR_ERR(rq->xdp_prog);
                rq->xdp_prog = NULL;
@@ -588,24 +584,26 @@ static int mlx5e_create_rq(struct mlx5e_channel *c,
                rq->rx_headroom = MLX5_RX_HEADROOM;
        }
 
-       switch (priv->params.rq_wq_type) {
+       switch (rq->wq_type) {
        case MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ:
-               if (mlx5e_is_vf_vport_rep(priv)) {
-                       err = -EINVAL;
-                       goto err_rq_wq_destroy;
-               }
 
-               rq->handle_rx_cqe = mlx5e_handle_rx_cqe_mpwrq;
                rq->alloc_wqe = mlx5e_alloc_rx_mpwqe;
                rq->dealloc_wqe = mlx5e_dealloc_rx_mpwqe;
 
-               rq->mpwqe_stride_sz = BIT(priv->params.mpwqe_log_stride_sz);
-               rq->mpwqe_num_strides = BIT(priv->params.mpwqe_log_num_strides);
+               rq->handle_rx_cqe = c->priv->profile->rx_handlers.handle_rx_cqe_mpwqe;
+               if (!rq->handle_rx_cqe) {
+                       err = -EINVAL;
+                       netdev_err(c->netdev, "RX handler of MPWQE RQ is not set, err %d\n", err);
+                       goto err_rq_wq_destroy;
+               }
+
+               rq->mpwqe_stride_sz = BIT(params->mpwqe_log_stride_sz);
+               rq->mpwqe_num_strides = BIT(params->mpwqe_log_num_strides);
 
                rq->buff.wqe_sz = rq->mpwqe_stride_sz * rq->mpwqe_num_strides;
                byte_count = rq->buff.wqe_sz;
 
-               err = mlx5e_create_rq_umr_mkey(rq);
+               err = mlx5e_create_rq_umr_mkey(mdev, rq);
                if (err)
                        goto err_rq_wq_destroy;
                rq->mkey_be = cpu_to_be32(rq->umr_mkey.key);
@@ -621,18 +619,20 @@ static int mlx5e_create_rq(struct mlx5e_channel *c,
                        err = -ENOMEM;
                        goto err_rq_wq_destroy;
                }
-
-               if (mlx5e_is_vf_vport_rep(priv))
-                       rq->handle_rx_cqe = mlx5e_handle_rx_cqe_rep;
-               else
-                       rq->handle_rx_cqe = mlx5e_handle_rx_cqe;
-
                rq->alloc_wqe = mlx5e_alloc_rx_wqe;
                rq->dealloc_wqe = mlx5e_dealloc_rx_wqe;
 
-               rq->buff.wqe_sz = (priv->params.lro_en) ?
-                               priv->params.lro_wqe_sz :
-                               MLX5E_SW2HW_MTU(priv->netdev->mtu);
+               rq->handle_rx_cqe = c->priv->profile->rx_handlers.handle_rx_cqe;
+               if (!rq->handle_rx_cqe) {
+                       kfree(rq->dma_info);
+                       err = -EINVAL;
+                       netdev_err(c->netdev, "RX handler of RQ is not set, err %d\n", err);
+                       goto err_rq_wq_destroy;
+               }
+
+               rq->buff.wqe_sz = params->lro_en  ?
+                               params->lro_wqe_sz :
+                               MLX5E_SW2HW_MTU(c->netdev->mtu);
                byte_count = rq->buff.wqe_sz;
 
                /* calc the required page order */
@@ -656,8 +656,7 @@ static int mlx5e_create_rq(struct mlx5e_channel *c,
        }
 
        INIT_WORK(&rq->am.work, mlx5e_rx_am_work);
-       rq->am.mode = priv->params.rx_cq_period_mode;
-
+       rq->am.mode = params->rx_cq_period_mode;
        rq->page_cache.head = 0;
        rq->page_cache.tail = 0;
 
@@ -674,7 +673,7 @@ err_rq_wq_destroy:
        return err;
 }
 
-static void mlx5e_destroy_rq(struct mlx5e_rq *rq)
+static void mlx5e_free_rq(struct mlx5e_rq *rq)
 {
        int i;
 
@@ -684,7 +683,7 @@ static void mlx5e_destroy_rq(struct mlx5e_rq *rq)
        switch (rq->wq_type) {
        case MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ:
                mlx5e_rq_free_mpwqe_info(rq);
-               mlx5_core_destroy_mkey(rq->priv->mdev, &rq->umr_mkey);
+               mlx5_core_destroy_mkey(rq->mdev, &rq->umr_mkey);
                break;
        default: /* MLX5_WQ_TYPE_LINKED_LIST */
                kfree(rq->dma_info);
@@ -699,10 +698,10 @@ static void mlx5e_destroy_rq(struct mlx5e_rq *rq)
        mlx5_wq_destroy(&rq->wq_ctrl);
 }
 
-static int mlx5e_enable_rq(struct mlx5e_rq *rq, struct mlx5e_rq_param *param)
+static int mlx5e_create_rq(struct mlx5e_rq *rq,
+                          struct mlx5e_rq_param *param)
 {
-       struct mlx5e_priv *priv = rq->priv;
-       struct mlx5_core_dev *mdev = priv->mdev;
+       struct mlx5_core_dev *mdev = rq->mdev;
 
        void *in;
        void *rqc;
@@ -723,7 +722,6 @@ static int mlx5e_enable_rq(struct mlx5e_rq *rq, struct mlx5e_rq_param *param)
 
        MLX5_SET(rqc,  rqc, cqn,                rq->cq.mcq.cqn);
        MLX5_SET(rqc,  rqc, state,              MLX5_RQC_STATE_RST);
-       MLX5_SET(rqc,  rqc, vsd, priv->params.vlan_strip_disable);
        MLX5_SET(wq,   wq,  log_wq_pg_sz,       rq->wq_ctrl.buf.page_shift -
                                                MLX5_ADAPTER_PAGE_SHIFT);
        MLX5_SET64(wq, wq,  dbr_addr,           rq->wq_ctrl.db.dma);
@@ -742,8 +740,7 @@ static int mlx5e_modify_rq_state(struct mlx5e_rq *rq, int curr_state,
                                 int next_state)
 {
        struct mlx5e_channel *c = rq->channel;
-       struct mlx5e_priv *priv = c->priv;
-       struct mlx5_core_dev *mdev = priv->mdev;
+       struct mlx5_core_dev *mdev = c->mdev;
 
        void *in;
        void *rqc;
@@ -767,7 +764,7 @@ static int mlx5e_modify_rq_state(struct mlx5e_rq *rq, int curr_state,
        return err;
 }
 
-static int mlx5e_modify_rq_vsd(struct mlx5e_rq *rq, bool vsd)
+static int mlx5e_modify_rq_scatter_fcs(struct mlx5e_rq *rq, bool enable)
 {
        struct mlx5e_channel *c = rq->channel;
        struct mlx5e_priv *priv = c->priv;
@@ -785,6 +782,35 @@ static int mlx5e_modify_rq_vsd(struct mlx5e_rq *rq, bool vsd)
 
        rqc = MLX5_ADDR_OF(modify_rq_in, in, ctx);
 
+       MLX5_SET(modify_rq_in, in, rq_state, MLX5_RQC_STATE_RDY);
+       MLX5_SET64(modify_rq_in, in, modify_bitmask,
+                  MLX5_MODIFY_RQ_IN_MODIFY_BITMASK_SCATTER_FCS);
+       MLX5_SET(rqc, rqc, scatter_fcs, enable);
+       MLX5_SET(rqc, rqc, state, MLX5_RQC_STATE_RDY);
+
+       err = mlx5_core_modify_rq(mdev, rq->rqn, in, inlen);
+
+       kvfree(in);
+
+       return err;
+}
+
+static int mlx5e_modify_rq_vsd(struct mlx5e_rq *rq, bool vsd)
+{
+       struct mlx5e_channel *c = rq->channel;
+       struct mlx5_core_dev *mdev = c->mdev;
+       void *in;
+       void *rqc;
+       int inlen;
+       int err;
+
+       inlen = MLX5_ST_SZ_BYTES(modify_rq_in);
+       in = mlx5_vzalloc(inlen);
+       if (!in)
+               return -ENOMEM;
+
+       rqc = MLX5_ADDR_OF(modify_rq_in, in, ctx);
+
        MLX5_SET(modify_rq_in, in, rq_state, MLX5_RQC_STATE_RDY);
        MLX5_SET64(modify_rq_in, in, modify_bitmask,
                   MLX5_MODIFY_RQ_IN_MODIFY_BITMASK_VSD);
@@ -798,25 +824,28 @@ static int mlx5e_modify_rq_vsd(struct mlx5e_rq *rq, bool vsd)
        return err;
 }
 
-static void mlx5e_disable_rq(struct mlx5e_rq *rq)
+static void mlx5e_destroy_rq(struct mlx5e_rq *rq)
 {
-       mlx5_core_destroy_rq(rq->priv->mdev, rq->rqn);
+       mlx5_core_destroy_rq(rq->mdev, rq->rqn);
 }
 
 static int mlx5e_wait_for_min_rx_wqes(struct mlx5e_rq *rq)
 {
        unsigned long exp_time = jiffies + msecs_to_jiffies(20000);
        struct mlx5e_channel *c = rq->channel;
-       struct mlx5e_priv *priv = c->priv;
+
        struct mlx5_wq_ll *wq = &rq->wq;
+       u16 min_wqes = mlx5_min_rx_wqes(rq->wq_type, mlx5_wq_ll_get_size(wq));
 
        while (time_before(jiffies, exp_time)) {
-               if (wq->cur_sz >= priv->params.min_rx_wqes)
+               if (wq->cur_sz >= min_wqes)
                        return 0;
 
                msleep(20);
        }
 
+       netdev_warn(c->netdev, "Failed to get min RX wqes on RQN[0x%x] wq cur_sz(%d) min_rx_wqes(%d)\n",
+                   rq->rqn, wq->cur_sz, min_wqes);
        return -ETIMEDOUT;
 }
 
@@ -842,83 +871,128 @@ static void mlx5e_free_rx_descs(struct mlx5e_rq *rq)
 }
 
 static int mlx5e_open_rq(struct mlx5e_channel *c,
+                        struct mlx5e_params *params,
                         struct mlx5e_rq_param *param,
                         struct mlx5e_rq *rq)
 {
-       struct mlx5e_sq *sq = &c->icosq;
-       u16 pi = sq->pc & sq->wq.sz_m1;
        int err;
 
-       err = mlx5e_create_rq(c, param, rq);
+       err = mlx5e_alloc_rq(c, params, param, rq);
        if (err)
                return err;
 
-       err = mlx5e_enable_rq(rq, param);
+       err = mlx5e_create_rq(rq, param);
        if (err)
-               goto err_destroy_rq;
+               goto err_free_rq;
 
-       set_bit(MLX5E_RQ_STATE_ENABLED, &rq->state);
        err = mlx5e_modify_rq_state(rq, MLX5_RQC_STATE_RST, MLX5_RQC_STATE_RDY);
        if (err)
-               goto err_disable_rq;
+               goto err_destroy_rq;
 
-       if (param->am_enabled)
+       if (params->rx_am_enabled)
                set_bit(MLX5E_RQ_STATE_AM, &c->rq.state);
 
-       sq->db.ico_wqe[pi].opcode     = MLX5_OPCODE_NOP;
-       sq->db.ico_wqe[pi].num_wqebbs = 1;
-       mlx5e_send_nop(sq, true); /* trigger mlx5e_post_rx_wqes() */
-
        return 0;
 
-err_disable_rq:
-       clear_bit(MLX5E_RQ_STATE_ENABLED, &rq->state);
-       mlx5e_disable_rq(rq);
 err_destroy_rq:
        mlx5e_destroy_rq(rq);
+err_free_rq:
+       mlx5e_free_rq(rq);
 
        return err;
 }
 
-static void mlx5e_close_rq(struct mlx5e_rq *rq)
+static void mlx5e_activate_rq(struct mlx5e_rq *rq)
+{
+       struct mlx5e_icosq *sq = &rq->channel->icosq;
+       u16 pi = sq->pc & sq->wq.sz_m1;
+       struct mlx5e_tx_wqe *nopwqe;
+
+       set_bit(MLX5E_RQ_STATE_ENABLED, &rq->state);
+       sq->db.ico_wqe[pi].opcode     = MLX5_OPCODE_NOP;
+       sq->db.ico_wqe[pi].num_wqebbs = 1;
+       nopwqe = mlx5e_post_nop(&sq->wq, sq->sqn, &sq->pc);
+       mlx5e_notify_hw(&sq->wq, sq->pc, sq->uar_map, &nopwqe->ctrl);
+}
+
+static void mlx5e_deactivate_rq(struct mlx5e_rq *rq)
 {
        clear_bit(MLX5E_RQ_STATE_ENABLED, &rq->state);
        napi_synchronize(&rq->channel->napi); /* prevent mlx5e_post_rx_wqes */
-       cancel_work_sync(&rq->am.work);
+}
 
-       mlx5e_disable_rq(rq);
-       mlx5e_free_rx_descs(rq);
+static void mlx5e_close_rq(struct mlx5e_rq *rq)
+{
+       cancel_work_sync(&rq->am.work);
        mlx5e_destroy_rq(rq);
+       mlx5e_free_rx_descs(rq);
+       mlx5e_free_rq(rq);
 }
 
-static void mlx5e_free_sq_xdp_db(struct mlx5e_sq *sq)
+static void mlx5e_free_xdpsq_db(struct mlx5e_xdpsq *sq)
 {
-       kfree(sq->db.xdp.di);
-       kfree(sq->db.xdp.wqe_info);
+       kfree(sq->db.di);
 }
 
-static int mlx5e_alloc_sq_xdp_db(struct mlx5e_sq *sq, int numa)
+static int mlx5e_alloc_xdpsq_db(struct mlx5e_xdpsq *sq, int numa)
 {
        int wq_sz = mlx5_wq_cyc_get_size(&sq->wq);
 
-       sq->db.xdp.di = kzalloc_node(sizeof(*sq->db.xdp.di) * wq_sz,
+       sq->db.di = kzalloc_node(sizeof(*sq->db.di) * wq_sz,
                                     GFP_KERNEL, numa);
-       sq->db.xdp.wqe_info = kzalloc_node(sizeof(*sq->db.xdp.wqe_info) * wq_sz,
-                                          GFP_KERNEL, numa);
-       if (!sq->db.xdp.di || !sq->db.xdp.wqe_info) {
-               mlx5e_free_sq_xdp_db(sq);
+       if (!sq->db.di) {
+               mlx5e_free_xdpsq_db(sq);
                return -ENOMEM;
        }
 
        return 0;
 }
 
-static void mlx5e_free_sq_ico_db(struct mlx5e_sq *sq)
+static int mlx5e_alloc_xdpsq(struct mlx5e_channel *c,
+                            struct mlx5e_params *params,
+                            struct mlx5e_sq_param *param,
+                            struct mlx5e_xdpsq *sq)
+{
+       void *sqc_wq               = MLX5_ADDR_OF(sqc, param->sqc, wq);
+       struct mlx5_core_dev *mdev = c->mdev;
+       int err;
+
+       sq->pdev      = c->pdev;
+       sq->mkey_be   = c->mkey_be;
+       sq->channel   = c;
+       sq->uar_map   = mdev->mlx5e_res.bfreg.map;
+       sq->min_inline_mode = params->tx_min_inline_mode;
+
+       param->wq.db_numa_node = cpu_to_node(c->cpu);
+       err = mlx5_wq_cyc_create(mdev, &param->wq, sqc_wq, &sq->wq, &sq->wq_ctrl);
+       if (err)
+               return err;
+       sq->wq.db = &sq->wq.db[MLX5_SND_DBR];
+
+       err = mlx5e_alloc_xdpsq_db(sq, cpu_to_node(c->cpu));
+       if (err)
+               goto err_sq_wq_destroy;
+
+       return 0;
+
+err_sq_wq_destroy:
+       mlx5_wq_destroy(&sq->wq_ctrl);
+
+       return err;
+}
+
+static void mlx5e_free_xdpsq(struct mlx5e_xdpsq *sq)
+{
+       mlx5e_free_xdpsq_db(sq);
+       mlx5_wq_destroy(&sq->wq_ctrl);
+}
+
+static void mlx5e_free_icosq_db(struct mlx5e_icosq *sq)
 {
        kfree(sq->db.ico_wqe);
 }
 
-static int mlx5e_alloc_sq_ico_db(struct mlx5e_sq *sq, int numa)
+static int mlx5e_alloc_icosq_db(struct mlx5e_icosq *sq, int numa)
 {
        u8 wq_sz = mlx5_wq_cyc_get_size(&sq->wq);
 
@@ -930,155 +1004,128 @@ static int mlx5e_alloc_sq_ico_db(struct mlx5e_sq *sq, int numa)
        return 0;
 }
 
-static void mlx5e_free_sq_txq_db(struct mlx5e_sq *sq)
+static int mlx5e_alloc_icosq(struct mlx5e_channel *c,
+                            struct mlx5e_sq_param *param,
+                            struct mlx5e_icosq *sq)
 {
-       kfree(sq->db.txq.wqe_info);
-       kfree(sq->db.txq.dma_fifo);
-       kfree(sq->db.txq.skb);
-}
+       void *sqc_wq               = MLX5_ADDR_OF(sqc, param->sqc, wq);
+       struct mlx5_core_dev *mdev = c->mdev;
+       int err;
 
-static int mlx5e_alloc_sq_txq_db(struct mlx5e_sq *sq, int numa)
-{
-       int wq_sz = mlx5_wq_cyc_get_size(&sq->wq);
-       int df_sz = wq_sz * MLX5_SEND_WQEBB_NUM_DS;
+       sq->pdev      = c->pdev;
+       sq->mkey_be   = c->mkey_be;
+       sq->channel   = c;
+       sq->uar_map   = mdev->mlx5e_res.bfreg.map;
 
-       sq->db.txq.skb = kzalloc_node(wq_sz * sizeof(*sq->db.txq.skb),
-                                     GFP_KERNEL, numa);
-       sq->db.txq.dma_fifo = kzalloc_node(df_sz * sizeof(*sq->db.txq.dma_fifo),
-                                          GFP_KERNEL, numa);
-       sq->db.txq.wqe_info = kzalloc_node(wq_sz * sizeof(*sq->db.txq.wqe_info),
-                                          GFP_KERNEL, numa);
-       if (!sq->db.txq.skb || !sq->db.txq.dma_fifo || !sq->db.txq.wqe_info) {
-               mlx5e_free_sq_txq_db(sq);
-               return -ENOMEM;
-       }
+       param->wq.db_numa_node = cpu_to_node(c->cpu);
+       err = mlx5_wq_cyc_create(mdev, &param->wq, sqc_wq, &sq->wq, &sq->wq_ctrl);
+       if (err)
+               return err;
+       sq->wq.db = &sq->wq.db[MLX5_SND_DBR];
 
-       sq->dma_fifo_mask = df_sz - 1;
+       err = mlx5e_alloc_icosq_db(sq, cpu_to_node(c->cpu));
+       if (err)
+               goto err_sq_wq_destroy;
+
+       sq->edge = (sq->wq.sz_m1 + 1) - MLX5E_ICOSQ_MAX_WQEBBS;
 
        return 0;
+
+err_sq_wq_destroy:
+       mlx5_wq_destroy(&sq->wq_ctrl);
+
+       return err;
 }
 
-static void mlx5e_free_sq_db(struct mlx5e_sq *sq)
+static void mlx5e_free_icosq(struct mlx5e_icosq *sq)
 {
-       switch (sq->type) {
-       case MLX5E_SQ_TXQ:
-               mlx5e_free_sq_txq_db(sq);
-               break;
-       case MLX5E_SQ_ICO:
-               mlx5e_free_sq_ico_db(sq);
-               break;
-       case MLX5E_SQ_XDP:
-               mlx5e_free_sq_xdp_db(sq);
-               break;
-       }
+       mlx5e_free_icosq_db(sq);
+       mlx5_wq_destroy(&sq->wq_ctrl);
 }
 
-static int mlx5e_alloc_sq_db(struct mlx5e_sq *sq, int numa)
+static void mlx5e_free_txqsq_db(struct mlx5e_txqsq *sq)
 {
-       switch (sq->type) {
-       case MLX5E_SQ_TXQ:
-               return mlx5e_alloc_sq_txq_db(sq, numa);
-       case MLX5E_SQ_ICO:
-               return mlx5e_alloc_sq_ico_db(sq, numa);
-       case MLX5E_SQ_XDP:
-               return mlx5e_alloc_sq_xdp_db(sq, numa);
-       }
-
-       return 0;
+       kfree(sq->db.wqe_info);
+       kfree(sq->db.dma_fifo);
 }
 
-static int mlx5e_sq_get_max_wqebbs(u8 sq_type)
+static int mlx5e_alloc_txqsq_db(struct mlx5e_txqsq *sq, int numa)
 {
-       switch (sq_type) {
-       case MLX5E_SQ_ICO:
-               return MLX5E_ICOSQ_MAX_WQEBBS;
-       case MLX5E_SQ_XDP:
-               return MLX5E_XDP_TX_WQEBBS;
+       int wq_sz = mlx5_wq_cyc_get_size(&sq->wq);
+       int df_sz = wq_sz * MLX5_SEND_WQEBB_NUM_DS;
+
+       sq->db.dma_fifo = kzalloc_node(df_sz * sizeof(*sq->db.dma_fifo),
+                                          GFP_KERNEL, numa);
+       sq->db.wqe_info = kzalloc_node(wq_sz * sizeof(*sq->db.wqe_info),
+                                          GFP_KERNEL, numa);
+       if (!sq->db.dma_fifo || !sq->db.wqe_info) {
+               mlx5e_free_txqsq_db(sq);
+               return -ENOMEM;
        }
-       return MLX5_SEND_WQE_MAX_WQEBBS;
+
+       sq->dma_fifo_mask = df_sz - 1;
+
+       return 0;
 }
 
-static int mlx5e_create_sq(struct mlx5e_channel *c,
-                          int tc,
-                          struct mlx5e_sq_param *param,
-                          struct mlx5e_sq *sq)
+static int mlx5e_alloc_txqsq(struct mlx5e_channel *c,
+                            int txq_ix,
+                            struct mlx5e_params *params,
+                            struct mlx5e_sq_param *param,
+                            struct mlx5e_txqsq *sq)
 {
-       struct mlx5e_priv *priv = c->priv;
-       struct mlx5_core_dev *mdev = priv->mdev;
-
-       void *sqc = param->sqc;
-       void *sqc_wq = MLX5_ADDR_OF(sqc, sqc, wq);
+       void *sqc_wq               = MLX5_ADDR_OF(sqc, param->sqc, wq);
+       struct mlx5_core_dev *mdev = c->mdev;
        int err;
 
-       sq->type      = param->type;
        sq->pdev      = c->pdev;
-       sq->tstamp    = &priv->tstamp;
+       sq->tstamp    = c->tstamp;
        sq->mkey_be   = c->mkey_be;
        sq->channel   = c;
-       sq->tc        = tc;
-
-       err = mlx5_alloc_bfreg(mdev, &sq->bfreg, MLX5_CAP_GEN(mdev, bf), false);
-       if (err)
-               return err;
+       sq->txq_ix    = txq_ix;
+       sq->uar_map   = mdev->mlx5e_res.bfreg.map;
+       sq->max_inline      = params->tx_max_inline;
+       sq->min_inline_mode = params->tx_min_inline_mode;
 
-       sq->uar_map = sq->bfreg.map;
        param->wq.db_numa_node = cpu_to_node(c->cpu);
-
-       err = mlx5_wq_cyc_create(mdev, &param->wq, sqc_wq, &sq->wq,
-                                &sq->wq_ctrl);
+       err = mlx5_wq_cyc_create(mdev, &param->wq, sqc_wq, &sq->wq, &sq->wq_ctrl);
        if (err)
-               goto err_unmap_free_uar;
-
-       sq->wq.db       = &sq->wq.db[MLX5_SND_DBR];
-       if (sq->bfreg.wc)
-               set_bit(MLX5E_SQ_STATE_BF_ENABLE, &sq->state);
-
-       sq->bf_buf_size = (1 << MLX5_CAP_GEN(mdev, log_bf_reg_size)) / 2;
-       sq->max_inline  = param->max_inline;
-       sq->min_inline_mode = param->min_inline_mode;
+               return err;
+       sq->wq.db    = &sq->wq.db[MLX5_SND_DBR];
 
-       err = mlx5e_alloc_sq_db(sq, cpu_to_node(c->cpu));
+       err = mlx5e_alloc_txqsq_db(sq, cpu_to_node(c->cpu));
        if (err)
                goto err_sq_wq_destroy;
 
-       if (sq->type == MLX5E_SQ_TXQ) {
-               int txq_ix;
-
-               txq_ix = c->ix + tc * priv->params.num_channels;
-               sq->txq = netdev_get_tx_queue(priv->netdev, txq_ix);
-               priv->txq_to_sq_map[txq_ix] = sq;
-       }
-
-       sq->edge = (sq->wq.sz_m1 + 1) - mlx5e_sq_get_max_wqebbs(sq->type);
-       sq->bf_budget = MLX5E_SQ_BF_BUDGET;
+       sq->edge = (sq->wq.sz_m1 + 1) - MLX5_SEND_WQE_MAX_WQEBBS;
 
        return 0;
 
 err_sq_wq_destroy:
        mlx5_wq_destroy(&sq->wq_ctrl);
 
-err_unmap_free_uar:
-       mlx5_free_bfreg(mdev, &sq->bfreg);
-
        return err;
 }
 
-static void mlx5e_destroy_sq(struct mlx5e_sq *sq)
+static void mlx5e_free_txqsq(struct mlx5e_txqsq *sq)
 {
-       struct mlx5e_channel *c = sq->channel;
-       struct mlx5e_priv *priv = c->priv;
-
-       mlx5e_free_sq_db(sq);
+       mlx5e_free_txqsq_db(sq);
        mlx5_wq_destroy(&sq->wq_ctrl);
-       mlx5_free_bfreg(priv->mdev, &sq->bfreg);
 }
 
-static int mlx5e_enable_sq(struct mlx5e_sq *sq, struct mlx5e_sq_param *param)
-{
-       struct mlx5e_channel *c = sq->channel;
-       struct mlx5e_priv *priv = c->priv;
-       struct mlx5_core_dev *mdev = priv->mdev;
+struct mlx5e_create_sq_param {
+       struct mlx5_wq_ctrl        *wq_ctrl;
+       u32                         cqn;
+       u32                         tisn;
+       u8                          tis_lst_sz;
+       u8                          min_inline_mode;
+};
 
+static int mlx5e_create_sq(struct mlx5_core_dev *mdev,
+                          struct mlx5e_sq_param *param,
+                          struct mlx5e_create_sq_param *csp,
+                          u32 *sqn)
+{
        void *in;
        void *sqc;
        void *wq;
@@ -1086,7 +1133,7 @@ static int mlx5e_enable_sq(struct mlx5e_sq *sq, struct mlx5e_sq_param *param)
        int err;
 
        inlen = MLX5_ST_SZ_BYTES(create_sq_in) +
-               sizeof(u64) * sq->wq_ctrl.buf.npages;
+               sizeof(u64) * csp->wq_ctrl->buf.npages;
        in = mlx5_vzalloc(inlen);
        if (!in)
                return -ENOMEM;
@@ -1095,40 +1142,40 @@ static int mlx5e_enable_sq(struct mlx5e_sq *sq, struct mlx5e_sq_param *param)
        wq = MLX5_ADDR_OF(sqc, sqc, wq);
 
        memcpy(sqc, param->sqc, sizeof(param->sqc));
-
-       MLX5_SET(sqc,  sqc, tis_num_0, param->type == MLX5E_SQ_ICO ?
-                                      0 : priv->tisn[sq->tc]);
-       MLX5_SET(sqc,  sqc, cqn,                sq->cq.mcq.cqn);
+       MLX5_SET(sqc,  sqc, tis_lst_sz, csp->tis_lst_sz);
+       MLX5_SET(sqc,  sqc, tis_num_0, csp->tisn);
+       MLX5_SET(sqc,  sqc, cqn, csp->cqn);
 
        if (MLX5_CAP_ETH(mdev, wqe_inline_mode) == MLX5_CAP_INLINE_MODE_VPORT_CONTEXT)
-               MLX5_SET(sqc,  sqc, min_wqe_inline_mode, sq->min_inline_mode);
+               MLX5_SET(sqc,  sqc, min_wqe_inline_mode, csp->min_inline_mode);
 
-       MLX5_SET(sqc,  sqc, state,              MLX5_SQC_STATE_RST);
-       MLX5_SET(sqc,  sqc, tis_lst_sz, param->type == MLX5E_SQ_ICO ? 0 : 1);
+       MLX5_SET(sqc,  sqc, state, MLX5_SQC_STATE_RST);
 
        MLX5_SET(wq,   wq, wq_type,       MLX5_WQ_TYPE_CYCLIC);
-       MLX5_SET(wq,   wq, uar_page,      sq->bfreg.index);
-       MLX5_SET(wq,   wq, log_wq_pg_sz,  sq->wq_ctrl.buf.page_shift -
+       MLX5_SET(wq,   wq, uar_page,      mdev->mlx5e_res.bfreg.index);
+       MLX5_SET(wq,   wq, log_wq_pg_sz,  csp->wq_ctrl->buf.page_shift -
                                          MLX5_ADAPTER_PAGE_SHIFT);
-       MLX5_SET64(wq, wq, dbr_addr,      sq->wq_ctrl.db.dma);
+       MLX5_SET64(wq, wq, dbr_addr,      csp->wq_ctrl->db.dma);
 
-       mlx5_fill_page_array(&sq->wq_ctrl.buf,
-                            (__be64 *)MLX5_ADDR_OF(wq, wq, pas));
+       mlx5_fill_page_array(&csp->wq_ctrl->buf, (__be64 *)MLX5_ADDR_OF(wq, wq, pas));
 
-       err = mlx5_core_create_sq(mdev, in, inlen, &sq->sqn);
+       err = mlx5_core_create_sq(mdev, in, inlen, sqn);
 
        kvfree(in);
 
        return err;
 }
 
-static int mlx5e_modify_sq(struct mlx5e_sq *sq, int curr_state,
-                          int next_state, bool update_rl, int rl_index)
-{
-       struct mlx5e_channel *c = sq->channel;
-       struct mlx5e_priv *priv = c->priv;
-       struct mlx5_core_dev *mdev = priv->mdev;
+struct mlx5e_modify_sq_param {
+       int curr_state;
+       int next_state;
+       bool rl_update;
+       int rl_index;
+};
 
+static int mlx5e_modify_sq(struct mlx5_core_dev *mdev, u32 sqn,
+                          struct mlx5e_modify_sq_param *p)
+{
        void *in;
        void *sqc;
        int inlen;
@@ -1141,68 +1188,94 @@ static int mlx5e_modify_sq(struct mlx5e_sq *sq, int curr_state,
 
        sqc = MLX5_ADDR_OF(modify_sq_in, in, ctx);
 
-       MLX5_SET(modify_sq_in, in, sq_state, curr_state);
-       MLX5_SET(sqc, sqc, state, next_state);
-       if (update_rl && next_state == MLX5_SQC_STATE_RDY) {
+       MLX5_SET(modify_sq_in, in, sq_state, p->curr_state);
+       MLX5_SET(sqc, sqc, state, p->next_state);
+       if (p->rl_update && p->next_state == MLX5_SQC_STATE_RDY) {
                MLX5_SET64(modify_sq_in, in, modify_bitmask, 1);
-               MLX5_SET(sqc,  sqc, packet_pacing_rate_limit_index, rl_index);
+               MLX5_SET(sqc,  sqc, packet_pacing_rate_limit_index, p->rl_index);
        }
 
-       err = mlx5_core_modify_sq(mdev, sq->sqn, in, inlen);
+       err = mlx5_core_modify_sq(mdev, sqn, in, inlen);
 
        kvfree(in);
 
        return err;
 }
 
-static void mlx5e_disable_sq(struct mlx5e_sq *sq)
+static void mlx5e_destroy_sq(struct mlx5_core_dev *mdev, u32 sqn)
 {
-       struct mlx5e_channel *c = sq->channel;
-       struct mlx5e_priv *priv = c->priv;
-       struct mlx5_core_dev *mdev = priv->mdev;
-
-       mlx5_core_destroy_sq(mdev, sq->sqn);
-       if (sq->rate_limit)
-               mlx5_rl_remove_rate(mdev, sq->rate_limit);
+       mlx5_core_destroy_sq(mdev, sqn);
 }
 
-static int mlx5e_open_sq(struct mlx5e_channel *c,
-                        int tc,
-                        struct mlx5e_sq_param *param,
-                        struct mlx5e_sq *sq)
+static int mlx5e_create_sq_rdy(struct mlx5_core_dev *mdev,
+                              struct mlx5e_sq_param *param,
+                              struct mlx5e_create_sq_param *csp,
+                              u32 *sqn)
 {
+       struct mlx5e_modify_sq_param msp = {0};
        int err;
 
-       err = mlx5e_create_sq(c, tc, param, sq);
+       err = mlx5e_create_sq(mdev, param, csp, sqn);
        if (err)
                return err;
 
-       err = mlx5e_enable_sq(sq, param);
+       msp.curr_state = MLX5_SQC_STATE_RST;
+       msp.next_state = MLX5_SQC_STATE_RDY;
+       err = mlx5e_modify_sq(mdev, *sqn, &msp);
        if (err)
-               goto err_destroy_sq;
+               mlx5e_destroy_sq(mdev, *sqn);
 
-       set_bit(MLX5E_SQ_STATE_ENABLED, &sq->state);
-       err = mlx5e_modify_sq(sq, MLX5_SQC_STATE_RST, MLX5_SQC_STATE_RDY,
-                             false, 0);
+       return err;
+}
+
+static int mlx5e_set_sq_maxrate(struct net_device *dev,
+                               struct mlx5e_txqsq *sq, u32 rate);
+
+static int mlx5e_open_txqsq(struct mlx5e_channel *c,
+                           u32 tisn,
+                           int txq_ix,
+                           struct mlx5e_params *params,
+                           struct mlx5e_sq_param *param,
+                           struct mlx5e_txqsq *sq)
+{
+       struct mlx5e_create_sq_param csp = {};
+       u32 tx_rate;
+       int err;
+
+       err = mlx5e_alloc_txqsq(c, txq_ix, params, param, sq);
        if (err)
-               goto err_disable_sq;
+               return err;
 
-       if (sq->txq) {
-               netdev_tx_reset_queue(sq->txq);
-               netif_tx_start_queue(sq->txq);
-       }
+       csp.tisn            = tisn;
+       csp.tis_lst_sz      = 1;
+       csp.cqn             = sq->cq.mcq.cqn;
+       csp.wq_ctrl         = &sq->wq_ctrl;
+       csp.min_inline_mode = sq->min_inline_mode;
+       err = mlx5e_create_sq_rdy(c->mdev, param, &csp, &sq->sqn);
+       if (err)
+               goto err_free_txqsq;
+
+       tx_rate = c->priv->tx_rates[sq->txq_ix];
+       if (tx_rate)
+               mlx5e_set_sq_maxrate(c->netdev, sq, tx_rate);
 
        return 0;
 
-err_disable_sq:
+err_free_txqsq:
        clear_bit(MLX5E_SQ_STATE_ENABLED, &sq->state);
-       mlx5e_disable_sq(sq);
-err_destroy_sq:
-       mlx5e_destroy_sq(sq);
+       mlx5e_free_txqsq(sq);
 
        return err;
 }
 
+static void mlx5e_activate_txqsq(struct mlx5e_txqsq *sq)
+{
+       sq->txq = netdev_get_tx_queue(sq->channel->netdev, sq->txq_ix);
+       set_bit(MLX5E_SQ_STATE_ENABLED, &sq->state);
+       netdev_tx_reset_queue(sq->txq);
+       netif_tx_start_queue(sq->txq);
+}
+
 static inline void netif_tx_disable_queue(struct netdev_queue *txq)
 {
        __netif_tx_lock_bh(txq);
@@ -1210,43 +1283,153 @@ static inline void netif_tx_disable_queue(struct netdev_queue *txq)
        __netif_tx_unlock_bh(txq);
 }
 
-static void mlx5e_close_sq(struct mlx5e_sq *sq)
+static void mlx5e_deactivate_txqsq(struct mlx5e_txqsq *sq)
 {
+       struct mlx5e_channel *c = sq->channel;
+
        clear_bit(MLX5E_SQ_STATE_ENABLED, &sq->state);
        /* prevent netif_tx_wake_queue */
-       napi_synchronize(&sq->channel->napi);
+       napi_synchronize(&c->napi);
 
-       if (sq->txq) {
-               netif_tx_disable_queue(sq->txq);
+       netif_tx_disable_queue(sq->txq);
 
-               /* last doorbell out, godspeed .. */
-               if (mlx5e_sq_has_room_for(sq, 1)) {
-                       sq->db.txq.skb[(sq->pc & sq->wq.sz_m1)] = NULL;
-                       mlx5e_send_nop(sq, true);
-               }
+       /* last doorbell out, godspeed .. */
+       if (mlx5e_wqc_has_room_for(&sq->wq, sq->cc, sq->pc, 1)) {
+               struct mlx5e_tx_wqe *nop;
+
+               sq->db.wqe_info[(sq->pc & sq->wq.sz_m1)].skb = NULL;
+               nop = mlx5e_post_nop(&sq->wq, sq->sqn, &sq->pc);
+               mlx5e_notify_hw(&sq->wq, sq->pc, sq->uar_map, &nop->ctrl);
        }
+}
+
+static void mlx5e_close_txqsq(struct mlx5e_txqsq *sq)
+{
+       struct mlx5e_channel *c = sq->channel;
+       struct mlx5_core_dev *mdev = c->mdev;
 
-       mlx5e_disable_sq(sq);
-       mlx5e_free_sq_descs(sq);
-       mlx5e_destroy_sq(sq);
+       mlx5e_destroy_sq(mdev, sq->sqn);
+       if (sq->rate_limit)
+               mlx5_rl_remove_rate(mdev, sq->rate_limit);
+       mlx5e_free_txqsq_descs(sq);
+       mlx5e_free_txqsq(sq);
 }
 
-static int mlx5e_create_cq(struct mlx5e_channel *c,
-                          struct mlx5e_cq_param *param,
-                          struct mlx5e_cq *cq)
+static int mlx5e_open_icosq(struct mlx5e_channel *c,
+                           struct mlx5e_params *params,
+                           struct mlx5e_sq_param *param,
+                           struct mlx5e_icosq *sq)
+{
+       struct mlx5e_create_sq_param csp = {};
+       int err;
+
+       err = mlx5e_alloc_icosq(c, param, sq);
+       if (err)
+               return err;
+
+       csp.cqn             = sq->cq.mcq.cqn;
+       csp.wq_ctrl         = &sq->wq_ctrl;
+       csp.min_inline_mode = params->tx_min_inline_mode;
+       set_bit(MLX5E_SQ_STATE_ENABLED, &sq->state);
+       err = mlx5e_create_sq_rdy(c->mdev, param, &csp, &sq->sqn);
+       if (err)
+               goto err_free_icosq;
+
+       return 0;
+
+err_free_icosq:
+       clear_bit(MLX5E_SQ_STATE_ENABLED, &sq->state);
+       mlx5e_free_icosq(sq);
+
+       return err;
+}
+
+static void mlx5e_close_icosq(struct mlx5e_icosq *sq)
+{
+       struct mlx5e_channel *c = sq->channel;
+
+       clear_bit(MLX5E_SQ_STATE_ENABLED, &sq->state);
+       napi_synchronize(&c->napi);
+
+       mlx5e_destroy_sq(c->mdev, sq->sqn);
+       mlx5e_free_icosq(sq);
+}
+
+static int mlx5e_open_xdpsq(struct mlx5e_channel *c,
+                           struct mlx5e_params *params,
+                           struct mlx5e_sq_param *param,
+                           struct mlx5e_xdpsq *sq)
+{
+       unsigned int ds_cnt = MLX5E_XDP_TX_DS_COUNT;
+       struct mlx5e_create_sq_param csp = {};
+       unsigned int inline_hdr_sz = 0;
+       int err;
+       int i;
+
+       err = mlx5e_alloc_xdpsq(c, params, param, sq);
+       if (err)
+               return err;
+
+       csp.tis_lst_sz      = 1;
+       csp.tisn            = c->priv->tisn[0]; /* tc = 0 */
+       csp.cqn             = sq->cq.mcq.cqn;
+       csp.wq_ctrl         = &sq->wq_ctrl;
+       csp.min_inline_mode = sq->min_inline_mode;
+       set_bit(MLX5E_SQ_STATE_ENABLED, &sq->state);
+       err = mlx5e_create_sq_rdy(c->mdev, param, &csp, &sq->sqn);
+       if (err)
+               goto err_free_xdpsq;
+
+       if (sq->min_inline_mode != MLX5_INLINE_MODE_NONE) {
+               inline_hdr_sz = MLX5E_XDP_MIN_INLINE;
+               ds_cnt++;
+       }
+
+       /* Pre initialize fixed WQE fields */
+       for (i = 0; i < mlx5_wq_cyc_get_size(&sq->wq); i++) {
+               struct mlx5e_tx_wqe      *wqe  = mlx5_wq_cyc_get_wqe(&sq->wq, i);
+               struct mlx5_wqe_ctrl_seg *cseg = &wqe->ctrl;
+               struct mlx5_wqe_eth_seg  *eseg = &wqe->eth;
+               struct mlx5_wqe_data_seg *dseg;
+
+               cseg->qpn_ds = cpu_to_be32((sq->sqn << 8) | ds_cnt);
+               eseg->inline_hdr.sz = cpu_to_be16(inline_hdr_sz);
+
+               dseg = (struct mlx5_wqe_data_seg *)cseg + (ds_cnt - 1);
+               dseg->lkey = sq->mkey_be;
+       }
+
+       return 0;
+
+err_free_xdpsq:
+       clear_bit(MLX5E_SQ_STATE_ENABLED, &sq->state);
+       mlx5e_free_xdpsq(sq);
+
+       return err;
+}
+
+static void mlx5e_close_xdpsq(struct mlx5e_xdpsq *sq)
+{
+       struct mlx5e_channel *c = sq->channel;
+
+       clear_bit(MLX5E_SQ_STATE_ENABLED, &sq->state);
+       napi_synchronize(&c->napi);
+
+       mlx5e_destroy_sq(c->mdev, sq->sqn);
+       mlx5e_free_xdpsq_descs(sq);
+       mlx5e_free_xdpsq(sq);
+}
+
+static int mlx5e_alloc_cq_common(struct mlx5_core_dev *mdev,
+                                struct mlx5e_cq_param *param,
+                                struct mlx5e_cq *cq)
 {
-       struct mlx5e_priv *priv = c->priv;
-       struct mlx5_core_dev *mdev = priv->mdev;
        struct mlx5_core_cq *mcq = &cq->mcq;
        int eqn_not_used;
        unsigned int irqn;
        int err;
        u32 i;
 
-       param->wq.buf_numa_node = cpu_to_node(c->cpu);
-       param->wq.db_numa_node  = cpu_to_node(c->cpu);
-       param->eq_ix   = c->ix;
-
        err = mlx5_cqwq_create(mdev, &param->wq, param->cqc, &cq->wq,
                               &cq->wq_ctrl);
        if (err)
@@ -1254,8 +1437,6 @@ static int mlx5e_create_cq(struct mlx5e_channel *c,
 
        mlx5_vector2eqn(mdev, param->eq_ix, &eqn_not_used, &irqn);
 
-       cq->napi        = &c->napi;
-
        mcq->cqe_sz     = 64;
        mcq->set_ci_db  = cq->wq_ctrl.db.db;
        mcq->arm_db     = cq->wq_ctrl.db.db + 1;
@@ -1272,21 +1453,38 @@ static int mlx5e_create_cq(struct mlx5e_channel *c,
                cqe->op_own = 0xf1;
        }
 
-       cq->channel = c;
-       cq->priv = priv;
+       cq->mdev = mdev;
 
        return 0;
 }
 
-static void mlx5e_destroy_cq(struct mlx5e_cq *cq)
+static int mlx5e_alloc_cq(struct mlx5e_channel *c,
+                         struct mlx5e_cq_param *param,
+                         struct mlx5e_cq *cq)
+{
+       struct mlx5_core_dev *mdev = c->priv->mdev;
+       int err;
+
+       param->wq.buf_numa_node = cpu_to_node(c->cpu);
+       param->wq.db_numa_node  = cpu_to_node(c->cpu);
+       param->eq_ix   = c->ix;
+
+       err = mlx5e_alloc_cq_common(mdev, param, cq);
+
+       cq->napi    = &c->napi;
+       cq->channel = c;
+
+       return err;
+}
+
+static void mlx5e_free_cq(struct mlx5e_cq *cq)
 {
        mlx5_cqwq_destroy(&cq->wq_ctrl);
 }
 
-static int mlx5e_enable_cq(struct mlx5e_cq *cq, struct mlx5e_cq_param *param)
+static int mlx5e_create_cq(struct mlx5e_cq *cq, struct mlx5e_cq_param *param)
 {
-       struct mlx5e_priv *priv = cq->priv;
-       struct mlx5_core_dev *mdev = priv->mdev;
+       struct mlx5_core_dev *mdev = cq->mdev;
        struct mlx5_core_cq *mcq = &cq->mcq;
 
        void *in;
@@ -1330,47 +1528,41 @@ static int mlx5e_enable_cq(struct mlx5e_cq *cq, struct mlx5e_cq_param *param)
        return 0;
 }
 
-static void mlx5e_disable_cq(struct mlx5e_cq *cq)
+static void mlx5e_destroy_cq(struct mlx5e_cq *cq)
 {
-       struct mlx5e_priv *priv = cq->priv;
-       struct mlx5_core_dev *mdev = priv->mdev;
-
-       mlx5_core_destroy_cq(mdev, &cq->mcq);
+       mlx5_core_destroy_cq(cq->mdev, &cq->mcq);
 }
 
 static int mlx5e_open_cq(struct mlx5e_channel *c,
+                        struct mlx5e_cq_moder moder,
                         struct mlx5e_cq_param *param,
-                        struct mlx5e_cq *cq,
-                        struct mlx5e_cq_moder moderation)
+                        struct mlx5e_cq *cq)
 {
+       struct mlx5_core_dev *mdev = c->mdev;
        int err;
-       struct mlx5e_priv *priv = c->priv;
-       struct mlx5_core_dev *mdev = priv->mdev;
 
-       err = mlx5e_create_cq(c, param, cq);
+       err = mlx5e_alloc_cq(c, param, cq);
        if (err)
                return err;
 
-       err = mlx5e_enable_cq(cq, param);
+       err = mlx5e_create_cq(cq, param);
        if (err)
-               goto err_destroy_cq;
+               goto err_free_cq;
 
        if (MLX5_CAP_GEN(mdev, cq_moderation))
-               mlx5_core_modify_cq_moderation(mdev, &cq->mcq,
-                                              moderation.usec,
-                                              moderation.pkts);
+               mlx5_core_modify_cq_moderation(mdev, &cq->mcq, moder.usec, moder.pkts);
        return 0;
 
-err_destroy_cq:
-       mlx5e_destroy_cq(cq);
+err_free_cq:
+       mlx5e_free_cq(cq);
 
        return err;
 }
 
 static void mlx5e_close_cq(struct mlx5e_cq *cq)
 {
-       mlx5e_disable_cq(cq);
        mlx5e_destroy_cq(cq);
+       mlx5e_free_cq(cq);
 }
 
 static int mlx5e_get_cpu(struct mlx5e_priv *priv, int ix)
@@ -1379,15 +1571,15 @@ static int mlx5e_get_cpu(struct mlx5e_priv *priv, int ix)
 }
 
 static int mlx5e_open_tx_cqs(struct mlx5e_channel *c,
+                            struct mlx5e_params *params,
                             struct mlx5e_channel_param *cparam)
 {
-       struct mlx5e_priv *priv = c->priv;
        int err;
        int tc;
 
        for (tc = 0; tc < c->num_tc; tc++) {
-               err = mlx5e_open_cq(c, &cparam->tx_cq, &c->sq[tc].cq,
-                                   priv->params.tx_cq_moderation);
+               err = mlx5e_open_cq(c, params->tx_cq_moderation,
+                                   &cparam->tx_cq, &c->sq[tc].cq);
                if (err)
                        goto err_close_tx_cqs;
        }
@@ -1410,13 +1602,17 @@ static void mlx5e_close_tx_cqs(struct mlx5e_channel *c)
 }
 
 static int mlx5e_open_sqs(struct mlx5e_channel *c,
+                         struct mlx5e_params *params,
                          struct mlx5e_channel_param *cparam)
 {
        int err;
        int tc;
 
-       for (tc = 0; tc < c->num_tc; tc++) {
-               err = mlx5e_open_sq(c, tc, &cparam->sq, &c->sq[tc]);
+       for (tc = 0; tc < params->num_tc; tc++) {
+               int txq_ix = c->ix + tc * params->num_channels;
+
+               err = mlx5e_open_txqsq(c, c->priv->tisn[tc], txq_ix,
+                                      params, &cparam->sq, &c->sq[tc]);
                if (err)
                        goto err_close_sqs;
        }
@@ -1425,7 +1621,7 @@ static int mlx5e_open_sqs(struct mlx5e_channel *c,
 
 err_close_sqs:
        for (tc--; tc >= 0; tc--)
-               mlx5e_close_sq(&c->sq[tc]);
+               mlx5e_close_txqsq(&c->sq[tc]);
 
        return err;
 }
@@ -1435,23 +1631,15 @@ static void mlx5e_close_sqs(struct mlx5e_channel *c)
        int tc;
 
        for (tc = 0; tc < c->num_tc; tc++)
-               mlx5e_close_sq(&c->sq[tc]);
-}
-
-static void mlx5e_build_channeltc_to_txq_map(struct mlx5e_priv *priv, int ix)
-{
-       int i;
-
-       for (i = 0; i < priv->profile->max_tc; i++)
-               priv->channeltc_to_txq_map[ix][i] =
-                       ix + i * priv->params.num_channels;
+               mlx5e_close_txqsq(&c->sq[tc]);
 }
 
 static int mlx5e_set_sq_maxrate(struct net_device *dev,
-                               struct mlx5e_sq *sq, u32 rate)
+                               struct mlx5e_txqsq *sq, u32 rate)
 {
        struct mlx5e_priv *priv = netdev_priv(dev);
        struct mlx5_core_dev *mdev = priv->mdev;
+       struct mlx5e_modify_sq_param msp = {0};
        u16 rl_index = 0;
        int err;
 
@@ -1474,8 +1662,11 @@ static int mlx5e_set_sq_maxrate(struct net_device *dev,
                }
        }
 
-       err = mlx5e_modify_sq(sq, MLX5_SQC_STATE_RDY,
-                             MLX5_SQC_STATE_RDY, true, rl_index);
+       msp.curr_state = MLX5_SQC_STATE_RDY;
+       msp.next_state = MLX5_SQC_STATE_RDY;
+       msp.rl_index   = rl_index;
+       msp.rl_update  = true;
+       err = mlx5e_modify_sq(mdev, sq->sqn, &msp);
        if (err) {
                netdev_err(dev, "Failed configuring rate %u: %d\n",
                           rate, err);
@@ -1493,7 +1684,7 @@ static int mlx5e_set_tx_maxrate(struct net_device *dev, int index, u32 rate)
 {
        struct mlx5e_priv *priv = netdev_priv(dev);
        struct mlx5_core_dev *mdev = priv->mdev;
-       struct mlx5e_sq *sq = priv->txq_to_sq_map[index];
+       struct mlx5e_txqsq *sq = priv->txq2sq[index];
        int err = 0;
 
        if (!mlx5_rl_is_supported(mdev)) {
@@ -1520,114 +1711,87 @@ static int mlx5e_set_tx_maxrate(struct net_device *dev, int index, u32 rate)
        return err;
 }
 
-static inline int mlx5e_get_max_num_channels(struct mlx5_core_dev *mdev)
-{
-       return is_kdump_kernel() ?
-               MLX5E_MIN_NUM_CHANNELS :
-               min_t(int, mdev->priv.eq_table.num_comp_vectors,
-                     MLX5E_MAX_NUM_CHANNELS);
-}
-
 static int mlx5e_open_channel(struct mlx5e_priv *priv, int ix,
+                             struct mlx5e_params *params,
                              struct mlx5e_channel_param *cparam,
                              struct mlx5e_channel **cp)
 {
-       struct mlx5e_cq_moder icosq_cq_moder = {0, 0};
+       struct mlx5e_cq_moder icocq_moder = {0, 0};
        struct net_device *netdev = priv->netdev;
-       struct mlx5e_cq_moder rx_cq_profile;
        int cpu = mlx5e_get_cpu(priv, ix);
        struct mlx5e_channel *c;
-       struct mlx5e_sq *sq;
        int err;
-       int i;
 
        c = kzalloc_node(sizeof(*c), GFP_KERNEL, cpu_to_node(cpu));
        if (!c)
                return -ENOMEM;
 
        c->priv     = priv;
+       c->mdev     = priv->mdev;
+       c->tstamp   = &priv->tstamp;
        c->ix       = ix;
        c->cpu      = cpu;
        c->pdev     = &priv->mdev->pdev->dev;
        c->netdev   = priv->netdev;
        c->mkey_be  = cpu_to_be32(priv->mdev->mlx5e_res.mkey.key);
-       c->num_tc   = priv->params.num_tc;
-       c->xdp      = !!priv->xdp_prog;
-
-       if (priv->params.rx_am_enabled)
-               rx_cq_profile = mlx5e_am_get_def_profile(priv->params.rx_cq_period_mode);
-       else
-               rx_cq_profile = priv->params.rx_cq_moderation;
-
-       mlx5e_build_channeltc_to_txq_map(priv, ix);
+       c->num_tc   = params->num_tc;
+       c->xdp      = !!params->xdp_prog;
 
        netif_napi_add(netdev, &c->napi, mlx5e_napi_poll, 64);
 
-       err = mlx5e_open_cq(c, &cparam->icosq_cq, &c->icosq.cq, icosq_cq_moder);
+       err = mlx5e_open_cq(c, icocq_moder, &cparam->icosq_cq, &c->icosq.cq);
        if (err)
                goto err_napi_del;
 
-       err = mlx5e_open_tx_cqs(c, cparam);
+       err = mlx5e_open_tx_cqs(c, params, cparam);
        if (err)
                goto err_close_icosq_cq;
 
-       err = mlx5e_open_cq(c, &cparam->rx_cq, &c->rq.cq,
-                           rx_cq_profile);
+       err = mlx5e_open_cq(c, params->rx_cq_moderation, &cparam->rx_cq, &c->rq.cq);
        if (err)
                goto err_close_tx_cqs;
 
        /* XDP SQ CQ params are same as normal TXQ sq CQ params */
-       err = c->xdp ? mlx5e_open_cq(c, &cparam->tx_cq, &c->xdp_sq.cq,
-                                    priv->params.tx_cq_moderation) : 0;
+       err = c->xdp ? mlx5e_open_cq(c, params->tx_cq_moderation,
+                                    &cparam->tx_cq, &c->rq.xdpsq.cq) : 0;
        if (err)
                goto err_close_rx_cq;
 
        napi_enable(&c->napi);
 
-       err = mlx5e_open_sq(c, 0, &cparam->icosq, &c->icosq);
+       err = mlx5e_open_icosq(c, params, &cparam->icosq, &c->icosq);
        if (err)
                goto err_disable_napi;
 
-       err = mlx5e_open_sqs(c, cparam);
+       err = mlx5e_open_sqs(c, params, cparam);
        if (err)
                goto err_close_icosq;
 
-       for (i = 0; i < priv->params.num_tc; i++) {
-               u32 txq_ix = priv->channeltc_to_txq_map[ix][i];
-
-               if (priv->tx_rates[txq_ix]) {
-                       sq = priv->txq_to_sq_map[txq_ix];
-                       mlx5e_set_sq_maxrate(priv->netdev, sq,
-                                            priv->tx_rates[txq_ix]);
-               }
-       }
-
-       err = c->xdp ? mlx5e_open_sq(c, 0, &cparam->xdp_sq, &c->xdp_sq) : 0;
+       err = c->xdp ? mlx5e_open_xdpsq(c, params, &cparam->xdp_sq, &c->rq.xdpsq) : 0;
        if (err)
                goto err_close_sqs;
 
-       err = mlx5e_open_rq(c, &cparam->rq, &c->rq);
+       err = mlx5e_open_rq(c, params, &cparam->rq, &c->rq);
        if (err)
                goto err_close_xdp_sq;
 
-       netif_set_xps_queue(netdev, get_cpu_mask(c->cpu), ix);
        *cp = c;
 
        return 0;
 err_close_xdp_sq:
        if (c->xdp)
-               mlx5e_close_sq(&c->xdp_sq);
+               mlx5e_close_xdpsq(&c->rq.xdpsq);
 
 err_close_sqs:
        mlx5e_close_sqs(c);
 
 err_close_icosq:
-       mlx5e_close_sq(&c->icosq);
+       mlx5e_close_icosq(&c->icosq);
 
 err_disable_napi:
        napi_disable(&c->napi);
        if (c->xdp)
-               mlx5e_close_cq(&c->xdp_sq.cq);
+               mlx5e_close_cq(&c->rq.xdpsq.cq);
 
 err_close_rx_cq:
        mlx5e_close_cq(&c->rq.cq);
@@ -1645,16 +1809,35 @@ err_napi_del:
        return err;
 }
 
+static void mlx5e_activate_channel(struct mlx5e_channel *c)
+{
+       int tc;
+
+       for (tc = 0; tc < c->num_tc; tc++)
+               mlx5e_activate_txqsq(&c->sq[tc]);
+       mlx5e_activate_rq(&c->rq);
+       netif_set_xps_queue(c->netdev, get_cpu_mask(c->cpu), c->ix);
+}
+
+static void mlx5e_deactivate_channel(struct mlx5e_channel *c)
+{
+       int tc;
+
+       mlx5e_deactivate_rq(&c->rq);
+       for (tc = 0; tc < c->num_tc; tc++)
+               mlx5e_deactivate_txqsq(&c->sq[tc]);
+}
+
 static void mlx5e_close_channel(struct mlx5e_channel *c)
 {
        mlx5e_close_rq(&c->rq);
        if (c->xdp)
-               mlx5e_close_sq(&c->xdp_sq);
+               mlx5e_close_xdpsq(&c->rq.xdpsq);
        mlx5e_close_sqs(c);
-       mlx5e_close_sq(&c->icosq);
+       mlx5e_close_icosq(&c->icosq);
        napi_disable(&c->napi);
        if (c->xdp)
-               mlx5e_close_cq(&c->xdp_sq.cq);
+               mlx5e_close_cq(&c->rq.xdpsq.cq);
        mlx5e_close_cq(&c->rq.cq);
        mlx5e_close_tx_cqs(c);
        mlx5e_close_cq(&c->icosq.cq);
@@ -1664,17 +1847,16 @@ static void mlx5e_close_channel(struct mlx5e_channel *c)
 }
 
 static void mlx5e_build_rq_param(struct mlx5e_priv *priv,
+                                struct mlx5e_params *params,
                                 struct mlx5e_rq_param *param)
 {
        void *rqc = param->rqc;
        void *wq = MLX5_ADDR_OF(rqc, rqc, wq);
 
-       switch (priv->params.rq_wq_type) {
+       switch (params->rq_wq_type) {
        case MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ:
-               MLX5_SET(wq, wq, log_wqe_num_of_strides,
-                        priv->params.mpwqe_log_num_strides - 9);
-               MLX5_SET(wq, wq, log_wqe_stride_size,
-                        priv->params.mpwqe_log_stride_sz - 6);
+               MLX5_SET(wq, wq, log_wqe_num_of_strides, params->mpwqe_log_num_strides - 9);
+               MLX5_SET(wq, wq, log_wqe_stride_size, params->mpwqe_log_stride_sz - 6);
                MLX5_SET(wq, wq, wq_type, MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ);
                break;
        default: /* MLX5_WQ_TYPE_LINKED_LIST */
@@ -1683,14 +1865,14 @@ static void mlx5e_build_rq_param(struct mlx5e_priv *priv,
 
        MLX5_SET(wq, wq, end_padding_mode, MLX5_WQ_END_PAD_MODE_ALIGN);
        MLX5_SET(wq, wq, log_wq_stride,    ilog2(sizeof(struct mlx5e_rx_wqe)));
-       MLX5_SET(wq, wq, log_wq_sz,        priv->params.log_rq_size);
+       MLX5_SET(wq, wq, log_wq_sz,        params->log_rq_size);
        MLX5_SET(wq, wq, pd,               priv->mdev->mlx5e_res.pdn);
        MLX5_SET(rqc, rqc, counter_set_id, priv->q_counter);
+       MLX5_SET(rqc, rqc, vsd,            params->vlan_strip_disable);
+       MLX5_SET(rqc, rqc, scatter_fcs,    params->scatter_fcs_en);
 
        param->wq.buf_numa_node = dev_to_node(&priv->mdev->pdev->dev);
        param->wq.linear = 1;
-
-       param->am_enabled = priv->params.rx_am_enabled;
 }
 
 static void mlx5e_build_drop_rq_param(struct mlx5e_rq_param *param)
@@ -1715,17 +1897,14 @@ static void mlx5e_build_sq_param_common(struct mlx5e_priv *priv,
 }
 
 static void mlx5e_build_sq_param(struct mlx5e_priv *priv,
+                                struct mlx5e_params *params,
                                 struct mlx5e_sq_param *param)
 {
        void *sqc = param->sqc;
        void *wq = MLX5_ADDR_OF(sqc, sqc, wq);
 
        mlx5e_build_sq_param_common(priv, param);
-       MLX5_SET(wq, wq, log_wq_sz,     priv->params.log_sq_size);
-
-       param->max_inline = priv->params.tx_max_inline;
-       param->min_inline_mode = priv->params.tx_min_inline_mode;
-       param->type = MLX5E_SQ_TXQ;
+       MLX5_SET(wq, wq, log_wq_sz, params->log_sq_size);
 }
 
 static void mlx5e_build_common_cq_param(struct mlx5e_priv *priv,
@@ -1737,37 +1916,36 @@ static void mlx5e_build_common_cq_param(struct mlx5e_priv *priv,
 }
 
 static void mlx5e_build_rx_cq_param(struct mlx5e_priv *priv,
+                                   struct mlx5e_params *params,
                                    struct mlx5e_cq_param *param)
 {
        void *cqc = param->cqc;
        u8 log_cq_size;
 
-       switch (priv->params.rq_wq_type) {
+       switch (params->rq_wq_type) {
        case MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ:
-               log_cq_size = priv->params.log_rq_size +
-                       priv->params.mpwqe_log_num_strides;
+               log_cq_size = params->log_rq_size + params->mpwqe_log_num_strides;
                break;
        default: /* MLX5_WQ_TYPE_LINKED_LIST */
-               log_cq_size = priv->params.log_rq_size;
+               log_cq_size = params->log_rq_size;
        }
 
        MLX5_SET(cqc, cqc, log_cq_size, log_cq_size);
-       if (MLX5E_GET_PFLAG(priv, MLX5E_PFLAG_RX_CQE_COMPRESS)) {
+       if (MLX5E_GET_PFLAG(params, MLX5E_PFLAG_RX_CQE_COMPRESS)) {
                MLX5_SET(cqc, cqc, mini_cqe_res_format, MLX5_CQE_FORMAT_CSUM);
                MLX5_SET(cqc, cqc, cqe_comp_en, 1);
        }
 
        mlx5e_build_common_cq_param(priv, param);
-
-       param->cq_period_mode = priv->params.rx_cq_period_mode;
 }
 
 static void mlx5e_build_tx_cq_param(struct mlx5e_priv *priv,
+                                   struct mlx5e_params *params,
                                    struct mlx5e_cq_param *param)
 {
        void *cqc = param->cqc;
 
-       MLX5_SET(cqc, cqc, log_cq_size, priv->params.log_sq_size);
+       MLX5_SET(cqc, cqc, log_cq_size, params->log_sq_size);
 
        mlx5e_build_common_cq_param(priv, param);
 
@@ -1775,8 +1953,8 @@ static void mlx5e_build_tx_cq_param(struct mlx5e_priv *priv,
 }
 
 static void mlx5e_build_ico_cq_param(struct mlx5e_priv *priv,
-                                    struct mlx5e_cq_param *param,
-                                    u8 log_wq_size)
+                                    u8 log_wq_size,
+                                    struct mlx5e_cq_param *param)
 {
        void *cqc = param->cqc;
 
@@ -1788,8 +1966,8 @@ static void mlx5e_build_ico_cq_param(struct mlx5e_priv *priv,
 }
 
 static void mlx5e_build_icosq_param(struct mlx5e_priv *priv,
-                                   struct mlx5e_sq_param *param,
-                                   u8 log_wq_size)
+                                   u8 log_wq_size,
+                                   struct mlx5e_sq_param *param)
 {
        void *sqc = param->sqc;
        void *wq = MLX5_ADDR_OF(sqc, sqc, wq);
@@ -1798,162 +1976,119 @@ static void mlx5e_build_icosq_param(struct mlx5e_priv *priv,
 
        MLX5_SET(wq, wq, log_wq_sz, log_wq_size);
        MLX5_SET(sqc, sqc, reg_umr, MLX5_CAP_ETH(priv->mdev, reg_umr_sq));
-
-       param->type = MLX5E_SQ_ICO;
 }
 
 static void mlx5e_build_xdpsq_param(struct mlx5e_priv *priv,
+                                   struct mlx5e_params *params,
                                    struct mlx5e_sq_param *param)
 {
        void *sqc = param->sqc;
        void *wq = MLX5_ADDR_OF(sqc, sqc, wq);
 
        mlx5e_build_sq_param_common(priv, param);
-       MLX5_SET(wq, wq, log_wq_sz,     priv->params.log_sq_size);
-
-       param->max_inline = priv->params.tx_max_inline;
-       param->min_inline_mode = priv->params.tx_min_inline_mode;
-       param->type = MLX5E_SQ_XDP;
+       MLX5_SET(wq, wq, log_wq_sz, params->log_sq_size);
 }
 
-static void mlx5e_build_channel_param(struct mlx5e_priv *priv, struct mlx5e_channel_param *cparam)
+static void mlx5e_build_channel_param(struct mlx5e_priv *priv,
+                                     struct mlx5e_params *params,
+                                     struct mlx5e_channel_param *cparam)
 {
        u8 icosq_log_wq_sz = MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE;
 
-       mlx5e_build_rq_param(priv, &cparam->rq);
-       mlx5e_build_sq_param(priv, &cparam->sq);
-       mlx5e_build_xdpsq_param(priv, &cparam->xdp_sq);
-       mlx5e_build_icosq_param(priv, &cparam->icosq, icosq_log_wq_sz);
-       mlx5e_build_rx_cq_param(priv, &cparam->rx_cq);
-       mlx5e_build_tx_cq_param(priv, &cparam->tx_cq);
-       mlx5e_build_ico_cq_param(priv, &cparam->icosq_cq, icosq_log_wq_sz);
+       mlx5e_build_rq_param(priv, params, &cparam->rq);
+       mlx5e_build_sq_param(priv, params, &cparam->sq);
+       mlx5e_build_xdpsq_param(priv, params, &cparam->xdp_sq);
+       mlx5e_build_icosq_param(priv, icosq_log_wq_sz, &cparam->icosq);
+       mlx5e_build_rx_cq_param(priv, params, &cparam->rx_cq);
+       mlx5e_build_tx_cq_param(priv, params, &cparam->tx_cq);
+       mlx5e_build_ico_cq_param(priv, icosq_log_wq_sz, &cparam->icosq_cq);
 }
 
-static int mlx5e_open_channels(struct mlx5e_priv *priv)
+int mlx5e_open_channels(struct mlx5e_priv *priv,
+                       struct mlx5e_channels *chs)
 {
        struct mlx5e_channel_param *cparam;
-       int nch = priv->params.num_channels;
        int err = -ENOMEM;
        int i;
-       int j;
-
-       priv->channel = kcalloc(nch, sizeof(struct mlx5e_channel *),
-                               GFP_KERNEL);
 
-       priv->txq_to_sq_map = kcalloc(nch * priv->params.num_tc,
-                                     sizeof(struct mlx5e_sq *), GFP_KERNEL);
+       chs->num = chs->params.num_channels;
 
+       chs->c = kcalloc(chs->num, sizeof(struct mlx5e_channel *), GFP_KERNEL);
        cparam = kzalloc(sizeof(struct mlx5e_channel_param), GFP_KERNEL);
+       if (!chs->c || !cparam)
+               goto err_free;
 
-       if (!priv->channel || !priv->txq_to_sq_map || !cparam)
-               goto err_free_txq_to_sq_map;
-
-       mlx5e_build_channel_param(priv, cparam);
-
-       for (i = 0; i < nch; i++) {
-               err = mlx5e_open_channel(priv, i, cparam, &priv->channel[i]);
-               if (err)
-                       goto err_close_channels;
-       }
-
-       for (j = 0; j < nch; j++) {
-               err = mlx5e_wait_for_min_rx_wqes(&priv->channel[j]->rq);
+       mlx5e_build_channel_param(priv, &chs->params, cparam);
+       for (i = 0; i < chs->num; i++) {
+               err = mlx5e_open_channel(priv, i, &chs->params, cparam, &chs->c[i]);
                if (err)
                        goto err_close_channels;
        }
 
-       /* FIXME: This is a W/A for tx timeout watch dog false alarm when
-        * polling for inactive tx queues.
-        */
-       netif_tx_start_all_queues(priv->netdev);
-
        kfree(cparam);
        return 0;
 
 err_close_channels:
        for (i--; i >= 0; i--)
-               mlx5e_close_channel(priv->channel[i]);
+               mlx5e_close_channel(chs->c[i]);
 
-err_free_txq_to_sq_map:
-       kfree(priv->txq_to_sq_map);
-       kfree(priv->channel);
+err_free:
+       kfree(chs->c);
        kfree(cparam);
-
+       chs->num = 0;
        return err;
 }
 
-static void mlx5e_close_channels(struct mlx5e_priv *priv)
+static void mlx5e_activate_channels(struct mlx5e_channels *chs)
 {
        int i;
 
-       /* FIXME: This is a W/A only for tx timeout watch dog false alarm when
-        * polling for inactive tx queues.
-        */
-       netif_tx_stop_all_queues(priv->netdev);
-       netif_tx_disable(priv->netdev);
-
-       for (i = 0; i < priv->params.num_channels; i++)
-               mlx5e_close_channel(priv->channel[i]);
-
-       kfree(priv->txq_to_sq_map);
-       kfree(priv->channel);
+       for (i = 0; i < chs->num; i++)
+               mlx5e_activate_channel(chs->c[i]);
 }
 
-static int mlx5e_rx_hash_fn(int hfunc)
+static int mlx5e_wait_channels_min_rx_wqes(struct mlx5e_channels *chs)
 {
-       return (hfunc == ETH_RSS_HASH_TOP) ?
-              MLX5_RX_HASH_FN_TOEPLITZ :
-              MLX5_RX_HASH_FN_INVERTED_XOR8;
-}
-
-static int mlx5e_bits_invert(unsigned long a, int size)
-{
-       int inv = 0;
+       int err = 0;
        int i;
 
-       for (i = 0; i < size; i++)
-               inv |= (test_bit(size - i - 1, &a) ? 1 : 0) << i;
+       for (i = 0; i < chs->num; i++) {
+               err = mlx5e_wait_for_min_rx_wqes(&chs->c[i]->rq);
+               if (err)
+                       break;
+       }
 
-       return inv;
+       return err;
 }
 
-static void mlx5e_fill_indir_rqt_rqns(struct mlx5e_priv *priv, void *rqtc)
+static void mlx5e_deactivate_channels(struct mlx5e_channels *chs)
 {
        int i;
 
-       for (i = 0; i < MLX5E_INDIR_RQT_SIZE; i++) {
-               int ix = i;
-               u32 rqn;
-
-               if (priv->params.rss_hfunc == ETH_RSS_HASH_XOR)
-                       ix = mlx5e_bits_invert(i, MLX5E_LOG_INDIR_RQT_SIZE);
-
-               ix = priv->params.indirection_rqt[ix];
-               rqn = test_bit(MLX5E_STATE_OPENED, &priv->state) ?
-                               priv->channel[ix]->rq.rqn :
-                               priv->drop_rq.rqn;
-               MLX5_SET(rqtc, rqtc, rq_num[i], rqn);
-       }
+       for (i = 0; i < chs->num; i++)
+               mlx5e_deactivate_channel(chs->c[i]);
 }
 
-static void mlx5e_fill_direct_rqt_rqn(struct mlx5e_priv *priv, void *rqtc,
-                                     int ix)
+void mlx5e_close_channels(struct mlx5e_channels *chs)
 {
-       u32 rqn = test_bit(MLX5E_STATE_OPENED, &priv->state) ?
-                       priv->channel[ix]->rq.rqn :
-                       priv->drop_rq.rqn;
+       int i;
 
-       MLX5_SET(rqtc, rqtc, rq_num[0], rqn);
+       for (i = 0; i < chs->num; i++)
+               mlx5e_close_channel(chs->c[i]);
+
+       kfree(chs->c);
+       chs->num = 0;
 }
 
-static int mlx5e_create_rqt(struct mlx5e_priv *priv, int sz,
-                           int ix, struct mlx5e_rqt *rqt)
+static int
+mlx5e_create_rqt(struct mlx5e_priv *priv, int sz, struct mlx5e_rqt *rqt)
 {
        struct mlx5_core_dev *mdev = priv->mdev;
        void *rqtc;
        int inlen;
        int err;
        u32 *in;
+       int i;
 
        inlen = MLX5_ST_SZ_BYTES(create_rqt_in) + sizeof(u32) * sz;
        in = mlx5_vzalloc(inlen);
@@ -1965,10 +2100,8 @@ static int mlx5e_create_rqt(struct mlx5e_priv *priv, int sz,
        MLX5_SET(rqtc, rqtc, rqt_actual_size, sz);
        MLX5_SET(rqtc, rqtc, rqt_max_size, sz);
 
-       if (sz > 1) /* RSS */
-               mlx5e_fill_indir_rqt_rqns(priv, rqtc);
-       else
-               mlx5e_fill_direct_rqt_rqn(priv, rqtc, ix);
+       for (i = 0; i < sz; i++)
+               MLX5_SET(rqtc, rqtc, rq_num[i], priv->drop_rq.rqn);
 
        err = mlx5_core_create_rqt(mdev, in, inlen, &rqt->rqtn);
        if (!err)
@@ -1984,11 +2117,15 @@ void mlx5e_destroy_rqt(struct mlx5e_priv *priv, struct mlx5e_rqt *rqt)
        mlx5_core_destroy_rqt(priv->mdev, rqt->rqtn);
 }
 
-static int mlx5e_create_indirect_rqts(struct mlx5e_priv *priv)
+int mlx5e_create_indirect_rqt(struct mlx5e_priv *priv)
 {
        struct mlx5e_rqt *rqt = &priv->indir_rqt;
+       int err;
 
-       return mlx5e_create_rqt(priv, MLX5E_INDIR_RQT_SIZE, 0, rqt);
+       err = mlx5e_create_rqt(priv, MLX5E_INDIR_RQT_SIZE, rqt);
+       if (err)
+               mlx5_core_warn(priv->mdev, "create indirect rqts failed, %d\n", err);
+       return err;
 }
 
 int mlx5e_create_direct_rqts(struct mlx5e_priv *priv)
@@ -1999,7 +2136,7 @@ int mlx5e_create_direct_rqts(struct mlx5e_priv *priv)
 
        for (ix = 0; ix < priv->profile->max_nch(priv->mdev); ix++) {
                rqt = &priv->direct_tir[ix].rqt;
-               err = mlx5e_create_rqt(priv, 1 /*size */, ix, rqt);
+               err = mlx5e_create_rqt(priv, 1 /*size */, rqt);
                if (err)
                        goto err_destroy_rqts;
        }
@@ -2007,13 +2144,64 @@ int mlx5e_create_direct_rqts(struct mlx5e_priv *priv)
        return 0;
 
 err_destroy_rqts:
+       mlx5_core_warn(priv->mdev, "create direct rqts failed, %d\n", err);
        for (ix--; ix >= 0; ix--)
                mlx5e_destroy_rqt(priv, &priv->direct_tir[ix].rqt);
 
        return err;
 }
 
-int mlx5e_redirect_rqt(struct mlx5e_priv *priv, u32 rqtn, int sz, int ix)
+void mlx5e_destroy_direct_rqts(struct mlx5e_priv *priv)
+{
+       int i;
+
+       for (i = 0; i < priv->profile->max_nch(priv->mdev); i++)
+               mlx5e_destroy_rqt(priv, &priv->direct_tir[i].rqt);
+}
+
+static int mlx5e_rx_hash_fn(int hfunc)
+{
+       return (hfunc == ETH_RSS_HASH_TOP) ?
+              MLX5_RX_HASH_FN_TOEPLITZ :
+              MLX5_RX_HASH_FN_INVERTED_XOR8;
+}
+
+static int mlx5e_bits_invert(unsigned long a, int size)
+{
+       int inv = 0;
+       int i;
+
+       for (i = 0; i < size; i++)
+               inv |= (test_bit(size - i - 1, &a) ? 1 : 0) << i;
+
+       return inv;
+}
+
+static void mlx5e_fill_rqt_rqns(struct mlx5e_priv *priv, int sz,
+                               struct mlx5e_redirect_rqt_param rrp, void *rqtc)
+{
+       int i;
+
+       for (i = 0; i < sz; i++) {
+               u32 rqn;
+
+               if (rrp.is_rss) {
+                       int ix = i;
+
+                       if (rrp.rss.hfunc == ETH_RSS_HASH_XOR)
+                               ix = mlx5e_bits_invert(i, ilog2(sz));
+
+                       ix = priv->channels.params.indirection_rqt[ix];
+                       rqn = rrp.rss.channels->c[ix]->rq.rqn;
+               } else {
+                       rqn = rrp.rqn;
+               }
+               MLX5_SET(rqtc, rqtc, rq_num[i], rqn);
+       }
+}
+
+int mlx5e_redirect_rqt(struct mlx5e_priv *priv, u32 rqtn, int sz,
+                      struct mlx5e_redirect_rqt_param rrp)
 {
        struct mlx5_core_dev *mdev = priv->mdev;
        void *rqtc;
@@ -2029,41 +2217,86 @@ int mlx5e_redirect_rqt(struct mlx5e_priv *priv, u32 rqtn, int sz, int ix)
        rqtc = MLX5_ADDR_OF(modify_rqt_in, in, ctx);
 
        MLX5_SET(rqtc, rqtc, rqt_actual_size, sz);
-       if (sz > 1) /* RSS */
-               mlx5e_fill_indir_rqt_rqns(priv, rqtc);
-       else
-               mlx5e_fill_direct_rqt_rqn(priv, rqtc, ix);
-
        MLX5_SET(modify_rqt_in, in, bitmask.rqn_list, 1);
-
+       mlx5e_fill_rqt_rqns(priv, sz, rrp, rqtc);
        err = mlx5_core_modify_rqt(mdev, rqtn, in, inlen);
 
        kvfree(in);
-
        return err;
 }
 
-static void mlx5e_redirect_rqts(struct mlx5e_priv *priv)
+static u32 mlx5e_get_direct_rqn(struct mlx5e_priv *priv, int ix,
+                               struct mlx5e_redirect_rqt_param rrp)
+{
+       if (!rrp.is_rss)
+               return rrp.rqn;
+
+       if (ix >= rrp.rss.channels->num)
+               return priv->drop_rq.rqn;
+
+       return rrp.rss.channels->c[ix]->rq.rqn;
+}
+
+static void mlx5e_redirect_rqts(struct mlx5e_priv *priv,
+                               struct mlx5e_redirect_rqt_param rrp)
 {
        u32 rqtn;
        int ix;
 
        if (priv->indir_rqt.enabled) {
+               /* RSS RQ table */
                rqtn = priv->indir_rqt.rqtn;
-               mlx5e_redirect_rqt(priv, rqtn, MLX5E_INDIR_RQT_SIZE, 0);
+               mlx5e_redirect_rqt(priv, rqtn, MLX5E_INDIR_RQT_SIZE, rrp);
        }
 
-       for (ix = 0; ix < priv->params.num_channels; ix++) {
+       for (ix = 0; ix < priv->profile->max_nch(priv->mdev); ix++) {
+               struct mlx5e_redirect_rqt_param direct_rrp = {
+                       .is_rss = false,
+                       {
+                               .rqn    = mlx5e_get_direct_rqn(priv, ix, rrp)
+                       },
+               };
+
+               /* Direct RQ Tables */
                if (!priv->direct_tir[ix].rqt.enabled)
                        continue;
+
                rqtn = priv->direct_tir[ix].rqt.rqtn;
-               mlx5e_redirect_rqt(priv, rqtn, 1, ix);
+               mlx5e_redirect_rqt(priv, rqtn, 1, direct_rrp);
        }
 }
 
-static void mlx5e_build_tir_ctx_lro(void *tirc, struct mlx5e_priv *priv)
+static void mlx5e_redirect_rqts_to_channels(struct mlx5e_priv *priv,
+                                           struct mlx5e_channels *chs)
+{
+       struct mlx5e_redirect_rqt_param rrp = {
+               .is_rss        = true,
+               {
+                       .rss = {
+                               .channels  = chs,
+                               .hfunc     = chs->params.rss_hfunc,
+                       }
+               },
+       };
+
+       mlx5e_redirect_rqts(priv, rrp);
+}
+
+static void mlx5e_redirect_rqts_to_drop(struct mlx5e_priv *priv)
+{
+       struct mlx5e_redirect_rqt_param drop_rrp = {
+               .is_rss = false,
+               {
+                       .rqn = priv->drop_rq.rqn,
+               },
+       };
+
+       mlx5e_redirect_rqts(priv, drop_rrp);
+}
+
+static void mlx5e_build_tir_ctx_lro(struct mlx5e_params *params, void *tirc)
 {
-       if (!priv->params.lro_en)
+       if (!params->lro_en)
                return;
 
 #define ROUGH_MAX_L2_L3_HDR_SZ 256
@@ -2072,13 +2305,13 @@ static void mlx5e_build_tir_ctx_lro(void *tirc, struct mlx5e_priv *priv)
                 MLX5_TIRC_LRO_ENABLE_MASK_IPV4_LRO |
                 MLX5_TIRC_LRO_ENABLE_MASK_IPV6_LRO);
        MLX5_SET(tirc, tirc, lro_max_ip_payload_size,
-                (priv->params.lro_wqe_sz -
-                 ROUGH_MAX_L2_L3_HDR_SZ) >> 8);
-       MLX5_SET(tirc, tirc, lro_timeout_period_usecs, priv->params.lro_timeout);
+                (params->lro_wqe_sz - ROUGH_MAX_L2_L3_HDR_SZ) >> 8);
+       MLX5_SET(tirc, tirc, lro_timeout_period_usecs, params->lro_timeout);
 }
 
-void mlx5e_build_indir_tir_ctx_hash(struct mlx5e_priv *priv, void *tirc,
-                                   enum mlx5e_traffic_types tt)
+void mlx5e_build_indir_tir_ctx_hash(struct mlx5e_params *params,
+                                   enum mlx5e_traffic_types tt,
+                                   void *tirc)
 {
        void *hfso = MLX5_ADDR_OF(tirc, tirc, rx_hash_field_selector_outer);
 
@@ -2094,16 +2327,15 @@ void mlx5e_build_indir_tir_ctx_hash(struct mlx5e_priv *priv, void *tirc,
                                 MLX5_HASH_FIELD_SEL_DST_IP   |\
                                 MLX5_HASH_FIELD_SEL_IPSEC_SPI)
 
-       MLX5_SET(tirc, tirc, rx_hash_fn,
-                mlx5e_rx_hash_fn(priv->params.rss_hfunc));
-       if (priv->params.rss_hfunc == ETH_RSS_HASH_TOP) {
+       MLX5_SET(tirc, tirc, rx_hash_fn, mlx5e_rx_hash_fn(params->rss_hfunc));
+       if (params->rss_hfunc == ETH_RSS_HASH_TOP) {
                void *rss_key = MLX5_ADDR_OF(tirc, tirc,
                                             rx_hash_toeplitz_key);
                size_t len = MLX5_FLD_SZ_BYTES(tirc,
                                               rx_hash_toeplitz_key);
 
                MLX5_SET(tirc, tirc, rx_hash_symmetric, 1);
-               memcpy(rss_key, priv->params.toeplitz_hash_key, len);
+               memcpy(rss_key, params->toeplitz_hash_key, len);
        }
 
        switch (tt) {
@@ -2208,7 +2440,7 @@ static int mlx5e_modify_tirs_lro(struct mlx5e_priv *priv)
        MLX5_SET(modify_tir_in, in, bitmask.lro, 1);
        tirc = MLX5_ADDR_OF(modify_tir_in, in, ctx);
 
-       mlx5e_build_tir_ctx_lro(tirc, priv);
+       mlx5e_build_tir_ctx_lro(&priv->channels.params, tirc);
 
        for (tt = 0; tt < MLX5E_NUM_INDIR_TIRS; tt++) {
                err = mlx5_core_modify_tir(mdev, priv->indir_tir[tt].tirn, in,
@@ -2258,9 +2490,9 @@ static void mlx5e_query_mtu(struct mlx5e_priv *priv, u16 *mtu)
        *mtu = MLX5E_HW2SW_MTU(hw_mtu);
 }
 
-static int mlx5e_set_dev_port_mtu(struct net_device *netdev)
+static int mlx5e_set_dev_port_mtu(struct mlx5e_priv *priv)
 {
-       struct mlx5e_priv *priv = netdev_priv(netdev);
+       struct net_device *netdev = priv->netdev;
        u16 mtu;
        int err;
 
@@ -2280,8 +2512,8 @@ static int mlx5e_set_dev_port_mtu(struct net_device *netdev)
 static void mlx5e_netdev_set_tcs(struct net_device *netdev)
 {
        struct mlx5e_priv *priv = netdev_priv(netdev);
-       int nch = priv->params.num_channels;
-       int ntc = priv->params.num_tc;
+       int nch = priv->channels.params.num_channels;
+       int ntc = priv->channels.params.num_tc;
        int tc;
 
        netdev_reset_tc(netdev);
@@ -2298,53 +2530,116 @@ static void mlx5e_netdev_set_tcs(struct net_device *netdev)
                netdev_set_tc_queue(netdev, tc, nch, 0);
 }
 
-int mlx5e_open_locked(struct net_device *netdev)
+static void mlx5e_build_channels_tx_maps(struct mlx5e_priv *priv)
 {
-       struct mlx5e_priv *priv = netdev_priv(netdev);
-       struct mlx5_core_dev *mdev = priv->mdev;
-       int num_txqs;
-       int err;
+       struct mlx5e_channel *c;
+       struct mlx5e_txqsq *sq;
+       int i, tc;
+
+       for (i = 0; i < priv->channels.num; i++)
+               for (tc = 0; tc < priv->profile->max_tc; tc++)
+                       priv->channel_tc2txq[i][tc] = i + tc * priv->channels.num;
+
+       for (i = 0; i < priv->channels.num; i++) {
+               c = priv->channels.c[i];
+               for (tc = 0; tc < c->num_tc; tc++) {
+                       sq = &c->sq[tc];
+                       priv->txq2sq[sq->txq_ix] = sq;
+               }
+       }
+}
 
-       set_bit(MLX5E_STATE_OPENED, &priv->state);
+static bool mlx5e_is_eswitch_vport_mngr(struct mlx5_core_dev *mdev)
+{
+       return (MLX5_CAP_GEN(mdev, vport_group_manager) &&
+               MLX5_CAP_GEN(mdev, port_type) == MLX5_CAP_PORT_TYPE_ETH);
+}
+
+void mlx5e_activate_priv_channels(struct mlx5e_priv *priv)
+{
+       int num_txqs = priv->channels.num * priv->channels.params.num_tc;
+       struct net_device *netdev = priv->netdev;
 
        mlx5e_netdev_set_tcs(netdev);
+       netif_set_real_num_tx_queues(netdev, num_txqs);
+       netif_set_real_num_rx_queues(netdev, priv->channels.num);
+
+       mlx5e_build_channels_tx_maps(priv);
+       mlx5e_activate_channels(&priv->channels);
+       netif_tx_start_all_queues(priv->netdev);
+
+       if (mlx5e_is_eswitch_vport_mngr(priv->mdev))
+               mlx5e_add_sqs_fwd_rules(priv);
+
+       mlx5e_wait_channels_min_rx_wqes(&priv->channels);
+       mlx5e_redirect_rqts_to_channels(priv, &priv->channels);
+}
+
+void mlx5e_deactivate_priv_channels(struct mlx5e_priv *priv)
+{
+       mlx5e_redirect_rqts_to_drop(priv);
+
+       if (mlx5e_is_eswitch_vport_mngr(priv->mdev))
+               mlx5e_remove_sqs_fwd_rules(priv);
+
+       /* FIXME: This is a W/A only for tx timeout watch dog false alarm when
+        * polling for inactive tx queues.
+        */
+       netif_tx_stop_all_queues(priv->netdev);
+       netif_tx_disable(priv->netdev);
+       mlx5e_deactivate_channels(&priv->channels);
+}
+
+void mlx5e_switch_priv_channels(struct mlx5e_priv *priv,
+                               struct mlx5e_channels *new_chs,
+                               mlx5e_fp_hw_modify hw_modify)
+{
+       struct net_device *netdev = priv->netdev;
+       int new_num_txqs;
+
+       new_num_txqs = new_chs->num * new_chs->params.num_tc;
+
+       netif_carrier_off(netdev);
+
+       if (new_num_txqs < netdev->real_num_tx_queues)
+               netif_set_real_num_tx_queues(netdev, new_num_txqs);
+
+       mlx5e_deactivate_priv_channels(priv);
+       mlx5e_close_channels(&priv->channels);
+
+       priv->channels = *new_chs;
+
+       /* New channels are ready to roll, modify HW settings if needed */
+       if (hw_modify)
+               hw_modify(priv);
+
+       mlx5e_refresh_tirs(priv, false);
+       mlx5e_activate_priv_channels(priv);
+
+       mlx5e_update_carrier(priv);
+}
+
+int mlx5e_open_locked(struct net_device *netdev)
+{
+       struct mlx5e_priv *priv = netdev_priv(netdev);
+       int err;
 
-       num_txqs = priv->params.num_channels * priv->params.num_tc;
-       netif_set_real_num_tx_queues(netdev, num_txqs);
-       netif_set_real_num_rx_queues(netdev, priv->params.num_channels);
+       set_bit(MLX5E_STATE_OPENED, &priv->state);
 
-       err = mlx5e_open_channels(priv);
-       if (err) {
-               netdev_err(netdev, "%s: mlx5e_open_channels failed, %d\n",
-                          __func__, err);
+       err = mlx5e_open_channels(priv, &priv->channels);
+       if (err)
                goto err_clear_state_opened_flag;
-       }
-
-       err = mlx5e_refresh_tirs_self_loopback(priv->mdev, false);
-       if (err) {
-               netdev_err(netdev, "%s: mlx5e_refresh_tirs_self_loopback_enable failed, %d\n",
-                          __func__, err);
-               goto err_close_channels;
-       }
 
-       mlx5e_redirect_rqts(priv);
+       mlx5e_refresh_tirs(priv, false);
+       mlx5e_activate_priv_channels(priv);
        mlx5e_update_carrier(priv);
        mlx5e_timestamp_init(priv);
-#ifdef CONFIG_RFS_ACCEL
-       priv->netdev->rx_cpu_rmap = priv->mdev->rmap;
-#endif
+
        if (priv->profile->update_stats)
                queue_delayed_work(priv->wq, &priv->update_stats_work, 0);
 
-       if (MLX5_CAP_GEN(mdev, vport_group_manager)) {
-               err = mlx5e_add_sqs_fwd_rules(priv);
-               if (err)
-                       goto err_close_channels;
-       }
        return 0;
 
-err_close_channels:
-       mlx5e_close_channels(priv);
 err_clear_state_opened_flag:
        clear_bit(MLX5E_STATE_OPENED, &priv->state);
        return err;
@@ -2365,7 +2660,6 @@ int mlx5e_open(struct net_device *netdev)
 int mlx5e_close_locked(struct net_device *netdev)
 {
        struct mlx5e_priv *priv = netdev_priv(netdev);
-       struct mlx5_core_dev *mdev = priv->mdev;
 
        /* May already be CLOSED in case a previous configuration operation
         * (e.g RX/TX queue size change) that involves close&open failed.
@@ -2375,13 +2669,10 @@ int mlx5e_close_locked(struct net_device *netdev)
 
        clear_bit(MLX5E_STATE_OPENED, &priv->state);
 
-       if (MLX5_CAP_GEN(mdev, vport_group_manager))
-               mlx5e_remove_sqs_fwd_rules(priv);
-
        mlx5e_timestamp_cleanup(priv);
        netif_carrier_off(priv->netdev);
-       mlx5e_redirect_rqts(priv);
-       mlx5e_close_channels(priv);
+       mlx5e_deactivate_priv_channels(priv);
+       mlx5e_close_channels(&priv->channels);
 
        return 0;
 }
@@ -2401,11 +2692,10 @@ int mlx5e_close(struct net_device *netdev)
        return err;
 }
 
-static int mlx5e_create_drop_rq(struct mlx5e_priv *priv,
-                               struct mlx5e_rq *rq,
-                               struct mlx5e_rq_param *param)
+static int mlx5e_alloc_drop_rq(struct mlx5_core_dev *mdev,
+                              struct mlx5e_rq *rq,
+                              struct mlx5e_rq_param *param)
 {
-       struct mlx5_core_dev *mdev = priv->mdev;
        void *rqc = param->rqc;
        void *rqc_wq = MLX5_ADDR_OF(rqc, rqc, wq);
        int err;
@@ -2417,111 +2707,85 @@ static int mlx5e_create_drop_rq(struct mlx5e_priv *priv,
        if (err)
                return err;
 
-       rq->priv = priv;
+       rq->mdev = mdev;
 
        return 0;
 }
 
-static int mlx5e_create_drop_cq(struct mlx5e_priv *priv,
-                               struct mlx5e_cq *cq,
-                               struct mlx5e_cq_param *param)
+static int mlx5e_alloc_drop_cq(struct mlx5_core_dev *mdev,
+                              struct mlx5e_cq *cq,
+                              struct mlx5e_cq_param *param)
 {
-       struct mlx5_core_dev *mdev = priv->mdev;
-       struct mlx5_core_cq *mcq = &cq->mcq;
-       int eqn_not_used;
-       unsigned int irqn;
-       int err;
-
-       err = mlx5_cqwq_create(mdev, &param->wq, param->cqc, &cq->wq,
-                              &cq->wq_ctrl);
-       if (err)
-               return err;
-
-       mlx5_vector2eqn(mdev, param->eq_ix, &eqn_not_used, &irqn);
-
-       mcq->cqe_sz     = 64;
-       mcq->set_ci_db  = cq->wq_ctrl.db.db;
-       mcq->arm_db     = cq->wq_ctrl.db.db + 1;
-       *mcq->set_ci_db = 0;
-       *mcq->arm_db    = 0;
-       mcq->vector     = param->eq_ix;
-       mcq->comp       = mlx5e_completion_event;
-       mcq->event      = mlx5e_cq_error_event;
-       mcq->irqn       = irqn;
-
-       cq->priv = priv;
-
-       return 0;
+       return mlx5e_alloc_cq_common(mdev, param, cq);
 }
 
-static int mlx5e_open_drop_rq(struct mlx5e_priv *priv)
+static int mlx5e_open_drop_rq(struct mlx5_core_dev *mdev,
+                             struct mlx5e_rq *drop_rq)
 {
-       struct mlx5e_cq_param cq_param;
-       struct mlx5e_rq_param rq_param;
-       struct mlx5e_rq *rq = &priv->drop_rq;
-       struct mlx5e_cq *cq = &priv->drop_rq.cq;
+       struct mlx5e_cq_param cq_param = {};
+       struct mlx5e_rq_param rq_param = {};
+       struct mlx5e_cq *cq = &drop_rq->cq;
        int err;
 
-       memset(&cq_param, 0, sizeof(cq_param));
-       memset(&rq_param, 0, sizeof(rq_param));
        mlx5e_build_drop_rq_param(&rq_param);
 
-       err = mlx5e_create_drop_cq(priv, cq, &cq_param);
+       err = mlx5e_alloc_drop_cq(mdev, cq, &cq_param);
        if (err)
                return err;
 
-       err = mlx5e_enable_cq(cq, &cq_param);
+       err = mlx5e_create_cq(cq, &cq_param);
        if (err)
-               goto err_destroy_cq;
+               goto err_free_cq;
 
-       err = mlx5e_create_drop_rq(priv, rq, &rq_param);
+       err = mlx5e_alloc_drop_rq(mdev, drop_rq, &rq_param);
        if (err)
-               goto err_disable_cq;
+               goto err_destroy_cq;
 
-       err = mlx5e_enable_rq(rq, &rq_param);
+       err = mlx5e_create_rq(drop_rq, &rq_param);
        if (err)
-               goto err_destroy_rq;
+               goto err_free_rq;
 
        return 0;
 
-err_destroy_rq:
-       mlx5e_destroy_rq(&priv->drop_rq);
-
-err_disable_cq:
-       mlx5e_disable_cq(&priv->drop_rq.cq);
+err_free_rq:
+       mlx5e_free_rq(drop_rq);
 
 err_destroy_cq:
-       mlx5e_destroy_cq(&priv->drop_rq.cq);
+       mlx5e_destroy_cq(cq);
+
+err_free_cq:
+       mlx5e_free_cq(cq);
 
        return err;
 }
 
-static void mlx5e_close_drop_rq(struct mlx5e_priv *priv)
+static void mlx5e_close_drop_rq(struct mlx5e_rq *drop_rq)
 {
-       mlx5e_disable_rq(&priv->drop_rq);
-       mlx5e_destroy_rq(&priv->drop_rq);
-       mlx5e_disable_cq(&priv->drop_rq.cq);
-       mlx5e_destroy_cq(&priv->drop_rq.cq);
+       mlx5e_destroy_rq(drop_rq);
+       mlx5e_free_rq(drop_rq);
+       mlx5e_destroy_cq(&drop_rq->cq);
+       mlx5e_free_cq(&drop_rq->cq);
 }
 
-static int mlx5e_create_tis(struct mlx5e_priv *priv, int tc)
+int mlx5e_create_tis(struct mlx5_core_dev *mdev, int tc,
+                    u32 underlay_qpn, u32 *tisn)
 {
-       struct mlx5_core_dev *mdev = priv->mdev;
        u32 in[MLX5_ST_SZ_DW(create_tis_in)] = {0};
        void *tisc = MLX5_ADDR_OF(create_tis_in, in, ctx);
 
        MLX5_SET(tisc, tisc, prio, tc << 1);
+       MLX5_SET(tisc, tisc, underlay_qpn, underlay_qpn);
        MLX5_SET(tisc, tisc, transport_domain, mdev->mlx5e_res.td.tdn);
 
        if (mlx5_lag_is_lacp_owner(mdev))
                MLX5_SET(tisc, tisc, strict_lag_tx_port_affinity, 1);
 
-       return mlx5_core_create_tis(mdev, in, sizeof(in), &priv->tisn[tc]);
+       return mlx5_core_create_tis(mdev, in, sizeof(in), tisn);
 }
 
-static void mlx5e_destroy_tis(struct mlx5e_priv *priv, int tc)
+void mlx5e_destroy_tis(struct mlx5_core_dev *mdev, u32 tisn)
 {
-       mlx5_core_destroy_tis(priv->mdev, priv->tisn[tc]);
+       mlx5_core_destroy_tis(mdev, tisn);
 }
 
 int mlx5e_create_tises(struct mlx5e_priv *priv)
@@ -2530,7 +2794,7 @@ int mlx5e_create_tises(struct mlx5e_priv *priv)
        int tc;
 
        for (tc = 0; tc < priv->profile->max_tc; tc++) {
-               err = mlx5e_create_tis(priv, tc);
+               err = mlx5e_create_tis(priv->mdev, tc, 0, &priv->tisn[tc]);
                if (err)
                        goto err_close_tises;
        }
@@ -2539,7 +2803,7 @@ int mlx5e_create_tises(struct mlx5e_priv *priv)
 
 err_close_tises:
        for (tc--; tc >= 0; tc--)
-               mlx5e_destroy_tis(priv, tc);
+               mlx5e_destroy_tis(priv->mdev, priv->tisn[tc]);
 
        return err;
 }
@@ -2549,34 +2813,34 @@ void mlx5e_cleanup_nic_tx(struct mlx5e_priv *priv)
        int tc;
 
        for (tc = 0; tc < priv->profile->max_tc; tc++)
-               mlx5e_destroy_tis(priv, tc);
+               mlx5e_destroy_tis(priv->mdev, priv->tisn[tc]);
 }
 
-static void mlx5e_build_indir_tir_ctx(struct mlx5e_priv *priv, u32 *tirc,
-                                     enum mlx5e_traffic_types tt)
+static void mlx5e_build_indir_tir_ctx(struct mlx5e_priv *priv,
+                                     enum mlx5e_traffic_types tt,
+                                     u32 *tirc)
 {
        MLX5_SET(tirc, tirc, transport_domain, priv->mdev->mlx5e_res.td.tdn);
 
-       mlx5e_build_tir_ctx_lro(tirc, priv);
+       mlx5e_build_tir_ctx_lro(&priv->channels.params, tirc);
 
        MLX5_SET(tirc, tirc, disp_type, MLX5_TIRC_DISP_TYPE_INDIRECT);
        MLX5_SET(tirc, tirc, indirect_table, priv->indir_rqt.rqtn);
-       mlx5e_build_indir_tir_ctx_hash(priv, tirc, tt);
+       mlx5e_build_indir_tir_ctx_hash(&priv->channels.params, tt, tirc);
 }
 
-static void mlx5e_build_direct_tir_ctx(struct mlx5e_priv *priv, u32 *tirc,
-                                      u32 rqtn)
+static void mlx5e_build_direct_tir_ctx(struct mlx5e_priv *priv, u32 rqtn, u32 *tirc)
 {
        MLX5_SET(tirc, tirc, transport_domain, priv->mdev->mlx5e_res.td.tdn);
 
-       mlx5e_build_tir_ctx_lro(tirc, priv);
+       mlx5e_build_tir_ctx_lro(&priv->channels.params, tirc);
 
        MLX5_SET(tirc, tirc, disp_type, MLX5_TIRC_DISP_TYPE_INDIRECT);
        MLX5_SET(tirc, tirc, indirect_table, rqtn);
        MLX5_SET(tirc, tirc, rx_hash_fn, MLX5_RX_HASH_FN_INVERTED_XOR8);
 }
 
-static int mlx5e_create_indirect_tirs(struct mlx5e_priv *priv)
+int mlx5e_create_indirect_tirs(struct mlx5e_priv *priv)
 {
        struct mlx5e_tir *tir;
        void *tirc;
@@ -2594,7 +2858,7 @@ static int mlx5e_create_indirect_tirs(struct mlx5e_priv *priv)
                memset(in, 0, inlen);
                tir = &priv->indir_tir[tt];
                tirc = MLX5_ADDR_OF(create_tir_in, in, ctx);
-               mlx5e_build_indir_tir_ctx(priv, tirc, tt);
+               mlx5e_build_indir_tir_ctx(priv, tt, tirc);
                err = mlx5e_create_tir(priv->mdev, tir, in, inlen);
                if (err)
                        goto err_destroy_tirs;
@@ -2605,6 +2869,7 @@ static int mlx5e_create_indirect_tirs(struct mlx5e_priv *priv)
        return 0;
 
 err_destroy_tirs:
+       mlx5_core_warn(priv->mdev, "create indirect tirs failed, %d\n", err);
        for (tt--; tt >= 0; tt--)
                mlx5e_destroy_tir(priv->mdev, &priv->indir_tir[tt]);
 
@@ -2632,8 +2897,7 @@ int mlx5e_create_direct_tirs(struct mlx5e_priv *priv)
                memset(in, 0, inlen);
                tir = &priv->direct_tir[ix];
                tirc = MLX5_ADDR_OF(create_tir_in, in, ctx);
-               mlx5e_build_direct_tir_ctx(priv, tirc,
-                                          priv->direct_tir[ix].rqt.rqtn);
+               mlx5e_build_direct_tir_ctx(priv, priv->direct_tir[ix].rqt.rqtn, tirc);
                err = mlx5e_create_tir(priv->mdev, tir, in, inlen);
                if (err)
                        goto err_destroy_ch_tirs;
@@ -2644,6 +2908,7 @@ int mlx5e_create_direct_tirs(struct mlx5e_priv *priv)
        return 0;
 
 err_destroy_ch_tirs:
+       mlx5_core_warn(priv->mdev, "create direct tirs failed, %d\n", err);
        for (ix--; ix >= 0; ix--)
                mlx5e_destroy_tir(priv->mdev, &priv->direct_tir[ix]);
 
@@ -2652,7 +2917,7 @@ err_destroy_ch_tirs:
        return err;
 }
 
-static void mlx5e_destroy_indirect_tirs(struct mlx5e_priv *priv)
+void mlx5e_destroy_indirect_tirs(struct mlx5e_priv *priv)
 {
        int i;
 
@@ -2669,16 +2934,27 @@ void mlx5e_destroy_direct_tirs(struct mlx5e_priv *priv)
                mlx5e_destroy_tir(priv->mdev, &priv->direct_tir[i]);
 }
 
-int mlx5e_modify_rqs_vsd(struct mlx5e_priv *priv, bool vsd)
+static int mlx5e_modify_channels_scatter_fcs(struct mlx5e_channels *chs, bool enable)
 {
        int err = 0;
        int i;
 
-       if (!test_bit(MLX5E_STATE_OPENED, &priv->state))
-               return 0;
+       for (i = 0; i < chs->num; i++) {
+               err = mlx5e_modify_rq_scatter_fcs(&chs->c[i]->rq, enable);
+               if (err)
+                       return err;
+       }
+
+       return 0;
+}
+
+static int mlx5e_modify_channels_vsd(struct mlx5e_channels *chs, bool vsd)
+{
+       int err = 0;
+       int i;
 
-       for (i = 0; i < priv->params.num_channels; i++) {
-               err = mlx5e_modify_rq_vsd(&priv->channel[i]->rq, vsd);
+       for (i = 0; i < chs->num; i++) {
+               err = mlx5e_modify_rq_vsd(&chs->c[i]->rq, vsd);
                if (err)
                        return err;
        }
@@ -2689,7 +2965,7 @@ int mlx5e_modify_rqs_vsd(struct mlx5e_priv *priv, bool vsd)
 static int mlx5e_setup_tc(struct net_device *netdev, u8 tc)
 {
        struct mlx5e_priv *priv = netdev_priv(netdev);
-       bool was_opened;
+       struct mlx5e_channels new_channels = {};
        int err = 0;
 
        if (tc && tc != MLX5E_MAX_NUM_TC)
@@ -2697,17 +2973,21 @@ static int mlx5e_setup_tc(struct net_device *netdev, u8 tc)
 
        mutex_lock(&priv->state_lock);
 
-       was_opened = test_bit(MLX5E_STATE_OPENED, &priv->state);
-       if (was_opened)
-               mlx5e_close_locked(priv->netdev);
+       new_channels.params = priv->channels.params;
+       new_channels.params.num_tc = tc ? tc : 1;
 
-       priv->params.num_tc = tc ? tc : 1;
+       if (test_bit(MLX5E_STATE_OPENED, &priv->state)) {
+               priv->channels.params = new_channels.params;
+               goto out;
+       }
 
-       if (was_opened)
-               err = mlx5e_open_locked(priv->netdev);
+       err = mlx5e_open_channels(priv, &new_channels);
+       if (err)
+               goto out;
 
+       mlx5e_switch_priv_channels(priv, &new_channels, NULL);
+out:
        mutex_unlock(&priv->state_lock);
-
        return err;
 }
 
@@ -2737,7 +3017,9 @@ mqprio:
        if (tc->type != TC_SETUP_MQPRIO)
                return -EINVAL;
 
-       return mlx5e_setup_tc(dev, tc->tc);
+       tc->mqprio->hw = TC_MQPRIO_HW_OFFLOAD_TCS;
+
+       return mlx5e_setup_tc(dev, tc->mqprio->num_tc);
 }
 
 static void
@@ -2822,26 +3104,31 @@ typedef int (*mlx5e_feature_handler)(struct net_device *netdev, bool enable);
 static int set_feature_lro(struct net_device *netdev, bool enable)
 {
        struct mlx5e_priv *priv = netdev_priv(netdev);
-       bool was_opened = test_bit(MLX5E_STATE_OPENED, &priv->state);
-       int err;
+       struct mlx5e_channels new_channels = {};
+       int err = 0;
+       bool reset;
 
        mutex_lock(&priv->state_lock);
 
-       if (was_opened && (priv->params.rq_wq_type == MLX5_WQ_TYPE_LINKED_LIST))
-               mlx5e_close_locked(priv->netdev);
+       reset = (priv->channels.params.rq_wq_type == MLX5_WQ_TYPE_LINKED_LIST);
+       reset = reset && test_bit(MLX5E_STATE_OPENED, &priv->state);
 
-       priv->params.lro_en = enable;
-       err = mlx5e_modify_tirs_lro(priv);
-       if (err) {
-               netdev_err(netdev, "lro modify failed, %d\n", err);
-               priv->params.lro_en = !enable;
+       new_channels.params = priv->channels.params;
+       new_channels.params.lro_en = enable;
+
+       if (!reset) {
+               priv->channels.params = new_channels.params;
+               err = mlx5e_modify_tirs_lro(priv);
+               goto out;
        }
 
-       if (was_opened && (priv->params.rq_wq_type == MLX5_WQ_TYPE_LINKED_LIST))
-               mlx5e_open_locked(priv->netdev);
+       err = mlx5e_open_channels(priv, &new_channels);
+       if (err)
+               goto out;
 
+       mlx5e_switch_priv_channels(priv, &new_channels, mlx5e_modify_tirs_lro);
+out:
        mutex_unlock(&priv->state_lock);
-
        return err;
 }
 
@@ -2878,18 +3165,39 @@ static int set_feature_rx_all(struct net_device *netdev, bool enable)
        return mlx5_set_port_fcs(mdev, !enable);
 }
 
-static int set_feature_rx_vlan(struct net_device *netdev, bool enable)
+static int set_feature_rx_fcs(struct net_device *netdev, bool enable)
 {
        struct mlx5e_priv *priv = netdev_priv(netdev);
        int err;
 
        mutex_lock(&priv->state_lock);
 
-       priv->params.vlan_strip_disable = !enable;
-       err = mlx5e_modify_rqs_vsd(priv, !enable);
+       priv->channels.params.scatter_fcs_en = enable;
+       err = mlx5e_modify_channels_scatter_fcs(&priv->channels, enable);
+       if (err)
+               priv->channels.params.scatter_fcs_en = !enable;
+
+       mutex_unlock(&priv->state_lock);
+
+       return err;
+}
+
+static int set_feature_rx_vlan(struct net_device *netdev, bool enable)
+{
+       struct mlx5e_priv *priv = netdev_priv(netdev);
+       int err = 0;
+
+       mutex_lock(&priv->state_lock);
+
+       priv->channels.params.vlan_strip_disable = !enable;
+       if (!test_bit(MLX5E_STATE_OPENED, &priv->state))
+               goto unlock;
+
+       err = mlx5e_modify_channels_vsd(&priv->channels, !enable);
        if (err)
-               priv->params.vlan_strip_disable = enable;
+               priv->channels.params.vlan_strip_disable = enable;
 
+unlock:
        mutex_unlock(&priv->state_lock);
 
        return err;
@@ -2947,6 +3255,8 @@ static int mlx5e_set_features(struct net_device *netdev,
                                    set_feature_tc_num_filters);
        err |= mlx5e_handle_feature(netdev, features, NETIF_F_RXALL,
                                    set_feature_rx_all);
+       err |= mlx5e_handle_feature(netdev, features, NETIF_F_RXFCS,
+                                   set_feature_rx_fcs);
        err |= mlx5e_handle_feature(netdev, features, NETIF_F_HW_VLAN_CTAG_RX,
                                    set_feature_rx_vlan);
 #ifdef CONFIG_RFS_ACCEL
@@ -2960,28 +3270,38 @@ static int mlx5e_set_features(struct net_device *netdev,
 static int mlx5e_change_mtu(struct net_device *netdev, int new_mtu)
 {
        struct mlx5e_priv *priv = netdev_priv(netdev);
-       bool was_opened;
+       struct mlx5e_channels new_channels = {};
+       int curr_mtu;
        int err = 0;
        bool reset;
 
        mutex_lock(&priv->state_lock);
 
-       reset = !priv->params.lro_en &&
-               (priv->params.rq_wq_type !=
+       reset = !priv->channels.params.lro_en &&
+               (priv->channels.params.rq_wq_type !=
                 MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ);
 
-       was_opened = test_bit(MLX5E_STATE_OPENED, &priv->state);
-       if (was_opened && reset)
-               mlx5e_close_locked(netdev);
+       reset = reset && test_bit(MLX5E_STATE_OPENED, &priv->state);
 
+       curr_mtu    = netdev->mtu;
        netdev->mtu = new_mtu;
-       mlx5e_set_dev_port_mtu(netdev);
 
-       if (was_opened && reset)
-               err = mlx5e_open_locked(netdev);
+       if (!reset) {
+               mlx5e_set_dev_port_mtu(priv);
+               goto out;
+       }
 
-       mutex_unlock(&priv->state_lock);
+       new_channels.params = priv->channels.params;
+       err = mlx5e_open_channels(priv, &new_channels);
+       if (err) {
+               netdev->mtu = curr_mtu;
+               goto out;
+       }
+
+       mlx5e_switch_priv_channels(priv, &new_channels, mlx5e_set_dev_port_mtu);
 
+out:
+       mutex_unlock(&priv->state_lock);
        return err;
 }
 
@@ -3186,8 +3506,8 @@ static void mlx5e_tx_timeout(struct net_device *dev)
 
        netdev_err(dev, "TX timeout detected\n");
 
-       for (i = 0; i < priv->params.num_channels * priv->params.num_tc; i++) {
-               struct mlx5e_sq *sq = priv->txq_to_sq_map[i];
+       for (i = 0; i < priv->channels.num * priv->channels.params.num_tc; i++) {
+               struct mlx5e_txqsq *sq = priv->txq2sq[i];
 
                if (!netif_xmit_stopped(netdev_get_tx_queue(dev, i)))
                        continue;
@@ -3219,7 +3539,7 @@ static int mlx5e_xdp_set(struct net_device *netdev, struct bpf_prog *prog)
 
        was_opened = test_bit(MLX5E_STATE_OPENED, &priv->state);
        /* no need for full reset when exchanging programs */
-       reset = (!priv->xdp_prog || !prog);
+       reset = (!priv->channels.params.xdp_prog || !prog);
 
        if (was_opened && reset)
                mlx5e_close_locked(netdev);
@@ -3227,7 +3547,7 @@ static int mlx5e_xdp_set(struct net_device *netdev, struct bpf_prog *prog)
                /* num_channels is invariant here, so we can take the
                 * batched reference right upfront.
                 */
-               prog = bpf_prog_add(prog, priv->params.num_channels);
+               prog = bpf_prog_add(prog, priv->channels.num);
                if (IS_ERR(prog)) {
                        err = PTR_ERR(prog);
                        goto unlock;
@@ -3237,12 +3557,12 @@ static int mlx5e_xdp_set(struct net_device *netdev, struct bpf_prog *prog)
        /* exchange programs, extra prog reference we got from caller
         * as long as we don't fail from this point onwards.
         */
-       old_prog = xchg(&priv->xdp_prog, prog);
+       old_prog = xchg(&priv->channels.params.xdp_prog, prog);
        if (old_prog)
                bpf_prog_put(old_prog);
 
        if (reset) /* change RQ type according to priv->xdp_prog */
-               mlx5e_set_rq_priv_params(priv);
+               mlx5e_set_rq_params(priv->mdev, &priv->channels.params);
 
        if (was_opened && reset)
                mlx5e_open_locked(netdev);
@@ -3253,8 +3573,8 @@ static int mlx5e_xdp_set(struct net_device *netdev, struct bpf_prog *prog)
        /* exchanging programs w/o reset, we update ref counts on behalf
         * of the channels RQs here.
         */
-       for (i = 0; i < priv->params.num_channels; i++) {
-               struct mlx5e_channel *c = priv->channel[i];
+       for (i = 0; i < priv->channels.num; i++) {
+               struct mlx5e_channel *c = priv->channels.c[i];
 
                clear_bit(MLX5E_RQ_STATE_ENABLED, &c->rq.state);
                napi_synchronize(&c->napi);
@@ -3280,7 +3600,7 @@ static bool mlx5e_xdp_attached(struct net_device *dev)
 {
        struct mlx5e_priv *priv = netdev_priv(dev);
 
-       return !!priv->xdp_prog;
+       return !!priv->channels.params.xdp_prog;
 }
 
 static int mlx5e_xdp(struct net_device *dev, struct netdev_xdp *xdp)
@@ -3303,10 +3623,12 @@ static int mlx5e_xdp(struct net_device *dev, struct netdev_xdp *xdp)
 static void mlx5e_netpoll(struct net_device *dev)
 {
        struct mlx5e_priv *priv = netdev_priv(dev);
+       struct mlx5e_channels *chs = &priv->channels;
+
        int i;
 
-       for (i = 0; i < priv->params.num_channels; i++)
-               napi_schedule(&priv->channel[i]->napi);
+       for (i = 0; i < chs->num; i++)
+               napi_schedule(&chs->c[i]->napi);
 }
 #endif
 
@@ -3475,6 +3797,13 @@ void mlx5e_set_rx_cq_mode_params(struct mlx5e_params *params, u8 cq_period_mode)
        if (cq_period_mode == MLX5_CQ_PERIOD_MODE_START_FROM_CQE)
                params->rx_cq_moderation.usec =
                        MLX5E_PARAMS_DEFAULT_RX_CQ_MODERATION_USEC_FROM_CQE;
+
+       if (params->rx_am_enabled)
+               params->rx_cq_moderation =
+                       mlx5e_am_get_def_profile(params->rx_cq_period_mode);
+
+       MLX5E_SET_PFLAG(params, MLX5E_PFLAG_RX_CQE_BASED_MODER,
+                       params->rx_cq_period_mode == MLX5_CQ_PERIOD_MODE_START_FROM_CQE);
 }
 
 u32 mlx5e_choose_lro_timeout(struct mlx5_core_dev *mdev, u32 wanted_timeout)
@@ -3489,75 +3818,80 @@ u32 mlx5e_choose_lro_timeout(struct mlx5_core_dev *mdev, u32 wanted_timeout)
        return MLX5_CAP_ETH(mdev, lro_timer_supported_periods[i]);
 }
 
-static void mlx5e_build_nic_netdev_priv(struct mlx5_core_dev *mdev,
-                                       struct net_device *netdev,
-                                       const struct mlx5e_profile *profile,
-                                       void *ppriv)
+void mlx5e_build_nic_params(struct mlx5_core_dev *mdev,
+                           struct mlx5e_params *params,
+                           u16 max_channels)
 {
-       struct mlx5e_priv *priv = netdev_priv(netdev);
+       u8 cq_period_mode = 0;
        u32 link_speed = 0;
        u32 pci_bw = 0;
-       u8 cq_period_mode = MLX5_CAP_GEN(mdev, cq_period_start_from_cqe) ?
-                                        MLX5_CQ_PERIOD_MODE_START_FROM_CQE :
-                                        MLX5_CQ_PERIOD_MODE_START_FROM_EQE;
 
-       priv->mdev                         = mdev;
-       priv->netdev                       = netdev;
-       priv->params.num_channels          = profile->max_nch(mdev);
-       priv->profile                      = profile;
-       priv->ppriv                        = ppriv;
+       params->num_channels = max_channels;
+       params->num_tc       = 1;
 
-       priv->params.lro_timeout =
-               mlx5e_choose_lro_timeout(mdev, MLX5E_DEFAULT_LRO_TIMEOUT);
-
-       priv->params.log_sq_size = is_kdump_kernel() ?
+       /* SQ */
+       params->log_sq_size = is_kdump_kernel() ?
                MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE :
                MLX5E_PARAMS_DEFAULT_LOG_SQ_SIZE;
 
        /* set CQE compression */
-       priv->params.rx_cqe_compress_def = false;
+       params->rx_cqe_compress_def = false;
        if (MLX5_CAP_GEN(mdev, cqe_compression) &&
-           MLX5_CAP_GEN(mdev, vport_group_manager)) {
+            MLX5_CAP_GEN(mdev, vport_group_manager)) {
                mlx5e_get_max_linkspeed(mdev, &link_speed);
                mlx5e_get_pci_bw(mdev, &pci_bw);
                mlx5_core_dbg(mdev, "Max link speed = %d, PCI BW = %d\n",
-                             link_speed, pci_bw);
-               priv->params.rx_cqe_compress_def =
-                       cqe_compress_heuristic(link_speed, pci_bw);
+                              link_speed, pci_bw);
+               params->rx_cqe_compress_def = cqe_compress_heuristic(link_speed, pci_bw);
        }
-
-       MLX5E_SET_PFLAG(priv, MLX5E_PFLAG_RX_CQE_COMPRESS,
-                       priv->params.rx_cqe_compress_def);
-
-       mlx5e_set_rq_priv_params(priv);
-       if (priv->params.rq_wq_type == MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ)
-               priv->params.lro_en = true;
-
-       priv->params.rx_am_enabled = MLX5_CAP_GEN(mdev, cq_moderation);
-       mlx5e_set_rx_cq_mode_params(&priv->params, cq_period_mode);
-
-       priv->params.tx_cq_moderation.usec =
-               MLX5E_PARAMS_DEFAULT_TX_CQ_MODERATION_USEC;
-       priv->params.tx_cq_moderation.pkts =
-               MLX5E_PARAMS_DEFAULT_TX_CQ_MODERATION_PKTS;
-       priv->params.tx_max_inline         = mlx5e_get_max_inline_cap(mdev);
-       mlx5_query_min_inline(mdev, &priv->params.tx_min_inline_mode);
-       if (priv->params.tx_min_inline_mode == MLX5_INLINE_MODE_NONE &&
+       MLX5E_SET_PFLAG(params, MLX5E_PFLAG_RX_CQE_COMPRESS, params->rx_cqe_compress_def);
+
+       /* RQ */
+       mlx5e_set_rq_params(mdev, params);
+
+       /* HW LRO */
+       /* TODO: && MLX5_CAP_ETH(mdev, lro_cap) */
+       if (params->rq_wq_type == MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ)
+               params->lro_en = true;
+       params->lro_timeout = mlx5e_choose_lro_timeout(mdev, MLX5E_DEFAULT_LRO_TIMEOUT);
+
+       /* CQ moderation params */
+       cq_period_mode = MLX5_CAP_GEN(mdev, cq_period_start_from_cqe) ?
+                       MLX5_CQ_PERIOD_MODE_START_FROM_CQE :
+                       MLX5_CQ_PERIOD_MODE_START_FROM_EQE;
+       params->rx_am_enabled = MLX5_CAP_GEN(mdev, cq_moderation);
+       mlx5e_set_rx_cq_mode_params(params, cq_period_mode);
+
+       params->tx_cq_moderation.usec = MLX5E_PARAMS_DEFAULT_TX_CQ_MODERATION_USEC;
+       params->tx_cq_moderation.pkts = MLX5E_PARAMS_DEFAULT_TX_CQ_MODERATION_PKTS;
+
+       /* TX inline */
+       params->tx_max_inline = mlx5e_get_max_inline_cap(mdev);
+       mlx5_query_min_inline(mdev, &params->tx_min_inline_mode);
+       if (params->tx_min_inline_mode == MLX5_INLINE_MODE_NONE &&
            !MLX5_CAP_ETH(mdev, wqe_vlan_insert))
-               priv->params.tx_min_inline_mode = MLX5_INLINE_MODE_L2;
+               params->tx_min_inline_mode = MLX5_INLINE_MODE_L2;
 
-       priv->params.num_tc                = 1;
-       priv->params.rss_hfunc             = ETH_RSS_HASH_XOR;
+       /* RSS */
+       params->rss_hfunc = ETH_RSS_HASH_XOR;
+       netdev_rss_key_fill(params->toeplitz_hash_key, sizeof(params->toeplitz_hash_key));
+       mlx5e_build_default_indir_rqt(mdev, params->indirection_rqt,
+                                     MLX5E_INDIR_RQT_SIZE, max_channels);
+}
 
-       netdev_rss_key_fill(priv->params.toeplitz_hash_key,
-                           sizeof(priv->params.toeplitz_hash_key));
+static void mlx5e_build_nic_netdev_priv(struct mlx5_core_dev *mdev,
+                                       struct net_device *netdev,
+                                       const struct mlx5e_profile *profile,
+                                       void *ppriv)
+{
+       struct mlx5e_priv *priv = netdev_priv(netdev);
 
-       mlx5e_build_default_indir_rqt(mdev, priv->params.indirection_rqt,
-                                     MLX5E_INDIR_RQT_SIZE, profile->max_nch(mdev));
+       priv->mdev        = mdev;
+       priv->netdev      = netdev;
+       priv->profile     = profile;
+       priv->ppriv       = ppriv;
 
-       /* Initialize pflags */
-       MLX5E_SET_PFLAG(priv, MLX5E_PFLAG_RX_CQE_BASED_MODER,
-                       priv->params.rx_cq_period_mode == MLX5_CQ_PERIOD_MODE_START_FROM_CQE);
+       mlx5e_build_nic_params(mdev, &priv->channels.params, profile->max_nch(mdev));
 
        mutex_init(&priv->state_lock);
 
@@ -3642,13 +3976,19 @@ static void mlx5e_build_nic_netdev(struct net_device *netdev)
        if (fcs_supported)
                netdev->hw_features |= NETIF_F_RXALL;
 
+       if (MLX5_CAP_ETH(mdev, scatter_fcs))
+               netdev->hw_features |= NETIF_F_RXFCS;
+
        netdev->features          = netdev->hw_features;
-       if (!priv->params.lro_en)
+       if (!priv->channels.params.lro_en)
                netdev->features  &= ~NETIF_F_LRO;
 
        if (fcs_enabled)
                netdev->features  &= ~NETIF_F_RXALL;
 
+       if (!priv->channels.params.scatter_fcs_en)
+               netdev->features  &= ~NETIF_F_RXFCS;
+
 #define FT_CAP(f) MLX5_CAP_FLOWTABLE(mdev, flow_table_properties_nic_receive.f)
        if (FT_CAP(flow_modify_en) &&
            FT_CAP(modify_root) &&
@@ -3708,39 +4048,30 @@ static void mlx5e_nic_cleanup(struct mlx5e_priv *priv)
 {
        mlx5e_vxlan_cleanup(priv);
 
-       if (priv->xdp_prog)
-               bpf_prog_put(priv->xdp_prog);
+       if (priv->channels.params.xdp_prog)
+               bpf_prog_put(priv->channels.params.xdp_prog);
 }
 
 static int mlx5e_init_nic_rx(struct mlx5e_priv *priv)
 {
        struct mlx5_core_dev *mdev = priv->mdev;
        int err;
-       int i;
 
-       err = mlx5e_create_indirect_rqts(priv);
-       if (err) {
-               mlx5_core_warn(mdev, "create indirect rqts failed, %d\n", err);
+       err = mlx5e_create_indirect_rqt(priv);
+       if (err)
                return err;
-       }
 
        err = mlx5e_create_direct_rqts(priv);
-       if (err) {
-               mlx5_core_warn(mdev, "create direct rqts failed, %d\n", err);
+       if (err)
                goto err_destroy_indirect_rqts;
-       }
 
        err = mlx5e_create_indirect_tirs(priv);
-       if (err) {
-               mlx5_core_warn(mdev, "create indirect tirs failed, %d\n", err);
+       if (err)
                goto err_destroy_direct_rqts;
-       }
 
        err = mlx5e_create_direct_tirs(priv);
-       if (err) {
-               mlx5_core_warn(mdev, "create direct tirs failed, %d\n", err);
+       if (err)
                goto err_destroy_indirect_tirs;
-       }
 
        err = mlx5e_create_flow_steering(priv);
        if (err) {
@@ -3761,8 +4092,7 @@ err_destroy_direct_tirs:
 err_destroy_indirect_tirs:
        mlx5e_destroy_indirect_tirs(priv);
 err_destroy_direct_rqts:
-       for (i = 0; i < priv->profile->max_nch(mdev); i++)
-               mlx5e_destroy_rqt(priv, &priv->direct_tir[i].rqt);
+       mlx5e_destroy_direct_rqts(priv);
 err_destroy_indirect_rqts:
        mlx5e_destroy_rqt(priv, &priv->indir_rqt);
        return err;
@@ -3770,14 +4100,11 @@ err_destroy_indirect_rqts:
 
 static void mlx5e_cleanup_nic_rx(struct mlx5e_priv *priv)
 {
-       int i;
-
        mlx5e_tc_cleanup(priv);
        mlx5e_destroy_flow_steering(priv);
        mlx5e_destroy_direct_tirs(priv);
        mlx5e_destroy_indirect_tirs(priv);
-       for (i = 0; i < priv->profile->max_nch(priv->mdev); i++)
-               mlx5e_destroy_rqt(priv, &priv->direct_tir[i].rqt);
+       mlx5e_destroy_direct_rqts(priv);
        mlx5e_destroy_rqt(priv, &priv->indir_rqt);
 }
 
@@ -3801,21 +4128,22 @@ static void mlx5e_nic_enable(struct mlx5e_priv *priv)
 {
        struct net_device *netdev = priv->netdev;
        struct mlx5_core_dev *mdev = priv->mdev;
-       struct mlx5_eswitch *esw = mdev->priv.eswitch;
-       struct mlx5_eswitch_rep rep;
+       u16 max_mtu;
+
+       mlx5e_init_l2_addr(priv);
+
+       /* MTU range: 68 - hw-specific max */
+       netdev->min_mtu = ETH_MIN_MTU;
+       mlx5_query_port_max_mtu(priv->mdev, &max_mtu, 1);
+       netdev->max_mtu = MLX5E_HW2SW_MTU(max_mtu);
+       mlx5e_set_dev_port_mtu(priv);
 
        mlx5_lag_add(mdev, netdev);
 
        mlx5e_enable_async_events(priv);
 
-       if (MLX5_CAP_GEN(mdev, vport_group_manager)) {
-               mlx5_query_nic_vport_mac_address(mdev, 0, rep.hw_id);
-               rep.load = mlx5e_nic_rep_load;
-               rep.unload = mlx5e_nic_rep_unload;
-               rep.vport = FDB_UPLINK_VPORT;
-               rep.netdev = netdev;
-               mlx5_eswitch_register_vport_rep(esw, 0, &rep);
-       }
+       if (MLX5_CAP_GEN(mdev, vport_group_manager))
+               mlx5e_register_vport_reps(priv);
 
        if (netdev->reg_state != NETREG_REGISTERED)
                return;
@@ -3828,16 +4156,29 @@ static void mlx5e_nic_enable(struct mlx5e_priv *priv)
        }
 
        queue_work(priv->wq, &priv->set_rx_mode_work);
+
+       rtnl_lock();
+       if (netif_running(netdev))
+               mlx5e_open(netdev);
+       netif_device_attach(netdev);
+       rtnl_unlock();
 }
 
 static void mlx5e_nic_disable(struct mlx5e_priv *priv)
 {
        struct mlx5_core_dev *mdev = priv->mdev;
-       struct mlx5_eswitch *esw = mdev->priv.eswitch;
+
+       rtnl_lock();
+       if (netif_running(priv->netdev))
+               mlx5e_close(priv->netdev);
+       netif_device_detach(priv->netdev);
+       rtnl_unlock();
 
        queue_work(priv->wq, &priv->set_rx_mode_work);
+
        if (MLX5_CAP_GEN(mdev, vport_group_manager))
-               mlx5_eswitch_unregister_vport_rep(esw, 0);
+               mlx5e_unregister_vport_reps(priv);
+
        mlx5e_disable_async_events(priv);
        mlx5_lag_remove(mdev);
 }
@@ -3853,9 +4194,13 @@ static const struct mlx5e_profile mlx5e_nic_profile = {
        .disable           = mlx5e_nic_disable,
        .update_stats      = mlx5e_update_stats,
        .max_nch           = mlx5e_get_max_num_channels,
+       .rx_handlers.handle_rx_cqe       = mlx5e_handle_rx_cqe,
+       .rx_handlers.handle_rx_cqe_mpwqe = mlx5e_handle_rx_cqe_mpwrq,
        .max_tc            = MLX5E_MAX_NUM_TC,
 };
 
+/* mlx5e generic netdev management API (move to en_common.c) */
+
 struct net_device *mlx5e_create_netdev(struct mlx5_core_dev *mdev,
                                       const struct mlx5e_profile *profile,
                                       void *ppriv)
@@ -3872,6 +4217,10 @@ struct net_device *mlx5e_create_netdev(struct mlx5_core_dev *mdev,
                return NULL;
        }
 
+#ifdef CONFIG_RFS_ACCEL
+       netdev->rx_cpu_rmap = mdev->rmap;
+#endif
+
        profile->init(mdev, netdev, profile, ppriv);
 
        netif_carrier_off(netdev);
@@ -3891,14 +4240,12 @@ err_cleanup_nic:
        return NULL;
 }
 
-int mlx5e_attach_netdev(struct mlx5_core_dev *mdev, struct net_device *netdev)
+int mlx5e_attach_netdev(struct mlx5e_priv *priv)
 {
+       struct mlx5_core_dev *mdev = priv->mdev;
        const struct mlx5e_profile *profile;
-       struct mlx5e_priv *priv;
-       u16 max_mtu;
        int err;
 
-       priv = netdev_priv(netdev);
        profile = priv->profile;
        clear_bit(MLX5E_STATE_DESTROYING, &priv->state);
 
@@ -3906,7 +4253,7 @@ int mlx5e_attach_netdev(struct mlx5_core_dev *mdev, struct net_device *netdev)
        if (err)
                goto out;
 
-       err = mlx5e_open_drop_rq(priv);
+       err = mlx5e_open_drop_rq(mdev, &priv->drop_rq);
        if (err) {
                mlx5_core_err(mdev, "open drop rq failed, %d\n", err);
                goto err_cleanup_tx;
@@ -3918,28 +4265,13 @@ int mlx5e_attach_netdev(struct mlx5_core_dev *mdev, struct net_device *netdev)
 
        mlx5e_create_q_counter(priv);
 
-       mlx5e_init_l2_addr(priv);
-
-       /* MTU range: 68 - hw-specific max */
-       netdev->min_mtu = ETH_MIN_MTU;
-       mlx5_query_port_max_mtu(priv->mdev, &max_mtu, 1);
-       netdev->max_mtu = MLX5E_HW2SW_MTU(max_mtu);
-
-       mlx5e_set_dev_port_mtu(netdev);
-
        if (profile->enable)
                profile->enable(priv);
 
-       rtnl_lock();
-       if (netif_running(netdev))
-               mlx5e_open(netdev);
-       netif_device_attach(netdev);
-       rtnl_unlock();
-
        return 0;
 
 err_close_drop_rq:
-       mlx5e_close_drop_rq(priv);
+       mlx5e_close_drop_rq(&priv->drop_rq);
 
 err_cleanup_tx:
        profile->cleanup_tx(priv);
@@ -3948,66 +4280,34 @@ out:
        return err;
 }
 
-static void mlx5e_register_vport_rep(struct mlx5_core_dev *mdev)
-{
-       struct mlx5_eswitch *esw = mdev->priv.eswitch;
-       int total_vfs = MLX5_TOTAL_VPORTS(mdev);
-       int vport;
-       u8 mac[ETH_ALEN];
-
-       if (!MLX5_CAP_GEN(mdev, vport_group_manager))
-               return;
-
-       mlx5_query_nic_vport_mac_address(mdev, 0, mac);
-
-       for (vport = 1; vport < total_vfs; vport++) {
-               struct mlx5_eswitch_rep rep;
-
-               rep.load = mlx5e_vport_rep_load;
-               rep.unload = mlx5e_vport_rep_unload;
-               rep.vport = vport;
-               ether_addr_copy(rep.hw_id, mac);
-               mlx5_eswitch_register_vport_rep(esw, vport, &rep);
-       }
-}
-
-static void mlx5e_unregister_vport_rep(struct mlx5_core_dev *mdev)
-{
-       struct mlx5_eswitch *esw = mdev->priv.eswitch;
-       int total_vfs = MLX5_TOTAL_VPORTS(mdev);
-       int vport;
-
-       if (!MLX5_CAP_GEN(mdev, vport_group_manager))
-               return;
-
-       for (vport = 1; vport < total_vfs; vport++)
-               mlx5_eswitch_unregister_vport_rep(esw, vport);
-}
-
-void mlx5e_detach_netdev(struct mlx5_core_dev *mdev, struct net_device *netdev)
+void mlx5e_detach_netdev(struct mlx5e_priv *priv)
 {
-       struct mlx5e_priv *priv = netdev_priv(netdev);
        const struct mlx5e_profile *profile = priv->profile;
 
        set_bit(MLX5E_STATE_DESTROYING, &priv->state);
 
-       rtnl_lock();
-       if (netif_running(netdev))
-               mlx5e_close(netdev);
-       netif_device_detach(netdev);
-       rtnl_unlock();
-
        if (profile->disable)
                profile->disable(priv);
        flush_workqueue(priv->wq);
 
        mlx5e_destroy_q_counter(priv);
        profile->cleanup_rx(priv);
-       mlx5e_close_drop_rq(priv);
+       mlx5e_close_drop_rq(&priv->drop_rq);
        profile->cleanup_tx(priv);
        cancel_delayed_work_sync(&priv->update_stats_work);
 }
 
+void mlx5e_destroy_netdev(struct mlx5e_priv *priv)
+{
+       const struct mlx5e_profile *profile = priv->profile;
+       struct net_device *netdev = priv->netdev;
+
+       destroy_workqueue(priv->wq);
+       if (profile->cleanup)
+               profile->cleanup(priv);
+       free_netdev(netdev);
+}
+
 /* mlx5e_attach and mlx5e_detach scope should be only creating/destroying
  * hardware contexts and to connect it to the current netdev.
  */
@@ -4024,13 +4324,12 @@ static int mlx5e_attach(struct mlx5_core_dev *mdev, void *vpriv)
        if (err)
                return err;
 
-       err = mlx5e_attach_netdev(mdev, netdev);
+       err = mlx5e_attach_netdev(priv);
        if (err) {
                mlx5e_destroy_mdev_resources(mdev);
                return err;
        }
 
-       mlx5e_register_vport_rep(mdev);
        return 0;
 }
 
@@ -4042,8 +4341,7 @@ static void mlx5e_detach(struct mlx5_core_dev *mdev, void *vpriv)
        if (!netif_device_present(netdev))
                return;
 
-       mlx5e_unregister_vport_rep(mdev);
-       mlx5e_detach_netdev(mdev, netdev);
+       mlx5e_detach_netdev(priv);
        mlx5e_destroy_mdev_resources(mdev);
 }
 
@@ -4051,7 +4349,7 @@ static void *mlx5e_add(struct mlx5_core_dev *mdev)
 {
        struct mlx5_eswitch *esw = mdev->priv.eswitch;
        int total_vfs = MLX5_TOTAL_VPORTS(mdev);
-       void *ppriv = NULL;
+       struct mlx5e_rep_priv *rpriv = NULL;
        void *priv;
        int vport;
        int err;
@@ -4061,10 +4359,17 @@ static void *mlx5e_add(struct mlx5_core_dev *mdev)
        if (err)
                return NULL;
 
-       if (MLX5_CAP_GEN(mdev, vport_group_manager))
-               ppriv = &esw->offloads.vport_reps[0];
+       if (MLX5_CAP_GEN(mdev, vport_group_manager)) {
+               rpriv = kzalloc(sizeof(*rpriv), GFP_KERNEL);
+               if (!rpriv) {
+                       mlx5_core_warn(mdev,
+                                      "Not creating net device, Failed to alloc rep priv data\n");
+                       return NULL;
+               }
+               rpriv->rep = &esw->offloads.vport_reps[0];
+       }
 
-       netdev = mlx5e_create_netdev(mdev, &mlx5e_nic_profile, ppriv);
+       netdev = mlx5e_create_netdev(mdev, &mlx5e_nic_profile, rpriv);
        if (!netdev) {
                mlx5_core_err(mdev, "mlx5e_create_netdev failed\n");
                goto err_unregister_reps;
@@ -4090,33 +4395,25 @@ err_detach:
        mlx5e_detach(mdev, priv);
 
 err_destroy_netdev:
-       mlx5e_destroy_netdev(mdev, priv);
+       mlx5e_destroy_netdev(priv);
 
 err_unregister_reps:
        for (vport = 1; vport < total_vfs; vport++)
                mlx5_eswitch_unregister_vport_rep(esw, vport);
 
+       kfree(rpriv);
        return NULL;
 }
 
-void mlx5e_destroy_netdev(struct mlx5_core_dev *mdev, struct mlx5e_priv *priv)
-{
-       const struct mlx5e_profile *profile = priv->profile;
-       struct net_device *netdev = priv->netdev;
-
-       destroy_workqueue(priv->wq);
-       if (profile->cleanup)
-               profile->cleanup(priv);
-       free_netdev(netdev);
-}
-
 static void mlx5e_remove(struct mlx5_core_dev *mdev, void *vpriv)
 {
        struct mlx5e_priv *priv = vpriv;
+       void *ppriv = priv->ppriv;
 
        unregister_netdev(priv->netdev);
        mlx5e_detach(mdev, vpriv);
-       mlx5e_destroy_netdev(mdev, priv);
+       mlx5e_destroy_netdev(priv);
+       kfree(ppriv);
 }
 
 static void *mlx5e_get_netdev(void *vpriv)