linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] bnxt_en: Fix logic of forward the VF MAC address to PF in bnxt_vf_validate_set_mac
@ 2018-07-24  5:24 YueHaibing
  2018-07-24  7:31 ` Michael Chan
  0 siblings, 1 reply; 5+ messages in thread
From: YueHaibing @ 2018-07-24  5:24 UTC (permalink / raw)
  To: davem, michael.chan; +Cc: linux-kernel, netdev, YueHaibing

Based on the comments,req->l2addr must match the VF MAC address
if firmware spec >= 1.2.2, mac_ok can be true.

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
index a649108..7925964 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
@@ -954,12 +954,9 @@ static int bnxt_vf_validate_set_mac(struct bnxt *bp, struct bnxt_vf_info *vf)
 		if (ether_addr_equal((const u8 *)req->l2_addr, vf->mac_addr))
 			mac_ok = true;
 	} else if (is_valid_ether_addr(vf->vf_mac_addr)) {
-		if (ether_addr_equal((const u8 *)req->l2_addr, vf->vf_mac_addr))
+		if (ether_addr_equal((const u8 *)req->l2_addr, vf->vf_mac_addr) &&
+		    bp->hwrm_spec_code >= 0x10202)
 			mac_ok = true;
-	} else if (bp->hwrm_spec_code < 0x10202) {
-		mac_ok = true;
-	} else {
-		mac_ok = true;
 	}
 	if (mac_ok)
 		return bnxt_hwrm_exec_fwd_resp(bp, vf, msg_size);
-- 
2.7.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next] bnxt_en: Fix logic of forward the VF MAC address to PF in bnxt_vf_validate_set_mac
  2018-07-24  5:24 [PATCH net-next] bnxt_en: Fix logic of forward the VF MAC address to PF in bnxt_vf_validate_set_mac YueHaibing
@ 2018-07-24  7:31 ` Michael Chan
  2018-07-24 16:01   ` Vasundhara Volam
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Chan @ 2018-07-24  7:31 UTC (permalink / raw)
  To: YueHaibing, Vasundhara Volam; +Cc: David Miller, open list, Netdev

On Mon, Jul 23, 2018 at 10:24 PM, YueHaibing <yuehaibing@huawei.com> wrote:
> Based on the comments,req->l2addr must match the VF MAC address
> if firmware spec >= 1.2.2, mac_ok can be true.
>
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> ---
>  drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
> index a649108..7925964 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
> @@ -954,12 +954,9 @@ static int bnxt_vf_validate_set_mac(struct bnxt *bp, struct bnxt_vf_info *vf)
>                 if (ether_addr_equal((const u8 *)req->l2_addr, vf->mac_addr))
>                         mac_ok = true;
>         } else if (is_valid_ether_addr(vf->vf_mac_addr)) {
> -               if (ether_addr_equal((const u8 *)req->l2_addr, vf->vf_mac_addr))
> +               if (ether_addr_equal((const u8 *)req->l2_addr, vf->vf_mac_addr) &&
> +                   bp->hwrm_spec_code >= 0x10202)
>                         mac_ok = true;

I'm not sure if this is correct.  If firmware spec < 0x10202, the VF
MAC address is not forwarded to the PF and so it doesn't have to match
and mac_ok should still be true.  I think we are missing that
condition with this patch.

I need to let my colleague Vasundhara comment on this.  She is more
familiar with this logic.

> -       } else if (bp->hwrm_spec_code < 0x10202) {
> -               mac_ok = true;
> -       } else {
> -               mac_ok = true;
>         }
>         if (mac_ok)
>                 return bnxt_hwrm_exec_fwd_resp(bp, vf, msg_size);
> --
> 2.7.0
>
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next] bnxt_en: Fix logic of forward the VF MAC address to PF in bnxt_vf_validate_set_mac
  2018-07-24  7:31 ` Michael Chan
@ 2018-07-24 16:01   ` Vasundhara Volam
  2018-07-24 21:48     ` Michael Chan
  0 siblings, 1 reply; 5+ messages in thread
From: Vasundhara Volam @ 2018-07-24 16:01 UTC (permalink / raw)
  To: Michael Chan; +Cc: YueHaibing, David Miller, open list, Netdev

On Tue, Jul 24, 2018 at 1:01 PM, Michael Chan <michael.chan@broadcom.com> wrote:
>
> On Mon, Jul 23, 2018 at 10:24 PM, YueHaibing <yuehaibing@huawei.com> wrote:
> > Based on the comments,req->l2addr must match the VF MAC address
> > if firmware spec >= 1.2.2, mac_ok can be true.
> >
> > Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> > ---
> >  drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c | 7 ++-----
> >  1 file changed, 2 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
> > index a649108..7925964 100644
> > --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
> > +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
> > @@ -954,12 +954,9 @@ static int bnxt_vf_validate_set_mac(struct bnxt *bp, struct bnxt_vf_info *vf)
> >                 if (ether_addr_equal((const u8 *)req->l2_addr, vf->mac_addr))
> >                         mac_ok = true;
> >         } else if (is_valid_ether_addr(vf->vf_mac_addr)) {
> > -               if (ether_addr_equal((const u8 *)req->l2_addr, vf->vf_mac_addr))
> > +               if (ether_addr_equal((const u8 *)req->l2_addr, vf->vf_mac_addr) &&
> > +                   bp->hwrm_spec_code >= 0x10202)
> >                         mac_ok = true;
>
> I'm not sure if this is correct.  If firmware spec < 0x10202, the VF
> MAC address is not forwarded to the PF and so it doesn't have to match
> and mac_ok should still be true.  I think we are missing that
> condition with this patch.
>
> I need to let my colleague Vasundhara comment on this.  She is more
> familiar with this logic.
Yes Michael, you are right. Also, the plain else condition is to cover
a special case to allow VF to modify
it's own MAC when PF has not assigned a valid MAC address and HWRM
spec code > 0x10202.
>
> > -       } else if (bp->hwrm_spec_code < 0x10202) {
> > -               mac_ok = true;
> > -       } else {
> > -               mac_ok = true;
> >         }
> >         if (mac_ok)
> >                 return bnxt_hwrm_exec_fwd_resp(bp, vf, msg_size);
> > --
> > 2.7.0
> >
> >

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next] bnxt_en: Fix logic of forward the VF MAC address to PF in bnxt_vf_validate_set_mac
  2018-07-24 16:01   ` Vasundhara Volam
@ 2018-07-24 21:48     ` Michael Chan
  2018-07-25 10:18       ` YueHaibing
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Chan @ 2018-07-24 21:48 UTC (permalink / raw)
  To: Vasundhara Volam; +Cc: YueHaibing, David Miller, open list, Netdev

On Tue, Jul 24, 2018 at 9:01 AM, Vasundhara Volam
<vasundhara-v.volam@broadcom.com> wrote:
> On Tue, Jul 24, 2018 at 1:01 PM, Michael Chan <michael.chan@broadcom.com> wrote:
>>
>> On Mon, Jul 23, 2018 at 10:24 PM, YueHaibing <yuehaibing@huawei.com> wrote:
>> > Based on the comments,req->l2addr must match the VF MAC address
>> > if firmware spec >= 1.2.2, mac_ok can be true.
>> >
>> > Signed-off-by: YueHaibing <yuehaibing@huawei.com>
>> > ---
>> >  drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c | 7 ++-----
>> >  1 file changed, 2 insertions(+), 5 deletions(-)
>> >
>> > diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
>> > index a649108..7925964 100644
>> > --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
>> > +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
>> > @@ -954,12 +954,9 @@ static int bnxt_vf_validate_set_mac(struct bnxt *bp, struct bnxt_vf_info *vf)
>> >                 if (ether_addr_equal((const u8 *)req->l2_addr, vf->mac_addr))
>> >                         mac_ok = true;
>> >         } else if (is_valid_ether_addr(vf->vf_mac_addr)) {
>> > -               if (ether_addr_equal((const u8 *)req->l2_addr, vf->vf_mac_addr))
>> > +               if (ether_addr_equal((const u8 *)req->l2_addr, vf->vf_mac_addr) &&
>> > +                   bp->hwrm_spec_code >= 0x10202)
>> >                         mac_ok = true;
>>
>> I'm not sure if this is correct.  If firmware spec < 0x10202, the VF
>> MAC address is not forwarded to the PF and so it doesn't have to match
>> and mac_ok should still be true.  I think we are missing that
>> condition with this patch.
>>
>> I need to let my colleague Vasundhara comment on this.  She is more
>> familiar with this logic.
> Yes Michael, you are right. Also, the plain else condition is to cover
> a special case to allow VF to modify
> it's own MAC when PF has not assigned a valid MAC address and HWRM
> spec code > 0x10202.

We should combine the "else if" and "else" below into a plain else and
add some comments to explain the conditions.

>>
>> > -       } else if (bp->hwrm_spec_code < 0x10202) {
>> > -               mac_ok = true;
>> > -       } else {
>> > -               mac_ok = true;
>> >         }
>> >         if (mac_ok)
>> >                 return bnxt_hwrm_exec_fwd_resp(bp, vf, msg_size);
>> > --
>> > 2.7.0
>> >
>> >

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next] bnxt_en: Fix logic of forward the VF MAC address to PF in bnxt_vf_validate_set_mac
  2018-07-24 21:48     ` Michael Chan
@ 2018-07-25 10:18       ` YueHaibing
  0 siblings, 0 replies; 5+ messages in thread
From: YueHaibing @ 2018-07-25 10:18 UTC (permalink / raw)
  To: Michael Chan, Vasundhara Volam; +Cc: David Miller, open list, Netdev

On 2018/7/25 5:48, Michael Chan wrote:
> On Tue, Jul 24, 2018 at 9:01 AM, Vasundhara Volam
> <vasundhara-v.volam@broadcom.com> wrote:
>> On Tue, Jul 24, 2018 at 1:01 PM, Michael Chan <michael.chan@broadcom.com> wrote:
>>>
>>> On Mon, Jul 23, 2018 at 10:24 PM, YueHaibing <yuehaibing@huawei.com> wrote:
>>>> Based on the comments,req->l2addr must match the VF MAC address
>>>> if firmware spec >= 1.2.2, mac_ok can be true.
>>>>
>>>> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
>>>> ---
>>>>  drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c | 7 ++-----
>>>>  1 file changed, 2 insertions(+), 5 deletions(-)
>>>>
>>>> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
>>>> index a649108..7925964 100644
>>>> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
>>>> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
>>>> @@ -954,12 +954,9 @@ static int bnxt_vf_validate_set_mac(struct bnxt *bp, struct bnxt_vf_info *vf)
>>>>                 if (ether_addr_equal((const u8 *)req->l2_addr, vf->mac_addr))
>>>>                         mac_ok = true;
>>>>         } else if (is_valid_ether_addr(vf->vf_mac_addr)) {
>>>> -               if (ether_addr_equal((const u8 *)req->l2_addr, vf->vf_mac_addr))
>>>> +               if (ether_addr_equal((const u8 *)req->l2_addr, vf->vf_mac_addr) &&
>>>> +                   bp->hwrm_spec_code >= 0x10202)
>>>>                         mac_ok = true;
>>>
>>> I'm not sure if this is correct.  If firmware spec < 0x10202, the VF
>>> MAC address is not forwarded to the PF and so it doesn't have to match
>>> and mac_ok should still be true.  I think we are missing that
>>> condition with this patch.
>>>
>>> I need to let my colleague Vasundhara comment on this.  She is more
>>> familiar with this logic.
>> Yes Michael, you are right. Also, the plain else condition is to cover
>> a special case to allow VF to modify
>> it's own MAC when PF has not assigned a valid MAC address and HWRM
>> spec code > 0x10202.
> 
> We should combine the "else if" and "else" below into a plain else and
> add some comments to explain the conditions.

Thank you for clarification.

I will send a new patch for this.

> 
>>>
>>>> -       } else if (bp->hwrm_spec_code < 0x10202) {
>>>> -               mac_ok = true;
>>>> -       } else {
>>>> -               mac_ok = true;
>>>>         }
>>>>         if (mac_ok)
>>>>                 return bnxt_hwrm_exec_fwd_resp(bp, vf, msg_size);
>>>> --
>>>> 2.7.0
>>>>
>>>>
> 
> .
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-07-25 10:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-24  5:24 [PATCH net-next] bnxt_en: Fix logic of forward the VF MAC address to PF in bnxt_vf_validate_set_mac YueHaibing
2018-07-24  7:31 ` Michael Chan
2018-07-24 16:01   ` Vasundhara Volam
2018-07-24 21:48     ` Michael Chan
2018-07-25 10:18       ` YueHaibing

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).