Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp668419pxb; Thu, 21 Apr 2022 07:57:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy3wxPbZIYpA4AZYXQnLtG4DNEOxeqj6oYBcIqpfo9C9K4OQwyFeNvHdO/QMaGTk90PDdeU X-Received: by 2002:a50:c099:0:b0:415:f5c7:700e with SMTP id k25-20020a50c099000000b00415f5c7700emr29338714edf.205.1650553027985; Thu, 21 Apr 2022 07:57:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650553027; cv=none; d=google.com; s=arc-20160816; b=gKxOWBaJE6/uEje8ZnPlb7PLDeXLVrP+NVaXiNBQPoc6BeMGvOOqYaAJp5W2HpJa+H bLMD+7PwalIrO1Z50NIN5xhbMS96ML4dL2FbTJAlZEATapG3i07s0H6jml4XBmC+JLAf k6fZic4wbBebrE3UAV/3ybLaJ2qta6cFLUWd5lIlFPLr/ySviuNqhMoU7KinzjkEXdcM bQN5A2hL5vm+6/sjma68DDjs0Zqt+WycS93X8n3iWRdm4Fyz8nnJLJ7GRh3jWskbiQs3 3cb0K7e0yxxmnIWAQSMMCphbEJzgcSCF+SKyHszI580ZP6FACgxGXcUOdCgZJXA23sE1 eIrw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=B/s0SnFQ5orrBW408dZM26QatHTbavJSKzVGf7XbXYI=; b=GVGdOhEHzi+rGTYFpUd0lrHvv3IfWmj6s19O6YzJqS4EoDqUc1+pWwybJu3TT0jGHg V9keHvOYw8e1r/j4GdZ1uN+H3rwe9CLA/u0xsNEwl0RWapJ7ZZ0WRildynU+1+tvL5TX VQ4S0XQQYJfLdVxxAQxMUCEtdx2U+bPGD5Z2HGxTbNFGgpmXfy77qrORML15mAD7Nert ZIR0fmzLFHyo6MDWPLzxcnI1+WIKV6e6E0xvALgVkvNo1R/dSzOfqSEcgpgdC4KwVwbL TbUufMb1dEGRnNiVp9zDtdNekhF6hsClQu0J9uPI8jHdwK1wrQpy5SppBZwxsiLXCLca 7iMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=s+47WS95; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pk15-20020a170906d7af00b006e8c7f61858si4302556ejb.315.2022.04.21.07.56.45; Thu, 21 Apr 2022 07:57:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-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=fail header.i=@nbd.name header.s=20160729 header.b=s+47WS95; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354489AbiDTMgD (ORCPT + 66 others); Wed, 20 Apr 2022 08:36:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354491AbiDTMgC (ORCPT ); Wed, 20 Apr 2022 08:36:02 -0400 Received: from nbd.name (nbd.name [IPv6:2a01:4f8:221:3d45::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E7FB3FDB9 for ; Wed, 20 Apr 2022 05:33:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-Id :Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=B/s0SnFQ5orrBW408dZM26QatHTbavJSKzVGf7XbXYI=; b=s+47WS95AmMQu9zQcgxn/jsel5 sf/B365b5zan5rB7rhfAnftqzvcJNDIB8J32k075i05NzbXt3ZPybicTkHDGsgS2BbmFpoNfKIUiO ikWLKXtwrbnL0hzWCgLQHOJGsqbHoGzXCsF23r2v801vpkdk+lO1/4O7w7WgUZTd186k=; Received: from p200300daa70ef200009e86881025829d.dip0.t-ipconnect.de ([2003:da:a70e:f200:9e:8688:1025:829d] helo=localhost.localdomain) by ds12 with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1nh9WF-0000rJ-3V; Wed, 20 Apr 2022 14:33:15 +0200 From: Felix Fietkau To: linux-wireless@vger.kernel.org Cc: =?UTF-8?q?Thibaut=20VAR=C3=88NE?= Subject: [PATCH] mt76: fix encap offload ethernet type check Date: Wed, 20 Apr 2022 14:33:08 +0200 Message-Id: <20220420123308.70104-1-nbd@nbd.name> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE 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-wireless@vger.kernel.org The driver needs to check if the format is 802.2 vs 802.3 in order to set a tx descriptor flag. skb->protocol can't be used, since it may not be properly initialized for packets coming in from a packet socket. Fix misdetection by checking the ethertype from the skb data instead Reported-by: Thibaut VARĂˆNE Signed-off-by: Felix Fietkau --- drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 4 +++- drivers/net/wireless/mediatek/mt76/mt7921/mac.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c index 5f4a0e811137..e353e8c44d6c 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c @@ -1016,6 +1016,7 @@ mt7915_mac_write_txwi_8023(struct mt7915_dev *dev, __le32 *txwi, u8 tid = skb->priority & IEEE80211_QOS_CTL_TID_MASK; u8 fc_type, fc_stype; + u16 ethertype; bool wmm = false; u32 val; @@ -1029,7 +1030,8 @@ mt7915_mac_write_txwi_8023(struct mt7915_dev *dev, __le32 *txwi, val = FIELD_PREP(MT_TXD1_HDR_FORMAT, MT_HDR_FORMAT_802_3) | FIELD_PREP(MT_TXD1_TID, tid); - if (be16_to_cpu(skb->protocol) >= ETH_P_802_3_MIN) + ethertype = get_unaligned_be16(&skb->data[12]); + if (ethertype >= ETH_P_802_3_MIN) val |= MT_TXD1_ETH_802_3; txwi[1] |= cpu_to_le32(val); diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c index 368e54c53ddd..ac11e8b28f13 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c @@ -814,6 +814,7 @@ mt7921_mac_write_txwi_8023(struct mt7921_dev *dev, __le32 *txwi, { u8 tid = skb->priority & IEEE80211_QOS_CTL_TID_MASK; u8 fc_type, fc_stype; + u16 ethertype; bool wmm = false; u32 val; @@ -827,7 +828,8 @@ mt7921_mac_write_txwi_8023(struct mt7921_dev *dev, __le32 *txwi, val = FIELD_PREP(MT_TXD1_HDR_FORMAT, MT_HDR_FORMAT_802_3) | FIELD_PREP(MT_TXD1_TID, tid); - if (be16_to_cpu(skb->protocol) >= ETH_P_802_3_MIN) + ethertype = get_unaligned_be16(&skb->data[12]); + if (ethertype >= ETH_P_802_3_MIN) val |= MT_TXD1_ETH_802_3; txwi[1] |= cpu_to_le32(val); -- 2.35.1