Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4830080ybl; Wed, 22 Jan 2020 05:31:50 -0800 (PST) X-Google-Smtp-Source: APXvYqx4NIQCXjoqGnGfKg9DRUPRwX8OOoHdIdqEwqfmSPBQb4wOYM0doCXzk1gAxTwfetT2jtYv X-Received: by 2002:aca:d483:: with SMTP id l125mr6636151oig.124.1579699910683; Wed, 22 Jan 2020 05:31:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579699910; cv=none; d=google.com; s=arc-20160816; b=qZyjTR8OPPrLECC2FOi6603RIw7jbbvM4v+iPkpFhqmqqiiOOHdf3bofq/iwrOPT0C xu3zDNKfjHPDVkojlyh4A5HNOl6jNfzhy+dbwpRMjQOQ8CmyQBO822gc6uKBlXlW9Xfo +5AY5FZDetOpBmi3XbIU8SAOUtwWdLsyusOBV5nVv3AQj6dxrk20hJl+nJuMA99rqFSQ b3eLYivnF5A8xkZRIiLphgic3TKtHg6iv2sObmCzWIHPgA1ihkIpsQ+JVTPKuQsLmXoX z7OGj3r7fp52lKg7VFOPN2cI2iCaHtMr2NbsXLYQbJpsmdFQbVfsxcYh2jqyAnhSP0Ab A+dA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=dN2/gUa4HY0DmyNqMPznNJIiPEQ/fpDrPsyWLSOWmwk=; b=sdetkOUUE1g4c2jYGLcUTqyYWewfaMmPaiOh3Vcd7KRKajIKTT0dvycdydM0F75euC keATg5u+h85IH28q8hbhMeoWltIE2VHS/sK10aOS++iPi1d9YlKbi+MzMvdPkGg68j8k K8gGU7inBDPAICuUqZgxrSZcTgGxTkyJTZgKis2C15jr49nR0VsGplb48K3sZKvbT9lM oE9hlCyHqIQWR/IPCAfdOHDzEMnQHGc1j3xnQEe73xVEeySXYAIjuP5oE09T8Ro/X7/J 1xCOrDXg663JNRTQHpJxGokeDsd4c8VAlwSLgixmAVcdhVZX2XrK1y7HRXahY/VQDDXD 3XYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KNvHkO5O; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k1si21319836oic.245.2020.01.22.05.31.36; Wed, 22 Jan 2020 05:31:50 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KNvHkO5O; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730234AbgAVNXx (ORCPT + 99 others); Wed, 22 Jan 2020 08:23:53 -0500 Received: from mail.kernel.org ([198.145.29.99]:42294 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726231AbgAVNXs (ORCPT ); Wed, 22 Jan 2020 08:23:48 -0500 Received: from localhost (unknown [84.241.205.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C18F824688; Wed, 22 Jan 2020 13:23:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579699427; bh=ZxYyBmcz/5wuirpUXUplrKtt/pbCq1dVIw7KyX/C3NU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KNvHkO5OM1c+9vpJvn6uF3c9+hSrx5e+79WIM+Arz8Shw6TrnQTWK+7243pq4muVY 74gBaevxNqHp7Hu4fwk0JuL6mI33DU/6svDOvbCw4vyS1BbXBmqgZj/MEsYL3W1FM6 IGSk0jirTYn157JRgzj5Pp3s36aG17WbBh4t7eZw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yunsheng Lin , Huazhong Tan , "David S. Miller" Subject: [PATCH 5.4 140/222] net: hns3: pad the short frame before sending to the hardware Date: Wed, 22 Jan 2020 10:28:46 +0100 Message-Id: <20200122092843.758942348@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200122092833.339495161@linuxfoundation.org> References: <20200122092833.339495161@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yunsheng Lin [ Upstream commit 36c67349a1a1c88b9cf11d7ca7762ababdb38867 ] 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 Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -54,6 +54,8 @@ MODULE_PARM_DESC(debug, " Network interf #define HNS3_INNER_VLAN_TAG 1 #define HNS3_OUTER_VLAN_TAG 2 +#define HNS3_MIN_TX_LEN 33U + /* hns3_pci_tbl - PCI Device ID Table * * Last entry must be all 0s @@ -1329,6 +1331,10 @@ netdev_tx_t hns3_nic_net_xmit(struct sk_ 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);