From patchwork Tue Aug 14 16:13:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 144188 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp4550877ljj; Tue, 14 Aug 2018 09:14:13 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxjImzfYtnovtiLCtnZ0lkKa+Foy5Ad1wg2u6bi8tWRTAHwy4p2OAMvbBj5KgPB32bDSv0K X-Received: by 2002:a63:5463:: with SMTP id e35-v6mr22100673pgm.115.1534263253655; Tue, 14 Aug 2018 09:14:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534263253; cv=none; d=google.com; s=arc-20160816; b=aDHceJ4GddxgUGdjgmonPvTkNckPkmJjSf9QBbBemrZiEsbSzHIxRw2qrkC8+Nx3P+ l1uiFaYESyKedoUtxQ7N941CLRiVJsaGZjP052E7N7jbjAdghDwl00clOxSQiW1EXSwi GDzGsqXOq2ui6gPJbED8m1VlCtOQXapB17/VPKRLeq1NrrXXofmCpChzjPtWc4eC9aT1 ReHm2msWLS8t/zIYpgmlYCC1NofK8Spdv/tM+h6H7nM+GeEBQKKULr95nr/731trv764 VkXWbO6AojB7ww2QIe86DH3I0lQDQcH0m9lYm/T2mTnM4eNDWMq31tLSW4/wZkVOKOZs 5/Lg== 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=1MrfejLWu2jV/ie/Qfj/XyNwrEqLnI1ZKZfi528MX0U=; b=IHb2gAeCvpBvn9LXZo7bwMTXDgz2lk9Q+jxX7abnPSFPqpIuqwIaS/4ivu8T6LRxgr G3iRUK4yHnjYA6yqTQvk1/d/cEIY0T0lwVuwdCJVWrxp5YCwUXCe/QigSas/e7prfz3V +vodK+JpeLNBEvyrzRDvHuFbI+v8+5rKqS1vB3Yu4ZAgtI9ncSEiGJEV1gscgDRz7rUh gbM4M3O9tIvsD/nUcbdMmaFV0nqy2nH8/D4ZGrQmg1a3Gb9i9vmYVYU5NR1U3/JrV9X0 FK2w93cUibZ+ZD11VnZ0+r/38JOvF+0xItabibV94Hcm7bbsUHAhiZ6ykk3efy27H73h Kelw== 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 g12-v6si18813436pfh.346.2018.08.14.09.14.13; Tue, 14 Aug 2018 09:14:13 -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 S1732979AbeHNTB6 (ORCPT + 32 others); Tue, 14 Aug 2018 15:01:58 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:40052 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732817AbeHNTB6 (ORCPT ); Tue, 14 Aug 2018 15:01:58 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id D538B19E6F2D4; Wed, 15 Aug 2018 00:14:06 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.202.226.54) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.399.0; Wed, 15 Aug 2018 00:14:00 +0800 From: Salil Mehta To: CC: , , , , , , , Yunsheng Lin Subject: [PATCH V2 net-next 1/8] net: hns3: Add support for serdes loopback selftest Date: Tue, 14 Aug 2018 17:13:12 +0100 Message-ID: <20180814161319.16392-2-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20180814161319.16392-1-salil.mehta@huawei.com> References: <20180814161319.16392-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.226.54] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peng Li This patch adds support for serdes loopback selftest in hns3 driver. Signed-off-by: Yunsheng Lin Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- Patch V2: Fixed comments from Davis S Miller @Link, https://lkml.org/lkml/2018/8/13/385 Patch V1: Initial Submit --- drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 11 +++-- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h | 12 +++++ .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 57 +++++++++++++++++++++- 3 files changed, 75 insertions(+), 5 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 80ba95d..f70ee69 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c @@ -53,7 +53,7 @@ static const struct hns3_stats hns3_rxq_stats[] = { #define HNS3_TQP_STATS_COUNT (HNS3_TXQ_STATS_COUNT + HNS3_RXQ_STATS_COUNT) -#define HNS3_SELF_TEST_TPYE_NUM 1 +#define HNS3_SELF_TEST_TYPE_NUM 2 #define HNS3_NIC_LB_TEST_PKT_NUM 1 #define HNS3_NIC_LB_TEST_RING_ID 0 #define HNS3_NIC_LB_TEST_PACKET_SIZE 128 @@ -78,6 +78,7 @@ static int hns3_lp_setup(struct net_device *ndev, enum hnae3_loop loop, bool en) return -EOPNOTSUPP; switch (loop) { + case HNAE3_MAC_INTER_LOOP_SERDES: case HNAE3_MAC_INTER_LOOP_MAC: ret = h->ae_algo->ops->set_loopback(h, loop, en); break; @@ -287,7 +288,7 @@ static void hns3_self_test(struct net_device *ndev, { struct hns3_nic_priv *priv = netdev_priv(ndev); struct hnae3_handle *h = priv->ae_handle; - int st_param[HNS3_SELF_TEST_TPYE_NUM][2]; + int st_param[HNS3_SELF_TEST_TYPE_NUM][2]; bool if_running = netif_running(ndev); #if IS_ENABLED(CONFIG_VLAN_8021Q) bool dis_vlan_filter; @@ -303,6 +304,10 @@ static void hns3_self_test(struct net_device *ndev, st_param[HNAE3_MAC_INTER_LOOP_MAC][1] = h->flags & HNAE3_SUPPORT_MAC_LOOPBACK; + st_param[HNAE3_MAC_INTER_LOOP_SERDES][0] = HNAE3_MAC_INTER_LOOP_SERDES; + st_param[HNAE3_MAC_INTER_LOOP_SERDES][1] = + h->flags & HNAE3_SUPPORT_SERDES_LOOPBACK; + if (if_running) dev_close(ndev); @@ -316,7 +321,7 @@ static void hns3_self_test(struct net_device *ndev, set_bit(HNS3_NIC_STATE_TESTING, &priv->state); - for (i = 0; i < HNS3_SELF_TEST_TPYE_NUM; i++) { + for (i = 0; i < HNS3_SELF_TEST_TYPE_NUM; i++) { enum hnae3_loop loop_type = (enum hnae3_loop)st_param[i][0]; if (!st_param[i][1]) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h index cd0a4f2..821d4c2 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h @@ -94,6 +94,7 @@ enum hclge_opcode_type { HCLGE_OPC_QUERY_LINK_STATUS = 0x0307, HCLGE_OPC_CONFIG_MAX_FRM_SIZE = 0x0308, HCLGE_OPC_CONFIG_SPEED_DUP = 0x0309, + HCLGE_OPC_SERDES_LOOPBACK = 0x0315, /* PFC/Pause commands */ HCLGE_OPC_CFG_MAC_PAUSE_EN = 0x0701, @@ -775,6 +776,17 @@ struct hclge_reset_cmd { u8 fun_reset_vfid; u8 rsv[22]; }; + +#define HCLGE_CMD_SERDES_SERIAL_INNER_LOOP_B BIT(0) +#define HCLGE_CMD_SERDES_DONE_B BIT(0) +#define HCLGE_CMD_SERDES_SUCCESS_B BIT(1) +struct hclge_serdes_lb_cmd { + u8 mask; + u8 enable; + u8 result; + u8 rsv[21]; +}; + #define HCLGE_DEFAULT_TX_BUF 0x4000 /* 16k bytes */ #define HCLGE_TOTAL_PKT_BUF 0x108000 /* 1.03125M bytes */ #define HCLGE_DEFAULT_DV 0xA000 /* 40k byte */ diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index fc813b7..9209122 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -787,9 +787,10 @@ static int hclge_get_sset_count(struct hnae3_handle *handle, int stringset) hdev->hw.mac.speed == HCLGE_MAC_SPEED_1G) { count += 1; handle->flags |= HNAE3_SUPPORT_MAC_LOOPBACK; - } else { - count = -EOPNOTSUPP; } + + count++; + handle->flags |= HNAE3_SUPPORT_SERDES_LOOPBACK; } else if (stringset == ETH_SS_STATS) { count = ARRAY_SIZE(g_mac_stats_string) + ARRAY_SIZE(g_all_32bit_stats_string) + @@ -3670,6 +3671,55 @@ static int hclge_set_mac_loopback(struct hclge_dev *hdev, bool en) return ret; } +static int hclge_set_serdes_loopback(struct hclge_dev *hdev, bool en) +{ +#define HCLGE_SERDES_RETRY_MS 10 +#define HCLGE_SERDES_RETRY_NUM 100 + struct hclge_serdes_lb_cmd *req; + struct hclge_desc desc; + int ret, i = 0; + + req = (struct hclge_serdes_lb_cmd *)&desc.data[0]; + hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_SERDES_LOOPBACK, false); + + if (en) { + req->enable = HCLGE_CMD_SERDES_SERIAL_INNER_LOOP_B; + req->mask = HCLGE_CMD_SERDES_SERIAL_INNER_LOOP_B; + } else { + req->mask = HCLGE_CMD_SERDES_SERIAL_INNER_LOOP_B; + } + + ret = hclge_cmd_send(&hdev->hw, &desc, 1); + if (ret) { + dev_err(&hdev->pdev->dev, + "serdes loopback set fail, ret = %d\n", ret); + return ret; + } + + do { + msleep(HCLGE_SERDES_RETRY_MS); + hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_SERDES_LOOPBACK, + true); + ret = hclge_cmd_send(&hdev->hw, &desc, 1); + if (ret) { + dev_err(&hdev->pdev->dev, + "serdes loopback get, ret = %d\n", ret); + return ret; + } + } while (++i < HCLGE_SERDES_RETRY_NUM && + !(req->result & HCLGE_CMD_SERDES_DONE_B)); + + if (!(req->result & HCLGE_CMD_SERDES_DONE_B)) { + dev_err(&hdev->pdev->dev, "serdes loopback set timeout\n"); + return -EBUSY; + } else if (!(req->result & HCLGE_CMD_SERDES_SUCCESS_B)) { + dev_err(&hdev->pdev->dev, "serdes loopback set failed in fw\n"); + return -EIO; + } + + return 0; +} + static int hclge_set_loopback(struct hnae3_handle *handle, enum hnae3_loop loop_mode, bool en) { @@ -3681,6 +3731,9 @@ static int hclge_set_loopback(struct hnae3_handle *handle, case HNAE3_MAC_INTER_LOOP_MAC: ret = hclge_set_mac_loopback(hdev, en); break; + case HNAE3_MAC_INTER_LOOP_SERDES: + ret = hclge_set_serdes_loopback(hdev, en); + break; default: ret = -ENOTSUPP; dev_err(&hdev->pdev->dev, From patchwork Tue Aug 14 16:13:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 144189 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp4550972ljj; Tue, 14 Aug 2018 09:14:18 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzClCFqsQkSCxAGJu7yr/IiVzNGuTE4NCkigY1stuqgi9n7BJ3NpbF8QUzEw6hcQG4cZkf2 X-Received: by 2002:a17:902:262:: with SMTP id 89-v6mr20819647plc.221.1534263257969; Tue, 14 Aug 2018 09:14:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534263257; cv=none; d=google.com; s=arc-20160816; b=AaOuqpffcEW3n4MhDGh94tMrV+DXe5FRhiZ3/6bWsPFUKZQjR3PeaptfnUDYxEt9j1 bFxQb6dY8d3cF60kn/rTKsrDqHCfAnWGkmZBVUwi5KrjiWYNrjSBFf3eEpWM2H+cEhNh R6maCVyjBcI5iWbEgUex4lGPsmOrTSnunR/F3Jg0k5SAquNgRFaA7Y00ncpYNlrUqirX LRRSvOdqf78Ta1gP96X8nupCLpMxAUHzofc5OenUbCZpolXCHPm4BFkFpcBkvjADPPTr X7vOMIUKYvNd5iSMa+3oVE8Ggo9l2AbdvwPAe3tzqHb0uV8CgTyZ8sIuWGBcArX6n7tj x9Bg== 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=BCN2FHbfMuwYAfPukV+tUnWLaoLT2sRycOfykelZ/Zo=; b=wbjmxQO/WezaJ7lAFnzwGiOSkmGzknuzqnkNyLnonXK28ia3uayPVrvUX28qONUuUU VayCGoUBKm6Oi0mZOPAiBhfXZT7HAei3XdX6dgIgMNN5KKet3Vq/wuAgA0bSdIWPI/LD pZuOKYbvgUdjtJPZnYSgBTaqk1ytxloMcWAtBWtbRKB2H6lT/BXxZc9UWm7bYi4yANOB J4gPbL+h3hypPP8UD6ipcjexSo8bgEH4ygDTy+FCgsyJlCVxV5qzmRrgahbUXx5NpMR4 Pp+NEmBE/QlG401VlQsTmCI+U/n8qCqkGH5xTW7Vx/WEOv1Kc69TuMbY6DT9QAjMBone jlbA== 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 g12-v6si18813436pfh.346.2018.08.14.09.14.17; Tue, 14 Aug 2018 09:14:17 -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 S1733000AbeHNTCD (ORCPT + 32 others); Tue, 14 Aug 2018 15:02:03 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:10722 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732817AbeHNTCC (ORCPT ); Tue, 14 Aug 2018 15:02:02 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 7065F6634A7DA; Wed, 15 Aug 2018 00:14:11 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.202.226.54) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.399.0; Wed, 15 Aug 2018 00:14:02 +0800 From: Salil Mehta To: CC: , , , , , , , Xi Wang Subject: [PATCH V2 net-next 2/8] net: hns3: Fix for command format parsing error in hclge_is_all_function_id_zero Date: Tue, 14 Aug 2018 17:13:13 +0100 Message-ID: <20180814161319.16392-3-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20180814161319.16392-1-salil.mehta@huawei.com> References: <20180814161319.16392-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.226.54] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xi Wang According to the functional specification of hardware, the first descriptor of response from command 'lookup vlan talbe' is not valid. Currently, the first descriptor is parsed as normal value, which will cause an expected error. This patch fixes this problem by skipping the first descriptor. Fixes: 46a3df9f9718 ("net: hns3: Add HNS3 Acceleration Engine & Compatibility Layer Support") Signed-off-by: Xi Wang Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 9209122..5f30ea4 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -3930,7 +3930,7 @@ static bool hclge_is_all_function_id_zero(struct hclge_desc *desc) #define HCLGE_FUNC_NUMBER_PER_DESC 6 int i, j; - for (i = 0; i < HCLGE_DESC_NUMBER; i++) + for (i = 1; i < HCLGE_DESC_NUMBER; i++) for (j = 0; j < HCLGE_FUNC_NUMBER_PER_DESC; j++) if (desc[i].data[j]) return false; From patchwork Tue Aug 14 16:13:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 144190 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp4551042ljj; Tue, 14 Aug 2018 09:14:21 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwi9a/rPCKl6MwbkUAPFQcK1xOuEftjHK9vxdb4nQ6hwKoelrXbDjROPzBSumyFNO1P0ecB X-Received: by 2002:aa7:83cd:: with SMTP id j13-v6mr24187161pfn.236.1534263260834; Tue, 14 Aug 2018 09:14:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534263260; cv=none; d=google.com; s=arc-20160816; b=zCtblGD3R48K/+niyg37o868dYeO2gaqKw5J7RbhqzmG5Wab4GHRchYpt+rs8AGDzL 7WqO4d9wSLotp6ZBNfMxB6qyrA+Nzz2O2gYMzWB4StMhXoiw6aKaK5ALcfJG/wyaMfWj 2KPF0xn5X0DQ3jlyxvV1H68zzCJ/nLL/fpe1LyFM/QX7daewtwQ7WQpwjrglD0XLy1O7 OxesWCbezkFo8H99N+Ph2U7A6PyXHkl4KnnzAaRpcemkOKmJOCdljIUFN32o8Syi5nFp J8TQchhWJphv9tPT1GHt6FADwb+SW7+u7KfMtJXQX40eVVaRIE8XSieTdNAX+0HvpQg6 LnZA== 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=U8/8gq3AozKYY+ZdUWAuUjrdUVSFAEK34lqwvq6jV4Y=; b=JgbwlSXfp5aj+ZvkGm3FugyMTjq4wNol/c0jIfaxh1k00gOqEook2fcTYefzHwIAiW m8OmSH+yd2qrSgbRDOMBsBdz0ZR4DSiac4mBEV55S8M5JEfs9hZDGDDd6dwkJ0TuQ/Ch 7mRa5LN+NdsRY569PigzRNlBFXOkCeOVw0KgOgdJ3mYPskLsi/1gDhMp7O4ejFCGAXI/ Nmt/4W0S9DiX1Zx5WUV2fWe2ztsq5PeuIJf6j7i07q05IP5XiKR39LmNwjfICy4sezBc gQe32KzhgzldwQKDczClL+VfqmSo9huWitL+Hm6SPXa9qlX9/fw1HFpj85Kc8SpbzI7B zxIw== 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 g12-v6si18813436pfh.346.2018.08.14.09.14.20; Tue, 14 Aug 2018 09:14:20 -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 S1733019AbeHNTCF (ORCPT + 32 others); Tue, 14 Aug 2018 15:02:05 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:10721 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732514AbeHNTCF (ORCPT ); Tue, 14 Aug 2018 15:02:05 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 75996BD1AC84E; Wed, 15 Aug 2018 00:14:11 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.202.226.54) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.399.0; Wed, 15 Aug 2018 00:14:05 +0800 From: Salil Mehta To: CC: , , , , , , , Fuyun Liang Subject: [PATCH V2 net-next 3/8] net: hns3: Fix for information of phydev lost problem when down/up Date: Tue, 14 Aug 2018 17:13:14 +0100 Message-ID: <20180814161319.16392-4-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20180814161319.16392-1-salil.mehta@huawei.com> References: <20180814161319.16392-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.226.54] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Fuyun Liang Function call of phy_connect_direct will reinitialize phydev. Some information like advertising will be lost. Phy_connect_direct only needs to be called once. And driver can run well. This patch adds some functions to ensure that phy_connect_direct is called only once to solve the information of phydev lost problem occurring when we stop the net and open it again. Fixes: 46a3df9f9718 ("net: hns3: Add HNS3 Acceleration Engine & Compatibility Layer Support Signed-off-by: Fuyun Liang Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 24 +++++++++++++++++---- .../ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c | 25 ++++++++++++++++++---- .../ethernet/hisilicon/hns3/hns3pf/hclge_mdio.h | 4 +++- 3 files changed, 44 insertions(+), 9 deletions(-) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 5f30ea4..2e9c8b9 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -3782,7 +3782,7 @@ static int hclge_ae_start(struct hnae3_handle *handle) { struct hclge_vport *vport = hclge_get_vport(handle); struct hclge_dev *hdev = vport->back; - int i, ret; + int i; for (i = 0; i < vport->alloc_tqps; i++) hclge_tqp_enable(hdev, i, 0, true); @@ -3796,9 +3796,7 @@ static int hclge_ae_start(struct hnae3_handle *handle) /* reset tqp stats */ hclge_reset_tqp_stats(handle); - ret = hclge_mac_start_phy(hdev); - if (ret) - return ret; + hclge_mac_start_phy(hdev); return 0; } @@ -5417,6 +5415,16 @@ static void hclge_get_mdix_mode(struct hnae3_handle *handle, *tp_mdix = ETH_TP_MDI; } +static int hclge_init_instance_hw(struct hclge_dev *hdev) +{ + return hclge_mac_connect_phy(hdev); +} + +static void hclge_uninit_instance_hw(struct hclge_dev *hdev) +{ + hclge_mac_disconnect_phy(hdev); +} + static int hclge_init_client_instance(struct hnae3_client *client, struct hnae3_ae_dev *ae_dev) { @@ -5436,6 +5444,13 @@ static int hclge_init_client_instance(struct hnae3_client *client, if (ret) return ret; + ret = hclge_init_instance_hw(hdev); + if (ret) { + client->ops->uninit_instance(&vport->nic, + 0); + return ret; + } + if (hdev->roce_client && hnae3_dev_roce_supported(hdev)) { struct hnae3_client *rc = hdev->roce_client; @@ -5498,6 +5513,7 @@ static void hclge_uninit_client_instance(struct hnae3_client *client, if (client->type == HNAE3_CLIENT_ROCE) return; if (client->ops->uninit_instance) { + hclge_uninit_instance_hw(hdev); client->ops->uninit_instance(&vport->nic, 0); hdev->nic_client = NULL; vport->nic.client = NULL; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c index 2065ee2f..85a123d 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c @@ -193,7 +193,7 @@ static void hclge_mac_adjust_link(struct net_device *netdev) netdev_err(netdev, "failed to configure flow control.\n"); } -int hclge_mac_start_phy(struct hclge_dev *hdev) +int hclge_mac_connect_phy(struct hclge_dev *hdev) { struct net_device *netdev = hdev->vport[0].nic.netdev; struct phy_device *phydev = hdev->hw.mac.phydev; @@ -213,11 +213,29 @@ int hclge_mac_start_phy(struct hclge_dev *hdev) phydev->supported &= HCLGE_PHY_SUPPORTED_FEATURES; phydev->advertising = phydev->supported; - phy_start(phydev); - return 0; } +void hclge_mac_disconnect_phy(struct hclge_dev *hdev) +{ + struct phy_device *phydev = hdev->hw.mac.phydev; + + if (!phydev) + return; + + phy_disconnect(phydev); +} + +void hclge_mac_start_phy(struct hclge_dev *hdev) +{ + struct phy_device *phydev = hdev->hw.mac.phydev; + + if (!phydev) + return; + + phy_start(phydev); +} + void hclge_mac_stop_phy(struct hclge_dev *hdev) { struct net_device *netdev = hdev->vport[0].nic.netdev; @@ -227,5 +245,4 @@ void hclge_mac_stop_phy(struct hclge_dev *hdev) return; phy_stop(phydev); - phy_disconnect(phydev); } diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.h index bb3ce35..5fbf7dd 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.h @@ -5,7 +5,9 @@ #define __HCLGE_MDIO_H int hclge_mac_mdio_config(struct hclge_dev *hdev); -int hclge_mac_start_phy(struct hclge_dev *hdev); +int hclge_mac_connect_phy(struct hclge_dev *hdev); +void hclge_mac_disconnect_phy(struct hclge_dev *hdev); +void hclge_mac_start_phy(struct hclge_dev *hdev); void hclge_mac_stop_phy(struct hclge_dev *hdev); #endif From patchwork Tue Aug 14 16:13:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 144192 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp4551188ljj; Tue, 14 Aug 2018 09:14:28 -0700 (PDT) X-Google-Smtp-Source: AA+uWPy0tPchB1NTnXgByo6OcodHqektgpW2hTSdZxxiB/lQnOqPFrsH2Fqa1Y8lon01vkTqrrcT X-Received: by 2002:a63:e718:: with SMTP id b24-v6mr21956468pgi.224.1534263268788; Tue, 14 Aug 2018 09:14:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534263268; cv=none; d=google.com; s=arc-20160816; b=zwTgdhd/fd6HoPEWQ/R2CF4BUOP1ZV7zOCWcnqM/gTj3llBY1NKsJkc2WKTBRWjhgJ VewaaX75wjX8wyaeISkqmhpt1g3aecbT8uRKZvcH+u3pZNd9BnfOjPHlOWNXZbRwmMNy Ynp/RBhd7Fl3CQGlaqeX89NrHaGSR8Mak6TrPLjO6/UeoqdIk86r60RUFc8s011Xfxym Put60LhU+QAUUX+lyGvAf3vDzMqye7cDbinUWHwkmtPojepfjC6sim1xmTxATypsqYfN N8gj5NfbAAameq7up5cMdLCGu0t52ZFZ0pn83bnWuWEz0NhjJpsojKPNdgneVgmPnQ1b 8/3Q== 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=OSOIMfim0oFUnUUPKTJsN6W2c5gL9u7UD79wfwyJbKU=; b=jTeSaUCaxjJYrRt37CQ3YgJMkgHm+WcKolXeVe+Aa8uYfrFpPZ2WF/FbBMmtlTLLIv aM4kqw4rNiYwQZ+6+XPqDRVMXjGauZFkm5fmW3yhqohL/4HICEBQiQnSoSwh6Eb5XoHu NgtMMe3K8h/+3vK0DxKUDYnIXpR56/UktSGHAJnzIllOYPUECR1MJNMVHOJLCF6ES5Ss cK9gNpDbT7Z8FztknZJBXGmMWJChWpg+a1pR0nFxDfrd/r53b8e/FNd7YqMhAtVP4QZJ 7Q1bE/y7RAGGc4BkcNCy+iV3rIivLite9jYyx79iMFvy+zGIpxz/yLKRgVao7Mx8LsPJ zn4w== 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 v4-v6si18643760pgc.450.2018.08.14.09.14.28; Tue, 14 Aug 2018 09:14:28 -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 S1733073AbeHNTCN (ORCPT + 32 others); Tue, 14 Aug 2018 15:02:13 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:11109 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732514AbeHNTCK (ORCPT ); Tue, 14 Aug 2018 15:02:10 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 8B9B7B61671D1; Wed, 15 Aug 2018 00:14:16 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.202.226.54) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.399.0; Wed, 15 Aug 2018 00:14:08 +0800 From: Salil Mehta To: CC: , , , , , , , Jian Shen Subject: [PATCH V2 net-next 4/8] net: hns3: Fix for phy link issue when using marvell phy driver Date: Tue, 14 Aug 2018 17:13:15 +0100 Message-ID: <20180814161319.16392-5-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20180814161319.16392-1-salil.mehta@huawei.com> References: <20180814161319.16392-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.226.54] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jian Shen For marvell phy m88e1510, bit SUPPORTED_FIBRE of phydev->supported is default on. Both phy_resume() and phy_suspend() will check the SUPPORTED_FIBRE bit and write register of fibre page. Currently in hns3 driver, the SUPPORTED_FIBRE bit will be cleared after phy_connect_direct() finished. Because phy_resume() is called in phy_connect_direct(), and phy_suspend() is called when disconnect phy device, so the operation for fibre page register is not symmetrical. It will cause phy link issue when reload hns3 driver. This patch fixes it by disable the SUPPORTED_FIBRE before connecting phy. Fixes: 256727da7395 ("net: hns3: Add MDIO support to HNS3 Ethernet driver for hip08 SoC") Signed-off-by: Jian Shen Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c index 85a123d..398971a 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c @@ -202,6 +202,8 @@ int hclge_mac_connect_phy(struct hclge_dev *hdev) if (!phydev) return 0; + phydev->supported &= ~SUPPORTED_FIBRE; + ret = phy_connect_direct(netdev, phydev, hclge_mac_adjust_link, PHY_INTERFACE_MODE_SGMII); From patchwork Tue Aug 14 16:13:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 144194 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp4551274ljj; Tue, 14 Aug 2018 09:14:33 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzQfCzaIOL/hivm79R3Z5wKQsHdJqgRUHwCaMnxYA8jML2x17cgdZZVCMsu4C4N9sKRCgwm X-Received: by 2002:a17:902:a58b:: with SMTP id az11-v6mr20617167plb.36.1534263273225; Tue, 14 Aug 2018 09:14:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534263273; cv=none; d=google.com; s=arc-20160816; b=fR+Iwl7wqd/t4meYa1nK3pbWrqz9Rw5rDKo0Mu81oH4dQ0nw8AAcMgsAhsbb75P38h xnEP3+gv7cVrdg2Qs7p8ZJJjguhpJToeq7A9ENoURMDou2uG4Otw4GXXlufbCzDrRnvi seGLsSWZUaC+NiUnR/DrizQmpf4d9QX36CGXfetv0bT+aGS2v2Buv+HxqurfHcNVIF1a twkh7YxbeJNNmThwhiEI4P5DVJqEc1CxvJXzALn6ZQZqmlp5ZxRkPOKSHCHo4Z5QCGCH P2nQpZuig6YuP73worHekfePt/+kXiFYeJ6BiZthRwXfFe1oJiW8G3G/TpLDa6QgufFv eFDg== 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=xmw/FY8FEQveghphRo+sktc7B39xigRosfCtoZ8ZsJo=; b=cJ9UkF+x1RJTndO7z6w5K585XyLDWK8gBdeXEZFNTzDNcxndjLCpg5Mw1nUtnesmMs Js9U69vvIR8D3L73Lc+duY7nixAsGI+rgTVh2ExDpOyNJYbMOjmdfx1rnd8qDak0US44 Q2Ayx8PmCUxLB/KBNJwEpRSvJwlgJ+X8vFIMDmApwdK30o1ogR0EXv2GMNid2LcFAsGF L85rA+sCGUqAA88GxRL368D22JUz+/YpabBJIaNEx0A5zjb4prefkLIvOJF0AtsH+xh8 qPisJdk93y3KOEvnTab7v/OwzW4jjIAkxpX37UXJfto/3cZ8o+j2yEPMzHamtqlrnx04 g6Zg== 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 p65-v6si21949244pga.401.2018.08.14.09.14.32; Tue, 14 Aug 2018 09:14: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 S1733115AbeHNTCS (ORCPT + 32 others); Tue, 14 Aug 2018 15:02:18 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:10723 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1733047AbeHNTCR (ORCPT ); Tue, 14 Aug 2018 15:02:17 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 92730D3608D5B; Wed, 15 Aug 2018 00:14:21 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.202.226.54) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.399.0; Wed, 15 Aug 2018 00:14:14 +0800 From: Salil Mehta To: CC: , , , , , , , Yunsheng Lin Subject: [PATCH V2 net-next 6/8] net: hns3: Remove tx ring BD len register in hns3_enet Date: Tue, 14 Aug 2018 17:13:17 +0100 Message-ID: <20180814161319.16392-7-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20180814161319.16392-1-salil.mehta@huawei.com> References: <20180814161319.16392-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.226.54] 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 There is no HNS3_RING_TX_RING_BD_LEN_REG register according to UM, so this patch removes it. Signed-off-by: Yunsheng Lin Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 2 -- drivers/net/ethernet/hisilicon/hns3/hns3_enet.h | 1 - 2 files changed, 3 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 a64d69c..b7b9ee3 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -2969,8 +2969,6 @@ static void hns3_init_ring_hw(struct hns3_enet_ring *ring) hns3_write_dev(q, HNS3_RING_TX_RING_BASEADDR_H_REG, (u32)((dma >> 31) >> 1)); - hns3_write_dev(q, HNS3_RING_TX_RING_BD_LEN_REG, - hns3_buf_size2type(ring->buf_size)); hns3_write_dev(q, HNS3_RING_TX_RING_BD_NUM_REG, ring->desc_num / 8 - 1); } diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h index e4b4a8f..0f071a0 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h @@ -37,7 +37,6 @@ enum hns3_nic_state { #define HNS3_RING_TX_RING_BASEADDR_L_REG 0x00040 #define HNS3_RING_TX_RING_BASEADDR_H_REG 0x00044 #define HNS3_RING_TX_RING_BD_NUM_REG 0x00048 -#define HNS3_RING_TX_RING_BD_LEN_REG 0x0004C #define HNS3_RING_TX_RING_TAIL_REG 0x00058 #define HNS3_RING_TX_RING_HEAD_REG 0x0005C #define HNS3_RING_TX_RING_FBDNUM_REG 0x00060 From patchwork Tue Aug 14 16:13:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 144193 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp4551234ljj; Tue, 14 Aug 2018 09:14:30 -0700 (PDT) X-Google-Smtp-Source: AA+uWPy9L8hu1jKOgNtk+3u/g+366HxCffM6eMcUd/IVGsVBVvghIKsQbxLdCgYa/updSITKOCvT X-Received: by 2002:a17:902:542:: with SMTP id 60-v6mr21539287plf.122.1534263270725; Tue, 14 Aug 2018 09:14:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534263270; cv=none; d=google.com; s=arc-20160816; b=uk/f1ipUtI7KgvcBCW75So+9dOv7FJKt3/eZUtGGwmvoLy4afCZwIbSvmuFaorq5KD qcUzDzA+YSXLsejEJZeCFRxpkIeeggTZOkQZhxxRu2B4nbiZOGBHajODjnmpJoYmugWO HsAWCdgP/Qhw6U+oLp9oc/+LipNgpPeo6q0yGM4XGWw+hhS5yrGFQVqaMFXuJkDO1kxs 6H2VZkhmeIbBeGGpiNtOqrxV5xj2sm5hRNMUcbqjEKc/VLSUDuqCLOSvyvQuRwhVfsz9 POgz1cz47x8a+VPlpQAx3glTFC/riSCzIpMaN7/InZ6pg7O9lcCFsd+CZlZGcbdUx6Gf B8wQ== 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=tUrSBJ/MNhV+Z152Dg5h6NY2XjOxCcvhAf6zTsv4lgQ=; b=yfC64AofP58vTwCBS/Wwqv5i6JHh1zj0HyhfMgmntBhiWwbFmNR6AXiK/d8FNCc5WU VP5RVdhXmuUhjV09fR+N3pvDwSwCLZtcKl68VcdrQTfWufUYwWiptr0zOQr5HrvmIIHz aS5I6X6tCTvmbwbIUKaYUmm1RRmCFaUXcZOOLOEZCjrfDRu/fOgK5m6Z1gaCpRRSGPUf 9gBvfThzrWEkWeHtCLlVWjFcKNcH0W8YtDgjGCWChQm21OAa+bNu01uTE/ffO0cD+Hoa +pxR4E991wUwyXTzEMwOuEancTxeGURPAw8L68WTMIomsc+B9zngJ08VBxi5ld2gAm9t oNOg== 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 g6-v6si11359553plm.181.2018.08.14.09.14.30; Tue, 14 Aug 2018 09:14:30 -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 S1733092AbeHNTCP (ORCPT + 32 others); Tue, 14 Aug 2018 15:02:15 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:10724 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1733022AbeHNTCO (ORCPT ); Tue, 14 Aug 2018 15:02:14 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 96B853A3FCE82; Wed, 15 Aug 2018 00:14:21 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.202.226.54) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.399.0; Wed, 15 Aug 2018 00:14:16 +0800 From: Salil Mehta To: CC: , , , , , , , Yunsheng Lin Subject: [PATCH V2 net-next 7/8] net: hns3: Set tx ring' tc info when netdev is up Date: Tue, 14 Aug 2018 17:13:18 +0100 Message-ID: <20180814161319.16392-8-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20180814161319.16392-1-salil.mehta@huawei.com> References: <20180814161319.16392-1-salil.mehta@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.226.54] 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 HNS3_RING_TX_RING_TC_REG register is used to map tx ring to specific tc, the tx queue to tc mapping is needed by the hardware to do the correct tx schedule. Signed-off-by: Yunsheng Lin Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 24 ++++++++++++++++++++++++ drivers/net/ethernet/hisilicon/hns3/hns3_enet.h | 1 + 2 files changed, 25 insertions(+) -- 2.7.4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index b7b9ee3..b28c7e1 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -2974,6 +2974,28 @@ static void hns3_init_ring_hw(struct hns3_enet_ring *ring) } } +static void hns3_init_tx_ring_tc(struct hns3_nic_priv *priv) +{ + struct hnae3_knic_private_info *kinfo = &priv->ae_handle->kinfo; + int i; + + for (i = 0; i < HNAE3_MAX_TC; i++) { + struct hnae3_tc_info *tc_info = &kinfo->tc_info[i]; + int j; + + if (!tc_info->enable) + continue; + + for (j = 0; j < tc_info->tqp_count; j++) { + struct hnae3_queue *q; + + q = priv->ring_data[tc_info->tqp_offset + j].ring->tqp; + hns3_write_dev(q, HNS3_RING_TX_RING_TC_REG, + tc_info->tc); + } + } +} + int hns3_init_all_ring(struct hns3_nic_priv *priv) { struct hnae3_handle *h = priv->ae_handle; @@ -3385,6 +3407,8 @@ int hns3_nic_reset_all_ring(struct hnae3_handle *h) rx_ring->next_to_use = 0; } + hns3_init_tx_ring_tc(priv); + return 0; } diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h index 0f071a0..a02a96a 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h @@ -37,6 +37,7 @@ enum hns3_nic_state { #define HNS3_RING_TX_RING_BASEADDR_L_REG 0x00040 #define HNS3_RING_TX_RING_BASEADDR_H_REG 0x00044 #define HNS3_RING_TX_RING_BD_NUM_REG 0x00048 +#define HNS3_RING_TX_RING_TC_REG 0x00050 #define HNS3_RING_TX_RING_TAIL_REG 0x00058 #define HNS3_RING_TX_RING_HEAD_REG 0x0005C #define HNS3_RING_TX_RING_FBDNUM_REG 0x00060