From patchwork Mon Jun 3 21:32:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yongseok Koh X-Patchwork-Id: 54270 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 165E51B9A2; Mon, 3 Jun 2019 23:32:46 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 0EBF01B99F for ; Mon, 3 Jun 2019 23:32:44 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE2 (envelope-from yskoh@mellanox.com) with ESMTPS (AES256-SHA encrypted); 4 Jun 2019 00:32:44 +0300 Received: from scfae-sc-2.mti.labs.mlnx (scfae-sc-2.mti.labs.mlnx [10.101.0.96]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x53LWeDD020818; Tue, 4 Jun 2019 00:32:41 +0300 From: Yongseok Koh To: shahafs@mellanox.com, thomas@monjalon.net, ferruh.yigit@intel.com, arybchenko@solarflare.com, adrien.mazarguil@6wind.com, olivier.matz@6wind.com Cc: dev@dpdk.org Date: Mon, 3 Jun 2019 14:32:29 -0700 Message-Id: <20190603213231.27020-1-yskoh@mellanox.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Subject: [dpdk-dev] [RFC 1/3] ethdev: extend flow metadata 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" Currently, metadata can be set on egress path via mbuf tx_meatadata field with PKT_TX_METADATA flag and RTE_FLOW_ITEM_TYPE_RX_META matches metadata. This patch extends the usability. 1) RTE_FLOW_ACTION_TYPE_SET_META When supporting multiple tables, Tx metadata can also be set by a rule and matched by another rule. This new action allows metadata to be set as a result of flow match. 2) Metadata on ingress There's also need to support metadata on packet Rx. Metadata can be set by SET_META action and matched by META item like Tx. The final value set by the action will be delivered to application via mbuf metadata field with PKT_RX_METADATA ol_flag. For this purpose, mbuf->tx_metadata is moved as a separate new field and renamed to 'metadata' to support both Rx and Tx metadata. For loopback/hairpin packet, metadata set on Rx/Tx may or may not be propagated to the other path depending on HW capability. Signed-off-by: Yongseok Koh --- app/test-pmd/util.c | 2 +- doc/guides/prog_guide/rte_flow.rst | 73 +++++++++++++++++++-------- drivers/net/mlx5/mlx5_rxtx.c | 12 ++--- drivers/net/mlx5/mlx5_rxtx_vec.c | 4 +- drivers/net/mlx5/mlx5_rxtx_vec_neon.h | 2 +- drivers/net/mlx5/mlx5_rxtx_vec_sse.h | 2 +- lib/librte_ethdev/rte_flow.h | 43 ++++++++++++++-- lib/librte_mbuf/rte_mbuf.h | 21 ++++---- 8 files changed, 111 insertions(+), 48 deletions(-) diff --git a/app/test-pmd/util.c b/app/test-pmd/util.c index a1164b7053..6ecc97351f 100644 --- a/app/test-pmd/util.c +++ b/app/test-pmd/util.c @@ -182,7 +182,7 @@ tx_pkt_set_md(uint16_t port_id, __rte_unused uint16_t queue, * and set ol_flags accordingly. */ for (i = 0; i < nb_pkts; i++) { - pkts[i]->tx_metadata = ports[port_id].tx_metadata; + pkts[i]->metadata = ports[port_id].tx_metadata; pkts[i]->ol_flags |= PKT_TX_METADATA; } return nb_pkts; diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index a34d012e55..016cd90e52 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -658,6 +658,32 @@ the physical device, with virtual groups in the PMD or not at all. | ``mask`` | ``id`` | zeroed to match any value | +----------+----------+---------------------------+ +Item: ``META`` +^^^^^^^^^^^^^^^^^ + +Matches 32 bit metadata item set. + +On egress, metadata can be set either by mbuf metadata field with +PKT_TX_METADATA flag or ``SET_META`` action. On ingress, ``SET_META`` action +sets metadata for a packet and the metadata will be reported via mbuf metadata +field with PKT_RX_METADATA flag. + +- Default ``mask`` matches the specified Rx metadata value. + +.. _table_rte_flow_item_meta: + +.. table:: META + + +----------+----------+---------------------------------------+ + | Field | Subfield | Value | + +==========+==========+=======================================+ + | ``spec`` | ``data`` | 32 bit metadata value | + +----------+----------+---------------------------------------+ + | ``last`` | ``data`` | upper range value | + +----------+----------+---------------------------------------+ + | ``mask`` | ``data`` | bit-mask applies to "spec" and "last" | + +----------+----------+---------------------------------------+ + Data matching item types ~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1189,27 +1215,6 @@ Normally preceded by any of: - `Item: ICMP6_ND_NS`_ - `Item: ICMP6_ND_OPT`_ -Item: ``META`` -^^^^^^^^^^^^^^ - -Matches an application specific 32 bit metadata item. - -- Default ``mask`` matches the specified metadata value. - -.. _table_rte_flow_item_meta: - -.. table:: META - - +----------+----------+---------------------------------------+ - | Field | Subfield | Value | - +==========+==========+=======================================+ - | ``spec`` | ``data`` | 32 bit metadata value | - +----------+--------------------------------------------------+ - | ``last`` | ``data`` | upper range value | - +----------+----------+---------------------------------------+ - | ``mask`` | ``data`` | bit-mask applies to "spec" and "last" | - +----------+----------+---------------------------------------+ - Actions ~~~~~~~ @@ -2345,6 +2350,32 @@ Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned. | ``mac_addr`` | MAC address | +--------------+---------------+ +Action: ``SET_META`` +^^^^^^^^^^^^^^^^^^^^^^^ + +Set metadata. Item ``META`` matches metadata. + +Metadata set by mbuf metadata field with PKT_TX_METADATA flag on egress will be +overridden by this action. On ingress, the metadata will be carried by mbuf +metadata field with PKT_RX_METADATA flag if set. + +Altering partial bits is supported with ``mask``. For bits which have never been +set, unpredictable value will be seen depending on driver implementation. For +loopback/hairpin packet, metadata set on Rx/Tx may or may not be propagated to +the other path depending on HW capability. + +.. _table_rte_flow_action_set_meta: + +.. table:: SET_META + + +----------+----------------------------+ + | Field | Value | + +==========+============================+ + | ``data`` | 32 bit metadata value | + +----------+----------------------------+ + | ``mask`` | bit-mask applies to "data" | + +----------+----------------------------+ + Negative types ~~~~~~~~~~~~~~ diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c index 7174ffc91c..19b4a2567b 100644 --- a/drivers/net/mlx5/mlx5_rxtx.c +++ b/drivers/net/mlx5/mlx5_rxtx.c @@ -626,8 +626,7 @@ mlx5_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n) txq_mbuf_to_swp(txq, buf, (uint8_t *)&swp_offsets, &swp_types); raw = ((uint8_t *)(uintptr_t)wqe) + 2 * MLX5_WQE_DWORD_SIZE; /* Copy metadata from mbuf if valid */ - metadata = buf->ol_flags & PKT_TX_METADATA ? buf->tx_metadata : - 0; + metadata = buf->ol_flags & PKT_TX_METADATA ? buf->metadata : 0; /* Replace the Ethernet type by the VLAN if necessary. */ if (buf->ol_flags & PKT_TX_VLAN_PKT) { uint32_t vlan = rte_cpu_to_be_32(0x81000000 | @@ -1029,8 +1028,7 @@ mlx5_tx_burst_mpw(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n) --pkts_n; cs_flags = txq_ol_cksum_to_cs(buf); /* Copy metadata from mbuf if valid */ - metadata = buf->ol_flags & PKT_TX_METADATA ? buf->tx_metadata : - 0; + metadata = buf->ol_flags & PKT_TX_METADATA ? buf->metadata : 0; /* Retrieve packet information. */ length = PKT_LEN(buf); assert(length); @@ -1264,8 +1262,7 @@ mlx5_tx_burst_mpw_inline(void *dpdk_txq, struct rte_mbuf **pkts, max_wqe = (1u << txq->wqe_n) - (txq->wqe_ci - txq->wqe_pi); cs_flags = txq_ol_cksum_to_cs(buf); /* Copy metadata from mbuf if valid */ - metadata = buf->ol_flags & PKT_TX_METADATA ? buf->tx_metadata : - 0; + metadata = buf->ol_flags & PKT_TX_METADATA ? buf->metadata : 0; /* Retrieve packet information. */ length = PKT_LEN(buf); /* Start new session if packet differs. */ @@ -1547,8 +1544,7 @@ txq_burst_empw(struct mlx5_txq_data *txq, struct rte_mbuf **pkts, break; cs_flags = txq_ol_cksum_to_cs(buf); /* Copy metadata from mbuf if valid */ - metadata = buf->ol_flags & PKT_TX_METADATA ? buf->tx_metadata : - 0; + metadata = buf->ol_flags & PKT_TX_METADATA ? buf->metadata : 0; /* Retrieve packet information. */ length = PKT_LEN(buf); /* Start new session if: diff --git a/drivers/net/mlx5/mlx5_rxtx_vec.c b/drivers/net/mlx5/mlx5_rxtx_vec.c index 9a3a5ae437..9f99c8cb03 100644 --- a/drivers/net/mlx5/mlx5_rxtx_vec.c +++ b/drivers/net/mlx5/mlx5_rxtx_vec.c @@ -71,7 +71,7 @@ txq_calc_offload(struct rte_mbuf **pkts, uint16_t pkts_n, uint8_t *cs_flags, if (!pkts_n) return 0; p0_metadata = pkts[0]->ol_flags & PKT_TX_METADATA ? - pkts[0]->tx_metadata : 0; + pkts[0]->metadata : 0; /* Count the number of packets having same offload parameters. */ for (pos = 1; pos < pkts_n; ++pos) { /* Check if packet has same checksum flags. */ @@ -81,7 +81,7 @@ txq_calc_offload(struct rte_mbuf **pkts, uint16_t pkts_n, uint8_t *cs_flags, /* Check if packet has same metadata. */ if (txq_offloads & DEV_TX_OFFLOAD_MATCH_METADATA) { pn_metadata = pkts[pos]->ol_flags & PKT_TX_METADATA ? - pkts[pos]->tx_metadata : 0; + pkts[pos]->metadata : 0; if (pn_metadata != p0_metadata) break; } diff --git a/drivers/net/mlx5/mlx5_rxtx_vec_neon.h b/drivers/net/mlx5/mlx5_rxtx_vec_neon.h index b2cc710887..c54914e97a 100644 --- a/drivers/net/mlx5/mlx5_rxtx_vec_neon.h +++ b/drivers/net/mlx5/mlx5_rxtx_vec_neon.h @@ -131,7 +131,7 @@ txq_scatter_v(struct mlx5_txq_data *txq, struct rte_mbuf **pkts, uint8x16_t ctrl; rte_be32_t metadata = metadata_ol && (buf->ol_flags & PKT_TX_METADATA) ? - buf->tx_metadata : 0; + buf->metadata : 0; assert(segs_n); max_elts = elts_n - (elts_head - txq->elts_tail); diff --git a/drivers/net/mlx5/mlx5_rxtx_vec_sse.h b/drivers/net/mlx5/mlx5_rxtx_vec_sse.h index dce3ee4b40..3de640a2fd 100644 --- a/drivers/net/mlx5/mlx5_rxtx_vec_sse.h +++ b/drivers/net/mlx5/mlx5_rxtx_vec_sse.h @@ -129,7 +129,7 @@ txq_scatter_v(struct mlx5_txq_data *txq, struct rte_mbuf **pkts, __m128i ctrl; rte_be32_t metadata = metadata_ol && (buf->ol_flags & PKT_TX_METADATA) ? - buf->tx_metadata : 0; + buf->metadata : 0; assert(segs_n); max_elts = elts_n - (elts_head - txq->elts_tail); diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h index f3a8fb103f..cda8628183 100644 --- a/lib/librte_ethdev/rte_flow.h +++ b/lib/librte_ethdev/rte_flow.h @@ -417,7 +417,8 @@ enum rte_flow_item_type { /** * [META] * - * Matches a metadata value specified in mbuf metadata field. + * Matches a metadata value. + * * See struct rte_flow_item_meta. */ RTE_FLOW_ITEM_TYPE_META, @@ -1164,9 +1165,16 @@ rte_flow_item_icmp6_nd_opt_tla_eth_mask = { #endif /** - * RTE_FLOW_ITEM_TYPE_META. + * @warning + * @b EXPERIMENTAL: this structure may change without prior notice * - * Matches a specified metadata value. + * RTE_FLOW_ITEM_TYPE_META + * + * Matches a specified metadata value. On egress, metadata can be set either by + * mbuf metadata field with PKT_TX_METADATA flag or + * RTE_FLOW_ACTION_TYPE_SET_META. On ingress, RTE_FLOW_ACTION_TYPE_SET_META sets + * metadata for a packet and the metadata will be reported via mbuf metadata + * field with PKT_RX_METADATA flag. */ struct rte_flow_item_meta { rte_be32_t data; @@ -1650,6 +1658,13 @@ enum rte_flow_action_type { * See struct rte_flow_action_set_mac. */ RTE_FLOW_ACTION_TYPE_SET_MAC_DST, + + /** + * Set metadata on ingress or egress path. + * + * See struct rte_flow_action_set_meta. + */ + RTE_FLOW_ACTION_TYPE_SET_META, }; /** @@ -2131,6 +2146,28 @@ struct rte_flow_action_set_mac { uint8_t mac_addr[RTE_ETHER_ADDR_LEN]; }; +/** + * @warning + * @b EXPERIMENTAL: this structure may change without prior notice + * + * RTE_FLOW_ACTION_TYPE_SET_META + * + * Set metadata. Metadata set by mbuf metadata field with PKT_TX_METADATA flag + * on egress will be overridden by this action. On ingress, the metadata will be + * carried by mbuf metadata field with PKT_RX_METADATA flag if set. + * + * Altering partial bits is supported with mask. For bits which have never been + * set, unpredictable value will be seen depending on driver implementation. For + * loopback/hairpin packet, metadata set on Rx/Tx may or may not be propagated + * to the other path depending on HW capability. + * + * RTE_FLOW_ITEM_TYPE_META matches metadata. + */ +struct rte_flow_action_set_meta { + rte_be32_t data; + rte_be32_t mask; +}; + /* * Definition of a single action. * diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index e4c2da6ee6..60f2b553e6 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -200,6 +200,11 @@ extern "C" { /* add new RX flags here */ +/** + * Indicate that mbuf has metadata from device. + */ +#define PKT_RX_METADATA (1ULL << 23) + /* add new TX flags here */ /** @@ -648,17 +653,6 @@ struct rte_mbuf { /**< User defined tags. See rte_distributor_process() */ uint32_t usr; } hash; /**< hash information */ - struct { - /** - * Application specific metadata value - * for egress flow rule match. - * Valid if PKT_TX_METADATA is set. - * Located here to allow conjunct use - * with hash.sched.hi. - */ - uint32_t tx_metadata; - uint32_t reserved; - }; }; /** Outer VLAN TCI (CPU order), valid if PKT_RX_QINQ is set. */ @@ -725,6 +719,11 @@ struct rte_mbuf { */ struct rte_mbuf_ext_shared_info *shinfo; + /** Application specific metadata value for flow rule match. + * Valid if PKT_RX_METADATA or PKT_TX_METADATA is set. + */ + uint32_t metadata; + } __rte_cache_aligned; /** From patchwork Mon Jun 3 21:32:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yongseok Koh X-Patchwork-Id: 54272 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 8D5061B9D1; Mon, 3 Jun 2019 23:32:53 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 602561B9B8 for ; Mon, 3 Jun 2019 23:32:50 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE2 (envelope-from yskoh@mellanox.com) with ESMTPS (AES256-SHA encrypted); 4 Jun 2019 00:32:46 +0300 Received: from scfae-sc-2.mti.labs.mlnx (scfae-sc-2.mti.labs.mlnx [10.101.0.96]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x53LWeDE020818; Tue, 4 Jun 2019 00:32:44 +0300 From: Yongseok Koh To: shahafs@mellanox.com, thomas@monjalon.net, ferruh.yigit@intel.com, arybchenko@solarflare.com, adrien.mazarguil@6wind.com, olivier.matz@6wind.com Cc: dev@dpdk.org Date: Mon, 3 Jun 2019 14:32:30 -0700 Message-Id: <20190603213231.27020-2-yskoh@mellanox.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190603213231.27020-1-yskoh@mellanox.com> References: <20190603213231.27020-1-yskoh@mellanox.com> MIME-Version: 1.0 Subject: [dpdk-dev] [RFC 2/3] ethdev: add flow modify mark action 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" Mark ID can be modified when supporting multiple tables. Partial bit alteration is supported to preserve some bit-fields set by previous match. Signed-off-by: Yongseok Koh --- doc/guides/prog_guide/rte_flow.rst | 21 +++++++++++++++++++++ lib/librte_ethdev/rte_flow.h | 24 ++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 016cd90e52..2907edfff4 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1463,6 +1463,27 @@ depends on the underlying implementation. It is returned in the | ``id`` | integer value to return with packets | +--------+--------------------------------------+ +Action: ``MODIFY_MARK`` +^^^^^^^^^^^^^^^^^^^^^^^ + +Alter partial bits of mark ID set by ``MARK`` action. + +``mask`` indicates which bits are modified. For bits which have never been set +by ``MARK`` or ``MODIFY_MARK``, unpredictable value will be seen depending on +driver implementation. + +.. _table_rte_flow_action_modify_mark: + +.. table:: MODIFY_MARK + + +----------+--------------------------------------+ + | Field | Value | + +==========+======================================+ + | ``id`` | integer value to return with packets | + +----------+--------------------------------------+ + | ``mask`` | bit-mask applies to "id" | + +----------+--------------------------------------+ + Action: ``FLAG`` ^^^^^^^^^^^^^^^^ diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h index cda8628183..d811f8a06e 100644 --- a/lib/librte_ethdev/rte_flow.h +++ b/lib/librte_ethdev/rte_flow.h @@ -1316,6 +1316,13 @@ enum rte_flow_action_type { */ RTE_FLOW_ACTION_TYPE_MARK, + /** + * Alter partial bits of mark ID set by RTE_FLOW_ACTION_TYPE_MARK. + * + * See struct rte_flow_action_modify_mark. + */ + RTE_FLOW_ACTION_TYPE_MODIFY_MARK, + /** * Flags packets. Similar to MARK without a specific value; only * sets the PKT_RX_FDIR mbuf flag. @@ -1681,6 +1688,23 @@ struct rte_flow_action_mark { uint32_t id; /**< Integer value to return with packets. */ }; +/** + * @warning + * @b EXPERIMENTAL: this structure may change without prior notice + * + * RTE_FLOW_ACTION_TYPE_MODIFY_MARK + * + * Alter partial bits of mark ID set by RTE_FLOW_ACTION_TYPE_MARK. + * + * Provided mask indicates which bits are modified. For bits which have never + * been set by mark action or modify_mark action, unpredictable value will be + * seen depending on driver implementation. + */ +struct rte_flow_action_modify_mark { + uint32_t id; /**< Integer value to return with packets. */ + uint32_t mask; /**< Mask of bits to modify. */ +}; + /** * @warning * @b EXPERIMENTAL: this structure may change without prior notice From patchwork Mon Jun 3 21:32:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yongseok Koh X-Patchwork-Id: 54271 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 BFAD31B9B8; Mon, 3 Jun 2019 23:32:51 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 59A1F1B9B1 for ; Mon, 3 Jun 2019 23:32:50 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE2 (envelope-from yskoh@mellanox.com) with ESMTPS (AES256-SHA encrypted); 4 Jun 2019 00:32:49 +0300 Received: from scfae-sc-2.mti.labs.mlnx (scfae-sc-2.mti.labs.mlnx [10.101.0.96]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x53LWeDF020818; Tue, 4 Jun 2019 00:32:47 +0300 From: Yongseok Koh To: shahafs@mellanox.com, thomas@monjalon.net, ferruh.yigit@intel.com, arybchenko@solarflare.com, adrien.mazarguil@6wind.com, olivier.matz@6wind.com Cc: dev@dpdk.org Date: Mon, 3 Jun 2019 14:32:31 -0700 Message-Id: <20190603213231.27020-3-yskoh@mellanox.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190603213231.27020-1-yskoh@mellanox.com> References: <20190603213231.27020-1-yskoh@mellanox.com> MIME-Version: 1.0 Subject: [dpdk-dev] [RFC 3/3] ethdev: add flow tag 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" A tag is a transient data which can be used during flow match. This can be used to store match result from a previous table so that the same pattern need not be matched again on the next table. Even if outer header is decapsulated on the previous match, the match result can be kept. Some device expose internal registers of its flow processing pipeline and those registers are quite useful for stateful connection tracking as it keeps status of flow matching. Multiple tags are supported by specifying index. Example testpmd commands are: flow create 0 ingress pattern ... / end actions set_tag index 2 value 0xaa00bb mask 0xffff00ff / set_tag index 3 value 0x123456 mask 0xffffff / vxlan_decap / jump group 1 / end flow create 0 ingress pattern ... / end actions set_tag index 2 value 0xcc00 mask 0xff00 / set_tag index 3 value 0x123456 mask 0xffffff / vxlan_decap / jump group 1 / end flow create 0 ingress group 1 pattern tag index is 2 value spec 0xaa00bb value mask 0xffff00ff / eth ... / end actions ... jump group 2 / end flow create 0 ingress group 1 pattern tag index is 2 value spec 0xcc00 value mask 0xff00 / tag index is 3 value spec 0x123456 value mask 0xffffff / eth ... / end actions ... / end flow create 0 ingress group 2 pattern tag index is 3 value spec 0x123456 value mask 0xffffff / eth ... / end actions ... / end Signed-off-by: Yongseok Koh --- doc/guides/prog_guide/rte_flow.rst | 50 +++++++++++++++++++++++++++ lib/librte_ethdev/rte_flow.h | 54 ++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 2907edfff4..f6ef4305b4 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -684,6 +684,34 @@ field with PKT_RX_METADATA flag. | ``mask`` | ``data`` | bit-mask applies to "spec" and "last" | +----------+----------+---------------------------------------+ +Item: ``TAG`` +^^^^^^^^^^^^^ + +Matches tag item set by other flows. Multiple tags are supported by specifying +``index``. + +- Default ``mask`` matches the specified tag value and index. + +.. _table_rte_flow_item_tag: + +.. table:: TAG + + +----------+----------+----------------------------------------+ + | Field | Subfield | Value | + +==========+===========+=======================================+ + | ``spec`` | ``data`` | 32 bit flow tag value | + | +-----------+---------------------------------------+ + | | ``index`` | index of flow tag | + +----------+-----------+---------------------------------------+ + | ``last`` | ``data`` | upper range value | + | +-----------+ | + | | ``index`` | | + +----------+-----------+---------------------------------------+ + | ``mask`` | ``data`` | bit-mask applies to "spec" and "last" | + | +-----------+ | + | | ``index`` | | + +----------+-----------+---------------------------------------+ + Data matching item types ~~~~~~~~~~~~~~~~~~~~~~~~ @@ -2397,6 +2425,28 @@ the other path depending on HW capability. | ``mask`` | bit-mask applies to "data" | +----------+----------------------------+ +Action: ``SET_TAG`` +^^^^^^^^^^^^^^^^^^^ + +Set Tag. + +Tag is a transient data used during flow matching. This is not delivered to +application. Multiple tags are supported by specifying index. + +.. _table_rte_flow_action_set_tag: + +.. table:: SET_TAG + + +-----------+----------------------------+ + | Field | Value | + +===========+============================+ + | ``data`` | 32 bit tag value | + +-----------+----------------------------+ + | ``mask`` | bit-mask applies to "data" | + +-----------+----------------------------+ + | ``index`` | index of tag to set | + +-----------+----------------------------+ + Negative types ~~~~~~~~~~~~~~ diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h index d811f8a06e..5ee2bc95c6 100644 --- a/lib/librte_ethdev/rte_flow.h +++ b/lib/librte_ethdev/rte_flow.h @@ -422,6 +422,15 @@ enum rte_flow_item_type { * See struct rte_flow_item_meta. */ RTE_FLOW_ITEM_TYPE_META, + + /** + * [META] + * + * Matches a tag value. + * + * See struct rte_flow_item_tag. + */ + RTE_FLOW_ITEM_TYPE_TAG, }; /** @@ -1187,6 +1196,27 @@ static const struct rte_flow_item_meta rte_flow_item_meta_mask = { }; #endif +/** + * @warning + * @b EXPERIMENTAL: this structure may change without prior notice + * + * RTE_FLOW_ITEM_TYPE_TAG + * + * Matches a specified tag value at the specified index. + */ +struct rte_flow_item_tag { + uint32_t data; + uint8_t index; +}; + +/** Default mask for RTE_FLOW_ITEM_TYPE_TAG. */ +#ifndef __cplusplus +static const struct rte_flow_item_tag rte_flow_item_rx_meta_mask = { + .data = 0xffffffff, + .index = 0xff, +}; +#endif + /** * @warning * @b EXPERIMENTAL: this structure may change without prior notice @@ -1672,6 +1702,15 @@ enum rte_flow_action_type { * See struct rte_flow_action_set_meta. */ RTE_FLOW_ACTION_TYPE_SET_META, + + /** + * Set Tag. + * + * Tag is not delivered to application. + * + * See struct rte_flow_action_set_tag. + */ + RTE_FLOW_ACTION_TYPE_SET_TAG, }; /** @@ -2192,6 +2231,21 @@ struct rte_flow_action_set_meta { rte_be32_t mask; }; +/** + * @warning + * @b EXPERIMENTAL: this structure may change without prior notice + * + * RTE_FLOW_ACTION_TYPE_SET_TAG + * + * Set a tag which is a transient data used during flow matching. This is not + * delivered to application. Multiple tags are supported by specifying index. + */ +struct rte_flow_action_set_tag { + uint32_t data; + uint32_t mask; + uint8_t index; +}; + /* * Definition of a single action. *