From: Andrew Lunn <andrew@lunn.ch>
To: Christian Marangi <ansuelsmth@gmail.com>
Cc: Vivien Didelot <vivien.didelot@gmail.com>,
Florian Fainelli <f.fainelli@gmail.com>,
Vladimir Oltean <olteanv@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
"Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Pawel Dembicki <paweldembicki@gmail.com>,
Lech Perczak <lech.perczak@gmail.com>
Subject: Re: [net PATCH 2/2] net: dsa: qca8k: fix ethtool autocast mib for big-endian systems
Date: Wed, 12 Oct 2022 14:37:34 +0200 [thread overview]
Message-ID: <Y0a1Ditnr/ekKR39@lunn.ch> (raw)
In-Reply-To: <20221010111459.18958-2-ansuelsmth@gmail.com>
> 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
next prev parent reply other threads:[~2022-10-12 12:37 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-10 11:14 [net PATCH 1/2] net: dsa: qca8k: fix inband mgmt for big-endian systems Christian Marangi
2022-10-10 11:14 ` [net PATCH 2/2] net: dsa: qca8k: fix ethtool autocast mib " Christian Marangi
2022-10-12 12:37 ` Andrew Lunn [this message]
2022-10-10 18:53 ` [net PATCH 1/2] net: dsa: qca8k: fix inband mgmt " Andrew Lunn
2022-10-10 12:44 ` Christian Marangi
2022-10-12 7:24 ` Vladimir Oltean
2022-10-12 12:24 ` Christian Marangi
2022-10-12 12:29 ` Andrew Lunn
2022-10-12 12:34 ` Christian Marangi
2022-10-12 7:27 ` Vladimir Oltean
2022-10-12 12:26 ` Christian Marangi
2022-10-12 12:31 ` Andrew Lunn
2022-10-12 12:42 ` Andrew Lunn
2022-10-12 12:54 ` Christian Marangi
2022-10-12 12:59 ` Christian Marangi
2022-10-12 13:31 ` Vladimir Oltean
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y0a1Ditnr/ekKR39@lunn.ch \
--to=andrew@lunn.ch \
--cc=ansuelsmth@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=kuba@kernel.org \
--cc=lech.perczak@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=paweldembicki@gmail.com \
--cc=rmk+kernel@armlinux.org.uk \
--cc=vivien.didelot@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).