Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2251336pxk; Sun, 27 Sep 2020 00:20:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWNpk/2lCZa57ucQOty/05UDHFKrX58zLI3wgTmJBm6R0tvX5DzwQUzPM9PGZFhufYqGNv X-Received: by 2002:a50:cc9a:: with SMTP id q26mr10291488edi.64.1601191221725; Sun, 27 Sep 2020 00:20:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601191221; cv=none; d=google.com; s=arc-20160816; b=KdRWfEv6cwGDe+w3ctA80MAE+91uah4iKmCr7n8rEph1kxShOOZsJjA1GlwKq5VlcC bLMlyNZQKG5+kwSsuVZzw6XlfUbKzJMi3IDnbVuMyFvhc8MTBmD40ZWld9BUXAAnREEt SfkyuCpORoyeJY1YQooACdznAP0lvVEDG4ZQNY68S3z0/UnI/xMOx4ufNj08FF88GeC0 kZblaBRo2MqlCs6b8Ncwwa7lJk8fcUpb33xZH8lSLYAorI9xBTRzCDtMLYPgACqT0UU9 tFM04pj3EsWorYx9dsJTDcsI00RJ3NqSPUCf+OT0ZidFU5ENEYU1wpTMo8Yvo1as5I5s Z9vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=39y4KQme2WUOYI2cFjkf1pbMKbTTJQ1Hyod9c7bIHGI=; b=alfdFkvOwDbTHw6HgfE82qWlH6aMuR2MBQDlwdvMejfLPX9613a+lHYR9usRY8HCd0 bYipTHR1K/DSLz7WCUMODv2exue7rATI7HILYoSjJVzifLnDWafR2tSshiAqUeJp5KIn OyeDooLQOjKqaE8KEDNpcuLRlWYUldDpLBE3PxT4XiUEeCn8IDrcW0ShaQ+tJ0aS7DY8 TFkwgSMR/cEEhFVs/CvwUBb9FuhpFJe0/yFjB8IPGBItrzqvThNr1oTdC62I2K+kYTur 2RwgLVFEKFuvZ4OIpqRwVk1VgN7X6su/+sIuhn+rM3xgkONW+DFLEjfPeFhwN0LewP8c 0/MQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bz3si4864163ejc.81.2020.09.27.00.19.59; Sun, 27 Sep 2020 00:20:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730440AbgI0HPo (ORCPT + 99 others); Sun, 27 Sep 2020 03:15:44 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:14244 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726840AbgI0HPn (ORCPT ); Sun, 27 Sep 2020 03:15:43 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 6C72534911D9A984CB76; Sun, 27 Sep 2020 15:15:41 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.487.0; Sun, 27 Sep 2020 15:15:32 +0800 From: Huazhong Tan To: CC: , , , , , , Guangbin Huang , Huazhong Tan Subject: [PATCH net-next 03/10] net: hns3: add support to query device capability Date: Sun, 27 Sep 2020 15:12:41 +0800 Message-ID: <1601190768-50075-4-git-send-email-tanhuazhong@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1601190768-50075-1-git-send-email-tanhuazhong@huawei.com> References: <1601190768-50075-1-git-send-email-tanhuazhong@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Guangbin Huang In order to improve code maintainability and compatibility, add support to query the device capability by expanding the existing version query command. The device capability refers to the features supported by the device. Signed-off-by: Guangbin Huang Signed-off-by: Huazhong Tan --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 10 ---------- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c | 15 ++++++++++++--- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h | 4 +++- drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_cmd.c | 14 +++++++++++--- drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_cmd.h | 4 +++- 5 files changed, 29 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index c44a685..1c4e820e 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -2076,15 +2076,6 @@ static void hns3_disable_sriov(struct pci_dev *pdev) pci_disable_sriov(pdev); } -static void hns3_get_dev_capability(struct pci_dev *pdev, - struct hnae3_ae_dev *ae_dev) -{ - if (pdev->revision >= 0x21) { - hnae3_set_bit(ae_dev->flag, HNAE3_DEV_SUPPORT_FD_B, 1); - hnae3_set_bit(ae_dev->flag, HNAE3_DEV_SUPPORT_GRO_B, 1); - } -} - /* hns3_probe - Device initialization routine * @pdev: PCI device information struct * @ent: entry in hns3_pci_tbl @@ -2106,7 +2097,6 @@ static int hns3_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ae_dev->pdev = pdev; ae_dev->flag = ent->driver_data; - hns3_get_dev_capability(pdev, ae_dev); pci_set_drvdata(pdev, ae_dev); ret = hnae3_register_ae_dev(ae_dev); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c index 03b7a96..9f6b1a6 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.c @@ -330,7 +330,8 @@ int hclge_cmd_send(struct hclge_hw *hw, struct hclge_desc *desc, int num) return retval; } -static enum hclge_cmd_status hclge_cmd_query_version(struct hclge_dev *hdev) +static enum hclge_cmd_status +hclge_cmd_query_version_and_capability(struct hclge_dev *hdev) { struct hnae3_ae_dev *ae_dev = pci_get_drvdata(hdev->pdev); struct hclge_query_version_cmd *resp; @@ -350,6 +351,12 @@ static enum hclge_cmd_status hclge_cmd_query_version(struct hclge_dev *hdev) HNAE3_PCI_REVISION_BIT_SIZE; ae_dev->dev_version |= hdev->pdev->revision; + if (!resp->caps[0] && + ae_dev->dev_version >= HNAE3_DEVICE_VERSION_V2) { + hnae3_set_bit(ae_dev->flag, HNAE3_DEV_SUPPORT_FD_B, 1); + hnae3_set_bit(ae_dev->flag, HNAE3_DEV_SUPPORT_GRO_B, 1); + } + return ret; } @@ -436,10 +443,12 @@ int hclge_cmd_init(struct hclge_dev *hdev) goto err_cmd_init; } - ret = hclge_cmd_query_version(hdev); + /* get version and device capabilities */ + ret = hclge_cmd_query_version_and_capability(hdev); if (ret) { dev_err(&hdev->pdev->dev, - "failed to query version ret=%d\n", ret); + "failed to query version and capabilities, ret = %d\n", + ret); goto err_cmd_init; } diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h index de73463..1252e88 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h @@ -362,10 +362,12 @@ struct hclge_rx_priv_buff_cmd { u8 rsv[6]; }; +#define HCLGE_QUERY_CAP_LENGTH 3 struct hclge_query_version_cmd { __le32 firmware; __le32 hardware; - __le32 rsv[4]; + __le32 rsv; + __le32 caps[HCLGE_QUERY_CAP_LENGTH]; /* capabilities of device */ }; #define HCLGE_RX_PRIV_EN_B 15 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_cmd.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_cmd.c index b323756..3a1f7b5 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_cmd.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_cmd.c @@ -313,7 +313,7 @@ int hclgevf_cmd_send(struct hclgevf_hw *hw, struct hclgevf_desc *desc, int num) return status; } -static int hclgevf_cmd_query_version(struct hclgevf_dev *hdev) +static int hclgevf_cmd_query_version_and_capability(struct hclgevf_dev *hdev) { struct hnae3_ae_dev *ae_dev = pci_get_drvdata(hdev->pdev); struct hclgevf_query_version_cmd *resp; @@ -333,6 +333,12 @@ static int hclgevf_cmd_query_version(struct hclgevf_dev *hdev) HNAE3_PCI_REVISION_BIT_SIZE; ae_dev->dev_version |= hdev->pdev->revision; + if (!resp->caps[0] && + ae_dev->dev_version >= HNAE3_DEVICE_VERSION_V2) { + hnae3_set_bit(ae_dev->flag, HNAE3_DEV_SUPPORT_FD_B, 1); + hnae3_set_bit(ae_dev->flag, HNAE3_DEV_SUPPORT_GRO_B, 1); + } + return status; } @@ -400,9 +406,11 @@ int hclgevf_cmd_init(struct hclgevf_dev *hdev) goto err_cmd_init; } - ret = hclgevf_cmd_query_version(hdev); + /* get version and device capabilities */ + ret = hclgevf_cmd_query_version_and_capability(hdev); if (ret) { - dev_err(&hdev->pdev->dev, "failed(%d) to query version\n", ret); + dev_err(&hdev->pdev->dev, + "failed to query version and capabilities, ret = %d\n", ret); goto err_cmd_init; } diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_cmd.h b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_cmd.h index 0601df6..52e7651 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_cmd.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_cmd.h @@ -141,10 +141,12 @@ struct hclgevf_ctrl_vector_chain { u8 resv; }; +#define HCLGEVF_QUERY_CAP_LENGTH 3 struct hclgevf_query_version_cmd { __le32 firmware; __le32 hardware; - __le32 rsv[4]; + __le32 rsv; + __le32 caps[HCLGEVF_QUERY_CAP_LENGTH]; /* capabilities of device */ }; #define HCLGEVF_MSIX_OFT_ROCEE_S 0 -- 2.7.4