Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp3705201rwi; Wed, 12 Oct 2022 05:54:21 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5noE+sceKzVSUK0o1zpuRZMSMhNcHfO9SuKzkEk4+75kBMG55dDH2Qg3IEEmQvlFcMpEXM X-Received: by 2002:a05:6402:190f:b0:45b:d959:e2ae with SMTP id e15-20020a056402190f00b0045bd959e2aemr19530575edz.187.1665579261403; Wed, 12 Oct 2022 05:54:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665579261; cv=none; d=google.com; s=arc-20160816; b=tMwR/CggZb4VHFbDov127GhIW2oIyxg0jBIItuuNnkT0JL++2catpf7g7902MMZASU 27RR2M2PPbbEcrr+C2hWLPalV2BiOEIo7wasx2qFTTvhMmvHpQEsgsgTmVOmd6IoXJ5x NfIWBccmVNtDpLY50sk/70rJidlsI8Is68haXLqoRz+4B6atKcfUoWZAhqLSqL46aVXt D0HGvmlhSVrU45vHYR2CRdt/79gV6pzzVQJ+CChsVWk/LVPvRy9WD/42a0g2jVL/HmVv D5BqiD3YRqrIFpTA1aapDCNeEW9cXwAfXbq/owjglYQnmyqo8mC5i01b3QnmTcawSwtG VkSQ== 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=JWy5RQWI5KogxEJb2DRzy4LpyNy0j033+Jo3GVosbOA=; b=gIA/5GsXw5Gj1PBcuVHwfrTwSFHfnIxcftC8lwJ7gCkrAlWGypHnrpYeeGruMbQUc1 XqocRx3hVLXQFUl63x/RkSoLr7Qo/bOMUeIglu139zoilwJsv3yU7WxsZIzG9WpBySsM CInumfcEWXrEICdIdBTuLCUCgMMCMVYdtOs8sR7Njfn4Gq2q2eB3dESJxBlGlThJ/hpv Q6xeXw1omkhuUH2O58HKHk3J4F5cZTZUktjSq+lgK12gn21p5ElqiAsTsnjJbpPkm9cE QdUYqd7dFi1FuNMRZXybsZxgbKSpg5DG8Nv525rVMsdsIowc4cKEP7iwEI8KTU6W05Yp oRag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=Fv134si1; 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 hp35-20020a1709073e2300b0073d626e2ef8si19262195ejc.461.2022.10.12.05.53.56; Wed, 12 Oct 2022 05:54:21 -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=Fv134si1; 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 S229892AbiJLMhx (ORCPT + 99 others); Wed, 12 Oct 2022 08:37:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229884AbiJLMht (ORCPT ); Wed, 12 Oct 2022 08:37:49 -0400 Received: from vps0.lunn.ch (vps0.lunn.ch [185.16.172.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C66C2C707B; Wed, 12 Oct 2022 05:37:42 -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=JWy5RQWI5KogxEJb2DRzy4LpyNy0j033+Jo3GVosbOA=; b=Fv134si1BGJlyz8/5vUhVpOeHt JGZxF13SrLBknVXU4cPUZV8ynsEWqL0qnDm3KAgqOfYTJck4Mmq3Pdm/+nPsH2q23JRtCZoMm4411 5LHiCQDf5PZOY7IMqEk2DFRRtuhwHkLp+yTeixw+IYp0HEl3omiw2fOMHHGSCtxQhSr4=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1oiazO-001njB-Aj; Wed, 12 Oct 2022 14:37:34 +0200 Date: Wed, 12 Oct 2022 14:37:34 +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 2/2] net: dsa: qca8k: fix ethtool autocast mib for big-endian systems Message-ID: References: <20221010111459.18958-1-ansuelsmth@gmail.com> <20221010111459.18958-2-ansuelsmth@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221010111459.18958-2-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 > struct qca8k_priv *priv = ds->priv; > const struct qca8k_mib_desc *mib; > struct mib_ethhdr *mib_ethhdr; > - int i, mib_len, offset = 0; > - u64 *data; > + __le32 *data2; > u8 port; > + int i; > > mib_ethhdr = (struct mib_ethhdr *)skb_mac_header(skb); > mib_eth_data = &priv->mib_eth_data; > @@ -1532,28 +1532,24 @@ static void qca8k_mib_autocast_handler(struct dsa_switch *ds, struct sk_buff *sk > if (port != mib_eth_data->req_port) > goto exit; > > - data = mib_eth_data->data; > + data2 = (__le32 *)skb->data; > > for (i = 0; i < priv->info->mib_count; i++) { > mib = &ar8327_mib[i]; > > /* First 3 mib are present in the skb head */ > if (i < 3) { > - data[i] = mib_ethhdr->data[i]; > + mib_eth_data->data[i] = le32_to_cpu(mib_ethhdr->data[i]); > continue; > } > > - mib_len = sizeof(uint32_t); > - > /* Some mib are 64 bit wide */ > if (mib->size == 2) > - mib_len = sizeof(uint64_t); > - > - /* Copy the mib value from packet to the */ > - memcpy(data + i, skb->data + offset, mib_len); > + mib_eth_data->data[i] = le64_to_cpu(*(__le64 *)data2); > + else > + mib_eth_data->data[i] = le32_to_cpu(*data2); Are there any alignment guarantees? The old memcpy did not care if the source has oddly alignment. But when you start dereferencing a pointed, you need to be sure those pointers are aligned. You might want to use get_unaligned_le32 and get_unaligned_le64. Andrew