Received: by 10.223.164.221 with SMTP id h29csp2059044wrb; Thu, 2 Nov 2017 05:20:57 -0700 (PDT) X-Google-Smtp-Source: ABhQp+T3ecI4u7euAscZP+z7xKXwjD02Kgypima1bH8MG+JHE2igJDm1L+cAP+w/vC6wkUNSj1+S X-Received: by 10.98.139.8 with SMTP id j8mr3642104pfe.30.1509625257062; Thu, 02 Nov 2017 05:20:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509625257; cv=none; d=google.com; s=arc-20160816; b=QFtY3VJEgtO3g0LUxAcC+PDzS+pUmBC5734hjWsP7l+UsnwT62iCKtbo3AjirC64Tt MJKGYjfRPYoAIHdncX/6SOT/6ZSvZ267ldIOBDJ0F9/cpqas5oqWyaBVOH2sKaG9Hqpc 4+knNEZnWtDj7PK208zSgT1k9vKtSwsw8uOX0G4O3/kEuacPSPeiQ1WA5/nTdXlVQveE sVWs/RB+uee0VZCpPLM0HuZFl6IW3H1a3usoHzWpc4n/89lbR8ZYzXdeLEWZ9Kl1YvvO OVvoE7RDtKUNhoCNk3Mt7s/F4mPuy6H/7WEkyLdT6/Dq7yjPpw7XfZeRilF+jaunoPtm 5Pkg== 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=L4DdoBSdC8u3VmjdUD+ZfTeNcQc9NWzgKikIqf/28+I=; b=S5b0leQCMHQia7UvFqRveiCpE3P0jDPURXn2iJv0zZ/tph1lNXnjxXWIPCLePC+F0H gSeZnFOL+epMKN3Jxu3jUy/SNlrRbLaXnrZERvR14deQRZkk4kfiFNKUo1WyKnhRrBtF z95C3tPgeek4mZkPRbnq9UK4BgE0C3dnrbtYaGmeCo1tKkM6QX8EFspIuJ50qqgM4BEk UZWkmbaDpF9YpnOOizbb20GHGecnbLLVYVbFX63ykSArIKZRH6/EA17gYzeP+qaEqHYo vMrWEGIvELDp13ECyZmH3ASbY+jrDNpzX6TAtmcH0JaGE4B5Ofvw5lok5n1JsQUhNaUL ciEw== 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 k87si3785524pfj.56.2017.11.02.05.20.39; Thu, 02 Nov 2017 05:20:57 -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 S932446AbdKBMTJ (ORCPT + 96 others); Thu, 2 Nov 2017 08:19:09 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:51480 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752607AbdKBMTE (ORCPT ); Thu, 2 Nov 2017 08:19:04 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 85848E9B79238; Thu, 2 Nov 2017 20:18:50 +0800 (CST) Received: from linux-ioko.site (10.71.200.31) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.361.1; Thu, 2 Nov 2017 20:17:46 +0800 From: Lipeng To: CC: , , , , Subject: [PATCH V2 net-next 1/9] net: hns3: Refactor the mapping of tqp to vport Date: Thu, 2 Nov 2017 20:45:15 +0800 Message-ID: <1509626723-18619-2-git-send-email-lipeng321@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1509626723-18619-1-git-send-email-lipeng321@huawei.com> References: <1509626723-18619-1-git-send-email-lipeng321@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.71.200.31] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch refactor the mapping of tqp to vport, making the maping function can be used both in the reset process and initialization process. Signed-off-by: qumingguang Signed-off-by: Lipeng Signed-off-by: Yunsheng Lin --- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 61 ++++++++++++++++++---- 1 file changed, 50 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 0b95fbe..404757a 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -1184,11 +1184,7 @@ static int hclge_assign_tqp(struct hclge_vport *vport, struct hnae3_queue **tqp, u16 num_tqps) { struct hclge_dev *hdev = vport->back; - int i, alloced, func_id, ret; - bool is_pf; - - func_id = vport->vport_id; - is_pf = (vport->vport_id == 0) ? true : false; + int i, alloced; for (i = 0, alloced = 0; i < hdev->num_tqps && alloced < num_tqps; i++) { @@ -1197,12 +1193,6 @@ static int hclge_assign_tqp(struct hclge_vport *vport, hdev->htqp[i].q.tqp_index = alloced; tqp[alloced] = &hdev->htqp[i].q; hdev->htqp[i].alloced = true; - ret = hclge_map_tqps_to_func(hdev, func_id, - hdev->htqp[i].index, - alloced, is_pf); - if (ret) - return ret; - alloced++; } } @@ -1254,6 +1244,49 @@ static int hclge_knic_setup(struct hclge_vport *vport, u16 num_tqps) return 0; } +static int hclge_map_tqp_to_vport(struct hclge_dev *hdev, + struct hclge_vport *vport) +{ + struct hnae3_handle *nic = &vport->nic; + struct hnae3_knic_private_info *kinfo; + u16 i; + + kinfo = &nic->kinfo; + for (i = 0; i < kinfo->num_tqps; i++) { + struct hclge_tqp *q = + container_of(kinfo->tqp[i], struct hclge_tqp, q); + bool is_pf; + int ret; + + is_pf = !(vport->vport_id); + ret = hclge_map_tqps_to_func(hdev, vport->vport_id, q->index, + i, is_pf); + if (ret) + return ret; + } + + return 0; +} + +static int hclge_map_tqp(struct hclge_dev *hdev) +{ + struct hclge_vport *vport = hdev->vport; + u16 i, num_vport; + + num_vport = hdev->num_vmdq_vport + hdev->num_req_vfs + 1; + for (i = 0; i < num_vport; i++) { + int ret; + + ret = hclge_map_tqp_to_vport(hdev, vport); + if (ret) + return ret; + + vport++; + } + + return 0; +} + static void hclge_unic_setup(struct hclge_vport *vport, u16 num_tqps) { /* this would be initialized later */ @@ -4459,6 +4492,12 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev) return ret; } + ret = hclge_map_tqp(hdev); + if (ret) { + dev_err(&pdev->dev, "Map tqp error, ret = %d.\n", ret); + return ret; + } + ret = hclge_mac_init(hdev); if (ret) { dev_err(&pdev->dev, "Mac init error, ret = %d\n", ret); -- 1.9.1 From 1583316579695824399@xxx Mon Nov 06 11:39:16 +0000 2017 X-GM-THRID: 1583316579695824399 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread