Skip to content

Commit

Permalink
net/mlx5: move rdma-core calls to separate file
Browse files Browse the repository at this point in the history
Partial-bug: #1783471
This lays the groundwork for externalizing rdma-core as an optional
run-time dependency instead of a mandatory one.

No functional change.

Change-Id: Ibc19ad2cf4419ee2f439c4f29b07b9312b129474
Signed-off-by: matan <matan@mellanox.com>
  • Loading branch information
Matan Azrad committed Jul 31, 2018
1 parent bcb4f12 commit 6c36ad6
Show file tree
Hide file tree
Showing 10 changed files with 587 additions and 106 deletions.
1 change: 1 addition & 0 deletions drivers/net/mlx5/Makefile
Expand Up @@ -53,6 +53,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_rss.c
SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_mr.c
SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_flow.c
SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_socket.c
SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD) += mlx5_glue.c

# Basic CFLAGS.
CFLAGS += -O3
Expand Down
40 changes: 21 additions & 19 deletions drivers/net/mlx5/mlx5.c
Expand Up @@ -65,6 +65,7 @@
#include "mlx5_rxtx.h"
#include "mlx5_autoconf.h"
#include "mlx5_defs.h"
#include "mlx5_glue.h"

/* Device parameter to enable RX completion queue compression. */
#define MLX5_RXQ_CQE_COMP_EN "rxq_cqe_comp_en"
Expand Down Expand Up @@ -238,8 +239,8 @@ mlx5_dev_close(struct rte_eth_dev *dev)
}
if (priv->pd != NULL) {
assert(priv->ctx != NULL);
claim_zero(ibv_dealloc_pd(priv->pd));
claim_zero(ibv_close_device(priv->ctx));
claim_zero(mlx5_glue->dealloc_pd(priv->pd));
claim_zero(mlx5_glue->close_device(priv->ctx));
} else
assert(priv->ctx == NULL);
if (priv->rss_conf.rss_key != NULL)
Expand Down Expand Up @@ -694,7 +695,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
DRV_LOG(DEBUG, "using driver device index %d", idx);
/* Save PCI address. */
mlx5_dev[idx].pci_addr = pci_dev->addr;
list = ibv_get_device_list(&i);
list = mlx5_glue->get_device_list(&i);
if (list == NULL) {
assert(errno);
err = errno;
Expand Down Expand Up @@ -736,7 +737,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
}
DRV_LOG(INFO, "PCI information matches, using device \"%s\"",
list[i]->name);
attr_ctx = ibv_open_device(list[i]);
attr_ctx = mlx5_glue->open_device(list[i]);
rte_errno = errno;
err = rte_errno;
break;
Expand All @@ -761,7 +762,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
* Multi-packet send is supported by ConnectX-4 Lx PF as well
* as all ConnectX-5 devices.
*/
mlx5dv_query_device(attr_ctx, &attrs_out);
mlx5_glue->dv_query_device(attr_ctx, &attrs_out);
if (attrs_out.flags & MLX5DV_CONTEXT_FLAGS_MPW_ALLOWED) {
if (attrs_out.flags & MLX5DV_CONTEXT_FLAGS_ENHANCED_MPW) {
DRV_LOG(DEBUG, "enhanced MPW is supported");
Expand All @@ -779,7 +780,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
cqe_comp = 0;
else
cqe_comp = 1;
err = ibv_query_device_ex(attr_ctx, NULL, &device_attr);
err = mlx5_glue->query_device_ex(attr_ctx, NULL, &device_attr);
if (err) {
DEBUG("ibv_query_device_ex() failed");
goto error;
Expand Down Expand Up @@ -852,13 +853,13 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
continue;
}
DRV_LOG(DEBUG, "using port %u (%08" PRIx32 ")", port, test);
ctx = ibv_open_device(ibv_dev);
ctx = mlx5_glue->open_device(ibv_dev);
if (ctx == NULL) {
err = ENODEV;
goto port_error;
}
/* Check port status. */
err = ibv_query_port(ctx, port, &port_attr);
err = mlx5_glue->query_port(ctx, port, &port_attr);
if (err) {
DRV_LOG(ERR, "port query failed: %s", strerror(err));
goto port_error;
Expand All @@ -872,10 +873,10 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
}
if (port_attr.state != IBV_PORT_ACTIVE)
DRV_LOG(DEBUG, "port %d is not active: \"%s\" (%d)",
port, ibv_port_state_str(port_attr.state),
port, mlx5_glue->port_state_str(port_attr.state),
port_attr.state);
/* Allocate protection domain. */
pd = ibv_alloc_pd(ctx);
pd = mlx5_glue->alloc_pd(ctx);
if (pd == NULL) {
DRV_LOG(ERR, "PD allocation failure");
err = ENOMEM;
Expand Down Expand Up @@ -912,7 +913,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
goto port_error;
}
mlx5_args_assign(priv, &args);
err = ibv_query_device_ex(ctx, NULL, &device_attr_ex);
err = mlx5_glue->query_device_ex(ctx, NULL, &device_attr_ex);
if (err) {
DRV_LOG(ERR, "ibv_query_device_ex() failed");
goto port_error;
Expand All @@ -932,7 +933,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,

#ifdef HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT
priv->counter_set_supported = !!(device_attr.max_counter_sets);
ibv_describe_counter_set(ctx, 0, &cs_desc);
mlx5_glue->describe_counter_set(ctx, 0, &cs_desc);
DRV_LOG(DEBUG,
"counter type = %d, num of cs = %ld, attributes = %d",
cs_desc.counter_type, cs_desc.num_of_cs,
Expand Down Expand Up @@ -1069,8 +1070,9 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
.free = &mlx5_free_verbs_buf,
.data = priv,
};
mlx5dv_set_context_attr(ctx, MLX5DV_CTX_ATTR_BUF_ALLOCATORS,
(void *)((uintptr_t)&alctr));
mlx5_glue->dv_set_context_attr(ctx,
MLX5DV_CTX_ATTR_BUF_ALLOCATORS,
(void *)((uintptr_t)&alctr));
/* Bring Ethernet device up. */
DRV_LOG(DEBUG, "port %u forcing Ethernet interface up",
eth_dev->data->port_id);
Expand All @@ -1086,9 +1088,9 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
if (priv)
rte_free(priv);
if (pd)
claim_zero(ibv_dealloc_pd(pd));
claim_zero(mlx5_glue->dealloc_pd(pd));
if (ctx)
claim_zero(ibv_close_device(ctx));
claim_zero(mlx5_glue->close_device(ctx));
if (eth_dev && rte_eal_process_type() == RTE_PROC_PRIMARY)
rte_eth_dev_release_port(eth_dev);
break;
Expand All @@ -1106,9 +1108,9 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
}
error:
if (attr_ctx)
claim_zero(ibv_close_device(attr_ctx));
claim_zero(mlx5_glue->close_device(attr_ctx));
if (list)
ibv_free_device_list(list);
mlx5_glue->free_device_list(list);
if (err) {
rte_errno = err;
return -rte_errno;
Expand Down Expand Up @@ -1182,7 +1184,7 @@ rte_mlx5_pmd_init(void)
/* Match the size of Rx completion entry to the size of a cacheline. */
if (RTE_CACHE_LINE_SIZE == 128)
setenv("MLX5_CQE_SIZE", "128", 0);
ibv_fork_init();
mlx5_glue->fork_init();
rte_pci_register(&mlx5_driver);
}

Expand Down
5 changes: 3 additions & 2 deletions drivers/net/mlx5/mlx5_ethdev.c
Expand Up @@ -63,6 +63,7 @@
#include <rte_malloc.h>

#include "mlx5.h"
#include "mlx5_glue.h"
#include "mlx5_rxtx.h"
#include "mlx5_utils.h"

Expand Down Expand Up @@ -916,7 +917,7 @@ mlx5_dev_status_handler(struct rte_eth_dev *dev)
}
/* Read all message and acknowledge them. */
for (;;) {
if (ibv_get_async_event(priv->ctx, &event))
if (mlx5_glue->get_async_event(priv->ctx, &event))
break;
if ((event.event_type == IBV_EVENT_PORT_ACTIVE ||
event.event_type == IBV_EVENT_PORT_ERR) &&
Expand All @@ -929,7 +930,7 @@ mlx5_dev_status_handler(struct rte_eth_dev *dev)
DRV_LOG(DEBUG,
"port %u event type %d on not handled",
dev->data->port_id, event.event_type);
ibv_ack_async_event(&event);
mlx5_glue->ack_async_event(&event);
}
return ret;
}
Expand Down

0 comments on commit 6c36ad6

Please sign in to comment.