#include <mlx5_glue.h>
#include <mlx5_common.h>
#include <mlx5_common_mr.h>
+#include <mlx5_rxtx.h>
#include <mlx5_verbs.h>
/**
* Register mr. Given protection domain pointer, pointer to addr and length
.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,
+};
#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. */
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. */
--- /dev/null
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2020 Mellanox Technologies, Ltd
+ */
+
+#include <stddef.h>
+#include <errno.h>
+#include <string.h>
+#include <stdint.h>
+#include <sys/queue.h>
+
+#include <rte_malloc.h>
+#include <rte_common.h>
+#include <rte_eal_paging.h>
+
+#include <mlx5_glue.h>
+#include <mlx5_devx_cmds.h>
+#include <mlx5_malloc.h>
+
+#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,
+};
--- /dev/null
+/* 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_ */
#include "mlx5_autoconf.h"
#include "mlx5_rxtx.h"
#include "mlx5_utils.h"
+#include "mlx5_devx.h"
/**
* DPDK callback to configure a VLAN filter.
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 */
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,