From patchwork Thu May 25 18:10:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Machon X-Patchwork-Id: 13255566 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 D06F91F95C for ; Thu, 25 May 2023 18:11:08 +0000 (UTC) Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 496CDD9 for ; Thu, 25 May 2023 11:11:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1685038262; x=1716574262; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=lihZEA8md6Ln0rRdNt1bbPU1NnyU/TsRvNIoNfvDfGM=; b=VPfeSgMvcdCJm7OF5u8IW+mubmRe6kUTt+sWQkuI5m7hmp7wWs+hfgze yovBvugImokekqU7qVBAMSRhqJIZNjdZL/Euz3YF9TX37MnMq42WPlPKa ewweFXDnSggH5r+mNeKNuauGD8JsEms62QRPw0FiM8zV3PornjD0zgEUv Ar8JUPHVu8OLneqf2JXT3bw/iOoQj8CL/Nsx3hXr19fdeSOCEiyFI42ss QxzM5Ch9pj/HjuzgEeaV2YJCl+e0cIl+Jdx1n72BWq0IVeL1OOkdJP0hs cgO23fnQHWlRKX74pRelmxuhR6MTSXUpZfT3+lMacKQxk6xPkIedEsZ3+ Q==; X-IronPort-AV: E=Sophos;i="6.00,191,1681196400"; d="scan'208";a="215499937" 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; 25 May 2023 11:11:02 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Thu, 25 May 2023 11:11:01 -0700 Received: from [10.205.21.38] (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.21 via Frontend Transport; Thu, 25 May 2023 11:11:00 -0700 From: Daniel Machon Date: Thu, 25 May 2023 20:10:21 +0200 Subject: [PATCH iproute2-next v2 1/8] 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-v2-1-9f38e688117e@microchip.com> References: <20230510-dcb-rewr-v2-0-9f38e688117e@microchip.com> In-Reply-To: <20230510-dcb-rewr-v2-0-9f38e688117e@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,URIBL_BLOCKED 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. Signed-off-by: Daniel Machon --- dcb/dcb_app.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/dcb/dcb_app.c b/dcb/dcb_app.c index eeb78e70f63f..8073415ad084 100644 --- a/dcb/dcb_app.c +++ b/dcb/dcb_app.c @@ -71,6 +71,7 @@ static void dcb_app_help(void) struct dcb_app_table { struct dcb_app *apps; size_t n_apps; + int attr; }; enum ieee_attrs_app dcb_app_attr_type_get(__u8 selector) @@ -583,7 +584,7 @@ static int dcb_app_get(struct dcb *dcb, const char *dev, struct dcb_app_table *t 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; @@ -606,7 +607,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]; @@ -715,7 +716,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); @@ -729,7 +730,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); @@ -743,7 +744,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); @@ -795,7 +796,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); @@ -848,9 +849,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); From patchwork Thu May 25 18:10:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Machon X-Patchwork-Id: 13255567 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 E841221080 for ; Thu, 25 May 2023 18:11:08 +0000 (UTC) Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BC5D19C for ; Thu, 25 May 2023 11:11:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1685038266; x=1716574266; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=lnAdOtE8rJJeWM0rv7uiFotMQI30BMt2qwsC5jOoSLM=; b=XuitoUajnU92kQixEPy+srPlR2N7UAsLPeJPbAHMUuAvHBvtxBl3p2Ve Ue7iEs1TAD15wZvmgYVUrckXMrWfXwKoJI4zjyQk1NyzuZhP+RaH3lyh3 NJwMWHEwtFt6RQdrMkUW/dLuNU18WYVJYGZI/flE5tS+Cp83l36L4Yds3 FLv1IK2r7stPsa5g9NK/YXa231F1qDsKoBAqAuL76zg5GuayWNoDjqVWv Sswe4mC95H9GL0RPik7z0uDRgyqjSf4mQheSrwgNW+AkMGhUUNevPqmfD dkpqTSIiGdMgCAGV33oLgSt5gMaJ3Mo0J/YI7Q4tK4w5o4+NP13eiVJ78 g==; X-IronPort-AV: E=Sophos;i="6.00,191,1681196400"; d="scan'208";a="227025976" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 25 May 2023 11:11:05 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) 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; Thu, 25 May 2023 11:11:02 -0700 Received: from [10.205.21.38] (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.21 via Frontend Transport; Thu, 25 May 2023 11:11:01 -0700 From: Daniel Machon Date: Thu, 25 May 2023 20:10:22 +0200 Subject: [PATCH iproute2-next v2 2/8] 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-v2-2-9f38e688117e@microchip.com> References: <20230510-dcb-rewr-v2-0-9f38e688117e@microchip.com> In-Reply-To: <20230510-dcb-rewr-v2-0-9f38e688117e@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,URIBL_BLOCKED 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 Where dcb-app requires protocol to be the printed key, dcb-rewr requires it to be the priority. Adapt existing dcb-app print functions for this. dcb_app_print_filtered() has been modified, to take two callbacks; one for printing the entire string (pid and prio), and one for the pid type (dec, hex, dscp, pcp). This saves us for making one dedicated function for each pid type for both app and rewr. 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. Signed-off-by: Daniel Machon --- dcb/dcb_app.c | 58 ++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 22 deletions(-) diff --git a/dcb/dcb_app.c b/dcb/dcb_app.c index 8073415ad084..1e36541bec61 100644 --- a/dcb/dcb_app.c +++ b/dcb/dcb_app.c @@ -403,38 +403,39 @@ 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) +static int dcb_app_print_pid_dec(__u16 protocol) { - return print_uint(PRINT_ANY, NULL, "%d:", protocol); + return print_uint(PRINT_ANY, NULL, "%u", 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); } -static int dcb_app_print_key_dscp(__u16 protocol) +static 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, "%u", protocol); } -static int dcb_app_print_key_pcp(__u16 protocol) +static 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, "%u", 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), + void (*print_pid_prio)(int (*print_pid)(__u16), + const struct dcb_app *), + int (*print_pid)(__u16 protocol), const char *json_name, const char *fp_name) { @@ -453,8 +454,8 @@ 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); + print_pid_prio(print_pid, app); + print_string(PRINT_ANY, NULL, "%s", " "); close_json_array(PRINT_JSON, NULL); } @@ -464,9 +465,17 @@ static void dcb_app_print_filtered(const struct dcb_app_table *tab, } } +static void dcb_app_print_pid_prio(int (*print_pid)(__u16 protocol), + const struct dcb_app *app) +{ + print_pid(app->protocol); + print_uint(PRINT_ANY, NULL, ":%u", app->priority); +} + 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_prio, dcb_app_print_pid_hex, "ethtype_prio", "ethtype-prio"); } @@ -474,8 +483,9 @@ 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_app_print_pid_prio, + dcb->numeric ? dcb_app_print_pid_dec : + dcb_app_print_pid_pcp, "pcp_prio", "pcp-prio"); } @@ -483,26 +493,30 @@ 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_app_print_pid_prio, + 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, + dcb_app_print_filtered(tab, dcb_app_is_stream_port, + dcb_app_print_pid_prio, 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, + dcb_app_print_filtered(tab, dcb_app_is_dgram_port, + dcb_app_print_pid_prio, 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_prio, dcb_app_print_pid_dec, "port_prio", "port-prio"); } From patchwork Thu May 25 18:10:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Machon X-Patchwork-Id: 13255568 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 B916622608 for ; Thu, 25 May 2023 18:11:10 +0000 (UTC) Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 002911A2 for ; Thu, 25 May 2023 11:11:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1685038267; x=1716574267; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=TwS+SgQnLkUmPQUlmnMvKsHqzy6kjPsgI99KvblQszk=; b=pVAUrnsalFRZMcCB/iijYYDlB14URvDZe96FV8y+TChcH4Ep78LBo0Ly d6XhxMnV7oF2IqOQD4E9JuSW5J7b+fd8ynX1USsrFSlfQQsLbWWVbvkIy Zj4g/BZ7CEaTzxdtJvehhvmFo8mbL3oU7fLXSRSb7p9WJ0IrlyCLoKkiR pxgg+c06WjlYpKpewr+ZCfsKpsx+fQQuf8XHOMQKIDqKLuXZ/L91Wc/vQ MwRAVdXZ7axh8UAOSLacVX6334R4mClE3FlHjFbNUhm48eUa17+GsmmHX jrg3NClMYd7kRRbJ6TASr5Vgi3dkFtXhOL08BVvLbos+k02JHhwBzdtwP A==; X-IronPort-AV: E=Sophos;i="6.00,191,1681196400"; d="scan'208";a="227025978" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 25 May 2023 11:11:05 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) 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; Thu, 25 May 2023 11:11:04 -0700 Received: from [10.205.21.38] (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.21 via Frontend Transport; Thu, 25 May 2023 11:11:03 -0700 From: Daniel Machon Date: Thu, 25 May 2023 20:10:23 +0200 Subject: [PATCH iproute2-next v2 3/8] 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-v2-3-9f38e688117e@microchip.com> References: <20230510-dcb-rewr-v2-0-9f38e688117e@microchip.com> In-Reply-To: <20230510-dcb-rewr-v2-0-9f38e688117e@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,URIBL_BLOCKED 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. Adapt the existing dcb_app_table_remove_replace function for this, by using callback functions for selector, pid and prio checks. Signed-off-by: Daniel Machon --- dcb/dcb.h | 14 ++++++++++++++ dcb/dcb_app.c | 32 ++++++++++++++++++++------------ 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/dcb/dcb.h b/dcb/dcb.h index d40664f29dad..84ce95d5c1b2 100644 --- a/dcb/dcb.h +++ b/dcb/dcb.h @@ -56,11 +56,25 @@ void dcb_print_array_kw(const __u8 *array, size_t array_size, /* dcb_app.c */ +struct dcb_app_table { + struct dcb_app *apps; + size_t n_apps; + int attr; +}; + 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); +bool dcb_app_pid_eq(const struct dcb_app *aa, const struct dcb_app *ab); +bool dcb_app_prio_eq(const struct dcb_app *aa, const struct dcb_app *ab); + +void dcb_app_table_remove_replaced(struct dcb_app_table *a, + const struct dcb_app_table *b, + bool (*key_eq)(const struct dcb_app *aa, + const struct dcb_app *ab)); + /* 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 1e36541bec61..4cd175a0623b 100644 --- a/dcb/dcb_app.c +++ b/dcb/dcb_app.c @@ -68,12 +68,6 @@ static void dcb_app_help(void) dcb_app_help_add(); } -struct dcb_app_table { - struct dcb_app *apps; - size_t n_apps; - int attr; -}; - enum ieee_attrs_app dcb_app_attr_type_get(__u8 selector) { switch (selector) { @@ -153,8 +147,22 @@ 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) +bool dcb_app_pid_eq(const struct dcb_app *aa, const struct dcb_app *ab) +{ + return aa->selector == ab->selector && + aa->protocol == ab->protocol; +} + +bool dcb_app_prio_eq(const struct dcb_app *aa, const struct dcb_app *ab) +{ + return aa->selector == ab->selector && + aa->priority == ab->priority; +} + +void dcb_app_table_remove_replaced(struct dcb_app_table *a, + const struct dcb_app_table *b, + bool (*key_eq)(const struct dcb_app *aa, + const struct dcb_app *ab)) { size_t ia, ja; size_t ib; @@ -167,13 +175,13 @@ static 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) + if (key_eq(aa, ab)) present = true; else continue; - if (aa->priority == ab->priority) { + if (aa->protocol == ab->protocol && + aa->priority == ab->priority) { found = true; break; } @@ -891,7 +899,7 @@ static int dcb_cmd_app_replace(struct dcb *dcb, const char *dev, int argc, char } /* Remove the obsolete entries. */ - dcb_app_table_remove_replaced(&orig, &tab); + dcb_app_table_remove_replaced(&orig, &tab, dcb_app_pid_eq); ret = dcb_app_add_del(dcb, dev, DCB_CMD_IEEE_DEL, &orig, NULL); if (ret != 0) { fprintf(stderr, "Could not remove replaced APP entries\n"); From patchwork Thu May 25 18:10:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Machon X-Patchwork-Id: 13255569 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 114E42261D for ; Thu, 25 May 2023 18:11:11 +0000 (UTC) Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D91FC1A6 for ; Thu, 25 May 2023 11:11:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1685038268; x=1716574268; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=pY1cAaxQTGK3OaSPybs5KAReghNK/3w3j7LcNLDonac=; b=KszM+XheJ2P1TpD+PCH5VGzYKBlmTm3pSHYvixgZqy5lMAWhy9oLiLrK By/Ii6wxpGIaZISps3NnquFHmyLqJLjRn09ejvoXLTA8tWeHatucaDJWe doPrz20z+D92PttyL4ZzO61fluW/I+70z/eFx1roHJkxFdHS1+fpb6nAX CmqZquGzRSikoTNM6iDxGVIGvooOTDsQ1qp3ToBkQ4eY5uMZ9TLTPYNfn +NSkeunsBVMulU5f6qlOw/0GMxj0iOuKs4CH9vjDMo8ZKbAk8ESbJYzer khq94GG1k2wDANl9610cSjMkU3xaRR5OUSEgkie8gvxWMfIutzmYfRLVd g==; X-IronPort-AV: E=Sophos;i="6.00,191,1681196400"; d="scan'208";a="227025983" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 25 May 2023 11:11:07 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) 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; Thu, 25 May 2023 11:11:06 -0700 Received: from [10.205.21.38] (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.21 via Frontend Transport; Thu, 25 May 2023 11:11:04 -0700 From: Daniel Machon Date: Thu, 25 May 2023 20:10:24 +0200 Subject: [PATCH iproute2-next v2 4/8] 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-v2-4-9f38e688117e@microchip.com> References: <20230510-dcb-rewr-v2-0-9f38e688117e@microchip.com> In-Reply-To: <20230510-dcb-rewr-v2-0-9f38e688117e@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,URIBL_BLOCKED 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. Adapt the existing dcb_app_parse_mapping_cb for this, by using callbacks for pushing app or rewr entries to the table. Signed-off-by: Daniel Machon --- dcb/dcb.h | 12 ++++++++++++ dcb/dcb_app.c | 23 ++++++++++++----------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/dcb/dcb.h b/dcb/dcb.h index 84ce95d5c1b2..b3bc30cd02c5 100644 --- a/dcb/dcb.h +++ b/dcb/dcb.h @@ -62,7 +62,16 @@ struct dcb_app_table { int attr; }; +struct dcb_app_parse_mapping { + __u8 selector; + struct dcb_app_table *tab; + int (*push)(struct dcb_app_table *tab, + __u8 selector, __u32 key, __u64 value); + int err; +}; + 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); @@ -70,11 +79,14 @@ bool dcb_app_selector_validate(enum ieee_attrs_app type, __u8 selector); bool dcb_app_pid_eq(const struct dcb_app *aa, const struct dcb_app *ab); bool dcb_app_prio_eq(const struct dcb_app *aa, const struct dcb_app *ab); +int dcb_app_table_push(struct dcb_app_table *tab, struct dcb_app *app); void dcb_app_table_remove_replaced(struct dcb_app_table *a, const struct dcb_app_table *b, bool (*key_eq)(const struct dcb_app *aa, const struct dcb_app *ab)); +void dcb_app_parse_mapping_cb(__u32 key, __u64 value, void *data); + /* 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 4cd175a0623b..97cba658aa6b 100644 --- a/dcb/dcb_app.c +++ b/dcb/dcb_app.c @@ -105,7 +105,7 @@ static void dcb_app_table_fini(struct dcb_app_table *tab) free(tab->apps); } -static int dcb_app_table_push(struct dcb_app_table *tab, struct dcb_app *app) +int dcb_app_table_push(struct dcb_app_table *tab, struct dcb_app *app) { struct dcb_app *apps = realloc(tab->apps, (tab->n_apps + 1) * sizeof(*tab->apps)); @@ -231,25 +231,25 @@ static 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) +static int dcb_app_push(struct dcb_app_table *tab, + __u8 selector, __u32 key, __u64 value) { - struct dcb_app_parse_mapping *pm = data; struct dcb_app app = { - .selector = pm->selector, + .selector = selector, .priority = value, .protocol = key, }; + return dcb_app_table_push(tab, &app); +} + +void dcb_app_parse_mapping_cb(__u32 key, __u64 value, void *data) +{ + struct dcb_app_parse_mapping *pm = data; if (pm->err) return; - pm->err = dcb_app_table_push(pm->tab, &app); + pm->err = pm->push(pm->tab, pm->selector, key, value); } static int dcb_app_parse_mapping_ethtype_prio(__u32 key, char *value, void *data) @@ -663,6 +663,7 @@ static int dcb_cmd_app_parse_add_del(struct dcb *dcb, const char *dev, { struct dcb_app_parse_mapping pm = { .tab = tab, + .push = dcb_app_push, }; int ret; From patchwork Thu May 25 18:10:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Machon X-Patchwork-Id: 13255571 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 3135D19532 for ; Thu, 25 May 2023 18:11:13 +0000 (UTC) Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D714B1A4 for ; Thu, 25 May 2023 11:11:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1685038269; x=1716574269; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=R9TXn39OaPVGwn+WAIogqyIiTPTC/caltsdL/6tESVU=; b=easFFDeKraHI8fZEJIUaLHdDITtoKWLZw6Fqjd0DYK4ajphIcV7JGlC3 xJvL9ZMfWq9DKz7YmlAw+e/ZsbApSPzWUgTBxYniLaCWqCyictfRaN5vt 1dZAo64nUFBzqA0Wwj80ZBlkyzDqsRHrdbG2BNxI+uqJqvB0ioerLbyy7 q8AXsp7PUJvAMNxEhEGE1NYBCGciS5YUdOKGXVEfc8Fq9/rI+lMts/xAg 3V4cmuJoDSY/+v+NW4NWXX9IonyqXDQghiSiBKAlEIttfqDb1sO5+E/Dv gnQhxjkxkMpn+4DkVjS+vp0KWq50xLIR6vdSdK+OQG/DLI9n20UBSbiXF Q==; X-IronPort-AV: E=Sophos;i="6.00,191,1681196400"; d="scan'208";a="213094946" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 25 May 2023 11:11:08 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Thu, 25 May 2023 11:11:07 -0700 Received: from [10.205.21.38] (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.21 via Frontend Transport; Thu, 25 May 2023 11:11:06 -0700 From: Daniel Machon Date: Thu, 25 May 2023 20:10:25 +0200 Subject: [PATCH iproute2-next v2 5/8] 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-v2-5-9f38e688117e@microchip.com> References: <20230510-dcb-rewr-v2-0-9f38e688117e@microchip.com> In-Reply-To: <20230510-dcb-rewr-v2-0-9f38e688117e@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,URIBL_BLOCKED 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 | 32 ++++++ dcb/dcb_app.c | 49 ++++---- dcb/dcb_rewr.c | 355 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 416 insertions(+), 27 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 b3bc30cd02c5..092dc90e8358 100644 --- a/dcb/dcb.h +++ b/dcb/dcb.h @@ -54,6 +54,10 @@ 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); +/* dcp_rewr.c */ + +int dcb_cmd_rewr(struct dcb *dcb, int argc, char **argv); + /* dcb_app.c */ struct dcb_app_table { @@ -70,8 +74,29 @@ struct dcb_app_parse_mapping { int err; }; +#define DCB_APP_PCP_MAX 15 +#define DCB_APP_DSCP_MAX 63 + 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 *)); + +bool dcb_app_is_dscp(const struct dcb_app *app); +bool dcb_app_is_pcp(const struct dcb_app *app); + +int dcb_app_print_pid_dscp(__u16 protocol); +int dcb_app_print_pid_pcp(__u16 protocol); +int dcb_app_print_pid_dec(__u16 protocol); +void dcb_app_print_filtered(const struct dcb_app_table *tab, + bool (*filter)(const struct dcb_app *), + void (*print_pid_prio)(int (*print_pid)(__u16), + const struct dcb_app *), + int (*print_pid)(__u16 protocol), + const char *json_name, const char *fp_name); + 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); @@ -80,11 +105,18 @@ bool dcb_app_pid_eq(const struct dcb_app *aa, const struct dcb_app *ab); bool dcb_app_prio_eq(const struct dcb_app *aa, const struct dcb_app *ab); int dcb_app_table_push(struct dcb_app_table *tab, struct dcb_app *app); +int dcb_app_table_copy(struct dcb_app_table *a, const struct dcb_app_table *b); +void dcb_app_table_sort(struct dcb_app_table *tab); +void dcb_app_table_fini(struct dcb_app_table *tab); +void dcb_app_table_remove_existing(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, bool (*key_eq)(const struct dcb_app *aa, const struct dcb_app *ab)); +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); /* dcb_apptrust.c */ diff --git a/dcb/dcb_app.c b/dcb/dcb_app.c index 97cba658aa6b..3cb1bb302ed6 100644 --- a/dcb/dcb_app.c +++ b/dcb/dcb_app.c @@ -100,7 +100,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); } @@ -119,8 +119,8 @@ 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; @@ -198,8 +198,7 @@ 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; @@ -226,7 +225,7 @@ 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); } @@ -269,7 +268,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; @@ -295,7 +294,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; @@ -320,7 +319,7 @@ static int dcb_app_parse_mapping_dscp_prio(__u32 key, char *value, void *data) if (get_u8(&prio, value, 0)) return -EINVAL; - return dcb_parse_mapping("DSCP", key, 63, + return dcb_parse_mapping("DSCP", key, DCB_APP_DSCP_MAX, "PRIO", prio, IEEE_8021QAZ_MAX_TCS - 1, dcb_app_parse_mapping_cb, data); } @@ -386,12 +385,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; } @@ -411,7 +410,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_pid_dec(__u16 protocol) +int dcb_app_print_pid_dec(__u16 protocol) { return print_uint(PRINT_ANY, NULL, "%u", protocol); } @@ -421,7 +420,7 @@ static int dcb_app_print_pid_hex(__u16 protocol) return print_uint(PRINT_ANY, NULL, "%x", protocol); } -static int dcb_app_print_pid_dscp(__u16 protocol) +int dcb_app_print_pid_dscp(__u16 protocol) { const char *name = rtnl_dsfield_get_name(protocol << 2); @@ -430,7 +429,7 @@ static int dcb_app_print_pid_dscp(__u16 protocol) return print_uint(PRINT_ANY, NULL, "%u", protocol); } -static int dcb_app_print_pid_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) @@ -439,13 +438,13 @@ static int dcb_app_print_pid_pcp(__u16 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 *), - void (*print_pid_prio)(int (*print_pid)(__u16), - const struct dcb_app *), - int (*print_pid)(__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 *), + void (*print_pid_prio)(int (*print_pid)(__u16), + const struct dcb_app *), + int (*print_pid)(__u16 protocol), + const char *json_name, + const char *fp_name) { bool first = true; size_t i; @@ -600,7 +599,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; @@ -643,9 +642,9 @@ 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, - const struct dcb_app_table *tab, - bool (*filter)(const struct dcb_app *)) +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 *)) { struct dcb_app_add_del add_del = { .tab = tab, diff --git a/dcb/dcb_rewr.c b/dcb/dcb_rewr.c new file mode 100644 index 000000000000..37372465cae0 --- /dev/null +++ b/dcb/dcb_rewr.c @@ -0,0 +1,355 @@ +// 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_pid(int (*print_pid)(__u16 protocol), + const struct dcb_app *app) +{ + print_uint(PRINT_ANY, NULL, "%u:", app->priority); + print_pid(app->protocol); +} + +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_rewr_print_prio_pid, + 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_rewr_print_prio_pid, + 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_rewr_push(struct dcb_app_table *tab, + __u8 selector, __u32 key, __u64 value) +{ + struct dcb_app app = { + .selector = selector, + .priority = key, + .protocol = value, + }; + return dcb_app_table_push(tab, &app); +} + +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, + .push = dcb_rewr_push, + }; + 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, dcb_app_prio_eq); + 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 Thu May 25 18:10:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Machon X-Patchwork-Id: 13255570 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 4CC542261D for ; Thu, 25 May 2023 18:11:12 +0000 (UTC) Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B42D5D8 for ; Thu, 25 May 2023 11:11:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1685038269; x=1716574269; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=6+QWEVz4aCT5UwKze9znK07ssiPNqha49g+7PmmsCPU=; b=aHdhEMmd3NmOYuyOngZHGzVMcbJ8+s2Jrg/YjEKJFJ5UDF+WLNIzk+0q WEgLm4bCsZHAdRAWxXoJTclI3a0wg/oVnkr3RBbLc0Nonp+IvEN7Du9+S xHhbjxYbUX+lzzo+ZIEUFWZnjkqkpC1PQg+NjaOa4O8Q14Gm4e39o4ZTK IppbSx69Q0jmBv48ugm3ob+/rEhRkm46rShT6KBJ+ma8qOjdYkN4XcVkJ rwO8L+wY/9QVeab5N+HT2ra6AwTxfwvUpxzXVXu/QhVOYjFBYB4wIHijS OLgOpJzOI4Ig9jmVJhk0JBD9LxfSsXxakmtq7pGnClWqUnxjGY2Dxo0kc w==; X-IronPort-AV: E=Sophos;i="6.00,191,1681196400"; d="scan'208";a="227026000" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 25 May 2023 11:11:09 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) 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; Thu, 25 May 2023 11:11:09 -0700 Received: from [10.205.21.38] (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.21 via Frontend Transport; Thu, 25 May 2023 11:11:07 -0700 From: Daniel Machon Date: Thu, 25 May 2023 20:10:26 +0200 Subject: [PATCH iproute2-next v2 6/8] 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-v2-6-9f38e688117e@microchip.com> References: <20230510-dcb-rewr-v2-0-9f38e688117e@microchip.com> In-Reply-To: <20230510-dcb-rewr-v2-0-9f38e688117e@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,URIBL_BLOCKED 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 Reviewed-by: Petr Machata --- 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..03b59cf4837c --- /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 the 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 Thu May 25 18:10:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Machon X-Patchwork-Id: 13255572 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 98E6819532 for ; Thu, 25 May 2023 18:11:14 +0000 (UTC) Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22EE512C for ; Thu, 25 May 2023 11:11:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1685038272; x=1716574272; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=VIqgeqTE41QWhNjlhHHHMfj2IZeaAiOoVx9OgelY3zU=; b=gbq/YFq811A08zypnSXJoE3Yl7YfGmK4VbKAk5/XXEXETJlqEbL0HEXY zL9HS59OEqOs15X2aW99NnI2y0yzUjx7+RZl8mflhiNf1r0QztuwtkVUO L5qNlnRVtOc3SJKES3YlI/qmRdUOZ2tuE+797ntfrjzLAS+KCKgGMDebE k7nMfbNnDP3IFsMzzMSGYfT2V5PZ2sZAFjTVF8p60TjAxv47224njoKM4 cCea3ynZADRLsiYFb25tNuBTq1IGmOYOYbvB2RE1hx/s2ZQvrGmW79yQN oyazeF6/Jj7dEc8f4zn0+KqgjlmjdjDbH5Z2lx6dZu9pjmpuI5PmF9/TS w==; X-IronPort-AV: E=Sophos;i="6.00,191,1681196400"; d="scan'208";a="215499952" 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; 25 May 2023 11:11:12 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Thu, 25 May 2023 11:11:10 -0700 Received: from [10.205.21.38] (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.21 via Frontend Transport; Thu, 25 May 2023 11:11:09 -0700 From: Daniel Machon Date: Thu, 25 May 2023 20:10:27 +0200 Subject: [PATCH iproute2-next v2 7/8] 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-v2-7-9f38e688117e@microchip.com> References: <20230510-dcb-rewr-v2-0-9f38e688117e@microchip.com> In-Reply-To: <20230510-dcb-rewr-v2-0-9f38e688117e@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,URIBL_BLOCKED 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 Reviewed-by: Petr Machata --- 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 Thu May 25 18:10:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Machon X-Patchwork-Id: 13255573 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 F047B101DA for ; Thu, 25 May 2023 18:11: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 DA580D8 for ; Thu, 25 May 2023 11:11: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=1685038292; x=1716574292; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=PT3Sa6iYxiN2q+wWQMrHB7xxWT17qn7L4PefheSr2JA=; b=R3N3tnCPBRxBmhQv29be/42r0mEEmqSTn5bx7Af7FINWIawXIlU8P1OC aje27nuZPhhMySdufWM72GcWxvKm2dgTGX27wRMwsldRhTsjJdp1r9AtH 6VtUAX6AggvMC6y7kTO7+IGLJwDvcmhajvrfZmMrfuk4GDQEQLYOi6Zmr teARuZB4FMOe5M5ybJ+yAigMyFZmJpjuJiHUExQSsr9ZS02T4R+y5SYkX IQlRI9QcFlnlIHvzAOboEUyrtvITEiHq/FmMAQ/eoQ4QeUKMxCxSdp9f7 5GuRMzDk/EhXLyUWJzhQ6BqL86lwKhFf0on5zByi0fsBgAkALA2HMUO3O Q==; X-IronPort-AV: E=Sophos;i="6.00,191,1681196400"; d="scan'208";a="217319855" 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; 25 May 2023 11:11:32 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) 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; Thu, 25 May 2023 11:11:12 -0700 Received: from [10.205.21.38] (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.21 via Frontend Transport; Thu, 25 May 2023 11:11:11 -0700 From: Daniel Machon Date: Thu, 25 May 2023 20:10:28 +0200 Subject: [PATCH iproute2-next v2 8/8] 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-v2-8-9f38e688117e@microchip.com> References: <20230510-dcb-rewr-v2-0-9f38e688117e@microchip.com> In-Reply-To: <20230510-dcb-rewr-v2-0-9f38e688117e@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,URIBL_BLOCKED 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 Reviewed-by: Petr Machata --- 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..be505a0be308 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 the 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