* [PATCH] mac802154_hwsim: define perm_extended_addr initialization
@ 2025-03-25 16:53 Ramon Fontes
2025-03-26 10:12 ` Miquel Raynal
0 siblings, 1 reply; 9+ messages in thread
From: Ramon Fontes @ 2025-03-25 16:53 UTC (permalink / raw)
To: davem, kuba, pabeni
Cc: linux-wpan, alex.aring, miquel.raynal, netdev, Ramon Fontes
This establishes an initialization method for perm_extended_addr, aligning it with the approach used in mac80211_hwsim.
Signed-off-by: Ramon Fontes <ramonreisfontes@gmail.com>
---
drivers/net/ieee802154/mac802154_hwsim.c | 18 +++++++++++++++++-
drivers/net/ieee802154/mac802154_hwsim.h | 2 ++
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ieee802154/mac802154_hwsim.c b/drivers/net/ieee802154/mac802154_hwsim.c
index 1cab20b5a..400cdac1f 100644
--- a/drivers/net/ieee802154/mac802154_hwsim.c
+++ b/drivers/net/ieee802154/mac802154_hwsim.c
@@ -41,6 +41,17 @@ enum hwsim_multicast_groups {
HWSIM_MCGRP_CONFIG,
};
+__le64 addr_to_le64(u8 *addr) {
+ return cpu_to_le64(((u64)addr[0] << 56) |
+ ((u64)addr[1] << 48) |
+ ((u64)addr[2] << 40) |
+ ((u64)addr[3] << 32) |
+ ((u64)addr[4] << 24) |
+ ((u64)addr[5] << 16) |
+ ((u64)addr[6] << 8) |
+ ((u64)addr[7]));
+}
+
static const struct genl_multicast_group hwsim_mcgrps[] = {
[HWSIM_MCGRP_CONFIG] = { .name = "config", },
};
@@ -896,6 +907,7 @@ static int hwsim_subscribe_all_others(struct hwsim_phy *phy)
static int hwsim_add_one(struct genl_info *info, struct device *dev,
bool init)
{
+ u8 addr[8];
struct ieee802154_hw *hw;
struct hwsim_phy *phy;
struct hwsim_pib *pib;
@@ -942,7 +954,11 @@ static int hwsim_add_one(struct genl_info *info, struct device *dev,
/* 950 MHz GFSK 802.15.4d-2009 */
hw->phy->supported.channels[6] |= 0x3ffc00;
- ieee802154_random_extended_addr(&hw->phy->perm_extended_addr);
+ memset(addr, 0, sizeof(addr));
+ /* give a specific prefix to the address */
+ addr[0] = 0x02;
+ addr[7] = idx;
+ hw->phy->perm_extended_addr = addr_to_le64(addr);
/* hwsim phy channel 13 as default */
hw->phy->current_channel = 13;
diff --git a/drivers/net/ieee802154/mac802154_hwsim.h b/drivers/net/ieee802154/mac802154_hwsim.h
index 6c6e30e38..536d95eb1 100644
--- a/drivers/net/ieee802154/mac802154_hwsim.h
+++ b/drivers/net/ieee802154/mac802154_hwsim.h
@@ -1,6 +1,8 @@
#ifndef __MAC802154_HWSIM_H
#define __MAC802154_HWSIM_H
+__le64 addr_to_le64(u8 *addr);
+
/* mac802154 hwsim netlink commands
*
* @MAC802154_HWSIM_CMD_UNSPEC: unspecified command to catch error
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] mac802154_hwsim: define perm_extended_addr initialization
2025-03-25 16:53 [PATCH] mac802154_hwsim: define perm_extended_addr initialization Ramon Fontes
@ 2025-03-26 10:12 ` Miquel Raynal
2025-03-26 10:34 ` Ramon Fontes
0 siblings, 1 reply; 9+ messages in thread
From: Miquel Raynal @ 2025-03-26 10:12 UTC (permalink / raw)
To: Ramon Fontes; +Cc: davem, kuba, pabeni, linux-wpan, alex.aring, netdev
Hello Ramon,
On 25/03/2025 at 13:53:12 -03, Ramon Fontes <ramonreisfontes@gmail.com> wrote:
> This establishes an initialization method for perm_extended_addr, aligning it with the approach used in mac80211_hwsim.
You are now enforcing an (almost) static value, is that the intended
behaviour? If yes I would like a better explanation of why this is
relevant and how you picked eg. 0x02 as prefix to justify the change.
In general I am not opposed, even though I kind of liked the idea of
generating random addresses, especially since hwsim is not the only one
to do that and having a simulator that behaves like regular device
drivers actually makes sense IMO.
Also, please wrap the commit log.
> Signed-off-by: Ramon Fontes <ramonreisfontes@gmail.com>
Thanks,
Miquèl
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] mac802154_hwsim: define perm_extended_addr initialization
2025-03-26 10:12 ` Miquel Raynal
@ 2025-03-26 10:34 ` Ramon Fontes
2025-03-26 17:00 ` Miquel Raynal
0 siblings, 1 reply; 9+ messages in thread
From: Ramon Fontes @ 2025-03-26 10:34 UTC (permalink / raw)
To: Miquel Raynal; +Cc: davem, kuba, pabeni, linux-wpan, alex.aring, netdev
Hello Miquèl,
This PR aims to replicate functionality similar to what is implemented
in mac80211_hwsim
(https://github.com/torvalds/linux/blob/master/drivers/net/wireless/virtual/mac80211_hwsim.c#L5223).
This approach is useful for testing wireless medium emulation tools
like wmediumd (https://github.com/bcopeland/wmediumd/blob/master/tests/)
and I plan to submit more PRs soon.
I've started developing a wmediumd-like framework for mac802154_hwsim,
which you can find here:
https://github.com/ramonfontes/wmediumd_802154. However, it's still in
its early stages.
Indeed, I'm responsible for Mininet-WiFi
(https://github.com/intrig-unicamp/mininet-wifi) which supports IEEE
802.15.4 emulation via mac802154_hwsim. Having a wireless medium
emulation for mac802154_hwsim would be highly beneficial, as it
enables controlled testing and facilitates prototyping.
> Also, please wrap the commit log.
Apologies for any confusion. Could you clarify if there are any
specific changes I need to make in the PR?
Em qua., 26 de mar. de 2025 às 07:12, Miquel Raynal
<miquel.raynal@bootlin.com> escreveu:
>
> Hello Ramon,
>
> On 25/03/2025 at 13:53:12 -03, Ramon Fontes <ramonreisfontes@gmail.com> wrote:
>
> > This establishes an initialization method for perm_extended_addr, aligning it with the approach used in mac80211_hwsim.
>
> You are now enforcing an (almost) static value, is that the intended
> behaviour? If yes I would like a better explanation of why this is
> relevant and how you picked eg. 0x02 as prefix to justify the change.
>
> In general I am not opposed, even though I kind of liked the idea of
> generating random addresses, especially since hwsim is not the only one
> to do that and having a simulator that behaves like regular device
> drivers actually makes sense IMO.
>
> Also, please wrap the commit log.
>
> > Signed-off-by: Ramon Fontes <ramonreisfontes@gmail.com>
>
> Thanks,
> Miquèl
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] mac802154_hwsim: define perm_extended_addr initialization
2025-03-26 10:34 ` Ramon Fontes
@ 2025-03-26 17:00 ` Miquel Raynal
0 siblings, 0 replies; 9+ messages in thread
From: Miquel Raynal @ 2025-03-26 17:00 UTC (permalink / raw)
To: Ramon Fontes; +Cc: davem, kuba, pabeni, linux-wpan, alex.aring, netdev
Hello Ramon,
On 26/03/2025 at 07:34:14 -03, Ramon Fontes <ramonreisfontes@gmail.com> wrote:
> Hello Miquèl,
>
> This PR aims to replicate functionality similar to what is implemented
> in mac80211_hwsim
> (https://github.com/torvalds/linux/blob/master/drivers/net/wireless/virtual/mac80211_hwsim.c#L5223).
> This approach is useful for testing wireless medium emulation tools
> like wmediumd (https://github.com/bcopeland/wmediumd/blob/master/tests/)
> and I plan to submit more PRs soon.
>
> I've started developing a wmediumd-like framework for mac802154_hwsim,
> which you can find here:
> https://github.com/ramonfontes/wmediumd_802154. However, it's still in
> its early stages.
>
> Indeed, I'm responsible for Mininet-WiFi
> (https://github.com/intrig-unicamp/mininet-wifi) which supports IEEE
> 802.15.4 emulation via mac802154_hwsim. Having a wireless medium
> emulation for mac802154_hwsim would be highly beneficial, as it
> enables controlled testing and facilitates prototyping.
Okay, I must say I do not know this project, but it looks interesting.
If the others are fine with this change, I'm fine too.
>> Also, please wrap the commit log.
> Apologies for any confusion. Could you clarify if there are any
> specific changes I need to make in the PR?
Yes, just change:
This establishes an initialization method for perm_extended_addr, aligning it with the approach used in mac80211_hwsim.
Into:
This establishes an initialization method for perm_extended_addr,
aligning it with the approach used in mac80211_hwsim.
Thanks,
Miquèl
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] mac802154_hwsim: define perm_extended_addr initialization
@ 2025-03-26 18:09 Ramon Fontes
2025-03-26 22:49 ` Alexander Aring
0 siblings, 1 reply; 9+ messages in thread
From: Ramon Fontes @ 2025-03-26 18:09 UTC (permalink / raw)
To: davem, kuba, pabeni
Cc: linux-wpan, alex.aring, miquel.raynal, netdev, Ramon Fontes
This establishes an initialization method for perm_extended_addr, aligning it with the approach used in mac80211_hwsim.
Signed-off-by: Ramon Fontes <ramonreisfontes@gmail.com>
---
drivers/net/ieee802154/mac802154_hwsim.c | 18 +++++++++++++++++-
drivers/net/ieee802154/mac802154_hwsim.h | 2 ++
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ieee802154/mac802154_hwsim.c b/drivers/net/ieee802154/mac802154_hwsim.c
index 1cab20b5a..400cdac1f 100644
--- a/drivers/net/ieee802154/mac802154_hwsim.c
+++ b/drivers/net/ieee802154/mac802154_hwsim.c
@@ -41,6 +41,17 @@ enum hwsim_multicast_groups {
HWSIM_MCGRP_CONFIG,
};
+__le64 addr_to_le64(u8 *addr) {
+ return cpu_to_le64(((u64)addr[0] << 56) |
+ ((u64)addr[1] << 48) |
+ ((u64)addr[2] << 40) |
+ ((u64)addr[3] << 32) |
+ ((u64)addr[4] << 24) |
+ ((u64)addr[5] << 16) |
+ ((u64)addr[6] << 8) |
+ ((u64)addr[7]));
+}
+
static const struct genl_multicast_group hwsim_mcgrps[] = {
[HWSIM_MCGRP_CONFIG] = { .name = "config", },
};
@@ -896,6 +907,7 @@ static int hwsim_subscribe_all_others(struct hwsim_phy *phy)
static int hwsim_add_one(struct genl_info *info, struct device *dev,
bool init)
{
+ u8 addr[8];
struct ieee802154_hw *hw;
struct hwsim_phy *phy;
struct hwsim_pib *pib;
@@ -942,7 +954,11 @@ static int hwsim_add_one(struct genl_info *info, struct device *dev,
/* 950 MHz GFSK 802.15.4d-2009 */
hw->phy->supported.channels[6] |= 0x3ffc00;
- ieee802154_random_extended_addr(&hw->phy->perm_extended_addr);
+ memset(addr, 0, sizeof(addr));
+ /* give a specific prefix to the address */
+ addr[0] = 0x02;
+ addr[7] = idx;
+ hw->phy->perm_extended_addr = addr_to_le64(addr);
/* hwsim phy channel 13 as default */
hw->phy->current_channel = 13;
diff --git a/drivers/net/ieee802154/mac802154_hwsim.h b/drivers/net/ieee802154/mac802154_hwsim.h
index 6c6e30e38..536d95eb1 100644
--- a/drivers/net/ieee802154/mac802154_hwsim.h
+++ b/drivers/net/ieee802154/mac802154_hwsim.h
@@ -1,6 +1,8 @@
#ifndef __MAC802154_HWSIM_H
#define __MAC802154_HWSIM_H
+__le64 addr_to_le64(u8 *addr);
+
/* mac802154 hwsim netlink commands
*
* @MAC802154_HWSIM_CMD_UNSPEC: unspecified command to catch error
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] mac802154_hwsim: define perm_extended_addr initialization
2025-03-26 18:09 Ramon Fontes
@ 2025-03-26 22:49 ` Alexander Aring
2025-03-26 23:24 ` Ramon Fontes
0 siblings, 1 reply; 9+ messages in thread
From: Alexander Aring @ 2025-03-26 22:49 UTC (permalink / raw)
To: Ramon Fontes
Cc: davem, kuba, pabeni, linux-wpan, alex.aring, miquel.raynal,
netdev
Hi,
On Wed, Mar 26, 2025 at 2:09 PM Ramon Fontes <ramonreisfontes@gmail.com> wrote:
>
> This establishes an initialization method for perm_extended_addr, aligning it with the approach used in mac80211_hwsim.
>
that is based on the phy index value instead of a random generated one?
> Signed-off-by: Ramon Fontes <ramonreisfontes@gmail.com>
> ---
> drivers/net/ieee802154/mac802154_hwsim.c | 18 +++++++++++++++++-
> drivers/net/ieee802154/mac802154_hwsim.h | 2 ++
> 2 files changed, 19 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ieee802154/mac802154_hwsim.c b/drivers/net/ieee802154/mac802154_hwsim.c
> index 1cab20b5a..400cdac1f 100644
> --- a/drivers/net/ieee802154/mac802154_hwsim.c
> +++ b/drivers/net/ieee802154/mac802154_hwsim.c
> @@ -41,6 +41,17 @@ enum hwsim_multicast_groups {
> HWSIM_MCGRP_CONFIG,
> };
>
> +__le64 addr_to_le64(u8 *addr) {
> + return cpu_to_le64(((u64)addr[0] << 56) |
> + ((u64)addr[1] << 48) |
> + ((u64)addr[2] << 40) |
> + ((u64)addr[3] << 32) |
> + ((u64)addr[4] << 24) |
> + ((u64)addr[5] << 16) |
> + ((u64)addr[6] << 8) |
> + ((u64)addr[7]));
> +}
> +
> static const struct genl_multicast_group hwsim_mcgrps[] = {
> [HWSIM_MCGRP_CONFIG] = { .name = "config", },
> };
> @@ -896,6 +907,7 @@ static int hwsim_subscribe_all_others(struct hwsim_phy *phy)
> static int hwsim_add_one(struct genl_info *info, struct device *dev,
> bool init)
> {
> + u8 addr[8];
why not using directly __le64?
> struct ieee802154_hw *hw;
> struct hwsim_phy *phy;
> struct hwsim_pib *pib;
> @@ -942,7 +954,11 @@ static int hwsim_add_one(struct genl_info *info, struct device *dev,
> /* 950 MHz GFSK 802.15.4d-2009 */
> hw->phy->supported.channels[6] |= 0x3ffc00;
>
> - ieee802154_random_extended_addr(&hw->phy->perm_extended_addr);
> + memset(addr, 0, sizeof(addr));
> + /* give a specific prefix to the address */
> + addr[0] = 0x02;
> + addr[7] = idx;
> + hw->phy->perm_extended_addr = addr_to_le64(addr);
>
> /* hwsim phy channel 13 as default */
> hw->phy->current_channel = 13;
> diff --git a/drivers/net/ieee802154/mac802154_hwsim.h b/drivers/net/ieee802154/mac802154_hwsim.h
> index 6c6e30e38..536d95eb1 100644
> --- a/drivers/net/ieee802154/mac802154_hwsim.h
> +++ b/drivers/net/ieee802154/mac802154_hwsim.h
> @@ -1,6 +1,8 @@
> #ifndef __MAC802154_HWSIM_H
> #define __MAC802154_HWSIM_H
>
> +__le64 addr_to_le64(u8 *addr);
> +
This is a uapi header for netlink which is not yet delivered through
kernel-headers installation.
Why do we need this prototype declaration here?
Thanks.
- Alex
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] mac802154_hwsim: define perm_extended_addr initialization
2025-03-26 22:49 ` Alexander Aring
@ 2025-03-26 23:24 ` Ramon Fontes
0 siblings, 0 replies; 9+ messages in thread
From: Ramon Fontes @ 2025-03-26 23:24 UTC (permalink / raw)
To: Alexander Aring
Cc: davem, kuba, pabeni, linux-wpan, alex.aring, miquel.raynal,
netdev
On Wed, Mar 26, 2025 at 7:49 PM, Alexander Aring <aahringo@redhat.com> wrote:
>
> Hi,
>
> On Wed, Mar 26, 2025 at 2:09 PM Ramon Fontes <ramonreisfontes@gmail.com> wrote:
> >
> > This establishes an initialization method for perm_extended_addr, aligning it with the approach used in mac80211_hwsim.
> >
>
> that is based on the phy index value instead of a random generated one?
Yes, that's based on the phy index value.
>
> > Signed-off-by: Ramon Fontes <ramonreisfontes@gmail.com>
> > ---
> > drivers/net/ieee802154/mac802154_hwsim.c | 18 +++++++++++++++++-
> > drivers/net/ieee802154/mac802154_hwsim.h | 2 ++
> > 2 files changed, 19 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/ieee802154/mac802154_hwsim.c b/drivers/net/ieee802154/mac802154_hwsim.c
> > index 1cab20b5a..400cdac1f 100644
> > --- a/drivers/net/ieee802154/mac802154_hwsim.c
> > +++ b/drivers/net/ieee802154/mac802154_hwsim.c
> > @@ -41,6 +41,17 @@ enum hwsim_multicast_groups {
> > HWSIM_MCGRP_CONFIG,
> > };
> >
> > +__le64 addr_to_le64(u8 *addr) {
> > + return cpu_to_le64(((u64)addr[0] << 56) |
> > + ((u64)addr[1] << 48) |
> > + ((u64)addr[2] << 40) |
> > + ((u64)addr[3] << 32) |
> > + ((u64)addr[4] << 24) |
> > + ((u64)addr[5] << 16) |
> > + ((u64)addr[6] << 8) |
> > + ((u64)addr[7]));
> > +}
> > +
> > static const struct genl_multicast_group hwsim_mcgrps[] = {
> > [HWSIM_MCGRP_CONFIG] = { .name = "config", },
> > };
> > @@ -896,6 +907,7 @@ static int hwsim_subscribe_all_others(struct hwsim_phy *phy)
> > static int hwsim_add_one(struct genl_info *info, struct device *dev,
> > bool init)
> > {
> > + u8 addr[8];
>
> why not using directly
Yes, we don't need it.
>
> > struct ieee802154_hw *hw;
> > struct hwsim_phy *phy;
> > struct hwsim_pib *pib;
> > @@ -942,7 +954,11 @@ static int hwsim_add_one(struct genl_info *info, struct device *dev,
> > /* 950 MHz GFSK 802.15.4d-2009 */
> > hw->phy->supported.channels[6] |= 0x3ffc00;
> >
> > - ieee802154_random_extended_addr(&hw->phy->perm_extended_addr);
> > + memset(addr, 0, sizeof(addr));
> > + /* give a specific prefix to the address */
> > + addr[0] = 0x02;
> > + addr[7] = idx;
> > + hw->phy->perm_extended_addr = addr_to_le64(addr);
I think we can replace everything with only one line of code:
hw->phy->perm_extended_addr = cpu_to_le64(((u64)0x02 << 56) | ((u64)idx));
This does the trick! What do you think?
> >
> > /* hwsim phy channel 13 as default */
> > hw->phy->current_channel = 13;
> > diff --git a/drivers/net/ieee802154/mac802154_hwsim.h b/drivers/net/ieee802154/mac802154_hwsim.h
> > index 6c6e30e38..536d95eb1 100644
> > --- a/drivers/net/ieee802154/mac802154_hwsim.h
> > +++ b/drivers/net/ieee802154/mac802154_hwsim.h
> > @@ -1,6 +1,8 @@
> > #ifndef __MAC802154_HWSIM_H
> > #define __MAC802154_HWSIM_H
> >
> > +__le64 addr_to_le64(u8 *addr);
> > +
>
> This is a uapi header for netlink which is not yet delivered through
> kernel-headers installation.
>
> Why do we need this prototype declaration here?
We don't need it.
>
> Thanks.
>
> - Alex
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] mac802154_hwsim: define perm_extended_addr initialization
@ 2025-03-29 14:20 Ramon Fontes
2025-03-31 8:15 ` Miquel Raynal
0 siblings, 1 reply; 9+ messages in thread
From: Ramon Fontes @ 2025-03-29 14:20 UTC (permalink / raw)
To: davem, kuba, pabeni
Cc: linux-wpan, alex.aring, miquel.raynal, netdev, Ramon Fontes
This establishes an initialization method for perm_extended_addr,
aligning it with the approach used in mac80211_hwsim.
Signed-off-by: Ramon Fontes <ramonreisfontes@gmail.com>
---
drivers/net/ieee802154/mac802154_hwsim.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ieee802154/mac802154_hwsim.c b/drivers/net/ieee802154/mac802154_hwsim.c
index 1cab20b5a..2f7520454 100644
--- a/drivers/net/ieee802154/mac802154_hwsim.c
+++ b/drivers/net/ieee802154/mac802154_hwsim.c
@@ -942,7 +942,7 @@ static int hwsim_add_one(struct genl_info *info, struct device *dev,
/* 950 MHz GFSK 802.15.4d-2009 */
hw->phy->supported.channels[6] |= 0x3ffc00;
- ieee802154_random_extended_addr(&hw->phy->perm_extended_addr);
+ hw->phy->perm_extended_addr = cpu_to_le64(((u64)0x02 << 56) | ((u64)idx));
/* hwsim phy channel 13 as default */
hw->phy->current_channel = 13;
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] mac802154_hwsim: define perm_extended_addr initialization
2025-03-29 14:20 Ramon Fontes
@ 2025-03-31 8:15 ` Miquel Raynal
0 siblings, 0 replies; 9+ messages in thread
From: Miquel Raynal @ 2025-03-31 8:15 UTC (permalink / raw)
To: Ramon Fontes; +Cc: davem, kuba, pabeni, linux-wpan, alex.aring, netdev
On 29/03/2025 at 11:20:10 -03, Ramon Fontes <ramonreisfontes@gmail.com> wrote:
> This establishes an initialization method for perm_extended_addr,
> aligning it with the approach used in mac80211_hwsim.
>
> Signed-off-by: Ramon Fontes <ramonreisfontes@gmail.com>
Yeah, that's simpler, thanks Alex.
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2025-03-31 8:15 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-25 16:53 [PATCH] mac802154_hwsim: define perm_extended_addr initialization Ramon Fontes
2025-03-26 10:12 ` Miquel Raynal
2025-03-26 10:34 ` Ramon Fontes
2025-03-26 17:00 ` Miquel Raynal
-- strict thread matches above, loose matches on Subject: below --
2025-03-26 18:09 Ramon Fontes
2025-03-26 22:49 ` Alexander Aring
2025-03-26 23:24 ` Ramon Fontes
2025-03-29 14:20 Ramon Fontes
2025-03-31 8:15 ` Miquel Raynal
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).