Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp82901rwb; Wed, 18 Jan 2023 14:30:26 -0800 (PST) X-Google-Smtp-Source: AMrXdXsBEZ0aR/7YlEHk/ssZ4xBiOi04eafdA8ZnNh4gXgLQu9b5q2ZzLceOjsRUb37hXJd3tj1N X-Received: by 2002:a17:902:e9cc:b0:194:767e:96fa with SMTP id 12-20020a170902e9cc00b00194767e96famr22246261plk.44.1674081026425; Wed, 18 Jan 2023 14:30:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674081026; cv=none; d=google.com; s=arc-20160816; b=FAmXmy4PrDySzFkVgwTc8IEN4/qct6SsjOcvGGcFOnJR8hR7v09B/RpVvOz1/3Pxu6 3PdQh0B4E15g1jSP3wSyD3a3ZhVhxlRv9mi839Z4EoG5I3XxuYW2BJeZkMff5C/5rJhh QtUmWQAe7IZgcop8j4z78TgSXw6e2OsSUAkhIBD4rD0GqG9eKtAzukncpsiJtc/GD8ld vdN2R8OdzGwy56r71i1L0eWZu3mNEuFSVjKwHHOU7WRDJqDZqlzv5wyaSLNFkEuSr8kQ plo842400WAj03RRvUZ1i5ni3O7p2c4QJ9oXq0jqhE6bzXFWZWs03L/dP0HAm8tUgn1I 3ADw== 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=aNojbpCiePe9aUx8t4yn4H2lwvmq7Nz6USTPiNk6j8Q=; b=IcBJnPzckfbxVb36UqNvbYZb4Dc8z8AeqwgrwHTxT1P1vmEXPAz7mvCf2cLoW7IabZ SAeTS4IKIfgU/8a8viN9+cbiNhYNxBlHPqrXH/bsvsaU5PRjhXD3aQN2pBg+PMPx69VB IoLHsLBZri0vGFIcXsJVcbMscm8PxukLNr4B4se89tPCQTROsk5KhQuUrNJAvibdOnXM L7KEHChUJbleUyDVEqlbLfM5idbd5awfciF21Vdb914uMKsX7vtSNifthNzEzDj1miPB j5n0nOh3OcvJTuH4DgWq3Qx6hJb+NLKOgRUF2A+c/jmEn6T9TWxgtxWOds8fYQVSRA5n XBpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=df0+f1cO; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p15-20020a170902e74f00b00190fb8f9e0bsi8208492plf.490.2023.01.18.14.30.20; Wed, 18 Jan 2023 14:30:26 -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=df0+f1cO; 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 S230333AbjARVJZ (ORCPT + 45 others); Wed, 18 Jan 2023 16:09:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230335AbjARVJE (ORCPT ); Wed, 18 Jan 2023 16:09:04 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6312C611F0; Wed, 18 Jan 2023 13:09:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1674076142; x=1705612142; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Wwp41EBsynnmFWMpb+zxl4+xcQO6Z+ZQm953U3ymkZc=; b=df0+f1cOOagi5Px2kTFJherUfrjcLuG++rdt4sqH2tIAsJXYJmutYh4S 6+zBvzAOO4PfQEhO7WpH4YY1bFUVaEqjKYqp8NknagVoCtUsFHxe+9pjH YBKW9N+B7sctoom2Uxn8UZUFDGgavbvb4AbnUCxFIrC6o+tahGSSRXz6M CQk0GfjmJCRpZcpFBYhSMbt2B3gOEEi5oeBLL37jwyWCuQSI7KkwR5k5e Sp5pnWIoQfiQ6iigWdslnYsgTc+Xi1JgJwCwgFobmi/AAdMWXoafTYRWS /tZBD2XGTyojydRuHh4VBCOhh/5bjFfRYLVEcX5RSjQuAAxEqTL/aiQPU A==; X-IronPort-AV: E=Sophos;i="5.97,226,1669100400"; d="scan'208";a="197370569" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 18 Jan 2023 14:09:02 -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.16; Wed, 18 Jan 2023 14:08:59 -0700 Received: from DEN-LT-70577.microchip.com (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Wed, 18 Jan 2023 14:08:55 -0700 From: Daniel Machon To: CC: , , , , , , , , , , , , , , , , Subject: [PATCH net-next v3 4/6] net: dcb: add helper functions to retrieve PCP and DSCP rewrite maps Date: Wed, 18 Jan 2023 22:08:28 +0100 Message-ID: <20230118210830.2287069-5-daniel.machon@microchip.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230118210830.2287069-1-daniel.machon@microchip.com> References: <20230118210830.2287069-1-daniel.machon@microchip.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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 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 --- 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 2ca7fffcf069..c0c438128575 100644 --- a/net/dcb/dcbnl.c +++ b/net/dcb/dcbnl.c @@ -2232,6 +2232,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 -- 2.34.1