[dpdk-dev] net/i40e: enable statistic reset for VF

Message ID 1487874421-11934-1-git-send-email-qi.z.zhang@intel.com (mailing list archive)
State Rejected, archived
Delegated to: Ferruh Yigit
Headers

Checks

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

Commit Message

Qi Zhang Feb. 23, 2017, 6:27 p.m. UTC
  The patch implements the dev_ops "stats_reset" for VF.

Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
---
 drivers/net/i40e/i40e_ethdev_vf.c | 34 ++++++++++++++++++++++++++++++++++
 drivers/net/i40e/i40e_pf.c        | 25 +++++++++++++++++++++++++
 drivers/net/i40e/i40e_pf.h        |  1 +
 3 files changed, 60 insertions(+)
  

Comments

Thomas Monjalon March 16, 2017, 4:03 p.m. UTC | #1
2017-02-23 13:27, Qi Zhang:
>  static void
> +i40evf_dev_stats_reset(struct rte_eth_dev *dev)
> +{
> +	struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
> +	/* only DPDK PF support this */
> +	if (vf->version_major == I40E_DPDK_VERSION_MAJOR) {
> +		if (i40evf_reset_statistics(dev))
> +			PMD_DRV_LOG(ERR, "Reset statistics failed");
> +	}
> +}

One more SR-IOV feature not supported with a Linux PF.
The basic stats feature must be marked as partially supported in
	doc/guides/nics/features/i40e_vf.ini
See also this email:
	http://dpdk.org/ml/archives/dev/2017-March/060063.html

I wonder whether we should allow such divergence between PF
implementations. Intel committed to avoid such fragmentation
and keep the SR-IOV messaging standard but it does not happen.
It is said that we must allow fast innovation in DPDK space.
I agree but we should also target a good usability of the VF drivers,
allowing to replace the PF implementations as needed.

Here is my suggestion: let's accept a VF feature only if the PF support
is submitted to both dpdk.org and kernel.org mailing lists.
I ask to add this topic to the next techboard meeting.
  
Qi Zhang March 17, 2017, 2:06 a.m. UTC | #2
Hi Thomas:
	

> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> Sent: Friday, March 17, 2017 12:04 AM
> To: Zhang, Qi Z <qi.z.zhang@intel.com>; techboard@dpdk.org
> Cc: dev@dpdk.org; Wu, Jingjing <jingjing.wu@intel.com>; Zhang, Helin
> <helin.zhang@intel.com>; Yigit, Ferruh <ferruh.yigit@intel.com>
> Subject: Re: [dpdk-dev] [PATCH] net/i40e: enable statistic reset for VF
> 
> 2017-02-23 13:27, Qi Zhang:
> >  static void
> > +i40evf_dev_stats_reset(struct rte_eth_dev *dev) {
> > +	struct i40e_vf *vf =
> I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
> > +	/* only DPDK PF support this */
> > +	if (vf->version_major == I40E_DPDK_VERSION_MAJOR) {
> > +		if (i40evf_reset_statistics(dev))
> > +			PMD_DRV_LOG(ERR, "Reset statistics failed");
> > +	}
> > +}
> 
> One more SR-IOV feature not supported with a Linux PF.
> The basic stats feature must be marked as partially supported in
> 	doc/guides/nics/features/i40e_vf.ini
> See also this email:
> 	http://dpdk.org/ml/archives/dev/2017-March/060063.html

Thanks for your capture
Actually I already got feedback from my team member and noticed
this is not right way, we should not do more to add divergence between PF.
So please regards this as my inattentive action, and please ignore this patch.
> 
> I wonder whether we should allow such divergence between PF
> implementations. 
No, we should not
>Intel committed to avoid such fragmentation and keep the
> SR-IOV messaging standard but it does not happen.
> It is said that we must allow fast innovation in DPDK space.
> I agree but we should also target a good usability of the VF drivers, allowing
> to replace the PF implementations as needed.
> 
> Here is my suggestion: let's accept a VF feature only if the PF support is
> submitted to both dpdk.org and kernel.org mailing lists.

> I ask to add this topic to the next techboard meeting.

Thanks
Qi
  
Zhang, Helin March 17, 2017, 3:28 a.m. UTC | #3
> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> Sent: Friday, March 17, 2017 12:04 AM
> To: Zhang, Qi Z; techboard@dpdk.org
> Cc: dev@dpdk.org; Wu, Jingjing; Zhang, Helin; Yigit, Ferruh
> Subject: Re: [dpdk-dev] [PATCH] net/i40e: enable statistic reset for VF
> 
> 2017-02-23 13:27, Qi Zhang:
> >  static void
> > +i40evf_dev_stats_reset(struct rte_eth_dev *dev) {
> > +	struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data-
> >dev_private);
> > +	/* only DPDK PF support this */
> > +	if (vf->version_major == I40E_DPDK_VERSION_MAJOR) {
> > +		if (i40evf_reset_statistics(dev))
> > +			PMD_DRV_LOG(ERR, "Reset statistics failed");
> > +	}
> > +}
> 
> One more SR-IOV feature not supported with a Linux PF.
> The basic stats feature must be marked as partially supported in
> 	doc/guides/nics/features/i40e_vf.ini
> See also this email:
> 	http://dpdk.org/ml/archives/dev/2017-March/060063.html
> 
> I wonder whether we should allow such divergence between PF
> implementations. Intel committed to avoid such fragmentation and keep the
> SR-IOV messaging standard but it does not happen.
> It is said that we must allow fast innovation in DPDK space.
> I agree but we should also target a good usability of the VF drivers, allowing to
> replace the PF implementations as needed.

Hi Thomas

I think I need to clarify a little bit here.
I think we will try our best, but I don't think we can commit. As they are on
totally different community, and of cause code repositories.

> 
> Here is my suggestion: let's accept a VF feature only if the PF support is
> submitted to both dpdk.org and kernel.org mailing lists.
> I ask to add this topic to the next techboard meeting.

Sorry, technically I disagree with this suggestion, as I don't understand why!
I was told DPDK is not Linux, and Linux is not DPDK. Why we want to add this
dependency on Linux PF host driver? And why just on PF/VF driver feature only?
I think if we can have any good innovative idea on DPDK first, why not just
have it on DPDK? Then Linux or even other OS/community/Company can learn
from DPDK and develop their own.

Regards,
Helin
  
Thomas Monjalon March 17, 2017, 8:02 a.m. UTC | #4
2017-03-17 03:28, Zhang, Helin:
> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> > 2017-02-23 13:27, Qi Zhang:
> > >  static void
> > > +i40evf_dev_stats_reset(struct rte_eth_dev *dev) {
> > > +	struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data-
> > >dev_private);
> > > +	/* only DPDK PF support this */
> > > +	if (vf->version_major == I40E_DPDK_VERSION_MAJOR) {
> > > +		if (i40evf_reset_statistics(dev))
> > > +			PMD_DRV_LOG(ERR, "Reset statistics failed");
> > > +	}
> > > +}
> > 
> > One more SR-IOV feature not supported with a Linux PF.
> > The basic stats feature must be marked as partially supported in
> > 	doc/guides/nics/features/i40e_vf.ini
> > See also this email:
> > 	http://dpdk.org/ml/archives/dev/2017-March/060063.html
> > 
> > I wonder whether we should allow such divergence between PF
> > implementations. Intel committed to avoid such fragmentation and keep the
> > SR-IOV messaging standard but it does not happen.
> > It is said that we must allow fast innovation in DPDK space.
> > I agree but we should also target a good usability of the VF drivers, allowing to
> > replace the PF implementations as needed.
> 
> Hi Thomas
> 
> I think I need to clarify a little bit here.
> I think we will try our best, but I don't think we can commit. As they are on
> totally different community, and of cause code repositories.
> 
> > 
> > Here is my suggestion: let's accept a VF feature only if the PF support is
> > submitted to both dpdk.org and kernel.org mailing lists.
> > I ask to add this topic to the next techboard meeting.
> 
> Sorry, technically I disagree with this suggestion, as I don't understand why!
> I was told DPDK is not Linux, and Linux is not DPDK. Why we want to add this
> dependency on Linux PF host driver? And why just on PF/VF driver feature only?
> I think if we can have any good innovative idea on DPDK first, why not just
> have it on DPDK? Then Linux or even other OS/community/Company can learn
> from DPDK and develop their own.

It is really a general problem.
Here you are adding a feature in a VF driver. But it does not work with
some PF drivers. We have the same problem when adding a feature which
does not work on BSD or on a CPU architecture.
Generally speaking, we have a usability issue when a feature works only
with a given environment.
And it is worst in the SR-IOV case because a VM can migrate from an
hypervisor (with a given PF) to another (and different) one.
  
Zhang, Helin March 17, 2017, 9:45 a.m. UTC | #5
>-----Original Message-----
>From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com] 
>Sent: Friday, March 17, 2017 4:03 PM
>To: Zhang, Helin <helin.zhang@intel.com>
>Cc: Zhang, Qi Z <qi.z.zhang@intel.com>; techboard@dpdk.org; dev@dpdk.org; Wu, Jingjing <jingjing.wu@intel.com>; Yigit, Ferruh <ferruh.yigit@intel.com>
>Subject: Re: [dpdk-dev] [PATCH] net/i40e: enable statistic reset for VF

>2017-03-17 03:28, Zhang, Helin:
>> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
>> > 2017-02-23 13:27, Qi Zhang:
>> > >  static void
>> > > +i40evf_dev_stats_reset(struct rte_eth_dev *dev) {
>> > > +	struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data-
>> > >dev_private);
>> > > +	/* only DPDK PF support this */
>> > > +	if (vf->version_major == I40E_DPDK_VERSION_MAJOR) {
>> > > +		if (i40evf_reset_statistics(dev))
>> > > +			PMD_DRV_LOG(ERR, "Reset statistics failed");
>> > > +	}
>> > > +}
>> > 
>> > One more SR-IOV feature not supported with a Linux PF.
>> > The basic stats feature must be marked as partially supported in
>> > 	doc/guides/nics/features/i40e_vf.ini
>> > See also this email:
>> > 	http://dpdk.org/ml/archives/dev/2017-March/060063.html
>> > 
>> > I wonder whether we should allow such divergence between PF 
>> > implementations. Intel committed to avoid such fragmentation and 
>> > keep the SR-IOV messaging standard but it does not happen.
>> > It is said that we must allow fast innovation in DPDK space.
>> > I agree but we should also target a good usability of the VF 
>> > drivers, allowing to replace the PF implementations as needed.
>> 
>> Hi Thomas
>> 
>> I think I need to clarify a little bit here.
>> I think we will try our best, but I don't think we can commit. As they 
>> are on totally different community, and of cause code repositories.
>> 
>> > 
>> > Here is my suggestion: let's accept a VF feature only if the PF 
>> > support is submitted to both dpdk.org and kernel.org mailing lists.
>> > I ask to add this topic to the next techboard meeting.
>> 
>> Sorry, technically I disagree with this suggestion, as I don't understand why!
>> I was told DPDK is not Linux, and Linux is not DPDK. Why we want to 
>> add this dependency on Linux PF host driver? And why just on PF/VF driver feature only?
>> I think if we can have any good innovative idea on DPDK first, why not 
>> just have it on DPDK? Then Linux or even other OS/community/Company 
>> can learn from DPDK and develop their own.
>
> It is really a general problem.
> Here you are adding a feature in a VF driver. But it does not work with some PF drivers.We have the same problem when adding a feature which does not work on BSD or on a CPU architecture.
> Generally speaking, we have a usability issue when a feature works only with a given environment.
> And it is worst in the SR-IOV case because a VM can migrate from an hypervisor (with a given PF) to another (and different) one.

Yes, I understood that's the reality and the issue. But I don't think we can address it with your suggestion.
Linux is just one of the OS, as you said, FreeBSD, Windows, VMWare,  ...
I'd suggest to start another discussion on the tech board to solve that problem, but not limit
adding new features. They are different topics and things, based on my understanding.

Thank you very much for your answers and have a nice day!

Regards,
Helin
  
Thomas Monjalon March 17, 2017, 10:15 a.m. UTC | #6
2017-03-17 09:45, Zhang, Helin:
>From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com] 
> >2017-03-17 03:28, Zhang, Helin:
> >> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> >> > 2017-02-23 13:27, Qi Zhang:
> >> > >  static void
> >> > > +i40evf_dev_stats_reset(struct rte_eth_dev *dev) {
> >> > > +	struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data-
> >> > >dev_private);
> >> > > +	/* only DPDK PF support this */
> >> > > +	if (vf->version_major == I40E_DPDK_VERSION_MAJOR) {
> >> > > +		if (i40evf_reset_statistics(dev))
> >> > > +			PMD_DRV_LOG(ERR, "Reset statistics failed");
> >> > > +	}
> >> > > +}
> >> > 
> >> > One more SR-IOV feature not supported with a Linux PF.
> >> > The basic stats feature must be marked as partially supported in
> >> > 	doc/guides/nics/features/i40e_vf.ini
> >> > See also this email:
> >> > 	http://dpdk.org/ml/archives/dev/2017-March/060063.html
> >> > 
> >> > I wonder whether we should allow such divergence between PF 
> >> > implementations. Intel committed to avoid such fragmentation and 
> >> > keep the SR-IOV messaging standard but it does not happen.
> >> > It is said that we must allow fast innovation in DPDK space.
> >> > I agree but we should also target a good usability of the VF 
> >> > drivers, allowing to replace the PF implementations as needed.
> >> 
> >> Hi Thomas
> >> 
> >> I think I need to clarify a little bit here.
> >> I think we will try our best, but I don't think we can commit. As they 
> >> are on totally different community, and of cause code repositories.

What prevent you from submitting your code to the kernel community?
Note that your statement does not respect the agreed policy:
	http://dpdk.org/ml/archives/dev/2017-January/055224.html
	http://dpdk.org/doc/guides/contributing/design.html#pf-and-vf-considerations

> >> > Here is my suggestion: let's accept a VF feature only if the PF 
> >> > support is submitted to both dpdk.org and kernel.org mailing lists.
> >> > I ask to add this topic to the next techboard meeting.
> >> 
> >> Sorry, technically I disagree with this suggestion, as I don't understand why!
> >> I was told DPDK is not Linux, and Linux is not DPDK. Why we want to 
> >> add this dependency on Linux PF host driver? And why just on PF/VF driver feature only?
> >> I think if we can have any good innovative idea on DPDK first, why not 
> >> just have it on DPDK? Then Linux or even other OS/community/Company 
> >> can learn from DPDK and develop their own.
> >
> > It is really a general problem.
> > Here you are adding a feature in a VF driver. But it does not work with
> > some PF drivers.We have the same problem when adding a feature which
> > does not work on BSD or on a CPU architecture.
> > Generally speaking, we have a usability issue when a feature works only
> > with a given environment.
> > And it is worst in the SR-IOV case because a VM can migrate from an
> > hypervisor (with a given PF) to another (and different) one.
> 
> Yes, I understood that's the reality and the issue. But I don't think we can address it with your suggestion.
> Linux is just one of the OS, as you said, FreeBSD, Windows, VMWare,  ...

I am talking about migration from a KVM to another one.
So BSD, Windows and VMware are irrelevant.

> I'd suggest to start another discussion on the tech board to solve that problem, but not limit
> adding new features. They are different topics and things, based on my understanding.

Helin, you just want to add your new code and hide issues.
You don't even bother to document the limitations or the partial support
as I have suggested earlier.
As a maintainer, I have to check the quality and the usability.
I can tell you that I stack the promises "I will fix it later" and
we are still waiting for a lot of them.
That's why, even if you think it is not related, we need sometimes
to block things until they are properly done and completed.
  
Vincent Jardin March 17, 2017, 8:14 p.m. UTC | #7
Le 17 mars 2017 11:15:22 AM Thomas Monjalon <thomas.monjalon@6wind.com> a 
écrit :

> 2017-03-17 09:45, Zhang, Helin:
>>From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
>> >2017-03-17 03:28, Zhang, Helin:
>> >> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
>> >> > 2017-02-23 13:27, Qi Zhang:
>> >> > >  static void
>> >> > > +i40evf_dev_stats_reset(struct rte_eth_dev *dev) {
>> >> > > +	struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data-
>> >> > >dev_private);
>> >> > > +	/* only DPDK PF support this */
>> >> > > +	if (vf->version_major == I40E_DPDK_VERSION_MAJOR) {
>> >> > > +		if (i40evf_reset_statistics(dev))
>> >> > > +			PMD_DRV_LOG(ERR, "Reset statistics failed");
>> >> > > +	}
>> >> > > +}
>> >> >
>> >> > One more SR-IOV feature not supported with a Linux PF.
>> >> > The basic stats feature must be marked as partially supported in
>> >> > 	doc/guides/nics/features/i40e_vf.ini
>> >> > See also this email:
>> >> > 	http://dpdk.org/ml/archives/dev/2017-March/060063.html
>> >> >
>> >> > I wonder whether we should allow such divergence between PF
>> >> > implementations. Intel committed to avoid such fragmentation and
>> >> > keep the SR-IOV messaging standard but it does not happen.
>> >> > It is said that we must allow fast innovation in DPDK space.
>> >> > I agree but we should also target a good usability of the VF
>> >> > drivers, allowing to replace the PF implementations as needed.
>> >>
>> >> Hi Thomas
>> >>
>> >> I think I need to clarify a little bit here.
>> >> I think we will try our best, but I don't think we can commit. As they
>> >> are on totally different community, and of cause code repositories.
>
> What prevent you from submitting your code to the kernel community?
> Note that your statement does not respect the agreed policy:
> 	http://dpdk.org/ml/archives/dev/2017-January/055224.html
> 	http://dpdk.org/doc/guides/contributing/design.html#pf-and-vf-considerations
>
>> >> > Here is my suggestion: let's accept a VF feature only if the PF
>> >> > support is submitted to both dpdk.org and kernel.org mailing lists.
>> >> > I ask to add this topic to the next techboard meeting.
>> >>
>> >> Sorry, technically I disagree with this suggestion, as I don't 
>> understand why!
>> >> I was told DPDK is not Linux, and Linux is not DPDK. Why we want to
>> >> add this dependency on Linux PF host driver? And why just on PF/VF 
>> driver feature only?
>> >> I think if we can have any good innovative idea on DPDK first, why not
>> >> just have it on DPDK? Then Linux or even other OS/community/Company
>> >> can learn from DPDK and develop their own.
>> >
>> > It is really a general problem.
>> > Here you are adding a feature in a VF driver. But it does not work with
>> > some PF drivers.We have the same problem when adding a feature which
>> > does not work on BSD or on a CPU architecture.
>> > Generally speaking, we have a usability issue when a feature works only
>> > with a given environment.
>> > And it is worst in the SR-IOV case because a VM can migrate from an
>> > hypervisor (with a given PF) to another (and different) one.
>>
>> Yes, I understood that's the reality and the issue. But I don't think we 
>> can address it with your suggestion.
>> Linux is just one of the OS, as you said, FreeBSD, Windows, VMWare,  ...
>
> I am talking about migration from a KVM to another one.
> So BSD, Windows and VMware are irrelevant.
>
>> I'd suggest to start another discussion on the tech board to solve that 
>> problem, but not limit
>> adding new features. They are different topics and things, based on my 
>> understanding.
>
> Helin, you just want to add your new code and hide issues.
> You don't even bother to document the limitations or the partial support
> as I have suggested earlier.
> As a maintainer, I have to check the quality and the usability.
> I can tell you that I stack the promises "I will fix it later" and
> we are still waiting for a lot of them.
> That's why, even if you think it is not related, we need sometimes
> to block things until they are properly done and completed.

Please, can you bring it to the next tech board? This dispersion of VF/PF 
make the DPDK unusable into open products with many parties since behavior 
becomes VF/PF specific.

Thank you,
  
Thomas Monjalon March 17, 2017, 11:03 p.m. UTC | #8
2017-03-17 21:14, Vincent Jardin:
> Please, can you bring it to the next tech board? This dispersion of VF/PF 
> make the DPDK unusable into open products with many parties since behavior 
> becomes VF/PF specific.

Already requested earlier in this thread:
	http://dpdk.org/ml/archives/dev/2017-March/060375.html
  
Vincent Jardin March 18, 2017, 10:34 a.m. UTC | #9
Le 18 mars 2017 00:03:08 Thomas Monjalon <thomas.monjalon@6wind.com> a écrit :

> 2017-03-17 21:14, Vincent Jardin:
>> Please, can you bring it to the next tech board? This dispersion of VF/PF
>> make the DPDK unusable into open products with many parties since behavior
>> becomes VF/PF specific.
>
> Already requested earlier in this thread:
> 	http://dpdk.org/ml/archives/dev/2017-March/060375.html

It is not on Konstantin's agenda.

>
>
  
Zhang, Helin March 20, 2017, 2:47 a.m. UTC | #10
> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> Sent: Friday, March 17, 2017 6:15 PM
> To: Zhang, Helin
> Cc: Zhang, Qi Z; techboard@dpdk.org; dev@dpdk.org; Wu, Jingjing; Yigit,
> Ferruh; Liang, Cunming; Fastabend, John R
> Subject: Re: [dpdk-dev] [PATCH] net/i40e: enable statistic reset for VF
> 
> 2017-03-17 09:45, Zhang, Helin:
> >From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> > >2017-03-17 03:28, Zhang, Helin:
> > >> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> > >> > 2017-02-23 13:27, Qi Zhang:
> > >> > >  static void
> > >> > > +i40evf_dev_stats_reset(struct rte_eth_dev *dev) {
> > >> > > +	struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data-
> > >> > >dev_private);
> > >> > > +	/* only DPDK PF support this */
> > >> > > +	if (vf->version_major == I40E_DPDK_VERSION_MAJOR) {
> > >> > > +		if (i40evf_reset_statistics(dev))
> > >> > > +			PMD_DRV_LOG(ERR, "Reset statistics failed");
> > >> > > +	}
> > >> > > +}
> > >> >
> > >> > One more SR-IOV feature not supported with a Linux PF.
> > >> > The basic stats feature must be marked as partially supported in
> > >> > 	doc/guides/nics/features/i40e_vf.ini
> > >> > See also this email:
> > >> > 	http://dpdk.org/ml/archives/dev/2017-March/060063.html
> > >> >
> > >> > I wonder whether we should allow such divergence between PF
> > >> > implementations. Intel committed to avoid such fragmentation and
> > >> > keep the SR-IOV messaging standard but it does not happen.
> > >> > It is said that we must allow fast innovation in DPDK space.
> > >> > I agree but we should also target a good usability of the VF
> > >> > drivers, allowing to replace the PF implementations as needed.
> > >>
> > >> Hi Thomas
> > >>
> > >> I think I need to clarify a little bit here.
> > >> I think we will try our best, but I don't think we can commit. As
> > >> they are on totally different community, and of cause code repositories.
> 
> What prevent you from submitting your code to the kernel community?
> Note that your statement does not respect the agreed policy:
> 	http://dpdk.org/ml/archives/dev/2017-January/055224.html
> 	http://dpdk.org/doc/guides/contributing/design.html#pf-and-vf-
> considerations

There might be some confusing or misunderstanding.
I didn't say we will not submit any patches to kernel community.
We will try to send a few first, and then see what will happen. If it will be
rejected, or take too much time to be accepted. Then we may give up.
If it can be accepted by kernel community, then we may continue.
That's the reality, we will try, but we cannot make any commitment
on having anything in kernel side.

> 
> > >> > Here is my suggestion: let's accept a VF feature only if the PF
> > >> > support is submitted to both dpdk.org and kernel.org mailing lists.
> > >> > I ask to add this topic to the next techboard meeting.
> > >>
> > >> Sorry, technically I disagree with this suggestion, as I don't understand
> why!
> > >> I was told DPDK is not Linux, and Linux is not DPDK. Why we want to
> > >> add this dependency on Linux PF host driver? And why just on PF/VF
> driver feature only?
> > >> I think if we can have any good innovative idea on DPDK first, why
> > >> not just have it on DPDK? Then Linux or even other
> > >> OS/community/Company can learn from DPDK and develop their own.
> > >
> > > It is really a general problem.
> > > Here you are adding a feature in a VF driver. But it does not work
> > > with some PF drivers.We have the same problem when adding a feature
> > > which does not work on BSD or on a CPU architecture.
> > > Generally speaking, we have a usability issue when a feature works
> > > only with a given environment.
> > > And it is worst in the SR-IOV case because a VM can migrate from an
> > > hypervisor (with a given PF) to another (and different) one.
> >
> > Yes, I understood that's the reality and the issue. But I don't think we can
> address it with your suggestion.
> > Linux is just one of the OS, as you said, FreeBSD, Windows, VMWare,  ...
> 
> I am talking about migration from a KVM to another one.
> So BSD, Windows and VMware are irrelevant.
But as a guest user, he may want to his application running well in all the VMs
without modifying anything, no matter in KVM, Windows, or VMWare.
Do you want to address that issue too?

> 
> > I'd suggest to start another discussion on the tech board to solve
> > that problem, but not limit adding new features. They are different topics
> and things, based on my understanding.
> 
> Helin, you just want to add your new code and hide issues.
> You don't even bother to document the limitations or the partial support as I
> have suggested earlier.
> As a maintainer, I have to check the quality and the usability.
> I can tell you that I stack the promises "I will fix it later" and we are still waiting
> for a lot of them.
> That's why, even if you think it is not related, we need sometimes to block
> things until they are properly done and completed.
There is no doubt, I appreciate your great job!
As I said before, we will try to submit a few first, and see what will happen.
For your doc requests, I think somebody else already replied you.

Sorry, I don't know that you are thinking about KVM migration. I was informed by
Vincent that all DPDK PF host features should be consistent with kernel host driver,
though I am not sure if I missed anything.
OK. Let's focus on the issue. What's the problem statement? What's the solution
well discussed and accepted widely by the community?
BTW, do we need to think about that a bit more? For example, do we need to
think about the similar policy on rte_flow API, ACL and possibly other features?

Thanks,
Helin
  
Thomas Monjalon March 20, 2017, 9:14 a.m. UTC | #11
2017-03-20 02:47, Zhang, Helin:
> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> > 2017-03-17 09:45, Zhang, Helin:
> > >From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> > > >2017-03-17 03:28, Zhang, Helin:
> > > >> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> > > >> > 2017-02-23 13:27, Qi Zhang:
> > > >> > >  static void
> > > >> > > +i40evf_dev_stats_reset(struct rte_eth_dev *dev) {
> > > >> > > +	struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data-
> > > >> > >dev_private);
> > > >> > > +	/* only DPDK PF support this */
> > > >> > > +	if (vf->version_major == I40E_DPDK_VERSION_MAJOR) {
> > > >> > > +		if (i40evf_reset_statistics(dev))
> > > >> > > +			PMD_DRV_LOG(ERR, "Reset statistics failed");
> > > >> > > +	}
> > > >> > > +}
> > > >> >
> > > >> > One more SR-IOV feature not supported with a Linux PF.
> > > >> > The basic stats feature must be marked as partially supported in
> > > >> > 	doc/guides/nics/features/i40e_vf.ini
> > > >> > See also this email:
> > > >> > 	http://dpdk.org/ml/archives/dev/2017-March/060063.html
> > > >> >
> > > >> > I wonder whether we should allow such divergence between PF
> > > >> > implementations. Intel committed to avoid such fragmentation and
> > > >> > keep the SR-IOV messaging standard but it does not happen.
> > > >> > It is said that we must allow fast innovation in DPDK space.
> > > >> > I agree but we should also target a good usability of the VF
> > > >> > drivers, allowing to replace the PF implementations as needed.
> > > >>
> > > >> Hi Thomas
> > > >>
> > > >> I think I need to clarify a little bit here.
> > > >> I think we will try our best, but I don't think we can commit. As
> > > >> they are on totally different community, and of cause code repositories.
> > 
> > What prevent you from submitting your code to the kernel community?
> > Note that your statement does not respect the agreed policy:
> > 	http://dpdk.org/ml/archives/dev/2017-January/055224.html
> > 	http://dpdk.org/doc/guides/contributing/design.html#pf-and-vf-
> > considerations
> 
> There might be some confusing or misunderstanding.
> I didn't say we will not submit any patches to kernel community.
> We will try to send a few first, and then see what will happen. If it will be
> rejected, or take too much time to be accepted. Then we may give up.
> If it can be accepted by kernel community, then we may continue.
> That's the reality, we will try, but we cannot make any commitment
> on having anything in kernel side.

Of course you do not know if it will be accepted in Linux.
The agreed policy was just to try:
"
PF functionality should only be added to DPDK for testing and
prototyping purposes while the kernel work is ongoing.
"

> > > >> > Here is my suggestion: let's accept a VF feature only if the PF
> > > >> > support is submitted to both dpdk.org and kernel.org mailing lists.
> > > >> > I ask to add this topic to the next techboard meeting.
> > > >>
> > > >> Sorry, technically I disagree with this suggestion, as I don't understand
> > why!
> > > >> I was told DPDK is not Linux, and Linux is not DPDK. Why we want to
> > > >> add this dependency on Linux PF host driver? And why just on PF/VF
> > driver feature only?
> > > >> I think if we can have any good innovative idea on DPDK first, why
> > > >> not just have it on DPDK? Then Linux or even other
> > > >> OS/community/Company can learn from DPDK and develop their own.
> > > >
> > > > It is really a general problem.
> > > > Here you are adding a feature in a VF driver. But it does not work
> > > > with some PF drivers.We have the same problem when adding a feature
> > > > which does not work on BSD or on a CPU architecture.
> > > > Generally speaking, we have a usability issue when a feature works
> > > > only with a given environment.
> > > > And it is worst in the SR-IOV case because a VM can migrate from an
> > > > hypervisor (with a given PF) to another (and different) one.
> > >
> > > Yes, I understood that's the reality and the issue. But I don't think we can
> > address it with your suggestion.
> > > Linux is just one of the OS, as you said, FreeBSD, Windows, VMWare,  ...
> > 
> > I am talking about migration from a KVM to another one.
> > So BSD, Windows and VMware are irrelevant.
> 
> But as a guest user, he may want to his application running well in all the VMs
> without modifying anything, no matter in KVM, Windows, or VMWare.
> Do you want to address that issue too?

That's a different question. DPDK PF is a replacement for Linux PF.
When considering another hypervisor (Windows or VMware), there can be
many things different. I think trying to have the same behaviour, with
all these hypervisors, is a nice goal but a smaller priority than
DPDK/Linux standardization.

> > > I'd suggest to start another discussion on the tech board to solve
> > > that problem, but not limit adding new features. They are different topics
> > and things, based on my understanding.
> > 
> > Helin, you just want to add your new code and hide issues.
> > You don't even bother to document the limitations or the partial support as I
> > have suggested earlier.
> > As a maintainer, I have to check the quality and the usability.
> > I can tell you that I stack the promises "I will fix it later" and we are still waiting
> > for a lot of them.
> > That's why, even if you think it is not related, we need sometimes to block
> > things until they are properly done and completed.
> 
> There is no doubt, I appreciate your great job!
> As I said before, we will try to submit a few first, and see what will happen.
> For your doc requests, I think somebody else already replied you.
> 
> Sorry, I don't know that you are thinking about KVM migration. I was informed by
> Vincent that all DPDK PF host features should be consistent with kernel host driver,
> though I am not sure if I missed anything.
> OK. Let's focus on the issue. What's the problem statement? What's the solution
> well discussed and accepted widely by the community?
> BTW, do we need to think about that a bit more? For example, do we need to
> think about the similar policy on rte_flow API, ACL and possibly other features?

Yes homogeneity should be general, so we must keep it in mind for future
works and enhancements of every DPDK areas.
We could write some general guidelines that the techboard would have
to approve.
  
Zhang, Helin March 22, 2017, 9:48 a.m. UTC | #12
> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> Sent: Monday, March 20, 2017 5:14 PM
> To: Zhang, Helin
> Cc: Zhang, Qi Z; techboard@dpdk.org; dev@dpdk.org; Wu, Jingjing; Yigit,
> Ferruh; Liang, Cunming; Fastabend, John R
> Subject: Re: [dpdk-dev] [PATCH] net/i40e: enable statistic reset for VF
> 
> 2017-03-20 02:47, Zhang, Helin:
> > From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> > > 2017-03-17 09:45, Zhang, Helin:
> > > >From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> > > > >2017-03-17 03:28, Zhang, Helin:
> > > > >> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> > > > >> > 2017-02-23 13:27, Qi Zhang:
> > > > >> > >  static void
> > > > >> > > +i40evf_dev_stats_reset(struct rte_eth_dev *dev) {
> > > > >> > > +	struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data-
> > > > >> > >dev_private);
> > > > >> > > +	/* only DPDK PF support this */
> > > > >> > > +	if (vf->version_major == I40E_DPDK_VERSION_MAJOR) {
> > > > >> > > +		if (i40evf_reset_statistics(dev))
> > > > >> > > +			PMD_DRV_LOG(ERR, "Reset statistics failed");
> > > > >> > > +	}
> > > > >> > > +}
> > > > >> >
> > > > >> > One more SR-IOV feature not supported with a Linux PF.
> > > > >> > The basic stats feature must be marked as partially supported in
> > > > >> > 	doc/guides/nics/features/i40e_vf.ini
> > > > >> > See also this email:
> > > > >> > 	http://dpdk.org/ml/archives/dev/2017-March/060063.html
> > > > >> >
> > > > >> > I wonder whether we should allow such divergence between PF
> > > > >> > implementations. Intel committed to avoid such fragmentation
> > > > >> > and keep the SR-IOV messaging standard but it does not happen.
> > > > >> > It is said that we must allow fast innovation in DPDK space.
> > > > >> > I agree but we should also target a good usability of the VF
> > > > >> > drivers, allowing to replace the PF implementations as needed.
> > > > >>
> > > > >> Hi Thomas
> > > > >>
> > > > >> I think I need to clarify a little bit here.
> > > > >> I think we will try our best, but I don't think we can commit.
> > > > >> As they are on totally different community, and of cause code
> repositories.
> > >
> > > What prevent you from submitting your code to the kernel community?
> > > Note that your statement does not respect the agreed policy:
> > > 	http://dpdk.org/ml/archives/dev/2017-January/055224.html
> > > 	http://dpdk.org/doc/guides/contributing/design.html#pf-and-vf-
> > > considerations
> >
> > There might be some confusing or misunderstanding.
> > I didn't say we will not submit any patches to kernel community.
> > We will try to send a few first, and then see what will happen. If it
> > will be rejected, or take too much time to be accepted. Then we may give up.
> > If it can be accepted by kernel community, then we may continue.
> > That's the reality, we will try, but we cannot make any commitment on
> > having anything in kernel side.
> 
> Of course you do not know if it will be accepted in Linux.
> The agreed policy was just to try:
> "
> PF functionality should only be added to DPDK for testing and prototyping
> purposes while the kernel work is ongoing.
> "
OK. I understood. I am sure we will try soon with few first. So we are aligned. Thanks!

> 
> > > > >> > Here is my suggestion: let's accept a VF feature only if the
> > > > >> > PF support is submitted to both dpdk.org and kernel.org mailing lists.
> > > > >> > I ask to add this topic to the next techboard meeting.
> > > > >>
> > > > >> Sorry, technically I disagree with this suggestion, as I don't
> > > > >> understand
> > > why!
> > > > >> I was told DPDK is not Linux, and Linux is not DPDK. Why we
> > > > >> want to add this dependency on Linux PF host driver? And why
> > > > >> just on PF/VF
> > > driver feature only?
> > > > >> I think if we can have any good innovative idea on DPDK first,
> > > > >> why not just have it on DPDK? Then Linux or even other
> > > > >> OS/community/Company can learn from DPDK and develop their own.
> > > > >
> > > > > It is really a general problem.
> > > > > Here you are adding a feature in a VF driver. But it does not
> > > > > work with some PF drivers.We have the same problem when adding a
> > > > > feature which does not work on BSD or on a CPU architecture.
> > > > > Generally speaking, we have a usability issue when a feature
> > > > > works only with a given environment.
> > > > > And it is worst in the SR-IOV case because a VM can migrate from
> > > > > an hypervisor (with a given PF) to another (and different) one.
> > > >
> > > > Yes, I understood that's the reality and the issue. But I don't
> > > > think we can
> > > address it with your suggestion.
> > > > Linux is just one of the OS, as you said, FreeBSD, Windows, VMWare,  ...
> > >
> > > I am talking about migration from a KVM to another one.
> > > So BSD, Windows and VMware are irrelevant.
> >
> > But as a guest user, he may want to his application running well in
> > all the VMs without modifying anything, no matter in KVM, Windows, or
> VMWare.
> > Do you want to address that issue too?
> 
> That's a different question. DPDK PF is a replacement for Linux PF.
> When considering another hypervisor (Windows or VMware), there can be
> many things different. I think trying to have the same behaviour, with all these
> hypervisors, is a nice goal but a smaller priority than DPDK/Linux
> standardization.
So you are suggesting to have the VF drivers with the same behaviours
between kernel host driver and DPDK host driver, right?
Nothing about kernel side live migration, nothing about link bonding, right?

Then I have thoughts as below.
- Frist, applications with using that VF should work well no matter with using
  kernel host or DPDK host driver, as long as the VF application can handle
  the return value gracefully. For example, if kernel host does not support a
  VF request, while DPDK host supports, the kernel driver will return with an
  error code to indicate that is not supported, and the VF application should
  handle that well and smartly. I don't think it will block anything. Any different
  view on that?
- Second, will there really have any desire to move from DPDK host to kernel host?
  I don't see there is any desire to do that, and we can add restriction there.
- Third, even two KVMs with different version of kernel driver, it may not work,
  as different version of kernel drivers have different features and capabilities.
  So we cannot assume it works the same way between two KVMs with different
  kernel driver versions.

> 
> > > > I'd suggest to start another discussion on the tech board to solve
> > > > that problem, but not limit adding new features. They are
> > > > different topics
> > > and things, based on my understanding.
> > >
> > > Helin, you just want to add your new code and hide issues.
> > > You don't even bother to document the limitations or the partial
> > > support as I have suggested earlier.
> > > As a maintainer, I have to check the quality and the usability.
> > > I can tell you that I stack the promises "I will fix it later" and
> > > we are still waiting for a lot of them.
> > > That's why, even if you think it is not related, we need sometimes
> > > to block things until they are properly done and completed.
> >
> > There is no doubt, I appreciate your great job!
> > As I said before, we will try to submit a few first, and see what will happen.
> > For your doc requests, I think somebody else already replied you.
> >
> > Sorry, I don't know that you are thinking about KVM migration. I was
> > informed by Vincent that all DPDK PF host features should be
> > consistent with kernel host driver, though I am not sure if I missed anything.
> > OK. Let's focus on the issue. What's the problem statement? What's the
> > solution well discussed and accepted widely by the community?
> > BTW, do we need to think about that a bit more? For example, do we
> > need to think about the similar policy on rte_flow API, ACL and possibly other
> features?
> 
> Yes homogeneity should be general, so we must keep it in mind for future
> works and enhancements of every DPDK areas.
> We could write some general guidelines that the techboard would have to
> approve.
Yes, a lot of issues or limitations even not just on DPDK needs to be addressed.
That's the great job the community maintainers and developers are working on.
Yes, doc update is always we need to do better. Thank you very much!

/Helin
  
Zhang, Helin April 1, 2017, 12:50 a.m. UTC | #13
As Thomas asked, I am not quite sure if experimental tag needs to be added. Please double check it.

Thanks,
Helin

> -----Original Message-----
> From: Zhang, Qi Z
> Sent: Friday, February 24, 2017 2:27 AM
> To: Wu, Jingjing; Zhang, Helin
> Cc: dev@dpdk.org; Zhang, Qi Z
> Subject: [PATCH] net/i40e: enable statistic reset for VF
> 
> The patch implements the dev_ops "stats_reset" for VF.
> 
> Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
> ---
>  drivers/net/i40e/i40e_ethdev_vf.c | 34
> ++++++++++++++++++++++++++++++++++
>  drivers/net/i40e/i40e_pf.c        | 25 +++++++++++++++++++++++++
>  drivers/net/i40e/i40e_pf.h        |  1 +
>  3 files changed, 60 insertions(+)
> 
> diff --git a/drivers/net/i40e/i40e_ethdev_vf.c
> b/drivers/net/i40e/i40e_ethdev_vf.c
> index 55fd344..5155b25 100644
> --- a/drivers/net/i40e/i40e_ethdev_vf.c
> +++ b/drivers/net/i40e/i40e_ethdev_vf.c
> @@ -110,6 +110,7 @@ static int i40evf_dev_link_update(struct rte_eth_dev
> *dev,
>  				  __rte_unused int wait_to_complete);  static
> void i40evf_dev_stats_get(struct rte_eth_dev *dev,
>  				struct rte_eth_stats *stats);
> +static void i40evf_dev_stats_reset(struct rte_eth_dev *dev);
>  static int i40evf_dev_xstats_get(struct rte_eth_dev *dev,
>  				 struct rte_eth_xstat *xstats, unsigned n);
> static int i40evf_dev_xstats_get_names(struct rte_eth_dev *dev, @@ -199,6
> +200,7 @@ static const struct eth_dev_ops i40evf_eth_dev_ops = {
>  	.allmulticast_disable = i40evf_dev_allmulticast_disable,
>  	.link_update          = i40evf_dev_link_update,
>  	.stats_get            = i40evf_dev_stats_get,
> +	.stats_reset          = i40evf_dev_stats_reset,
>  	.xstats_get           = i40evf_dev_xstats_get,
>  	.xstats_get_names     = i40evf_dev_xstats_get_names,
>  	.xstats_reset         = i40evf_dev_xstats_reset,
> @@ -988,6 +990,27 @@ i40evf_get_statistics(struct rte_eth_dev *dev, struct
> rte_eth_stats *stats)
>  	return 0;
>  }
> 
> +static int
> +i40evf_reset_statistics(struct rte_eth_dev *dev) {
> +	struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data-
> >dev_private);
> +	int err;
> +	struct vf_cmd_info args;
> +	u16 vsi_id = vf->vsi_res->vsi_id;
Basically DPDK developers use uint16_t but not u16.

> +
> +	args.ops = (enum i40e_virtchnl_ops)I40E_VIRTCHNL_OP_RESET_STATS;
> +	args.in_args = (uint8_t *)&vsi_id;
> +	args.in_args_size = sizeof(vsi_id);
> +	args.out_buffer = vf->aq_resp;
> +	args.out_size = I40E_AQ_BUF_SZ;
> +
> +	err = i40evf_execute_vf_cmd(dev, &args);
> +	if (err)
> +		PMD_DRV_LOG(ERR, "fail to execute command
> CFG_VLAN_OFFLOAD");
> +
> +	return err;
> +}
> +
>  static void
>  i40evf_dev_xstats_reset(struct rte_eth_dev *dev)  { @@ -2310,6 +2333,17
> @@ i40evf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats
> *stats)  }
> 
>  static void
> +i40evf_dev_stats_reset(struct rte_eth_dev *dev) {
> +	struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data-
> >dev_private);
> +	/* only DPDK PF support this */
> +	if (vf->version_major == I40E_DPDK_VERSION_MAJOR) {
> +		if (i40evf_reset_statistics(dev))
> +			PMD_DRV_LOG(ERR, "Reset statistics failed");
> +	}
> +}
> +
> +static void
>  i40evf_dev_close(struct rte_eth_dev *dev)  {
>  	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data-
> >dev_private);
> diff --git a/drivers/net/i40e/i40e_pf.c b/drivers/net/i40e/i40e_pf.c index
> f771dfb..62d2bfd 100644
> --- a/drivers/net/i40e/i40e_pf.c
> +++ b/drivers/net/i40e/i40e_pf.c
> @@ -1155,6 +1155,27 @@ i40e_pf_host_process_cmd_cfg_pvid(struct
> i40e_pf_vf *vf,
>  	return ret;
>  }
> 
> +static int
> +i40e_pf_host_process_cmd_reset_stats(struct i40e_pf_vf *vf,
> +					bool b_op)
> +{
> +	vf->vsi->offset_loaded = false;
> +	i40e_update_vsi_stats(vf->vsi);
Does it need to check the return value of above function call?
> +
> +	if (b_op)
> +		i40e_pf_host_send_msg_to_vf(vf,
> I40E_VIRTCHNL_OP_RESET_STATS,
> +					    I40E_SUCCESS,
> +					    NULL,
> +					    0);
> +	else
> +		i40e_pf_host_send_msg_to_vf(vf,
> I40E_VIRTCHNL_OP_RESET_STATS,
> +					    I40E_NOT_SUPPORTED,
> +					    NULL,
> +					    0);
> +
> +	return I40E_SUCCESS;
> +}
> +
>  void
>  i40e_notify_vf_link_status(struct rte_eth_dev *dev, struct i40e_pf_vf *vf)
> { @@ -1300,6 +1321,10 @@ i40e_pf_host_handle_vf_msg(struct rte_eth_dev
> *dev,
>  		PMD_DRV_LOG(INFO, "OP_CFG_VLAN_PVID received");
>  		i40e_pf_host_process_cmd_cfg_pvid(vf, msg, msglen, b_op);
>  		break;
> +	case I40E_VIRTCHNL_OP_RESET_STATS:
> +		PMD_DRV_LOG(INFO, "OP_RESET_STATS received");
> +		i40e_pf_host_process_cmd_reset_stats(vf, b_op);
> +		break;
>  	/* Don't add command supported below, which will
>  	 * return an error code.
>  	 */
> diff --git a/drivers/net/i40e/i40e_pf.h b/drivers/net/i40e/i40e_pf.h index
> b4c2287..69ef873 100644
> --- a/drivers/net/i40e/i40e_pf.h
> +++ b/drivers/net/i40e/i40e_pf.h
> @@ -58,6 +58,7 @@ enum i40e_virtchnl_ops_dpdk {
>  						I40E_DPDK_OFFSET,
>  	I40E_VIRTCHNL_OP_CFG_VLAN_PVID,
>  	I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES_EXT,
> +	I40E_VIRTCHNL_OP_RESET_STATS,
>  };
> 
>  /* A structure to support extended info of a receive queue. */
> --
> 2.7.4
  
Qi Zhang April 12, 2017, 11:19 a.m. UTC | #14
> -----Original Message-----
> From: Zhang, Qi Z
> Sent: Wednesday, April 12, 2017 7:08 PM
> To: Zhang, Qi Z <qi.z.zhang@intel.com>
> Subject: RE: [PATCH] net/i40e: enable statistic reset for VF
> 
> -----Original Message-----
> From: Zhang, Qi Z
> Sent: Friday, February 24, 2017 2:27 AM
> To: Wu, Jingjing; Zhang, Helin
> Cc: dev@dpdk.org; Zhang, Qi Z
> Subject: [PATCH] net/i40e: enable statistic reset for VF
> 
> The patch implements the dev_ops "stats_reset" for VF.
> 
> Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
> ---
>   drivers/net/i40e/i40e_ethdev_vf.c | 34
> ++++++++++++++++++++++++++++++++++
>   drivers/net/i40e/i40e_pf.c        | 25 +++++++++++++++++++++++++
>   drivers/net/i40e/i40e_pf.h        |  1 +
>   3 files changed, 60 insertions(+)
> 
>  diff --git a/drivers/net/i40e/i40e_ethdev_vf.c
>  b/drivers/net/i40e/i40e_ethdev_vf.c
>  index 55fd344..5155b25 100644
>  --- a/drivers/net/i40e/i40e_ethdev_vf.c
>  +++ b/drivers/net/i40e/i40e_ethdev_vf.c
>  @@ -110,6 +110,7 @@ static int i40evf_dev_link_update(struct
> rte_eth_dev *dev,
>   				  __rte_unused int wait_to_complete);  static void
> i40evf_dev_stats_get(struct rte_eth_dev *dev,
>   				struct rte_eth_stats *stats);
>  +static void i40evf_dev_stats_reset(struct rte_eth_dev *dev);
>   static int i40evf_dev_xstats_get(struct rte_eth_dev *dev,
>   				 struct rte_eth_xstat *xstats, unsigned n); static int
> i40evf_dev_xstats_get_names(struct rte_eth_dev *dev, @@ -199,6
>  +200,7 @@ static const struct eth_dev_ops i40evf_eth_dev_ops = {
>   	.allmulticast_disable = i40evf_dev_allmulticast_disable,
>   	.link_update          = i40evf_dev_link_update,
>   	.stats_get            = i40evf_dev_stats_get,
>  +	.stats_reset          = i40evf_dev_stats_reset,
>   	.xstats_get           = i40evf_dev_xstats_get,
>   	.xstats_get_names     = i40evf_dev_xstats_get_names,
>   	.xstats_reset         = i40evf_dev_xstats_reset,
>  @@ -988,6 +990,27 @@ i40evf_get_statistics(struct rte_eth_dev *dev,
> struct rte_eth_stats *stats)
>   	return 0;
>   }
> 
>  +static int
>  +i40evf_reset_statistics(struct rte_eth_dev *dev) {
>  +	struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data-
>  >dev_private);
>  +	int err;
>  +	struct vf_cmd_info args;
>  +	u16 vsi_id = vf->vsi_res->vsi_id;
>  +
>  +	args.ops = (enum i40e_virtchnl_ops)I40E_VIRTCHNL_OP_RESET_STATS;
>  +	args.in_args = (uint8_t *)&vsi_id;
>  +	args.in_args_size = sizeof(vsi_id);
>  +	args.out_buffer = vf->aq_resp;
>  +	args.out_size = I40E_AQ_BUF_SZ;
>  +
>  +	err = i40evf_execute_vf_cmd(dev, &args);
>  +	if (err)
>  +		PMD_DRV_LOG(ERR, "fail to execute command
>  CFG_VLAN_OFFLOAD");
>  +
>  +	return err;
>  +}
>  +
>   static void
>   i40evf_dev_xstats_reset(struct rte_eth_dev *dev)  { @@ -2310,6
>  +2333,17 @@ i40evf_dev_stats_get(struct rte_eth_dev *dev, struct
> rte_eth_stats
>  *stats)  }
> 
>   static void
>  +i40evf_dev_stats_reset(struct rte_eth_dev *dev) {
>  +	struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data-
>  >dev_private);
>  +	/* only DPDK PF support this */
>  +	if (vf->version_major == I40E_DPDK_VERSION_MAJOR) {
>  +		if (i40evf_reset_statistics(dev))
>  +			PMD_DRV_LOG(ERR, "Reset statistics failed");
>  +	}
>  +}
>  +
>  +static void
>   i40evf_dev_close(struct rte_eth_dev *dev)  {
>   	struct i40e_hw *hw =
> I40E_DEV_PRIVATE_TO_HW(dev->data-  >dev_private);  diff --git
> a/drivers/net/i40e/i40e_pf.c b/drivers/net/i40e/i40e_pf.c  index
> f771dfb..62d2bfd 100644
>  --- a/drivers/net/i40e/i40e_pf.c
>  +++ b/drivers/net/i40e/i40e_pf.c
>  @@ -1155,6 +1155,27 @@ i40e_pf_host_process_cmd_cfg_pvid(struct
>  i40e_pf_vf *vf,
>   	return ret;
>   }
> 
>  +static int
>  +i40e_pf_host_process_cmd_reset_stats(struct i40e_pf_vf *vf,
>  +					bool b_op)
>  +{
>  +	vf->vsi->offset_loaded = false;
>  +	i40e_update_vsi_stats(vf->vsi);
> 
>  +
>  +	if (b_op)
>  +		i40e_pf_host_send_msg_to_vf(vf,
>  I40E_VIRTCHNL_OP_RESET_STATS,
>  +					    I40E_SUCCESS,
>  +					    NULL,
>  +					    0);
>  +	else
>  +		i40e_pf_host_send_msg_to_vf(vf,
>  I40E_VIRTCHNL_OP_RESET_STATS,
>  +					    I40E_NOT_SUPPORTED,
>  +					    NULL,
>  +					    0);
>  +
>  +	return I40E_SUCCESS;
>  +}
>  +
>   void
>   i40e_notify_vf_link_status(struct rte_eth_dev *dev, struct i40e_pf_vf
>  *vf) { @@ -1300,6 +1321,10 @@ i40e_pf_host_handle_vf_msg(struct
> rte_eth_dev *dev,
>   		PMD_DRV_LOG(INFO, "OP_CFG_VLAN_PVID received");
>   		i40e_pf_host_process_cmd_cfg_pvid(vf, msg, msglen, b_op);
>   		break;
>  +	case I40E_VIRTCHNL_OP_RESET_STATS:
>  +		PMD_DRV_LOG(INFO, "OP_RESET_STATS received");
>  +		i40e_pf_host_process_cmd_reset_stats(vf, b_op);
>  +		break;
>   	/* Don't add command supported below, which will
>   	 * return an error code.
>   	 */
>  diff --git a/drivers/net/i40e/i40e_pf.h b/drivers/net/i40e/i40e_pf.h  index
>  b4c2287..69ef873 100644
>  --- a/drivers/net/i40e/i40e_pf.h
>  +++ b/drivers/net/i40e/i40e_pf.h
>  @@ -58,6 +58,7 @@ enum i40e_virtchnl_ops_dpdk {
>   						I40E_DPDK_OFFSET,
>   	I40E_VIRTCHNL_OP_CFG_VLAN_PVID,
>   	I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES_EXT,
>  +	I40E_VIRTCHNL_OP_RESET_STATS,
>   };
> 
>   /* A structure to support extended info of a receive queue. */
>  --
>  2.7.4

This patch will not take effect since vf->version_major == I40E_DPDK_VERSION_MAJOR 
will always be false based on current implementation, so 

Nacked-by: Qi Zhang <qi.z.zhang@intel.com>
  

Patch

diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index 55fd344..5155b25 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -110,6 +110,7 @@  static int i40evf_dev_link_update(struct rte_eth_dev *dev,
 				  __rte_unused int wait_to_complete);
 static void i40evf_dev_stats_get(struct rte_eth_dev *dev,
 				struct rte_eth_stats *stats);
+static void i40evf_dev_stats_reset(struct rte_eth_dev *dev);
 static int i40evf_dev_xstats_get(struct rte_eth_dev *dev,
 				 struct rte_eth_xstat *xstats, unsigned n);
 static int i40evf_dev_xstats_get_names(struct rte_eth_dev *dev,
@@ -199,6 +200,7 @@  static const struct eth_dev_ops i40evf_eth_dev_ops = {
 	.allmulticast_disable = i40evf_dev_allmulticast_disable,
 	.link_update          = i40evf_dev_link_update,
 	.stats_get            = i40evf_dev_stats_get,
+	.stats_reset          = i40evf_dev_stats_reset,
 	.xstats_get           = i40evf_dev_xstats_get,
 	.xstats_get_names     = i40evf_dev_xstats_get_names,
 	.xstats_reset         = i40evf_dev_xstats_reset,
@@ -988,6 +990,27 @@  i40evf_get_statistics(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 	return 0;
 }
 
+static int
+i40evf_reset_statistics(struct rte_eth_dev *dev)
+{
+	struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
+	int err;
+	struct vf_cmd_info args;
+	u16 vsi_id = vf->vsi_res->vsi_id;
+
+	args.ops = (enum i40e_virtchnl_ops)I40E_VIRTCHNL_OP_RESET_STATS;
+	args.in_args = (uint8_t *)&vsi_id;
+	args.in_args_size = sizeof(vsi_id);
+	args.out_buffer = vf->aq_resp;
+	args.out_size = I40E_AQ_BUF_SZ;
+
+	err = i40evf_execute_vf_cmd(dev, &args);
+	if (err)
+		PMD_DRV_LOG(ERR, "fail to execute command CFG_VLAN_OFFLOAD");
+
+	return err;
+}
+
 static void
 i40evf_dev_xstats_reset(struct rte_eth_dev *dev)
 {
@@ -2310,6 +2333,17 @@  i40evf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 }
 
 static void
+i40evf_dev_stats_reset(struct rte_eth_dev *dev)
+{
+	struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private);
+	/* only DPDK PF support this */
+	if (vf->version_major == I40E_DPDK_VERSION_MAJOR) {
+		if (i40evf_reset_statistics(dev))
+			PMD_DRV_LOG(ERR, "Reset statistics failed");
+	}
+}
+
+static void
 i40evf_dev_close(struct rte_eth_dev *dev)
 {
 	struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
diff --git a/drivers/net/i40e/i40e_pf.c b/drivers/net/i40e/i40e_pf.c
index f771dfb..62d2bfd 100644
--- a/drivers/net/i40e/i40e_pf.c
+++ b/drivers/net/i40e/i40e_pf.c
@@ -1155,6 +1155,27 @@  i40e_pf_host_process_cmd_cfg_pvid(struct i40e_pf_vf *vf,
 	return ret;
 }
 
+static int
+i40e_pf_host_process_cmd_reset_stats(struct i40e_pf_vf *vf,
+					bool b_op)
+{
+	vf->vsi->offset_loaded = false;
+	i40e_update_vsi_stats(vf->vsi);
+
+	if (b_op)
+		i40e_pf_host_send_msg_to_vf(vf, I40E_VIRTCHNL_OP_RESET_STATS,
+					    I40E_SUCCESS,
+					    NULL,
+					    0);
+	else
+		i40e_pf_host_send_msg_to_vf(vf, I40E_VIRTCHNL_OP_RESET_STATS,
+					    I40E_NOT_SUPPORTED,
+					    NULL,
+					    0);
+
+	return I40E_SUCCESS;
+}
+
 void
 i40e_notify_vf_link_status(struct rte_eth_dev *dev, struct i40e_pf_vf *vf)
 {
@@ -1300,6 +1321,10 @@  i40e_pf_host_handle_vf_msg(struct rte_eth_dev *dev,
 		PMD_DRV_LOG(INFO, "OP_CFG_VLAN_PVID received");
 		i40e_pf_host_process_cmd_cfg_pvid(vf, msg, msglen, b_op);
 		break;
+	case I40E_VIRTCHNL_OP_RESET_STATS:
+		PMD_DRV_LOG(INFO, "OP_RESET_STATS received");
+		i40e_pf_host_process_cmd_reset_stats(vf, b_op);
+		break;
 	/* Don't add command supported below, which will
 	 * return an error code.
 	 */
diff --git a/drivers/net/i40e/i40e_pf.h b/drivers/net/i40e/i40e_pf.h
index b4c2287..69ef873 100644
--- a/drivers/net/i40e/i40e_pf.h
+++ b/drivers/net/i40e/i40e_pf.h
@@ -58,6 +58,7 @@  enum i40e_virtchnl_ops_dpdk {
 						I40E_DPDK_OFFSET,
 	I40E_VIRTCHNL_OP_CFG_VLAN_PVID,
 	I40E_VIRTCHNL_OP_CONFIG_VSI_QUEUES_EXT,
+	I40E_VIRTCHNL_OP_RESET_STATS,
 };
 
 /* A structure to support extended info of a receive queue. */