From patchwork Mon May 22 18:41:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Machon X-Patchwork-Id: 13250938 X-Patchwork-Delegate: dsahern@gmail.com Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A1E751641F for ; Mon, 22 May 2023 18:41:33 +0000 (UTC) Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CECED11A for ; Mon, 22 May 2023 11:41:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1684780889; x=1716316889; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=uYa82/qjX7//OFvIcicvGXMubHSVLKMTGcZH7kb3plo=; b=DeIpAokcrnDBJ7SgjgTmpBZRNYH9z4LfioqDRyw2gnYKMsIJsdwl5j5m 3gPWfFi14wstnvxPJw5UAQ9XTVR7GVDzaUvQOY4LYPHiblT+fD183L7iB hSG0hPLE3nBOForcKgqL4V+zXFBHZA39/WdiblcCFkNAHTE9wJqD1QDt+ BCNFi9fF0C2gq6eMw9y9WN/SZeZ2Hea3riGtgQqwy+pBXpXjEV1FXn11P /3+k+JmZKdU5DkccC6hUTObcA7gUbvbQpWBWIyJYVgpqKJ6aGR+NrX6IW 1XNyKbhR9NJjvJUK7kkNZ6YXngkXXGf3IRvUK8p4PRLb+d3CC3+s8rL1m w==; X-IronPort-AV: E=Sophos;i="6.00,184,1681196400"; d="scan'208";a="214969716" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 22 May 2023 11:41:28 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Mon, 22 May 2023 11:41:27 -0700 Received: from [10.205.21.38] (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2507.21 via Frontend Transport; Mon, 22 May 2023 11:41:25 -0700 From: Daniel Machon Date: Mon, 22 May 2023 20:41:04 +0200 Subject: [PATCH iproute2-next 1/9] dcb: app: expose dcb-app functions in new header Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20230510-dcb-rewr-v1-1-83adc1f93356@microchip.com> References: <20230510-dcb-rewr-v1-0-83adc1f93356@microchip.com> In-Reply-To: <20230510-dcb-rewr-v1-0-83adc1f93356@microchip.com> To: CC: , , , , X-Mailer: b4 0.12.2 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: dsahern@gmail.com Add new headerfile dcb-app.h that exposes the functions required later by dcb-rewr. The new dcb-rewr implementation will reuse much of the existing dcb-app code. I thought this called for a separate header file, instead of polluting the existing dcb.h file. Signed-off-by: Daniel Machon --- dcb/dcb.h | 9 ++------- dcb/dcb_app.c | 54 ++++++++++++++++++------------------------------------ dcb/dcb_app.h | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 43 deletions(-) diff --git a/dcb/dcb.h b/dcb/dcb.h index d40664f29dad..4c8a4aa25e0c 100644 --- a/dcb/dcb.h +++ b/dcb/dcb.h @@ -6,6 +6,8 @@ #include #include +#include "dcb_app.h" + /* dcb.c */ struct dcb { @@ -54,13 +56,6 @@ void dcb_print_array_on_off(const __u8 *array, size_t size); void dcb_print_array_kw(const __u8 *array, size_t array_size, const char *const kw[], size_t kw_size); -/* dcb_app.c */ - -int dcb_cmd_app(struct dcb *dcb, int argc, char **argv); -enum ieee_attrs_app dcb_app_attr_type_get(__u8 selector); -bool dcb_app_attr_type_validate(enum ieee_attrs_app type); -bool dcb_app_selector_validate(enum ieee_attrs_app type, __u8 selector); - /* dcb_apptrust.c */ int dcb_cmd_apptrust(struct dcb *dcb, int argc, char **argv); diff --git a/dcb/dcb_app.c b/dcb/dcb_app.c index eeb78e70f63f..df339babd8e6 100644 --- a/dcb/dcb_app.c +++ b/dcb/dcb_app.c @@ -10,8 +10,6 @@ #include "utils.h" #include "rt_names.h" -#define DCB_APP_PCP_MAX 15 - static const char *const pcp_names[DCB_APP_PCP_MAX + 1] = { "0nd", "1nd", "2nd", "3nd", "4nd", "5nd", "6nd", "7nd", "0de", "1de", "2de", "3de", "4de", "5de", "6de", "7de" @@ -22,6 +20,7 @@ static const char *const ieee_attrs_app_names[__DCB_ATTR_IEEE_APP_MAX] = { [DCB_ATTR_DCB_APP] = "DCB_ATTR_DCB_APP" }; + static void dcb_app_help_add(void) { fprintf(stderr, @@ -68,11 +67,6 @@ static void dcb_app_help(void) dcb_app_help_add(); } -struct dcb_app_table { - struct dcb_app *apps; - size_t n_apps; -}; - enum ieee_attrs_app dcb_app_attr_type_get(__u8 selector) { switch (selector) { @@ -105,7 +99,7 @@ bool dcb_app_selector_validate(enum ieee_attrs_app type, __u8 selector) return dcb_app_attr_type_get(selector) == type; } -static void dcb_app_table_fini(struct dcb_app_table *tab) +void dcb_app_table_fini(struct dcb_app_table *tab) { free(tab->apps); } @@ -124,8 +118,8 @@ static int dcb_app_table_push(struct dcb_app_table *tab, struct dcb_app *app) return 0; } -static void dcb_app_table_remove_existing(struct dcb_app_table *a, - const struct dcb_app_table *b) +void dcb_app_table_remove_existing(struct dcb_app_table *a, + const struct dcb_app_table *b) { size_t ia, ja; size_t ib; @@ -152,8 +146,8 @@ static void dcb_app_table_remove_existing(struct dcb_app_table *a, a->n_apps = ja; } -static void dcb_app_table_remove_replaced(struct dcb_app_table *a, - const struct dcb_app_table *b) +void dcb_app_table_remove_replaced(struct dcb_app_table *a, + const struct dcb_app_table *b) { size_t ia, ja; size_t ib; @@ -189,8 +183,7 @@ static void dcb_app_table_remove_replaced(struct dcb_app_table *a, a->n_apps = ja; } -static int dcb_app_table_copy(struct dcb_app_table *a, - const struct dcb_app_table *b) +int dcb_app_table_copy(struct dcb_app_table *a, const struct dcb_app_table *b) { size_t i; int ret; @@ -217,18 +210,12 @@ static int dcb_app_cmp_cb(const void *a, const void *b) return dcb_app_cmp(a, b); } -static void dcb_app_table_sort(struct dcb_app_table *tab) +void dcb_app_table_sort(struct dcb_app_table *tab) { qsort(tab->apps, tab->n_apps, sizeof(*tab->apps), dcb_app_cmp_cb); } -struct dcb_app_parse_mapping { - __u8 selector; - struct dcb_app_table *tab; - int err; -}; - -static void dcb_app_parse_mapping_cb(__u32 key, __u64 value, void *data) +void dcb_app_parse_mapping_cb(__u32 key, __u64 value, void *data) { struct dcb_app_parse_mapping *pm = data; struct dcb_app app = { @@ -260,7 +247,7 @@ static int dcb_app_parse_mapping_ethtype_prio(__u32 key, char *value, void *data dcb_app_parse_mapping_cb, data); } -static int dcb_app_parse_pcp(__u32 *key, const char *arg) +int dcb_app_parse_pcp(__u32 *key, const char *arg) { int i; @@ -286,7 +273,7 @@ static int dcb_app_parse_mapping_pcp_prio(__u32 key, char *value, void *data) dcb_app_parse_mapping_cb, data); } -static int dcb_app_parse_dscp(__u32 *key, const char *arg) +int dcb_app_parse_dscp(__u32 *key, const char *arg) { if (parse_mapping_num_all(key, arg) == 0) return 0; @@ -377,12 +364,12 @@ static bool dcb_app_is_default(const struct dcb_app *app) app->protocol == 0; } -static bool dcb_app_is_dscp(const struct dcb_app *app) +bool dcb_app_is_dscp(const struct dcb_app *app) { return app->selector == IEEE_8021QAZ_APP_SEL_DSCP; } -static bool dcb_app_is_pcp(const struct dcb_app *app) +bool dcb_app_is_pcp(const struct dcb_app *app) { return app->selector == DCB_APP_SEL_PCP; } @@ -402,7 +389,7 @@ static bool dcb_app_is_port(const struct dcb_app *app) return app->selector == IEEE_8021QAZ_APP_SEL_ANY; } -static int dcb_app_print_key_dec(__u16 protocol) +int dcb_app_print_key_dec(__u16 protocol) { return print_uint(PRINT_ANY, NULL, "%d:", protocol); } @@ -412,7 +399,7 @@ static int dcb_app_print_key_hex(__u16 protocol) return print_uint(PRINT_ANY, NULL, "%x:", protocol); } -static int dcb_app_print_key_dscp(__u16 protocol) +int dcb_app_print_key_dscp(__u16 protocol) { const char *name = rtnl_dsfield_get_name(protocol << 2); @@ -422,7 +409,7 @@ static int dcb_app_print_key_dscp(__u16 protocol) return print_uint(PRINT_ANY, NULL, "%d:", protocol); } -static int dcb_app_print_key_pcp(__u16 protocol) +int dcb_app_print_key_pcp(__u16 protocol) { /* Print in numerical form, if protocol value is out-of-range */ if (protocol > DCB_APP_PCP_MAX) @@ -577,7 +564,7 @@ static int dcb_app_get_table_attr_cb(const struct nlattr *attr, void *data) return MNL_CB_OK; } -static int dcb_app_get(struct dcb *dcb, const char *dev, struct dcb_app_table *tab) +int dcb_app_get(struct dcb *dcb, const char *dev, struct dcb_app_table *tab) { uint16_t payload_len; void *payload; @@ -594,11 +581,6 @@ static int dcb_app_get(struct dcb *dcb, const char *dev, struct dcb_app_table *t return 0; } -struct dcb_app_add_del { - const struct dcb_app_table *tab; - bool (*filter)(const struct dcb_app *app); -}; - static int dcb_app_add_del_cb(struct dcb *dcb, struct nlmsghdr *nlh, void *data) { struct dcb_app_add_del *add_del = data; @@ -620,7 +602,7 @@ static int dcb_app_add_del_cb(struct dcb *dcb, struct nlmsghdr *nlh, void *data) return 0; } -static int dcb_app_add_del(struct dcb *dcb, const char *dev, int command, +int dcb_app_add_del(struct dcb *dcb, const char *dev, int command, const struct dcb_app_table *tab, bool (*filter)(const struct dcb_app *)) { diff --git a/dcb/dcb_app.h b/dcb/dcb_app.h new file mode 100644 index 000000000000..8e7b010dcf75 --- /dev/null +++ b/dcb/dcb_app.h @@ -0,0 +1,55 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __DCB_APP_H_ +#define __DCB_APP_H_ + +struct dcb; + +struct dcb_app_table { + struct dcb_app *apps; + size_t n_apps; +}; + +struct dcb_app_add_del { + const struct dcb_app_table *tab; + bool (*filter)(const struct dcb_app *app); +}; + +struct dcb_app_parse_mapping { + __u8 selector; + struct dcb_app_table *tab; + int err; +}; + +#define DCB_APP_PCP_MAX 15 + +int dcb_cmd_app(struct dcb *dcb, int argc, char **argv); + +int dcb_app_get(struct dcb *dcb, const char *dev, struct dcb_app_table *tab); +int dcb_app_add_del(struct dcb *dcb, const char *dev, int command, + const struct dcb_app_table *tab, + bool (*filter)(const struct dcb_app *)); + +void dcb_app_table_sort(struct dcb_app_table *tab); +void dcb_app_table_fini(struct dcb_app_table *tab); +int dcb_app_table_copy(struct dcb_app_table *a, const struct dcb_app_table *b); +void dcb_app_table_remove_replaced(struct dcb_app_table *a, + const struct dcb_app_table *b); +void dcb_app_table_remove_existing(struct dcb_app_table *a, + const struct dcb_app_table *b); + +bool dcb_app_is_pcp(const struct dcb_app *app); +bool dcb_app_is_dscp(const struct dcb_app *app); + +int dcb_app_print_key_dec(__u16 protocol); +int dcb_app_print_key_dscp(__u16 protocol); +int dcb_app_print_key_pcp(__u16 protocol); + +int dcb_app_parse_pcp(__u32 *key, const char *arg); +int dcb_app_parse_dscp(__u32 *key, const char *arg); +void dcb_app_parse_mapping_cb(__u32 key, __u64 value, void *data); + +bool dcb_app_selector_validate(enum ieee_attrs_app type, __u8 selector); +bool dcb_app_attr_type_validate(enum ieee_attrs_app type); +enum ieee_attrs_app dcb_app_attr_type_get(__u8 selector); + +#endif From patchwork Mon May 22 18:41:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Machon X-Patchwork-Id: 13250939 X-Patchwork-Delegate: dsahern@gmail.com Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3BA3F168B9 for ; Mon, 22 May 2023 18:41:36 +0000 (UTC) Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3819718B for ; Mon, 22 May 2023 11:41:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1684780890; x=1716316890; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=9ezf1ZQc5Uwx0m6kF828+rN5S5pfb5JqHrcbI/QkGT0=; b=wK+sh6j+q5cEknZQsCKn43nvMOC/4sS9rUN5SXQOLBkdIHrR+ToXfRac ckiejZuWtUXc0He/nCzSEuoiYTwY5IyelK8hoOux9OTh8kXkF9LzU/iCT LXrG9f+ZBH6s68YXl944NWAJnmePag4l4G2pZd6R9Y2DgPpt79WRNUYY2 oIki5xm7lLQv0jTpNBc3BPBFJ2sZr4QiwgvrvH043Ki9G9Bl6KNBfLVRG SBAeaRhewlCWj8IuQkEde1cRZZXnC4XD8PeqTkRBILvHoSwQdgkM4cAdT mVh+8Of7Xc5KJBst1Qm9ClhmF+2bIKHRdNnUfCWtJytWDOckofFgrFKex Q==; X-IronPort-AV: E=Sophos;i="6.00,184,1681196400"; d="scan'208";a="214969732" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 22 May 2023 11:41:30 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Mon, 22 May 2023 11:41:28 -0700 Received: from [10.205.21.38] (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2507.21 via Frontend Transport; Mon, 22 May 2023 11:41:27 -0700 From: Daniel Machon Date: Mon, 22 May 2023 20:41:05 +0200 Subject: [PATCH iproute2-next 2/9] dcb: app: add new dcbnl attribute field Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20230510-dcb-rewr-v1-2-83adc1f93356@microchip.com> References: <20230510-dcb-rewr-v1-0-83adc1f93356@microchip.com> In-Reply-To: <20230510-dcb-rewr-v1-0-83adc1f93356@microchip.com> To: CC: , , , , X-Mailer: b4 0.12.2 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: dsahern@gmail.com Add a new field 'attr' to the dcb_app_table struct, in order to inject different dcbnl get/set attributes for APP and rewrite. This is required later, when a number of the existing dcb-app functions are refactored for reuse by dcb-rewr. Signed-off-by: Daniel Machon --- dcb/dcb_app.c | 18 +++++++++--------- dcb/dcb_app.h | 1 + 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/dcb/dcb_app.c b/dcb/dcb_app.c index df339babd8e6..1d0da35f987d 100644 --- a/dcb/dcb_app.c +++ b/dcb/dcb_app.c @@ -570,7 +570,7 @@ int dcb_app_get(struct dcb *dcb, const char *dev, struct dcb_app_table *tab) void *payload; int ret; - ret = dcb_get_attribute_va(dcb, dev, DCB_ATTR_IEEE_APP_TABLE, &payload, &payload_len); + ret = dcb_get_attribute_va(dcb, dev, tab->attr, &payload, &payload_len); if (ret != 0) return ret; @@ -588,7 +588,7 @@ static int dcb_app_add_del_cb(struct dcb *dcb, struct nlmsghdr *nlh, void *data) struct nlattr *nest; size_t i; - nest = mnl_attr_nest_start(nlh, DCB_ATTR_IEEE_APP_TABLE); + nest = mnl_attr_nest_start(nlh, add_del->tab->attr); for (i = 0; i < add_del->tab->n_apps; i++) { const struct dcb_app *app = &add_del->tab->apps[i]; @@ -697,7 +697,7 @@ static int dcb_cmd_app_parse_add_del(struct dcb *dcb, const char *dev, static int dcb_cmd_app_add(struct dcb *dcb, const char *dev, int argc, char **argv) { - struct dcb_app_table tab = {}; + struct dcb_app_table tab = { .attr = DCB_ATTR_IEEE_APP_TABLE }; int ret; ret = dcb_cmd_app_parse_add_del(dcb, dev, argc, argv, &tab); @@ -711,7 +711,7 @@ static int dcb_cmd_app_add(struct dcb *dcb, const char *dev, int argc, char **ar static int dcb_cmd_app_del(struct dcb *dcb, const char *dev, int argc, char **argv) { - struct dcb_app_table tab = {}; + struct dcb_app_table tab = { .attr = DCB_ATTR_IEEE_APP_TABLE }; int ret; ret = dcb_cmd_app_parse_add_del(dcb, dev, argc, argv, &tab); @@ -725,7 +725,7 @@ static int dcb_cmd_app_del(struct dcb *dcb, const char *dev, int argc, char **ar static int dcb_cmd_app_show(struct dcb *dcb, const char *dev, int argc, char **argv) { - struct dcb_app_table tab = {}; + struct dcb_app_table tab = { .attr = DCB_ATTR_IEEE_APP_TABLE }; int ret; ret = dcb_app_get(dcb, dev, &tab); @@ -777,7 +777,7 @@ out: static int dcb_cmd_app_flush(struct dcb *dcb, const char *dev, int argc, char **argv) { - struct dcb_app_table tab = {}; + struct dcb_app_table tab = { .attr = DCB_ATTR_IEEE_APP_TABLE }; int ret; ret = dcb_app_get(dcb, dev, &tab); @@ -830,9 +830,9 @@ out: static int dcb_cmd_app_replace(struct dcb *dcb, const char *dev, int argc, char **argv) { - struct dcb_app_table orig = {}; - struct dcb_app_table tab = {}; - struct dcb_app_table new = {}; + struct dcb_app_table orig = { .attr = DCB_ATTR_IEEE_APP_TABLE }; + struct dcb_app_table tab = { .attr = DCB_ATTR_IEEE_APP_TABLE }; + struct dcb_app_table new = { .attr = DCB_ATTR_IEEE_APP_TABLE }; int ret; ret = dcb_app_get(dcb, dev, &orig); diff --git a/dcb/dcb_app.h b/dcb/dcb_app.h index 8e7b010dcf75..3aea0bfd1786 100644 --- a/dcb/dcb_app.h +++ b/dcb/dcb_app.h @@ -7,6 +7,7 @@ struct dcb; struct dcb_app_table { struct dcb_app *apps; size_t n_apps; + int attr; }; struct dcb_app_add_del { From patchwork Mon May 22 18:41:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Machon X-Patchwork-Id: 13250941 X-Patchwork-Delegate: dsahern@gmail.com Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1B92D171A9 for ; Mon, 22 May 2023 18:41:40 +0000 (UTC) Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B7E3B7 for ; Mon, 22 May 2023 11:41:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1684780892; x=1716316892; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=3k1FqpTmY/asTbLgdAzN+mcuoZJ6n/wt6prPnRSDePk=; b=fwjRoZ6xfqi7Rzqmah/WXJKOuhlXY0D2jxC4VbdX2Kv0Fuclihmri7+5 Tl7MKIlAPrX0qaPwRaii2VFT/MW+tIFOiujWJYyRGle2vj7dTKqaS5qG0 txjd7HSbwKlG++T5ur2eGXJTEc7XzOwSOdSPgimtxarpOa3dEW1pnpomn i7kwznGGcm1QtIsbUCW8kxSytUAIm8QCLkCancjj1PIoLc9+C2tnRsIAA cou9urpooWTsjDLJ0zCjJb507Ji7Tt2NECpo1pG9WDVjOKJS2JK76a5gm xJdp7Jt/Tl1eNx/yDupVLBBpRpeHI9Jb6d/RYdGw6pWPmcd0Fug+HKFcO Q==; X-IronPort-AV: E=Sophos;i="6.00,184,1681196400"; d="scan'208";a="216701921" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 22 May 2023 11:41:31 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Mon, 22 May 2023 11:41:30 -0700 Received: from [10.205.21.38] (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2507.21 via Frontend Transport; Mon, 22 May 2023 11:41:29 -0700 From: Daniel Machon Date: Mon, 22 May 2023 20:41:06 +0200 Subject: [PATCH iproute2-next 3/9] dcb: app: modify dcb-app print functions for dcb-rewr reuse Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20230510-dcb-rewr-v1-3-83adc1f93356@microchip.com> References: <20230510-dcb-rewr-v1-0-83adc1f93356@microchip.com> In-Reply-To: <20230510-dcb-rewr-v1-0-83adc1f93356@microchip.com> To: CC: , , , , X-Mailer: b4 0.12.2 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: dsahern@gmail.com Whereas dcb-app requires protocol to be the printed key, dcb-rewr requires it to be the priority. Existing dcb-app print functions can easily be adapted to support this, by using the newly introduced dcbnl attribute in the dcb_app_table struct. - dcb_app_print_key_*() functions have been renamed to dcb_app_print_pid_*() to align with new situation. Also, none of them will print the colon anymore. - dcb_app_print_filtered() will now print either priority or protocol first, depending on the dcbnl set/get attribute. Signed-off-by: Daniel Machon --- dcb/dcb_app.c | 62 ++++++++++++++++++++++++++++++++--------------------------- dcb/dcb_app.h | 10 +++++++--- 2 files changed, 41 insertions(+), 31 deletions(-) diff --git a/dcb/dcb_app.c b/dcb/dcb_app.c index 1d0da35f987d..9bb64f32e12e 100644 --- a/dcb/dcb_app.c +++ b/dcb/dcb_app.c @@ -389,40 +389,38 @@ static bool dcb_app_is_port(const struct dcb_app *app) return app->selector == IEEE_8021QAZ_APP_SEL_ANY; } -int dcb_app_print_key_dec(__u16 protocol) +int dcb_app_print_pid_dec(__u16 protocol) { - return print_uint(PRINT_ANY, NULL, "%d:", protocol); + return print_uint(PRINT_ANY, NULL, "%d", protocol); } -static int dcb_app_print_key_hex(__u16 protocol) +static int dcb_app_print_pid_hex(__u16 protocol) { - return print_uint(PRINT_ANY, NULL, "%x:", protocol); + return print_uint(PRINT_ANY, NULL, "%x", protocol); } -int dcb_app_print_key_dscp(__u16 protocol) +int dcb_app_print_pid_dscp(__u16 protocol) { const char *name = rtnl_dsfield_get_name(protocol << 2); - if (!is_json_context() && name != NULL) - return print_string(PRINT_FP, NULL, "%s:", name); - return print_uint(PRINT_ANY, NULL, "%d:", protocol); + return print_string(PRINT_FP, NULL, "%s", name); + return print_uint(PRINT_ANY, NULL, "%d", protocol); } -int dcb_app_print_key_pcp(__u16 protocol) +int dcb_app_print_pid_pcp(__u16 protocol) { /* Print in numerical form, if protocol value is out-of-range */ if (protocol > DCB_APP_PCP_MAX) - return print_uint(PRINT_ANY, NULL, "%d:", protocol); + return print_uint(PRINT_ANY, NULL, "%d", protocol); - return print_string(PRINT_ANY, NULL, "%s:", pcp_names[protocol]); + return print_string(PRINT_ANY, NULL, "%s", pcp_names[protocol]); } -static void dcb_app_print_filtered(const struct dcb_app_table *tab, - bool (*filter)(const struct dcb_app *), - int (*print_key)(__u16 protocol), - const char *json_name, - const char *fp_name) +void dcb_app_print_filtered(const struct dcb_app_table *tab, + bool (*filter)(const struct dcb_app *), + int (*print_pid)(__u16 protocol), + const char *json_name, const char *fp_name) { bool first = true; size_t i; @@ -439,8 +437,14 @@ static void dcb_app_print_filtered(const struct dcb_app_table *tab, } open_json_array(PRINT_JSON, NULL); - print_key(app->protocol); - print_uint(PRINT_ANY, NULL, "%d ", app->priority); + if (tab->attr == DCB_ATTR_IEEE_APP_TABLE) { + print_pid(app->protocol); + print_uint(PRINT_ANY, NULL, ":%d", app->priority); + } else { + print_uint(PRINT_ANY, NULL, "%d:", app->priority); + print_pid(app->protocol); + } + print_string(PRINT_ANY, NULL, "%s", " "); close_json_array(PRINT_JSON, NULL); } @@ -452,7 +456,7 @@ static void dcb_app_print_filtered(const struct dcb_app_table *tab, static void dcb_app_print_ethtype_prio(const struct dcb_app_table *tab) { - dcb_app_print_filtered(tab, dcb_app_is_ethtype, dcb_app_print_key_hex, + dcb_app_print_filtered(tab, dcb_app_is_ethtype, dcb_app_print_pid_hex, "ethtype_prio", "ethtype-prio"); } @@ -460,8 +464,8 @@ static void dcb_app_print_pcp_prio(const struct dcb *dcb, const struct dcb_app_table *tab) { dcb_app_print_filtered(tab, dcb_app_is_pcp, - dcb->numeric ? dcb_app_print_key_dec - : dcb_app_print_key_pcp, + dcb->numeric ? dcb_app_print_pid_dec : + dcb_app_print_pid_pcp, "pcp_prio", "pcp-prio"); } @@ -469,26 +473,28 @@ static void dcb_app_print_dscp_prio(const struct dcb *dcb, const struct dcb_app_table *tab) { dcb_app_print_filtered(tab, dcb_app_is_dscp, - dcb->numeric ? dcb_app_print_key_dec - : dcb_app_print_key_dscp, + dcb->numeric ? dcb_app_print_pid_dec : + dcb_app_print_pid_dscp, "dscp_prio", "dscp-prio"); } static void dcb_app_print_stream_port_prio(const struct dcb_app_table *tab) { - dcb_app_print_filtered(tab, dcb_app_is_stream_port, dcb_app_print_key_dec, - "stream_port_prio", "stream-port-prio"); + dcb_app_print_filtered(tab, dcb_app_is_stream_port, + dcb_app_print_pid_dec, "stream_port_prio", + "stream-port-prio"); } static void dcb_app_print_dgram_port_prio(const struct dcb_app_table *tab) { - dcb_app_print_filtered(tab, dcb_app_is_dgram_port, dcb_app_print_key_dec, - "dgram_port_prio", "dgram-port-prio"); + dcb_app_print_filtered(tab, dcb_app_is_dgram_port, + dcb_app_print_pid_dec, "dgram_port_prio", + "dgram-port-prio"); } static void dcb_app_print_port_prio(const struct dcb_app_table *tab) { - dcb_app_print_filtered(tab, dcb_app_is_port, dcb_app_print_key_dec, + dcb_app_print_filtered(tab, dcb_app_is_port, dcb_app_print_pid_dec, "port_prio", "port-prio"); } diff --git a/dcb/dcb_app.h b/dcb/dcb_app.h index 3aea0bfd1786..8f048605c3a8 100644 --- a/dcb/dcb_app.h +++ b/dcb/dcb_app.h @@ -41,9 +41,13 @@ void dcb_app_table_remove_existing(struct dcb_app_table *a, bool dcb_app_is_pcp(const struct dcb_app *app); bool dcb_app_is_dscp(const struct dcb_app *app); -int dcb_app_print_key_dec(__u16 protocol); -int dcb_app_print_key_dscp(__u16 protocol); -int dcb_app_print_key_pcp(__u16 protocol); +int dcb_app_print_pid_dec(__u16 protocol); +int dcb_app_print_pid_dscp(__u16 protocol); +int dcb_app_print_pid_pcp(__u16 protocol); +void dcb_app_print_filtered(const struct dcb_app_table *tab, + bool (*filter)(const struct dcb_app *), + int (*print_pid)(__u16 protocol), + const char *json_name, const char *fp_name); int dcb_app_parse_pcp(__u32 *key, const char *arg); int dcb_app_parse_dscp(__u32 *key, const char *arg); From patchwork Mon May 22 18:41:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Machon X-Patchwork-Id: 13250940 X-Patchwork-Delegate: dsahern@gmail.com Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CFCD4168B9 for ; Mon, 22 May 2023 18:41:39 +0000 (UTC) Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15974C2 for ; Mon, 22 May 2023 11:41:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1684780894; x=1716316894; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=P3Qm4amTf84BGBm659hkzAx4jwgXeM+DlxWmKpizBOE=; b=MkiYtvcuLKh6A2tmT2IxBMpLynDGZdmNn4leLgw/vC4/lMa68yCT1XJj scjb27SRacMQWhzKic/C4W5Ig+cXpOAafm/t6QiYe2aCtIR0aATO/BOJh kbVSBdUY3tqUcKrgK6UwOxMWp355sThKZ486pg+saz8k4yy3n7c1qcUl6 Q2CCVnsMYM7VrrzaHSoHlfzvdj7aif8QgOljQ9qtOgnX38VvbscIjfb6t AhoyM7eOQQ/BK4ME+Re+14XlhD/gGJI8imzRZWdh1rZ71TdnZhl0hfRFH MzFJDpFahn/2AhPUqD367EBxMRtMFQK3gHuYJ5nUJO08qASqq5aMZn4JO g==; X-IronPort-AV: E=Sophos;i="6.00,184,1681196400"; d="scan'208";a="216701930" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 22 May 2023 11:41:32 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Mon, 22 May 2023 11:41:31 -0700 Received: from [10.205.21.38] (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2507.21 via Frontend Transport; Mon, 22 May 2023 11:41:30 -0700 From: Daniel Machon Date: Mon, 22 May 2023 20:41:07 +0200 Subject: [PATCH iproute2-next 4/9] dcb: app: modify dcb_app_table_remove_replaced() for dcb-rewr reuse Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20230510-dcb-rewr-v1-4-83adc1f93356@microchip.com> References: <20230510-dcb-rewr-v1-0-83adc1f93356@microchip.com> In-Reply-To: <20230510-dcb-rewr-v1-0-83adc1f93356@microchip.com> To: CC: , , , , X-Mailer: b4 0.12.2 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: dsahern@gmail.com When doing a replace command, entries are checked against selector and protocol. Rewrite requires the check to be against selector and priority. Modify the existing dcb_app_table_remove_replace function for dcb-rewr reuse, by using the newly introduced dcbnl attribute in the dcb_app_table struct. Signed-off-by: Daniel Machon --- dcb/dcb_app.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/dcb/dcb_app.c b/dcb/dcb_app.c index 9bb64f32e12e..23d6bb2a0013 100644 --- a/dcb/dcb_app.c +++ b/dcb/dcb_app.c @@ -160,15 +160,27 @@ void dcb_app_table_remove_replaced(struct dcb_app_table *a, for (ib = 0; ib < b->n_apps; ib++) { const struct dcb_app *ab = &b->apps[ib]; - if (aa->selector == ab->selector && - aa->protocol == ab->protocol) - present = true; - else + if (aa->selector != ab->selector) continue; - if (aa->priority == ab->priority) { - found = true; - break; + if (a->attr == DCB_ATTR_IEEE_APP_TABLE) { + if (aa->protocol == ab->protocol) + present = true; + else + continue; + if (aa->priority == ab->priority) { + found = true; + break; + } + } else { + if (aa->priority == ab->priority) + present = true; + else + continue; + if (aa->protocol == ab->protocol) { + found = true; + break; + } } } From patchwork Mon May 22 18:41:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Machon X-Patchwork-Id: 13250946 X-Patchwork-Delegate: dsahern@gmail.com Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 16537171D8 for ; Mon, 22 May 2023 18:41:43 +0000 (UTC) Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6C0910D for ; Mon, 22 May 2023 11:41:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1684780899; x=1716316899; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=CEix2089coFr4QW9fnXh9p4fXbFtV4ZyIkR4k/A8XIo=; b=BV+5sxKPSMhVOthfHo9EEXL1KSvlGraQV23JcMhWnDKLRtkZYPVw5/17 PCKBNWuHaKQbL482uai23i3Lk0lGmNZt2K6Vtb6D6VtX0yPCOHHv937Gs JfxQ4iZaeyg4DTWKVBEbHVVtZpSOy8KPfPpP3gkgHNErUbFGIEM3xBnZ7 E/LfMSbpFYE3xAZtA2rN5WYvJPi9JW+z9toG+Jh/gdLw+WwUlF/VHBige o3B+I9FFsmkQ3FkIncELLPBRoSHGL57ro9ZrwiSGoWuAP2D5xs7NEMWGL K/2ov/MWcXgxlElsFccNFvP5Qr9/wdYyV7D+/j4ZlRZDBSzT8qw3AQMtL w==; X-IronPort-AV: E=Sophos;i="6.00,184,1681196400"; d="scan'208";a="216701945" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 22 May 2023 11:41:33 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Mon, 22 May 2023 11:41:33 -0700 Received: from [10.205.21.38] (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2507.21 via Frontend Transport; Mon, 22 May 2023 11:41:32 -0700 From: Daniel Machon Date: Mon, 22 May 2023 20:41:08 +0200 Subject: [PATCH iproute2-next 5/9] dcb: app: modify dcb_app_parse_mapping_cb for dcb-rewr reuse Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20230510-dcb-rewr-v1-5-83adc1f93356@microchip.com> References: <20230510-dcb-rewr-v1-0-83adc1f93356@microchip.com> In-Reply-To: <20230510-dcb-rewr-v1-0-83adc1f93356@microchip.com> To: CC: , , , , X-Mailer: b4 0.12.2 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: dsahern@gmail.com When parsing APP table entries, priority and protocol is assigned from value and key, respectively. Rewrite requires it opposite. Modify the existing dcb_app_parse_mapping_cb for dcb-rewr reuse, by using the newly introduced dcbnl attribute in the dcb_app_table struct. Signed-off-by: Daniel Machon --- dcb/dcb_app.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/dcb/dcb_app.c b/dcb/dcb_app.c index 23d6bb2a0013..46af67112748 100644 --- a/dcb/dcb_app.c +++ b/dcb/dcb_app.c @@ -232,10 +232,17 @@ void dcb_app_parse_mapping_cb(__u32 key, __u64 value, void *data) struct dcb_app_parse_mapping *pm = data; struct dcb_app app = { .selector = pm->selector, - .priority = value, - .protocol = key, }; + if (pm->tab->attr == DCB_ATTR_IEEE_APP_TABLE) { + app.priority = value; + app.protocol = key; + + } else { + app.priority = key; + app.protocol = value; + } + if (pm->err) return; From patchwork Mon May 22 18:41:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Machon X-Patchwork-Id: 13250942 X-Patchwork-Delegate: dsahern@gmail.com Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4E765171A9 for ; Mon, 22 May 2023 18:41:42 +0000 (UTC) Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 902F9102 for ; Mon, 22 May 2023 11:41:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1684780896; x=1716316896; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=x/pZrZkjJQ2gokFUi3CsS56hDyjCxvBzdLe+My/SB74=; b=ZJ+wZEMpEi2eXcf7PJ/kG6GOZduooj+wnOibifB99EaWbAZbb826G05Q fovZdNbP/TAddxqILs1IXWUUQIPw37IvBssNrFxTfs0tJuTfD3186tVqk cJZYP+XjS3wOJD5G5/+CQ829WeCLQqZUPgd57cjwzCe55gUbiBrBtlWC4 svO7DwtMkrze8Kn0XPhUPJnCSPJM/wd5Ph6DRwqXT5b9b+WzLhdDAYaQq N5ruJ6y/Zsu15SDpEzxXo2GuWQ2a+3+/S+ptRJm21Q01Ob+nHrIcCCqUO 5wk6Wo4scJrpOYjgcBMkU3sclllDU9iInC13QAjuHYYZlwxmm7Z8BYROS A==; X-IronPort-AV: E=Sophos;i="6.00,184,1681196400"; d="scan'208";a="153361949" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 22 May 2023 11:41:35 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Mon, 22 May 2023 11:41:35 -0700 Received: from [10.205.21.38] (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2507.21 via Frontend Transport; Mon, 22 May 2023 11:41:33 -0700 From: Daniel Machon Date: Mon, 22 May 2023 20:41:09 +0200 Subject: [PATCH iproute2-next 6/9] dcb: rewr: add new dcb-rewr subcommand Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20230510-dcb-rewr-v1-6-83adc1f93356@microchip.com> References: <20230510-dcb-rewr-v1-0-83adc1f93356@microchip.com> In-Reply-To: <20230510-dcb-rewr-v1-0-83adc1f93356@microchip.com> To: CC: , , , , X-Mailer: b4 0.12.2 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: dsahern@gmail.com Add a new subcommand 'rewr' for configuring the in-kernel DCB rewrite table. The rewr-table of the kernel is similar to the APP-table, and so is this new subcommand. Therefore, much of the existing bookkeeping code from dcb-app, can be reused in the dcb-rewr implementation. Initially, only support for configuring PCP and DSCP-based rewrite has been added. Signed-off-by: Daniel Machon --- dcb/Makefile | 3 +- dcb/dcb.c | 4 +- dcb/dcb.h | 3 + dcb/dcb_app.h | 1 + dcb/dcb_rewr.c | 332 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 341 insertions(+), 2 deletions(-) diff --git a/dcb/Makefile b/dcb/Makefile index dd41a559a0c8..10794c9dc19f 100644 --- a/dcb/Makefile +++ b/dcb/Makefile @@ -8,7 +8,8 @@ DCBOBJ = dcb.o \ dcb_ets.o \ dcb_maxrate.o \ dcb_pfc.o \ - dcb_apptrust.o + dcb_apptrust.o \ + dcb_rewr.o TARGETS += dcb LDLIBS += -lm diff --git a/dcb/dcb.c b/dcb/dcb.c index 9b996abac529..fe0a0f04143d 100644 --- a/dcb/dcb.c +++ b/dcb/dcb.c @@ -470,7 +470,7 @@ static void dcb_help(void) fprintf(stderr, "Usage: dcb [ OPTIONS ] OBJECT { COMMAND | help }\n" " dcb [ -f | --force ] { -b | --batch } filename [ -n | --netns ] netnsname\n" - "where OBJECT := { app | apptrust | buffer | dcbx | ets | maxrate | pfc }\n" + "where OBJECT := { app | apptrust | buffer | dcbx | ets | maxrate | pfc | rewr }\n" " OPTIONS := [ -V | --Version | -i | --iec | -j | --json\n" " | -N | --Numeric | -p | --pretty\n" " | -s | --statistics | -v | --verbose]\n"); @@ -485,6 +485,8 @@ static int dcb_cmd(struct dcb *dcb, int argc, char **argv) return dcb_cmd_app(dcb, argc - 1, argv + 1); } else if (strcmp(*argv, "apptrust") == 0) { return dcb_cmd_apptrust(dcb, argc - 1, argv + 1); + } else if (strcmp(*argv, "rewr") == 0) { + return dcb_cmd_rewr(dcb, argc - 1, argv + 1); } else if (matches(*argv, "buffer") == 0) { return dcb_cmd_buffer(dcb, argc - 1, argv + 1); } else if (matches(*argv, "dcbx") == 0) { diff --git a/dcb/dcb.h b/dcb/dcb.h index 4c8a4aa25e0c..39a04f1c59df 100644 --- a/dcb/dcb.h +++ b/dcb/dcb.h @@ -56,6 +56,9 @@ void dcb_print_array_on_off(const __u8 *array, size_t size); void dcb_print_array_kw(const __u8 *array, size_t array_size, const char *const kw[], size_t kw_size); +/* dcb_rewr.c */ +int dcb_cmd_rewr(struct dcb *dcb, int argc, char **argv); + /* dcb_apptrust.c */ int dcb_cmd_apptrust(struct dcb *dcb, int argc, char **argv); diff --git a/dcb/dcb_app.h b/dcb/dcb_app.h index 8f048605c3a8..02c9eb03f6c2 100644 --- a/dcb/dcb_app.h +++ b/dcb/dcb_app.h @@ -22,6 +22,7 @@ struct dcb_app_parse_mapping { }; #define DCB_APP_PCP_MAX 15 +#define DCB_APP_DSCP_MAX 63 int dcb_cmd_app(struct dcb *dcb, int argc, char **argv); diff --git a/dcb/dcb_rewr.c b/dcb/dcb_rewr.c new file mode 100644 index 000000000000..731ba78977e2 --- /dev/null +++ b/dcb/dcb_rewr.c @@ -0,0 +1,332 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include +#include +#include + +#include "dcb.h" +#include "utils.h" + +static void dcb_rewr_help_add(void) +{ + fprintf(stderr, + "Usage: dcb rewr { add | del | replace } dev STRING\n" + " [ prio-pcp PRIO:PCP ]\n" + " [ prio-dscp PRIO:DSCP ]\n" + "\n" + " where PRIO := { 0 .. 7 }\n" + " PCP := { 0(nd/de) .. 7(nd/de) }\n" + " DSCP := { 0 .. 63 }\n" + "\n" + ); +} + +static void dcb_rewr_help_show_flush(void) +{ + fprintf(stderr, + "Usage: dcb rewr { show | flush } dev STRING\n" + " [ prio-pcp ]\n" + " [ prio-dscp ]\n" + "\n" + ); +} + +static void dcb_rewr_help(void) +{ + fprintf(stderr, + "Usage: dcb rewr help\n" + "\n" + ); + dcb_rewr_help_show_flush(); + dcb_rewr_help_add(); +} + +static int dcb_rewr_parse_mapping_prio_pcp(__u32 key, char *value, void *data) +{ + __u32 pcp; + + if (dcb_app_parse_pcp(&pcp, value)) + return -EINVAL; + + return dcb_parse_mapping("PRIO", key, IEEE_8021QAZ_MAX_TCS - 1, "PCP", + pcp, DCB_APP_PCP_MAX, dcb_app_parse_mapping_cb, + data); +} + +static int dcb_rewr_parse_mapping_prio_dscp(__u32 key, char *value, void *data) +{ + __u32 dscp; + + if (dcb_app_parse_dscp(&dscp, value)) + return -EINVAL; + + return dcb_parse_mapping("PRIO", key, IEEE_8021QAZ_MAX_TCS - 1, "DSCP", + dscp, DCB_APP_DSCP_MAX, + dcb_app_parse_mapping_cb, data); +} + +static void dcb_rewr_print_prio_pcp(const struct dcb *dcb, + const struct dcb_app_table *tab) +{ + dcb_app_print_filtered(tab, dcb_app_is_pcp, + dcb->numeric ? dcb_app_print_pid_dec : + dcb_app_print_pid_pcp, + "prio_pcp", "prio-pcp"); +} + +static void dcb_rewr_print_prio_dscp(const struct dcb *dcb, + const struct dcb_app_table *tab) +{ + dcb_app_print_filtered(tab, dcb_app_is_dscp, + dcb->numeric ? dcb_app_print_pid_dec : + dcb_app_print_pid_dscp, + "prio_dscp", "prio-dscp"); +} + +static void dcb_rewr_print(const struct dcb *dcb, + const struct dcb_app_table *tab) +{ + dcb_rewr_print_prio_pcp(dcb, tab); + dcb_rewr_print_prio_dscp(dcb, tab); +} + +static int dcb_cmd_rewr_parse_add_del(struct dcb *dcb, const char *dev, + int argc, char **argv, + struct dcb_app_table *tab) +{ + struct dcb_app_parse_mapping pm = { .tab = tab }; + int ret; + + if (!argc) { + dcb_rewr_help_add(); + return 0; + } + + do { + if (strcmp(*argv, "help") == 0) { + dcb_rewr_help_add(); + return 0; + } else if (strcmp(*argv, "prio-pcp") == 0) { + NEXT_ARG(); + pm.selector = DCB_APP_SEL_PCP; + ret = parse_mapping(&argc, &argv, false, + &dcb_rewr_parse_mapping_prio_pcp, + &pm); + } else if (strcmp(*argv, "prio-dscp") == 0) { + NEXT_ARG(); + pm.selector = IEEE_8021QAZ_APP_SEL_DSCP; + ret = parse_mapping(&argc, &argv, false, + &dcb_rewr_parse_mapping_prio_dscp, + &pm); + } else { + fprintf(stderr, "What is \"%s\"?\n", *argv); + dcb_rewr_help_add(); + return -EINVAL; + } + + if (ret != 0) { + fprintf(stderr, "Invalid mapping %s\n", *argv); + return ret; + } + if (pm.err) + return pm.err; + } while (argc > 0); + + return 0; +} + +static int dcb_cmd_rewr_add(struct dcb *dcb, const char *dev, int argc, + char **argv) +{ + struct dcb_app_table tab = { .attr = DCB_ATTR_DCB_REWR_TABLE }; + int ret; + + ret = dcb_cmd_rewr_parse_add_del(dcb, dev, argc, argv, &tab); + if (ret != 0) + return ret; + + ret = dcb_app_add_del(dcb, dev, DCB_CMD_IEEE_SET, &tab, NULL); + dcb_app_table_fini(&tab); + return ret; +} + +static int dcb_cmd_rewr_del(struct dcb *dcb, const char *dev, int argc, + char **argv) +{ + struct dcb_app_table tab = { .attr = DCB_ATTR_DCB_REWR_TABLE }; + int ret; + + ret = dcb_cmd_rewr_parse_add_del(dcb, dev, argc, argv, &tab); + if (ret != 0) + return ret; + + ret = dcb_app_add_del(dcb, dev, DCB_CMD_IEEE_DEL, &tab, NULL); + dcb_app_table_fini(&tab); + return ret; +} + +static int dcb_cmd_rewr_replace(struct dcb *dcb, const char *dev, int argc, + char **argv) +{ + struct dcb_app_table orig = { .attr = DCB_ATTR_DCB_REWR_TABLE }; + struct dcb_app_table tab = { .attr = DCB_ATTR_DCB_REWR_TABLE }; + struct dcb_app_table new = { .attr = DCB_ATTR_DCB_REWR_TABLE }; + int ret; + + ret = dcb_app_get(dcb, dev, &orig); + if (ret != 0) + return ret; + + ret = dcb_cmd_rewr_parse_add_del(dcb, dev, argc, argv, &tab); + if (ret != 0) + goto out; + + /* Attempts to add an existing entry would be rejected, so drop + * these entries from tab. + */ + ret = dcb_app_table_copy(&new, &tab); + if (ret != 0) + goto out; + dcb_app_table_remove_existing(&new, &orig); + + ret = dcb_app_add_del(dcb, dev, DCB_CMD_IEEE_SET, &new, NULL); + if (ret != 0) { + fprintf(stderr, "Could not add new rewrite entries\n"); + goto out; + } + + /* Remove the obsolete entries. */ + dcb_app_table_remove_replaced(&orig, &tab); + ret = dcb_app_add_del(dcb, dev, DCB_CMD_IEEE_DEL, &orig, NULL); + if (ret != 0) { + fprintf(stderr, "Could not remove replaced rewrite entries\n"); + goto out; + } + +out: + dcb_app_table_fini(&new); + dcb_app_table_fini(&tab); + dcb_app_table_fini(&orig); + return 0; +} + + +static int dcb_cmd_rewr_show(struct dcb *dcb, const char *dev, int argc, + char **argv) +{ + struct dcb_app_table tab = { .attr = DCB_ATTR_DCB_REWR_TABLE }; + int ret; + + ret = dcb_app_get(dcb, dev, &tab); + if (ret != 0) + return ret; + + dcb_app_table_sort(&tab); + + open_json_object(NULL); + + if (!argc) { + dcb_rewr_print(dcb, &tab); + goto out; + } + + do { + if (strcmp(*argv, "help") == 0) { + dcb_rewr_help_show_flush(); + goto out; + } else if (strcmp(*argv, "prio-pcp") == 0) { + dcb_rewr_print_prio_pcp(dcb, &tab); + } else if (strcmp(*argv, "prio-dscp") == 0) { + dcb_rewr_print_prio_dscp(dcb, &tab); + } else { + fprintf(stderr, "What is \"%s\"?\n", *argv); + dcb_rewr_help_show_flush(); + ret = -EINVAL; + goto out; + } + + NEXT_ARG_FWD(); + } while (argc > 0); + +out: + close_json_object(); + dcb_app_table_fini(&tab); + return ret; +} + +static int dcb_cmd_rewr_flush(struct dcb *dcb, const char *dev, int argc, + char **argv) +{ + struct dcb_app_table tab = { .attr = DCB_ATTR_DCB_REWR_TABLE }; + int ret; + + ret = dcb_app_get(dcb, dev, &tab); + if (ret != 0) + return ret; + + if (!argc) { + ret = dcb_app_add_del(dcb, dev, DCB_CMD_IEEE_DEL, &tab, + NULL); + goto out; + } + + do { + if (strcmp(*argv, "help") == 0) { + dcb_rewr_help_show_flush(); + goto out; + } else if (strcmp(*argv, "prio-pcp") == 0) { + ret = dcb_app_add_del(dcb, dev, DCB_CMD_IEEE_DEL, &tab, + &dcb_app_is_pcp); + if (ret != 0) + goto out; + } else if (strcmp(*argv, "prio-dscp") == 0) { + ret = dcb_app_add_del(dcb, dev, DCB_CMD_IEEE_DEL, &tab, + &dcb_app_is_dscp); + if (ret != 0) + goto out; + } else { + fprintf(stderr, "What is \"%s\"?\n", *argv); + dcb_rewr_help_show_flush(); + ret = -EINVAL; + goto out; + } + + NEXT_ARG_FWD(); + } while (argc > 0); + +out: + dcb_app_table_fini(&tab); + return ret; +} + +int dcb_cmd_rewr(struct dcb *dcb, int argc, char **argv) +{ + if (!argc || strcmp(*argv, "help") == 0) { + dcb_rewr_help(); + return 0; + } else if (strcmp(*argv, "show") == 0) { + NEXT_ARG_FWD(); + return dcb_cmd_parse_dev(dcb, argc, argv, dcb_cmd_rewr_show, + dcb_rewr_help_show_flush); + } else if (strcmp(*argv, "flush") == 0) { + NEXT_ARG_FWD(); + return dcb_cmd_parse_dev(dcb, argc, argv, dcb_cmd_rewr_flush, + dcb_rewr_help_show_flush); + } else if (strcmp(*argv, "add") == 0) { + NEXT_ARG_FWD(); + return dcb_cmd_parse_dev(dcb, argc, argv, dcb_cmd_rewr_add, + dcb_rewr_help_add); + } else if (strcmp(*argv, "del") == 0) { + NEXT_ARG_FWD(); + return dcb_cmd_parse_dev(dcb, argc, argv, dcb_cmd_rewr_del, + dcb_rewr_help_add); + } else if (strcmp(*argv, "replace") == 0) { + NEXT_ARG_FWD(); + return dcb_cmd_parse_dev(dcb, argc, argv, dcb_cmd_rewr_replace, + dcb_rewr_help_add); + } else { + fprintf(stderr, "What is \"%s\"?\n", *argv); + dcb_rewr_help(); + return -EINVAL; + } +} From patchwork Mon May 22 18:41:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Machon X-Patchwork-Id: 13250944 X-Patchwork-Delegate: dsahern@gmail.com Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EE608171D2 for ; Mon, 22 May 2023 18:41:42 +0000 (UTC) Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77C73107 for ; Mon, 22 May 2023 11:41:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1684780897; x=1716316897; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=XZPZZbxzKUHOitrO7AJnnufkxPdClM1UKATxTR5vpZk=; b=1ypG76UUX9JDWeS+CQzei6wlKFTk9nKX12KHxZusuPxe0NMzK5a/UT0h 6N30BtSFxUfgvi8P7hqtr4scGbTozjh5+1f/7VigxLMEhTFTLHq398xaQ cFnjW8GfApy/BozVMmHkjIpTLlXl+s+Is4tou6yHBIPyqETSu7J7suzrU 7axARTD0lpdfWcjeQMxUI1Gs7EQn0pJqdU4izTOIbm7TzwEQqnyn3lKl9 bstv4Oby516iX5d3vLdbMCoahUdFLnIOqCwlQxqjMXFJhHaaujhjFQwQi r/VEV67q3dn5P5izLRf6p8PbgL4i22JITgmGd0juv0m/PjkTTKes1wVct A==; X-IronPort-AV: E=Sophos;i="6.00,184,1681196400"; d="scan'208";a="153361961" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 22 May 2023 11:41:36 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Mon, 22 May 2023 11:41:36 -0700 Received: from [10.205.21.38] (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2507.21 via Frontend Transport; Mon, 22 May 2023 11:41:35 -0700 From: Daniel Machon Date: Mon, 22 May 2023 20:41:10 +0200 Subject: [PATCH iproute2-next 7/9] man: dcb-rewr: add new manpage for dcb-rewr Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20230510-dcb-rewr-v1-7-83adc1f93356@microchip.com> References: <20230510-dcb-rewr-v1-0-83adc1f93356@microchip.com> In-Reply-To: <20230510-dcb-rewr-v1-0-83adc1f93356@microchip.com> To: CC: , , , , X-Mailer: b4 0.12.2 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: dsahern@gmail.com Add a new manpage for dcb-rewr. Most of the content is copied over from dcb-app, as the same set of commands and parameters (in reverse) applies to dcb-rewr. Signed-off-by: Daniel Machon --- man/man8/dcb-rewr.8 | 206 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 206 insertions(+) diff --git a/man/man8/dcb-rewr.8 b/man/man8/dcb-rewr.8 new file mode 100644 index 000000000000..b859dfea37c1 --- /dev/null +++ b/man/man8/dcb-rewr.8 @@ -0,0 +1,206 @@ +.TH DCB-REWR 8 "15 may 2023" "iproute2" "Linux" +.SH NAME +dcb-rewr \- show / manipulate the rewrite table of +the DCB (Data Center Bridging) subsystem +.SH SYNOPSIS +.sp +.ad l +.in +8 + +.ti -8 +.B dcb +.RI "[ " OPTIONS " ] " +.B rewr +.RI "{ " COMMAND " | " help " }" +.sp + +.ti -8 +.B dcb rewr " { " show " | " flush " } " dev +.RI DEV +.RB "[ " prio-dscp " ]" +.RB "[ " prio-pcp " ]" + +.ti -8 +.B dcb rewr " { " add " | " del " | " replace " } " dev +.RI DEV +.RB "[ " prio-dscp " " \fIDSCP-MAP\fB " ]" +.RB "[ " prio-pcp " " \fIPCP-MAP\fB " ]" + +.ti -8 +.IR DSCP-MAP " := [ " DSCP-MAP " ] " DSCP-MAPPING + +.ti -8 +.IR DSCP-MAPPING " := " \fIPRIO \fB:\fR "{ " DSCP " | " \fBall\fR " }" + +.ti -8 +.IR PCP-MAP " := [ " PCP-MAP " ] " PCP-MAPPING + +.ti -8 +.IR PCP-MAPPING " := " \fIPRIO \fB:\fR PCP\fR + +.ti -8 +.IR DSCP " := { " \fB0\fR " .. " \fB63\fR " }" + +.ti -8 +.IR PCP " := { " \fB0(nd/de)\fR " .. " \fB7(nd/de)\fR " }" + +.ti -8 +.IR PRIO " := { " \fB0\fR " .. " \fB7\fR " }" + +.SH DESCRIPTION + +.B dcb rewr +is used to configure the rewrite table, in the DCB (Data Center Bridging) +subsystem. The rewrite table is used to rewrite certain values in the packet +headers, based on packet priority. + +DCB rewrite entries are, like DCB APP entries, 3-tuples of selector, protocol +ID, and priority. Selector is an enumeration that picks one of the +prioritization namespaces. Currently, only the DSCP and PCP selector namespaces +are supported by dcb rewr. + +The rewrite table is a list of DCB rewrite rules, that applies to packets +with matching priority. Notably, it is valid to have conflicting rewrite +assignment for the same selector and priority. For example, the set of two +rewrite entries (DSCP, 10, 1) and (DSCP, 11, 1), where packets with priority 1 +should have its DSCP value rewritten to both 10 and 11, form a well-defined +rewrite table. +.B dcb rewr +tool allows low-level management of the rewrite table by adding and deleting +individual rewrite 3-tuples through +.B add +and +.B del +commands. On the other hand, the command +.B replace +does what one would typically want in this situation--first adds the new +configuration, and then removes the obsolete one, so that only one +rewrite rule is in effect for a given selector and priority. + +.SH COMMANDS + +.TP +.B show +Display all entries with a given selector. When no selector is given, shows all +rewrite table entries categorized per selector. + +.TP +.B flush +Remove all entries with a given selector. When no selector is given, removes all +rewrite table entries. + +.TP +.B add +.TQ +.B del +Add and, respectively, remove individual rewrite 3-tuples to and from the DCB +rewrite table. + +.TP +.B replace +Take the list of entries mentioned as parameter, and add those that are not +present in the rewrite table yet. Then remove those entries, whose selector and +priority have been mentioned as parameter, but not with the exact same +protocol ID. This has the effect of, for the given selector and priority, +causing that the table only contains the protocol ID (or ID's) given as +parameter. + +.SH PARAMETERS + +The following table shows parameters in a way that they would be used with +\fBadd\fR, \fBdel\fR and \fBreplace\fR commands. For \fBshow\fR and +\fBflush\fR, the parameter name is to be used as a simple keyword without +further arguments. + +.TP +.B prio-dscp \fIDSCP-MAP +\fIDSCP-MAP\fR uses the array parameter syntax, see +.BR dcb (8) +for details. Keys are priorities, values are DSCP points for traffic +with matching priority. DSCP points can be written either directly as numeric +values, or using symbolic names specified in +.B /etc/iproute2/rt_dsfield +(however note that file specifies full 8-bit dsfield values, whereas +.B dcb rewr +will only use the higher six bits). +.B dcb rewr show +will similarly format DSCP values as symbolic names if possible. The +command line option +.B -N +turns the show translation off. + +.TP +.B prio-pcp \fIPCP-MAP +\fIPCP-MAP\fR uses the array parameter syntax, see +.BR dcb (8) +for details. Keys are priorities. Values are PCP/DEI for traffic with +matching priority. PCP/DEI values are written as a combination of numeric- and +symbolic values, to accommodate for both. PCP always in numeric form e.g 0 .. +7 and DEI in symbolic form e.g 'de' (drop-eligible), indicating that the DEI +bit is 1 or 'nd' (not-drop-eligible), indicating that the DEI bit is 0. In +combination 1:2de translates to a mapping of priority 1 to PCP=2 and DEI=1. + +.SH EXAMPLE & USAGE + +Add a rule to rewrite DSCP to 0, 24 and 48 for traffic with priority 0, 3 and +6, respectively: +.P +# dcb rewr add dev eth0 prio-dscp 0:0 3:24 6:48 + +Add a rule to rewrite DSCP to 25 for traffic with priority 3: +.P +# dcb rewr add dev eth0 prio-dscp 3:25 +.br +# dcb rewr show dev eth0 prio-dscp +.br +prio-dscp 0:0 3:CS3 3:25 6:CS6 +.br +# dcb -N rewr show dev eth0 prio-dscp +.br +prio-dscp 0:0 3:24 3:25 6:48 + +Reconfigure the table so that only one rule exists for rewriting traffic with +priority 3. + +.P +# dcb rewr replace dev eth0 prio-dscp 3:26 +.br +# dcb rewr -N show dev eth0 prio-dscp +.br +prio-dscp 0:0 3:26 6:48 + +Flush all DSCP rules: + +.P +# dcb rewr flush dev eth0 prio-dscp +.br +# dcb rewr show dev eth0 prio-dscp +.br +(nothing) + +Add a rule to rewrite PCP to 1 and DEI to 0 for traffic with priority 1 and a +rule to rewrite PCP to 2 and DEI to 1 for traffic with priority 2: + +.P +# dcb rewr add dev eth0 prio-pcp 1:1nd 2:2de +.br +# dcb rewr show dev eth0 prio-pcp +.br +prio-pcp 1:1nd 2:2de + +.SH EXIT STATUS +Exit status is 0 if command was successful or a positive integer upon failure. + +.SH SEE ALSO +.BR dcb (8) +.BR dcb-app (8) +.BR dcb-apptrust (8) + +.SH REPORTING BUGS +Report any bugs to the Network Developers mailing list +.B +where the development and maintenance is primarily done. You do not have to be +subscribed to the list to send a message there. + +.SH AUTHOR +Daniel Machon From patchwork Mon May 22 18:41:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Machon X-Patchwork-Id: 13250943 X-Patchwork-Delegate: dsahern@gmail.com Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E121C171D1 for ; Mon, 22 May 2023 18:41:42 +0000 (UTC) Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28E6A10C for ; Mon, 22 May 2023 11:41:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1684780900; x=1716316900; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=VIqgeqTE41QWhNjlhHHHMfj2IZeaAiOoVx9OgelY3zU=; b=FasEsJVJBhMzvpweo87JHh46Nzfx5A8Ht2ziKhA80YFP42gTMilbT5/1 gRej3WS1mWQ/los707NoCf561p8X9k2lOWJtlD2OFNZAje2fmGVh5/B+k duVI+swZCdYH4N0unrbVV6MoHlK02BueLIfKcncL8VnP08H+SB683IDXe 8CCiJrCnIpSEyOYACmDZB53WUj5U51N9A+taxrjET2Djgl9HG+kqYvdP9 A8lJFMmJWSkE0Xz+K+ez8US7CER1+Nzn+01+FWzIfI/1qdLMlUIGnjgTJ QQ4qu3HoFi5E+oL/UP27ZQJxRZ0VcbGeMfvOFEotIAiEbmWeWIcwB75/V w==; X-IronPort-AV: E=Sophos;i="6.00,184,1681196400"; d="scan'208";a="214969742" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 22 May 2023 11:41:40 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Mon, 22 May 2023 11:41:38 -0700 Received: from [10.205.21.38] (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2507.21 via Frontend Transport; Mon, 22 May 2023 11:41:36 -0700 From: Daniel Machon Date: Mon, 22 May 2023 20:41:11 +0200 Subject: [PATCH iproute2-next 8/9] man: dcb: add additional references under 'SEE ALSO' Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20230510-dcb-rewr-v1-8-83adc1f93356@microchip.com> References: <20230510-dcb-rewr-v1-0-83adc1f93356@microchip.com> In-Reply-To: <20230510-dcb-rewr-v1-0-83adc1f93356@microchip.com> To: CC: , , , , X-Mailer: b4 0.12.2 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: dsahern@gmail.com Add dcb-apptrust and dcb-rewr to the 'SEE ALSO' section of the dcb manpage. Signed-off-by: Daniel Machon --- man/man8/dcb.8 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/man/man8/dcb.8 b/man/man8/dcb.8 index 24944b73816b..a1d6505e93b4 100644 --- a/man/man8/dcb.8 +++ b/man/man8/dcb.8 @@ -140,10 +140,12 @@ Exit status is 0 if command was successful or a positive integer upon failure. .SH SEE ALSO .BR dcb-app (8), +.BR dcb-apptrust (8), .BR dcb-buffer (8), .BR dcb-ets (8), .BR dcb-maxrate (8), -.BR dcb-pfc (8) +.BR dcb-pfc (8), +.BR dcb-rewr (8) .br .SH REPORTING BUGS From patchwork Mon May 22 18:41:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Machon X-Patchwork-Id: 13250945 X-Patchwork-Delegate: dsahern@gmail.com Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 17587171D9 for ; Mon, 22 May 2023 18:41:43 +0000 (UTC) Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C274B7 for ; Mon, 22 May 2023 11:41:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1684780901; x=1716316901; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=o3QC/4YnVxGwCH8tYQPHg2Hyh1as7efsgGR8kHz+Qco=; b=Rkz4KE9cbLSODtNDr/TUYJ+acWDyUM9IRre61pKiillXYorwehYI4utb dXUV1a1IWHOQobIbQs3d1OEZUjV6sawQEbqid3V8KPRfdwh5nFtx9mMRY Rm6KI1W/OotkPg83ZBmb15eOrMoipC9EXar5I/0zPhZyWihGb43wIXF7C A4mSOLwWGn6iPLwO6s7Ren1iDGRHTCBrCZOJxDs5YN3MM0JLsONSNNUsK L5bXFDjH44OmOx5SvQjalUC50IhruECXapz3Dwtsgntev+kg+pD8xL6aH CbxTHKH3xZZqO05w/Smm1+zS1RvFcabrV7byWBpw1TIIIfYNXDpMT2POo Q==; X-IronPort-AV: E=Sophos;i="6.00,184,1681196400"; d="scan'208";a="214969752" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 22 May 2023 11:41:41 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Mon, 22 May 2023 11:41:39 -0700 Received: from [10.205.21.38] (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2507.21 via Frontend Transport; Mon, 22 May 2023 11:41:38 -0700 From: Daniel Machon Date: Mon, 22 May 2023 20:41:12 +0200 Subject: [PATCH iproute2-next 9/9] man: dcb-app: clean up a few mistakes Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <20230510-dcb-rewr-v1-9-83adc1f93356@microchip.com> References: <20230510-dcb-rewr-v1-0-83adc1f93356@microchip.com> In-Reply-To: <20230510-dcb-rewr-v1-0-83adc1f93356@microchip.com> To: CC: , , , , X-Mailer: b4 0.12.2 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: dsahern@gmail.com While referencing the dcb-app manpage, I spotted a few mistakes. Lets fix them. Signed-off-by: Daniel Machon --- man/man8/dcb-app.8 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/man/man8/dcb-app.8 b/man/man8/dcb-app.8 index ecb38591168e..ebec67c90801 100644 --- a/man/man8/dcb-app.8 +++ b/man/man8/dcb-app.8 @@ -1,4 +1,4 @@ -.TH DCB-ETS 8 "6 December 2020" "iproute2" "Linux" +.TH DCB-APP 8 "6 December 2020" "iproute2" "Linux" .SH NAME dcb-app \- show / manipulate application priority table of the DCB (Data Center Bridging) subsystem @@ -26,7 +26,7 @@ the DCB (Data Center Bridging) subsystem .RB "[ " pcp-prio " ]" .ti -8 -.B dcb ets " { " add " | " del " | " replace " } " dev +.B dcb app " { " add " | " del " | " replace " } " dev .RI DEV .RB "[ " default-prio " " \fIPRIO-LIST\fB " ]" .RB "[ " ethtype-prio " " \fIET-MAP\fB " ]" @@ -106,7 +106,7 @@ individual APP 3-tuples through .B add and .B del -commands. On the other other hand, the command +commands. On the other hand, the command .B replace does what one would typically want in this situation--first adds the new configuration, and then removes the obsolete one, so that only one @@ -184,7 +184,7 @@ for details. Keys are DSCP points, values are priorities assigned to traffic with matching DSCP. DSCP points can be written either directly as numeric values, or using symbolic names specified in .B /etc/iproute2/rt_dsfield -(however note that that file specifies full 8-bit dsfield values, whereas +(however note that file specifies full 8-bit dsfield values, whereas .B dcb app will only use the higher six bits). .B dcb app show @@ -230,7 +230,7 @@ priority 4: .P # dcb app replace dev eth0 dscp-prio 24:4 .br -# dcb app show dev eth0 dscp-prio +# dcb app -N show dev eth0 dscp-prio .br dscp-prio 0:0 24:4 48:6