From: Rory Sexton Date: Wed, 11 Oct 2017 16:18:47 +0000 (+0100) Subject: net/i40e: support converting VF MAC to VF id X-Git-Tag: spdx-start~1608 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=a399ed9ae4df3a6e76d1bd9b7960520d125e66ef;p=dpdk.git net/i40e: support converting VF MAC to VF id 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 --- diff --git a/drivers/net/i40e/rte_pmd_i40e.c b/drivers/net/i40e/rte_pmd_i40e.c index 0988023f9c..103e16145b 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 8fa5869f47..91f647e558 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 9292454ac3..3f5871c485 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;