From patchwork Wed Oct 11 16:18:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hunt, David" X-Patchwork-Id: 30155 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A9A371B206; Wed, 11 Oct 2017 18:19:03 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id C21351B197 for ; Wed, 11 Oct 2017 18:19:01 +0200 (CEST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Oct 2017 09:19:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.43,362,1503385200"; d="scan'208";a="322102471" Received: from silpixa00397898.ir.intel.com ([10.237.223.116]) by fmsmga004.fm.intel.com with ESMTP; 11 Oct 2017 09:18:59 -0700 From: David Hunt To: dev@dpdk.org Cc: konstantin.ananyev@intel.com, jingjing.wu@intel.com, santosh.shukla@caviumnetworks.com, "Sexton, Rory" , Nemanja Marjanovic , David Hunt Date: Wed, 11 Oct 2017 17:18:47 +0100 Message-Id: <1507738735-24879-2-git-send-email-david.hunt@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507738735-24879-1-git-send-email-david.hunt@intel.com> References: <1505299459-24135-2-git-send-email-david.hunt@intel.com> <1507738735-24879-1-git-send-email-david.hunt@intel.com> Subject: [dpdk-dev] [PATCH v9 1/9] net/i40e: add API to convert VF MAC to VF id X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: "Sexton, Rory" Need a way to convert a vf id to a pf id on the host so as to query the pf for relevant statistics which are used for the frequency changes in the vm_power_manager app. Used when profiles are passed down from the guest to the host, allowing the host to map the vfs to pfs. Signed-off-by: Nemanja Marjanovic Signed-off-by: Rory Sexton Signed-off-by: David Hunt Reviewed-by: Santosh Shukla Acked-by: Konstantin Ananyev --- drivers/net/i40e/rte_pmd_i40e.c | 30 ++++++++++++++++++++++++++++++ drivers/net/i40e/rte_pmd_i40e.h | 15 +++++++++++++++ drivers/net/i40e/rte_pmd_i40e_version.map | 1 + 3 files changed, 46 insertions(+) diff --git a/drivers/net/i40e/rte_pmd_i40e.c b/drivers/net/i40e/rte_pmd_i40e.c index 0988023..103e161 100644 --- a/drivers/net/i40e/rte_pmd_i40e.c +++ b/drivers/net/i40e/rte_pmd_i40e.c @@ -2430,3 +2430,33 @@ rte_pmd_i40e_flow_type_mapping_update( return 0; } + +int +rte_pmd_i40e_query_vfid_by_mac(uint16_t port, const struct ether_addr *vf_mac) +{ + struct rte_eth_dev *dev; + struct ether_addr *mac; + struct i40e_pf *pf; + int vf_id; + struct i40e_pf_vf *vf; + uint16_t vf_num; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV); + dev = &rte_eth_devices[port]; + + if (!is_i40e_supported(dev)) + return -ENOTSUP; + + pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private); + vf_num = pf->vf_num; + + for (vf_id = 0; vf_id < vf_num; vf_id++) { + vf = &pf->vfs[vf_id]; + mac = &vf->mac_addr; + + if (is_same_ether_addr(mac, vf_mac)) + return vf_id; + } + + return -EINVAL; +} diff --git a/drivers/net/i40e/rte_pmd_i40e.h b/drivers/net/i40e/rte_pmd_i40e.h index 8fa5869..91f647e 100644 --- a/drivers/net/i40e/rte_pmd_i40e.h +++ b/drivers/net/i40e/rte_pmd_i40e.h @@ -737,4 +737,19 @@ int rte_pmd_i40e_flow_type_mapping_get( */ int rte_pmd_i40e_flow_type_mapping_reset(uint8_t port); +/** + * On the PF, find VF index based on VF MAC address + * + * @param port + * pointer to port identifier of the device + * @param vf_mac + * the mac address of the vf to determine index of + * @return + * The index of vfid If successful. + * -EINVAL: vf mac address does not exist for this port + * -ENOTSUP: i40e not supported for this port. + */ +int rte_pmd_i40e_query_vfid_by_mac(uint16_t port, + const struct ether_addr *vf_mac); + #endif /* _PMD_I40E_H_ */ diff --git a/drivers/net/i40e/rte_pmd_i40e_version.map b/drivers/net/i40e/rte_pmd_i40e_version.map index 9292454..3f5871c 100644 --- a/drivers/net/i40e/rte_pmd_i40e_version.map +++ b/drivers/net/i40e/rte_pmd_i40e_version.map @@ -53,5 +53,6 @@ DPDK_17.11 { rte_pmd_i40e_flow_type_mapping_update; rte_pmd_i40e_flow_type_mapping_get; rte_pmd_i40e_flow_type_mapping_reset; + rte_pmd_i40e_query_vfid_by_mac; } DPDK_17.08;