net/mlx5: use PCI address as port name
[dpdk.git] / drivers / net / mlx5 / mlx5.c
index ca44a0a..445729c 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,
@@ -614,6 +620,8 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
        INFO("%u port(s) detected", device_attr.orig_attr.phys_port_cnt);
 
        for (i = 0; i < device_attr.orig_attr.phys_port_cnt; i++) {
+               char name[RTE_ETH_NAME_MAX_LEN];
+               int len;
                uint32_t port = i + 1; /* ports are indexed from one */
                uint32_t test = (1 << i);
                struct ibv_context *ctx = NULL;
@@ -629,7 +637,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,
@@ -638,14 +645,15 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
                        .inline_max_packet_sz = MLX5_ARG_UNSET,
                };
 
+               len = snprintf(name, sizeof(name), PCI_PRI_FMT,
+                        pci_dev->addr.domain, pci_dev->addr.bus,
+                        pci_dev->addr.devid, pci_dev->addr.function);
+               if (device_attr.orig_attr.phys_port_cnt > 1)
+                       snprintf(name + len, sizeof(name), " port %u", i);
+
                mlx5_dev[idx].ports |= test;
 
                if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
-                       /* from rte_ethdev.c */
-                       char name[RTE_ETH_NAME_MAX_LEN];
-
-                       snprintf(name, sizeof(name), "%s port %u",
-                                ibv_get_device_name(ibv_dev), port);
                        eth_dev = rte_eth_dev_attach_secondary(name);
                        if (eth_dev == NULL) {
                                ERROR("can not attach rte ethdev");
@@ -793,10 +801,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;
@@ -805,10 +812,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 " : "",
@@ -844,14 +847,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
                priv_get_mtu(priv, &priv->mtu);
                DEBUG("port %u MTU is %u", priv->port, priv->mtu);
 
-               /* from rte_ethdev.c */
-               {
-                       char name[RTE_ETH_NAME_MAX_LEN];
-
-                       snprintf(name, sizeof(name), "%s port %u",
-                                ibv_get_device_name(ibv_dev), port);
-                       eth_dev = rte_eth_dev_allocate(name);
-               }
+               eth_dev = rte_eth_dev_allocate(name);
                if (eth_dev == NULL) {
                        ERROR("can not allocate rte ethdev");
                        err = ENOMEM;
@@ -881,7 +877,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;