From patchwork Mon Apr 23 15:56:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Doherty, Declan" X-Patchwork-Id: 38731 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0B0086CC5; Mon, 23 Apr 2018 18:04:58 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 3AB605B32 for ; Mon, 23 Apr 2018 18:04:48 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Apr 2018 09:04:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,318,1520924400"; d="scan'208";a="222649094" Received: from dwdohert-ws.ir.intel.com ([163.33.210.60]) by fmsmga005.fm.intel.com with ESMTP; 23 Apr 2018 09:04:44 -0700 From: Declan Doherty To: dev@dpdk.org Cc: Alex Rosenbaum , Ferruh Yigit , Thomas Monjalon , Shahaf Shuler , Qi Zhang , Alejandro Lucero , Andrew Rybchenko , Mohammad Abdul Awal , Remy Horton , John McNamara , Rony Efraim , Jingjing Wu , Wenzhuo Lu , Vincent Jardin , Yuanhan Liu , Bruce Richardson , Konstantin Ananyev , Declan Doherty Date: Mon, 23 Apr 2018 16:56:19 +0100 Message-Id: <20180423155620.22409-4-declan.doherty@intel.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180423155620.22409-1-declan.doherty@intel.com> References: <20180418210423.13847-1-declan.doherty@intel.com> <20180423155620.22409-1-declan.doherty@intel.com> Subject: [dpdk-dev] [PATCH v5 3/4] ethdev: add mark flow item to rte_flow_item_types 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" Introduces a new action type RTE_FLOW_ITEM_TYPE_MARK which enables flow patterns to specify arbitrary integer values to match aginst set by the RTE_FLOW_ACTION_TYPE_MARK action in previously matched flows. Add support for specification of new MARK flow item in testpmd's cli. Update testpmd documentation to describe new MARK flow item support. Signed-off-by: Declan Doherty --- app/test-pmd/cmdline_flow.c | 22 +++++++++++++++++++++ doc/guides/prog_guide/rte_flow.rst | 30 +++++++++++++++++++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 4 ++++ lib/librte_ether/rte_flow.h | 29 ++++++++++++++++++++++++++++ 4 files changed, 85 insertions(+) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 8c570baf4..61af77aeb 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -91,6 +91,8 @@ enum index { ITEM_PHY_PORT_INDEX, ITEM_PORT_ID, ITEM_PORT_ID_ID, + ITEM_MARK, + ITEM_MARK_ID, ITEM_RAW, ITEM_RAW_RELATIVE, ITEM_RAW_SEARCH, @@ -453,6 +455,7 @@ static const enum index next_item[] = { ITEM_VF, ITEM_PHY_PORT, ITEM_PORT_ID, + ITEM_MARK, ITEM_RAW, ITEM_ETH, ITEM_VLAN, @@ -505,6 +508,12 @@ static const enum index item_port_id[] = { ZERO, }; +static const enum index item_mark[] = { + ITEM_MARK_ID, + ITEM_NEXT, + ZERO, +}; + static const enum index item_raw[] = { ITEM_RAW_RELATIVE, ITEM_RAW_SEARCH, @@ -1127,6 +1136,19 @@ static const struct token token_list[] = { .next = NEXT(item_port_id, NEXT_ENTRY(UNSIGNED), item_param), .args = ARGS(ARGS_ENTRY(struct rte_flow_item_port_id, id)), }, + [ITEM_MARK] = { + .name = "mark", + .help = "match traffic against value set in previously matched rule", + .priv = PRIV_ITEM(MARK, sizeof(struct rte_flow_item_mark)), + .next = NEXT(item_mark), + .call = parse_vc, + }, + [ITEM_MARK_ID] = { + .name = "id", + .help = "Integer value to match against", + .next = NEXT(item_mark, NEXT_ENTRY(UNSIGNED), item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_mark, id)), + }, [ITEM_RAW] = { .name = "raw", .help = "match an arbitrary byte string", diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 837f30667..c8a79f59f 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -656,6 +656,36 @@ representor" depending on the kind of underlying device). | ``mask`` | ``id`` | zeroed to match any port ID | +----------+----------+-----------------------------+ +Item: ``MARK`` +^^^^^^^^^^^^^^ + +Matches an arbitrary integer value which was set using the ``MARK`` action in +a previously matched rule. + +This item can only specified once as a match criteria as the ``MARK`` action can +only be specified once in a flow action. + +Note the value of MARK field is arbitrary and application defined. + +Depending on the underlying implementation the MARK item may be supported on +the physical device, with virtual groups in the PMD or not at all. + +- Default ``mask`` matches any integer value. + +.. _table_rte_flow_item_mark: + +.. table:: MARK + + +----------+----------+---------------------------+ + | Field | Subfield | Value | + +==========+==========+===========================+ + | ``spec`` | ``id`` | integer value | + +----------+--------------------------------------+ + | ``last`` | ``id`` | upper range value | + +----------+----------+---------------------------+ + | ``mask`` | ``id`` | zeroed to match any value | + +----------+------- --+---------------------------+ + Data matching item types ~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index eec3cee4e..c6f321334 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3215,6 +3215,10 @@ This section lists supported pattern items and their attributes, if any. - ``port_id``: match traffic from/to a given DPDK port ID. - ``id {unsigned}``: DPDK port ID. + +- ``mark``: match value set in previously matched flow rule using the mark action. + + - ``id {unsigned}``: arbitrary integer value. - ``raw``: match an arbitrary byte string. diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index 0372bd49f..cd2d56d51 100644 --- a/lib/librte_ether/rte_flow.h +++ b/lib/librte_ether/rte_flow.h @@ -341,6 +341,13 @@ enum rte_flow_item_type { * See struct rte_flow_item_geneve. */ RTE_FLOW_ITEM_TYPE_GENEVE, + + /** + * Matches specified mark field. + * + * See struct rte_flow_item_mark. + */ + RTE_FLOW_ITEM_TYPE_MARK, }; /** @@ -869,6 +876,28 @@ static const struct rte_flow_item_geneve rte_flow_item_geneve_mask = { }; #endif +/** + * @warning + * @b EXPERIMENTAL: this structure may change without prior notice + * + * RTE_FLOW_ITEM_TYPE_MARK + * + * Matches an arbitrary integer value which was set using the ``MARK`` action + * in a previously matched rule. + * + * This item can only be specified once as a match criteria as the ``MARK`` + * action can only be specified once in a flow action. + * + * This value is arbitrary and application-defined. Maximum allowed value + * depends on the underlying implementation. + * + * Depending on the underlying implementation the MARK item may be supported on + * the physical device, with virtual groups in the PMD or not at all. + */ +struct rte_flow_item_mark { + uint32_t id; /**< Integer value to match against. */ +}; + /** * Matching pattern item definition. *