From patchwork Fri Sep 1 11:31:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Yuying" X-Patchwork-Id: 131078 X-Patchwork-Delegate: qi.z.zhang@intel.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 889144221F; Fri, 1 Sep 2023 13:09:41 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 142D6402A8; Fri, 1 Sep 2023 13:09:37 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id CD6414029D for ; Fri, 1 Sep 2023 13:09:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1693566575; x=1725102575; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HaqBLncrHvFbzGmSTppqoPOBKgaUb4+oumojDhqoYic=; b=Xf+JxY04uCXtmHW+f1icw2FfFpi1aV7LzDptMx+mAusQlcfaBu/KVC+M /2jCDUVAM6yz+ZJCC9pg+oEf/wlJK+6bC7arfu5cfG1QdTUuDCnV00qZe jVOClpemyYd2Ld1aK74qEG/5hakRMzwiX+1w7IU3wpxo2Vw18qepBZ9pu BFIVwlRFT1b3Rt+IcBa2pW67uHHHufDG27Ct2hQAPJDnwuoU0XXiOOgF7 uXb9VbvwYUoS+vkEPx+nesz+dLSJUSrBIVBR8Mti/KaXf+PAZxLI3Kc+q VHWr2GZomycIyy1eRcWRyjglmhBJzUFmh4EqOM79y+lWOK0NZJ/37i5J9 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10819"; a="356511026" X-IronPort-AV: E=Sophos;i="6.02,219,1688454000"; d="scan'208";a="356511026" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Sep 2023 04:09:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10819"; a="854670971" X-IronPort-AV: E=Sophos;i="6.02,219,1688454000"; d="scan'208";a="854670971" Received: from dpdk-yuyingzh-icelake.sh.intel.com ([10.67.116.226]) by fmsmga002.fm.intel.com with ESMTP; 01 Sep 2023 04:09:28 -0700 From: Yuying Zhang To: dev@dpdk.org, qi.z.zhang@intel.com, jingjing.wu@intel.com, beilei.xing@intel.com Cc: Wenjing Qiao Subject: [PATCH v2 1/8] net/cpfl: parse flow parser file in devargs Date: Fri, 1 Sep 2023 11:31:51 +0000 Message-Id: <20230901113158.1654044-2-yuying.zhang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230901113158.1654044-1-yuying.zhang@intel.com> References: <20230812075506.361769-1-yuying.zhang@intel.com> <20230901113158.1654044-1-yuying.zhang@intel.com> MIME-Version: 1.0 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 From: Wenjing Qiao Add devargs "flow_parser" for rte_flow json parser. Signed-off-by: Wenjing Qiao --- doc/guides/nics/cpfl.rst | 32 ++++++++++++++++++++++++++++ drivers/net/cpfl/cpfl_ethdev.c | 38 +++++++++++++++++++++++++++++++++- drivers/net/cpfl/cpfl_ethdev.h | 3 +++ drivers/net/cpfl/meson.build | 6 ++++++ 4 files changed, 78 insertions(+), 1 deletion(-) diff --git a/doc/guides/nics/cpfl.rst b/doc/guides/nics/cpfl.rst index c20334230b..7032dd1a1a 100644 --- a/doc/guides/nics/cpfl.rst +++ b/doc/guides/nics/cpfl.rst @@ -128,12 +128,24 @@ Runtime Configuration -a BDF,representor=vf[0-3],representor=c1pf1 +- ``flow_parser`` (default ``not enabled``) + + The PMD supports using a JSON file to parse rte_flow tokens into low level hardware + resources defined in a DDP package file. + + The user can specify the path of json file, for example:: + + -a ca:00.0,flow_parser="refpkg.json" + + Then the PMD will load json file for device ``ca:00.0``. + The parameter is optional. Driver compilation and testing ------------------------------ Refer to the document :doc:`build_and_test` for details. +Rte flow need to install json-c library. Features -------- @@ -164,3 +176,23 @@ Hairpin queue E2100 Series can loopback packets from RX port to TX port. This feature is called port-to-port or hairpin. Currently, the PMD only supports single port hairpin. + +Rte_flow +~~~~~~~~~~~~~ + +Rte_flow uses a json file to direct CPF PMD to parse rte_flow tokens into +low level hardware resources defined in a DDP package file. + +#. install json-c library:: + + .. code-block:: console + + git clone https://github.com/json-c/json-c.git + cd json-c + git checkout 777dd06be83ef7fac71c2218b565557cd068a714 + +#. run testpmd with the json file:: + + .. code-block:: console + + dpdk-testpmd -c 0x3 -n 4 -a 0000:af:00.6,vport=[0],flow_parser="refpkg.json" -- -i diff --git a/drivers/net/cpfl/cpfl_ethdev.c b/drivers/net/cpfl/cpfl_ethdev.c index 88c1479f3a..3c4a6a4724 100644 --- a/drivers/net/cpfl/cpfl_ethdev.c +++ b/drivers/net/cpfl/cpfl_ethdev.c @@ -21,6 +21,10 @@ #define CPFL_RX_SINGLE_Q "rx_single" #define CPFL_VPORT "vport" +#ifdef CPFL_FLOW_JSON_SUPPORT +#define CPFL_FLOW_PARSER "flow_parser" +#endif + rte_spinlock_t cpfl_adapter_lock; /* A list for all adapters, one adapter matches one PCI device */ struct cpfl_adapter_list cpfl_adapter_list; @@ -31,6 +35,9 @@ static const char * const cpfl_valid_args_first[] = { CPFL_TX_SINGLE_Q, CPFL_RX_SINGLE_Q, CPFL_VPORT, +#ifdef CPFL_FLOW_JSON_SUPPORT + CPFL_FLOW_PARSER, +#endif NULL }; @@ -1537,6 +1544,24 @@ parse_repr(const char *key __rte_unused, const char *value, void *args) return 0; } +#ifdef CPFL_FLOW_JSON_SUPPORT +static int +parse_file(const char *key, const char *value, void *args) +{ + char *name = args; + + if (strlen(value) > CPFL_FLOW_FILE_LEN - 1) { + PMD_DRV_LOG(ERR, "file path(%s) is too long.", value); + return -1; + } + + PMD_DRV_LOG(DEBUG, "value:\"%s\" for key:\"%s\"", value, key); + strlcpy(name, value, CPFL_FLOW_FILE_LEN); + + return 0; +} +#endif + static int cpfl_parse_devargs(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *adapter, bool first) { @@ -1585,7 +1610,18 @@ cpfl_parse_devargs(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *adap &adapter->base.is_rx_singleq); if (ret != 0) goto fail; - +#ifdef CPFL_FLOW_JSON_SUPPORT + if (rte_kvargs_get(kvlist, CPFL_FLOW_PARSER)) { + ret = rte_kvargs_process(kvlist, CPFL_FLOW_PARSER, + &parse_file, cpfl_args->flow_parser); + if (ret) { + PMD_DRV_LOG(ERR, "Failed to parser flow_parser, ret: %d", ret); + goto fail; + } + } else { + cpfl_args->flow_parser[0] = '\0'; + } +#endif fail: rte_kvargs_free(kvlist); return ret; diff --git a/drivers/net/cpfl/cpfl_ethdev.h b/drivers/net/cpfl/cpfl_ethdev.h index a891bd8df9..ed730cc0e9 100644 --- a/drivers/net/cpfl/cpfl_ethdev.h +++ b/drivers/net/cpfl/cpfl_ethdev.h @@ -87,6 +87,8 @@ #define ACC_LCE_ID 15 #define IMC_MBX_EFD_ID 0 +#define CPFL_FLOW_FILE_LEN 100 + struct cpfl_vport_param { struct cpfl_adapter_ext *adapter; uint16_t devarg_id; /* arg id from user */ @@ -100,6 +102,7 @@ struct cpfl_devargs { uint16_t req_vport_nb; uint8_t repr_args_num; struct rte_eth_devargs repr_args[CPFL_REPR_ARG_NUM_MAX]; + char flow_parser[CPFL_FLOW_FILE_LEN]; }; struct p2p_queue_chunks_info { diff --git a/drivers/net/cpfl/meson.build b/drivers/net/cpfl/meson.build index fb075c6860..0be25512c3 100644 --- a/drivers/net/cpfl/meson.build +++ b/drivers/net/cpfl/meson.build @@ -38,3 +38,9 @@ if arch_subdir == 'x86' cflags += ['-DCC_AVX512_SUPPORT'] endif endif + +js_dep = dependency('json-c', required: false, method : 'pkg-config') +if js_dep.found() + dpdk_conf.set('CPFL_FLOW_JSON_SUPPORT', true) + ext_deps += js_dep +endif \ No newline at end of file