From patchwork Fri Feb 21 11:55:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Taihsiang Ho (tai271828)" X-Patchwork-Id: 1242055 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48P8zZ2v0zz9sRl; Fri, 21 Feb 2020 22:55:37 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1j56u3-0001nZ-R7; Fri, 21 Feb 2020 11:55:31 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1j56u1-0001nI-Ay for kernel-team@lists.ubuntu.com; Fri, 21 Feb 2020 11:55:29 +0000 Received: from mail-pf1-f199.google.com ([209.85.210.199]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1j56u0-0003lg-UZ for kernel-team@lists.ubuntu.com; Fri, 21 Feb 2020 11:55:29 +0000 Received: by mail-pf1-f199.google.com with SMTP id x10so1128393pfn.4 for ; Fri, 21 Feb 2020 03:55:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=D+7BIw1V2+I1VzrZAFdjGip7Y5bben3xYHRdLxJbe5Q=; b=dUY2E5wkk2AzupBAmzg9HO2ovjfvJEv0sdsiXGwAaJP8tAFAsYJcX0pNclpw3GPXef CBXQeUk9NYJJgbSn6t8CD9HLnBYmH8bt2Uv0ud+dYQGi1YaR249EFAWuqmYAk0CbymWZ X2znBUXFXEALAMsf2EvNc4uDY6y7HQmd+jHM2m6n9wDvWNdbMTrH2i0HD9r9OLgeH5q1 sX1hwiSVJZJFlk+kXQ2JicsjyJBNBy9gBRTF2MQXGot7feURL2jxq9AozumhsAHIVMLd DsLLrjN+kNIZvLOAIpUPT2G2NfY2aT3TVLqtFMeCDk6Op7/I1iOPtyYwivTx7N342fCY szQw== X-Gm-Message-State: APjAAAX+1Yxsi3fd9D/ZL0qvcsejsjJX6CQt8jDWnrTACAiCWgwIsxoB XeW66YUpJdtDee/YnkI94enXossrBaCQUAxiePqUCX7QQKaT/ThwTYKdMZHPMUS2yCGAMrBnxGG dET7BGVwrXygFJ/XNd9sWu8wR8IWqsgpKAR8z2fd9ww== X-Received: by 2002:a17:90a:af81:: with SMTP id w1mr2851328pjq.14.1582286127212; Fri, 21 Feb 2020 03:55:27 -0800 (PST) X-Google-Smtp-Source: APXvYqwl1GCu3nAStpLGlO7nyXfz8i2Fdwmv3Kk8qG60FhCxn6Nx1j5HuuDvp6XKKYCUegFZk14qBA== X-Received: by 2002:a17:90a:af81:: with SMTP id w1mr2851305pjq.14.1582286126801; Fri, 21 Feb 2020 03:55:26 -0800 (PST) Received: from localhost.localdomain (2001-b400-e23d-31f7-24b0-89a7-8589-dfc8.emome-ip6.hinet.net. [2001:b400:e23d:31f7:24b0:89a7:8589:dfc8]) by smtp.gmail.com with ESMTPSA id m187sm2261513pga.65.2020.02.21.03.55.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Feb 2020 03:55:26 -0800 (PST) From: "Taihsiang Ho (tai271828)" To: kernel-team@lists.ubuntu.com Subject: [PATCH][SRU][B] net: hns3: pad the short frame before sending to the hardware Date: Fri, 21 Feb 2020 19:55:21 +0800 Message-Id: <20200221115521.13448-1-taihsiang.ho@canonical.com> X-Mailer: git-send-email 2.17.1 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Yunsheng Lin 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 Signed-off-by: Huazhong Tan Signed-off-by: David S. Miller (backported from commit 36c67349a1a1c88b9cf11d7ca7762ababdb38867) Signed-off-by: Taihsiang Ho (tai271828) --- 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);