net/mlx5: fix allocation when no memory on device NUMA node
[dpdk.git] / drivers / net / mlx5 / mlx5.c
index fdd4710..bc4b6ba 100644 (file)
@@ -51,7 +51,7 @@
 #endif
 
 #include <rte_malloc.h>
-#include <rte_ethdev.h>
+#include <rte_ethdev_driver.h>
 #include <rte_ethdev_pci.h>
 #include <rte_pci.h>
 #include <rte_bus_pci.h>
@@ -85,9 +85,6 @@
 /* Device parameter to limit the size of inlining packet. */
 #define MLX5_TXQ_MAX_INLINE_LEN "txq_max_inline_len"
 
-/* Device parameter to enable hardware TSO offload. */
-#define MLX5_TSO "tso"
-
 /* Device parameter to enable hardware Tx vector. */
 #define MLX5_TX_VEC_EN "tx_vec_en"
 
@@ -142,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;
 }
@@ -287,6 +294,7 @@ const struct eth_dev_ops mlx5_dev_ops = {
        .tx_descriptor_status = mlx5_tx_descriptor_status,
        .rx_queue_intr_enable = mlx5_rx_intr_enable,
        .rx_queue_intr_disable = mlx5_rx_intr_disable,
+       .is_removed = mlx5_is_removed,
 };
 
 static const struct eth_dev_ops mlx5_dev_sec_ops = {
@@ -334,6 +342,7 @@ const struct eth_dev_ops mlx5_dev_ops_isolate = {
        .tx_descriptor_status = mlx5_tx_descriptor_status,
        .rx_queue_intr_enable = mlx5_rx_intr_enable,
        .rx_queue_intr_disable = mlx5_rx_intr_disable,
+       .is_removed = mlx5_is_removed,
 };
 
 static struct {
@@ -406,8 +415,6 @@ mlx5_args_check(const char *key, const char *val, void *opaque)
                config->mpw_hdr_dseg = !!tmp;
        } else if (strcmp(MLX5_TXQ_MAX_INLINE_LEN, key) == 0) {
                config->inline_max_packet_sz = tmp;
-       } else if (strcmp(MLX5_TSO, key) == 0) {
-               config->tso = !!tmp;
        } else if (strcmp(MLX5_TX_VEC_EN, key) == 0) {
                config->tx_vec_en = !!tmp;
        } else if (strcmp(MLX5_RX_VEC_EN, key) == 0) {
@@ -440,7 +447,6 @@ mlx5_args(struct mlx5_dev_config *config, struct rte_devargs *devargs)
                MLX5_TXQ_MPW_EN,
                MLX5_TXQ_MPW_HDR_DSEG_EN,
                MLX5_TXQ_MAX_INLINE_LEN,
-               MLX5_TSO,
                MLX5_TX_VEC_EN,
                MLX5_RX_VEC_EN,
                NULL,
@@ -629,7 +635,6 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
                        .cqe_comp = cqe_comp,
                        .mps = mps,
                        .tunnel_en = tunnel_en,
-                       .tso = 0,
                        .tx_vec_en = 1,
                        .rx_vec_en = 1,
                        .mpw_hdr_dseg = 0,
@@ -759,8 +764,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
                      (config.hw_csum_l2tun ? "" : "not "));
 
 #ifdef HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT
-               config.counter_set_supported =
-                                       !!(device_attr.max_counter_sets);
+               config.flow_counter_en = !!(device_attr.max_counter_sets);
                ibv_describe_counter_set(ctx, 0, &cs_desc);
                DEBUG("counter type = %d, num of cs = %ld, attributes = %d",
                      cs_desc.counter_type, cs_desc.num_of_cs,
@@ -794,10 +798,9 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
 
                priv_get_num_vfs(priv, &num_vfs);
                config.sriov = (num_vfs || sriov);
-               if (config.tso)
-                       config.tso = ((device_attr_ex.tso_caps.max_tso > 0) &&
-                                     (device_attr_ex.tso_caps.supported_qpts &
-                                     (1 << IBV_QPT_RAW_PACKET)));
+               config.tso = ((device_attr_ex.tso_caps.max_tso > 0) &&
+                             (device_attr_ex.tso_caps.supported_qpts &
+                             (1 << IBV_QPT_RAW_PACKET)));
                if (config.tso)
                        config.tso_max_payload_sz =
                                        device_attr_ex.tso_caps.max_tso;
@@ -806,10 +809,6 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
                              " (" MLX5_TXQ_MPW_EN ")");
                        err = ENOTSUP;
                        goto port_error;
-               } else if (config.mps && config.tso) {
-                       WARN("multi-packet send not supported in conjunction "
-                             "with TSO. MPS disabled");
-                       config.mps = 0;
                }
                INFO("%sMPS is %s",
                     config.mps == MLX5_MPW_ENHANCED ? "Enhanced " : "",
@@ -882,7 +881,6 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
                /* Bring Ethernet device up. */
                DEBUG("forcing Ethernet interface up");
                priv_set_flags(priv, ~IFF_UP, IFF_UP);
-               mlx5_link_update(priv->dev, 1);
                /* Store device configuration on private structure. */
                priv->config = config;
                continue;