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 048AB429D0; Mon, 24 Apr 2023 04:27:14 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C8848410EC; Mon, 24 Apr 2023 04:27:13 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id 12925410DE for ; Mon, 24 Apr 2023 04:27:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1682303232; x=1713839232; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Dd770/NKI8Fxw0hkdDPgfF8GGDMemUzpgKBRjrf1p5g=; b=cdnvx7DpIbS3DdoHypJpgcR1HoheFw1rHsEj+P8NP3YtVeJbgFojIOX0 2/Iq7Pd7upndL8Z/tuNgQSgH1OGLEHOk6K/h9QmM9BKq/0KPukKEq3U0F y2+6AErX3+A1TfZQgu3AUmSDAlX0DLsI4+fyH2UExvhn3+UE8kKRZN8aY sZNX5GDEuWJXW2eJ9uqiZZpsHbo2WT3yc0qxuZjdGHh6ob3hLRt3lJ03/ GdewnQXazUfdPr0ALrOMfTpK1eNBvdzYco39tLxdBqaWjPqv78CWPAR1B RooUUweHgOEtiuEAK6CTuWCPkBCSeMmSqifu8OBSdRU3bPbm6LP9gWsZD w==; X-IronPort-AV: E=McAfee;i="6600,9927,10689"; a="325945079" X-IronPort-AV: E=Sophos;i="5.99,221,1677571200"; d="scan'208";a="325945079" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Apr 2023 19:27:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10689"; a="686609402" X-IronPort-AV: E=Sophos;i="5.99,221,1677571200"; d="scan'208";a="686609402" Received: from dpdk-mingxial-ice.sh.intel.com ([10.67.111.14]) by orsmga007.jf.intel.com with ESMTP; 23 Apr 2023 19:27:09 -0700 From: Mingxia Liu To: dev@dpdk.org Cc: jingjing.wu@intel.com, beilei.xing@intel.com, Mingxia Liu Subject: [PATCH v3] net/idpf: refine devargs parse functions Date: Mon, 24 Apr 2023 10:43:41 +0000 Message-Id: <20230424104341.64232-1-mingxia.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230424103943.64095-1-mingxia.liu@intel.com> References: <20230424103943.64095-1-mingxia.liu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 This patch refines devargs parsing functions and use valid variable max_vport_nb to replace IDPF_MAX_VPORT_NUM. Signed-off-by: Mingxia Liu --- drivers/net/idpf/idpf_ethdev.c | 55 +++++++++++++++------------------- 1 file changed, 24 insertions(+), 31 deletions(-) diff --git a/drivers/net/idpf/idpf_ethdev.c b/drivers/net/idpf/idpf_ethdev.c index e02ec2ec5a..7b9f04095b 100644 --- a/drivers/net/idpf/idpf_ethdev.c +++ b/drivers/net/idpf/idpf_ethdev.c @@ -857,12 +857,6 @@ insert_value(struct idpf_devargs *devargs, uint16_t id) return 0; } - if (devargs->req_vport_nb >= RTE_DIM(devargs->req_vports)) { - PMD_INIT_LOG(ERR, "Total vport number can't be > %d", - IDPF_MAX_VPORT_NUM); - return -EINVAL; - } - devargs->req_vports[devargs->req_vport_nb] = id; devargs->req_vport_nb++; @@ -879,12 +873,10 @@ parse_range(const char *value, struct idpf_devargs *devargs) result = sscanf(value, "%hu%n-%hu%n", &lo, &n, &hi, &n); if (result == 1) { - if (lo >= IDPF_MAX_VPORT_NUM) - return NULL; if (insert_value(devargs, lo) != 0) return NULL; } else if (result == 2) { - if (lo > hi || hi >= IDPF_MAX_VPORT_NUM) + if (lo > hi) return NULL; for (i = lo; i <= hi; i++) { if (insert_value(devargs, i) != 0) @@ -969,40 +961,40 @@ idpf_parse_devargs(struct rte_pci_device *pci_dev, struct idpf_adapter_ext *adap return -EINVAL; } + ret = rte_kvargs_process(kvlist, IDPF_VPORT, &parse_vport, + idpf_args); + if (ret != 0) + goto fail; + + ret = rte_kvargs_process(kvlist, IDPF_TX_SINGLE_Q, &parse_bool, + &adapter->base.is_tx_singleq); + if (ret != 0) + goto fail; + + ret = rte_kvargs_process(kvlist, IDPF_RX_SINGLE_Q, &parse_bool, + &adapter->base.is_rx_singleq); + if (ret != 0) + goto fail; + /* check parsed devargs */ if (adapter->cur_vport_nb + idpf_args->req_vport_nb > - IDPF_MAX_VPORT_NUM) { + adapter->max_vport_nb) { PMD_INIT_LOG(ERR, "Total vport number can't be > %d", - IDPF_MAX_VPORT_NUM); + adapter->max_vport_nb); ret = -EINVAL; - goto bail; + goto fail; } for (i = 0; i < idpf_args->req_vport_nb; i++) { if (adapter->cur_vports & RTE_BIT32(idpf_args->req_vports[i])) { - PMD_INIT_LOG(ERR, "Vport %d has been created", + PMD_INIT_LOG(ERR, "Vport %d has been requested", idpf_args->req_vports[i]); ret = -EINVAL; - goto bail; + goto fail; } } - ret = rte_kvargs_process(kvlist, IDPF_VPORT, &parse_vport, - idpf_args); - if (ret != 0) - goto bail; - - ret = rte_kvargs_process(kvlist, IDPF_TX_SINGLE_Q, &parse_bool, - &adapter->base.is_tx_singleq); - if (ret != 0) - goto bail; - - ret = rte_kvargs_process(kvlist, IDPF_RX_SINGLE_Q, &parse_bool, - &adapter->base.is_rx_singleq); - if (ret != 0) - goto bail; - -bail: +fail: rte_kvargs_free(kvlist); return ret; } @@ -1152,7 +1144,8 @@ idpf_adapter_ext_init(struct rte_pci_device *pci_dev, struct idpf_adapter_ext *a rte_eal_alarm_set(IDPF_ALARM_INTERVAL, idpf_dev_alarm_handler, adapter); - adapter->max_vport_nb = adapter->base.caps.max_vports; + adapter->max_vport_nb = adapter->base.caps.max_vports > IDPF_MAX_VPORT_NUM ? + IDPF_MAX_VPORT_NUM : adapter->base.caps.max_vports; adapter->vports = rte_zmalloc("vports", adapter->max_vport_nb * -- 2.34.1