Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2251280pxk; Sun, 27 Sep 2020 00:20:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzRsbbRV5vo2o4FcKHqXDfU1In7n4Pdn2IfxeYEKEouUHpyP7Vb/UCgsIS/gkwbJNiXXH1T X-Received: by 2002:a05:6402:1fb:: with SMTP id i27mr10203340edy.379.1601191211242; Sun, 27 Sep 2020 00:20:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601191211; cv=none; d=google.com; s=arc-20160816; b=CkwynEZ11fdAyca7ggOq9k3f6H8c67GjQdE2VzbSGy/gDFeYr7nt8kYpP27FMsOjx8 zM6bAl0jSQiBMgzTJ/i5AWfxCowo2YvOwtFW60ndyK+nbzjo++OplnmZDRT2aX2HYvtK O57JqG/Tg+RVk6Cy8RnBEuXRS2UQwbfjHCUJt+k/OEU+8fEMY73kCnCzlEIgXUoegKeI 4hJ2GMbJG3UBXpixZKkNGK0fb/79tzrCYgrf3vAzhZS9FqqMOgnAoH4288DEyvqtWuq8 MGjqkvTDeOftV0gtYo40wgGuWz8yriZSaB28XoOt1phkx3sZljNcaWohLIEP9saPdtEP SWAw== 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=waecjNw6E0TrULvtq2MhphNUADjndAJnQYlXKxR6yhs=; b=LS6W8ESSU8Kxdq6qg0jZh7ongU7owtz2zvkJagHX9YdWsLIZQ6j0lAX3K7xyNrglWD QQOiOpFpv1BMMmB9qzxQKtcvlrCZCveEPVdxcxg+rqRwk0G8qVGBTXgW+oJxX0cr/APY KjHcMOEf4NdwtLedUWhnQI2tx36QU4fRwP1/H3tJzuzxyk+YCvaFhTZhRWby9Bn8NPUs Kr6dXZ1t5uS3WfvkzV09+8K07uzDd3aJAPKh5tPs24sy7qOag8tsV1/LdxThnL+WDLFU MdbuIAhetwI+zYI6eZtYIs6Oiau7mxEcwNeyvfvPMyS5wwbFtkquLYfUxPJq2MwCfiTw iRfw== 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 r17si5201502ejz.238.2020.09.27.00.19.47; Sun, 27 Sep 2020 00:20:11 -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 S1730387AbgI0HPn (ORCPT + 99 others); Sun, 27 Sep 2020 03:15:43 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:14243 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730331AbgI0HPn (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 67CF19890BD069C315A7; 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:35 +0800 From: Huazhong Tan To: CC: , , , , , , Guangbin Huang , Huazhong Tan Subject: [PATCH net-next 09/10] net: hns3: add a check for device specifications queried from firmware Date: Sun, 27 Sep 2020 15:12:47 +0800 Message-ID: <1601190768-50075-10-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 The device specifications querying is unsupported by the old firmware, in this case, these specifications are 0. However, some specifications should not be 0 or will cause problem. So after querying from firmware, some device specifications are needed to check their value and set to default value if their values are 0. Signed-off-by: Guangbin Huang Signed-off-by: Huazhong Tan --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 15 +++++++++++++++ drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 13 +++++++++++++ 2 files changed, 28 insertions(+) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 34b2932..1f02640 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -1383,6 +1383,20 @@ static void hclge_parse_dev_specs(struct hclge_dev *hdev, ae_dev->dev_specs.max_tm_rate = le32_to_cpu(req0->max_tm_rate); } +static void hclge_check_dev_specs(struct hclge_dev *hdev) +{ + struct hnae3_dev_specs *dev_specs = &hdev->ae_dev->dev_specs; + + if (!dev_specs->max_non_tso_bd_num) + dev_specs->max_non_tso_bd_num = HCLGE_MAX_NON_TSO_BD_NUM; + if (!dev_specs->rss_ind_tbl_size) + dev_specs->rss_ind_tbl_size = HCLGE_RSS_IND_TBL_SIZE; + if (!dev_specs->rss_key_size) + dev_specs->rss_key_size = HCLGE_RSS_KEY_SIZE; + if (!dev_specs->max_tm_rate) + dev_specs->max_tm_rate = HCLGE_ETHER_MAX_RATE; +} + static int hclge_query_dev_specs(struct hclge_dev *hdev) { struct hclge_desc desc[HCLGE_QUERY_DEV_SPECS_BD_NUM]; @@ -1409,6 +1423,7 @@ static int hclge_query_dev_specs(struct hclge_dev *hdev) return ret; hclge_parse_dev_specs(hdev, desc); + hclge_check_dev_specs(hdev); return 0; } diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c index b64fa0b..8c8e666 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c @@ -2965,6 +2965,18 @@ static void hclgevf_parse_dev_specs(struct hclgevf_dev *hdev, ae_dev->dev_specs.rss_key_size = le16_to_cpu(req0->rss_key_size); } +static void hclgevf_check_dev_specs(struct hclgevf_dev *hdev) +{ + struct hnae3_dev_specs *dev_specs = &hdev->ae_dev->dev_specs; + + if (!dev_specs->max_non_tso_bd_num) + dev_specs->max_non_tso_bd_num = HCLGEVF_MAX_NON_TSO_BD_NUM; + if (!dev_specs->rss_ind_tbl_size) + dev_specs->rss_ind_tbl_size = HCLGEVF_RSS_IND_TBL_SIZE; + if (!dev_specs->rss_key_size) + dev_specs->rss_key_size = HCLGEVF_RSS_KEY_SIZE; +} + static int hclgevf_query_dev_specs(struct hclgevf_dev *hdev) { struct hclgevf_desc desc[HCLGEVF_QUERY_DEV_SPECS_BD_NUM]; @@ -2992,6 +3004,7 @@ static int hclgevf_query_dev_specs(struct hclgevf_dev *hdev) return ret; hclgevf_parse_dev_specs(hdev, desc); + hclgevf_check_dev_specs(hdev); return 0; } -- 2.7.4