Commit 0d4636f7 authored by Christian Marangi's avatar Christian Marangi Committed by David S. Miller

net: dsa: qca8k: fix ethtool autocast mib for big-endian systems

The switch sends autocast mib in little-endian. This is problematic for
big-endian system as the values needs to be converted.

Fix this by converting each mib value to cpu byte order.

Fixes: 5c957c7c ("net: dsa: qca8k: add support for mib autocast in Ethernet packet")
Tested-by: default avatarPawel Dembicki <paweldembicki@gmail.com>
Tested-by: default avatarLech Perczak <lech.perczak@gmail.com>
Signed-off-by: default avatarChristian Marangi <ansuelsmth@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a2550d3c
...@@ -1518,9 +1518,9 @@ static void qca8k_mib_autocast_handler(struct dsa_switch *ds, struct sk_buff *sk ...@@ -1518,9 +1518,9 @@ static void qca8k_mib_autocast_handler(struct dsa_switch *ds, struct sk_buff *sk
struct qca8k_priv *priv = ds->priv; struct qca8k_priv *priv = ds->priv;
const struct qca8k_mib_desc *mib; const struct qca8k_mib_desc *mib;
struct mib_ethhdr *mib_ethhdr; struct mib_ethhdr *mib_ethhdr;
int i, mib_len, offset = 0; __le32 *data2;
u64 *data;
u8 port; u8 port;
int i;
mib_ethhdr = (struct mib_ethhdr *)skb_mac_header(skb); mib_ethhdr = (struct mib_ethhdr *)skb_mac_header(skb);
mib_eth_data = &priv->mib_eth_data; 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 ...@@ -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) if (port != mib_eth_data->req_port)
goto exit; goto exit;
data = mib_eth_data->data; data2 = (__le32 *)skb->data;
for (i = 0; i < priv->info->mib_count; i++) { for (i = 0; i < priv->info->mib_count; i++) {
mib = &ar8327_mib[i]; mib = &ar8327_mib[i];
/* First 3 mib are present in the skb head */ /* First 3 mib are present in the skb head */
if (i < 3) { if (i < 3) {
data[i] = mib_ethhdr->data[i]; mib_eth_data->data[i] = get_unaligned_le32(mib_ethhdr->data + i);
continue; continue;
} }
mib_len = sizeof(uint32_t);
/* Some mib are 64 bit wide */ /* Some mib are 64 bit wide */
if (mib->size == 2) if (mib->size == 2)
mib_len = sizeof(uint64_t); mib_eth_data->data[i] = get_unaligned_le64((__le64 *)data2);
else
/* Copy the mib value from packet to the */ mib_eth_data->data[i] = get_unaligned_le32(data2);
memcpy(data + i, skb->data + offset, mib_len);
/* Set the offset for the next mib */ data2 += mib->size;
offset += mib_len;
} }
exit: exit:
......
...@@ -73,7 +73,7 @@ enum mdio_cmd { ...@@ -73,7 +73,7 @@ enum mdio_cmd {
}; };
struct mib_ethhdr { struct mib_ethhdr {
u32 data[3]; /* first 3 mib counter */ __le32 data[3]; /* first 3 mib counter */
__be16 hdr; /* qca hdr */ __be16 hdr; /* qca hdr */
} __packed; } __packed;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment