From: Michael Baum Date: Thu, 3 Sep 2020 10:13:42 +0000 (+0000) Subject: net/mlx5: share Rx queue object modification X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=fa2c85cc9c71183fa909071b1f990f0aa6fb8a07;p=dpdk.git net/mlx5: share Rx queue object modification Use new modify_wq functions for Rx object creation in DevX and Verbs modules. Signed-off-by: Michael Baum Acked-by: Matan Azrad --- diff --git a/drivers/net/mlx5/linux/mlx5_verbs.c b/drivers/net/mlx5/linux/mlx5_verbs.c index 0808956007..249280702d 100644 --- a/drivers/net/mlx5/linux/mlx5_verbs.c +++ b/drivers/net/mlx5/linux/mlx5_verbs.c @@ -88,6 +88,27 @@ mlx5_rxq_obj_modify_wq_vlan_strip(struct mlx5_rxq_obj *rxq_obj, int on) .flags_mask = IBV_WQ_FLAGS_CVLAN_STRIPPING, .flags = vlan_offloads, }; + + return mlx5_glue->modify_wq(rxq_obj->wq, &mod); +} + +/** + * Modifies the attributes for the specified WQ. + * + * @param rxq_obj + * Verbs Rx queue object. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. + */ +static int +mlx5_ibv_modify_wq(struct mlx5_rxq_obj *rxq_obj, bool is_start) +{ + struct ibv_wq_attr mod = { + .attr_mask = IBV_WQ_ATTR_STATE, + .wq_state = is_start ? IBV_WQS_RDY : IBV_WQS_RESET, + }; + return mlx5_glue->modify_wq(rxq_obj->wq, &mod); } @@ -272,7 +293,6 @@ mlx5_rxq_ibv_obj_new(struct rte_eth_dev *dev, uint16_t idx) struct mlx5_rxq_data *rxq_data = (*priv->rxqs)[idx]; struct mlx5_rxq_ctrl *rxq_ctrl = container_of(rxq_data, struct mlx5_rxq_ctrl, rxq); - struct ibv_wq_attr mod; struct mlx5_rxq_obj *tmpl = rxq_ctrl->obj; struct mlx5dv_cq cq_info; struct mlx5dv_rwq rwq; @@ -334,11 +354,7 @@ mlx5_rxq_ibv_obj_new(struct rte_eth_dev *dev, uint16_t idx) goto error; } /* Change queue state to ready. */ - mod = (struct ibv_wq_attr){ - .attr_mask = IBV_WQ_ATTR_STATE, - .wq_state = IBV_WQS_RDY, - }; - ret = mlx5_glue->modify_wq(tmpl->wq, &mod); + ret = mlx5_ibv_modify_wq(tmpl, true); if (ret) { DRV_LOG(ERR, "Port %u Rx queue %u WQ state to IBV_WQS_RDY failed.", @@ -423,26 +439,6 @@ exit: return -rte_errno; } -/** - * Modifies the attributes for the specified WQ. - * - * @param rxq_obj - * Verbs Rx queue object. - * - * @return - * 0 on success, a negative errno value otherwise and rte_errno is set. - */ -static int -mlx5_ibv_modify_wq(struct mlx5_rxq_obj *rxq_obj, bool is_start) -{ - struct ibv_wq_attr mod = { - .attr_mask = IBV_WQ_ATTR_STATE, - .wq_state = is_start ? IBV_WQS_RDY : IBV_WQS_RESET, - }; - - return mlx5_glue->modify_wq(rxq_obj->wq, &mod); -} - struct mlx5_obj_ops ibv_obj_ops = { .rxq_obj_modify_vlan_strip = mlx5_rxq_obj_modify_wq_vlan_strip, .rxq_obj_new = mlx5_rxq_ibv_obj_new, diff --git a/drivers/net/mlx5/mlx5_devx.c b/drivers/net/mlx5/mlx5_devx.c index e577e38aa4..07922c2aac 100644 --- a/drivers/net/mlx5/mlx5_devx.c +++ b/drivers/net/mlx5/mlx5_devx.c @@ -46,6 +46,31 @@ mlx5_rxq_obj_modify_rq_vlan_strip(struct mlx5_rxq_obj *rxq_obj, int on) return mlx5_devx_cmd_modify_rq(rxq_obj->rq, &rq_attr); } +/** + * Modify RQ using DevX API. + * + * @param rxq_obj + * DevX Rx queue object. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. + */ +static int +mlx5_devx_modify_rq(struct mlx5_rxq_obj *rxq_obj, bool is_start) +{ + struct mlx5_devx_modify_rq_attr rq_attr; + + memset(&rq_attr, 0, sizeof(rq_attr)); + if (is_start) { + rq_attr.rq_state = MLX5_RQC_STATE_RST; + rq_attr.state = MLX5_RQC_STATE_RDY; + } else { + rq_attr.rq_state = MLX5_RQC_STATE_RDY; + rq_attr.state = MLX5_RQC_STATE_RST; + } + return mlx5_devx_cmd_modify_rq(rxq_obj->rq, &rq_attr); +} + /** * Release the resources allocated for an RQ DevX object. * @@ -100,24 +125,6 @@ rxq_release_devx_cq_resources(struct mlx5_rxq_ctrl *rxq_ctrl) } } -/** - * Release an Rx hairpin related resources. - * - * @param rxq_obj - * Hairpin Rx queue object. - */ -static void -mlx5_rxq_obj_hairpin_release(struct mlx5_rxq_obj *rxq_obj) -{ - struct mlx5_devx_modify_rq_attr rq_attr = { 0 }; - - MLX5_ASSERT(rxq_obj); - rq_attr.state = MLX5_RQC_STATE_RST; - rq_attr.rq_state = MLX5_RQC_STATE_RDY; - mlx5_devx_cmd_modify_rq(rxq_obj->rq, &rq_attr); - claim_zero(mlx5_devx_cmd_destroy(rxq_obj->rq)); -} - /** * Release an Rx DevX queue object. * @@ -130,7 +137,8 @@ mlx5_rxq_devx_obj_release(struct mlx5_rxq_obj *rxq_obj) MLX5_ASSERT(rxq_obj); MLX5_ASSERT(rxq_obj->rq); if (rxq_obj->type == MLX5_RXQ_OBJ_TYPE_DEVX_HAIRPIN) { - mlx5_rxq_obj_hairpin_release(rxq_obj); + mlx5_devx_modify_rq(rxq_obj, false); + claim_zero(mlx5_devx_cmd_destroy(rxq_obj->rq)); } else { MLX5_ASSERT(rxq_obj->devx_cq); claim_zero(mlx5_devx_cmd_destroy(rxq_obj->rq)); @@ -143,31 +151,6 @@ mlx5_rxq_devx_obj_release(struct mlx5_rxq_obj *rxq_obj) } } -/** - * Modify RQ using DevX API. - * - * @param rxq_obj - * DevX Rx queue object. - * - * @return - * 0 on success, a negative errno value otherwise and rte_errno is set. - */ -static int -mlx5_devx_modify_rq(struct mlx5_rxq_obj *rxq_obj, bool is_start) -{ - struct mlx5_devx_modify_rq_attr rq_attr; - - memset(&rq_attr, 0, sizeof(rq_attr)); - if (is_start) { - rq_attr.rq_state = MLX5_RQC_STATE_RST; - rq_attr.state = MLX5_RQC_STATE_RDY; - } else { - rq_attr.rq_state = MLX5_RQC_STATE_RDY; - rq_attr.state = MLX5_RQC_STATE_RST; - } - return mlx5_devx_cmd_modify_rq(rxq_obj->rq, &rq_attr); -} - /** * Get event for an Rx DevX queue object. * @@ -563,7 +546,6 @@ mlx5_rxq_devx_obj_new(struct rte_eth_dev *dev, uint16_t idx) struct mlx5_rxq_ctrl *rxq_ctrl = container_of(rxq_data, struct mlx5_rxq_ctrl, rxq); struct mlx5_rxq_obj *tmpl = rxq_ctrl->obj; - struct mlx5_devx_modify_rq_attr rq_attr = { 0 }; int ret = 0; MLX5_ASSERT(rxq_data); @@ -602,9 +584,7 @@ mlx5_rxq_devx_obj_new(struct rte_eth_dev *dev, uint16_t idx) goto error; } /* Change queue state to ready. */ - rq_attr.rq_state = MLX5_RQC_STATE_RST; - rq_attr.state = MLX5_RQC_STATE_RDY; - ret = mlx5_devx_cmd_modify_rq(tmpl->rq, &rq_attr); + ret = mlx5_devx_modify_rq(tmpl, true); if (ret) goto error; rxq_data->cq_arm_sn = 0;