diff mbox series

[1/1,SRU,B] net: hns3: pad the short frame before sending to the hardware

Message ID 20200224164724.26030-2-taihsiang.ho@canonical.com
State New
Headers show
Series LP#1860320 -- Fix hns3 driver by padding the short frame before sending to the hardware | expand

Commit Message

Taihsiang Ho (tai271828) Feb. 24, 2020, 4:47 p.m. UTC
From: Yunsheng Lin <linyunsheng@huawei.com>

BugLink: http://bugs.launchpad.net/bugs/1860320

The hardware can not handle short frames below or equal to 32
bytes according to the hardware user manual, and it will trigger
a RAS error when the frame's length is below 33 bytes.

This patch pads the SKB when skb->len is below 33 bytes before
sending it to hardware.

Fixes: 76ad4f0ee747 ("net: hns3: Add support of HNS3 Ethernet Driver for hip08 SoC")
Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(backported from commit 36c67349a1a1c88b9cf11d7ca7762ababdb38867)
Signed-off-by: Taihsiang Ho (tai271828) <taihsiang.ho@canonical.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Kleber Sacilotto de Souza Feb. 25, 2020, 4:42 p.m. UTC | #1
On 24.02.20 17:47, Taihsiang Ho (tai271828) wrote:
> From: Yunsheng Lin <linyunsheng@huawei.com>
> 
> BugLink: http://bugs.launchpad.net/bugs/1860320
> 
> The hardware can not handle short frames below or equal to 32
> bytes according to the hardware user manual, and it will trigger
> a RAS error when the frame's length is below 33 bytes.
> 
> This patch pads the SKB when skb->len is below 33 bytes before
> sending it to hardware.
> 
> Fixes: 76ad4f0ee747 ("net: hns3: Add support of HNS3 Ethernet Driver for hip08 SoC")
> Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
> Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
> Signed-off-by: David S. Miller <davem@davemloft.net>
> (backported from commit 36c67349a1a1c88b9cf11d7ca7762ababdb38867)
> Signed-off-by: Taihsiang Ho (tai271828) <taihsiang.ho@canonical.com>

Clean cherry-pick and specific to platform driver.

Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>


Please nominate the bug report against the affected package and series
when sending kernel patches to the ML. I have fixed it adding the
nominations to linux -> bionic.

Is this patch needed for newer series as well?


Kleber


> ---
>  drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
> index a6b834c6d323..f5f24c065a8b 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
> @@ -32,6 +32,8 @@ static const char hns3_driver_string[] =
>  static const char hns3_copyright[] = "Copyright (c) 2017 Huawei Corporation.";
>  static struct hnae3_client client;
>  
> +#define HNS3_MIN_TX_LEN		33U
> +
>  /* hns3_pci_tbl - PCI Device ID Table
>   *
>   * Last entry must be all 0s
> @@ -1224,6 +1226,10 @@ netdev_tx_t hns3_nic_net_xmit(struct sk_buff *skb, struct net_device *netdev)
>  	int ret;
>  	int i;
>  
> +	/* Hardware can only handle short frames above 32 bytes */
> +	if (skb_put_padto(skb, HNS3_MIN_TX_LEN))
> +		return NETDEV_TX_OK;
> +
>  	/* Prefetch the data used later */
>  	prefetch(skb->data);
>  
>
Taihsiang Ho (tai271828) Feb. 26, 2020, 2:14 p.m. UTC | #2
Hi Kleber,

Thank you for your comments, reminder, and the help of nomination. I will
nominate the bug report against the affected package and series next time.
Nominating linux->bionic is sufficient. The patch has been in newer series.

Kind regards,
Tai

On Tue, Feb 25, 2020 at 5:42 PM Kleber Souza <kleber.souza@canonical.com>
wrote:

> On 24.02.20 17:47, Taihsiang Ho (tai271828) wrote:
> > From: Yunsheng Lin <linyunsheng@huawei.com>
> >
> > BugLink: http://bugs.launchpad.net/bugs/1860320
> >
> > The hardware can not handle short frames below or equal to 32
> > bytes according to the hardware user manual, and it will trigger
> > a RAS error when the frame's length is below 33 bytes.
> >
> > This patch pads the SKB when skb->len is below 33 bytes before
> > sending it to hardware.
> >
> > Fixes: 76ad4f0ee747 ("net: hns3: Add support of HNS3 Ethernet Driver for
> hip08 SoC")
> > Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
> > Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
> > Signed-off-by: David S. Miller <davem@davemloft.net>
> > (backported from commit 36c67349a1a1c88b9cf11d7ca7762ababdb38867)
> > Signed-off-by: Taihsiang Ho (tai271828) <taihsiang.ho@canonical.com>
>
> Clean cherry-pick and specific to platform driver.
>
> Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
>
>
> Please nominate the bug report against the affected package and series
> when sending kernel patches to the ML. I have fixed it adding the
> nominations to linux -> bionic.
>
> Is this patch needed for newer series as well?
>
>
> Kleber
>
>
> > ---
> >  drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 6 ++++++
> >  1 file changed, 6 insertions(+)
> >
> > diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
> b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
> > index a6b834c6d323..f5f24c065a8b 100644
> > --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
> > +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
> > @@ -32,6 +32,8 @@ static const char hns3_driver_string[] =
> >  static const char hns3_copyright[] = "Copyright (c) 2017 Huawei
> Corporation.";
> >  static struct hnae3_client client;
> >
> > +#define HNS3_MIN_TX_LEN              33U
> > +
> >  /* hns3_pci_tbl - PCI Device ID Table
> >   *
> >   * Last entry must be all 0s
> > @@ -1224,6 +1226,10 @@ netdev_tx_t hns3_nic_net_xmit(struct sk_buff
> *skb, struct net_device *netdev)
> >       int ret;
> >       int i;
> >
> > +     /* Hardware can only handle short frames above 32 bytes */
> > +     if (skb_put_padto(skb, HNS3_MIN_TX_LEN))
> > +             return NETDEV_TX_OK;
> > +
> >       /* Prefetch the data used later */
> >       prefetch(skb->data);
> >
> >
>
>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index a6b834c6d323..f5f24c065a8b 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -32,6 +32,8 @@  static const char hns3_driver_string[] =
 static const char hns3_copyright[] = "Copyright (c) 2017 Huawei Corporation.";
 static struct hnae3_client client;
 
+#define HNS3_MIN_TX_LEN		33U
+
 /* hns3_pci_tbl - PCI Device ID Table
  *
  * Last entry must be all 0s
@@ -1224,6 +1226,10 @@  netdev_tx_t hns3_nic_net_xmit(struct sk_buff *skb, struct net_device *netdev)
 	int ret;
 	int i;
 
+	/* Hardware can only handle short frames above 32 bytes */
+	if (skb_put_padto(skb, HNS3_MIN_TX_LEN))
+		return NETDEV_TX_OK;
+
 	/* Prefetch the data used later */
 	prefetch(skb->data);