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 33AA3A0093; Tue, 23 Aug 2022 12:23:07 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2599E40DDA; Tue, 23 Aug 2022 12:23:07 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 3B8DC400D6 for ; Tue, 23 Aug 2022 12:23:05 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 27NAIJYV025034; Tue, 23 Aug 2022 03:23:04 -0700 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=48l1+aAjdzm0rZTIewlEP2TpUt23+cbijco4GexUSc4=; b=Nl1L56VzdHXUNWbIus+zovcVmmFsmg71s9MCeezHKjw5+EHbgHebCeFu4q6ouT8Shi9t YK7MEqy1/YRM2MxWRAcAJY9XcDYu6B1Wf5J/7Ucf22WayGP9ua/d5WifcGqKz9M7Btl3 aAaEljyPuDp6KaMaa24WVlE3D38PA714UweCfjMe08d71+d+e/Sm1G19JvPrQwBTvdFz HOTr0+YCqlcwO9ANn6Sek0qFYnGPyG9LZf0OiTz490ktLN4NFWroS/U/mDzfxnXLiA44 gs6phh5HTM34kVG/X+BQ4nTuPLXVMpnNEvaqSGxksEdHwgB8bRIoTZ+c6cBiA8q0zL6J 5A== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3j4ubj8e9n-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 23 Aug 2022 03:23:04 -0700 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; Tue, 23 Aug 2022 03:23:02 -0700 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; Tue, 23 Aug 2022 03:23:02 -0700 Received: from localhost.localdomain (unknown [10.28.34.25]) by maili.marvell.com (Postfix) with ESMTP id 51DC55B6929; Tue, 23 Aug 2022 03:22:59 -0700 (PDT) From: To: Cristian Dumitrescu , Aman Singh , Yuying Zhang , "Nithin Dabilpuram" , Kiran Kumar K , Sunil Kumar Kori , Satha Rao , Jasvinder Singh , "Thomas Monjalon" , Ferruh Yigit , Andrew Rybchenko CC: Subject: [PATCH v2 1/1] ethdev: add protocol param to color table update Date: Tue, 23 Aug 2022 15:52:55 +0530 Message-ID: <20220823102255.2905191-1-skori@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220707065743.76932-1-skori@marvell.com> References: <20220707065743.76932-1-skori@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: bbzr8VLT13NRsvQ1vNaXyMUvs4kO-CDA X-Proofpoint-ORIG-GUID: bbzr8VLT13NRsvQ1vNaXyMUvs4kO-CDA X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-08-23_04,2022-08-22_02,2022-06-22_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: Sunil Kumar Kori Using rte_mtr_color_in_protocol_set(), user can configure combination of protocol headers, like outer_vlan and outer_ip, can be enabled on given meter object. But rte_mtr_meter_vlan_table_update() and rte_mtr_meter_dscp_table_update() do not have information that which table needs to be updated corresponding to protocol header i.e. inner or outer. Adding protocol paramreter will allow user to provide required protocol information so that corresponding inner or outer table can be updated corresponding to protocol header. If user wishes to configure both inner and outer table then API must be called twice with correct protocol information. Signed-off-by: Sunil Kumar Kori --- v1..v2: - Rebase on ToT of dpdk-next-net-mrvl/for-next-net branch. - Remove "Depends On:" tag as dependent patch is merged. app/test-pmd/cmdline_mtr.c | 42 ++++++++++++++++----- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 8 ++-- drivers/net/cnxk/cnxk_ethdev_mtr.c | 20 +++++++++- drivers/net/softnic/rte_eth_softnic_meter.c | 4 +- lib/ethdev/rte_mtr.c | 8 ++-- lib/ethdev/rte_mtr.h | 7 +++- lib/ethdev/rte_mtr_driver.h | 4 +- 7 files changed, 70 insertions(+), 23 deletions(-) diff --git a/app/test-pmd/cmdline_mtr.c b/app/test-pmd/cmdline_mtr.c index 833273da0d..f517a328b7 100644 --- a/app/test-pmd/cmdline_mtr.c +++ b/app/test-pmd/cmdline_mtr.c @@ -297,8 +297,8 @@ parse_meter_color_str(char *c_str, uint32_t *use_prev_meter_color, } static int -parse_multi_token_string(char *t_str, uint16_t *port_id, - uint32_t *mtr_id, enum rte_color **dscp_table) +parse_multi_token_string(char *t_str, uint16_t *port_id, uint32_t *mtr_id, + enum rte_mtr_color_in_protocol *proto, enum rte_color **dscp_table) { char *token; uint64_t val; @@ -326,6 +326,16 @@ parse_multi_token_string(char *t_str, uint16_t *port_id, *mtr_id = val; + /* Third token: protocol */ + token = strtok_r(t_str, PARSE_DELIMITER, &t_str); + if (token == NULL) + return 0; + + if (strcmp(token, "outer_ip") == 0) + *proto = RTE_MTR_COLOR_IN_PROTO_OUTER_IP; + else if (strcmp(token, "inner_ip") == 0) + *proto = RTE_MTR_COLOR_IN_PROTO_INNER_IP; + ret = parse_dscp_table_entries(t_str, dscp_table); if (ret != 0) return -1; @@ -335,7 +345,7 @@ parse_multi_token_string(char *t_str, uint16_t *port_id, static int parse_multi_token_vlan_str(char *t_str, uint16_t *port_id, uint32_t *mtr_id, - enum rte_color **vlan_table) + enum rte_mtr_color_in_protocol *proto, enum rte_color **vlan_table) { uint64_t val; char *token; @@ -363,6 +373,16 @@ parse_multi_token_vlan_str(char *t_str, uint16_t *port_id, uint32_t *mtr_id, *mtr_id = val; + /* Third token: protocol */ + token = strtok_r(t_str, PARSE_DELIMITER, &t_str); + if (token == NULL) + return 0; + + if (strcmp(token, "outer_vlan") == 0) + *proto = RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN; + else if (strcmp(token, "inner_vlan") == 0) + *proto = RTE_MTR_COLOR_IN_PROTO_INNER_VLAN; + ret = parse_vlan_table_entries(t_str, vlan_table); if (ret != 0) return -1; @@ -1388,6 +1408,7 @@ static void cmd_set_port_meter_dscp_table_parsed(void *parsed_result, __rte_unused void *data) { struct cmd_set_port_meter_dscp_table_result *res = parsed_result; + enum rte_mtr_color_in_protocol proto = 0; struct rte_mtr_error error; enum rte_color *dscp_table = NULL; char *t_str = res->token_string; @@ -1396,7 +1417,8 @@ static void cmd_set_port_meter_dscp_table_parsed(void *parsed_result, int ret; /* Parse string */ - ret = parse_multi_token_string(t_str, &port_id, &mtr_id, &dscp_table); + ret = parse_multi_token_string(t_str, &port_id, &mtr_id, &proto, + &dscp_table); if (ret) { fprintf(stderr, " Multi token string parse error\n"); return; @@ -1406,7 +1428,7 @@ static void cmd_set_port_meter_dscp_table_parsed(void *parsed_result, goto free_table; /* Update Meter DSCP Table*/ - ret = rte_mtr_meter_dscp_table_update(port_id, mtr_id, + ret = rte_mtr_meter_dscp_table_update(port_id, mtr_id, proto, dscp_table, &error); if (ret != 0) print_err_msg(&error); @@ -1418,7 +1440,7 @@ static void cmd_set_port_meter_dscp_table_parsed(void *parsed_result, cmdline_parse_inst_t cmd_set_port_meter_dscp_table = { .f = cmd_set_port_meter_dscp_table_parsed, .data = NULL, - .help_str = "set port meter dscp table " + .help_str = "set port meter dscp table " "[ ... ]", .tokens = { (void *)&cmd_set_port_meter_dscp_table_set, @@ -1461,6 +1483,7 @@ static void cmd_set_port_meter_vlan_table_parsed(void *parsed_result, __rte_unused void *data) { struct cmd_set_port_meter_vlan_table_result *res = parsed_result; + enum rte_mtr_color_in_protocol proto = 0; struct rte_mtr_error error; enum rte_color *vlan_table = NULL; char *t_str = res->token_string; @@ -1469,7 +1492,8 @@ static void cmd_set_port_meter_vlan_table_parsed(void *parsed_result, int ret; /* Parse string */ - ret = parse_multi_token_vlan_str(t_str, &port_id, &mtr_id, &vlan_table); + ret = parse_multi_token_vlan_str(t_str, &port_id, &mtr_id, &proto, + &vlan_table); if (ret) { fprintf(stderr, " Multi token string parse error\n"); return; @@ -1479,7 +1503,7 @@ static void cmd_set_port_meter_vlan_table_parsed(void *parsed_result, goto free_table; /* Update Meter VLAN Table*/ - ret = rte_mtr_meter_vlan_table_update(port_id, mtr_id, + ret = rte_mtr_meter_vlan_table_update(port_id, mtr_id, proto, vlan_table, &error); if (ret != 0) print_err_msg(&error); @@ -1491,7 +1515,7 @@ static void cmd_set_port_meter_vlan_table_parsed(void *parsed_result, cmdline_parse_inst_t cmd_set_port_meter_vlan_table = { .f = cmd_set_port_meter_vlan_table_parsed, .data = NULL, - .help_str = "set port meter vlan table " + .help_str = "set port meter vlan table " "[ ... ]", .tokens = { (void *)&cmd_set_port_meter_vlan_table_set, diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 330e34427d..ce40e3b6f2 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -2597,15 +2597,15 @@ set port meter dscp table Set meter dscp table for the ethernet device:: - testpmd> set port meter dscp table (port_id) (mtr_id) [(dscp_tbl_entry0) \ - (dscp_tbl_entry1)...(dscp_tbl_entry63)] + testpmd> set port meter dscp table (port_id) (mtr_id) (proto) \ + [(dscp_tbl_entry0) (dscp_tbl_entry1)...(dscp_tbl_entry63)] set port meter vlan table ~~~~~~~~~~~~~~~~~~~~~~~~~ Set meter VLAN table for the Ethernet device:: - testpmd> set port meter vlan table (port_id) (mtr_id) [(vlan_tbl_entry0) \ - (vlan_tbl_entry1)...(vlan_tbl_entry15)] + testpmd> set port meter vlan table (port_id) (mtr_id) (proto) \ + [(vlan_tbl_entry0) (vlan_tbl_entry1)...(vlan_tbl_entry15)] set port meter protocol ~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/drivers/net/cnxk/cnxk_ethdev_mtr.c b/drivers/net/cnxk/cnxk_ethdev_mtr.c index be2cb7d628..0fa18f01c7 100644 --- a/drivers/net/cnxk/cnxk_ethdev_mtr.c +++ b/drivers/net/cnxk/cnxk_ethdev_mtr.c @@ -720,6 +720,7 @@ cnxk_nix_mtr_disable(struct rte_eth_dev *eth_dev, uint32_t mtr_id, static int cnxk_nix_mtr_dscp_table_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id, + enum rte_mtr_color_in_protocol proto, enum rte_color *dscp_table, struct rte_mtr_error *error) { @@ -750,7 +751,7 @@ cnxk_nix_mtr_dscp_table_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id, table.count = ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP; - switch (dev->proto) { + switch (proto) { case RTE_MTR_COLOR_IN_PROTO_OUTER_IP: table.mode = ROC_NIX_BPF_PC_MODE_DSCP_OUTER; break; @@ -764,6 +765,13 @@ cnxk_nix_mtr_dscp_table_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id, goto exit; } + if (dev->proto != proto) { + rc = -rte_mtr_error_set(error, EINVAL, + RTE_MTR_ERROR_TYPE_UNSPECIFIED, NULL, + "input color protocol is not configured"); + goto exit; + } + for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_DSCP; i++) table.color[i] = nix_dscp_tbl[i]; @@ -784,6 +792,7 @@ cnxk_nix_mtr_dscp_table_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id, static int cnxk_nix_mtr_vlan_table_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id, + enum rte_mtr_color_in_protocol proto, enum rte_color *vlan_table, struct rte_mtr_error *error) { @@ -814,7 +823,7 @@ cnxk_nix_mtr_vlan_table_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id, table.count = ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN; - switch (dev->proto) { + switch (proto) { case RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN: table.mode = ROC_NIX_BPF_PC_MODE_VLAN_OUTER; break; @@ -828,6 +837,13 @@ cnxk_nix_mtr_vlan_table_update(struct rte_eth_dev *eth_dev, uint32_t mtr_id, goto exit; } + if (dev->proto != proto) { + rc = -rte_mtr_error_set(error, EINVAL, + RTE_MTR_ERROR_TYPE_UNSPECIFIED, NULL, + "input color protocol is not configured"); + goto exit; + } + for (i = 0; i < ROC_NIX_BPF_PRECOLOR_TBL_SIZE_VLAN; i++) table.color[i] = nix_vlan_tbl[i]; diff --git a/drivers/net/softnic/rte_eth_softnic_meter.c b/drivers/net/softnic/rte_eth_softnic_meter.c index 6b02f43e31..3e635a3cfe 100644 --- a/drivers/net/softnic/rte_eth_softnic_meter.c +++ b/drivers/net/softnic/rte_eth_softnic_meter.c @@ -636,7 +636,7 @@ pmd_mtr_meter_profile_update(struct rte_eth_dev *dev, /* MTR object meter DSCP table update */ static int pmd_mtr_meter_dscp_table_update(struct rte_eth_dev *dev, - uint32_t mtr_id, + uint32_t mtr_id, enum rte_mtr_color_in_protocol proto, enum rte_color *dscp_table, struct rte_mtr_error *error) { @@ -648,6 +648,8 @@ pmd_mtr_meter_dscp_table_update(struct rte_eth_dev *dev, uint32_t table_id, i; int status; + RTE_SET_USED(proto); + /* MTR object id must be valid */ m = softnic_mtr_find(p, mtr_id); if (m == NULL) diff --git a/lib/ethdev/rte_mtr.c b/lib/ethdev/rte_mtr.c index c460e4f4e0..e4dff20f76 100644 --- a/lib/ethdev/rte_mtr.c +++ b/lib/ethdev/rte_mtr.c @@ -197,25 +197,25 @@ rte_mtr_meter_policy_update(uint16_t port_id, /** MTR object meter DSCP table update */ int rte_mtr_meter_dscp_table_update(uint16_t port_id, - uint32_t mtr_id, + uint32_t mtr_id, enum rte_mtr_color_in_protocol proto, enum rte_color *dscp_table, struct rte_mtr_error *error) { struct rte_eth_dev *dev = &rte_eth_devices[port_id]; return RTE_MTR_FUNC(port_id, meter_dscp_table_update)(dev, - mtr_id, dscp_table, error); + mtr_id, proto, dscp_table, error); } /** MTR object meter VLAN table update */ int rte_mtr_meter_vlan_table_update(uint16_t port_id, - uint32_t mtr_id, + uint32_t mtr_id, enum rte_mtr_color_in_protocol proto, enum rte_color *vlan_table, struct rte_mtr_error *error) { struct rte_eth_dev *dev = &rte_eth_devices[port_id]; return RTE_MTR_FUNC(port_id, meter_vlan_table_update)(dev, - mtr_id, vlan_table, error); + mtr_id, proto, vlan_table, error); } /** Set the input color protocol on MTR object */ diff --git a/lib/ethdev/rte_mtr.h b/lib/ethdev/rte_mtr.h index 008bc84f0d..5e4f7ba73b 100644 --- a/lib/ethdev/rte_mtr.h +++ b/lib/ethdev/rte_mtr.h @@ -913,6 +913,8 @@ rte_mtr_meter_policy_update(uint16_t port_id, * The port identifier of the Ethernet device. * @param[in] mtr_id * MTR object ID. Needs to be valid. + * @param[in] proto + * Input color protocol. * @param[in] dscp_table * 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 @@ -927,7 +929,7 @@ rte_mtr_meter_policy_update(uint16_t port_id, __rte_experimental int rte_mtr_meter_dscp_table_update(uint16_t port_id, - uint32_t mtr_id, + uint32_t mtr_id, enum rte_mtr_color_in_protocol proto, enum rte_color *dscp_table, struct rte_mtr_error *error); @@ -938,6 +940,8 @@ rte_mtr_meter_dscp_table_update(uint16_t port_id, * The port identifier of the Ethernet device. * @param[in] mtr_id * MTR object ID. Needs to be valid. + * @param[in] proto + * Input color protocol. * @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 @@ -952,6 +956,7 @@ rte_mtr_meter_dscp_table_update(uint16_t port_id, __rte_experimental int rte_mtr_meter_vlan_table_update(uint16_t port_id, uint32_t mtr_id, + enum rte_mtr_color_in_protocol proto, enum rte_color *vlan_table, struct rte_mtr_error *error); diff --git a/lib/ethdev/rte_mtr_driver.h b/lib/ethdev/rte_mtr_driver.h index f7dca9a54c..a8b652a607 100644 --- a/lib/ethdev/rte_mtr_driver.h +++ b/lib/ethdev/rte_mtr_driver.h @@ -93,13 +93,13 @@ typedef int (*rte_mtr_meter_policy_update_t)(struct rte_eth_dev *dev, /** @internal MTR object meter DSCP table update. */ typedef int (*rte_mtr_meter_dscp_table_update_t)(struct rte_eth_dev *dev, - uint32_t mtr_id, + uint32_t mtr_id, enum rte_mtr_color_in_protocol proto, enum rte_color *dscp_table, struct rte_mtr_error *error); /** @internal mtr object meter vlan table update. */ typedef int (*rte_mtr_meter_vlan_table_update_t)(struct rte_eth_dev *dev, - uint32_t mtr_id, + uint32_t mtr_id, enum rte_mtr_color_in_protocol proto, enum rte_color *vlan_table, struct rte_mtr_error *error); -- 2.25.1