[dpdk-dev,v6,1/9] net/i40e: add API to convert VF MAC to VF id

Message ID 1507206350-215367-2-git-send-email-david.hunt@intel.com (mailing list archive)
State Superseded, archived
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Hunt, David Oct. 5, 2017, 12:25 p.m. UTC
  From: "Sexton, Rory" <rory.sexton@intel.com>

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 <nemanja.marjanovic@intel.com>
Signed-off-by: Rory Sexton <rory.sexton@intel.com>
Signed-off-by: David Hunt <david.hunt@intel.com>
---
 drivers/net/i40e/rte_pmd_i40e.c           | 30 ++++++++++++++++++++++++++++++
 drivers/net/i40e/rte_pmd_i40e.h           | 15 +++++++++++++++
 drivers/net/i40e/rte_pmd_i40e_version.map |  7 +++++++
 3 files changed, 52 insertions(+)
  

Comments

Ananyev, Konstantin Oct. 5, 2017, 12:45 p.m. UTC | #1
Hi Dave,

> -----Original Message-----
> From: Hunt, David
> Sent: Thursday, October 5, 2017 1:26 PM
> To: dev@dpdk.org
> Cc: Ananyev, Konstantin <konstantin.ananyev@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>; santosh.shukla@caviumnetworks.com;
> Sexton, Rory <rory.sexton@intel.com>; Marjanovic, Nemanja <nemanja.marjanovic@intel.com>; Hunt, David <david.hunt@intel.com>
> Subject: [PATCH v6 1/9] net/i40e: add API to convert VF MAC to VF id
> 
> From: "Sexton, Rory" <rory.sexton@intel.com>
> 
> 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 <nemanja.marjanovic@intel.com>
> Signed-off-by: Rory Sexton <rory.sexton@intel.com>
> Signed-off-by: David Hunt <david.hunt@intel.com>
> ---
>  drivers/net/i40e/rte_pmd_i40e.c           | 30 ++++++++++++++++++++++++++++++
>  drivers/net/i40e/rte_pmd_i40e.h           | 15 +++++++++++++++
>  drivers/net/i40e/rte_pmd_i40e_version.map |  7 +++++++
>  3 files changed, 52 insertions(+)
> 
> diff --git a/drivers/net/i40e/rte_pmd_i40e.c b/drivers/net/i40e/rte_pmd_i40e.c
> index f12b7f4..541d575 100644
> --- a/drivers/net/i40e/rte_pmd_i40e.c
> +++ b/drivers/net/i40e/rte_pmd_i40e.c
> @@ -2115,3 +2115,33 @@ int rte_pmd_i40e_ptype_mapping_replace(uint8_t port,
> 
>  	return 0;
>  }
> +
> +int64_t
> +rte_pmd_i40e_query_vfid_by_mac(uint8_t port, const struct ether_addr *vf_mac)

I don't think you need int64_t as a return value here.
Just 'int' seems good enough.
Anyway vf_id is just an 'int'.
Konstantin

> +{
> +	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 356fa89..2952ab0 100644
> --- a/drivers/net/i40e/rte_pmd_i40e.h
> +++ b/drivers/net/i40e/rte_pmd_i40e.h
> @@ -637,4 +637,19 @@ int rte_pmd_i40e_ptype_mapping_replace(uint8_t port,
>  				       uint8_t mask,
>  				       uint32_t pkt_type);
> 
> +/**
> + * 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.
> + */
> +int64_t rte_pmd_i40e_query_vfid_by_mac(uint8_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 20cc980..d8b74bd 100644
> --- a/drivers/net/i40e/rte_pmd_i40e_version.map
> +++ b/drivers/net/i40e/rte_pmd_i40e_version.map
> @@ -45,3 +45,10 @@ DPDK_17.08 {
>  	rte_pmd_i40e_get_ddp_info;
> 
>  } DPDK_17.05;
> +
> +DPDK_17.11 {
> +	global:
> +
> +	rte_pmd_i40e_query_vfid_by_mac;
> +
> +} DPDK_17.08;
> --
> 2.7.4
  
Hunt, David Oct. 5, 2017, 12:51 p.m. UTC | #2
Hi Konstantin,


On 5/10/2017 1:45 PM, Ananyev, Konstantin wrote:
> Hi Dave,
>
>> -----Original Message-----
>> From: Hunt, David
>> Sent: Thursday, October 5, 2017 1:26 PM
>> To: dev@dpdk.org
>> Cc: Ananyev, Konstantin <konstantin.ananyev@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>; santosh.shukla@caviumnetworks.com;
>> Sexton, Rory <rory.sexton@intel.com>; Marjanovic, Nemanja <nemanja.marjanovic@intel.com>; Hunt, David <david.hunt@intel.com>
>> Subject: [PATCH v6 1/9] net/i40e: add API to convert VF MAC to VF id
>>
>> From: "Sexton, Rory" <rory.sexton@intel.com>
>>
>> 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 <nemanja.marjanovic@intel.com>
>> Signed-off-by: Rory Sexton <rory.sexton@intel.com>
>> Signed-off-by: David Hunt <david.hunt@intel.com>
>> ---
>>   drivers/net/i40e/rte_pmd_i40e.c           | 30 ++++++++++++++++++++++++++++++
>>   drivers/net/i40e/rte_pmd_i40e.h           | 15 +++++++++++++++
>>   drivers/net/i40e/rte_pmd_i40e_version.map |  7 +++++++
>>   3 files changed, 52 insertions(+)
>>
>> diff --git a/drivers/net/i40e/rte_pmd_i40e.c b/drivers/net/i40e/rte_pmd_i40e.c
>> index f12b7f4..541d575 100644
>> --- a/drivers/net/i40e/rte_pmd_i40e.c
>> +++ b/drivers/net/i40e/rte_pmd_i40e.c
>> @@ -2115,3 +2115,33 @@ int rte_pmd_i40e_ptype_mapping_replace(uint8_t port,
>>
>>   	return 0;
>>   }
>> +
>> +int64_t
>> +rte_pmd_i40e_query_vfid_by_mac(uint8_t port, const struct ether_addr *vf_mac)
> I don't think you need int64_t as a return value here.
> Just 'int' seems good enough.
> Anyway vf_id is just an 'int'.
> Konstantin

OK. I'll push a v7 in the next couple of hours.

Thanks,
Dave.

---snip--
  

Patch

diff --git a/drivers/net/i40e/rte_pmd_i40e.c b/drivers/net/i40e/rte_pmd_i40e.c
index f12b7f4..541d575 100644
--- a/drivers/net/i40e/rte_pmd_i40e.c
+++ b/drivers/net/i40e/rte_pmd_i40e.c
@@ -2115,3 +2115,33 @@  int rte_pmd_i40e_ptype_mapping_replace(uint8_t port,
 
 	return 0;
 }
+
+int64_t
+rte_pmd_i40e_query_vfid_by_mac(uint8_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 356fa89..2952ab0 100644
--- a/drivers/net/i40e/rte_pmd_i40e.h
+++ b/drivers/net/i40e/rte_pmd_i40e.h
@@ -637,4 +637,19 @@  int rte_pmd_i40e_ptype_mapping_replace(uint8_t port,
 				       uint8_t mask,
 				       uint32_t pkt_type);
 
+/**
+ * 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.
+ */
+int64_t rte_pmd_i40e_query_vfid_by_mac(uint8_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 20cc980..d8b74bd 100644
--- a/drivers/net/i40e/rte_pmd_i40e_version.map
+++ b/drivers/net/i40e/rte_pmd_i40e_version.map
@@ -45,3 +45,10 @@  DPDK_17.08 {
 	rte_pmd_i40e_get_ddp_info;
 
 } DPDK_17.05;
+
+DPDK_17.11 {
+	global:
+
+	rte_pmd_i40e_query_vfid_by_mac;
+
+} DPDK_17.08;