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 D2F18A0540; Thu, 7 Jul 2022 08:57:55 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C4CE4410D3; Thu, 7 Jul 2022 08:57:55 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 5D545406B4 for ; Thu, 7 Jul 2022 08:57:54 +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 266NFQOq008098; Wed, 6 Jul 2022 23:57:53 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=VyRqtyV/ow+ini9tUmLuzI05GVcq3ifSwLpzrDXeANM=; b=aO45yCFijKUx8HyVE+8OEWLTPbhHG1+0LBlbOupuoPpY8xu4p+AzH6WB0Wd2fVZbr99P 3cnKdckaNqsz1kStcRqc929WM6lrZpEpmEhBZ8arbrXe1Cc7gaoIamU3MBKlo7cxx/gi CRMCxL6wAcNuLEBPNOLgvfmZguh7tUuEc1Lw+2lpDe3MnOscChWktHmZsEm/run4+TUZ NWtycbnJWzZ9SpaV9Vfe52+hnKgF62SgHzCLDg3TRpj0gDBe+3Vi/8sNdX30alvJlW1Y FtC2ywyIfPxnHyiD4UDzzDxPXRNokMIFxIingMVIZ+0mK7Qzqw2yCxn+SGjjFdipuVSp IQ== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3h5kwj1c9q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 06 Jul 2022 23:57:53 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 6 Jul 2022 23:57:51 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Wed, 6 Jul 2022 23:57:51 -0700 Received: from localhost.localdomain (unknown [10.28.34.25]) by maili.marvell.com (Postfix) with ESMTP id A94E03F7061; Wed, 6 Jul 2022 23:57:47 -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] ethdev: add protocol param to color table update Date: Thu, 7 Jul 2022 12:27:43 +0530 Message-ID: <20220707065743.76932-1-skori@marvell.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: z9511yJ_dQ0fHmWon1qYS2BFqxvMK5rk X-Proofpoint-GUID: z9511yJ_dQ0fHmWon1qYS2BFqxvMK5rk X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-07_04,2022-06-28_01,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. Depends-on: series-23647 ("common/cnxk: update precolor table setup for VLAN") Signed-off-by: Sunil Kumar Kori --- 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 b92e66cedb..c3644ef443 100644 --- a/app/test-pmd/cmdline_mtr.c +++ b/app/test-pmd/cmdline_mtr.c @@ -293,8 +293,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; @@ -322,6 +322,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; @@ -331,7 +341,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; @@ -359,6 +369,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; @@ -1384,6 +1404,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; @@ -1392,7 +1413,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; @@ -1402,7 +1424,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); @@ -1414,7 +1436,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, @@ -1457,6 +1479,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; @@ -1465,7 +1488,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; @@ -1475,7 +1499,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); @@ -1487,7 +1511,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