From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 2A4EF37B4 for ; Mon, 25 Sep 2017 14:38:02 +0200 (CEST) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Sep 2017 05:38:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,436,1500966000"; d="scan'208";a="153019121" Received: from silpixa00397898.ir.intel.com (HELO silpixa00397898.ger.corp.intel.com) ([10.237.223.116]) by orsmga005.jf.intel.com with ESMTP; 25 Sep 2017 05:38:00 -0700 From: David Hunt To: dev@dpdk.org Cc: konstantin.ananyev@intel.com, jingjing.wu@intel.com, "Sexton, Rory" , Nemanja Marjanovic , David Hunt Date: Mon, 25 Sep 2017 13:27:02 +0100 Message-Id: <1506342429-199695-2-git-send-email-david.hunt@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1506342429-199695-1-git-send-email-david.hunt@intel.com> References: <1503676941-80981-1-git-send-email-david.hunt@intel.com> <1506342429-199695-1-git-send-email-david.hunt@intel.com> Subject: [dpdk-dev] [PATCH v2 1/8] net/i40e: add API to convert VF MAC to VSI index 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: , X-List-Received-Date: Mon, 25 Sep 2017 12:38:02 -0000 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 --- drivers/net/i40e/rte_pmd_i40e.c | 35 +++++++++++++++++++++++++++++++++++ drivers/net/i40e/rte_pmd_i40e.h | 13 +++++++++++++ 2 files changed, 48 insertions(+) diff --git a/drivers/net/i40e/rte_pmd_i40e.c b/drivers/net/i40e/rte_pmd_i40e.c index f12b7f4..85b540f 100644 --- a/drivers/net/i40e/rte_pmd_i40e.c +++ b/drivers/net/i40e/rte_pmd_i40e.c @@ -2115,3 +2115,38 @@ int rte_pmd_i40e_ptype_mapping_replace(uint8_t port, return 0; } + +uint64_t +rte_pmd_i40e_query_vfid_by_mac(uint8_t port, uint64_t vf_mac) { + struct rte_eth_dev *dev; + struct ether_addr *vf_mac_addr = (struct ether_addr *)&vf_mac; + struct ether_addr *mac; + struct i40e_pf *pf; + int i, x; + 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 (x = 0; x < vf_num; x++) { + int mac_addr_matches = 1; + vf = &pf->vfs[x]; + mac = &vf->mac_addr; + + for (i = 0; i < ETHER_ADDR_LEN; i++) { + if (mac->addr_bytes[i] != vf_mac_addr->addr_bytes[i]) + mac_addr_matches = 0; + } + if (mac_addr_matches) + return x; + } + + return -EINVAL; +} diff --git a/drivers/net/i40e/rte_pmd_i40e.h b/drivers/net/i40e/rte_pmd_i40e.h index 356fa89..6984105 100644 --- a/drivers/net/i40e/rte_pmd_i40e.h +++ b/drivers/net/i40e/rte_pmd_i40e.h @@ -637,4 +637,17 @@ int rte_pmd_i40e_ptype_mapping_replace(uint8_t port, uint8_t mask, uint32_t pkt_type); +/** + * Translate a VF mac address into VF index in array of pf->vfs + * + * @param port + * pointer to port identifier of the device + * @param vf_mac + * the mac address of the vf to determine index of + * @return + * -(-22 EINVAL) the vf mac does not exist on this port + * -(!-22) the index of vfid in pf->vfs + */ +uint64_t rte_pmd_i40e_query_vfid_by_mac(uint8_t port, uint64_t vf_mac); + #endif /* _PMD_I40E_H_ */ -- 2.7.4