From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f44.google.com (mail-wm0-f44.google.com [74.125.82.44]) by dpdk.org (Postfix) with ESMTP id B32C79ACE for ; Wed, 8 Jun 2016 11:44:42 +0200 (CEST) Received: by mail-wm0-f44.google.com with SMTP id v199so55276484wmv.0 for ; Wed, 08 Jun 2016 02:44:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=EFD9X/vImuizPS+Q2e/nQHx5PqNZknB0y6+gJTQTwoA=; b=QbG/Q1oAxEyN7PciPwTN/CupM1iHDwO/7qLTaAQHoWDMc23Wgj6pgRzwKq84H2+ln5 JOqyCkjgcPkfmpNvu93PSuSNfcezWnM0WLbc4DNgHi8cIiyQHlR+Y7dPJL0OXrmdExQX n5DRhrOiUMNt/osf/Ik470pj/IBABq4o4f4YHA6FG9JXipcUDWEWBkjXNDLHgp+L20oq ys+2Ui+8ON3rDd7Y6Kq6i+4p4P84iJSwb/OXAzqQ7agGfjBfUuqHEEqJFrpVg9+okGu4 Gcpr338uMNXFZon5qYrdAUsYljliQIPXMy/iIe2R9vKkHr7y8rQ0Dt+eeVYjMmg9OAxC ju1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=EFD9X/vImuizPS+Q2e/nQHx5PqNZknB0y6+gJTQTwoA=; b=gloEnj+EtrV/pyVFNdndDoZ9yJFNXkiP7SxqSU4rY/7tSF6i7GRKR8JoYXVYJljfWF JBNxTafHPo2A3zDFD8/kmFGni5ZnCloXFPB7Xp+UR4tciqxjcHE0RUGx2zPNmsmub1l7 /fURmzShtLDFjMUO3/v8CTVLUvUiJdS09y4uN1WPFGWlqXhNA5zoPx0j9aGC7mJj0ehe +X5h3SOJtCuC+mqrlteB5tn3iWNPTd4G1LtlVrLnue5fgnk/JWuPXjK9twH4yf6OhTDS aYrQrSxXPnFLM7HrMMwgoXyRatmjVpuwiwML+IODelVlXXwA7WYJjT2AIr9gxHn4D7hp lIVg== X-Gm-Message-State: ALyK8tKiB7HuhfDxPWVegGCdxU4zIWo0Uye/H7VXlV87P5quahoEdO7Br99TijVrhXV0DXEd X-Received: by 10.28.8.17 with SMTP id 17mr7317150wmi.67.1465379082314; Wed, 08 Jun 2016 02:44:42 -0700 (PDT) Received: from ping.vm.6wind.com (guy78-3-82-239-227-177.fbx.proxad.net. [82.239.227.177]) by smtp.gmail.com with ESMTPSA id xw8sm479085wjb.30.2016.06.08.02.44.41 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 08 Jun 2016 02:44:41 -0700 (PDT) From: Nelio Laranjeiro To: dev@dpdk.org Cc: Adrien Mazarguil Date: Wed, 8 Jun 2016 11:43:30 +0200 Message-Id: <1465379011-24646-7-git-send-email-nelio.laranjeiro@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1465379011-24646-1-git-send-email-nelio.laranjeiro@6wind.com> References: <1465379011-24646-1-git-send-email-nelio.laranjeiro@6wind.com> Subject: [dpdk-dev] [PATCH 6/7] mlx5: enhance SR-IOV detection X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Jun 2016 09:44:42 -0000 SR-IOV mode is currently set when dealing with VF devices. PF devices must be taken into account as well if they have active VFs. Signed-off-by: Nelio Laranjeiro Signed-off-by: Adrien Mazarguil --- drivers/net/mlx5/mlx5.c | 14 ++++++++------ drivers/net/mlx5/mlx5.h | 3 ++- drivers/net/mlx5/mlx5_ethdev.c | 32 ++++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_rxtx.c | 4 ++-- 4 files changed, 44 insertions(+), 9 deletions(-) diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 041cfc3..67a541c 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -260,7 +260,7 @@ mlx5_pci_devinit(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) int err = 0; struct ibv_context *attr_ctx = NULL; struct ibv_device_attr device_attr; - unsigned int vf; + unsigned int sriov; unsigned int mps; int idx; int i; @@ -303,17 +303,17 @@ mlx5_pci_devinit(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) (pci_dev->addr.devid != pci_addr.devid) || (pci_dev->addr.function != pci_addr.function)) continue; - vf = ((pci_dev->id.device_id == + sriov = ((pci_dev->id.device_id == PCI_DEVICE_ID_MELLANOX_CONNECTX4VF) || (pci_dev->id.device_id == PCI_DEVICE_ID_MELLANOX_CONNECTX4LXVF)); /* Multi-packet send is only supported by ConnectX-4 Lx PF. */ mps = (pci_dev->id.device_id == PCI_DEVICE_ID_MELLANOX_CONNECTX4LX); - INFO("PCI information matches, using device \"%s\" (VF: %s," - " MPS: %s)", + INFO("PCI information matches, using device \"%s\"" + " (SR-IOV: %s, MPS: %s)", list[i]->name, - vf ? "true" : "false", + sriov ? "true" : "false", mps ? "true" : "false"); attr_ctx = ibv_open_device(list[i]); err = errno; @@ -351,6 +351,7 @@ mlx5_pci_devinit(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) struct ibv_exp_device_attr exp_device_attr; #endif /* HAVE_EXP_QUERY_DEVICE */ struct ether_addr mac; + uint16_t num_vfs = 0; #ifdef HAVE_EXP_QUERY_DEVICE exp_device_attr.comp_mask = @@ -464,7 +465,8 @@ mlx5_pci_devinit(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) priv->ind_table_max_size = RSS_INDIRECTION_TABLE_SIZE; #endif /* HAVE_EXP_QUERY_DEVICE */ - priv->vf = vf; + priv_get_num_vfs(priv, &num_vfs); + priv->sriov = (num_vfs || sriov); priv->mps = mps; /* Allocate and register default RSS hash keys. */ priv->rss_conf = rte_calloc(__func__, hash_rxq_init_n, diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 2487662..dccc18d 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -105,7 +105,7 @@ struct priv { unsigned int hw_vlan_strip:1; /* VLAN stripping is supported. */ unsigned int hw_fcs_strip:1; /* FCS stripping is supported. */ unsigned int hw_padding:1; /* End alignment padding is supported. */ - unsigned int vf:1; /* This is a VF device. */ + unsigned int sriov:1; /* This is a VF or PF with VF devices. */ unsigned int mps:1; /* Whether multi-packet send is supported. */ unsigned int pending_alarm:1; /* An alarm is pending. */ /* RX/TX queues. */ @@ -173,6 +173,7 @@ struct priv *mlx5_get_priv(struct rte_eth_dev *dev); int mlx5_is_secondary(void); int priv_get_ifname(const struct priv *, char (*)[IF_NAMESIZE]); int priv_ifreq(const struct priv *, int req, struct ifreq *); +int priv_get_num_vfs(struct priv *, uint16_t *); int priv_get_mtu(struct priv *, uint16_t *); int priv_set_flags(struct priv *, unsigned int, unsigned int); int mlx5_dev_configure(struct rte_eth_dev *); diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c index ecbb49b..d2a63b8 100644 --- a/drivers/net/mlx5/mlx5_ethdev.c +++ b/drivers/net/mlx5/mlx5_ethdev.c @@ -363,6 +363,38 @@ priv_ifreq(const struct priv *priv, int req, struct ifreq *ifr) } /** + * Return the number of active VFs for the current device. + * + * @param[in] priv + * Pointer to private structure. + * @param[out] num_vfs + * Number of active VFs. + * + * @return + * 0 on success, -1 on failure and errno is set. + */ +int +priv_get_num_vfs(struct priv *priv, uint16_t *num_vfs) +{ + /* The sysfs entry name depends on the operating system. */ + const char **name = (const char *[]){ + "device/sriov_numvfs", + "device/mlx5_num_vfs", + NULL, + }; + int ret; + + do { + unsigned long ulong_num_vfs; + + ret = priv_get_sysfs_ulong(priv, *name, &ulong_num_vfs); + if (!ret) + *num_vfs = ulong_num_vfs; + } while (*(++name) && ret); + return ret; +} + +/** * Get device MTU. * * @param priv diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c index 3881c30..9cb1dfa 100644 --- a/drivers/net/mlx5/mlx5_rxtx.c +++ b/drivers/net/mlx5/mlx5_rxtx.c @@ -507,7 +507,7 @@ tx_burst_sg(struct txq *txq, unsigned int segs, struct txq_elt *elt, } /* Update SGE. */ sge->addr = rte_pktmbuf_mtod(buf, uintptr_t); - if (txq->priv->vf) + if (txq->priv->sriov) rte_prefetch0((volatile void *) (uintptr_t)sge->addr); sge->length = DATA_LEN(buf); @@ -662,7 +662,7 @@ mlx5_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n) length = DATA_LEN(buf); /* Update element. */ elt->buf = buf; - if (txq->priv->vf) + if (txq->priv->sriov) rte_prefetch0((volatile void *) (uintptr_t)addr); /* Prefetch next buffer data. */ -- 2.1.4