LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] ethernet: fm10k: Actually drop 4 bits
@ 2015-01-22 22:53 Rasmus Villemoes
  2015-01-23  3:27 ` Jeff Kirsher
  2015-01-24  0:18 ` Vick, Matthew
  0 siblings, 2 replies; 5+ messages in thread
From: Rasmus Villemoes @ 2015-01-22 22:53 UTC (permalink / raw)
  To: Alexander Duyck, Jeff Kirsher
  Cc: Rasmus Villemoes, e1000-devel, netdev, linux-kernel

The comment explains the intention, but vid has type u16. Before the
inner shift, it is promoted to int, which has plenty of space for all
vid's bits, so nothing is dropped. Use a simple mask instead.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
 drivers/net/ethernet/intel/fm10k/fm10k_pf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_pf.c b/drivers/net/ethernet/intel/fm10k/fm10k_pf.c
index 275423d4f777..b1c57d0166a9 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_pf.c
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_pf.c
@@ -335,7 +335,7 @@ static s32 fm10k_update_xc_addr_pf(struct fm10k_hw *hw, u16 glort,
 		return FM10K_ERR_PARAM;
 
 	/* drop upper 4 bits of VLAN ID */
-	vid = (vid << 4) >> 4;
+	vid &= 0x0fff;
 
 	/* record fields */
 	mac_update.mac_lower = cpu_to_le32(((u32)mac[2] << 24) |
-- 
2.1.3


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

* Re: [PATCH] ethernet: fm10k: Actually drop 4 bits
  2015-01-22 22:53 [PATCH] ethernet: fm10k: Actually drop 4 bits Rasmus Villemoes
@ 2015-01-23  3:27 ` Jeff Kirsher
  2015-01-24  0:18 ` Vick, Matthew
  1 sibling, 0 replies; 5+ messages in thread
From: Jeff Kirsher @ 2015-01-23  3:27 UTC (permalink / raw)
  To: Rasmus Villemoes; +Cc: Alexander Duyck, e1000-devel, netdev, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 501 bytes --]

On Thu, 2015-01-22 at 23:53 +0100, Rasmus Villemoes wrote:
> The comment explains the intention, but vid has type u16. Before the
> inner shift, it is promoted to int, which has plenty of space for all
> vid's bits, so nothing is dropped. Use a simple mask instead.
> 
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> ---
>  drivers/net/ethernet/intel/fm10k/fm10k_pf.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Thanks Rasmus, I will add your patch to my queue.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH] ethernet: fm10k: Actually drop 4 bits
  2015-01-22 22:53 [PATCH] ethernet: fm10k: Actually drop 4 bits Rasmus Villemoes
  2015-01-23  3:27 ` Jeff Kirsher
@ 2015-01-24  0:18 ` Vick, Matthew
  2015-01-24  0:50   ` Rasmus Villemoes
  1 sibling, 1 reply; 5+ messages in thread
From: Vick, Matthew @ 2015-01-24  0:18 UTC (permalink / raw)
  To: Rasmus Villemoes, Alexander Duyck, Kirsher, Jeffrey T
  Cc: e1000-devel, netdev, linux-kernel

On 1/22/15, 2:53 PM, "Rasmus Villemoes" <linux@rasmusvillemoes.dk> wrote:

>The comment explains the intention, but vid has type u16. Before the
>inner shift, it is promoted to int, which has plenty of space for all
>vid's bits, so nothing is dropped. Use a simple mask instead.
>
>Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
>---
> drivers/net/ethernet/intel/fm10k/fm10k_pf.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_pf.c
>b/drivers/net/ethernet/intel/fm10k/fm10k_pf.c
>index 275423d4f777..b1c57d0166a9 100644
>--- a/drivers/net/ethernet/intel/fm10k/fm10k_pf.c
>+++ b/drivers/net/ethernet/intel/fm10k/fm10k_pf.c
>@@ -335,7 +335,7 @@ static s32 fm10k_update_xc_addr_pf(struct fm10k_hw
>*hw, u16 glort,
> 		return FM10K_ERR_PARAM;
> 
> 	/* drop upper 4 bits of VLAN ID */
>-	vid = (vid << 4) >> 4;
>+	vid &= 0x0fff;
> 
> 	/* record fields */
> 	mac_update.mac_lower = cpu_to_le32(((u32)mac[2] << 24) |

Good catch! I noticed this too and was getting a patch together to address
this.

The difference is that I was planning on not silently accepting an invalid
VLAN ID to begin with and returning FM10K_ERR_PARAM if the VLAN was
invalid, which I think is a better approach for this situation. If it's
alright with you, I'll generate the patch shortly and credit you via your
Reported-by.

Cheers,
Matthew


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

* Re: [PATCH] ethernet: fm10k: Actually drop 4 bits
  2015-01-24  0:18 ` Vick, Matthew
@ 2015-01-24  0:50   ` Rasmus Villemoes
  2015-01-26 16:58     ` Vick, Matthew
  0 siblings, 1 reply; 5+ messages in thread
From: Rasmus Villemoes @ 2015-01-24  0:50 UTC (permalink / raw)
  To: Vick, Matthew
  Cc: Alexander Duyck, Kirsher, Jeffrey T, e1000-devel, netdev, linux-kernel

On Sat, Jan 24 2015, "Vick, Matthew" <matthew.vick@intel.com> wrote:

> Good catch! I noticed this too and was getting a patch together to address
> this.
>
> The difference is that I was planning on not silently accepting an invalid
> VLAN ID to begin with and returning FM10K_ERR_PARAM if the VLAN was
> invalid, which I think is a better approach for this situation. If it's
> alright with you, I'll generate the patch shortly and credit you via your
> Reported-by.

Sure, do what you think is best.

Rasmus

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

* Re: [PATCH] ethernet: fm10k: Actually drop 4 bits
  2015-01-24  0:50   ` Rasmus Villemoes
@ 2015-01-26 16:58     ` Vick, Matthew
  0 siblings, 0 replies; 5+ messages in thread
From: Vick, Matthew @ 2015-01-26 16:58 UTC (permalink / raw)
  To: Rasmus Villemoes
  Cc: Alexander Duyck, Kirsher, Jeffrey T, e1000-devel, netdev, linux-kernel

On 1/23/15, 4:50 PM, "Rasmus Villemoes" <linux@rasmusvillemoes.dk> wrote:

>On Sat, Jan 24 2015, "Vick, Matthew" <matthew.vick@intel.com> wrote:
>
>> Good catch! I noticed this too and was getting a patch together to
>>address
>> this.
>>
>> The difference is that I was planning on not silently accepting an
>>invalid
>> VLAN ID to begin with and returning FM10K_ERR_PARAM if the VLAN was
>> invalid, which I think is a better approach for this situation. If it's
>> alright with you, I'll generate the patch shortly and credit you via
>>your
>> Reported-by.
>
>Sure, do what you think is best.
>
>Rasmus

Sounds good. I'll get the patch created and validated through Jeff's tree.

Cheers,
Matthew


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

end of thread, other threads:[~2015-01-26 16:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-22 22:53 [PATCH] ethernet: fm10k: Actually drop 4 bits Rasmus Villemoes
2015-01-23  3:27 ` Jeff Kirsher
2015-01-24  0:18 ` Vick, Matthew
2015-01-24  0:50   ` Rasmus Villemoes
2015-01-26 16:58     ` Vick, Matthew

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).