From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 110B7A034C; Mon, 14 Feb 2022 12:56:03 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D277E4114E; Mon, 14 Feb 2022 12:56:02 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 886A8410F3 for ; Mon, 14 Feb 2022 12:56:01 +0100 (CET) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 21EBK8CP006574; Mon, 14 Feb 2022 03:55:39 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=D7rw4nd9hFZhg97QCZXF8rARBxSphCDATvKWEtj2sWw=; b=HWFEHmZvRG6XKVayOAaqF5q6CXFcwYfcfXhfjD98KTP8jcc/v3gB0AisXIEOEny/5Ll/ gASC2Zhu+80yAQcssOp1Sm7C2N2WBCeiN0EfjsBmA/YYFUe/HWnuHjZ+CU++vv2Gq400 hjMLoqt72GCY0YoRt7Q+vK7UoXE1iE5sIbsTOaoqxO3IjlNcgWBj+xeCXBGUrTJDhC0r 9hPyNwZ1xjXsBfgYW/7i96Hv+sVYWzJuNWQP7cQvfmMtc4e5gibgmk9vbkWILnyr9anQ +kec14jSPhDjwVCtCo9D6GtDauIbnRRdwkWKItUhXYi69ksXnJyJRhy3fUZQN2xZlCE4 Jg== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3e7dbc1w3e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 14 Feb 2022 03:55:39 -0800 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 14 Feb 2022 03:55:37 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Mon, 14 Feb 2022 03:55:37 -0800 Received: from jerin-lab.marvell.com (jerin-lab.marvell.com [10.28.34.14]) by maili.marvell.com (Postfix) with ESMTP id DCDA03F7084; Mon, 14 Feb 2022 03:55:19 -0800 (PST) From: To: , Cristian Dumitrescu , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko , Ray Kinsella CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Jerin Jacob Subject: [dpdk-dev] [v22.07] [PATCH] ethdev: mtr: support input color selection Date: Mon, 14 Feb 2022 17:26:11 +0530 Message-ID: <20220214115612.4173225-1-jerinj@marvell.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20210820082401.3778736-1-jerinj@marvell.com> References: <20210820082401.3778736-1-jerinj@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: 6hsGbxKoCGFwEMbFnspEZweGYxGVEjeP X-Proofpoint-ORIG-GUID: 6hsGbxKoCGFwEMbFnspEZweGYxGVEjeP X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-14_04,2022-02-14_03,2021-12-02_01 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: Jerin Jacob Currently, meter object supports only DSCP based on input color table, The patch enhance that to support VLAN based input color table, color table based on inner field for the tunnel use case, and support for fallback color per meter if packet based on a different field. All of the above features are exposed through capability and added additional capability to specify the implementation supports more than one input color table per ethdev port Suggested-by: Cristian Dumitrescu Signed-off-by: Jerin Jacob --- v1..RFC: Address the review comments by Cristian at https://patches.dpdk.org/project/dpdk/patch/20210820082401.3778736-1-jerinj@marvell.com/ - Moved to v22.07 release - Updated rte_mtr_input_color_method to support all VLAN, DSCP, Inner cases - Added input_color_method - Removed union between vlan_table and dscp_table - Kept VLAN instead of PCP as HW coloring based on DEI(1bit), PCP(3 bits) What is missing: - 22.07 release notes update - Testpmd and driver updates(Waiting for the review comments v1 API spec) .../traffic_metering_and_policing.rst | 27 +++ lib/ethdev/rte_mtr.h | 162 +++++++++++++++++- lib/ethdev/version.map | 3 + 3 files changed, 190 insertions(+), 2 deletions(-) diff --git a/doc/guides/prog_guide/traffic_metering_and_policing.rst b/doc/guides/prog_guide/traffic_metering_and_policing.rst index ceb5a96488..97d27c92e3 100644 --- a/doc/guides/prog_guide/traffic_metering_and_policing.rst +++ b/doc/guides/prog_guide/traffic_metering_and_policing.rst @@ -21,6 +21,7 @@ The main features are: * Policer actions (per meter output color): recolor, drop * Statistics (per policer output color) * Chaining multiple meter objects +* Packet content based input color selection Configuration steps ------------------- @@ -105,3 +106,29 @@ traffic meter and policing library. * Adding one (or multiple) actions of the type ``RTE_FLOW_ACTION_TYPE_METER`` to the list of meter actions (``struct rte_mtr_meter_policy_params::actions``) specified per color as show in :numref:`figure_rte_mtr_chaining`. + +Packet content based input color selection +------------------------------------------ + +The API supports selecting the input color based on the packet content. +Following is the API usage model for the same. + +#. Probe the input color selection device capabilities using following + parameter using ``rte_mtr_capabilities_get()`` API + ``struct rte_mtr_capabilities::rte_mtr_input_color_method`` and + ``struct rte_mtr_capabilitie::seperate_input_color_table_per_port`` +#. When creating the meter object using ``rte_mtr_create()``, configure + relevant input color selection parameters such as + + * Select the input color method ``struct rte_mtr_params::input_color_method`` + + * Fill the tables ``struct rte_mtr_params::dscp_table``, + ``struct rte_mtr_params::dscp_table`` based on input color selected + + * Update the ``struct rte_mtr_params::default_input_color`` to determine + the default input color in case the input packet does not match + the input color method + + * If needed, update the input color table at runtime using + ``rte_mtr_meter_vlan_table_update()`` and ``rte_mtr_meter_dscp_table_update()`` + APIs. diff --git a/lib/ethdev/rte_mtr.h b/lib/ethdev/rte_mtr.h index 40df0888c8..3caea823ad 100644 --- a/lib/ethdev/rte_mtr.h +++ b/lib/ethdev/rte_mtr.h @@ -213,6 +213,80 @@ struct rte_mtr_meter_policy_params { const struct rte_flow_action *actions[RTE_COLORS]; }; +/** + * Input color method + */ +enum rte_mtr_input_color_method { + /** + * The input color is always green. + * The default_input_color is ignored for this method. + * @see struct rte_mtr_params::default_input_color + */ + RTE_MTR_INPUT_COLOR_METHOD_COLOR_BLIND, + /** + * If the input packet has at least one VLAN label, its input color is + * detected by the outermost VLAN DEI(1bit), PCP(3 bits) + * indexing into the struct rte_mtr_params::vlan_table. + * Otherwise, the default_input_color is applied. + * @see struct rte_mtr_params::default_input_color + * @see struct rte_mtr_params::vlan_table + */ + RTE_MTR_INPUT_COLOR_METHOD_VLAN, + /** + * If the input packet is IPv4 or IPv6, its input color is detected by + * the outermost DSCP field indexing into the + * struct rte_mtr_params::dscp_table. + * Otherwise, the default_input_color is applied. + * @see struct rte_mtr_params::default_input_color + * @see struct rte_mtr_params::dscp_table + */ + RTE_MTR_INPUT_COLOR_METHOD_DSCP, + /** + * If the input packet has at least one VLAN label, its input color is + * detected by the outermost VLAN DEI(1bit), PCP(3 bits) + * indexing into the struct rte_mtr_params::vlan_table. + * If the input packet is IPv4 or IPv6, its input color is detected by + * the outermost DSCP field indexing into the + * struct rte_mtr_params::dscp_table. + * Otherwise, the default_input_color is applied. + * @see struct rte_mtr_params::default_input_color + * @see struct rte_mtr_params::vlan_table + * @see struct rte_mtr_params::dscp_table + */ + RTE_MTR_INPUT_COLOR_METHOD_VLAN_DSCP, + /** + * If the input packet has at least one VLAN label, its input color is + * detected by the innermost VLAN DEI(1bit), PCP(3 bits) + * indexing into the struct rte_mtr_params::vlan_table. + * Otherwise, the default_input_color is applied. + * @see struct rte_mtr_params::default_input_color + * @see struct rte_mtr_params::vlan_table + */ + RTE_MTR_INPUT_COLOR_METHOD_INNER_VLAN, + /** + * If the input packet is IPv4 or IPv6, its input color is detected by + * the innermost DSCP field indexing into the + * struct rte_mtr_params::dscp_table. + * Otherwise, the default_input_color is applied. + * @see struct rte_mtr_params::default_input_color + * @see struct rte_mtr_params::dscp_table + */ + RTE_MTR_INPUT_COLOR_METHOD_INNER_DSCP, + /** + * If the input packet has at least one VLAN label, its input color is + * detected by the innermost VLAN DEI(1bit), PCP(3 bits) + * indexing into the struct rte_mtr_params::vlan_table. + * If the input packet is IPv4 or IPv6, its input color is detected by + * the innermost DSCP field indexing into the + * struct rte_mtr_params::dscp_table. + * Otherwise, the default_input_color is applied. + * @see struct rte_mtr_params::default_input_color + * @see struct rte_mtr_params::vlan_table + * @see struct rte_mtr_params::dscp_table + */ + RTE_MTR_INPUT_COLOR_METHOD_INNER_VLAN_DSCP, +}; + /** * Parameters for each traffic metering & policing object * @@ -233,7 +307,15 @@ struct rte_mtr_params { */ int use_prev_mtr_color; - /** Meter input color. When non-NULL: it points to a pre-allocated and + /** Meter input color based on IP DSCP field. + * + * Valid when input_color_method set to any of the following + * RTE_MTR_INPUT_COLOR_METHOD_DSCP, + * RTE_MTR_INPUT_COLOR_METHOD_VLAN_DSCP, + * RTE_MTR_INPUT_COLOR_METHOD_INNER_DSCP, + * RTE_MTR_INPUT_COLOR_METHOD_INNER_VLAN_DSCP + * + * When non-NULL: it points to a pre-allocated and * pre-populated table with exactly 64 elements providing the input * color for each value of the IPv4/IPv6 Differentiated Services Code * Point (DSCP) input packet field. When NULL: it is equivalent to @@ -244,9 +326,39 @@ struct rte_mtr_params { * *use_prev_mtr_color* is non-zero value or when *dscp_table* contains * at least one yellow or red color element, then the color aware mode * is configured. + * @see enum rte_mtr_input_color_method::RTE_MTR_INPUT_COLOR_METHOD_DSCP + * @see enum rte_mtr_input_color_method::RTE_MTR_INPUT_COLOR_METHOD_VLAN_DSCP + * @see enum rte_mtr_input_color_method::RTE_MTR_INPUT_COLOR_METHOD_INNER_DSCP + * @see enum rte_mtr_input_color_method::RTE_MTR_INPUT_COLOR_METHOD_INNER_VLAN_DSCP + * @see struct rte_mtr_params::input_color_method */ enum rte_color *dscp_table; - + /** Meter input color based on VLAN DEI(1bit), PCP(3 bits) fields. + * + * Valid when input_color_method set to any of the following + * RTE_MTR_INPUT_COLOR_METHOD_VLAN, + * RTE_MTR_INPUT_COLOR_METHOD_VLAN_DSCP, + * RTE_MTR_INPUT_COLOR_METHOD_INNER_VLAN, + * RTE_MTR_INPUT_COLOR_METHOD_INNER_VLAN_DSCP + * + * When non-NULL: it points to a pre-allocated and pre-populated + * table with exactly 16 elements providing the input color for + * each value of the DEI(1bit), PCP(3 bits) input packet field. + * When NULL: it is equivalent to setting this parameter to an + * all-green populated table (i.e. table with + * all the 16 elements set to green color). The color blind mode + * is configured by setting *use_prev_mtr_color* to 0 and + * *vlan_table* to either NULL or to an all-green + * populated table. When *use_prev_mtr_color* is non-zero value + * or when *vlan_table* contains at least one yellow or + * red color element, then the color aware mode is configured. + * @see enum rte_mtr_input_color_method::RTE_MTR_INPUT_COLOR_METHOD_VLAN + * @see enum rte_mtr_input_color_method::RTE_MTR_INPUT_COLOR_METHOD_VLAN_DSCP + * @see enum rte_mtr_input_color_method::RTE_MTR_INPUT_COLOR_METHOD_INNER_VLAN + * @see enum rte_mtr_input_color_method::RTE_MTR_INPUT_COLOR_METHOD_INNER_VLAN_DSCP + * @see struct rte_mtr_params::input_color_method + */ + enum rte_color *vlan_table; /** Non-zero to enable the meter, zero to disable the meter at the time * of MTR object creation. Ignored when the meter profile indicated by * *meter_profile_id* is set to NONE. @@ -261,6 +373,20 @@ struct rte_mtr_params { /** Meter policy ID. @see rte_mtr_meter_policy_add() */ uint32_t meter_policy_id; + + /** Input color method to select. + * @see struct rte_mtr_params::dscp_table + * @see struct rte_mtr_params::vlan_table + */ + enum rte_mtr_input_color_method input_color_method; + + /** Input color to be set for the input packet when none of the + * enabled input color methods is applicable to the input packet. + * Ignored when this method is set to the + * enum rte_mtr_input_color_method::RTE_MTR_INPUT_COLOR_METHOD_COLOR_BLIND + * method. + */ + enum rte_color default_input_color; }; /** @@ -417,6 +543,14 @@ struct rte_mtr_capabilities { * @see enum rte_mtr_stats_type */ uint64_t stats_mask; + + /** Input color methods supported. */ + enum rte_mtr_input_color_method methods_supported; + + /** When non-zero, it indicates that driver supports separate + * input color table for given ethdev port. + */ + int seperate_input_color_table_per_port; }; /** @@ -832,6 +966,30 @@ rte_mtr_meter_dscp_table_update(uint16_t port_id, enum rte_color *dscp_table, struct rte_mtr_error *error); +/** + * MTR object VLAN table update + * + * @param[in] port_id + * The port identifier of the Ethernet device. + * @param[in] mtr_id + * MTR object ID. Needs to be valid. + * @param[in] vlan_table + * When non-NULL: it points to a pre-allocated and pre-populated table with + * exactly 16 elements providing the input color for each value of the + * each value of the DEI(1bit), PCP(3 bits) input packet field. + * When NULL: it is equivalent to setting this parameter to an "all-green" + * populated table (i.e. table with all the 16 elements set to green color). + * @param[out] error + * Error details. Filled in only on error, when not NULL. + * @return + * 0 on success, non-zero error code otherwise. + */ +__rte_experimental +int +rte_mtr_meter_vlan_table_update(uint16_t port_id, + uint32_t mtr_id, + enum rte_color *vlan_table, + struct rte_mtr_error *error); /** * MTR object enabled statistics counters update * diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map index d5cc56a560..430c620490 100644 --- a/lib/ethdev/version.map +++ b/lib/ethdev/version.map @@ -264,6 +264,9 @@ EXPERIMENTAL { rte_eth_ip_reassembly_capability_get; rte_eth_ip_reassembly_conf_get; rte_eth_ip_reassembly_conf_set; + + # added in 22.07 + rte_mtr_meter_vlan_table_update; }; INTERNAL { -- 2.35.1