]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
net: hns3: fix the descriptor index when get rss type
authorPeng Li <lipeng321@huawei.com>
Thu, 20 Dec 2018 03:52:05 +0000 (11:52 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 12 Feb 2019 19:02:24 +0000 (20:02 +0100)
[ Upstream commit 31a16f99e02c2e0b40a5fb05d66f5e56721027e2 ]

Driver gets rss information from the last descriptor of the packet.
When driver handle the rss type, ring->next_to_clean indicates the
first descriptor of next packet.

This patch fix the descriptor index with "ring->next_to_clean - 1".

Fixes: 232fc64b6e62 ("net: hns3: Add HW RSS hash information to RX skb")
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c

index beb5dbd5e98dea8be775492f9cd288c0f68aa765..d424d5bc050790763e96f12530b794c8a7489e15 100644 (file)
@@ -2332,9 +2332,16 @@ static bool hns3_parse_vlan_tag(struct hns3_enet_ring *ring,
 static void hns3_set_rx_skb_rss_type(struct hns3_enet_ring *ring,
                                     struct sk_buff *skb)
 {
-       struct hns3_desc *desc = &ring->desc[ring->next_to_clean];
        struct hnae3_handle *handle = ring->tqp->handle;
        enum pkt_hash_types rss_type;
+       struct hns3_desc *desc;
+       int last_bd;
+
+       /* When driver handle the rss type, ring->next_to_clean indicates the
+        * first descriptor of next packet, need -1 here.
+        */
+       last_bd = (ring->next_to_clean - 1 + ring->desc_num) % ring->desc_num;
+       desc = &ring->desc[last_bd];
 
        if (le32_to_cpu(desc->rx.rss_hash))
                rss_type = handle->kinfo.rss_type;