New upstream version 17.11.1
[deb_dpdk.git] / drivers / net / mlx5 / mlx5.c
index 0548d17..45e0e8d 100644 (file)
@@ -158,7 +158,6 @@ mlx5_alloc_verbs_buf(size_t size, void *data)
        size_t alignment = sysconf(_SC_PAGESIZE);
 
        assert(data != NULL);
-       assert(!mlx5_is_secondary());
        ret = rte_malloc_socket(__func__, size, alignment,
                                priv->dev->device->numa_node);
        DEBUG("Extern alloc size: %lu, align: %lu: %p", size, alignment, ret);
@@ -177,7 +176,6 @@ static void
 mlx5_free_verbs_buf(void *ptr, void *data __rte_unused)
 {
        assert(data != NULL);
-       assert(!mlx5_is_secondary());
        DEBUG("Extern free request: %p", ptr);
        rte_free(ptr);
 }
@@ -662,6 +660,7 @@ 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];
                uint32_t port = i + 1; /* ports are indexed from one */
                uint32_t test = (1 << i);
                struct ibv_context *ctx = NULL;
@@ -685,14 +684,13 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
                        .rx_vec_en = MLX5_ARG_UNSET,
                };
 
-               mlx5_dev[idx].ports |= test;
+               snprintf(name, sizeof(name), PCI_PRI_FMT,
+                        pci_dev->addr.domain, pci_dev->addr.bus,
+                        pci_dev->addr.devid, pci_dev->addr.function);
 
-               if (mlx5_is_secondary()) {
-                       /* from rte_ethdev.c */
-                       char name[RTE_ETH_NAME_MAX_LEN];
+               mlx5_dev[idx].ports |= test;
 
-                       snprintf(name, sizeof(name), "%s port %u",
-                                ibv_get_device_name(ibv_dev), port);
+               if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
                        eth_dev = rte_eth_dev_attach_secondary(name);
                        if (eth_dev == NULL) {
                                ERROR("can not attach rte ethdev");
@@ -802,7 +800,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
                priv->hw_csum_l2tun = !!(exp_device_attr.exp_device_cap_flags &
                                         IBV_DEVICE_VXLAN_SUPPORT);
 #endif
-               DEBUG("L2 tunnel checksum offloads are %ssupported",
+               DEBUG("Rx L2 tunnel checksum offloads are %ssupported",
                      (priv->hw_csum_l2tun ? "" : "not "));
 
 #ifdef HAVE_IBV_DEVICE_COUNTERS_SET_SUPPORT
@@ -902,14 +900,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;
@@ -920,6 +911,11 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
                eth_dev->device = &pci_dev->device;
                rte_eth_copy_pci_info(eth_dev, pci_dev);
                eth_dev->device->driver = &mlx5_driver.driver;
+               /*
+                * Initialize burst functions to prevent crashes before link-up.
+                */
+               eth_dev->rx_pkt_burst = removed_rx_burst;
+               eth_dev->tx_pkt_burst = removed_tx_burst;
                priv->dev = eth_dev;
                eth_dev->dev_ops = &mlx5_dev_ops;
                /* Register MAC address. */
@@ -939,7 +935,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);
                continue;
 
 port_error: