From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id CAE7EA0547; Thu, 9 Sep 2021 15:20:42 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 821E440041; Thu, 9 Sep 2021 15:20:42 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id 217A54003E for ; Thu, 9 Sep 2021 15:20:40 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10101"; a="220837861" X-IronPort-AV: E=Sophos;i="5.85,280,1624345200"; d="scan'208";a="220837861" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Sep 2021 06:20:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,280,1624345200"; d="scan'208";a="539622935" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by FMSMGA003.fm.intel.com with ESMTP; 09 Sep 2021 06:20:39 -0700 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12; Thu, 9 Sep 2021 06:20:39 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx611.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12 via Frontend Transport; Thu, 9 Sep 2021 06:20:39 -0700 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (104.47.56.175) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2242.12; Thu, 9 Sep 2021 06:20:39 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BWBlaWINTQVh+kvM6CyOgXRwjmlppYzoIV9sBKXivD1n1BPtpLmwZ9yQst8DHWmManvi5tPaKXymrkXOxbZae6UG0VfM0TGD0/uyU8SU/+PA7CL8z6nM7DpDfcgasyL4ADWQqbTPn5u+qb9s3xfCJsoQUFyo3I/vZxGMrPPzcj5rRVKXgnbHf8/wh/2t3NpIPrV2YRaotbtkaWC2yseRolaVieVdy4Ss6/ZIoGpyW7jQEfWJXvJmdN9AJqI3VGf7A8gHu20yROuc8JeUnVSHOjmqedr1b7e10CL1lkZpSwpuOonGWA3Agu844Ib2GMhEA+tfGwdUx3ThczOqGOhbEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=UWq/w2s1zj7b+SIwHHh/BVHeN5tZruMd4rF47hIt+aM=; b=cZsE6xv1SV3cC+fP6OLR8zQQnYKoBtjqEaQGgHl6Y+XfyVhkmfJ5LOu+OWQ4HZRodI5hyCOdHdfy3XqsRQl4m/+GfsAO/gJgXcmiqVhTFYbjtOd0Pr44T40jmn1XnhbFl4U9MOBu3tq1VelmMz05PjVaPzsjSn20zUfAk/UJL6cJ3bprAznFsnyab4YHznCjPpUR9F2omYAH4rhRQjFz961yoHxN8Iul/fPFSXs4ICsQ6YeZsNRAxZMUYDQvfHgiCXJ1ADk0QnyubVj+PjHaiRsuO+VAk964pYYnF1nqaFLI3LUv7nalZ5JgvJnlXQ+CLQFs5/A+NKE6RSZF+5ZsJQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UWq/w2s1zj7b+SIwHHh/BVHeN5tZruMd4rF47hIt+aM=; b=GiUaflnQdrddSKFNS/fkGWBBMyUEALM3fGnsjmaq3QZ7RFtiujaajBKdY/Wat/rsYq6fFxiKK495f3U/K+wOWF2mG02x4UPOOx9rby71PKkNty/CBqMqrozD+Ps6pDbBOFeEWZR2u5pIRlHsVliZwqmp2R+SyWUgTSz4+8Cv6JA= Authentication-Results: oktetlabs.ru; dkim=none (message not signed) header.d=none;oktetlabs.ru; dmarc=none action=none header.from=intel.com; Received: from PH0PR11MB5000.namprd11.prod.outlook.com (2603:10b6:510:41::19) by PH0PR11MB5095.namprd11.prod.outlook.com (2603:10b6:510:3b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.19; Thu, 9 Sep 2021 13:20:38 +0000 Received: from PH0PR11MB5000.namprd11.prod.outlook.com ([fe80::747b:3a08:d1ec:31fc]) by PH0PR11MB5000.namprd11.prod.outlook.com ([fe80::747b:3a08:d1ec:31fc%5]) with mapi id 15.20.4478.025; Thu, 9 Sep 2021 13:20:38 +0000 To: "Min Hu (Connor)" , CC: References: <1630295328-44604-1-git-send-email-humin29@huawei.com> From: Ferruh Yigit X-User: ferruhy Message-ID: <22f0f080-b12b-2d7c-6d1b-4646252caec8@intel.com> Date: Thu, 9 Sep 2021 14:20:33 +0100 In-Reply-To: <1630295328-44604-1-git-send-email-humin29@huawei.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-ClientProxiedBy: DB3PR08CA0034.eurprd08.prod.outlook.com (2603:10a6:8::47) To PH0PR11MB5000.namprd11.prod.outlook.com (2603:10b6:510:41::19) MIME-Version: 1.0 Received: from [192.168.0.206] (37.228.236.146) by DB3PR08CA0034.eurprd08.prod.outlook.com (2603:10a6:8::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Thu, 9 Sep 2021 13:20:37 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b4eaabed-76d0-4276-3499-08d973949d7e X-MS-TrafficTypeDiagnostic: PH0PR11MB5095: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:34; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /+4FG5HL210D7Y125txoBLVVwMa9MHTAiUtlQANF4/aYaQNXHJm5QjQXdhJOmSk8VTkTJTlBp5LWsXU3aUpEF8uEdyJ3/k8Y6PtfihK4Q8Un45e+xDv81Mlg+GSIUM28cVUWZeFx1A2y29eGT+8x4euOYdDeSnJGhcK+4WBKSJFYyM4/Hwmjn0fiAGLuAHCJ+ySUssk+6Zla3s1glAjvcimbVWY2QEsCzleHzLxl4uo9ieva4cdV9bmhtwQq3pEUMYyRTklGA3qthf7Xqd0PKOad3ZCaM4qv1V4D2We2HfX1e9LOn9NSAgL3GGnYP8RLfI2tSFYzzZpMEbX9LxKSvEp0a+r2Y9yUCLnD7CRxBPiYR+SCRlF3Bj0sOfPjKxLXoIxGdohsZ9tB5vxH7jF6FTzM2UkJar05qKrVQ1NoKxKw3aiI7F7rvFz2Hv40IMMLF5RqsOsGNy0HvmaTW5wMavsl/xmG+zJjxGI9tEfiYoAVJq2TSnk1unv1gyCWcWYYuApt4V/ZjqXPi+6wWp//uO10xIw8awJYqiSdSLGzdYKHnsSWWZepg0UR2MWsWwXPsnGhelNbbqvlG16OhIdWygXI00/i4L/xYyv+Hz2wMHME1+SF5G8hg+/l+UMIr0AGiq067n+oVpFlAYn1l4JGR9JiAXAmLqtfGGjRmKEWWN1vcxlCpW3wCFBjMc3ZwmLyiAaJmZel6/SE6DqKe/Ll7w== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR11MB5000.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(346002)(39860400002)(396003)(136003)(376002)(86362001)(316002)(83380400001)(16576012)(66556008)(5660300002)(44832011)(6486002)(2906002)(956004)(66476007)(186003)(4326008)(26005)(31696002)(66946007)(36756003)(53546011)(8936002)(6666004)(8676002)(478600001)(31686004)(38100700002)(2616005)(45980500001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?ZDBxM2haVVFQWDl3WTA3VW1vZ05LUjVoSjlOcGJrcVFLNE1QOE9BUHVkeXZB?= =?utf-8?B?cFNqSFRvN1ppRG1ScmlDOTlHWStmU2lEc2pySTZwbE12R2pMaTdIZW9LbnU5?= =?utf-8?B?YUNQRWZnd25RMjJnaFI1SWs3aFdiVVhpcUp4SGVQYWFTdnY1NU93emV6dzJD?= =?utf-8?B?ZUtnKzR3UXZ3S1BtTm54K0RHaklkR0ZKWlJwVmRYZXU3Mi93dk5RQVREa0hP?= =?utf-8?B?eHVPYjh4WHR1Q1N5T01iZ0wvVUpFeFdGM2hmbExkRFZFSzh0ZUNrR1ZRUGlj?= =?utf-8?B?NGZzWThIaEF0UlIzREZtWGY1c01SbjJCL2pKZERaMTliOTltWHRtRlNIRU1L?= =?utf-8?B?ZExLdWl4VzdVdWJxSDZWUGU3SVZ4TEFJb3dodVpZSi9Vem50cmQvcXpla1ZC?= =?utf-8?B?WElwS1JGSENJd2pLK1l5eEpZTHlLb2FOU0RKZWg1UXVtWndZMSt0OFBTaEFT?= =?utf-8?B?WjlJYXBtSVIxRjhUL0pjWFY0WWxzTnBQOTNOK2w5SHRYRFVKTVp2ZllEOXBl?= =?utf-8?B?STcvamRMYXM1SW9iVG04ZjZFc3BYNk04TDVkVVpKRTBFbTZEd1hVajB4VGpw?= =?utf-8?B?Q3E2Vms2eGZsTnBuZGJTUjV4Y1ByNlB1eDVpaTR6MFVOMUFVMFF5bmF3NVZo?= =?utf-8?B?d2pNY1JYYW5MTTRETEIzYlNWR2NlOHZ2S3liVHZ3S3RSTHpxZUhoSHdIQ0pH?= =?utf-8?B?VjhOdUZSbGFYM0JUUmw1YWRvZkRsdGQ1TWpBbmwrQjJtdDdOL0NQUy80eEI0?= =?utf-8?B?Ly9wTG40Y3BHYkJaZkpUMVRuYnY3Ylk3RHJNZmFwK1RaYnFQSHJuM01qU0du?= =?utf-8?B?bkFJSW9JTzNZNHdmVjJsVHZuVjl6NTdydnNoN24rMktRejc4bm05VlhpOHJT?= =?utf-8?B?b3d0K3J3RzlqLysrc25Uc2dteEVhNmlBK05FMzVvQ2xRdjQvQ1lTV1R1Vitp?= =?utf-8?B?QkVrV0dVditCRFR0RzQvM05sem83SUVDUFM2ODZacjBNbW1ERTZ1ck9PUWVw?= =?utf-8?B?QzUvakZxWDhZcWR3cHJGUE8xZWhXTlNTOStscmdYRkI1ekxPOHM1eXM4dW1G?= =?utf-8?B?WHlHMHZlTjNKRUFkdnJCcW1GOXJNV0k1WCtEL2dubW8zbWNTVkkxRnhpQkJa?= =?utf-8?B?Y1VIWWxjQXp4ZWNpM1M4WFJ2TmY4NzNLcDUzcExCUEZtNllZcmgycDJMM2p6?= =?utf-8?B?S0FQTDNMN0ZKVlNHZ054R2xYbmxIVm02bGUzbzl1Ykc2cWlNT2NNQlFkVzBN?= =?utf-8?B?SHJ1bXBVeUwyRGQrcHdnRUdnbFV2bHI0b1ZuTXhKNW1JaXdmczl2bXg1eXNR?= =?utf-8?B?U2ZXcW9nTUtSUFY5cTFDUFlPY0xROWhtOUFPaEVBNllheDNlZ3diODAvQVBB?= =?utf-8?B?VlJaTjRWY2tkbmpLMWUvVitmckYxWVE0Qk0rYmZCSXZocDJMVjFuZUpia01B?= =?utf-8?B?LzYrVFljMy9ZNDhSNDFYUUpWT0p3SnZmemduYVhXbXZPZlM2RzUzUnNWZU9L?= =?utf-8?B?VHp1bWNNZHo3MjI3Y3dQV0tVWlZ2Z01zeFp0bkp6K2ZXYTFSNml4TTcrZmQ2?= =?utf-8?B?Zy9UTkFGUmRtNmhrRWU0S1hOdktwUDdJTVFrMUZPTkdVYjVZeDc0SUVQZkpY?= =?utf-8?B?VldPcnR5Y2F2Qm41SzczUDdpWlc0WGFOOGR4RllBRkJPbWdBeGoyZHdxVk02?= =?utf-8?B?dCsrWVRhOTRhNVVtV3gzckNyaGNJVlZUa01DdFZ2UlZNeVRpV3RLcHBzVmR4?= =?utf-8?Q?dZjSd5ws6zryc5CtWBpv3ekdgua1KwHi8qAJxw0?= X-MS-Exchange-CrossTenant-Network-Message-Id: b4eaabed-76d0-4276-3499-08d973949d7e X-MS-Exchange-CrossTenant-AuthSource: PH0PR11MB5000.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Sep 2021 13:20:38.5866 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: aSVVZaqvF29tM5KOIn885nm5PLXLPSBZRq2OztAZ+57WIjg7UTmUYyw6YXSb3TLluNK1u12Qdz8F/WoJif5nKA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR11MB5095 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH] net/hns3: add runtime config to set MBX limit time X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 8/30/2021 4:48 AM, Min Hu (Connor) wrote: > From: Chengchang Tang > > Current, the max waiting time for MBX response is 500ms, but in > some scenarios, it is not enough. Since it depends on the response > of the kernel mode driver, and its response time is related to the > scheduling of the system. In this special scenario, most of the > cores are isolated, and only a few cores are used for system > scheduling. When a large number of services are started, the > scheduling of the system will be very busy, and the reply of the > mbx message will time out, which will cause our PMD initialization > to fail. > > This patch add a runtime config to set the max wait time. For the > above scenes, users can adjust the waiting time to a suitable value > by themselves. > > Fixes: 463e748964f5 ("net/hns3: support mailbox") > Cc: stable@dpdk.org > > Signed-off-by: Chengchang Tang > Signed-off-by: Min Hu (Connor) > --- > drivers/net/hns3/hns3_ethdev.c | 26 +++++++++++++++++++++++++- > drivers/net/hns3/hns3_ethdev.h | 3 +++ > drivers/net/hns3/hns3_ethdev_vf.c | 3 ++- > drivers/net/hns3/hns3_mbx.c | 10 +++++++--- > drivers/net/hns3/hns3_mbx.h | 1 + > 5 files changed, 38 insertions(+), 5 deletions(-) > > diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c > index 7d37004..4c1a6f1 100644 > --- a/drivers/net/hns3/hns3_ethdev.c > +++ b/drivers/net/hns3/hns3_ethdev.c > @@ -7357,9 +7357,24 @@ hns3_parse_dev_caps_mask(const char *key, const char *value, void *extra_args) > return 0; > } > > +static int > +hns3_parse_mbx_time_limit(const char *key, const char *value, void *extra_args) > +{ > + uint32_t val; > + > + RTE_SET_USED(key); > + > + val = strtoul(value, NULL, 10); > + if (val > HNS3_MBX_DEF_TIME_LIMIT_MS && val <= UINT16_MAX) This check adds a restriction that timeout can't be set less the 500ms but this restriction is not documented in the help string, comment or commit log etc... Can you either remove the restriction or document it? > + *(uint16_t *)extra_args = val; > + > + return 0; > +} > + > void > hns3_parse_devargs(struct rte_eth_dev *dev) > { > + uint16_t mbx_time_limit_ms = HNS3_MBX_DEF_TIME_LIMIT_MS; > struct hns3_adapter *hns = dev->data->dev_private; > uint32_t rx_func_hint = HNS3_IO_FUNC_HINT_NONE; > uint32_t tx_func_hint = HNS3_IO_FUNC_HINT_NONE; > @@ -7380,6 +7395,9 @@ hns3_parse_devargs(struct rte_eth_dev *dev) > &hns3_parse_io_hint_func, &tx_func_hint); > (void)rte_kvargs_process(kvlist, HNS3_DEVARG_DEV_CAPS_MASK, > &hns3_parse_dev_caps_mask, &dev_caps_mask); > + (void)rte_kvargs_process(kvlist, HNS3_DEVARG_MBX_TIME_LIMIT_MS, > + &hns3_parse_mbx_time_limit, &mbx_time_limit_ms); > + > rte_kvargs_free(kvlist); > > if (rx_func_hint != HNS3_IO_FUNC_HINT_NONE) > @@ -7395,6 +7413,11 @@ hns3_parse_devargs(struct rte_eth_dev *dev) > hns3_warn(hw, "parsed %s = 0x%" PRIx64 ".", > HNS3_DEVARG_DEV_CAPS_MASK, dev_caps_mask); > hns->dev_caps_mask = dev_caps_mask; > + > + if (mbx_time_limit_ms != HNS3_MBX_DEF_TIME_LIMIT_MS) > + hns3_warn(hw, "parsed %s = %u.", HNS3_DEVARG_MBX_TIME_LIMIT_MS, > + mbx_time_limit_ms); > + hns->mbx_time_limit_ms = mbx_time_limit_ms; > } > > static const struct eth_dev_ops hns3_eth_dev_ops = { > @@ -7651,6 +7674,7 @@ RTE_PMD_REGISTER_KMOD_DEP(net_hns3, "* igb_uio | vfio-pci"); > RTE_PMD_REGISTER_PARAM_STRING(net_hns3, > HNS3_DEVARG_RX_FUNC_HINT "=vec|sve|simple|common " > HNS3_DEVARG_TX_FUNC_HINT "=vec|sve|simple|common " > - HNS3_DEVARG_DEV_CAPS_MASK "=<1-65535> "); > + HNS3_DEVARG_DEV_CAPS_MASK "=<1-65535> " > + HNS3_DEVARG_MBX_TIME_LIMIT_MS "= "); > RTE_LOG_REGISTER_SUFFIX(hns3_logtype_init, init, NOTICE); > RTE_LOG_REGISTER_SUFFIX(hns3_logtype_driver, driver, NOTICE); > diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h > index 0e4e426..6476ad5 100644 > --- a/drivers/net/hns3/hns3_ethdev.h > +++ b/drivers/net/hns3/hns3_ethdev.h > @@ -852,6 +852,7 @@ struct hns3_adapter { > uint32_t tx_func_hint; > > uint64_t dev_caps_mask; > + uint16_t mbx_time_limit_ms; /* wait time for mbx message */ > > struct hns3_ptype_table ptype_tbl __rte_cache_aligned; > }; > @@ -869,6 +870,8 @@ enum { > > #define HNS3_DEVARG_DEV_CAPS_MASK "dev_caps_mask" > > +#define HNS3_DEVARG_MBX_TIME_LIMIT_MS "mbx_time_limit_ms" > + > enum { > HNS3_DEV_SUPPORT_DCB_B, > HNS3_DEV_SUPPORT_COPPER_B, > diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c > index 8d9b797..7ed9cb2 100644 > --- a/drivers/net/hns3/hns3_ethdev_vf.c > +++ b/drivers/net/hns3/hns3_ethdev_vf.c > @@ -3115,4 +3115,5 @@ RTE_PMD_REGISTER_KMOD_DEP(net_hns3_vf, "* igb_uio | vfio-pci"); > RTE_PMD_REGISTER_PARAM_STRING(net_hns3_vf, > HNS3_DEVARG_RX_FUNC_HINT "=vec|sve|simple|common " > HNS3_DEVARG_TX_FUNC_HINT "=vec|sve|simple|common " > - HNS3_DEVARG_DEV_CAPS_MASK "=<1-65535> "); > + HNS3_DEVARG_DEV_CAPS_MASK "=<1-65535> " > + HNS3_DEVARG_MBX_TIME_LIMIT_MS "= "); > diff --git a/drivers/net/hns3/hns3_mbx.c b/drivers/net/hns3/hns3_mbx.c > index f36cb10..a1556f7 100644 > --- a/drivers/net/hns3/hns3_mbx.c > +++ b/drivers/net/hns3/hns3_mbx.c > @@ -61,8 +61,9 @@ static int > hns3_get_mbx_resp(struct hns3_hw *hw, uint16_t code, uint16_t subcode, > uint8_t *resp_data, uint16_t resp_len) > { > -#define HNS3_MAX_RETRY_US 500000 > #define HNS3_WAIT_RESP_US 100 > +#define US_PER_MS 1000 > + uint32_t mbx_time_limit = HNS3_MBX_DEF_TIME_LIMIT_MS * US_PER_MS; > struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); > struct hns3_mbx_resp_status *mbx_resp; > uint32_t wait_time = 0; > @@ -74,7 +75,10 @@ hns3_get_mbx_resp(struct hns3_hw *hw, uint16_t code, uint16_t subcode, > return -EINVAL; > } > > - while (wait_time < HNS3_MAX_RETRY_US) { > + if (hns->mbx_time_limit_ms > HNS3_MBX_DEF_TIME_LIMIT_MS) > + mbx_time_limit = (uint32_t)hns->mbx_time_limit_ms * US_PER_MS; > + Why calculating the 'mbx_time_limit' twice in this function, isn't 'hns->mbx_time_limit_ms' has already either default value or user provided value, why not just keep this calculation even with removing above check? > + while (wait_time < mbx_time_limit) { > if (__atomic_load_n(&hw->reset.disable_cmd, __ATOMIC_RELAXED)) { > hns3_err(hw, "Don't wait for mbx respone because of " > "disable_cmd"); > @@ -103,7 +107,7 @@ hns3_get_mbx_resp(struct hns3_hw *hw, uint16_t code, uint16_t subcode, > wait_time += HNS3_WAIT_RESP_US; > } > hw->mbx_resp.req_msg_data = 0; > - if (wait_time >= HNS3_MAX_RETRY_US) { > + if (wait_time >= mbx_time_limit) { > hns3_mbx_proc_timeout(hw, code, subcode); > return -ETIME; > } > diff --git a/drivers/net/hns3/hns3_mbx.h b/drivers/net/hns3/hns3_mbx.h > index f868e33..d637bd2 100644 > --- a/drivers/net/hns3/hns3_mbx.h > +++ b/drivers/net/hns3/hns3_mbx.h > @@ -87,6 +87,7 @@ enum hns3_mbx_link_fail_subcode { > > #define HNS3_MBX_MAX_MSG_SIZE 16 > #define HNS3_MBX_MAX_RESP_DATA_SIZE 8 > +#define HNS3_MBX_DEF_TIME_LIMIT_MS 500 > > enum { > HNS3_MBX_RESP_MATCHING_SCHEME_OF_ORIGINAL = 0, >