From patchwork Mon Jan 16 14:48:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Machon X-Patchwork-Id: 44208 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1235479wrn; Mon, 16 Jan 2023 07:00:57 -0800 (PST) X-Google-Smtp-Source: AMrXdXumRQxLjNyGGWTWbxnyCgjIDJ70M+uHq8jp/06WMdZ4vbaewTUQNUpm6gi6TkubQFA4hG4x X-Received: by 2002:a17:906:31cb:b0:870:7e7d:97a3 with SMTP id f11-20020a17090631cb00b008707e7d97a3mr3900211ejf.59.1673881257502; Mon, 16 Jan 2023 07:00:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673881257; cv=none; d=google.com; s=arc-20160816; b=EZSCqqjoF5vk82kfgHuVqQNdDKn19fQX1nD7ZizO93e/LHF8Mtg0c8nePQtsba13h1 fgU+LNHmqDKZz0/ZvMthxF3YNEHiN0mqiCt3mcilvKhyi9czYTr/FmQAoVgAdCOB40sD tdUKW1kztLFBPkUMGcPtZfGml5plx1OcsGSYmH1/Ckt8EX4s3k8GFtHPMRsFSczxd7oB CcUtNJEVdIZTX5y1zpLybsX520nlyhPqGQLU7nxl1kW+6pD/xMcL3hgePQm5sIt6Z02+ aa/5R+dtKiPSsyLU7iZUk5cCvkWjU4jCtjT5iGraARyIu5iWwWlDG1wucBrZryhmL7mr NMUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=baojEPaXOn84hWI1HRFMBUQ/Hsto9nIjMV3pYMak3s8=; b=AHBoXuN8pPLEcCw3RIMUi3AGjQ0OuoAbSsYXCUIS9UTkb+7uV/iHK2EuL9xt31LVsp rme9Jr/7JvwMn22rrTjTAzHmvpmrmSLGAbF8mPAs5inRJXS2Ou/R5fWMe8fE5AuDNjjA uKzCKFr+bDnHXMA9e+GOgRRfyn078P8CVKt6evSOJKxPOxPYTBVNlBp/mUrW2afwd1Wk bK1YqnXc9uoI8mXLCqAhnXB+kay+3AY9TPDekGOION05q3YHL3I02m5KT1JfRC63CFQK 5Ax4fj9NQ3G6X2zckeCLRo46WSCFdol0gPAeeZC5SKyFWjchMoufM06et1/k8AGOySSp UG1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=oNqaPjp7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xj1-20020a170906db0100b007c4fadff8dasi32079488ejb.933.2023.01.16.07.00.33; Mon, 16 Jan 2023 07:00:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=oNqaPjp7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232887AbjAPO7w (ORCPT + 99 others); Mon, 16 Jan 2023 09:59:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232985AbjAPO6t (ORCPT ); Mon, 16 Jan 2023 09:58:49 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3295C23113; Mon, 16 Jan 2023 06:49:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1673880563; x=1705416563; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6Qh4zQJU7xlIbKt/Tp/4b+qadxEfvcnUlOyzhGDJIL0=; b=oNqaPjp7cgfYTZ8KjzROKm2zbM5XYsKYx8B/J6moDtW5/u3KjQ1tPMeJ 9xVyGuZJQSyu9i0jClA+eiFSsfE7nq4ovn9BVD4MwkQFkWd++jMFyU8HB 8XhqQoKyyFdOHf1zBXUuYGsOMdBvaU2lf8/9MlRuOYu7giNyVziV+RUNe 9YsC0znqjicrUmrOzsVbeA7d93kCc1v146hvf6ycE1UzZYhL4uLtsf4Z2 fnuprpSlE8QdCKxlw0OU7qBXhmCQ3MvXV092ay+Q+MgikrKswm3iOyC38 raLXceAgeV3iBd7yWES1wzWkuirb70z/oafFHK32AhjhLL3zovJknWHm9 A==; X-IronPort-AV: E=Sophos;i="5.97,221,1669100400"; d="scan'208";a="207974494" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 16 Jan 2023 07:49:21 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) 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.16; Mon, 16 Jan 2023 07:49:20 -0700 Received: from DEN-LT-70577.microchip.com (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Mon, 16 Jan 2023 07:49:16 -0700 From: Daniel Machon To: CC: , , , , , , , , , , , , , , , , Subject: [PATCH net-next v2 4/6] net: dcb: add helper functions to retrieve PCP and DSCP rewrite maps Date: Mon, 16 Jan 2023 15:48:51 +0100 Message-ID: <20230116144853.2446315-5-daniel.machon@microchip.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230116144853.2446315-1-daniel.machon@microchip.com> References: <20230116144853.2446315-1-daniel.machon@microchip.com> MIME-Version: 1.0 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_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755191713666809003?= X-GMAIL-MSGID: =?utf-8?q?1755191713666809003?= Add two new helper functions to retrieve a mapping of priority to PCP and DSCP bitmasks, where each bitmap contains ones in positions that match a rewrite entry. dcb_ieee_getrewr_prio_dscp_mask_map() reuses the dcb_ieee_app_prio_map, as this struct is already used for a similar mapping in the app table. Signed-off-by: Daniel Machon Reviewed-by: Petr Machata --- include/net/dcbnl.h | 10 +++++++++ net/dcb/dcbnl.c | 52 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/include/net/dcbnl.h b/include/net/dcbnl.h index fe7dfb8bcb5b..42207fc44660 100644 --- a/include/net/dcbnl.h +++ b/include/net/dcbnl.h @@ -29,12 +29,22 @@ int dcb_ieee_setapp(struct net_device *, struct dcb_app *); int dcb_ieee_delapp(struct net_device *, struct dcb_app *); u8 dcb_ieee_getapp_mask(struct net_device *, struct dcb_app *); +struct dcb_rewr_prio_pcp_map { + u16 map[IEEE_8021QAZ_MAX_TCS]; +}; + +void dcb_getrewr_prio_pcp_mask_map(const struct net_device *dev, + struct dcb_rewr_prio_pcp_map *p_map); + struct dcb_ieee_app_prio_map { u64 map[IEEE_8021QAZ_MAX_TCS]; }; void dcb_ieee_getapp_prio_dscp_mask_map(const struct net_device *dev, struct dcb_ieee_app_prio_map *p_map); +void dcb_getrewr_prio_dscp_mask_map(const struct net_device *dev, + struct dcb_ieee_app_prio_map *p_map); + struct dcb_ieee_app_dscp_map { u8 map[64]; }; diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c index 54af3ee03491..fc1389794467 100644 --- a/net/dcb/dcbnl.c +++ b/net/dcb/dcbnl.c @@ -2231,6 +2231,58 @@ int dcb_ieee_delapp(struct net_device *dev, struct dcb_app *del) } EXPORT_SYMBOL(dcb_ieee_delapp); +/* dcb_getrewr_prio_pcp_mask_map - For a given device, find mapping from + * priorities to the PCP and DEI values assigned to that priority. + */ +void dcb_getrewr_prio_pcp_mask_map(const struct net_device *dev, + struct dcb_rewr_prio_pcp_map *p_map) +{ + int ifindex = dev->ifindex; + struct dcb_app_type *itr; + u8 prio; + + memset(p_map->map, 0, sizeof(p_map->map)); + + spin_lock_bh(&dcb_lock); + list_for_each_entry(itr, &dcb_rewr_list, list) { + if (itr->ifindex == ifindex && + itr->app.selector == DCB_APP_SEL_PCP && + itr->app.protocol < 16 && + itr->app.priority < IEEE_8021QAZ_MAX_TCS) { + prio = itr->app.priority; + p_map->map[prio] |= 1 << itr->app.protocol; + } + } + spin_unlock_bh(&dcb_lock); +} +EXPORT_SYMBOL(dcb_getrewr_prio_pcp_mask_map); + +/* dcb_getrewr_prio_dscp_mask_map - For a given device, find mapping from + * priorities to the DSCP values assigned to that priority. + */ +void dcb_getrewr_prio_dscp_mask_map(const struct net_device *dev, + struct dcb_ieee_app_prio_map *p_map) +{ + int ifindex = dev->ifindex; + struct dcb_app_type *itr; + u8 prio; + + memset(p_map->map, 0, sizeof(p_map->map)); + + spin_lock_bh(&dcb_lock); + list_for_each_entry(itr, &dcb_rewr_list, list) { + if (itr->ifindex == ifindex && + itr->app.selector == IEEE_8021QAZ_APP_SEL_DSCP && + itr->app.protocol < 64 && + itr->app.priority < IEEE_8021QAZ_MAX_TCS) { + prio = itr->app.priority; + p_map->map[prio] |= 1ULL << itr->app.protocol; + } + } + spin_unlock_bh(&dcb_lock); +} +EXPORT_SYMBOL(dcb_getrewr_prio_dscp_mask_map); + /* * dcb_ieee_getapp_prio_dscp_mask_map - For a given device, find mapping from * priorities to the DSCP values assigned to that priority. Initialize p_map