net/mlx5: add operations for secondary process
authorXueming Li <xuemingl@mellanox.com>
Fri, 6 Oct 2017 15:45:51 +0000 (23:45 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Thu, 12 Oct 2017 00:36:57 +0000 (01:36 +0100)
Add operations that are safe for secondary processes:
* (x)stats
* device info get
* rx/tx descriptor status

Signed-off-by: Xueming Li <xuemingl@mellanox.com>
Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
doc/guides/nics/features/mlx5.ini
doc/guides/nics/mlx5.rst
drivers/net/mlx5/mlx5.c
drivers/net/mlx5/mlx5.h
drivers/net/mlx5/mlx5_ethdev.c

index 4a2c3a6..c363639 100644 (file)
@@ -35,6 +35,7 @@ Tx descriptor status = Y
 Basic stats          = Y
 Extended stats       = Y
 Stats per queue      = Y
+Multiprocess aware   = Y
 Other kdrv           = Y
 ARMv8                = Y
 Power8               = Y
index be0e91c..d24941a 100644 (file)
@@ -92,7 +92,7 @@ Features
 - Flow director (RTE_FDIR_MODE_PERFECT, RTE_FDIR_MODE_PERFECT_MAC_VLAN and
   RTE_ETH_FDIR_REJECT).
 - Flow API.
-- Secondary process TX is supported.
+- Multiple process.
 - KVM and VMware ESX SR-IOV modes are supported.
 - RSS hash result is supported.
 - Hardware TSO.
@@ -106,7 +106,7 @@ Limitations
 - Inner RSS for VXLAN frames is not supported yet.
 - Port statistics through software counters only.
 - Hardware checksum RX offloads for VXLAN inner header are not supported yet.
-- Secondary process RX is not supported.
+- Forked secondary process not supported.
 - Flow pattern without any specific vlan will match for vlan packets as well:
 
   When VLAN spec is not specified in the pattern, the matching rule will be created with VLAN as a wild card.
index 6541ee3..92adbcd 100644 (file)
@@ -303,6 +303,18 @@ static const struct eth_dev_ops mlx5_dev_ops = {
        .rx_queue_intr_disable = mlx5_rx_intr_disable,
 };
 
+
+static const struct eth_dev_ops mlx5_dev_sec_ops = {
+       .stats_get = mlx5_stats_get,
+       .stats_reset = mlx5_stats_reset,
+       .xstats_get = mlx5_xstats_get,
+       .xstats_reset = mlx5_xstats_reset,
+       .xstats_get_names = mlx5_xstats_get_names,
+       .dev_infos_get = mlx5_dev_infos_get,
+       .rx_descriptor_status = mlx5_rx_descriptor_status,
+       .tx_descriptor_status = mlx5_tx_descriptor_status,
+};
+
 static struct {
        struct rte_pci_addr pci_addr; /* associated PCI address */
        uint32_t ports; /* physical ports bitfield. */
@@ -640,7 +652,7 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
                                goto error;
                        }
                        eth_dev->device = &pci_dev->device;
-                       eth_dev->dev_ops = NULL;
+                       eth_dev->dev_ops = &mlx5_dev_sec_ops;
                        priv = eth_dev->data->dev_private;
                        /* Receive command fd from primary process */
                        err = priv_socket_connect(priv);
@@ -707,6 +719,8 @@ mlx5_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
                }
 
                priv->ctx = ctx;
+               strncpy(priv->ibdev_path, priv->ctx->device->ibdev_path,
+                       sizeof(priv->ibdev_path));
                priv->device_attr = device_attr;
                priv->port = port;
                priv->pd = pd;
index 1ce02e8..928aeb6 100644 (file)
@@ -91,6 +91,7 @@ struct priv {
        struct ibv_context *ctx; /* Verbs context. */
        struct ibv_device_attr_ex device_attr; /* Device properties. */
        struct ibv_pd *pd; /* Protection Domain. */
+       char ibdev_path[IBV_SYSFS_PATH_MAX]; /* IB device path for secondary */
        /*
         * MAC addresses array and configuration bit-field.
         * An extra entry that cannot be modified by the DPDK is reserved
index adcde9c..318bc9d 100644 (file)
@@ -165,7 +165,7 @@ priv_get_ifname(const struct priv *priv, char (*ifname)[IF_NAMESIZE])
        char match[IF_NAMESIZE] = "";
 
        {
-               MKSTR(path, "%s/device/net", priv->ctx->device->ibdev_path);
+               MKSTR(path, "%s/device/net", priv->ibdev_path);
 
                dir = opendir(path);
                if (dir == NULL)
@@ -183,7 +183,7 @@ priv_get_ifname(const struct priv *priv, char (*ifname)[IF_NAMESIZE])
                        continue;
 
                MKSTR(path, "%s/device/net/%s/%s",
-                     priv->ctx->device->ibdev_path, name,
+                     priv->ibdev_path, name,
                      (dev_type ? "dev_id" : "dev_port"));
 
                file = fopen(path, "rb");
@@ -271,11 +271,11 @@ priv_sysfs_read(const struct priv *priv, const char *entry,
 
        if (priv_is_ib_cntr(entry)) {
                MKSTR(path, "%s/ports/1/hw_counters/%s",
-                     priv->ctx->device->ibdev_path, entry);
+                     priv->ibdev_path, entry);
                file = fopen(path, "rb");
        } else {
                MKSTR(path, "%s/device/net/%s/%s",
-                     priv->ctx->device->ibdev_path, ifname, entry);
+                     priv->ibdev_path, ifname, entry);
                file = fopen(path, "rb");
        }
        if (file == NULL)
@@ -318,8 +318,7 @@ priv_sysfs_write(const struct priv *priv, const char *entry,
        if (priv_get_ifname(priv, &ifname))
                return -1;
 
-       MKSTR(path, "%s/device/net/%s/%s", priv->ctx->device->ibdev_path,
-             ifname, entry);
+       MKSTR(path, "%s/device/net/%s/%s", priv->ibdev_path, ifname, entry);
 
        file = fopen(path, "wb");
        if (file == NULL)