Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp349731ybb; Sat, 28 Mar 2020 00:13:35 -0700 (PDT) X-Google-Smtp-Source: ADFU+vu4y3ibjGyTKYBau8VIBDnBnZI6eAatALL3ZkWeaxiPUIrrPVyeZt9frUJ8mDOJxBjC2ji+ X-Received: by 2002:a05:6830:23bb:: with SMTP id m27mr1880593ots.195.1585379615649; Sat, 28 Mar 2020 00:13:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585379615; cv=none; d=google.com; s=arc-20160816; b=dUrhR7Ru31gC8VE3gbDRvNWIbZF/M/tnO7AjQBJuhN/6GA25T8LUA5cLdkWOq9f7Rn T1eFS92YdXMKAn2t5fzv9/4KPlkj7T0hNgvPHyazg70HsIuapFeOYrpLua+VP+Uqe5GV /3OJTUvDAY+xQXcjQnlPnGFU/fXFQok6v3XLkz8xAdMALCW30kOdemZ5dxKFTZxskVv7 Jh1ykOxIqyJwylF5cZL32AdJQ2QWCCtuiz4ZrM9nxLju1RRFMfYZoCR+ekMPE8KSQLJm FEoCs3DQS280AfWHad0bxTPTAaQRJOvvp6Tjmzih6yvRXfH7jbJ2/FRl6sxSRk9oEfxW /8mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=P2LAQPwwD6WCl6I7YnMUJA5q9H9naPeWJdMiIYbv+TM=; b=yopsIKWDSwIQIMVTz1H7B85ajGE3ckY2ebnL3tamJcs0N7cRBzK5Dpi9D1hkehIKi9 8oVBUUZ1TRDM4mnZkvEJw1Yoi1DcGHQKuKjbY9sN26Rt565GXwPUZSP0DV6+0dDjU6xS FxvAMffhrxxo6ggaW9EzpqT3b2RqKX58L3/avkI/cZrT1M4beka2yPxn/FPt0nHWUNog bUSwF55feQs3srtIgsZB3Kcf1CtWU/M/fpLJDIu4Jw0Bmv4bDu5Ht9bQbulFr5+Xxb+z pSSbxLJrKadV7m7q4oZ07bXoYWAxPr5pk27VWb4VOu8trv4LRf19V7GHq3kdMc1upjO4 0fpg== ARC-Authentication-Results: i=1; mx.google.com; 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 x1si3259388otq.201.2020.03.28.00.13.23; Sat, 28 Mar 2020 00:13:35 -0700 (PDT) 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; 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 S1726449AbgC1HLY (ORCPT + 99 others); Sat, 28 Mar 2020 03:11:24 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:35120 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725810AbgC1HLY (ORCPT ); Sat, 28 Mar 2020 03:11:24 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 8CC8DB7F545C39E14CDB; Sat, 28 Mar 2020 15:10:52 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.487.0; Sat, 28 Mar 2020 15:10:44 +0800 From: Huazhong Tan To: CC: , , , , , , Huazhong Tan , Yunsheng Lin Subject: [PATCH net 2/4] net: hns3: fix for fraglist SKB headlen not handling correctly Date: Sat, 28 Mar 2020 15:09:56 +0800 Message-ID: <1585379398-36224-3-git-send-email-tanhuazhong@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1585379398-36224-1-git-send-email-tanhuazhong@huawei.com> References: <1585379398-36224-1-git-send-email-tanhuazhong@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When the fraglist SKB headlen is larger than zero, current code still handle the fraglist SKB linear data as frag data, which may cause TX error. This patch adds a new DESC_TYPE_FRAGLIST_SKB type to handle the mapping and unmapping of the fraglist SKB linear data buffer. Fixes: 8ae10cfb5089 ("net: hns3: support tx-scatter-gather-fraglist feature") Signed-off-by: Yunsheng Lin Signed-off-by: Huazhong Tan --- drivers/net/ethernet/hisilicon/hns3/hnae3.h | 1 + drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h index a3e4081..5587605 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h @@ -78,6 +78,7 @@ enum hns_desc_type { DESC_TYPE_SKB, + DESC_TYPE_FRAGLIST_SKB, DESC_TYPE_PAGE, }; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index a7f40aa..6936384 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -1107,6 +1107,10 @@ static int hns3_fill_desc(struct hns3_enet_ring *ring, void *priv, return ret; dma = dma_map_single(dev, skb->data, size, DMA_TO_DEVICE); + } else if (type == DESC_TYPE_FRAGLIST_SKB) { + struct sk_buff *skb = (struct sk_buff *)priv; + + dma = dma_map_single(dev, skb->data, size, DMA_TO_DEVICE); } else { frag = (skb_frag_t *)priv; dma = skb_frag_dma_map(dev, frag, 0, size, DMA_TO_DEVICE); @@ -1144,8 +1148,9 @@ static int hns3_fill_desc(struct hns3_enet_ring *ring, void *priv, /* The txbd's baseinfo of DESC_TYPE_PAGE & DESC_TYPE_SKB */ desc_cb->priv = priv; desc_cb->dma = dma + HNS3_MAX_BD_SIZE * k; - desc_cb->type = (type == DESC_TYPE_SKB && !k) ? - DESC_TYPE_SKB : DESC_TYPE_PAGE; + desc_cb->type = ((type == DESC_TYPE_FRAGLIST_SKB || + type == DESC_TYPE_SKB) && !k) ? + type : DESC_TYPE_PAGE; /* now, fill the descriptor */ desc->addr = cpu_to_le64(dma + HNS3_MAX_BD_SIZE * k); @@ -1354,7 +1359,9 @@ static void hns3_clear_desc(struct hns3_enet_ring *ring, int next_to_use_orig) ring_ptr_move_bw(ring, next_to_use); /* unmap the descriptor dma address */ - if (ring->desc_cb[ring->next_to_use].type == DESC_TYPE_SKB) + if (ring->desc_cb[ring->next_to_use].type == DESC_TYPE_SKB || + ring->desc_cb[ring->next_to_use].type == + DESC_TYPE_FRAGLIST_SKB) dma_unmap_single(dev, ring->desc_cb[ring->next_to_use].dma, ring->desc_cb[ring->next_to_use].length, @@ -1447,7 +1454,8 @@ netdev_tx_t hns3_nic_net_xmit(struct sk_buff *skb, struct net_device *netdev) goto out; skb_walk_frags(skb, frag_skb) { - ret = hns3_fill_skb_to_desc(ring, frag_skb, DESC_TYPE_PAGE); + ret = hns3_fill_skb_to_desc(ring, frag_skb, + DESC_TYPE_FRAGLIST_SKB); if (unlikely(ret < 0)) goto fill_err; @@ -2356,7 +2364,7 @@ static int hns3_map_buffer(struct hns3_enet_ring *ring, struct hns3_desc_cb *cb) static void hns3_unmap_buffer(struct hns3_enet_ring *ring, struct hns3_desc_cb *cb) { - if (cb->type == DESC_TYPE_SKB) + if (cb->type == DESC_TYPE_SKB || cb->type == DESC_TYPE_FRAGLIST_SKB) dma_unmap_single(ring_to_dev(ring), cb->dma, cb->length, ring_to_dma_dir(ring)); else if (cb->length) -- 2.7.4