Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp3762076rwi; Wed, 12 Oct 2022 06:31:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6aafqSQwaLJgrqbfL2gzdoMlq63F6FVnQV7pc6vlaMe8WGZcPal7Ky0fVDDBfNLiHP5v0r X-Received: by 2002:a63:4e5a:0:b0:438:9513:da55 with SMTP id o26-20020a634e5a000000b004389513da55mr25147947pgl.381.1665581462208; Wed, 12 Oct 2022 06:31:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665581462; cv=none; d=google.com; s=arc-20160816; b=WlaMKMmTbFA2zplH4I6bjwaxvlyC8QzSVAkfUx06pscITz3drikQIeqAHHjSM60Ruh TnfNcAolWd5spW6v5Goy0BB/WZTS4owdQITF/q37I0ojD8mxGNhWHuIvYZWUXJ3xVhF1 xwxDZEFQikTxjvhuQxRTuBgv+7Pz0NWuMD4IZ4UJazeJXA8ncRyDCVZZeFvMeW/ygLjF rMvfnMipwm8kIZN9zuT9KGM0oHXM2yfgsGf4pgjdsjvNJZ7ZD5d70KaG/J6UTJAlD9g6 32Zh+ie4lBJxjLHGUibQEksHudC4CdbHXgb3IU2GkhFpBQYXOhGzRmw7tRn2qein/W09 zmQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ZDOHsKJ2O6yHB6mK3GypL2lDL6oF4YLtssKIorMpkUY=; b=LhfYqdG71lzZtvebtKvcJ2EuJ/ufR9IJVG9qCaN0MudwC7aijjz+mR2Q6zo2PMbCPR OweaOYL0I8h07bMWCXWkswlgsdkiU0cO8XMTZq/XdAmHmZYIB3+ewh4d/1nxfiz0CLeW bVsg7B8Jlf93jweBVmn+4hn2y7OYBDKfLEHbpn7DYwtUS08m3vlAb57yDztirZDRs6yv 3G3ihijcZYn+46XR4MikJrFrDyxBhWMottvALNMHshoRCAINFe6iTARh5Fd1hJpmElp8 T5xLN801jmGKr66qDg/QcnY8gRgiuZdvlzHRFB86Kmk8IInvghPDTX9Itse/qDVDGiCe xdyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=tAqLQQXt; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m5-20020a170902db0500b00176939b5cd9si21991988plx.578.2022.10.12.06.30.47; Wed, 12 Oct 2022 06:31:02 -0700 (PDT) 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=@lunn.ch header.s=20171124 header.b=tAqLQQXt; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229930AbiJLMmc (ORCPT + 99 others); Wed, 12 Oct 2022 08:42:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229895AbiJLMmZ (ORCPT ); Wed, 12 Oct 2022 08:42:25 -0400 Received: from vps0.lunn.ch (vps0.lunn.ch [185.16.172.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB66FC894F; Wed, 12 Oct 2022 05:42:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=ZDOHsKJ2O6yHB6mK3GypL2lDL6oF4YLtssKIorMpkUY=; b=tAqLQQXtGcqUKQQMcUwu8J+DSU B93WVo9Tk9gbUZ6kMdj96CQpCUS1Ch0PBf39+r8kZLeBETTJmgN3hiz1qswvSttsk1PYk3wlMnyJt +0uA5s6JUmiBDfgGJhZNmho2YqSK3DM1jZsj6dgjO2fgwfKgLzO80503Eq07DYTm/AOM=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1oib3w-001nlI-Co; Wed, 12 Oct 2022 14:42:16 +0200 Date: Wed, 12 Oct 2022 14:42:16 +0200 From: Andrew Lunn To: Christian Marangi Cc: Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "Russell King (Oracle)" , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Pawel Dembicki , Lech Perczak Subject: Re: [net PATCH 1/2] net: dsa: qca8k: fix inband mgmt for big-endian systems Message-ID: References: <20221010111459.18958-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221010111459.18958-1-ansuelsmth@gmail.com> 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_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 On Mon, Oct 10, 2022 at 01:14:58PM +0200, Christian Marangi wrote: > The header and the data of the skb for the inband mgmt requires > to be in little-endian. This is problematic for big-endian system > as the mgmt header is written in the cpu byte order. > > Fix this by converting each value for the mgmt header and data to > little-endian, and convert to cpu byte order the mgmt header and > data sent by the switch. > > Fixes: 5950c7c0a68c ("net: dsa: qca8k: add support for mgmt read/write in Ethernet packet") > Tested-by: Pawel Dembicki > Tested-by: Lech Perczak > Signed-off-by: Christian Marangi > Reviewed-by: Lech Perczak > --- > drivers/net/dsa/qca/qca8k-8xxx.c | 63 ++++++++++++++++++++++++-------- > include/linux/dsa/tag_qca.h | 6 +-- > 2 files changed, 50 insertions(+), 19 deletions(-) > > diff --git a/drivers/net/dsa/qca/qca8k-8xxx.c b/drivers/net/dsa/qca/qca8k-8xxx.c > index 5669c92c93f7..4bb9b7eac68b 100644 > --- a/drivers/net/dsa/qca/qca8k-8xxx.c > +++ b/drivers/net/dsa/qca/qca8k-8xxx.c > @@ -137,27 +137,42 @@ static void qca8k_rw_reg_ack_handler(struct dsa_switch *ds, struct sk_buff *skb) > struct qca8k_mgmt_eth_data *mgmt_eth_data; > struct qca8k_priv *priv = ds->priv; > struct qca_mgmt_ethhdr *mgmt_ethhdr; > + u32 command; > u8 len, cmd; > + int i; > > mgmt_ethhdr = (struct qca_mgmt_ethhdr *)skb_mac_header(skb); > mgmt_eth_data = &priv->mgmt_eth_data; > > - cmd = FIELD_GET(QCA_HDR_MGMT_CMD, mgmt_ethhdr->command); > - len = FIELD_GET(QCA_HDR_MGMT_LENGTH, mgmt_ethhdr->command); > + command = le32_to_cpu(mgmt_ethhdr->command); > + cmd = FIELD_GET(QCA_HDR_MGMT_CMD, command); > + len = FIELD_GET(QCA_HDR_MGMT_LENGTH, command); Humm... This might have the same alignment issue as the second patch. In fact, because the Ethernet header is 14 bytes in size, it is often deliberately out of alignment by 2 bytes, so that the IP header is aligned. You should probably be using get_unaligned_le32() when accessing members of mgmt_ethhdr. Andrew