ethdev: fix representor port ID search by name
[dpdk.git] / drivers / net / mlx5 / linux / mlx5_os.c
index c15a44d..0dcf500 100644 (file)
@@ -786,6 +786,32 @@ mlx5_flow_counter_mode_config(struct rte_eth_dev *dev __rte_unused)
 #endif
 }
 
+/**
+ * DR flow drop action support detect.
+ *
+ * @param dev
+ *   Pointer to rte_eth_dev structure.
+ *
+ */
+static void
+mlx5_flow_drop_action_config(struct rte_eth_dev *dev __rte_unused)
+{
+#ifdef HAVE_MLX5DV_DR
+       struct mlx5_priv *priv = dev->data->dev_private;
+
+       if (!priv->config.dv_flow_en || !priv->sh->dr_drop_action)
+               return;
+       /**
+        * DR supports drop action placeholder when it is supported;
+        * otherwise, use the queue drop action.
+        */
+       if (mlx5_flow_discover_dr_action_support(dev))
+               priv->root_drop_action = priv->drop_queue.hrxq->action;
+       else
+               priv->root_drop_action = priv->sh->dr_drop_action;
+#endif
+}
+
 static void
 mlx5_queue_counter_id_prepare(struct rte_eth_dev *dev)
 {
@@ -1008,8 +1034,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
                err = mlx5_proc_priv_init(eth_dev);
                if (err)
                        return NULL;
-               mp_id.port_id = eth_dev->data->port_id;
-               strlcpy(mp_id.name, MLX5_MP_NAME, RTE_MP_MAX_NAME_LEN);
+               mlx5_mp_id_init(&mp_id, eth_dev->data->port_id);
                /* Receive command fd from primary process */
                err = mlx5_mp_req_verbs_cmd_fd(&mp_id);
                if (err < 0)
@@ -1288,7 +1313,7 @@ err_secondary:
        }
        /* Override some values set by hardware configuration. */
        mlx5_args(config, dpdk_dev->devargs);
-       err = mlx5_dev_check_sibling_config(priv, config);
+       err = mlx5_dev_check_sibling_config(priv, config, dpdk_dev);
        if (err)
                goto error;
        config->hw_csum = !!(sh->device_attr.device_cap_flags_ex &
@@ -1651,6 +1676,19 @@ err_secondary:
        if (priv->representor) {
                eth_dev->data->dev_flags |= RTE_ETH_DEV_REPRESENTOR;
                eth_dev->data->representor_id = priv->representor_id;
+               MLX5_ETH_FOREACH_DEV(port_id, dpdk_dev) {
+                       struct mlx5_priv *opriv =
+                               rte_eth_devices[port_id].data->dev_private;
+                       if (opriv &&
+                           opriv->master &&
+                           opriv->domain_id == priv->domain_id &&
+                           opriv->sh == priv->sh) {
+                               eth_dev->data->backer_port_id = port_id;
+                               break;
+                       }
+               }
+               if (port_id >= RTE_MAX_ETHPORTS)
+                       eth_dev->data->backer_port_id = eth_dev->data->port_id;
        }
        priv->mp_id.port_id = eth_dev->data->port_id;
        strlcpy(priv->mp_id.name, MLX5_MP_NAME, RTE_MP_MAX_NAME_LEN);
@@ -1676,11 +1714,8 @@ err_secondary:
                goto error;
        }
        DRV_LOG(INFO,
-               "port %u MAC address is %02x:%02x:%02x:%02x:%02x:%02x",
-               eth_dev->data->port_id,
-               mac.addr_bytes[0], mac.addr_bytes[1],
-               mac.addr_bytes[2], mac.addr_bytes[3],
-               mac.addr_bytes[4], mac.addr_bytes[5]);
+               "port %u MAC address is " RTE_ETHER_ADDR_PRT_FMT,
+               eth_dev->data->port_id, RTE_ETHER_ADDR_BYTES(&mac));
 #ifdef RTE_LIBRTE_MLX5_DEBUG
        {
                char ifname[MLX5_NAMESIZE];
@@ -1875,6 +1910,7 @@ err_secondary:
        }
        rte_spinlock_init(&priv->shared_act_sl);
        mlx5_flow_counter_mode_config(eth_dev);
+       mlx5_flow_drop_action_config(eth_dev);
        if (priv->config.dv_flow_en)
                eth_dev->data->dev_flags |= RTE_ETH_DEV_FLOW_OPS_THREAD_SAFE;
        return eth_dev;
@@ -2109,12 +2145,14 @@ mlx5_os_config_default(struct mlx5_dev_config *config)
        config->txqs_inline = MLX5_ARG_UNSET;
        config->vf_nl_en = 1;
        config->mr_ext_memseg_en = 1;
+       config->mr_mempool_reg_en = 1;
        config->mprq.max_memcpy_len = MLX5_MPRQ_MEMCPY_DEFAULT_LEN;
        config->mprq.min_rxqs_num = MLX5_MPRQ_MIN_RXQS;
        config->dv_esw_en = 1;
        config->dv_flow_en = 1;
        config->decap_en = 1;
        config->log_hp_size = MLX5_ARG_UNSET;
+       config->allow_duplicate_pattern = 1;
 }
 
 /**
@@ -2537,7 +2575,6 @@ mlx5_os_pci_probe_pf(struct rte_pci_device *pci_dev,
                /* Default configuration. */
                mlx5_os_config_default(&dev_config);
                dev_config.vf = dev_config_vf;
-               dev_config.allow_duplicate_pattern = 1;
                list[i].numa_node = pci_dev->device.numa_node;
                list[i].eth_dev = mlx5_dev_spawn(&pci_dev->device,
                                                 &list[i],
@@ -2673,9 +2710,20 @@ mlx5_os_pci_probe(struct rte_pci_device *pci_dev)
 
        if (eth_da.nb_ports > 0) {
                /* Iterate all port if devargs pf is range: "pf[0-1]vf[...]". */
-               for (p = 0; p < eth_da.nb_ports; p++)
+               for (p = 0; p < eth_da.nb_ports; p++) {
                        ret = mlx5_os_pci_probe_pf(pci_dev, &eth_da,
                                                   eth_da.ports[p]);
+                       if (ret)
+                               break;
+               }
+               if (ret) {
+                       DRV_LOG(ERR, "Probe of PCI device " PCI_PRI_FMT " "
+                               "aborted due to proding failure of PF %u",
+                               pci_dev->addr.domain, pci_dev->addr.bus,
+                               pci_dev->addr.devid, pci_dev->addr.function,
+                               eth_da.ports[p]);
+                       mlx5_net_remove(&pci_dev->device);
+               }
        } else {
                ret = mlx5_os_pci_probe_pf(pci_dev, &eth_da, 0);
        }