From patchwork Wed Aug 25 08:38:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qingfang Deng X-Patchwork-Id: 12456729 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3A8EC4338F for ; Wed, 25 Aug 2021 08:41:10 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AF29B61176 for ; Wed, 25 Aug 2021 08:41:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org AF29B61176 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=7y6V1YiTFPuifBfWYhGDav/TvMuVrKhkEU6McUoxCQU=; b=0BLFP5LMLAN/Af Ja6+Sqqn6ngKDG1Eex8/ImswCxdEFJNR0DeTPQKwF/KzMp3HGw70Xwp5EqJce3bXcG53G0utQhsno 9RcD7ji4hIzSoRYndQuYQPpKTIzv5e92lA3WV8IZgTjLFJ9K/8y/wElb1dVEyG6Dr6xYZI4qNxq0D e1RA9ooPfdGBExcw+YCvdbKvzfz5FLXATtl3hdjrqMa7ukxV/fsHRVlsYb1H8Ye/FKo5KSUrM5UwR eOX7hY93K0UC7qdc6h2A/uE5QgL8XFgqD8MOFeW0cOjVCwhWQ5cJtlfNhsQ0MCJKJ0LUlkSCp0bvD Z3Mexvn8xeFj+UPw/L3w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mIoRE-005wxU-Rf; Wed, 25 Aug 2021 08:39:13 +0000 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mIoR0-005wsF-Vy; Wed, 25 Aug 2021 08:39:00 +0000 Received: by mail-pg1-x52f.google.com with SMTP id g184so3857471pgc.6; Wed, 25 Aug 2021 01:38:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Dbzh7P/VLZjz7T/PHz/hbVveQrgt7YUkwRS8X1gGPMQ=; b=PTryOgjrkt3xSyLLZ3nI0ySlPsg/rl42Z0nmnf4JRFvvk84qFrsvr2LFark0zt6Zak KupWKcKNvx4c7Kp/JxLfkkMJ5hHP0qa0vGDfzYUEcKlfzYynxZH7176zVLY7hjT/webd RsJkq6SgkfevzO0pn/U5EJneZBoK5QW6SCi+cP1M/1dOLqYHQ+RmwS0iV51F8yTjm0eF r3vARMZhBwWhsOWRwpVF/DAgWgEgb11ZmyT/y6KHl/7s300OE8fwyf9ZYkVgqCCIdvfc fex16reT0nrhHm1tz13SsnBM9Ini/rBK9wRaSpkGpdYP1BhHkX/gxzrIdxd6tnqRFXdH UUrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Dbzh7P/VLZjz7T/PHz/hbVveQrgt7YUkwRS8X1gGPMQ=; b=p6wokiM59gGm00Wxm0thvmG7xbrAXt3xhLtCO6kPYMAJtge6Rq0tjgOWF5cS2nWkaJ eg19+D3iZk4N9iYXjTJA+WbZMCPpPwunt6GdVT3lUOKsBkJKibra3uHcevhhhdqNlOlJ s1+lIqb5T/LL4OD5dqSNfk75dld29wQolcYusi2d0k/ld7uhcZY58hTgYMzcvsFOmrfP KskL2Vw6humR/tgck2mxI8JCjxFIB6We7n2n22NXQ+B36O2K2WPqVjMwprEQVfl+J6f9 gWwSXZPc5yIqgR/QszqucNW5sW6CQXBxKGT2MDDJXVtFZyeFQNsI8z/HF8QUczWbVWi6 2FRw== X-Gm-Message-State: AOAM530js0XODI91k/MPAuQ0tIiTDjs7eGhPnqFsSnvQjjSoO3hZDijY Atcs0qpio6JSLFeRK+DhDJM= X-Google-Smtp-Source: ABdhPJwKwchoRLdo4BZ3JiVc2OLHRyzG0ZZZHm30+1GgS/uyS0K2qPV/3P41I55ugBeCg/tJeNDEHA== X-Received: by 2002:a63:3dcd:: with SMTP id k196mr1250905pga.387.1629880729365; Wed, 25 Aug 2021 01:38:49 -0700 (PDT) Received: from haswell-ubuntu20.lan ([138.197.212.246]) by smtp.gmail.com with ESMTPSA id p18sm24872294pgk.28.2021.08.25.01.38.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Aug 2021 01:38:48 -0700 (PDT) From: DENG Qingfang To: Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Jakub Kicinski , Sean Wang , Landen Chao , Matthias Brugger , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [RFC net-next 1/2] net: dsa: allow taggers to customise netdev features Date: Wed, 25 Aug 2021 16:38:30 +0800 Message-Id: <20210825083832.2425886-2-dqfext@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210825083832.2425886-1-dqfext@gmail.com> References: <20210825083832.2425886-1-dqfext@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210825_013859_070669_D2F63BCC X-CRM114-Status: GOOD ( 12.56 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Allow taggers to add netdev features, such as VLAN offload, to slave devices, which will make it possible for taggers to handle VLAN tags themselves. Signed-off-by: DENG Qingfang Reviewed-by: Vladimir Oltean Reviewed-by: Florian Fainelli --- include/net/dsa.h | 2 ++ net/dsa/slave.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/net/dsa.h b/include/net/dsa.h index f9a17145255a..f65442858f71 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -96,6 +96,8 @@ struct dsa_device_ops { * its RX filter. */ bool promisc_on_master; + /* Additional features to be applied to the slave. */ + netdev_features_t features; }; /* This structure defines the control interfaces that are overlayed by the diff --git a/net/dsa/slave.c b/net/dsa/slave.c index 662ff531d4e2..6d6f1aebf1ca 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -1885,7 +1885,8 @@ void dsa_slave_setup_tagger(struct net_device *slave) p->xmit = cpu_dp->tag_ops->xmit; - slave->features = master->vlan_features | NETIF_F_HW_TC; + slave->features = master->vlan_features | cpu_dp->tag_ops->features | + NETIF_F_HW_TC; slave->hw_features |= NETIF_F_HW_TC; slave->features |= NETIF_F_LLTX; if (slave->needed_tailroom) From patchwork Wed Aug 25 08:38:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qingfang Deng X-Patchwork-Id: 12456731 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E444C4338F for ; Wed, 25 Aug 2021 08:41:21 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DF58360187 for ; Wed, 25 Aug 2021 08:41:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org DF58360187 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=kSTNXRC8xlsQXL7DyaH2qbEOhgC+r5d11WFMZaDfxUA=; b=DPglrLgq5nI/l7 UeWHqt4cQCsxj4CxmHNmUDYNsZjVgIxFmlx1ECNYnAZk3qGju4CdOEoo82sKcT7utu44dgvo+Bt+U Hs92VSZbF2pgPOHJUkb2D43QhkXl8/e6i5r9onMss2bPuwOYCOCU3I3a5XI6meLLiYL9OySxnmdTQ LFuVJuy/yumB+zUl8IKqPR5ir2YwTkF/EFAM6jpPdmtE4e0c6hVtTY8VLguh4VvgJ3tGNX9FPE4sd ztXTGcBjE9jIErcsQGUp3U5nZweY26TjRNs6JxDzvlF3h3uJwWgJgJmgiN1uRrXuO3cLb5bP1huhV kGzQ/nzlHuVriQv9jMpQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mIoRP-005wzJ-Fx; Wed, 25 Aug 2021 08:39:23 +0000 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mIoR1-005wu4-3a; Wed, 25 Aug 2021 08:39:00 +0000 Received: by mail-pg1-x52d.google.com with SMTP id n18so22387458pgm.12; Wed, 25 Aug 2021 01:38:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=BQ5Km8P5KshreDxxyfZN+g53ic8Bq6hG2JyV+9iqoI8=; b=iFFhRGxdH+NeAiYMTNireqJG2l/UYCQOXCnjGSnQFMArA+eGw+8wfcveq4IT1WeYKO vw9beeyxSi1qsmdxVK+o1EtnDn1hsXbzej53jUICNyISg+TOszHId1hpnMAiKOQgItMN kgjGP5fOoO3lA5RtBPE+vl1CcGSFnrb5cLOFth5/THAWxRSYhSkehomdaP7hjebMYKJe jDpyYTwcHhjogeVhzTMCUj+5MehL8zyfHoPWzTruofKv/nLlfbHZD0NK9ARqn+2ivJeG iTYteEct0Urw0+NoBAS9aZ2aAcY7qfQAPGNM8D85H0lHlcUOrK9MUBD0KPuGQMd90irH 3TKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BQ5Km8P5KshreDxxyfZN+g53ic8Bq6hG2JyV+9iqoI8=; b=BY+p+bPABmW2DuiIZXs94H/wcOnj0H439jdDJJ0skEkCBkpxIAfVXI/8inGHl0p/LS e7JLBGGa08tQYpkV5Vwu7QAzh+CQ8hwDJRRthI/0yl4HfGZsJvEeu9+TdGTkbwBnC34w NrJ8r9B6qiOd+fS5FZMmvG2oLRn6Wea6j2PTu4giv2gUlappiGvIzCfi8E68O6Aw4I6U 7pr9kk0Ta9YIuW/AtHKt3GDEI6a1KmuLCCtzpgk+1VHYjNg4FYyAok/hsSTn1mdhS6my WXWGXUTy6X/YappFv3plN6Ln4/l1Nz1zOH6EzKpl1QXwzozpCpzDQ2fW1MEtYpwWux0H IL+w== X-Gm-Message-State: AOAM530gRRadQGMtEgi0BNPgEw+uXrsxUUyVxr05JopuFmwJpXHRL9jo oMhtJtj6hqJjo6iA5xdaaErMVZsg+LRchIjJ X-Google-Smtp-Source: ABdhPJxdfhF4L9hI63/ncflJW8yqJrHcIQJNGKtQAmcyZJAyAWmfBEqk0nGVgPCddFeurrjP49SaEA== X-Received: by 2002:a05:6a00:22d2:b0:3eb:b41:583 with SMTP id f18-20020a056a0022d200b003eb0b410583mr21417058pfj.73.1629880735662; Wed, 25 Aug 2021 01:38:55 -0700 (PDT) Received: from haswell-ubuntu20.lan ([138.197.212.246]) by smtp.gmail.com with ESMTPSA id p18sm24872294pgk.28.2021.08.25.01.38.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Aug 2021 01:38:55 -0700 (PDT) From: DENG Qingfang To: Sean Wang , Landen Chao , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Jakub Kicinski , Matthias Brugger , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC net-next 2/2] net: dsa: tag_mtk: handle VLAN tag insertion on TX Date: Wed, 25 Aug 2021 16:38:31 +0800 Message-Id: <20210825083832.2425886-3-dqfext@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210825083832.2425886-1-dqfext@gmail.com> References: <20210825083832.2425886-1-dqfext@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210825_013859_196113_9FD4DCF0 X-CRM114-Status: GOOD ( 14.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Advertise TX VLAN offload features, and handle VLAN tag insertion in the tag_xmit function. Signed-off-by: DENG Qingfang --- net/dsa/tag_mtk.c | 46 ++++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/net/dsa/tag_mtk.c b/net/dsa/tag_mtk.c index 415d8ece242a..e407abefa06c 100644 --- a/net/dsa/tag_mtk.c +++ b/net/dsa/tag_mtk.c @@ -22,7 +22,6 @@ static struct sk_buff *mtk_tag_xmit(struct sk_buff *skb, struct net_device *dev) { struct dsa_port *dp = dsa_slave_to_port(dev); - u8 xmit_tpid; u8 *mtk_tag; /* Build the special tag after the MAC Source Address. If VLAN header @@ -31,33 +30,31 @@ static struct sk_buff *mtk_tag_xmit(struct sk_buff *skb, * the both special and VLAN tag at the same time and then look up VLAN * table with VID. */ - switch (skb->protocol) { - case htons(ETH_P_8021Q): - xmit_tpid = MTK_HDR_XMIT_TAGGED_TPID_8100; - break; - case htons(ETH_P_8021AD): - xmit_tpid = MTK_HDR_XMIT_TAGGED_TPID_88A8; - break; - default: - xmit_tpid = MTK_HDR_XMIT_UNTAGGED; - skb_push(skb, MTK_HDR_LEN); - dsa_alloc_etype_header(skb, MTK_HDR_LEN); - } - + skb_push(skb, MTK_HDR_LEN); + dsa_alloc_etype_header(skb, MTK_HDR_LEN); mtk_tag = dsa_etype_header_pos_tx(skb); - /* Mark tag attribute on special tag insertion to notify hardware - * whether that's a combined special tag with 802.1Q header. - */ - mtk_tag[0] = xmit_tpid; - mtk_tag[1] = (1 << dp->index) & MTK_HDR_XMIT_DP_BIT_MASK; - - /* Tag control information is kept for 802.1Q */ - if (xmit_tpid == MTK_HDR_XMIT_UNTAGGED) { - mtk_tag[2] = 0; - mtk_tag[3] = 0; + if (skb_vlan_tag_present(skb)) { + switch (skb->vlan_proto) { + case htons(ETH_P_8021Q): + mtk_tag[0] = MTK_HDR_XMIT_TAGGED_TPID_8100; + break; + case htons(ETH_P_8021AD): + mtk_tag[0] = MTK_HDR_XMIT_TAGGED_TPID_88A8; + break; + default: + return NULL; + } + + ((__be16 *)mtk_tag)[1] = htons(skb_vlan_tag_get(skb)); + __vlan_hwaccel_clear_tag(skb); + } else { + mtk_tag[0] = MTK_HDR_XMIT_UNTAGGED; + ((__be16 *)mtk_tag)[1] = 0; } + mtk_tag[1] = (1 << dp->index) & MTK_HDR_XMIT_DP_BIT_MASK; + return skb; } @@ -96,6 +93,7 @@ static const struct dsa_device_ops mtk_netdev_ops = { .xmit = mtk_tag_xmit, .rcv = mtk_tag_rcv, .needed_headroom = MTK_HDR_LEN, + .features = NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_STAG_TX, }; MODULE_LICENSE("GPL");