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 1/2] net: dsa: qca8k: fix inband mgmt for big-endian systems
Date: Wed, 12 Oct 2022 14:42:16 +0200 [thread overview]
Message-ID: <Y0a2KD9pVeoYkHkK@lunn.ch> (raw)
In-Reply-To: <20221010111459.18958-1-ansuelsmth@gmail.com>
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 <paweldembicki@gmail.com>
> Tested-by: Lech Perczak <lech.perczak@gmail.com>
> Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
> Reviewed-by: Lech Perczak <lech.perczak@gmail.com>
> ---
> 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
next prev parent reply other threads:[~2022-10-12 12:42 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
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 [this message]
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=Y0a2KD9pVeoYkHkK@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).