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: 12456737 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 4BF2DC4338F for ; Wed, 25 Aug 2021 08:39:44 +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 0BD4561181 for ; Wed, 25 Aug 2021 08:39:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0BD4561181 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=dFvPdP2AGZC4OvjcumMehDJH2xwFSdfTwF0yry+EtjE=; b=3qZKsvs2nqG9qJ mjU05WYryNYgUeUEFQGgrtwcr4cE8HL9Aam6A5Z0ahLjsa6sJ2kZibA0fWzWbuLsfFn1wRjhSw4NV otIZ5yqMfsLEPX2VTF39lcW0pjVU0i9Zu2wXWg06hzOfq9WEvI4E/Yg05MZZJ122gxZY+u5mqHmAX iIq9qjt1JJJ0tctmg91d2o56uiFUxoVMqQta4qGaR2VWPTfY96OxaQczGGdJDdKJq5uF0dOei3YwO gYcuPWx0680fsQfDTodOd3hF64bFlGIBScOHnhQGj9L8K0KqDsAQtwnx1C9nSW3tNJsU1BvenAXOR Y33h3B5YIFE6e1KTxDOA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mIoRZ-005x2S-9s; Wed, 25 Aug 2021 08:39:33 +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-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=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: 12456739 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 CBFFAC4338F for ; Wed, 25 Aug 2021 08:39:47 +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 83CA861181 for ; Wed, 25 Aug 2021 08:39:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 83CA861181 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=K5C35oVHgSfyZSDH1m9jatXX5lFaFiyUCtaMIFW+gDU=; b=mQYthtQwSiaDKV TWtifgTAa68zteslbRTcV1kF6vgT8tjS8jcVaYdaHgeQbbPZWMUlq+6oWMevLbp6LI8F0Lq7WLJn1 DZZqX/q+In73RY3IhuUpA+7IZS5SGNvQqBSqy9vA26pvXFFM7Xu4wz96Q7zxTZJtyCVi5+bUiavMa MgT7gJ8p3zAmUiQ1AUt8mUpVMm0MF3frtmSBM9uWIK8yhsXbwgFmNN23lZtimbY78El8rFYjc518v FlSFhQD+ZnptyCpDFgYs6mObuNi/elVcjh0oaOXu8f05ENk/4/S+AowzqsrjCeFIjbs2VBDjJzoSv CGKShtCsuts0VXNTp+WA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mIoRa-005x2j-7j; Wed, 25 Aug 2021 08:39:34 +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-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=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");