From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id AD526A04AF; Thu, 20 Aug 2020 16:53:21 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B33271C1A2; Thu, 20 Aug 2020 16:51:27 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 380C51C115 for ; Thu, 20 Aug 2020 16:51:16 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from ophirmu@nvidia.com) with SMTP; 20 Aug 2020 17:51:10 +0300 Received: from nvidia.com (pegasus05.mtr.labs.mlnx [10.210.16.100]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 07KEoq42015127; Thu, 20 Aug 2020 17:51:10 +0300 From: Ophir Munk To: dev@dpdk.org Cc: Ophir Munk , Gregory Etelson , Ophir Munk Date: Thu, 20 Aug 2020 14:50:27 +0000 Message-Id: <20200820145028.4090-12-ophirmu@nvidia.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20200820145028.4090-1-ophirmu@nvidia.com> References: <20200820145028.4090-1-ophirmu@nvidia.com> Subject: [dpdk-dev] [PATCH v1 12/13] net/mlx5: separate vlan strip modification X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Ophir Munk When updating a queue vlan stripping offload - either the WQ is modified in Verbs or the RQ is modified in DevX. Add a vlan stripping modify callback to 'struct mlx5_obj_ops' and assign it with the specic Verbs and DevX implementations: 'rxq_obj_modify_wq_vlan_strip' and 'rxq_obj_modify_rq_vlan_strip' respectively. Signed-off-by: Ophir Munk Acked-by: Matan Azrad --- drivers/net/mlx5/linux/mlx5_verbs.c | 28 ++++++++++++++++++++++ drivers/net/mlx5/mlx5.h | 6 +++++ drivers/net/mlx5/mlx5_devx.c | 48 +++++++++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_devx.h | 12 ++++++++++ drivers/net/mlx5/mlx5_vlan.c | 27 ++++----------------- 5 files changed, 98 insertions(+), 23 deletions(-) create mode 100644 drivers/net/mlx5/mlx5_devx.c create mode 100644 drivers/net/mlx5/mlx5_devx.h diff --git a/drivers/net/mlx5/linux/mlx5_verbs.c b/drivers/net/mlx5/linux/mlx5_verbs.c index d41b0fe..6271f0f 100644 --- a/drivers/net/mlx5/linux/mlx5_verbs.c +++ b/drivers/net/mlx5/linux/mlx5_verbs.c @@ -19,6 +19,7 @@ #include #include #include +#include #include /** * Register mr. Given protection domain pointer, pointer to addr and length @@ -61,3 +62,30 @@ const struct mlx5_verbs_ops mlx5_verbs_ops = { .reg_mr = mlx5_reg_mr, .dereg_mr = mlx5_dereg_mr, }; + +/** + * Modify Rx WQ vlan stripping offload + * + * @param rxq_obj + * Rx queue object. + * + * @return 0 on success, non-0 otherwise + */ +static int +mlx5_rxq_obj_modify_wq_vlan_strip(struct mlx5_rxq_obj *rxq_obj, int on) +{ + uint16_t vlan_offloads = + (on ? IBV_WQ_FLAGS_CVLAN_STRIPPING : 0) | + 0; + struct ibv_wq_attr mod; + mod = (struct ibv_wq_attr){ + .attr_mask = IBV_WQ_ATTR_FLAGS, + .flags_mask = IBV_WQ_FLAGS_CVLAN_STRIPPING, + .flags = vlan_offloads, + }; + 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, +}; diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 34d7a15..431f861 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -676,6 +676,11 @@ TAILQ_HEAD(mlx5_flow_meters, mlx5_flow_meter); #define MLX5_PROC_PRIV(port_id) \ ((struct mlx5_proc_priv *)rte_eth_devices[port_id].process_private) +/* HW objects operations structure. */ +struct mlx5_obj_ops { + int (*rxq_obj_modify_vlan_strip)(struct mlx5_rxq_obj *rxq_obj, int on); +}; + struct mlx5_priv { struct rte_eth_dev_data *dev_data; /* Pointer to device data. */ struct mlx5_dev_ctx_shared *sh; /* Shared device context. */ @@ -719,6 +724,7 @@ struct mlx5_priv { void *rss_desc; /* Intermediate rss description resources. */ int flow_idx; /* Intermediate device flow index. */ int flow_nested_idx; /* Intermediate device flow index, nested. */ + struct mlx5_obj_ops *obj_ops; /* HW objects operations. */ LIST_HEAD(rxq, mlx5_rxq_ctrl) rxqsctrl; /* DPDK Rx queues. */ LIST_HEAD(rxqobj, mlx5_rxq_obj) rxqsobj; /* Verbs/DevX Rx queues. */ uint32_t hrxqs; /* Verbs Hash Rx queues. */ diff --git a/drivers/net/mlx5/mlx5_devx.c b/drivers/net/mlx5/mlx5_devx.c new file mode 100644 index 0000000..7340412 --- /dev/null +++ b/drivers/net/mlx5/mlx5_devx.c @@ -0,0 +1,48 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2020 Mellanox Technologies, Ltd + */ + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include "mlx5.h" +#include "mlx5_common_os.h" +#include "mlx5_rxtx.h" +#include "mlx5_utils.h" +#include "mlx5_devx.h" + +/** + * Modify RQ vlan stripping offload + * + * @param rxq_obj + * Rx queue object. + * + * @return 0 on success, non-0 otherwise + */ +static int +mlx5_rxq_obj_modify_rq_vlan_strip(struct mlx5_rxq_obj *rxq_obj, int on) +{ + struct mlx5_devx_modify_rq_attr rq_attr; + + memset(&rq_attr, 0, sizeof(rq_attr)); + rq_attr.rq_state = MLX5_RQC_STATE_RDY; + rq_attr.state = MLX5_RQC_STATE_RDY; + rq_attr.vsd = (on ? 0 : 1); + rq_attr.modify_bitmask = MLX5_MODIFY_RQ_IN_MODIFY_BITMASK_VSD; + return mlx5_devx_cmd_modify_rq(rxq_obj->rq, &rq_attr); +} + +struct mlx5_obj_ops devx_obj_ops = { + .rxq_obj_modify_vlan_strip = mlx5_rxq_obj_modify_rq_vlan_strip, +}; diff --git a/drivers/net/mlx5/mlx5_devx.h b/drivers/net/mlx5/mlx5_devx.h new file mode 100644 index 0000000..844985c --- /dev/null +++ b/drivers/net/mlx5/mlx5_devx.h @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2020 Mellanox Technologies, Ltd + */ + +#ifndef RTE_PMD_MLX5_DEVX_H_ +#define RTE_PMD_MLX5_DEVX_H_ + +#include "mlx5.h" + +extern struct mlx5_obj_ops devx_obj_ops; + +#endif /* RTE_PMD_MLX5_DEVX_H_ */ diff --git a/drivers/net/mlx5/mlx5_vlan.c b/drivers/net/mlx5/mlx5_vlan.c index 89983a4..ea89599 100644 --- a/drivers/net/mlx5/mlx5_vlan.c +++ b/drivers/net/mlx5/mlx5_vlan.c @@ -22,6 +22,7 @@ #include "mlx5_autoconf.h" #include "mlx5_rxtx.h" #include "mlx5_utils.h" +#include "mlx5_devx.h" /** * DPDK callback to configure a VLAN filter. @@ -97,10 +98,6 @@ mlx5_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t queue, int on) struct mlx5_rxq_data *rxq = (*priv->rxqs)[queue]; struct mlx5_rxq_ctrl *rxq_ctrl = container_of(rxq, struct mlx5_rxq_ctrl, rxq); - struct ibv_wq_attr mod; - uint16_t vlan_offloads = - (on ? IBV_WQ_FLAGS_CVLAN_STRIPPING : 0) | - 0; int ret = 0; /* Validate hw support */ @@ -115,30 +112,14 @@ mlx5_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t queue, int on) dev->data->port_id, queue); return; } - DRV_LOG(DEBUG, "port %u set VLAN offloads 0x%x for port %uqueue %d", - dev->data->port_id, vlan_offloads, rxq->port_id, queue); + DRV_LOG(DEBUG, "port %u set VLAN stripping offloads %d for port %uqueue %d", + dev->data->port_id, on, rxq->port_id, queue); if (!rxq_ctrl->obj) { /* Update related bits in RX queue. */ rxq->vlan_strip = !!on; return; } - if (rxq_ctrl->obj->type == MLX5_RXQ_OBJ_TYPE_IBV) { - mod = (struct ibv_wq_attr){ - .attr_mask = IBV_WQ_ATTR_FLAGS, - .flags_mask = IBV_WQ_FLAGS_CVLAN_STRIPPING, - .flags = vlan_offloads, - }; - ret = mlx5_glue->modify_wq(rxq_ctrl->obj->wq, &mod); - } else if (rxq_ctrl->obj->type == MLX5_RXQ_OBJ_TYPE_DEVX_RQ) { - struct mlx5_devx_modify_rq_attr rq_attr; - - memset(&rq_attr, 0, sizeof(rq_attr)); - rq_attr.rq_state = MLX5_RQC_STATE_RDY; - rq_attr.state = MLX5_RQC_STATE_RDY; - rq_attr.vsd = (on ? 0 : 1); - rq_attr.modify_bitmask = MLX5_MODIFY_RQ_IN_MODIFY_BITMASK_VSD; - ret = mlx5_devx_cmd_modify_rq(rxq_ctrl->obj->rq, &rq_attr); - } + ret = priv->obj_ops->rxq_obj_modify_vlan_strip(rxq_ctrl->obj, on); if (ret) { DRV_LOG(ERR, "port %u failed to modify object %d stripping " "mode: %s", dev->data->port_id, -- 2.8.4