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 917F5A04B5; Thu, 10 Sep 2020 09:41:32 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6BC1C1C0D2; Thu, 10 Sep 2020 09:41:24 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 7EA3D1C0D2 for ; Thu, 10 Sep 2020 09:41:22 +0200 (CEST) IronPort-SDR: 92BsQyQDpBJUD/DsXbCEi2V4sZ1agJyw2XsaGWG/BsjAeBnw5cXhJLw9/F7wsWrI3OifRlFJVp TBLenY9ByOEg== X-IronPort-AV: E=McAfee;i="6000,8403,9739"; a="155884473" X-IronPort-AV: E=Sophos;i="5.76,412,1592895600"; d="scan'208";a="155884473" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Sep 2020 00:41:21 -0700 IronPort-SDR: DGWAEZ8lWogFvOQmWb09dn8al8wYg3haHRLtlMKy5imsbz+9XKaR2PlqqtfNL9YHi1gXmO7KB5 KyraWEg7Gqyw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,412,1592895600"; d="scan'208";a="480787371" Received: from unknown (HELO npg-dpdk-cvl-simeisu-118d193.sh.intel.com) ([10.67.110.178]) by orsmga005.jf.intel.com with ESMTP; 10 Sep 2020 00:41:18 -0700 From: Simei Su To: qi.z.zhang@intel.com, qiming.yang@intel.com Cc: dev@dpdk.org, haiyue.wang@intel.com, beilei.xing@intel.com, Simei Su Date: Thu, 10 Sep 2020 15:37:34 +0800 Message-Id: <1599723455-353059-3-git-send-email-simei.su@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1599723455-353059-1-git-send-email-simei.su@intel.com> References: <1599723455-353059-1-git-send-email-simei.su@intel.com> Subject: [dpdk-dev] [PATCH v1 2/3] net/ice: add devarg for ACL ipv4 rule number 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" This patch enables devargs for ACL ipv4 rule number and refactor DCF capability selection API to be more flexible. Signed-off-by: Simei Su --- drivers/net/ice/ice_dcf_ethdev.c | 102 ++++++++++++++++++++++++++++++--------- drivers/net/ice/ice_ethdev.h | 1 + 2 files changed, 80 insertions(+), 23 deletions(-) diff --git a/drivers/net/ice/ice_dcf_ethdev.c b/drivers/net/ice/ice_dcf_ethdev.c index 2faed3c..3238ce2 100644 --- a/drivers/net/ice/ice_dcf_ethdev.c +++ b/drivers/net/ice/ice_dcf_ethdev.c @@ -26,6 +26,16 @@ #include "ice_dcf_ethdev.h" #include "ice_rxtx.h" +/* devargs */ +#define ICE_DCF_CAP "cap" +#define ICE_DCF_ACL_IPV4_RULES_NUM "acl_ipv4_nums" + +static const char * const ice_dcf_valid_args[] = { + ICE_DCF_CAP, + ICE_DCF_ACL_IPV4_RULES_NUM, + NULL, +}; + static uint16_t ice_dcf_recv_pkts(__rte_unused void *rx_queue, __rte_unused struct rte_mbuf **bufs, @@ -895,9 +905,51 @@ }; static int +parse_int(__rte_unused const char *key, const char *value, void *args) +{ + int *i = (int *)args; + char *end; + int num; + + num = strtoul(value, &end, 10); + *i = num; + + return 0; +} + +static int ice_dcf_parse_devargs(struct rte_eth_dev *dev) +{ + struct ice_dcf_adapter *adapter = dev->data->dev_private; + struct ice_adapter *parent_adapter = &adapter->parent; + + struct rte_devargs *devargs = dev->device->devargs; + struct rte_kvargs *kvlist; + int ret; + + if (devargs == NULL) + return 0; + + kvlist = rte_kvargs_parse(devargs->args, ice_dcf_valid_args); + if (kvlist == NULL) { + PMD_INIT_LOG(ERR, "Invalid kvargs key\n"); + return -EINVAL; + } + + ret = rte_kvargs_process(kvlist, ICE_DCF_ACL_IPV4_RULES_NUM, + &parse_int, &parent_adapter->devargs.acl_ipv4_rules_num); + if (ret) + goto bail; + +bail: + rte_kvargs_free(kvlist); + return ret; +} + +static int ice_dcf_dev_init(struct rte_eth_dev *eth_dev) { struct ice_dcf_adapter *adapter = eth_dev->data->dev_private; + int ret; eth_dev->dev_ops = &ice_dcf_eth_dev_ops; eth_dev->rx_pkt_burst = ice_dcf_recv_pkts; @@ -908,6 +960,12 @@ eth_dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE; + ret = ice_dcf_parse_devargs(eth_dev); + if (ret) { + PMD_INIT_LOG(ERR, "Failed to parse devargs"); + return -EINVAL; + } + adapter->real_hw.vc_event_msg_cb = ice_dcf_handle_pf_event_msg; if (ice_dcf_init_hw(eth_dev, &adapter->real_hw) != 0) { PMD_INIT_LOG(ERR, "Failed to init DCF hardware"); @@ -932,49 +990,47 @@ } static int -ice_dcf_cap_check_handler(__rte_unused const char *key, - const char *value, __rte_unused void *opaque) +handle_dcf_arg(__rte_unused const char *key, const char *value, + __rte_unused void *arg) { - if (strcmp(value, "dcf")) - return -1; + bool *dcf = arg; + + if (arg == NULL || value == NULL) + return -EINVAL; + + if (strcmp(value, "dcf") == 0) + *dcf = true; + else + *dcf = false; return 0; } -static int -ice_dcf_cap_selected(struct rte_devargs *devargs) +static bool +check_cap_dcf_enable(struct rte_devargs *devargs) { struct rte_kvargs *kvlist; - const char *key = "cap"; - int ret = 0; + bool enable = false; if (devargs == NULL) - return 0; + return false; kvlist = rte_kvargs_parse(devargs->args, NULL); if (kvlist == NULL) - return 0; - - if (!rte_kvargs_count(kvlist, key)) - goto exit; - - /* dcf capability selected when there's a key-value pair: cap=dcf */ - if (rte_kvargs_process(kvlist, key, - ice_dcf_cap_check_handler, NULL) < 0) - goto exit; + return false; - ret = 1; + rte_kvargs_process(kvlist, ICE_DCF_CAP, handle_dcf_arg, &enable); -exit: rte_kvargs_free(kvlist); - return ret; + + return enable; } static int eth_ice_dcf_pci_probe(__rte_unused struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) { - if (!ice_dcf_cap_selected(pci_dev->device.devargs)) - return 1; + if (!check_cap_dcf_enable(pci_dev->device.devargs)) + return 1; /* continue to probe */ return rte_eth_dev_pci_generic_probe(pci_dev, sizeof(struct ice_dcf_adapter), diff --git a/drivers/net/ice/ice_ethdev.h b/drivers/net/ice/ice_ethdev.h index 758caa8..13f4167 100644 --- a/drivers/net/ice/ice_ethdev.h +++ b/drivers/net/ice/ice_ethdev.h @@ -447,6 +447,7 @@ struct ice_devargs { int pipe_mode_support; int flow_mark_support; uint8_t proto_xtr[ICE_MAX_QUEUE_NUM]; + int acl_ipv4_rules_num; }; /** -- 1.8.3.1