From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5967CC433EF for ; Wed, 2 Feb 2022 00:04:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243108AbiBBAER (ORCPT ); Tue, 1 Feb 2022 19:04:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243082AbiBBAEM (ORCPT ); Tue, 1 Feb 2022 19:04:12 -0500 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96C70C06173B; Tue, 1 Feb 2022 16:04:12 -0800 (PST) Received: by mail-ed1-x52e.google.com with SMTP id u24so37669067eds.11; Tue, 01 Feb 2022 16:04:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PBNCS2QbHogQfRAW59h5YIugEzrVS9q3EYocxM/OSkM=; b=a3YsEaI5uFYT1GLJRzyJxND6xoiQlPghij30lqcfQgLkxmYpQ5yXx9Qj4hJBapoas4 M3yUJxUnn+gkJ6kNW2390gEC5AcIYRNbPspJt3USSvQg2KhWpF3njwENzjLfH6+vEiQY 65i+gG5yk+W/FR7fcwTKFkGvd4cumlKHGGQBdBICyAe/vtU7bPkFXP5foFptKVyqaZU/ ehbMjcWIkOw6WSHZPDM9amJguv6kzMse1BDzEj/k0iN0KaFjS45ltJAF76sylkR/Mbd4 JsJuWEIDs6nxZ/X1++yXPH9ZddI6XJCZPcFHXy51a6fSeIfTT4mo1TV+/FOvIxrpRkQU Fb7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PBNCS2QbHogQfRAW59h5YIugEzrVS9q3EYocxM/OSkM=; b=v9O7FTfWAfGaAbh0wlLQYXL8yxpEY7gm5ApqfN+/cpVbxSiCWT7gnpI4UHlY6ngDfO 2ejAMu/WhnO/hUHlICAw03axINy1/dlSNSwtmTVcUz+ptdDQpPaMmPNpmt7VLpnG6rNy lQkQB8i0x3QXsKPRNm19gwCw/yT5ciqOME6Cob+XRyygJmnFIsrL0AzUsMqBoQ19yAty cfbSObdui043kmtA+gHQ4IgrhSkkpLuebv4q706vTpL1lcaPtpM2g5ik6ogP17XBlI42 xrYp7m1QrqGmA1n1ylk/g/0QXeDItnM5uCga1a7l5i9p8EpCZpmM2a53oyDWvMlojZ9s smMw== X-Gm-Message-State: AOAM5314RkRx5vTQJWozynGqhyx7Av29XH0gmeB0Ox6LGkz5DPPvOQXn PtKPh+jQbb/m4G37ZpaU7hxGlgLox7w= X-Google-Smtp-Source: ABdhPJwVUJ1ZfJlAceSBK9jUXWrAZwqzyOHYNOyYWOvO/e/JvnBeEV+tnU5xinlOozY8xW4z98xY8g== X-Received: by 2002:a05:6402:42c6:: with SMTP id i6mr28598063edc.166.1643760251035; Tue, 01 Feb 2022 16:04:11 -0800 (PST) Received: from Ansuel-xps.localdomain (93-42-71-246.ip85.fastwebnet.it. [93.42.71.246]) by smtp.googlemail.com with ESMTPSA id n3sm3590451ejr.6.2022.02.01.16.04.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 16:04:10 -0800 (PST) From: Ansuel Smith To: Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Jakub Kicinski , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: Ansuel Smith Subject: [net-next PATCH v8 03/16] net: dsa: tag_qca: convert to FIELD macro Date: Wed, 2 Feb 2022 01:03:22 +0100 Message-Id: <20220202000335.19296-4-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220202000335.19296-1-ansuelsmth@gmail.com> References: <20220202000335.19296-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Convert driver to FIELD macro to drop redundant define. Signed-off-by: Ansuel Smith Reviewed-by: Vladimir Oltean Reviewed-by: Florian Fainelli --- net/dsa/tag_qca.c | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/net/dsa/tag_qca.c b/net/dsa/tag_qca.c index 1ea9401b8ace..55fa6b96b4eb 100644 --- a/net/dsa/tag_qca.c +++ b/net/dsa/tag_qca.c @@ -4,29 +4,24 @@ */ #include +#include #include "dsa_priv.h" #define QCA_HDR_LEN 2 #define QCA_HDR_VERSION 0x2 -#define QCA_HDR_RECV_VERSION_MASK GENMASK(15, 14) -#define QCA_HDR_RECV_VERSION_S 14 -#define QCA_HDR_RECV_PRIORITY_MASK GENMASK(13, 11) -#define QCA_HDR_RECV_PRIORITY_S 11 -#define QCA_HDR_RECV_TYPE_MASK GENMASK(10, 6) -#define QCA_HDR_RECV_TYPE_S 6 +#define QCA_HDR_RECV_VERSION GENMASK(15, 14) +#define QCA_HDR_RECV_PRIORITY GENMASK(13, 11) +#define QCA_HDR_RECV_TYPE GENMASK(10, 6) #define QCA_HDR_RECV_FRAME_IS_TAGGED BIT(3) -#define QCA_HDR_RECV_SOURCE_PORT_MASK GENMASK(2, 0) - -#define QCA_HDR_XMIT_VERSION_MASK GENMASK(15, 14) -#define QCA_HDR_XMIT_VERSION_S 14 -#define QCA_HDR_XMIT_PRIORITY_MASK GENMASK(13, 11) -#define QCA_HDR_XMIT_PRIORITY_S 11 -#define QCA_HDR_XMIT_CONTROL_MASK GENMASK(10, 8) -#define QCA_HDR_XMIT_CONTROL_S 8 +#define QCA_HDR_RECV_SOURCE_PORT GENMASK(2, 0) + +#define QCA_HDR_XMIT_VERSION GENMASK(15, 14) +#define QCA_HDR_XMIT_PRIORITY GENMASK(13, 11) +#define QCA_HDR_XMIT_CONTROL GENMASK(10, 8) #define QCA_HDR_XMIT_FROM_CPU BIT(7) -#define QCA_HDR_XMIT_DP_BIT_MASK GENMASK(6, 0) +#define QCA_HDR_XMIT_DP_BIT GENMASK(6, 0) static struct sk_buff *qca_tag_xmit(struct sk_buff *skb, struct net_device *dev) { @@ -40,8 +35,9 @@ static struct sk_buff *qca_tag_xmit(struct sk_buff *skb, struct net_device *dev) phdr = dsa_etype_header_pos_tx(skb); /* Set the version field, and set destination port information */ - hdr = QCA_HDR_VERSION << QCA_HDR_XMIT_VERSION_S | - QCA_HDR_XMIT_FROM_CPU | BIT(dp->index); + hdr = FIELD_PREP(QCA_HDR_XMIT_VERSION, QCA_HDR_VERSION); + hdr |= QCA_HDR_XMIT_FROM_CPU; + hdr |= FIELD_PREP(QCA_HDR_XMIT_DP_BIT, BIT(dp->index)); *phdr = htons(hdr); @@ -62,7 +58,7 @@ static struct sk_buff *qca_tag_rcv(struct sk_buff *skb, struct net_device *dev) hdr = ntohs(*phdr); /* Make sure the version is correct */ - ver = (hdr & QCA_HDR_RECV_VERSION_MASK) >> QCA_HDR_RECV_VERSION_S; + ver = FIELD_GET(QCA_HDR_RECV_VERSION, hdr); if (unlikely(ver != QCA_HDR_VERSION)) return NULL; @@ -71,7 +67,7 @@ static struct sk_buff *qca_tag_rcv(struct sk_buff *skb, struct net_device *dev) dsa_strip_etype_header(skb, QCA_HDR_LEN); /* Get source port information */ - port = (hdr & QCA_HDR_RECV_SOURCE_PORT_MASK); + port = FIELD_GET(QCA_HDR_RECV_SOURCE_PORT, hdr); skb->dev = dsa_master_find_slave(dev, 0, port); if (!skb->dev) -- 2.33.1