* [PATCH] net: ethernet: mtk_eth_soc: use be32 type to store be32 values
@ 2023-04-01 6:43 Simon Horman
2023-04-01 7:31 ` Simon Horman
2023-04-01 15:55 ` Andrew Lunn
0 siblings, 2 replies; 4+ messages in thread
From: Simon Horman @ 2023-04-01 6:43 UTC (permalink / raw)
To: Jakub Kicinski, David S. Miller, Eric Dumazet, Paolo Abeni
Cc: Felix Fietkau, John Crispin, Sean Wang, Mark Lee,
Lorenzo Bianconi, Matthias Brugger, AngeloGioacchino Del Regno,
netdev, linux-kernel, linux-arm-kernel, linux-mediatek
Perhaps there is a nicer way to handle this but the code
calls for converting an array of host byte order 32bit values
to big endian 32bit values: an ipv6 address to be pretty printed.
Use a sparse-friendly array of be32 to store these values.
Also make use of the cpu_to_be32_array helper rather
than open coding the conversion.
Flagged by sparse:
drivers/net/ethernet/mediatek/mtk_ppe_debugfs.c:59:27: warning: incorrect type in assignment (different base types)
drivers/net/ethernet/mediatek/mtk_ppe_debugfs.c:59:27: expected unsigned int
drivers/net/ethernet/mediatek/mtk_ppe_debugfs.c:59:27: got restricted __be32 [usertype]
drivers/net/ethernet/mediatek/mtk_ppe_debugfs.c:161:46: warning: cast to restricted __be16
No functional changes intended.
Compile tested only.
Signed-off-by: Simon Horman <horms@kernel.org>
---
drivers/net/ethernet/mediatek/mtk_ppe_debugfs.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/mediatek/mtk_ppe_debugfs.c b/drivers/net/ethernet/mediatek/mtk_ppe_debugfs.c
index 53cf87e9acbb..1e0bb8cee7c4 100644
--- a/drivers/net/ethernet/mediatek/mtk_ppe_debugfs.c
+++ b/drivers/net/ethernet/mediatek/mtk_ppe_debugfs.c
@@ -47,16 +47,14 @@ static const char *mtk_foe_pkt_type_str(int type)
static void
mtk_print_addr(struct seq_file *m, u32 *addr, bool ipv6)
{
- u32 n_addr[4];
- int i;
+ __be32 n_addr[4];
if (!ipv6) {
seq_printf(m, "%pI4h", addr);
return;
}
- for (i = 0; i < ARRAY_SIZE(n_addr); i++)
- n_addr[i] = htonl(addr[i]);
+ cpu_to_be32_array(n_addr, addr, 4);
seq_printf(m, "%pI6", n_addr);
}
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] net: ethernet: mtk_eth_soc: use be32 type to store be32 values
2023-04-01 6:43 [PATCH] net: ethernet: mtk_eth_soc: use be32 type to store be32 values Simon Horman
@ 2023-04-01 7:31 ` Simon Horman
2023-04-01 15:55 ` Andrew Lunn
1 sibling, 0 replies; 4+ messages in thread
From: Simon Horman @ 2023-04-01 7:31 UTC (permalink / raw)
To: Jakub Kicinski, David S. Miller, Eric Dumazet, Paolo Abeni
Cc: Felix Fietkau, John Crispin, Sean Wang, Mark Lee,
Lorenzo Bianconi, Matthias Brugger, AngeloGioacchino Del Regno,
netdev, linux-kernel, linux-arm-kernel, linux-mediatek
On Sat, Apr 01, 2023 at 08:43:44AM +0200, Simon Horman wrote:
> Perhaps there is a nicer way to handle this but the code
> calls for converting an array of host byte order 32bit values
> to big endian 32bit values: an ipv6 address to be pretty printed.
>
> Use a sparse-friendly array of be32 to store these values.
>
> Also make use of the cpu_to_be32_array helper rather
> than open coding the conversion.
>
> Flagged by sparse:
> drivers/net/ethernet/mediatek/mtk_ppe_debugfs.c:59:27: warning: incorrect type in assignment (different base types)
> drivers/net/ethernet/mediatek/mtk_ppe_debugfs.c:59:27: expected unsigned int
> drivers/net/ethernet/mediatek/mtk_ppe_debugfs.c:59:27: got restricted __be32 [usertype]
> drivers/net/ethernet/mediatek/mtk_ppe_debugfs.c:161:46: warning: cast to restricted __be16
>
> No functional changes intended.
> Compile tested only.
>
> Signed-off-by: Simon Horman <horms@kernel.org>
Sorry, I forgot to tag this for net-next.
I can repost if needed, after an appropriate pause.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] net: ethernet: mtk_eth_soc: use be32 type to store be32 values
2023-04-01 6:43 [PATCH] net: ethernet: mtk_eth_soc: use be32 type to store be32 values Simon Horman
2023-04-01 7:31 ` Simon Horman
@ 2023-04-01 15:55 ` Andrew Lunn
2023-04-03 12:52 ` Simon Horman
1 sibling, 1 reply; 4+ messages in thread
From: Andrew Lunn @ 2023-04-01 15:55 UTC (permalink / raw)
To: Simon Horman
Cc: Jakub Kicinski, David S. Miller, Eric Dumazet, Paolo Abeni,
Felix Fietkau, John Crispin, Sean Wang, Mark Lee,
Lorenzo Bianconi, Matthias Brugger, AngeloGioacchino Del Regno,
netdev, linux-kernel, linux-arm-kernel, linux-mediatek
On Sat, Apr 01, 2023 at 08:43:44AM +0200, Simon Horman wrote:
> Perhaps there is a nicer way to handle this but the code
> calls for converting an array of host byte order 32bit values
> to big endian 32bit values: an ipv6 address to be pretty printed.
Hi Simon
Maybe make a generic helper? I could be used in other places, e.g:
https://elixir.bootlin.com/linux/latest/source/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c#L6773
Andrew
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] net: ethernet: mtk_eth_soc: use be32 type to store be32 values
2023-04-01 15:55 ` Andrew Lunn
@ 2023-04-03 12:52 ` Simon Horman
0 siblings, 0 replies; 4+ messages in thread
From: Simon Horman @ 2023-04-03 12:52 UTC (permalink / raw)
To: Andrew Lunn
Cc: Jakub Kicinski, David S. Miller, Eric Dumazet, Paolo Abeni,
Felix Fietkau, John Crispin, Sean Wang, Mark Lee,
Lorenzo Bianconi, Matthias Brugger, AngeloGioacchino Del Regno,
netdev, linux-kernel, linux-arm-kernel, linux-mediatek
On Sat, Apr 01, 2023 at 05:55:35PM +0200, Andrew Lunn wrote:
> On Sat, Apr 01, 2023 at 08:43:44AM +0200, Simon Horman wrote:
> > Perhaps there is a nicer way to handle this but the code
> > calls for converting an array of host byte order 32bit values
> > to big endian 32bit values: an ipv6 address to be pretty printed.
>
> Hi Simon
>
> Maybe make a generic helper? I could be used in other places, e.g:
>
> https://elixir.bootlin.com/linux/latest/source/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c#L6773
Hi Andrew,
do you mean something like this?
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index 7332296eca44..cff6c1177502 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -935,6 +935,11 @@ static inline void iph_to_flow_copy_v6addrs(struct flow_keys *flow,
flow->control.addr_type = FLOW_DISSECTOR_KEY_IPV6_ADDRS;
}
+static inline void ipv6_addr_cpu_to_be32(__be32 *dst, const u32 *src)
+{
+ cpu_to_be32_array(dst, src, 4);
+}
+
#if IS_ENABLED(CONFIG_IPV6)
static inline bool ipv6_can_nonlocal_bind(struct net *net,
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-04-03 12:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-01 6:43 [PATCH] net: ethernet: mtk_eth_soc: use be32 type to store be32 values Simon Horman
2023-04-01 7:31 ` Simon Horman
2023-04-01 15:55 ` Andrew Lunn
2023-04-03 12:52 ` Simon Horman
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).