From patchwork Fri Jul 6 10:27:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 141283 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2944658ljj; Fri, 6 Jul 2018 03:29:04 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcVQb3ajNHdqCTYL4smBK9JiLH0gqhO+LnHRhyUnw65GPxod1Uw9WhgmJVT9T7ghUZ+EJSq X-Received: by 2002:a63:314f:: with SMTP id x76-v6mr8770928pgx.373.1530872944627; Fri, 06 Jul 2018 03:29:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530872944; cv=none; d=google.com; s=arc-20160816; b=zdOdElKPwMhPzt+LvikwfYHvRH/0CutFVOyqUMxgzZT21PPBAZFLJkBohf195nihJ8 P2SmyDuhYQBRc4NtveupNXyzKmIBGbH+mfiKRpIgsFRAyOpB1br0HffzgkDtAJwDYalE PqFGMct9pCUK2Q975IBTU8CUpQZgFeW9lGInIFAPyiN/L52IgaHawsDrzFPm0j9/tz27 TQ9mixJNFBMETP9v1nrqEtE2i4KHTfgPehTWvrsnZVcoDSohyZ7xYhNGVAzIRw2ZtUnb Y89/iv9/XcRzq2lQhLf2sPh13v3h02KJ1fDAe9+xHWFZOzYtWG6dKQ5+8aZhkCvOacAO CNnw== 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=dRs2luLPirK4FQlI5FY4dVs3aws+rwgyvx9EMLP8iVA=; b=Z1rWfHHUcSH5XeTjR92yDx7fL3QLuVvInP2ZZHbAGcVzjXVOaKadEVp6ZkeMFTRxA6 He89Btt6F9g18mhrfspw+sKUMuVWSyQxRjAO0kERCywAv/3G+hoVUUYuFqBRJyEMMHvV Bcoljdkuen9mi0L3Mpon8Jg0F0bczEQ4KRKRWyeQ7HsGs+51kQg1H7KfV5/jl61pWBCq mT1D8tlZF5Pm4J+WgTeYqXVqwLej56CW9AU015aYUQ/QxA9SMTwfe4ABXWPkadBrWIMd 7UMTlHka4Sw//0pQ7KnpI5IoDUZL0ZKWJ2AgJ17EyynSGxjPnxs88h+4lcMnVkuRhYx6 /HCw== 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 e62-v6si8282948pfe.327.2018.07.06.03.29.04; Fri, 06 Jul 2018 03:29:04 -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 S932300AbeGFK3C (ORCPT + 30 others); Fri, 6 Jul 2018 06:29:02 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:55983 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1753348AbeGFK27 (ORCPT ); Fri, 6 Jul 2018 06:28:59 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 2EA2AE23E89A4; Fri, 6 Jul 2018 18:28:56 +0800 (CST) Received: from S00293818-DELL1.huawei.com (10.202.226.54) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.382.0; Fri, 6 Jul 2018 18:28:49 +0800 From: Salil Mehta To: CC: , , , , , , , Yunsheng Lin Subject: [PATCH net-next 01/10] net: hns3: Fix tc setup when netdev is first up Date: Fri, 6 Jul 2018 11:27:55 +0100 Message-ID: <20180706102804.196-2-salil.mehta@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180706102804.196-1-salil.mehta@huawei.com> References: <20180706102804.196-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 Currently, tc related configuration is not setup when the netdev is first up, which cause the stack only using tc 0 problem. This patch fixes it by setting the tc related configuration using the info from NCL_CONFIG when netdev is first up. 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 | 78 ++++++++++--------------- 1 file changed, 31 insertions(+), 47 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 f73c9df..e5e51e8 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -239,7 +239,28 @@ static int hns3_nic_set_real_num_queue(struct net_device *netdev) struct hnae3_handle *h = hns3_get_handle(netdev); struct hnae3_knic_private_info *kinfo = &h->kinfo; unsigned int queue_size = kinfo->rss_size * kinfo->num_tc; - int ret; + int i, ret; + + if (kinfo->num_tc <= 1) { + netdev_reset_tc(netdev); + } else { + ret = netdev_set_num_tc(netdev, kinfo->num_tc); + if (ret) { + netdev_err(netdev, + "netdev_set_num_tc fail, ret=%d!\n", ret); + return ret; + } + + for (i = 0; i < HNAE3_MAX_TC; i++) { + if (!kinfo->tc_info[i].enable) + continue; + + netdev_set_tc_queue(netdev, + kinfo->tc_info[i].tc, + kinfo->tc_info[i].tqp_count, + kinfo->tc_info[i].tqp_offset); + } + } ret = netif_set_real_num_tx_queues(netdev, queue_size); if (ret) { @@ -312,7 +333,9 @@ static int hns3_nic_net_up(struct net_device *netdev) static int hns3_nic_net_open(struct net_device *netdev) { struct hns3_nic_priv *priv = netdev_priv(netdev); - int ret; + struct hnae3_handle *h = hns3_get_handle(netdev); + struct hnae3_knic_private_info *kinfo; + int i, ret; netif_carrier_off(netdev); @@ -327,6 +350,12 @@ static int hns3_nic_net_open(struct net_device *netdev) return ret; } + kinfo = &h->kinfo; + for (i = 0; i < HNAE3_MAX_USER_PRIO; i++) { + netdev_set_prio_tc_map(netdev, i, + kinfo->prio_tc[i]); + } + priv->ae_handle->last_reset_time = jiffies; return 0; } @@ -1307,7 +1336,6 @@ static int hns3_setup_tc(struct net_device *netdev, void *type_data) u16 mode = mqprio_qopt->mode; u8 hw = mqprio_qopt->qopt.hw; bool if_running; - unsigned int i; int ret; if (!((hw == TC_MQPRIO_HW_OFFLOAD_TCS && @@ -1331,24 +1359,6 @@ static int hns3_setup_tc(struct net_device *netdev, void *type_data) if (ret) goto out; - if (tc <= 1) { - netdev_reset_tc(netdev); - } else { - ret = netdev_set_num_tc(netdev, tc); - if (ret) - goto out; - - for (i = 0; i < HNAE3_MAX_TC; i++) { - if (!kinfo->tc_info[i].enable) - continue; - - netdev_set_tc_queue(netdev, - kinfo->tc_info[i].tc, - kinfo->tc_info[i].tqp_count, - kinfo->tc_info[i].tqp_offset); - } - } - ret = hns3_nic_set_real_num_queue(netdev); out: @@ -3202,7 +3212,6 @@ static int hns3_client_setup_tc(struct hnae3_handle *handle, u8 tc) struct net_device *ndev = kinfo->netdev; bool if_running; int ret; - u8 i; if (tc > HNAE3_MAX_TC) return -EINVAL; @@ -3212,10 +3221,6 @@ static int hns3_client_setup_tc(struct hnae3_handle *handle, u8 tc) if_running = netif_running(ndev); - ret = netdev_set_num_tc(ndev, tc); - if (ret) - return ret; - if (if_running) { (void)hns3_nic_net_stop(ndev); msleep(100); @@ -3226,27 +3231,6 @@ static int hns3_client_setup_tc(struct hnae3_handle *handle, u8 tc) if (ret) goto err_out; - if (tc <= 1) { - netdev_reset_tc(ndev); - goto out; - } - - for (i = 0; i < HNAE3_MAX_TC; i++) { - struct hnae3_tc_info *tc_info = &kinfo->tc_info[i]; - - if (tc_info->enable) - netdev_set_tc_queue(ndev, - tc_info->tc, - tc_info->tqp_count, - tc_info->tqp_offset); - } - - for (i = 0; i < HNAE3_MAX_USER_PRIO; i++) { - netdev_set_prio_tc_map(ndev, i, - kinfo->prio_tc[i]); - } - -out: ret = hns3_nic_set_real_num_queue(ndev); err_out: