From patchwork Wed May 9 16:24:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 135308 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp5842193lji; Wed, 9 May 2018 09:26:34 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqKMFowaXDXi1viGNnEeZ90uTQ77gFE8TZ0gSxkRNOMvvkDsAbXt/WJjwLZeHjvtrcml3EM X-Received: by 2002:a17:902:4303:: with SMTP id i3-v6mr47547881pld.394.1525883194750; Wed, 09 May 2018 09:26:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525883194; cv=none; d=google.com; s=arc-20160816; b=XEeHxyXWpU1TqTVXsVyCLOYkCnChKdEZY151avmTF7xjgaBK/EcNuMJlNKTuBntGBV Rxz/8NAhlJ4SQ7UnV2EiXPQCBtatdroS75Yzyo47Mi/GOblRszvfnz0zbfMOeN2nd1ey HTpGA0cycoApx9gPkLoaz4jI/PZMiuOjEJD+kJzj8B3u6nEAUpMdlBF6UEKTx9GlhjOd h04c9SVG8CXPYo7n7NXBa/Cv/YCwOa2GiV8Brn0WRnS6uRPX2NS+EGTHrvXWMnhg96sN XieLht7aXDL6ZLZYW9hvXY/Qcsuf/SCINoLepoa7/dcgeB5uwtxJoIO+HCkT4l0vdYyJ D07Q== 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:arc-authentication-results; bh=aKA0glO01VDpZZ7EwaO53HUURfyvOTFAFh/FWMrKDzM=; b=hdoC9QJlpYXiiti1I8HUIVjMmC3q+dzuAeV5+fKc/J1URgoU9zIDW+X8EOc3WvwFjr njW76x8Ys2rxZCLvsRdJoRJ0CjWTpbWKxpwJPgyvC9I6BO9Uou9In60lMMk4CURqE4OS /q6zwuv3mYo3bFelANMryUHUEzoVXwmtCSvcg0aylST/ZRzgAQ1uoYgPxycWLRDc+Y+b JIRRug1Ff1IJfGwW/I3rYXqt9J4jX1dqO/4uvXaItQUDH5DIYBBc5Pcpal/KS9a5Pydr 9061kugRBWywCuAsiPH3xK+XRQ/qTBKTnwTFiCHgWjAFShgcBtPsDGNJfgANCXpDIjJR wm2g== 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 b6-v6si27073142plm.153.2018.05.09.09.26.34; Wed, 09 May 2018 09:26:34 -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 S965589AbeEIQ0Y (ORCPT + 29 others); Wed, 9 May 2018 12:26:24 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:7663 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S965532AbeEIQ0W (ORCPT ); Wed, 9 May 2018 12:26:22 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id E49D9D63E23C5; Thu, 10 May 2018 00:26:08 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.202.227.234) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.361.1; Thu, 10 May 2018 00:25:59 +0800 From: Salil Mehta To: CC: , , , , , , , Yunsheng Lin Subject: [PATCH net-next 1/4] net: hns3: Fix for setting mac address when resetting Date: Wed, 9 May 2018 17:24:38 +0100 Message-ID: <20180509162441.18068-2-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20180509162441.18068-1-salil.mehta@huawei.com> References: <20180509162441.18068-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.234] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yunsheng Lin When hns3_init_mac_addr is called during reset process, it will get the mac address from NCL_CONFIG and set it to hardware. If user has changed the mac address, then the mac address set by user is lost during resetting. This patch fixes it by not getting the mac address from NCL_CONFIG when resetting. Fixes: 424eb834a9be ("net: hns3: Unified HNS3 {VF|PF} Ethernet Driver for hip08 SoC") Signed-off-by: Yunsheng Lin Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 729bcab..a55c8f515 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -3046,13 +3046,13 @@ int hns3_uninit_all_ring(struct hns3_nic_priv *priv) } /* Set mac addr if it is configured. or leave it to the AE driver */ -static void hns3_init_mac_addr(struct net_device *netdev) +static void hns3_init_mac_addr(struct net_device *netdev, bool init) { struct hns3_nic_priv *priv = netdev_priv(netdev); struct hnae3_handle *h = priv->ae_handle; u8 mac_addr_temp[ETH_ALEN]; - if (h->ae_algo->ops->get_mac_addr) { + if (h->ae_algo->ops->get_mac_addr && init) { h->ae_algo->ops->get_mac_addr(h, mac_addr_temp); ether_addr_copy(netdev->dev_addr, mac_addr_temp); } @@ -3106,7 +3106,7 @@ static int hns3_client_init(struct hnae3_handle *handle) handle->kinfo.netdev = netdev; handle->priv = (void *)priv; - hns3_init_mac_addr(netdev); + hns3_init_mac_addr(netdev, true); hns3_set_default_feature(netdev); @@ -3353,7 +3353,7 @@ static int hns3_reset_notify_init_enet(struct hnae3_handle *handle) struct hns3_nic_priv *priv = netdev_priv(netdev); int ret; - hns3_init_mac_addr(netdev); + hns3_init_mac_addr(netdev, false); hns3_nic_set_rx_mode(netdev); hns3_recover_hw_addr(netdev); From patchwork Wed May 9 16:24:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 135309 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp5842364lji; Wed, 9 May 2018 09:26:46 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoV8aokzaZxdxHjucKNHhIs8cqA4RXAY665tyqlTpMKxDdxsyBwKHezhLIwwikf7qa5H90f X-Received: by 2002:a63:63c5:: with SMTP id x188-v6mr4320768pgb.302.1525883206046; Wed, 09 May 2018 09:26:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525883206; cv=none; d=google.com; s=arc-20160816; b=Zbik17/0T91zdXt/g3wtO3DYToz8EFzhpdABJbJ8KFw5IbwYS96rGDH8ow9PYNrSVD 5DaZebwQbBQjqCO9QbZANVNbsFJAncP1Kp80Bx4bSyaNyU1XuP+p7trukZt+LQPvKJpl mOvkCBv1ktgrbUJUQ14xGuNLzyQ0P2Fwqvd40/ImNfHoqwfaK1hazqfNVl73/ElFGujN YZLkcwrvGwUeiRONFRD9SkDEHDU7wl8umfsu63tf9LUr984DlTs6pEv0OTFu1bOsiuT+ sP6b7J6UiaJJGV1s0Lf6fecY70Owh3JsWb04Q8Sy3f+yTaneVZkfzvDBC0vDwhzVdG6Y QjYQ== 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:arc-authentication-results; bh=4ePW8GIEmlSbeyJ/8dziyLWTVPXlKHpJ3ERjtcyQ9ls=; b=hj67C9Z04Rb23alCAtK3XB6GoDBHkOopAoNpsxKyrEdIqxdnpRxV9hjuXdeyShvU2Z VaehO9b879L4JRlWoTLYMyGnxuFAOKR95WChMzU7WZNEzBVu+twgyjxjnP1tg/Ll5KZc B3Y/HWF9IuvyRBVwt/eujZc2vIB6LYkaR8pn6gew/ClIobPm7vIdhPyqwRLtvZk1jjMu FOg0vQrxZD1ezdZmOmrcTeM/i+ib4Op8wiTZdzbCwZ39dHo+jhTUV8sB9v1vNZoyQHxF yOyJtPmJW7Juy9Lc4/L+3KyvKIYBdaioCSC6Ma2i8O6STyrz476GIEqHVBuQkKVEg2C2 sivw== 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 y12si25962765pfl.283.2018.05.09.09.26.45; Wed, 09 May 2018 09:26:46 -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 S965605AbeEIQ0o (ORCPT + 29 others); Wed, 9 May 2018 12:26:44 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:7664 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S965558AbeEIQ0X (ORCPT ); Wed, 9 May 2018 12:26:23 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id D60C9BDC5697E; Thu, 10 May 2018 00:26:08 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.202.227.234) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.361.1; Thu, 10 May 2018 00:26:02 +0800 From: Salil Mehta To: CC: , , , , , , , Yunsheng Lin Subject: [PATCH net-next 2/4] net: hns3: remove add/del_tunnel_udp in hns3_enet module Date: Wed, 9 May 2018 17:24:39 +0100 Message-ID: <20180509162441.18068-3-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20180509162441.18068-1-salil.mehta@huawei.com> References: <20180509162441.18068-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.234] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yunsheng Lin The add/del_tunnel_udp is not implemented in hclge_main moulde, the NETIF_F_RX_UDP_TUNNEL_PORT feature bit is added automatically by stack when ndo_udp_tunnel_add is not null in dev->netdev_ops. This patch removes the add/del_tunnel_udp related function, for we do not support this feature now. Signed-off-by: Yunsheng Lin Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hnae3.h | 7 -- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 89 ------------------------- 2 files changed, 96 deletions(-) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h index 37ec1b3..804ea83 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h @@ -273,10 +273,6 @@ struct hnae3_ae_dev { * Map rings to vector * unmap_ring_from_vector() * Unmap rings from vector - * add_tunnel_udp() - * Add tunnel information to hardware - * del_tunnel_udp() - * Delete tunnel information from hardware * reset_queue() * Reset queue * get_fw_version() @@ -388,9 +384,6 @@ struct hnae3_ae_ops { int vector_num, struct hnae3_ring_chain_node *vr_chain); - int (*add_tunnel_udp)(struct hnae3_handle *handle, u16 port_num); - int (*del_tunnel_udp)(struct hnae3_handle *handle, u16 port_num); - void (*reset_queue)(struct hnae3_handle *handle, u16 queue_id); u32 (*get_fw_version)(struct hnae3_handle *handle); void (*get_mdix_mode)(struct hnae3_handle *handle, diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index a55c8f515..bd8e14b 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -1244,93 +1244,6 @@ static void hns3_nic_get_stats64(struct net_device *netdev, stats->tx_compressed = netdev->stats.tx_compressed; } -static void hns3_add_tunnel_port(struct net_device *netdev, u16 port, - enum hns3_udp_tnl_type type) -{ - struct hns3_nic_priv *priv = netdev_priv(netdev); - struct hns3_udp_tunnel *udp_tnl = &priv->udp_tnl[type]; - struct hnae3_handle *h = priv->ae_handle; - - if (udp_tnl->used && udp_tnl->dst_port == port) { - udp_tnl->used++; - return; - } - - if (udp_tnl->used) { - netdev_warn(netdev, - "UDP tunnel [%d], port [%d] offload\n", type, port); - return; - } - - udp_tnl->dst_port = port; - udp_tnl->used = 1; - /* TBD send command to hardware to add port */ - if (h->ae_algo->ops->add_tunnel_udp) - h->ae_algo->ops->add_tunnel_udp(h, port); -} - -static void hns3_del_tunnel_port(struct net_device *netdev, u16 port, - enum hns3_udp_tnl_type type) -{ - struct hns3_nic_priv *priv = netdev_priv(netdev); - struct hns3_udp_tunnel *udp_tnl = &priv->udp_tnl[type]; - struct hnae3_handle *h = priv->ae_handle; - - if (!udp_tnl->used || udp_tnl->dst_port != port) { - netdev_warn(netdev, - "Invalid UDP tunnel port %d\n", port); - return; - } - - udp_tnl->used--; - if (udp_tnl->used) - return; - - udp_tnl->dst_port = 0; - /* TBD send command to hardware to del port */ - if (h->ae_algo->ops->del_tunnel_udp) - h->ae_algo->ops->del_tunnel_udp(h, port); -} - -/* hns3_nic_udp_tunnel_add - Get notifiacetion about UDP tunnel ports - * @netdev: This physical ports's netdev - * @ti: Tunnel information - */ -static void hns3_nic_udp_tunnel_add(struct net_device *netdev, - struct udp_tunnel_info *ti) -{ - u16 port_n = ntohs(ti->port); - - switch (ti->type) { - case UDP_TUNNEL_TYPE_VXLAN: - hns3_add_tunnel_port(netdev, port_n, HNS3_UDP_TNL_VXLAN); - break; - case UDP_TUNNEL_TYPE_GENEVE: - hns3_add_tunnel_port(netdev, port_n, HNS3_UDP_TNL_GENEVE); - break; - default: - netdev_err(netdev, "unsupported tunnel type %d\n", ti->type); - break; - } -} - -static void hns3_nic_udp_tunnel_del(struct net_device *netdev, - struct udp_tunnel_info *ti) -{ - u16 port_n = ntohs(ti->port); - - switch (ti->type) { - case UDP_TUNNEL_TYPE_VXLAN: - hns3_del_tunnel_port(netdev, port_n, HNS3_UDP_TNL_VXLAN); - break; - case UDP_TUNNEL_TYPE_GENEVE: - hns3_del_tunnel_port(netdev, port_n, HNS3_UDP_TNL_GENEVE); - break; - default: - break; - } -} - static int hns3_setup_tc(struct net_device *netdev, void *type_data) { struct tc_mqprio_qopt_offload *mqprio_qopt = type_data; @@ -1569,8 +1482,6 @@ static const struct net_device_ops hns3_nic_netdev_ops = { .ndo_get_stats64 = hns3_nic_get_stats64, .ndo_setup_tc = hns3_nic_setup_tc, .ndo_set_rx_mode = hns3_nic_set_rx_mode, - .ndo_udp_tunnel_add = hns3_nic_udp_tunnel_add, - .ndo_udp_tunnel_del = hns3_nic_udp_tunnel_del, .ndo_vlan_rx_add_vid = hns3_vlan_rx_add_vid, .ndo_vlan_rx_kill_vid = hns3_vlan_rx_kill_vid, .ndo_set_vf_vlan = hns3_ndo_set_vf_vlan, From patchwork Wed May 9 16:24:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 135307 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp5842187lji; Wed, 9 May 2018 09:26:34 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr6/cMN6JrVdS0mNArXRc1xrE4JKjBty4dslvFzBL4DA2aFduRw1Pm8Hgp2eO1QC+H6ms6s X-Received: by 10.98.220.78 with SMTP id t75mr44371064pfg.139.1525883194386; Wed, 09 May 2018 09:26:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525883194; cv=none; d=google.com; s=arc-20160816; b=ZGyV901sdH6yGc2pz9V7AB+lfPDlZjWMYxwYFZi4yATm/On09dzafrSkHLdk/Q2ICe AZboFxpc+hpuJAFnz0JKjLDD8ogI/yrhjQXswitZYG82JpUYlfGH2kX7kC0XtOWvSZzD sfih3qcDJwSTjmgc68vEnCWA5pbTznrDLiGoIZ8f4oaDC0OeKsJFF09+H9W9en3OnT4O +GTP++pcRAFqnVHOxgHsPmbG/PNt5aythtlZihs1a2wKzA8gcNuebRBl3SqDPrbI4Ak+ RaWJL7iJHokrcnQgWi9mhFeCPMrjcOl6WC4dYxfubxh4XN3UtHqZxN170HpxZGpm83cJ cZaQ== 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:arc-authentication-results; bh=ZOMrEfqghoLZ0BJkARNzMkmzZkBuBytprGPd8FuoFJ0=; b=gDHGh8V33rtwLzPMeyodg6BHlw0CaYLYwXcYKpAD7CWO4k4FTUZKpPkHFq4OHRjyLx al7fjQAqEBR0XZ0hnm1sE7enouSz490llwbVK35IvD+MAJBfn6U7kIushHkZcvTXVoCs 9+VsoTtfzREA/FDNkCtd7AEOjukDG4Pf5cJjXc9JjTOTvjzgtDpDC0EGFvDPWCbSicQa B//mmTNsnw7Lgbs4TiYyYxTgFOEXmM5Dmdp7pZMrV0bzQ0L2don/qwTKH9AG5/8isAYg 9o5GjA3d1Jwj3GN6eT7q4T0gLKnC2Vc/qaLYKlwMnUU7VpOVs50wPYluKsetVSziaiXw hDJw== 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 b6-v6si27073142plm.153.2018.05.09.09.26.34; Wed, 09 May 2018 09:26:34 -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 S965571AbeEIQ0W (ORCPT + 29 others); Wed, 9 May 2018 12:26:22 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:42813 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S965513AbeEIQ0R (ORCPT ); Wed, 9 May 2018 12:26:17 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 884E8CB17C4DD; Thu, 10 May 2018 00:26:14 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.202.227.234) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.361.1; Thu, 10 May 2018 00:26:05 +0800 From: Salil Mehta To: CC: , , , , , , , Yunsheng Lin Subject: [PATCH net-next 3/4] net: hns3: fix for cleaning ring problem Date: Wed, 9 May 2018 17:24:40 +0100 Message-ID: <20180509162441.18068-4-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20180509162441.18068-1-salil.mehta@huawei.com> References: <20180509162441.18068-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.234] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yunsheng Lin The head or tail in hardware is not longer valid when resetting, current hns3_clear_all_ring use them to clean the ring, which will cause problem during resetting. This patch fixes it by using next_to_use and next_to_clean in the ring struct. Fixes: 76ad4f0ee747 ("net: hns3: Add support of HNS3 Ethernet Driver for hip08 SoC") Signed-off-by: Yunsheng Lin Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 34 ++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index bd8e14b..4031174 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -3203,9 +3203,35 @@ static void hns3_recover_hw_addr(struct net_device *ndev) hns3_nic_mc_sync(ndev, ha->addr); } -static void hns3_drop_skb_data(struct hns3_enet_ring *ring, struct sk_buff *skb) +static void hns3_clear_tx_ring(struct hns3_enet_ring *ring) { - dev_kfree_skb_any(skb); + if (!HNAE3_IS_TX_RING(ring)) + return; + + while (ring->next_to_clean != ring->next_to_use) { + hns3_free_buffer_detach(ring, ring->next_to_clean); + ring_ptr_move_fw(ring, next_to_clean); + } +} + +static void hns3_clear_rx_ring(struct hns3_enet_ring *ring) +{ + if (HNAE3_IS_TX_RING(ring)) + return; + + while (ring->next_to_use != ring->next_to_clean) { + /* When a buffer is not reused, it's memory has been + * freed in hns3_handle_rx_bd or will be freed by + * stack, so only need to unmap the buffer here. + */ + if (!ring->desc_cb[ring->next_to_use].reuse_flag) { + hns3_unmap_buffer(ring, + &ring->desc_cb[ring->next_to_use]); + ring->desc_cb[ring->next_to_use].dma = 0; + } + + ring_ptr_move_fw(ring, next_to_use); + } } static void hns3_clear_all_ring(struct hnae3_handle *h) @@ -3219,13 +3245,13 @@ static void hns3_clear_all_ring(struct hnae3_handle *h) struct hns3_enet_ring *ring; ring = priv->ring_data[i].ring; - hns3_clean_tx_ring(ring, ring->desc_num); + hns3_clear_tx_ring(ring); dev_queue = netdev_get_tx_queue(ndev, priv->ring_data[i].queue_index); netdev_tx_reset_queue(dev_queue); ring = priv->ring_data[i + h->kinfo.num_tqps].ring; - hns3_clean_rx_ring(ring, ring->desc_num, hns3_drop_skb_data); + hns3_clear_rx_ring(ring); } } From patchwork Wed May 9 16:24:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 135306 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp5842180lji; Wed, 9 May 2018 09:26:34 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoofNA7e7z8WPg/956566gc/2cwMBAWOVzZFturLQFW+mlKwtJzmTrg0foUKVMLe9SN43Ij X-Received: by 2002:a17:902:2805:: with SMTP id e5-v6mr46692725plb.55.1525883193987; Wed, 09 May 2018 09:26:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525883193; cv=none; d=google.com; s=arc-20160816; b=DwxzLg/0T9Lbs/b1WDKalSTBI9kvKAodZlC4Ygp/r0y+EzNTvjmp9jTmQcuRPsK1/q 3XeyagOqJeR85+wUitpSuWik41PiOehKvOYSPK/MQmdo4Gldl0sqXF2w7vx/ka5zu0WM xj0rqzdrua7bUTY0HTC04E4gJn5QKkkmBdrom8dQTBQlEmtvORGBZ8AFfc1/bLq/L0iI yatjDyJOAPZW5eCAIL87+lrWlkjDUfqin/f8Z2zCy1MPLY4qydW0KEvRGRRqOVjp3sSD uQJRyMwCCg9PoebWIgWAvaDvO+Hnc538D2RqZmntfbaWRGWUXcDPHUyl6UKxZuGpKJlQ a3tg== 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:arc-authentication-results; bh=u71jBQXqcUhgB3EwVG2g57rE8Y3lylnapeFcXcHJ9yM=; b=T9rvAqLXg+1ReI61mbSWQWvaIKZ5EImURvzgIr38eunAfxkCKCNAKpUTWlY+m/Gz6z SOimUUt75L077Nbm2C65uaOTehQ1+zB5XlJcafnGxmzI8+L8mPRaYcqXvTf32Yo5B8vv YQ6gEWsGyOkGTQh3y3dQ/5z1m1+D+x7igMmK5nAHYI8xtcUYOqYRty5f82aDGKOvy1HE H+AARNMcsAoS0VYrQkdWxqr+E6Q5uPeS24S3HH0eyQPbKJbBL/crTF7+dYYTOTB1oePf ooz1UDoJlO3vfrHLjdhkC6len06MpiofvuKuh0vEBBvdYyO2oQ558xgeRA2ysijkPBDF d16w== 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 b6-v6si27073142plm.153.2018.05.09.09.26.22; Wed, 09 May 2018 09:26:33 -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 S965557AbeEIQ0V (ORCPT + 29 others); Wed, 9 May 2018 12:26:21 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:42819 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S965532AbeEIQ0R (ORCPT ); Wed, 9 May 2018 12:26:17 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 95AA14338B257; Thu, 10 May 2018 00:26:14 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.202.227.234) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.361.1; Thu, 10 May 2018 00:26:07 +0800 From: Salil Mehta To: CC: , , , , , , , Yunsheng Lin Subject: [PATCH net-next 4/4] net: hns3: refactor the loopback related function Date: Wed, 9 May 2018 17:24:41 +0100 Message-ID: <20180509162441.18068-5-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20180509162441.18068-1-salil.mehta@huawei.com> References: <20180509162441.18068-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.234] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yunsheng Lin This patch refactors the loopback related function in order to support the serdes loopback. Signed-off-by: Yunsheng Lin Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 21 +++---- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 68 +++++++++++----------- 2 files changed, 42 insertions(+), 47 deletions(-) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c index eb3c34f..c16bb6c 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c @@ -74,7 +74,7 @@ struct hns3_link_mode_mapping { u32 ethtool_link_mode; }; -static int hns3_lp_setup(struct net_device *ndev, enum hnae3_loop loop) +static int hns3_lp_setup(struct net_device *ndev, enum hnae3_loop loop, bool en) { struct hnae3_handle *h = hns3_get_handle(ndev); int ret; @@ -85,11 +85,7 @@ static int hns3_lp_setup(struct net_device *ndev, enum hnae3_loop loop) switch (loop) { case HNAE3_MAC_INTER_LOOP_MAC: - ret = h->ae_algo->ops->set_loopback(h, loop, true); - break; - case HNAE3_MAC_LOOP_NONE: - ret = h->ae_algo->ops->set_loopback(h, - HNAE3_MAC_INTER_LOOP_MAC, false); + ret = h->ae_algo->ops->set_loopback(h, loop, en); break; default: ret = -ENOTSUPP; @@ -99,10 +95,7 @@ static int hns3_lp_setup(struct net_device *ndev, enum hnae3_loop loop) if (ret) return ret; - if (loop == HNAE3_MAC_LOOP_NONE) - h->ae_algo->ops->set_promisc_mode(h, ndev->flags & IFF_PROMISC); - else - h->ae_algo->ops->set_promisc_mode(h, 1); + h->ae_algo->ops->set_promisc_mode(h, en); return ret; } @@ -122,13 +115,13 @@ static int hns3_lp_up(struct net_device *ndev, enum hnae3_loop loop_mode) return ret; } - ret = hns3_lp_setup(ndev, loop_mode); + ret = hns3_lp_setup(ndev, loop_mode, true); usleep_range(10000, 20000); return ret; } -static int hns3_lp_down(struct net_device *ndev) +static int hns3_lp_down(struct net_device *ndev, enum hnae3_loop loop_mode) { struct hnae3_handle *h = hns3_get_handle(ndev); int ret; @@ -136,7 +129,7 @@ static int hns3_lp_down(struct net_device *ndev) if (!h->ae_algo->ops->stop) return -EOPNOTSUPP; - ret = hns3_lp_setup(ndev, HNAE3_MAC_LOOP_NONE); + ret = hns3_lp_setup(ndev, loop_mode, false); if (ret) { netdev_err(ndev, "lb_setup return error: %d\n", ret); return ret; @@ -332,7 +325,7 @@ static void hns3_self_test(struct net_device *ndev, data[test_index] = hns3_lp_up(ndev, loop_type); if (!data[test_index]) { data[test_index] = hns3_lp_run_test(ndev, loop_type); - hns3_lp_down(ndev); + hns3_lp_down(ndev, loop_type); } if (data[test_index]) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 084b904..316ec842 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -3682,48 +3682,50 @@ static void hclge_cfg_mac_mode(struct hclge_dev *hdev, bool enable) "mac enable fail, ret =%d.\n", ret); } -static int hclge_set_loopback(struct hnae3_handle *handle, - enum hnae3_loop loop_mode, bool en) +static int hclge_set_mac_loopback(struct hclge_dev *hdev, bool en) { - struct hclge_vport *vport = hclge_get_vport(handle); struct hclge_config_mac_mode_cmd *req; - struct hclge_dev *hdev = vport->back; struct hclge_desc desc; u32 loop_en; int ret; - switch (loop_mode) { - case HNAE3_MAC_INTER_LOOP_MAC: - req = (struct hclge_config_mac_mode_cmd *)&desc.data[0]; - /* 1 Read out the MAC mode config at first */ - hclge_cmd_setup_basic_desc(&desc, - HCLGE_OPC_CONFIG_MAC_MODE, - true); - ret = hclge_cmd_send(&hdev->hw, &desc, 1); - if (ret) { - dev_err(&hdev->pdev->dev, - "mac loopback get fail, ret =%d.\n", - ret); - return ret; - } + req = (struct hclge_config_mac_mode_cmd *)&desc.data[0]; + /* 1 Read out the MAC mode config at first */ + hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_CONFIG_MAC_MODE, true); + ret = hclge_cmd_send(&hdev->hw, &desc, 1); + if (ret) { + dev_err(&hdev->pdev->dev, + "mac loopback get fail, ret =%d.\n", ret); + return ret; + } - /* 2 Then setup the loopback flag */ - loop_en = le32_to_cpu(req->txrx_pad_fcs_loop_en); - if (en) - hnae_set_bit(loop_en, HCLGE_MAC_APP_LP_B, 1); - else - hnae_set_bit(loop_en, HCLGE_MAC_APP_LP_B, 0); + /* 2 Then setup the loopback flag */ + loop_en = le32_to_cpu(req->txrx_pad_fcs_loop_en); + hnae_set_bit(loop_en, HCLGE_MAC_APP_LP_B, en ? 1 : 0); - req->txrx_pad_fcs_loop_en = cpu_to_le32(loop_en); + req->txrx_pad_fcs_loop_en = cpu_to_le32(loop_en); - /* 3 Config mac work mode with loopback flag - * and its original configure parameters - */ - hclge_cmd_reuse_desc(&desc, false); - ret = hclge_cmd_send(&hdev->hw, &desc, 1); - if (ret) - dev_err(&hdev->pdev->dev, - "mac loopback set fail, ret =%d.\n", ret); + /* 3 Config mac work mode with loopback flag + * and its original configure parameters + */ + hclge_cmd_reuse_desc(&desc, false); + ret = hclge_cmd_send(&hdev->hw, &desc, 1); + if (ret) + dev_err(&hdev->pdev->dev, + "mac loopback set fail, ret =%d.\n", ret); + return ret; +} + +static int hclge_set_loopback(struct hnae3_handle *handle, + enum hnae3_loop loop_mode, bool en) +{ + struct hclge_vport *vport = hclge_get_vport(handle); + struct hclge_dev *hdev = vport->back; + int ret; + + switch (loop_mode) { + case HNAE3_MAC_INTER_LOOP_MAC: + ret = hclge_set_mac_loopback(hdev, en); break; default: ret = -ENOTSUPP;