|
|
a6040a |
From 064e2489caf7aeb9cd01dfcdc1b6a73b091b7f23 Mon Sep 17 00:00:00 2001
|
|
|
a6040a |
From: Adrien Mazarguil <adrien.mazarguil@6wind.com>
|
|
|
a6040a |
Date: Tue, 30 Jan 2018 16:34:52 +0100
|
|
|
a6040a |
Subject: [PATCH 1/9] net/mlx4: move rdma-core calls to separate file
|
|
|
a6040a |
|
|
|
a6040a |
This lays the groundwork for externalizing rdma-core as an optional
|
|
|
a6040a |
run-time dependency instead of a mandatory one.
|
|
|
a6040a |
|
|
|
a6040a |
No functional change.
|
|
|
a6040a |
|
|
|
a6040a |
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
|
|
|
a6040a |
Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
|
|
|
a6040a |
(cherry picked from commit 5f03b79b97d77804620e220a7715b696d8073b0e)
|
|
|
a6040a |
---
|
|
|
a6040a |
drivers/net/mlx4/Makefile | 1 +
|
|
|
a6040a |
drivers/net/mlx4/mlx4.c | 33 ++---
|
|
|
a6040a |
drivers/net/mlx4/mlx4_ethdev.c | 1 +
|
|
|
a6040a |
drivers/net/mlx4/mlx4_flow.c | 32 ++---
|
|
|
a6040a |
drivers/net/mlx4/mlx4_glue.c | 275 +++++++++++++++++++++++++++++++++++++++++
|
|
|
a6040a |
drivers/net/mlx4/mlx4_glue.h | 80 ++++++++++++
|
|
|
a6040a |
drivers/net/mlx4/mlx4_intr.c | 10 +-
|
|
|
a6040a |
drivers/net/mlx4/mlx4_mr.c | 7 +-
|
|
|
a6040a |
drivers/net/mlx4/mlx4_rxq.c | 53 ++++----
|
|
|
a6040a |
drivers/net/mlx4/mlx4_txq.c | 17 +--
|
|
|
a6040a |
10 files changed, 438 insertions(+), 71 deletions(-)
|
|
|
a6040a |
create mode 100644 drivers/net/mlx4/mlx4_glue.c
|
|
|
a6040a |
create mode 100644 drivers/net/mlx4/mlx4_glue.h
|
|
|
a6040a |
|
|
|
a6040a |
diff --git a/drivers/net/mlx4/Makefile b/drivers/net/mlx4/Makefile
|
|
|
a6040a |
index f1f47c2..7ba304b 100644
|
|
|
a6040a |
--- a/drivers/net/mlx4/Makefile
|
|
|
a6040a |
+++ b/drivers/net/mlx4/Makefile
|
|
|
a6040a |
@@ -38,6 +38,7 @@ LIB = librte_pmd_mlx4.a
|
|
|
a6040a |
SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4.c
|
|
|
a6040a |
SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4_ethdev.c
|
|
|
a6040a |
SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4_flow.c
|
|
|
a6040a |
+SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4_glue.c
|
|
|
a6040a |
SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4_intr.c
|
|
|
a6040a |
SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4_mr.c
|
|
|
a6040a |
SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4_rxq.c
|
|
|
a6040a |
diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c
|
|
|
a6040a |
index f9e4f9d..7f58e26 100644
|
|
|
a6040a |
--- a/drivers/net/mlx4/mlx4.c
|
|
|
a6040a |
+++ b/drivers/net/mlx4/mlx4.c
|
|
|
a6040a |
@@ -67,6 +67,7 @@
|
|
|
a6040a |
#include <rte_mbuf.h>
|
|
|
a6040a |
|
|
|
a6040a |
#include "mlx4.h"
|
|
|
a6040a |
+#include "mlx4_glue.h"
|
|
|
a6040a |
#include "mlx4_flow.h"
|
|
|
a6040a |
#include "mlx4_rxtx.h"
|
|
|
a6040a |
#include "mlx4_utils.h"
|
|
|
a6040a |
@@ -218,8 +219,8 @@ struct mlx4_conf {
|
|
|
a6040a |
mlx4_tx_queue_release(dev->data->tx_queues[i]);
|
|
|
a6040a |
if (priv->pd != NULL) {
|
|
|
a6040a |
assert(priv->ctx != NULL);
|
|
|
a6040a |
- claim_zero(ibv_dealloc_pd(priv->pd));
|
|
|
a6040a |
- claim_zero(ibv_close_device(priv->ctx));
|
|
|
a6040a |
+ claim_zero(mlx4_glue->dealloc_pd(priv->pd));
|
|
|
a6040a |
+ claim_zero(mlx4_glue->close_device(priv->ctx));
|
|
|
a6040a |
} else
|
|
|
a6040a |
assert(priv->ctx == NULL);
|
|
|
a6040a |
mlx4_intr_uninstall(priv);
|
|
|
a6040a |
@@ -434,7 +435,7 @@ struct mlx4_conf {
|
|
|
a6040a |
|
|
|
a6040a |
(void)pci_drv;
|
|
|
a6040a |
assert(pci_drv == &mlx4_driver);
|
|
|
a6040a |
- list = ibv_get_device_list(&i);
|
|
|
a6040a |
+ list = mlx4_glue->get_device_list(&i);
|
|
|
a6040a |
if (list == NULL) {
|
|
|
a6040a |
rte_errno = errno;
|
|
|
a6040a |
assert(rte_errno);
|
|
|
a6040a |
@@ -463,12 +464,12 @@ struct mlx4_conf {
|
|
|
a6040a |
PCI_DEVICE_ID_MELLANOX_CONNECTX3VF);
|
|
|
a6040a |
INFO("PCI information matches, using device \"%s\" (VF: %s)",
|
|
|
a6040a |
list[i]->name, (vf ? "true" : "false"));
|
|
|
a6040a |
- attr_ctx = ibv_open_device(list[i]);
|
|
|
a6040a |
+ attr_ctx = mlx4_glue->open_device(list[i]);
|
|
|
a6040a |
err = errno;
|
|
|
a6040a |
break;
|
|
|
a6040a |
}
|
|
|
a6040a |
if (attr_ctx == NULL) {
|
|
|
a6040a |
- ibv_free_device_list(list);
|
|
|
a6040a |
+ mlx4_glue->free_device_list(list);
|
|
|
a6040a |
switch (err) {
|
|
|
a6040a |
case 0:
|
|
|
a6040a |
rte_errno = ENODEV;
|
|
|
a6040a |
@@ -485,7 +486,7 @@ struct mlx4_conf {
|
|
|
a6040a |
}
|
|
|
a6040a |
ibv_dev = list[i];
|
|
|
a6040a |
DEBUG("device opened");
|
|
|
a6040a |
- if (ibv_query_device(attr_ctx, &device_attr)) {
|
|
|
a6040a |
+ if (mlx4_glue->query_device(attr_ctx, &device_attr)) {
|
|
|
a6040a |
rte_errno = ENODEV;
|
|
|
a6040a |
goto error;
|
|
|
a6040a |
}
|
|
|
a6040a |
@@ -512,13 +513,13 @@ struct mlx4_conf {
|
|
|
a6040a |
if (!(conf.ports.enabled & (1 << i)))
|
|
|
a6040a |
continue;
|
|
|
a6040a |
DEBUG("using port %u", port);
|
|
|
a6040a |
- ctx = ibv_open_device(ibv_dev);
|
|
|
a6040a |
+ ctx = mlx4_glue->open_device(ibv_dev);
|
|
|
a6040a |
if (ctx == NULL) {
|
|
|
a6040a |
rte_errno = ENODEV;
|
|
|
a6040a |
goto port_error;
|
|
|
a6040a |
}
|
|
|
a6040a |
/* Check port status. */
|
|
|
a6040a |
- err = ibv_query_port(ctx, port, &port_attr);
|
|
|
a6040a |
+ err = mlx4_glue->query_port(ctx, port, &port_attr);
|
|
|
a6040a |
if (err) {
|
|
|
a6040a |
rte_errno = err;
|
|
|
a6040a |
ERROR("port query failed: %s", strerror(rte_errno));
|
|
|
a6040a |
@@ -532,7 +533,7 @@ struct mlx4_conf {
|
|
|
a6040a |
}
|
|
|
a6040a |
if (port_attr.state != IBV_PORT_ACTIVE)
|
|
|
a6040a |
DEBUG("port %d is not active: \"%s\" (%d)",
|
|
|
a6040a |
- port, ibv_port_state_str(port_attr.state),
|
|
|
a6040a |
+ port, mlx4_glue->port_state_str(port_attr.state),
|
|
|
a6040a |
port_attr.state);
|
|
|
a6040a |
/* Make asynchronous FD non-blocking to handle interrupts. */
|
|
|
a6040a |
if (mlx4_fd_set_non_blocking(ctx->async_fd) < 0) {
|
|
|
a6040a |
@@ -541,7 +542,7 @@ struct mlx4_conf {
|
|
|
a6040a |
goto port_error;
|
|
|
a6040a |
}
|
|
|
a6040a |
/* Allocate protection domain. */
|
|
|
a6040a |
- pd = ibv_alloc_pd(ctx);
|
|
|
a6040a |
+ pd = mlx4_glue->alloc_pd(ctx);
|
|
|
a6040a |
if (pd == NULL) {
|
|
|
a6040a |
rte_errno = ENOMEM;
|
|
|
a6040a |
ERROR("PD allocation failure");
|
|
|
a6040a |
@@ -605,7 +606,7 @@ struct mlx4_conf {
|
|
|
a6040a |
char name[RTE_ETH_NAME_MAX_LEN];
|
|
|
a6040a |
|
|
|
a6040a |
snprintf(name, sizeof(name), "%s port %u",
|
|
|
a6040a |
- ibv_get_device_name(ibv_dev), port);
|
|
|
a6040a |
+ mlx4_glue->get_device_name(ibv_dev), port);
|
|
|
a6040a |
eth_dev = rte_eth_dev_allocate(name);
|
|
|
a6040a |
}
|
|
|
a6040a |
if (eth_dev == NULL) {
|
|
|
a6040a |
@@ -648,9 +649,9 @@ struct mlx4_conf {
|
|
|
a6040a |
port_error:
|
|
|
a6040a |
rte_free(priv);
|
|
|
a6040a |
if (pd)
|
|
|
a6040a |
- claim_zero(ibv_dealloc_pd(pd));
|
|
|
a6040a |
+ claim_zero(mlx4_glue->dealloc_pd(pd));
|
|
|
a6040a |
if (ctx)
|
|
|
a6040a |
- claim_zero(ibv_close_device(ctx));
|
|
|
a6040a |
+ claim_zero(mlx4_glue->close_device(ctx));
|
|
|
a6040a |
if (eth_dev)
|
|
|
a6040a |
rte_eth_dev_release_port(eth_dev);
|
|
|
a6040a |
break;
|
|
|
a6040a |
@@ -665,9 +666,9 @@ struct mlx4_conf {
|
|
|
a6040a |
*/
|
|
|
a6040a |
error:
|
|
|
a6040a |
if (attr_ctx)
|
|
|
a6040a |
- claim_zero(ibv_close_device(attr_ctx));
|
|
|
a6040a |
+ claim_zero(mlx4_glue->close_device(attr_ctx));
|
|
|
a6040a |
if (list)
|
|
|
a6040a |
- ibv_free_device_list(list);
|
|
|
a6040a |
+ mlx4_glue->free_device_list(list);
|
|
|
a6040a |
assert(rte_errno >= 0);
|
|
|
a6040a |
return -rte_errno;
|
|
|
a6040a |
}
|
|
|
a6040a |
@@ -714,7 +715,7 @@ struct mlx4_conf {
|
|
|
a6040a |
* using this PMD, which is not supported in forked processes.
|
|
|
a6040a |
*/
|
|
|
a6040a |
setenv("RDMAV_HUGEPAGES_SAFE", "1", 1);
|
|
|
a6040a |
- ibv_fork_init();
|
|
|
a6040a |
+ mlx4_glue->fork_init();
|
|
|
a6040a |
rte_pci_register(&mlx4_driver);
|
|
|
a6040a |
}
|
|
|
a6040a |
|
|
|
a6040a |
diff --git a/drivers/net/mlx4/mlx4_ethdev.c b/drivers/net/mlx4/mlx4_ethdev.c
|
|
|
a6040a |
index 2f69e7d..e2f9509 100644
|
|
|
a6040a |
--- a/drivers/net/mlx4/mlx4_ethdev.c
|
|
|
a6040a |
+++ b/drivers/net/mlx4/mlx4_ethdev.c
|
|
|
a6040a |
@@ -70,6 +70,7 @@
|
|
|
a6040a |
|
|
|
a6040a |
#include "mlx4.h"
|
|
|
a6040a |
#include "mlx4_flow.h"
|
|
|
a6040a |
+#include "mlx4_glue.h"
|
|
|
a6040a |
#include "mlx4_rxtx.h"
|
|
|
a6040a |
#include "mlx4_utils.h"
|
|
|
a6040a |
|
|
|
a6040a |
diff --git a/drivers/net/mlx4/mlx4_flow.c b/drivers/net/mlx4/mlx4_flow.c
|
|
|
a6040a |
index 8b87b29..4a6b8a4 100644
|
|
|
a6040a |
--- a/drivers/net/mlx4/mlx4_flow.c
|
|
|
a6040a |
+++ b/drivers/net/mlx4/mlx4_flow.c
|
|
|
a6040a |
@@ -65,6 +65,7 @@
|
|
|
a6040a |
|
|
|
a6040a |
/* PMD headers. */
|
|
|
a6040a |
#include "mlx4.h"
|
|
|
a6040a |
+#include "mlx4_glue.h"
|
|
|
a6040a |
#include "mlx4_flow.h"
|
|
|
a6040a |
#include "mlx4_rxtx.h"
|
|
|
a6040a |
#include "mlx4_utils.h"
|
|
|
a6040a |
@@ -914,24 +915,25 @@ struct mlx4_drop {
|
|
|
a6040a |
.priv = priv,
|
|
|
a6040a |
.refcnt = 1,
|
|
|
a6040a |
};
|
|
|
a6040a |
- drop->cq = ibv_create_cq(priv->ctx, 1, NULL, NULL, 0);
|
|
|
a6040a |
+ drop->cq = mlx4_glue->create_cq(priv->ctx, 1, NULL, NULL, 0);
|
|
|
a6040a |
if (!drop->cq)
|
|
|
a6040a |
goto error;
|
|
|
a6040a |
- drop->qp = ibv_create_qp(priv->pd,
|
|
|
a6040a |
- &(struct ibv_qp_init_attr){
|
|
|
a6040a |
- .send_cq = drop->cq,
|
|
|
a6040a |
- .recv_cq = drop->cq,
|
|
|
a6040a |
- .qp_type = IBV_QPT_RAW_PACKET,
|
|
|
a6040a |
- });
|
|
|
a6040a |
+ drop->qp = mlx4_glue->create_qp
|
|
|
a6040a |
+ (priv->pd,
|
|
|
a6040a |
+ &(struct ibv_qp_init_attr){
|
|
|
a6040a |
+ .send_cq = drop->cq,
|
|
|
a6040a |
+ .recv_cq = drop->cq,
|
|
|
a6040a |
+ .qp_type = IBV_QPT_RAW_PACKET,
|
|
|
a6040a |
+ });
|
|
|
a6040a |
if (!drop->qp)
|
|
|
a6040a |
goto error;
|
|
|
a6040a |
priv->drop = drop;
|
|
|
a6040a |
return drop;
|
|
|
a6040a |
error:
|
|
|
a6040a |
if (drop->qp)
|
|
|
a6040a |
- claim_zero(ibv_destroy_qp(drop->qp));
|
|
|
a6040a |
+ claim_zero(mlx4_glue->destroy_qp(drop->qp));
|
|
|
a6040a |
if (drop->cq)
|
|
|
a6040a |
- claim_zero(ibv_destroy_cq(drop->cq));
|
|
|
a6040a |
+ claim_zero(mlx4_glue->destroy_cq(drop->cq));
|
|
|
a6040a |
if (drop)
|
|
|
a6040a |
rte_free(drop);
|
|
|
a6040a |
rte_errno = ENOMEM;
|
|
|
a6040a |
@@ -951,8 +953,8 @@ struct mlx4_drop {
|
|
|
a6040a |
if (--drop->refcnt)
|
|
|
a6040a |
return;
|
|
|
a6040a |
drop->priv->drop = NULL;
|
|
|
a6040a |
- claim_zero(ibv_destroy_qp(drop->qp));
|
|
|
a6040a |
- claim_zero(ibv_destroy_cq(drop->cq));
|
|
|
a6040a |
+ claim_zero(mlx4_glue->destroy_qp(drop->qp));
|
|
|
a6040a |
+ claim_zero(mlx4_glue->destroy_cq(drop->cq));
|
|
|
a6040a |
rte_free(drop);
|
|
|
a6040a |
}
|
|
|
a6040a |
|
|
|
a6040a |
@@ -984,7 +986,7 @@ struct mlx4_drop {
|
|
|
a6040a |
if (!enable) {
|
|
|
a6040a |
if (!flow->ibv_flow)
|
|
|
a6040a |
return 0;
|
|
|
a6040a |
- claim_zero(ibv_destroy_flow(flow->ibv_flow));
|
|
|
a6040a |
+ claim_zero(mlx4_glue->destroy_flow(flow->ibv_flow));
|
|
|
a6040a |
flow->ibv_flow = NULL;
|
|
|
a6040a |
if (flow->drop)
|
|
|
a6040a |
mlx4_drop_put(priv->drop);
|
|
|
a6040a |
@@ -997,7 +999,7 @@ struct mlx4_drop {
|
|
|
a6040a |
!priv->isolated &&
|
|
|
a6040a |
flow->ibv_attr->priority == MLX4_FLOW_PRIORITY_LAST) {
|
|
|
a6040a |
if (flow->ibv_flow) {
|
|
|
a6040a |
- claim_zero(ibv_destroy_flow(flow->ibv_flow));
|
|
|
a6040a |
+ claim_zero(mlx4_glue->destroy_flow(flow->ibv_flow));
|
|
|
a6040a |
flow->ibv_flow = NULL;
|
|
|
a6040a |
if (flow->drop)
|
|
|
a6040a |
mlx4_drop_put(priv->drop);
|
|
|
a6040a |
@@ -1027,7 +1029,7 @@ struct mlx4_drop {
|
|
|
a6040a |
if (missing ^ !flow->drop)
|
|
|
a6040a |
return 0;
|
|
|
a6040a |
/* Verbs flow needs updating. */
|
|
|
a6040a |
- claim_zero(ibv_destroy_flow(flow->ibv_flow));
|
|
|
a6040a |
+ claim_zero(mlx4_glue->destroy_flow(flow->ibv_flow));
|
|
|
a6040a |
flow->ibv_flow = NULL;
|
|
|
a6040a |
if (flow->drop)
|
|
|
a6040a |
mlx4_drop_put(priv->drop);
|
|
|
a6040a |
@@ -1059,7 +1061,7 @@ struct mlx4_drop {
|
|
|
a6040a |
assert(qp);
|
|
|
a6040a |
if (flow->ibv_flow)
|
|
|
a6040a |
return 0;
|
|
|
a6040a |
- flow->ibv_flow = ibv_create_flow(qp, flow->ibv_attr);
|
|
|
a6040a |
+ flow->ibv_flow = mlx4_glue->create_flow(qp, flow->ibv_attr);
|
|
|
a6040a |
if (flow->ibv_flow)
|
|
|
a6040a |
return 0;
|
|
|
a6040a |
if (flow->drop)
|
|
|
a6040a |
diff --git a/drivers/net/mlx4/mlx4_glue.c b/drivers/net/mlx4/mlx4_glue.c
|
|
|
a6040a |
new file mode 100644
|
|
|
a6040a |
index 0000000..30797bd
|
|
|
a6040a |
--- /dev/null
|
|
|
a6040a |
+++ b/drivers/net/mlx4/mlx4_glue.c
|
|
|
a6040a |
@@ -0,0 +1,275 @@
|
|
|
a6040a |
+/* SPDX-License-Identifier: BSD-3-Clause
|
|
|
a6040a |
+ * Copyright 2018 6WIND S.A.
|
|
|
a6040a |
+ * Copyright 2018 Mellanox
|
|
|
a6040a |
+ */
|
|
|
a6040a |
+
|
|
|
a6040a |
+/* Verbs headers do not support -pedantic. */
|
|
|
a6040a |
+#ifdef PEDANTIC
|
|
|
a6040a |
+#pragma GCC diagnostic ignored "-Wpedantic"
|
|
|
a6040a |
+#endif
|
|
|
a6040a |
+#include <infiniband/mlx4dv.h>
|
|
|
a6040a |
+#include <infiniband/verbs.h>
|
|
|
a6040a |
+#ifdef PEDANTIC
|
|
|
a6040a |
+#pragma GCC diagnostic error "-Wpedantic"
|
|
|
a6040a |
+#endif
|
|
|
a6040a |
+
|
|
|
a6040a |
+#include "mlx4_glue.h"
|
|
|
a6040a |
+
|
|
|
a6040a |
+static int
|
|
|
a6040a |
+mlx4_glue_fork_init(void)
|
|
|
a6040a |
+{
|
|
|
a6040a |
+ return ibv_fork_init();
|
|
|
a6040a |
+}
|
|
|
a6040a |
+
|
|
|
a6040a |
+static int
|
|
|
a6040a |
+mlx4_glue_get_async_event(struct ibv_context *context,
|
|
|
a6040a |
+ struct ibv_async_event *event)
|
|
|
a6040a |
+{
|
|
|
a6040a |
+ return ibv_get_async_event(context, event);
|
|
|
a6040a |
+}
|
|
|
a6040a |
+
|
|
|
a6040a |
+static void
|
|
|
a6040a |
+mlx4_glue_ack_async_event(struct ibv_async_event *event)
|
|
|
a6040a |
+{
|
|
|
a6040a |
+ ibv_ack_async_event(event);
|
|
|
a6040a |
+}
|
|
|
a6040a |
+
|
|
|
a6040a |
+static struct ibv_pd *
|
|
|
a6040a |
+mlx4_glue_alloc_pd(struct ibv_context *context)
|
|
|
a6040a |
+{
|
|
|
a6040a |
+ return ibv_alloc_pd(context);
|
|
|
a6040a |
+}
|
|
|
a6040a |
+
|
|
|
a6040a |
+static int
|
|
|
a6040a |
+mlx4_glue_dealloc_pd(struct ibv_pd *pd)
|
|
|
a6040a |
+{
|
|
|
a6040a |
+ return ibv_dealloc_pd(pd);
|
|
|
a6040a |
+}
|
|
|
a6040a |
+
|
|
|
a6040a |
+static struct ibv_device **
|
|
|
a6040a |
+mlx4_glue_get_device_list(int *num_devices)
|
|
|
a6040a |
+{
|
|
|
a6040a |
+ return ibv_get_device_list(num_devices);
|
|
|
a6040a |
+}
|
|
|
a6040a |
+
|
|
|
a6040a |
+static void
|
|
|
a6040a |
+mlx4_glue_free_device_list(struct ibv_device **list)
|
|
|
a6040a |
+{
|
|
|
a6040a |
+ ibv_free_device_list(list);
|
|
|
a6040a |
+}
|
|
|
a6040a |
+
|
|
|
a6040a |
+static struct ibv_context *
|
|
|
a6040a |
+mlx4_glue_open_device(struct ibv_device *device)
|
|
|
a6040a |
+{
|
|
|
a6040a |
+ return ibv_open_device(device);
|
|
|
a6040a |
+}
|
|
|
a6040a |
+
|
|
|
a6040a |
+static int
|
|
|
a6040a |
+mlx4_glue_close_device(struct ibv_context *context)
|
|
|
a6040a |
+{
|
|
|
a6040a |
+ return ibv_close_device(context);
|
|
|
a6040a |
+}
|
|
|
a6040a |
+
|
|
|
a6040a |
+static const char *
|
|
|
a6040a |
+mlx4_glue_get_device_name(struct ibv_device *device)
|
|
|
a6040a |
+{
|
|
|
a6040a |
+ return ibv_get_device_name(device);
|
|
|
a6040a |
+}
|
|
|
a6040a |
+
|
|
|
a6040a |
+static int
|
|
|
a6040a |
+mlx4_glue_query_device(struct ibv_context *context,
|
|
|
a6040a |
+ struct ibv_device_attr *device_attr)
|
|
|
a6040a |
+{
|
|
|
a6040a |
+ return ibv_query_device(context, device_attr);
|
|
|
a6040a |
+}
|
|
|
a6040a |
+
|
|
|
a6040a |
+static int
|
|
|
a6040a |
+mlx4_glue_query_device_ex(struct ibv_context *context,
|
|
|
a6040a |
+ const struct ibv_query_device_ex_input *input,
|
|
|
a6040a |
+ struct ibv_device_attr_ex *attr)
|
|
|
a6040a |
+{
|
|
|
a6040a |
+ return ibv_query_device_ex(context, input, attr);
|
|
|
a6040a |
+}
|
|
|
a6040a |
+
|
|
|
a6040a |
+static int
|
|
|
a6040a |
+mlx4_glue_query_port(struct ibv_context *context, uint8_t port_num,
|
|
|
a6040a |
+ struct ibv_port_attr *port_attr)
|
|
|
a6040a |
+{
|
|
|
a6040a |
+ return ibv_query_port(context, port_num, port_attr);
|
|
|
a6040a |
+}
|
|
|
a6040a |
+
|
|
|
a6040a |
+static const char *
|
|
|
a6040a |
+mlx4_glue_port_state_str(enum ibv_port_state port_state)
|
|
|
a6040a |
+{
|
|
|
a6040a |
+ return ibv_port_state_str(port_state);
|
|
|
a6040a |
+}
|
|
|
a6040a |
+
|
|
|
a6040a |
+static struct ibv_comp_channel *
|
|
|
a6040a |
+mlx4_glue_create_comp_channel(struct ibv_context *context)
|
|
|
a6040a |
+{
|
|
|
a6040a |
+ return ibv_create_comp_channel(context);
|
|
|
a6040a |
+}
|
|
|
a6040a |
+
|
|
|
a6040a |
+static int
|
|
|
a6040a |
+mlx4_glue_destroy_comp_channel(struct ibv_comp_channel *channel)
|
|
|
a6040a |
+{
|
|
|
a6040a |
+ return ibv_destroy_comp_channel(channel);
|
|
|
a6040a |
+}
|
|
|
a6040a |
+
|
|
|
a6040a |
+static struct ibv_cq *
|
|
|
a6040a |
+mlx4_glue_create_cq(struct ibv_context *context, int cqe, void *cq_context,
|
|
|
a6040a |
+ struct ibv_comp_channel *channel, int comp_vector)
|
|
|
a6040a |
+{
|
|
|
a6040a |
+ return ibv_create_cq(context, cqe, cq_context, channel, comp_vector);
|
|
|
a6040a |
+}
|
|
|
a6040a |
+
|
|
|
a6040a |
+static int
|
|
|
a6040a |
+mlx4_glue_destroy_cq(struct ibv_cq *cq)
|
|
|
a6040a |
+{
|
|
|
a6040a |
+ return ibv_destroy_cq(cq);
|
|
|
a6040a |
+}
|
|
|
a6040a |
+
|
|
|
a6040a |
+static int
|
|
|
a6040a |
+mlx4_glue_get_cq_event(struct ibv_comp_channel *channel, struct ibv_cq **cq,
|
|
|
a6040a |
+ void **cq_context)
|
|
|
a6040a |
+{
|
|
|
a6040a |
+ return ibv_get_cq_event(channel, cq, cq_context);
|
|
|
a6040a |
+}
|
|
|
a6040a |
+
|
|
|
a6040a |
+static void
|
|
|
a6040a |
+mlx4_glue_ack_cq_events(struct ibv_cq *cq, unsigned int nevents)
|
|
|
a6040a |
+{
|
|
|
a6040a |
+ ibv_ack_cq_events(cq, nevents);
|
|
|
a6040a |
+}
|
|
|
a6040a |
+
|
|
|
a6040a |
+static struct ibv_flow *
|
|
|
a6040a |
+mlx4_glue_create_flow(struct ibv_qp *qp, struct ibv_flow_attr *flow)
|
|
|
a6040a |
+{
|
|
|
a6040a |
+ return ibv_create_flow(qp, flow);
|
|
|
a6040a |
+}
|
|
|
a6040a |
+
|
|
|
a6040a |
+static int
|
|
|
a6040a |
+mlx4_glue_destroy_flow(struct ibv_flow *flow_id)
|
|
|
a6040a |
+{
|
|
|
a6040a |
+ return ibv_destroy_flow(flow_id);
|
|
|
a6040a |
+}
|
|
|
a6040a |
+
|
|
|
a6040a |
+static struct ibv_qp *
|
|
|
a6040a |
+mlx4_glue_create_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *qp_init_attr)
|
|
|
a6040a |
+{
|
|
|
a6040a |
+ return ibv_create_qp(pd, qp_init_attr);
|
|
|
a6040a |
+}
|
|
|
a6040a |
+
|
|
|
a6040a |
+static struct ibv_qp *
|
|
|
a6040a |
+mlx4_glue_create_qp_ex(struct ibv_context *context,
|
|
|
a6040a |
+ struct ibv_qp_init_attr_ex *qp_init_attr_ex)
|
|
|
a6040a |
+{
|
|
|
a6040a |
+ return ibv_create_qp_ex(context, qp_init_attr_ex);
|
|
|
a6040a |
+}
|
|
|
a6040a |
+
|
|
|
a6040a |
+static int
|
|
|
a6040a |
+mlx4_glue_destroy_qp(struct ibv_qp *qp)
|
|
|
a6040a |
+{
|
|
|
a6040a |
+ return ibv_destroy_qp(qp);
|
|
|
a6040a |
+}
|
|
|
a6040a |
+
|
|
|
a6040a |
+static int
|
|
|
a6040a |
+mlx4_glue_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr, int attr_mask)
|
|
|
a6040a |
+{
|
|
|
a6040a |
+ return ibv_modify_qp(qp, attr, attr_mask);
|
|
|
a6040a |
+}
|
|
|
a6040a |
+
|
|
|
a6040a |
+static struct ibv_mr *
|
|
|
a6040a |
+mlx4_glue_reg_mr(struct ibv_pd *pd, void *addr, size_t length, int access)
|
|
|
a6040a |
+{
|
|
|
a6040a |
+ return ibv_reg_mr(pd, addr, length, access);
|
|
|
a6040a |
+}
|
|
|
a6040a |
+
|
|
|
a6040a |
+static int
|
|
|
a6040a |
+mlx4_glue_dereg_mr(struct ibv_mr *mr)
|
|
|
a6040a |
+{
|
|
|
a6040a |
+ return ibv_dereg_mr(mr);
|
|
|
a6040a |
+}
|
|
|
a6040a |
+
|
|
|
a6040a |
+static struct ibv_rwq_ind_table *
|
|
|
a6040a |
+mlx4_glue_create_rwq_ind_table(struct ibv_context *context,
|
|
|
a6040a |
+ struct ibv_rwq_ind_table_init_attr *init_attr)
|
|
|
a6040a |
+{
|
|
|
a6040a |
+ return ibv_create_rwq_ind_table(context, init_attr);
|
|
|
a6040a |
+}
|
|
|
a6040a |
+
|
|
|
a6040a |
+static int
|
|
|
a6040a |
+mlx4_glue_destroy_rwq_ind_table(struct ibv_rwq_ind_table *rwq_ind_table)
|
|
|
a6040a |
+{
|
|
|
a6040a |
+ return ibv_destroy_rwq_ind_table(rwq_ind_table);
|
|
|
a6040a |
+}
|
|
|
a6040a |
+
|
|
|
a6040a |
+static struct ibv_wq *
|
|
|
a6040a |
+mlx4_glue_create_wq(struct ibv_context *context,
|
|
|
a6040a |
+ struct ibv_wq_init_attr *wq_init_attr)
|
|
|
a6040a |
+{
|
|
|
a6040a |
+ return ibv_create_wq(context, wq_init_attr);
|
|
|
a6040a |
+}
|
|
|
a6040a |
+
|
|
|
a6040a |
+static int
|
|
|
a6040a |
+mlx4_glue_destroy_wq(struct ibv_wq *wq)
|
|
|
a6040a |
+{
|
|
|
a6040a |
+ return ibv_destroy_wq(wq);
|
|
|
a6040a |
+}
|
|
|
a6040a |
+static int
|
|
|
a6040a |
+mlx4_glue_modify_wq(struct ibv_wq *wq, struct ibv_wq_attr *wq_attr)
|
|
|
a6040a |
+{
|
|
|
a6040a |
+ return ibv_modify_wq(wq, wq_attr);
|
|
|
a6040a |
+}
|
|
|
a6040a |
+
|
|
|
a6040a |
+static int
|
|
|
a6040a |
+mlx4_glue_dv_init_obj(struct mlx4dv_obj *obj, uint64_t obj_type)
|
|
|
a6040a |
+{
|
|
|
a6040a |
+ return mlx4dv_init_obj(obj, obj_type);
|
|
|
a6040a |
+}
|
|
|
a6040a |
+
|
|
|
a6040a |
+static int
|
|
|
a6040a |
+mlx4_glue_dv_set_context_attr(struct ibv_context *context,
|
|
|
a6040a |
+ enum mlx4dv_set_ctx_attr_type attr_type,
|
|
|
a6040a |
+ void *attr)
|
|
|
a6040a |
+{
|
|
|
a6040a |
+ return mlx4dv_set_context_attr(context, attr_type, attr);
|
|
|
a6040a |
+}
|
|
|
a6040a |
+
|
|
|
a6040a |
+const struct mlx4_glue *mlx4_glue = &(const struct mlx4_glue){
|
|
|
a6040a |
+ .fork_init = mlx4_glue_fork_init,
|
|
|
a6040a |
+ .get_async_event = mlx4_glue_get_async_event,
|
|
|
a6040a |
+ .ack_async_event = mlx4_glue_ack_async_event,
|
|
|
a6040a |
+ .alloc_pd = mlx4_glue_alloc_pd,
|
|
|
a6040a |
+ .dealloc_pd = mlx4_glue_dealloc_pd,
|
|
|
a6040a |
+ .get_device_list = mlx4_glue_get_device_list,
|
|
|
a6040a |
+ .free_device_list = mlx4_glue_free_device_list,
|
|
|
a6040a |
+ .open_device = mlx4_glue_open_device,
|
|
|
a6040a |
+ .close_device = mlx4_glue_close_device,
|
|
|
a6040a |
+ .get_device_name = mlx4_glue_get_device_name,
|
|
|
a6040a |
+ .query_device = mlx4_glue_query_device,
|
|
|
a6040a |
+ .query_device_ex = mlx4_glue_query_device_ex,
|
|
|
a6040a |
+ .query_port = mlx4_glue_query_port,
|
|
|
a6040a |
+ .port_state_str = mlx4_glue_port_state_str,
|
|
|
a6040a |
+ .create_comp_channel = mlx4_glue_create_comp_channel,
|
|
|
a6040a |
+ .destroy_comp_channel = mlx4_glue_destroy_comp_channel,
|
|
|
a6040a |
+ .create_cq = mlx4_glue_create_cq,
|
|
|
a6040a |
+ .destroy_cq = mlx4_glue_destroy_cq,
|
|
|
a6040a |
+ .get_cq_event = mlx4_glue_get_cq_event,
|
|
|
a6040a |
+ .ack_cq_events = mlx4_glue_ack_cq_events,
|
|
|
a6040a |
+ .create_flow = mlx4_glue_create_flow,
|
|
|
a6040a |
+ .destroy_flow = mlx4_glue_destroy_flow,
|
|
|
a6040a |
+ .create_qp = mlx4_glue_create_qp,
|
|
|
a6040a |
+ .create_qp_ex = mlx4_glue_create_qp_ex,
|
|
|
a6040a |
+ .destroy_qp = mlx4_glue_destroy_qp,
|
|
|
a6040a |
+ .modify_qp = mlx4_glue_modify_qp,
|
|
|
a6040a |
+ .reg_mr = mlx4_glue_reg_mr,
|
|
|
a6040a |
+ .dereg_mr = mlx4_glue_dereg_mr,
|
|
|
a6040a |
+ .create_rwq_ind_table = mlx4_glue_create_rwq_ind_table,
|
|
|
a6040a |
+ .destroy_rwq_ind_table = mlx4_glue_destroy_rwq_ind_table,
|
|
|
a6040a |
+ .create_wq = mlx4_glue_create_wq,
|
|
|
a6040a |
+ .destroy_wq = mlx4_glue_destroy_wq,
|
|
|
a6040a |
+ .modify_wq = mlx4_glue_modify_wq,
|
|
|
a6040a |
+ .dv_init_obj = mlx4_glue_dv_init_obj,
|
|
|
a6040a |
+ .dv_set_context_attr = mlx4_glue_dv_set_context_attr,
|
|
|
a6040a |
+};
|
|
|
a6040a |
diff --git a/drivers/net/mlx4/mlx4_glue.h b/drivers/net/mlx4/mlx4_glue.h
|
|
|
a6040a |
new file mode 100644
|
|
|
a6040a |
index 0000000..0623511
|
|
|
a6040a |
--- /dev/null
|
|
|
a6040a |
+++ b/drivers/net/mlx4/mlx4_glue.h
|
|
|
a6040a |
@@ -0,0 +1,80 @@
|
|
|
a6040a |
+/* SPDX-License-Identifier: BSD-3-Clause
|
|
|
a6040a |
+ * Copyright 2018 6WIND S.A.
|
|
|
a6040a |
+ * Copyright 2018 Mellanox
|
|
|
a6040a |
+ */
|
|
|
a6040a |
+
|
|
|
a6040a |
+#ifndef MLX4_GLUE_H_
|
|
|
a6040a |
+#define MLX4_GLUE_H_
|
|
|
a6040a |
+
|
|
|
a6040a |
+/* Verbs headers do not support -pedantic. */
|
|
|
a6040a |
+#ifdef PEDANTIC
|
|
|
a6040a |
+#pragma GCC diagnostic ignored "-Wpedantic"
|
|
|
a6040a |
+#endif
|
|
|
a6040a |
+#include <infiniband/mlx4dv.h>
|
|
|
a6040a |
+#include <infiniband/verbs.h>
|
|
|
a6040a |
+#ifdef PEDANTIC
|
|
|
a6040a |
+#pragma GCC diagnostic error "-Wpedantic"
|
|
|
a6040a |
+#endif
|
|
|
a6040a |
+
|
|
|
a6040a |
+struct mlx4_glue {
|
|
|
a6040a |
+ int (*fork_init)(void);
|
|
|
a6040a |
+ int (*get_async_event)(struct ibv_context *context,
|
|
|
a6040a |
+ struct ibv_async_event *event);
|
|
|
a6040a |
+ void (*ack_async_event)(struct ibv_async_event *event);
|
|
|
a6040a |
+ struct ibv_pd *(*alloc_pd)(struct ibv_context *context);
|
|
|
a6040a |
+ int (*dealloc_pd)(struct ibv_pd *pd);
|
|
|
a6040a |
+ struct ibv_device **(*get_device_list)(int *num_devices);
|
|
|
a6040a |
+ void (*free_device_list)(struct ibv_device **list);
|
|
|
a6040a |
+ struct ibv_context *(*open_device)(struct ibv_device *device);
|
|
|
a6040a |
+ int (*close_device)(struct ibv_context *context);
|
|
|
a6040a |
+ const char *(*get_device_name)(struct ibv_device *device);
|
|
|
a6040a |
+ int (*query_device)(struct ibv_context *context,
|
|
|
a6040a |
+ struct ibv_device_attr *device_attr);
|
|
|
a6040a |
+ int (*query_device_ex)(struct ibv_context *context,
|
|
|
a6040a |
+ const struct ibv_query_device_ex_input *input,
|
|
|
a6040a |
+ struct ibv_device_attr_ex *attr);
|
|
|
a6040a |
+ int (*query_port)(struct ibv_context *context, uint8_t port_num,
|
|
|
a6040a |
+ struct ibv_port_attr *port_attr);
|
|
|
a6040a |
+ const char *(*port_state_str)(enum ibv_port_state port_state);
|
|
|
a6040a |
+ struct ibv_comp_channel *(*create_comp_channel)
|
|
|
a6040a |
+ (struct ibv_context *context);
|
|
|
a6040a |
+ int (*destroy_comp_channel)(struct ibv_comp_channel *channel);
|
|
|
a6040a |
+ struct ibv_cq *(*create_cq)(struct ibv_context *context, int cqe,
|
|
|
a6040a |
+ void *cq_context,
|
|
|
a6040a |
+ struct ibv_comp_channel *channel,
|
|
|
a6040a |
+ int comp_vector);
|
|
|
a6040a |
+ int (*destroy_cq)(struct ibv_cq *cq);
|
|
|
a6040a |
+ int (*get_cq_event)(struct ibv_comp_channel *channel,
|
|
|
a6040a |
+ struct ibv_cq **cq, void **cq_context);
|
|
|
a6040a |
+ void (*ack_cq_events)(struct ibv_cq *cq, unsigned int nevents);
|
|
|
a6040a |
+ struct ibv_flow *(*create_flow)(struct ibv_qp *qp,
|
|
|
a6040a |
+ struct ibv_flow_attr *flow);
|
|
|
a6040a |
+ int (*destroy_flow)(struct ibv_flow *flow_id);
|
|
|
a6040a |
+ struct ibv_qp *(*create_qp)(struct ibv_pd *pd,
|
|
|
a6040a |
+ struct ibv_qp_init_attr *qp_init_attr);
|
|
|
a6040a |
+ struct ibv_qp *(*create_qp_ex)
|
|
|
a6040a |
+ (struct ibv_context *context,
|
|
|
a6040a |
+ struct ibv_qp_init_attr_ex *qp_init_attr_ex);
|
|
|
a6040a |
+ int (*destroy_qp)(struct ibv_qp *qp);
|
|
|
a6040a |
+ int (*modify_qp)(struct ibv_qp *qp, struct ibv_qp_attr *attr,
|
|
|
a6040a |
+ int attr_mask);
|
|
|
a6040a |
+ struct ibv_mr *(*reg_mr)(struct ibv_pd *pd, void *addr,
|
|
|
a6040a |
+ size_t length, int access);
|
|
|
a6040a |
+ int (*dereg_mr)(struct ibv_mr *mr);
|
|
|
a6040a |
+ struct ibv_rwq_ind_table *(*create_rwq_ind_table)
|
|
|
a6040a |
+ (struct ibv_context *context,
|
|
|
a6040a |
+ struct ibv_rwq_ind_table_init_attr *init_attr);
|
|
|
a6040a |
+ int (*destroy_rwq_ind_table)(struct ibv_rwq_ind_table *rwq_ind_table);
|
|
|
a6040a |
+ struct ibv_wq *(*create_wq)(struct ibv_context *context,
|
|
|
a6040a |
+ struct ibv_wq_init_attr *wq_init_attr);
|
|
|
a6040a |
+ int (*destroy_wq)(struct ibv_wq *wq);
|
|
|
a6040a |
+ int (*modify_wq)(struct ibv_wq *wq, struct ibv_wq_attr *wq_attr);
|
|
|
a6040a |
+ int (*dv_init_obj)(struct mlx4dv_obj *obj, uint64_t obj_type);
|
|
|
a6040a |
+ int (*dv_set_context_attr)(struct ibv_context *context,
|
|
|
a6040a |
+ enum mlx4dv_set_ctx_attr_type attr_type,
|
|
|
a6040a |
+ void *attr);
|
|
|
a6040a |
+};
|
|
|
a6040a |
+
|
|
|
a6040a |
+const struct mlx4_glue *mlx4_glue;
|
|
|
a6040a |
+
|
|
|
a6040a |
+#endif /* MLX4_GLUE_H_ */
|
|
|
a6040a |
diff --git a/drivers/net/mlx4/mlx4_intr.c b/drivers/net/mlx4/mlx4_intr.c
|
|
|
a6040a |
index 50d1976..c63806d 100644
|
|
|
a6040a |
--- a/drivers/net/mlx4/mlx4_intr.c
|
|
|
a6040a |
+++ b/drivers/net/mlx4/mlx4_intr.c
|
|
|
a6040a |
@@ -57,6 +57,7 @@
|
|
|
a6040a |
#include <rte_interrupts.h>
|
|
|
a6040a |
|
|
|
a6040a |
#include "mlx4.h"
|
|
|
a6040a |
+#include "mlx4_glue.h"
|
|
|
a6040a |
#include "mlx4_rxtx.h"
|
|
|
a6040a |
#include "mlx4_utils.h"
|
|
|
a6040a |
|
|
|
a6040a |
@@ -216,7 +217,7 @@
|
|
|
a6040a |
unsigned int i;
|
|
|
a6040a |
|
|
|
a6040a |
/* Read all message and acknowledge them. */
|
|
|
a6040a |
- while (!ibv_get_async_event(priv->ctx, &event)) {
|
|
|
a6040a |
+ while (!mlx4_glue->get_async_event(priv->ctx, &event)) {
|
|
|
a6040a |
switch (event.event_type) {
|
|
|
a6040a |
case IBV_EVENT_PORT_ACTIVE:
|
|
|
a6040a |
case IBV_EVENT_PORT_ERR:
|
|
|
a6040a |
@@ -231,7 +232,7 @@
|
|
|
a6040a |
DEBUG("event type %d on physical port %d not handled",
|
|
|
a6040a |
event.event_type, event.element.port_num);
|
|
|
a6040a |
}
|
|
|
a6040a |
- ibv_ack_async_event(&event);
|
|
|
a6040a |
+ mlx4_glue->ack_async_event(&event);
|
|
|
a6040a |
}
|
|
|
a6040a |
for (i = 0; i != RTE_DIM(caught); ++i)
|
|
|
a6040a |
if (caught[i])
|
|
|
a6040a |
@@ -354,7 +355,8 @@
|
|
|
a6040a |
if (!rxq || !rxq->channel) {
|
|
|
a6040a |
ret = EINVAL;
|
|
|
a6040a |
} else {
|
|
|
a6040a |
- ret = ibv_get_cq_event(rxq->cq->channel, &ev_cq, &ev_ctx);
|
|
|
a6040a |
+ ret = mlx4_glue->get_cq_event(rxq->cq->channel, &ev_cq,
|
|
|
a6040a |
+ &ev_ctx);
|
|
|
a6040a |
if (ret || ev_cq != rxq->cq)
|
|
|
a6040a |
ret = EINVAL;
|
|
|
a6040a |
}
|
|
|
a6040a |
@@ -364,7 +366,7 @@
|
|
|
a6040a |
idx);
|
|
|
a6040a |
} else {
|
|
|
a6040a |
rxq->mcq.arm_sn++;
|
|
|
a6040a |
- ibv_ack_cq_events(rxq->cq, 1);
|
|
|
a6040a |
+ mlx4_glue->ack_cq_events(rxq->cq, 1);
|
|
|
a6040a |
}
|
|
|
a6040a |
return -ret;
|
|
|
a6040a |
}
|
|
|
a6040a |
diff --git a/drivers/net/mlx4/mlx4_mr.c b/drivers/net/mlx4/mlx4_mr.c
|
|
|
a6040a |
index 2a3e269..493c008 100644
|
|
|
a6040a |
--- a/drivers/net/mlx4/mlx4_mr.c
|
|
|
a6040a |
+++ b/drivers/net/mlx4/mlx4_mr.c
|
|
|
a6040a |
@@ -60,6 +60,7 @@
|
|
|
a6040a |
#include <rte_mempool.h>
|
|
|
a6040a |
#include <rte_spinlock.h>
|
|
|
a6040a |
|
|
|
a6040a |
+#include "mlx4_glue.h"
|
|
|
a6040a |
#include "mlx4_rxtx.h"
|
|
|
a6040a |
#include "mlx4_utils.h"
|
|
|
a6040a |
|
|
|
a6040a |
@@ -200,8 +201,8 @@ struct mlx4_mr *
|
|
|
a6040a |
.end = end,
|
|
|
a6040a |
.refcnt = 1,
|
|
|
a6040a |
.priv = priv,
|
|
|
a6040a |
- .mr = ibv_reg_mr(priv->pd, (void *)start, end - start,
|
|
|
a6040a |
- IBV_ACCESS_LOCAL_WRITE),
|
|
|
a6040a |
+ .mr = mlx4_glue->reg_mr(priv->pd, (void *)start, end - start,
|
|
|
a6040a |
+ IBV_ACCESS_LOCAL_WRITE),
|
|
|
a6040a |
.mp = mp,
|
|
|
a6040a |
};
|
|
|
a6040a |
if (mr->mr) {
|
|
|
a6040a |
@@ -240,7 +241,7 @@ struct mlx4_mr *
|
|
|
a6040a |
if (--mr->refcnt)
|
|
|
a6040a |
goto release;
|
|
|
a6040a |
LIST_REMOVE(mr, next);
|
|
|
a6040a |
- claim_zero(ibv_dereg_mr(mr->mr));
|
|
|
a6040a |
+ claim_zero(mlx4_glue->dereg_mr(mr->mr));
|
|
|
a6040a |
rte_free(mr);
|
|
|
a6040a |
release:
|
|
|
a6040a |
rte_spinlock_unlock(&priv->mr_lock);
|
|
|
a6040a |
diff --git a/drivers/net/mlx4/mlx4_rxq.c b/drivers/net/mlx4/mlx4_rxq.c
|
|
|
a6040a |
index 53313c5..7ab3a46 100644
|
|
|
a6040a |
--- a/drivers/net/mlx4/mlx4_rxq.c
|
|
|
a6040a |
+++ b/drivers/net/mlx4/mlx4_rxq.c
|
|
|
a6040a |
@@ -62,6 +62,7 @@
|
|
|
a6040a |
#include <rte_mempool.h>
|
|
|
a6040a |
|
|
|
a6040a |
#include "mlx4.h"
|
|
|
a6040a |
+#include "mlx4_glue.h"
|
|
|
a6040a |
#include "mlx4_flow.h"
|
|
|
a6040a |
#include "mlx4_rxtx.h"
|
|
|
a6040a |
#include "mlx4_utils.h"
|
|
|
a6040a |
@@ -231,7 +232,7 @@ struct mlx4_rss *
|
|
|
a6040a |
}
|
|
|
a6040a |
ind_tbl[i] = rxq->wq;
|
|
|
a6040a |
}
|
|
|
a6040a |
- rss->ind = ibv_create_rwq_ind_table
|
|
|
a6040a |
+ rss->ind = mlx4_glue->create_rwq_ind_table
|
|
|
a6040a |
(priv->ctx,
|
|
|
a6040a |
&(struct ibv_rwq_ind_table_init_attr){
|
|
|
a6040a |
.log_ind_tbl_size = rte_log2_u32(RTE_DIM(ind_tbl)),
|
|
|
a6040a |
@@ -243,7 +244,7 @@ struct mlx4_rss *
|
|
|
a6040a |
msg = "RSS indirection table creation failure";
|
|
|
a6040a |
goto error;
|
|
|
a6040a |
}
|
|
|
a6040a |
- rss->qp = ibv_create_qp_ex
|
|
|
a6040a |
+ rss->qp = mlx4_glue->create_qp_ex
|
|
|
a6040a |
(priv->ctx,
|
|
|
a6040a |
&(struct ibv_qp_init_attr_ex){
|
|
|
a6040a |
.comp_mask = (IBV_QP_INIT_ATTR_PD |
|
|
|
a6040a |
@@ -264,7 +265,7 @@ struct mlx4_rss *
|
|
|
a6040a |
msg = "RSS hash QP creation failure";
|
|
|
a6040a |
goto error;
|
|
|
a6040a |
}
|
|
|
a6040a |
- ret = ibv_modify_qp
|
|
|
a6040a |
+ ret = mlx4_glue->modify_qp
|
|
|
a6040a |
(rss->qp,
|
|
|
a6040a |
&(struct ibv_qp_attr){
|
|
|
a6040a |
.qp_state = IBV_QPS_INIT,
|
|
|
a6040a |
@@ -275,7 +276,7 @@ struct mlx4_rss *
|
|
|
a6040a |
msg = "failed to switch RSS hash QP to INIT state";
|
|
|
a6040a |
goto error;
|
|
|
a6040a |
}
|
|
|
a6040a |
- ret = ibv_modify_qp
|
|
|
a6040a |
+ ret = mlx4_glue->modify_qp
|
|
|
a6040a |
(rss->qp,
|
|
|
a6040a |
&(struct ibv_qp_attr){
|
|
|
a6040a |
.qp_state = IBV_QPS_RTR,
|
|
|
a6040a |
@@ -288,11 +289,11 @@ struct mlx4_rss *
|
|
|
a6040a |
return 0;
|
|
|
a6040a |
error:
|
|
|
a6040a |
if (rss->qp) {
|
|
|
a6040a |
- claim_zero(ibv_destroy_qp(rss->qp));
|
|
|
a6040a |
+ claim_zero(mlx4_glue->destroy_qp(rss->qp));
|
|
|
a6040a |
rss->qp = NULL;
|
|
|
a6040a |
}
|
|
|
a6040a |
if (rss->ind) {
|
|
|
a6040a |
- claim_zero(ibv_destroy_rwq_ind_table(rss->ind));
|
|
|
a6040a |
+ claim_zero(mlx4_glue->destroy_rwq_ind_table(rss->ind));
|
|
|
a6040a |
rss->ind = NULL;
|
|
|
a6040a |
}
|
|
|
a6040a |
while (i--)
|
|
|
a6040a |
@@ -325,9 +326,9 @@ struct mlx4_rss *
|
|
|
a6040a |
assert(rss->ind);
|
|
|
a6040a |
if (--rss->usecnt)
|
|
|
a6040a |
return;
|
|
|
a6040a |
- claim_zero(ibv_destroy_qp(rss->qp));
|
|
|
a6040a |
+ claim_zero(mlx4_glue->destroy_qp(rss->qp));
|
|
|
a6040a |
rss->qp = NULL;
|
|
|
a6040a |
- claim_zero(ibv_destroy_rwq_ind_table(rss->ind));
|
|
|
a6040a |
+ claim_zero(mlx4_glue->destroy_rwq_ind_table(rss->ind));
|
|
|
a6040a |
rss->ind = NULL;
|
|
|
a6040a |
for (i = 0; i != rss->queues; ++i)
|
|
|
a6040a |
mlx4_rxq_detach(priv->dev->data->rx_queues[rss->queue_id[i]]);
|
|
|
a6040a |
@@ -364,9 +365,10 @@ struct mlx4_rss *
|
|
|
a6040a |
int ret;
|
|
|
a6040a |
|
|
|
a6040a |
/* Prepare range for RSS contexts before creating the first WQ. */
|
|
|
a6040a |
- ret = mlx4dv_set_context_attr(priv->ctx,
|
|
|
a6040a |
- MLX4DV_SET_CTX_ATTR_LOG_WQS_RANGE_SZ,
|
|
|
a6040a |
- &log2_range);
|
|
|
a6040a |
+ ret = mlx4_glue->dv_set_context_attr
|
|
|
a6040a |
+ (priv->ctx,
|
|
|
a6040a |
+ MLX4DV_SET_CTX_ATTR_LOG_WQS_RANGE_SZ,
|
|
|
a6040a |
+ &log2_range);
|
|
|
a6040a |
if (ret) {
|
|
|
a6040a |
ERROR("cannot set up range size for RSS context to %u"
|
|
|
a6040a |
" (for %u Rx queues), error: %s",
|
|
|
a6040a |
@@ -402,13 +404,13 @@ struct mlx4_rss *
|
|
|
a6040a |
* sequentially and are guaranteed to never be reused in the
|
|
|
a6040a |
* same context by the underlying implementation.
|
|
|
a6040a |
*/
|
|
|
a6040a |
- cq = ibv_create_cq(priv->ctx, 1, NULL, NULL, 0);
|
|
|
a6040a |
+ cq = mlx4_glue->create_cq(priv->ctx, 1, NULL, NULL, 0);
|
|
|
a6040a |
if (!cq) {
|
|
|
a6040a |
ret = ENOMEM;
|
|
|
a6040a |
msg = "placeholder CQ creation failure";
|
|
|
a6040a |
goto error;
|
|
|
a6040a |
}
|
|
|
a6040a |
- wq = ibv_create_wq
|
|
|
a6040a |
+ wq = mlx4_glue->create_wq
|
|
|
a6040a |
(priv->ctx,
|
|
|
a6040a |
&(struct ibv_wq_init_attr){
|
|
|
a6040a |
.wq_type = IBV_WQT_RQ,
|
|
|
a6040a |
@@ -419,11 +421,11 @@ struct mlx4_rss *
|
|
|
a6040a |
});
|
|
|
a6040a |
if (wq) {
|
|
|
a6040a |
wq_num = wq->wq_num;
|
|
|
a6040a |
- claim_zero(ibv_destroy_wq(wq));
|
|
|
a6040a |
+ claim_zero(mlx4_glue->destroy_wq(wq));
|
|
|
a6040a |
} else {
|
|
|
a6040a |
wq_num = 0; /* Shut up GCC 4.8 warnings. */
|
|
|
a6040a |
}
|
|
|
a6040a |
- claim_zero(ibv_destroy_cq(cq));
|
|
|
a6040a |
+ claim_zero(mlx4_glue->destroy_cq(cq));
|
|
|
a6040a |
if (!wq) {
|
|
|
a6040a |
ret = ENOMEM;
|
|
|
a6040a |
msg = "placeholder WQ creation failure";
|
|
|
a6040a |
@@ -522,13 +524,14 @@ struct mlx4_rss *
|
|
|
a6040a |
int ret;
|
|
|
a6040a |
|
|
|
a6040a |
assert(rte_is_power_of_2(elts_n));
|
|
|
a6040a |
- cq = ibv_create_cq(priv->ctx, elts_n / sges_n, NULL, rxq->channel, 0);
|
|
|
a6040a |
+ cq = mlx4_glue->create_cq(priv->ctx, elts_n / sges_n, NULL,
|
|
|
a6040a |
+ rxq->channel, 0);
|
|
|
a6040a |
if (!cq) {
|
|
|
a6040a |
ret = ENOMEM;
|
|
|
a6040a |
msg = "CQ creation failure";
|
|
|
a6040a |
goto error;
|
|
|
a6040a |
}
|
|
|
a6040a |
- wq = ibv_create_wq
|
|
|
a6040a |
+ wq = mlx4_glue->create_wq
|
|
|
a6040a |
(priv->ctx,
|
|
|
a6040a |
&(struct ibv_wq_init_attr){
|
|
|
a6040a |
.wq_type = IBV_WQT_RQ,
|
|
|
a6040a |
@@ -542,7 +545,7 @@ struct mlx4_rss *
|
|
|
a6040a |
msg = "WQ creation failure";
|
|
|
a6040a |
goto error;
|
|
|
a6040a |
}
|
|
|
a6040a |
- ret = ibv_modify_wq
|
|
|
a6040a |
+ ret = mlx4_glue->modify_wq
|
|
|
a6040a |
(wq,
|
|
|
a6040a |
&(struct ibv_wq_attr){
|
|
|
a6040a |
.attr_mask = IBV_WQ_ATTR_STATE,
|
|
|
a6040a |
@@ -557,7 +560,7 @@ struct mlx4_rss *
|
|
|
a6040a |
mlxdv.cq.out = &dv_cq;
|
|
|
a6040a |
mlxdv.rwq.in = wq;
|
|
|
a6040a |
mlxdv.rwq.out = &dv_rwq;
|
|
|
a6040a |
- ret = mlx4dv_init_obj(&mlxdv, MLX4DV_OBJ_RWQ | MLX4DV_OBJ_CQ);
|
|
|
a6040a |
+ ret = mlx4_glue->dv_init_obj(&mlxdv, MLX4DV_OBJ_RWQ | MLX4DV_OBJ_CQ);
|
|
|
a6040a |
if (ret) {
|
|
|
a6040a |
msg = "failed to obtain device information from WQ/CQ objects";
|
|
|
a6040a |
goto error;
|
|
|
a6040a |
@@ -619,9 +622,9 @@ struct mlx4_rss *
|
|
|
a6040a |
return 0;
|
|
|
a6040a |
error:
|
|
|
a6040a |
if (wq)
|
|
|
a6040a |
- claim_zero(ibv_destroy_wq(wq));
|
|
|
a6040a |
+ claim_zero(mlx4_glue->destroy_wq(wq));
|
|
|
a6040a |
if (cq)
|
|
|
a6040a |
- claim_zero(ibv_destroy_cq(cq));
|
|
|
a6040a |
+ claim_zero(mlx4_glue->destroy_cq(cq));
|
|
|
a6040a |
rte_errno = ret;
|
|
|
a6040a |
ERROR("error while attaching Rx queue %p: %s: %s",
|
|
|
a6040a |
(void *)rxq, msg, strerror(ret));
|
|
|
a6040a |
@@ -649,9 +652,9 @@ struct mlx4_rss *
|
|
|
a6040a |
memset(&rxq->mcq, 0, sizeof(rxq->mcq));
|
|
|
a6040a |
rxq->rq_db = NULL;
|
|
|
a6040a |
rxq->wqes = NULL;
|
|
|
a6040a |
- claim_zero(ibv_destroy_wq(rxq->wq));
|
|
|
a6040a |
+ claim_zero(mlx4_glue->destroy_wq(rxq->wq));
|
|
|
a6040a |
rxq->wq = NULL;
|
|
|
a6040a |
- claim_zero(ibv_destroy_cq(rxq->cq));
|
|
|
a6040a |
+ claim_zero(mlx4_glue->destroy_cq(rxq->cq));
|
|
|
a6040a |
rxq->cq = NULL;
|
|
|
a6040a |
DEBUG("%p: freeing Rx queue elements", (void *)rxq);
|
|
|
a6040a |
for (i = 0; (i != RTE_DIM(*elts)); ++i) {
|
|
|
a6040a |
@@ -812,7 +815,7 @@ struct mlx4_rss *
|
|
|
a6040a |
goto error;
|
|
|
a6040a |
}
|
|
|
a6040a |
if (dev->data->dev_conf.intr_conf.rxq) {
|
|
|
a6040a |
- rxq->channel = ibv_create_comp_channel(priv->ctx);
|
|
|
a6040a |
+ rxq->channel = mlx4_glue->create_comp_channel(priv->ctx);
|
|
|
a6040a |
if (rxq->channel == NULL) {
|
|
|
a6040a |
rte_errno = ENOMEM;
|
|
|
a6040a |
ERROR("%p: Rx interrupt completion channel creation"
|
|
|
a6040a |
@@ -867,7 +870,7 @@ struct mlx4_rss *
|
|
|
a6040a |
assert(!rxq->wqes);
|
|
|
a6040a |
assert(!rxq->rq_db);
|
|
|
a6040a |
if (rxq->channel)
|
|
|
a6040a |
- claim_zero(ibv_destroy_comp_channel(rxq->channel));
|
|
|
a6040a |
+ claim_zero(mlx4_glue->destroy_comp_channel(rxq->channel));
|
|
|
a6040a |
if (rxq->mr)
|
|
|
a6040a |
mlx4_mr_put(rxq->mr);
|
|
|
a6040a |
rte_free(rxq);
|
|
|
a6040a |
diff --git a/drivers/net/mlx4/mlx4_txq.c b/drivers/net/mlx4/mlx4_txq.c
|
|
|
a6040a |
index 7882a4d..d97221b 100644
|
|
|
a6040a |
--- a/drivers/net/mlx4/mlx4_txq.c
|
|
|
a6040a |
+++ b/drivers/net/mlx4/mlx4_txq.c
|
|
|
a6040a |
@@ -60,6 +60,7 @@
|
|
|
a6040a |
|
|
|
a6040a |
#include "mlx4.h"
|
|
|
a6040a |
#include "mlx4_autoconf.h"
|
|
|
a6040a |
+#include "mlx4_glue.h"
|
|
|
a6040a |
#include "mlx4_prm.h"
|
|
|
a6040a |
#include "mlx4_rxtx.h"
|
|
|
a6040a |
#include "mlx4_utils.h"
|
|
|
a6040a |
@@ -284,7 +285,7 @@ struct txq_mp2mr_mbuf_check_data {
|
|
|
a6040a |
.lb = !!priv->vf,
|
|
|
a6040a |
.bounce_buf = bounce_buf,
|
|
|
a6040a |
};
|
|
|
a6040a |
- txq->cq = ibv_create_cq(priv->ctx, desc, NULL, NULL, 0);
|
|
|
a6040a |
+ txq->cq = mlx4_glue->create_cq(priv->ctx, desc, NULL, NULL, 0);
|
|
|
a6040a |
if (!txq->cq) {
|
|
|
a6040a |
rte_errno = ENOMEM;
|
|
|
a6040a |
ERROR("%p: CQ creation failure: %s",
|
|
|
a6040a |
@@ -304,7 +305,7 @@ struct txq_mp2mr_mbuf_check_data {
|
|
|
a6040a |
/* No completion events must occur by default. */
|
|
|
a6040a |
.sq_sig_all = 0,
|
|
|
a6040a |
};
|
|
|
a6040a |
- txq->qp = ibv_create_qp(priv->pd, &qp_init_attr);
|
|
|
a6040a |
+ txq->qp = mlx4_glue->create_qp(priv->pd, &qp_init_attr);
|
|
|
a6040a |
if (!txq->qp) {
|
|
|
a6040a |
rte_errno = errno ? errno : EINVAL;
|
|
|
a6040a |
ERROR("%p: QP creation failure: %s",
|
|
|
a6040a |
@@ -312,7 +313,7 @@ struct txq_mp2mr_mbuf_check_data {
|
|
|
a6040a |
goto error;
|
|
|
a6040a |
}
|
|
|
a6040a |
txq->max_inline = qp_init_attr.cap.max_inline_data;
|
|
|
a6040a |
- ret = ibv_modify_qp
|
|
|
a6040a |
+ ret = mlx4_glue->modify_qp
|
|
|
a6040a |
(txq->qp,
|
|
|
a6040a |
&(struct ibv_qp_attr){
|
|
|
a6040a |
.qp_state = IBV_QPS_INIT,
|
|
|
a6040a |
@@ -325,7 +326,7 @@ struct txq_mp2mr_mbuf_check_data {
|
|
|
a6040a |
(void *)dev, strerror(rte_errno));
|
|
|
a6040a |
goto error;
|
|
|
a6040a |
}
|
|
|
a6040a |
- ret = ibv_modify_qp
|
|
|
a6040a |
+ ret = mlx4_glue->modify_qp
|
|
|
a6040a |
(txq->qp,
|
|
|
a6040a |
&(struct ibv_qp_attr){
|
|
|
a6040a |
.qp_state = IBV_QPS_RTR,
|
|
|
a6040a |
@@ -337,7 +338,7 @@ struct txq_mp2mr_mbuf_check_data {
|
|
|
a6040a |
(void *)dev, strerror(rte_errno));
|
|
|
a6040a |
goto error;
|
|
|
a6040a |
}
|
|
|
a6040a |
- ret = ibv_modify_qp
|
|
|
a6040a |
+ ret = mlx4_glue->modify_qp
|
|
|
a6040a |
(txq->qp,
|
|
|
a6040a |
&(struct ibv_qp_attr){
|
|
|
a6040a |
.qp_state = IBV_QPS_RTS,
|
|
|
a6040a |
@@ -354,7 +355,7 @@ struct txq_mp2mr_mbuf_check_data {
|
|
|
a6040a |
mlxdv.cq.out = &dv_cq;
|
|
|
a6040a |
mlxdv.qp.in = txq->qp;
|
|
|
a6040a |
mlxdv.qp.out = &dv_qp;
|
|
|
a6040a |
- ret = mlx4dv_init_obj(&mlxdv, MLX4DV_OBJ_QP | MLX4DV_OBJ_CQ);
|
|
|
a6040a |
+ ret = mlx4_glue->dv_init_obj(&mlxdv, MLX4DV_OBJ_QP | MLX4DV_OBJ_CQ);
|
|
|
a6040a |
if (ret) {
|
|
|
a6040a |
rte_errno = EINVAL;
|
|
|
a6040a |
ERROR("%p: failed to obtain information needed for"
|
|
|
a6040a |
@@ -401,9 +402,9 @@ struct txq_mp2mr_mbuf_check_data {
|
|
|
a6040a |
}
|
|
|
a6040a |
mlx4_txq_free_elts(txq);
|
|
|
a6040a |
if (txq->qp)
|
|
|
a6040a |
- claim_zero(ibv_destroy_qp(txq->qp));
|
|
|
a6040a |
+ claim_zero(mlx4_glue->destroy_qp(txq->qp));
|
|
|
a6040a |
if (txq->cq)
|
|
|
a6040a |
- claim_zero(ibv_destroy_cq(txq->cq));
|
|
|
a6040a |
+ claim_zero(mlx4_glue->destroy_cq(txq->cq));
|
|
|
a6040a |
for (i = 0; i != RTE_DIM(txq->mp2mr); ++i) {
|
|
|
a6040a |
if (!txq->mp2mr[i].mp)
|
|
|
a6040a |
break;
|
|
|
a6040a |
--
|
|
|
a6040a |
1.8.3.1
|
|
|
a6040a |
|