From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id C313BA3160 for ; Wed, 9 Oct 2019 15:12:57 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 49E541DFEF; Wed, 9 Oct 2019 15:12:57 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 45BB11DF98 for ; Wed, 9 Oct 2019 15:12:55 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Oct 2019 06:12:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,276,1566889200"; d="scan'208";a="277418605" Received: from npg-dpdk-haiyue-1.sh.intel.com ([10.67.119.153]) by orsmga001.jf.intel.com with ESMTP; 09 Oct 2019 06:12:53 -0700 From: Haiyue Wang To: dev@dpdk.org Cc: Haiyue Wang Date: Wed, 9 Oct 2019 21:07:16 +0800 Message-Id: <20191009130716.80418-1-haiyue.wang@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH v1] net/ice: avoid the parsed devargs value being overwritten X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" If the default dev args 'proto_xtr' is not in the first position, it will overwrite the parsed queue map value, so use an new variable to save the default. And enhance the error message printing to show the right information. Signed-off-by: Haiyue Wang --- drivers/net/ice/ice_ethdev.c | 44 +++++++++++++++++++++++++----------- drivers/net/ice/ice_ethdev.h | 1 + 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c index 022b58c01..440203247 100644 --- a/drivers/net/ice/ice_ethdev.c +++ b/drivers/net/ice/ice_ethdev.c @@ -428,8 +428,7 @@ parse_queue_proto_xtr(const char *queues, struct ice_devargs *devargs) if (xtr_type < 0) return -1; - memset(devargs->proto_xtr, xtr_type, - sizeof(devargs->proto_xtr)); + devargs->proto_xtr_dflt = xtr_type; return 0; } @@ -1369,12 +1368,36 @@ ice_interrupt_handler(void *param) rte_intr_ack(dev->intr_handle); } +static void +ice_init_proto_xtr(struct rte_eth_dev *dev) +{ + struct ice_adapter *ad = + ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private); + struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private); + struct ice_hw *hw = ICE_PF_TO_HW(pf); + uint16_t i; + + if (!ice_proto_xtr_support(hw)) { + PMD_DRV_LOG(NOTICE, "Protocol extraction is not supported"); + return; + } + + pf->proto_xtr = rte_zmalloc(NULL, pf->lan_nb_qps, 0); + if (unlikely(pf->proto_xtr == NULL)) { + PMD_DRV_LOG(ERR, "No memory for setting up protocol extraction table"); + return; + } + + for (i = 0; i < pf->lan_nb_qps; i++) + pf->proto_xtr[i] = ad->devargs.proto_xtr[i] != PROTO_XTR_NONE ? + ad->devargs.proto_xtr[i] : + ad->devargs.proto_xtr_dflt; +} + /* Initialize SW parameters of PF */ static int ice_pf_sw_init(struct rte_eth_dev *dev) { - struct ice_adapter *ad = - ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private); struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private); struct ice_hw *hw = ICE_PF_TO_HW(pf); @@ -1384,15 +1407,7 @@ ice_pf_sw_init(struct rte_eth_dev *dev) pf->lan_nb_qps = pf->lan_nb_qp_max; - if (ice_proto_xtr_support(hw)) - pf->proto_xtr = rte_zmalloc(NULL, pf->lan_nb_qps, 0); - - if (pf->proto_xtr != NULL) - rte_memcpy(pf->proto_xtr, ad->devargs.proto_xtr, - RTE_MIN((size_t)pf->lan_nb_qps, - sizeof(ad->devargs.proto_xtr))); - else - PMD_DRV_LOG(NOTICE, "Protocol extraction is disabled"); + ice_init_proto_xtr(dev); return 0; } @@ -1805,6 +1820,7 @@ static int ice_parse_devargs(struct rte_eth_dev *dev) return -EINVAL; } + ad->devargs.proto_xtr_dflt = PROTO_XTR_NONE; memset(ad->devargs.proto_xtr, PROTO_XTR_NONE, sizeof(ad->devargs.proto_xtr)); @@ -2126,6 +2142,8 @@ ice_dev_close(struct rte_eth_dev *dev) rte_free(hw->port_info); hw->port_info = NULL; ice_shutdown_all_ctrlq(hw); + rte_free(pf->proto_xtr); + pf->proto_xtr = NULL; dev->dev_ops = NULL; dev->rx_pkt_burst = NULL; diff --git a/drivers/net/ice/ice_ethdev.h b/drivers/net/ice/ice_ethdev.h index 182c6f611..2fd98817b 100644 --- a/drivers/net/ice/ice_ethdev.h +++ b/drivers/net/ice/ice_ethdev.h @@ -288,6 +288,7 @@ struct ice_pf { */ struct ice_devargs { int safe_mode_support; + uint8_t proto_xtr_dflt; uint8_t proto_xtr[ICE_MAX_QUEUE_NUM]; }; -- 2.17.1