From: Ophir Munk Date: Tue, 25 Aug 2020 09:31:15 +0000 (+0000) Subject: net/mlx5: separate VLAN strip modification X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=8bb2410ea3ce520a2638a1e484daa2b73cd88338;p=dpdk.git net/mlx5: separate VLAN strip modification 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 specific 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 --- diff --git a/drivers/net/mlx5/linux/mlx5_verbs.c b/drivers/net/mlx5/linux/mlx5_verbs.c index d41b0fe871..6271f0f1ea 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 34d7a15b56..431f861aec 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 0000000000..73404124bf --- /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 0000000000..844985c22b --- /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 89983a4c94..ea8959940f 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,