]> git.droids-corp.org - dpdk.git/commitdiff
net/mlx5: fix allocation when no memory on device NUMA node
authorOlivier Matz <olivier.matz@6wind.com>
Mon, 22 Jan 2018 12:33:38 +0000 (13:33 +0100)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 29 Jan 2018 09:04:28 +0000 (10:04 +0100)
When no memory is available on the same numa node than the device, the
initialization of the device fails. However, the use case where the
cores and memory are on a different socket than the device is valid,
even if not optimal.

To fix this issue, this commit introduces an infrastructure to select
the socket on which to allocate the verbs objects based on the ethdev
configuration and the object type, rather than the PCI numa node.

Fixes: 1e3a39f72d5d ("net/mlx5: allocate verbs object into shared memory")
Cc: stable@dpdk.org
Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Signed-off-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
drivers/net/mlx5/mlx5.c
drivers/net/mlx5/mlx5.h
drivers/net/mlx5/mlx5_rxq.c
drivers/net/mlx5/mlx5_txq.c

index 9d1de366b4301e1c7c9c113ff0db9b4ec312cec4..bc4b6bad045bce027dd61b72c59d322a0ca88403 100644 (file)
@@ -139,10 +139,20 @@ mlx5_alloc_verbs_buf(size_t size, void *data)
        struct priv *priv = data;
        void *ret;
        size_t alignment = sysconf(_SC_PAGESIZE);
+       unsigned int socket = SOCKET_ID_ANY;
 
+       if (priv->verbs_alloc_ctx.type == MLX5_VERBS_ALLOC_TYPE_TX_QUEUE) {
+               const struct mlx5_txq_ctrl *ctrl = priv->verbs_alloc_ctx.obj;
+
+               socket = ctrl->socket;
+       } else if (priv->verbs_alloc_ctx.type ==
+                  MLX5_VERBS_ALLOC_TYPE_RX_QUEUE) {
+               const struct mlx5_rxq_ctrl *ctrl = priv->verbs_alloc_ctx.obj;
+
+               socket = ctrl->socket;
+       }
        assert(data != NULL);
-       ret = rte_malloc_socket(__func__, size, alignment,
-                               priv->dev->device->numa_node);
+       ret = rte_malloc_socket(__func__, size, alignment, socket);
        DEBUG("Extern alloc size: %lu, align: %lu: %p", size, alignment, ret);
        return ret;
 }
index eb0894fa5a0b8dfd6505b6cd6312894fb216f21d..a7ec607c3a259cb27e68ba7b3c6a98dc8fce7dfb 100644 (file)
@@ -123,6 +123,24 @@ struct mlx5_dev_config {
        int inline_max_packet_sz; /* Max packet size for inlining. */
 };
 
+/**
+ * Type of objet being allocated.
+ */
+enum mlx5_verbs_alloc_type {
+       MLX5_VERBS_ALLOC_TYPE_NONE,
+       MLX5_VERBS_ALLOC_TYPE_TX_QUEUE,
+       MLX5_VERBS_ALLOC_TYPE_RX_QUEUE,
+};
+
+/**
+ * Verbs allocator needs a context to know in the callback which kind of
+ * resources it is allocating.
+ */
+struct mlx5_verbs_alloc_ctx {
+       enum mlx5_verbs_alloc_type type; /* Kind of object being allocated. */
+       const void *obj; /* Pointer to the DPDK object. */
+};
+
 struct priv {
        struct rte_eth_dev *dev; /* Ethernet device of master process. */
        struct ibv_context *ctx; /* Verbs context. */
@@ -164,6 +182,8 @@ struct priv {
        int primary_socket; /* Unix socket for primary process. */
        struct rte_intr_handle intr_handle_socket; /* Interrupt handler. */
        struct mlx5_dev_config config; /* Device configuration. */
+       struct mlx5_verbs_alloc_ctx verbs_alloc_ctx;
+       /* Context for Verbs allocator. */
 };
 
 /**
index 8cee5de12ddc5d07fd429d89a79241281ab021e3..545896e5f1691c2ac62419e4be35896f1671b62c 100644 (file)
@@ -654,6 +654,8 @@ mlx5_priv_rxq_ibv_new(struct priv *priv, uint16_t idx)
 
        assert(rxq_data);
        assert(!rxq_ctrl->ibv);
+       priv->verbs_alloc_ctx.type = MLX5_VERBS_ALLOC_TYPE_RX_QUEUE;
+       priv->verbs_alloc_ctx.obj = rxq_ctrl;
        tmpl = rte_calloc_socket(__func__, 1, sizeof(*tmpl), 0,
                                 rxq_ctrl->socket);
        if (!tmpl) {
@@ -817,6 +819,7 @@ mlx5_priv_rxq_ibv_new(struct priv *priv, uint16_t idx)
        DEBUG("%p: Verbs Rx queue %p: refcnt %d", (void *)priv,
              (void *)tmpl, rte_atomic32_read(&tmpl->refcnt));
        LIST_INSERT_HEAD(&priv->rxqsibv, tmpl, next);
+       priv->verbs_alloc_ctx.type = MLX5_VERBS_ALLOC_TYPE_NONE;
        return tmpl;
 error:
        if (tmpl->wq)
@@ -827,6 +830,7 @@ error:
                claim_zero(ibv_destroy_comp_channel(tmpl->channel));
        if (tmpl->mr)
                priv_mr_release(priv, tmpl->mr);
+       priv->verbs_alloc_ctx.type = MLX5_VERBS_ALLOC_TYPE_NONE;
        return NULL;
 }
 
index 49018303e19eea0fb98a93f13ed8bc51f0515d2b..18321c3e3a716bd2063cb22beea6b45c467d7e07 100644 (file)
@@ -396,6 +396,8 @@ mlx5_priv_txq_ibv_new(struct priv *priv, uint16_t idx)
        int ret = 0;
 
        assert(txq_data);
+       priv->verbs_alloc_ctx.type = MLX5_VERBS_ALLOC_TYPE_TX_QUEUE;
+       priv->verbs_alloc_ctx.obj = txq_ctrl;
        if (mlx5_getenv_int("MLX5_ENABLE_CQE_COMPRESSION")) {
                ERROR("MLX5_ENABLE_CQE_COMPRESSION must never be set");
                goto error;
@@ -526,12 +528,14 @@ mlx5_priv_txq_ibv_new(struct priv *priv, uint16_t idx)
        DEBUG("%p: Verbs Tx queue %p: refcnt %d", (void *)priv,
              (void *)txq_ibv, rte_atomic32_read(&txq_ibv->refcnt));
        LIST_INSERT_HEAD(&priv->txqsibv, txq_ibv, next);
+       priv->verbs_alloc_ctx.type = MLX5_VERBS_ALLOC_TYPE_NONE;
        return txq_ibv;
 error:
        if (tmpl.cq)
                claim_zero(ibv_destroy_cq(tmpl.cq));
        if (tmpl.qp)
                claim_zero(ibv_destroy_qp(tmpl.qp));
+       priv->verbs_alloc_ctx.type = MLX5_VERBS_ALLOC_TYPE_NONE;
        return NULL;
 }