|
@@ -52,7 +52,6 @@ struct mlx5e_sq_param {
|
|
|
struct mlx5_wq_param wq;
|
|
|
u16 max_inline;
|
|
|
u8 min_inline_mode;
|
|
|
- enum mlx5e_sq_type type;
|
|
|
};
|
|
|
|
|
|
struct mlx5e_cq_param {
|
|
@@ -402,8 +401,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;
|
|
@@ -539,9 +540,9 @@ static int mlx5e_create_rq_umr_mkey(struct mlx5e_rq *rq)
|
|
|
return mlx5e_create_umr_mkey(priv, 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_rq_param *param,
|
|
|
+ struct mlx5e_rq *rq)
|
|
|
{
|
|
|
struct mlx5e_priv *priv = c->priv;
|
|
|
struct mlx5_core_dev *mdev = priv->mdev;
|
|
@@ -674,7 +675,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;
|
|
|
|
|
@@ -699,7 +700,7 @@ 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;
|
|
@@ -798,7 +799,7 @@ 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);
|
|
|
}
|
|
@@ -845,37 +846,38 @@ static int mlx5e_open_rq(struct mlx5e_channel *c,
|
|
|
struct mlx5e_rq_param *param,
|
|
|
struct mlx5e_rq *rq)
|
|
|
{
|
|
|
- struct mlx5e_sq *sq = &c->icosq;
|
|
|
+ struct mlx5e_icosq *sq = &c->icosq;
|
|
|
u16 pi = sq->pc & sq->wq.sz_m1;
|
|
|
+ struct mlx5e_tx_wqe *nopwqe;
|
|
|
int err;
|
|
|
|
|
|
- err = mlx5e_create_rq(c, param, rq);
|
|
|
+ err = mlx5e_alloc_rq(c, 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)
|
|
|
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() */
|
|
|
-
|
|
|
+ nopwqe = mlx5e_post_nop(&sq->wq, sq->sqn, &sq->pc);
|
|
|
+ mlx5e_notify_hw(&sq->wq, sq->pc, sq->uar_map, &nopwqe->ctrl);
|
|
|
return 0;
|
|
|
|
|
|
-err_disable_rq:
|
|
|
- clear_bit(MLX5E_RQ_STATE_ENABLED, &rq->state);
|
|
|
- mlx5e_disable_rq(rq);
|
|
|
err_destroy_rq:
|
|
|
+ clear_bit(MLX5E_RQ_STATE_ENABLED, &rq->state);
|
|
|
mlx5e_destroy_rq(rq);
|
|
|
+err_free_rq:
|
|
|
+ mlx5e_free_rq(rq);
|
|
|
|
|
|
return err;
|
|
|
}
|
|
@@ -886,39 +888,75 @@ static void mlx5e_close_rq(struct mlx5e_rq *rq)
|
|
|
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);
|
|
|
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_sq_param *param,
|
|
|
+ struct mlx5e_xdpsq *sq)
|
|
|
+{
|
|
|
+ void *sqc_wq = MLX5_ADDR_OF(sqc, param->sqc, wq);
|
|
|
+ struct mlx5e_priv *priv = c->priv;
|
|
|
+ struct mlx5_core_dev *mdev = priv->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 = param->min_inline_mode;
|
|
|
+
|
|
|
+ param->wq.db_numa_node = cpu_to_node(c->cpu);
|
|
|
+ err = mlx5_wq_cyc_create(mdev, ¶m->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,153 +968,138 @@ 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,
|
|
|
+ int tc,
|
|
|
+ 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 mlx5e_priv *priv = c->priv;
|
|
|
+ struct mlx5_core_dev *mdev = priv->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, ¶m->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);
|
|
|
+ kfree(sq->db.skb);
|
|
|
}
|
|
|
|
|
|
-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.skb = kzalloc_node(wq_sz * sizeof(*sq->db.skb),
|
|
|
+ GFP_KERNEL, numa);
|
|
|
+ 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.skb || !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 tc,
|
|
|
+ struct mlx5e_sq_param *param,
|
|
|
+ struct mlx5e_txqsq *sq)
|
|
|
{
|
|
|
- struct mlx5e_priv *priv = c->priv;
|
|
|
+ void *sqc_wq = MLX5_ADDR_OF(sqc, param->sqc, wq);
|
|
|
+ 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);
|
|
|
+ int txq_ix;
|
|
|
int err;
|
|
|
|
|
|
- sq->type = param->type;
|
|
|
sq->pdev = c->pdev;
|
|
|
sq->tstamp = &priv->tstamp;
|
|
|
sq->mkey_be = c->mkey_be;
|
|
|
sq->channel = c;
|
|
|
sq->tc = tc;
|
|
|
+ sq->uar_map = mdev->mlx5e_res.bfreg.map;
|
|
|
+ sq->max_inline = param->max_inline;
|
|
|
+ sq->min_inline_mode = param->min_inline_mode;
|
|
|
|
|
|
- err = mlx5_alloc_bfreg(mdev, &sq->bfreg, MLX5_CAP_GEN(mdev, bf), false);
|
|
|
- if (err)
|
|
|
- return err;
|
|
|
-
|
|
|
- sq->uar_map = sq->bfreg.map;
|
|
|
param->wq.db_numa_node = cpu_to_node(c->cpu);
|
|
|
-
|
|
|
- err = mlx5_wq_cyc_create(mdev, ¶m->wq, sqc_wq, &sq->wq,
|
|
|
- &sq->wq_ctrl);
|
|
|
+ err = mlx5_wq_cyc_create(mdev, ¶m->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;
|
|
|
- }
|
|
|
+ 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_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 mlx5e_priv *priv,
|
|
|
+ struct mlx5e_sq_param *param,
|
|
|
+ struct mlx5e_create_sq_param *csp,
|
|
|
+ u32 *sqn)
|
|
|
{
|
|
|
- struct mlx5e_channel *c = sq->channel;
|
|
|
- struct mlx5e_priv *priv = c->priv;
|
|
|
struct mlx5_core_dev *mdev = priv->mdev;
|
|
|
|
|
|
void *in;
|
|
@@ -1086,7 +1109,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,38 +1118,41 @@ 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, priv->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_modify_sq_param {
|
|
|
+ int curr_state;
|
|
|
+ int next_state;
|
|
|
+ bool rl_update;
|
|
|
+ int rl_index;
|
|
|
+};
|
|
|
+
|
|
|
+static int mlx5e_modify_sq(struct mlx5e_priv *priv,
|
|
|
+ u32 sqn,
|
|
|
+ struct mlx5e_modify_sq_param *p)
|
|
|
{
|
|
|
- struct mlx5e_channel *c = sq->channel;
|
|
|
- struct mlx5e_priv *priv = c->priv;
|
|
|
struct mlx5_core_dev *mdev = priv->mdev;
|
|
|
|
|
|
void *in;
|
|
@@ -1141,64 +1167,76 @@ 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 mlx5e_priv *priv, 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(priv->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 mlx5e_priv *priv,
|
|
|
+ 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(priv, 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(priv, *sqn, &msp);
|
|
|
if (err)
|
|
|
- goto err_destroy_sq;
|
|
|
+ mlx5e_destroy_sq(priv, *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_open_txqsq(struct mlx5e_channel *c,
|
|
|
+ int tc,
|
|
|
+ struct mlx5e_sq_param *param,
|
|
|
+ struct mlx5e_txqsq *sq)
|
|
|
+{
|
|
|
+ struct mlx5e_create_sq_param csp = {};
|
|
|
+ struct mlx5e_priv *priv = c->priv;
|
|
|
+ int err;
|
|
|
+
|
|
|
+ err = mlx5e_alloc_txqsq(c, tc, 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 = priv->tisn[sq->tc];
|
|
|
+ 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;
|
|
|
+ set_bit(MLX5E_SQ_STATE_ENABLED, &sq->state);
|
|
|
+ err = mlx5e_create_sq_rdy(c->priv, param, &csp, &sq->sqn);
|
|
|
+ if (err)
|
|
|
+ goto err_free_txqsq;
|
|
|
|
|
|
+ netdev_tx_reset_queue(sq->txq);
|
|
|
+ netif_tx_start_queue(sq->txq);
|
|
|
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;
|
|
|
}
|
|
@@ -1210,30 +1248,142 @@ 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_close_txqsq(struct mlx5e_txqsq *sq)
|
|
|
{
|
|
|
+ struct mlx5e_channel *c = sq->channel;
|
|
|
+ struct mlx5e_priv *priv = c->priv;
|
|
|
+ struct mlx5_core_dev *mdev = priv->mdev;
|
|
|
+
|
|
|
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.skb[(sq->pc & sq->wq.sz_m1)] = NULL;
|
|
|
+ nop = mlx5e_post_nop(&sq->wq, sq->sqn, &sq->pc);
|
|
|
+ mlx5e_notify_hw(&sq->wq, sq->pc, sq->uar_map, &nop->ctrl);
|
|
|
}
|
|
|
|
|
|
- mlx5e_disable_sq(sq);
|
|
|
- mlx5e_free_sq_descs(sq);
|
|
|
- mlx5e_destroy_sq(sq);
|
|
|
+ mlx5e_destroy_sq(priv, 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_open_icosq(struct mlx5e_channel *c,
|
|
|
+ int tc,
|
|
|
+ struct mlx5e_sq_param *param,
|
|
|
+ struct mlx5e_icosq *sq)
|
|
|
+{
|
|
|
+ struct mlx5e_create_sq_param csp = {};
|
|
|
+ int err;
|
|
|
+
|
|
|
+ err = mlx5e_alloc_icosq(c, tc, param, sq);
|
|
|
+ if (err)
|
|
|
+ return err;
|
|
|
+
|
|
|
+ csp.cqn = sq->cq.mcq.cqn;
|
|
|
+ csp.wq_ctrl = &sq->wq_ctrl;
|
|
|
+ csp.min_inline_mode = param->min_inline_mode;
|
|
|
+ set_bit(MLX5E_SQ_STATE_ENABLED, &sq->state);
|
|
|
+ err = mlx5e_create_sq_rdy(c->priv, 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 int mlx5e_create_cq(struct mlx5e_channel *c,
|
|
|
- struct mlx5e_cq_param *param,
|
|
|
- struct mlx5e_cq *cq)
|
|
|
+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->priv, sq->sqn);
|
|
|
+ mlx5e_free_icosq(sq);
|
|
|
+}
|
|
|
+
|
|
|
+static int mlx5e_open_xdpsq(struct mlx5e_channel *c,
|
|
|
+ struct mlx5e_sq_param *param,
|
|
|
+ struct mlx5e_xdpsq *sq)
|
|
|
+{
|
|
|
+ unsigned int ds_cnt = MLX5E_XDP_TX_DS_COUNT;
|
|
|
+ struct mlx5e_create_sq_param csp = {};
|
|
|
+ struct mlx5e_priv *priv = c->priv;
|
|
|
+ unsigned int inline_hdr_sz = 0;
|
|
|
+ int err;
|
|
|
+ int i;
|
|
|
+
|
|
|
+ err = mlx5e_alloc_xdpsq(c, param, sq);
|
|
|
+ if (err)
|
|
|
+ return err;
|
|
|
+
|
|
|
+ csp.tis_lst_sz = 1;
|
|
|
+ csp.tisn = 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->priv, 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->priv, sq->sqn);
|
|
|
+ mlx5e_free_xdpsq_descs(sq);
|
|
|
+ mlx5e_free_xdpsq(sq);
|
|
|
+}
|
|
|
+
|
|
|
+static int mlx5e_alloc_cq(struct mlx5e_channel *c,
|
|
|
+ struct mlx5e_cq_param *param,
|
|
|
+ struct mlx5e_cq *cq)
|
|
|
{
|
|
|
struct mlx5e_priv *priv = c->priv;
|
|
|
struct mlx5_core_dev *mdev = priv->mdev;
|
|
@@ -1278,12 +1428,12 @@ static int mlx5e_create_cq(struct mlx5e_channel *c,
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-static void mlx5e_destroy_cq(struct mlx5e_cq *cq)
|
|
|
+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;
|
|
@@ -1330,7 +1480,7 @@ 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;
|
|
@@ -1347,13 +1497,13 @@ static int mlx5e_open_cq(struct mlx5e_channel *c,
|
|
|
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,
|
|
@@ -1361,16 +1511,16 @@ static int mlx5e_open_cq(struct mlx5e_channel *c,
|
|
|
moderation.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)
|
|
@@ -1416,7 +1566,7 @@ static int mlx5e_open_sqs(struct mlx5e_channel *c,
|
|
|
int tc;
|
|
|
|
|
|
for (tc = 0; tc < c->num_tc; tc++) {
|
|
|
- err = mlx5e_open_sq(c, tc, &cparam->sq, &c->sq[tc]);
|
|
|
+ err = mlx5e_open_txqsq(c, tc, &cparam->sq, &c->sq[tc]);
|
|
|
if (err)
|
|
|
goto err_close_sqs;
|
|
|
}
|
|
@@ -1425,7 +1575,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,7 +1585,7 @@ 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]);
|
|
|
+ mlx5e_close_txqsq(&c->sq[tc]);
|
|
|
}
|
|
|
|
|
|
static void mlx5e_build_channeltc_to_txq_map(struct mlx5e_priv *priv, int ix)
|
|
@@ -1448,10 +1598,11 @@ static void mlx5e_build_channeltc_to_txq_map(struct mlx5e_priv *priv, int ix)
|
|
|
}
|
|
|
|
|
|
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 +1625,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(priv, sq->sqn, &msp);
|
|
|
if (err) {
|
|
|
netdev_err(dev, "Failed configuring rate %u: %d\n",
|
|
|
rate, err);
|
|
@@ -1493,7 +1647,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->txq_to_sq_map[index];
|
|
|
int err = 0;
|
|
|
|
|
|
if (!mlx5_rl_is_supported(mdev)) {
|
|
@@ -1537,7 +1691,6 @@ static int mlx5e_open_channel(struct mlx5e_priv *priv, int ix,
|
|
|
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;
|
|
|
|
|
@@ -1577,14 +1730,14 @@ static int mlx5e_open_channel(struct mlx5e_priv *priv, int ix,
|
|
|
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,
|
|
|
+ err = c->xdp ? mlx5e_open_cq(c, &cparam->tx_cq, &c->rq.xdpsq.cq,
|
|
|
priv->params.tx_cq_moderation) : 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, 0, &cparam->icosq, &c->icosq);
|
|
|
if (err)
|
|
|
goto err_disable_napi;
|
|
|
|
|
@@ -1596,13 +1749,14 @@ static int mlx5e_open_channel(struct mlx5e_priv *priv, int ix,
|
|
|
u32 txq_ix = priv->channeltc_to_txq_map[ix][i];
|
|
|
|
|
|
if (priv->tx_rates[txq_ix]) {
|
|
|
- sq = priv->txq_to_sq_map[txq_ix];
|
|
|
+ struct mlx5e_txqsq *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, &cparam->xdp_sq, &c->rq.xdpsq) : 0;
|
|
|
if (err)
|
|
|
goto err_close_sqs;
|
|
|
|
|
@@ -1616,18 +1770,18 @@ static int mlx5e_open_channel(struct mlx5e_priv *priv, int ix,
|
|
|
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);
|
|
@@ -1649,12 +1803,12 @@ 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);
|
|
@@ -1725,7 +1879,6 @@ static void mlx5e_build_sq_param(struct mlx5e_priv *priv,
|
|
|
|
|
|
param->max_inline = priv->params.tx_max_inline;
|
|
|
param->min_inline_mode = priv->params.tx_min_inline_mode;
|
|
|
- param->type = MLX5E_SQ_TXQ;
|
|
|
}
|
|
|
|
|
|
static void mlx5e_build_common_cq_param(struct mlx5e_priv *priv,
|
|
@@ -1798,8 +1951,6 @@ 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,
|
|
@@ -1813,7 +1964,6 @@ static void mlx5e_build_xdpsq_param(struct mlx5e_priv *priv,
|
|
|
|
|
|
param->max_inline = priv->params.tx_max_inline;
|
|
|
param->min_inline_mode = priv->params.tx_min_inline_mode;
|
|
|
- param->type = MLX5E_SQ_XDP;
|
|
|
}
|
|
|
|
|
|
static void mlx5e_build_channel_param(struct mlx5e_priv *priv, struct mlx5e_channel_param *cparam)
|
|
@@ -2401,9 +2551,9 @@ 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 mlx5e_priv *priv,
|
|
|
+ struct mlx5e_rq *rq,
|
|
|
+ struct mlx5e_rq_param *param)
|
|
|
{
|
|
|
struct mlx5_core_dev *mdev = priv->mdev;
|
|
|
void *rqc = param->rqc;
|
|
@@ -2422,9 +2572,9 @@ static int mlx5e_create_drop_rq(struct mlx5e_priv *priv,
|
|
|
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 mlx5e_priv *priv,
|
|
|
+ struct mlx5e_cq *cq,
|
|
|
+ struct mlx5e_cq_param *param)
|
|
|
{
|
|
|
struct mlx5_core_dev *mdev = priv->mdev;
|
|
|
struct mlx5_core_cq *mcq = &cq->mcq;
|
|
@@ -2466,42 +2616,42 @@ static int mlx5e_open_drop_rq(struct mlx5e_priv *priv)
|
|
|
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(priv, 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(priv, rq, &rq_param);
|
|
|
if (err)
|
|
|
- goto err_disable_cq;
|
|
|
+ goto err_destroy_cq;
|
|
|
|
|
|
- err = mlx5e_enable_rq(rq, &rq_param);
|
|
|
+ err = mlx5e_create_rq(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(&priv->drop_rq);
|
|
|
|
|
|
err_destroy_cq:
|
|
|
mlx5e_destroy_cq(&priv->drop_rq.cq);
|
|
|
|
|
|
+err_free_cq:
|
|
|
+ mlx5e_free_cq(&priv->drop_rq.cq);
|
|
|
+
|
|
|
return err;
|
|
|
}
|
|
|
|
|
|
static void mlx5e_close_drop_rq(struct mlx5e_priv *priv)
|
|
|
{
|
|
|
- mlx5e_disable_rq(&priv->drop_rq);
|
|
|
mlx5e_destroy_rq(&priv->drop_rq);
|
|
|
- mlx5e_disable_cq(&priv->drop_rq.cq);
|
|
|
+ mlx5e_free_rq(&priv->drop_rq);
|
|
|
mlx5e_destroy_cq(&priv->drop_rq.cq);
|
|
|
+ mlx5e_free_cq(&priv->drop_rq.cq);
|
|
|
}
|
|
|
|
|
|
static int mlx5e_create_tis(struct mlx5e_priv *priv, int tc)
|
|
@@ -3189,7 +3339,7 @@ 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];
|
|
|
+ struct mlx5e_txqsq *sq = priv->txq_to_sq_map[i];
|
|
|
|
|
|
if (!netif_xmit_stopped(netdev_get_tx_queue(dev, i)))
|
|
|
continue;
|