mac802154_hwsim: define perm_extended_addr initialization
Subsystems (3)
PATCH 1/1 mac802154_hwsim: define perm_extended_addr initialization
This establishes an initialization method for perm_extended_addr, aligning it with the approach used in mac80211_hwsim.
--- drivers/net/ieee802154/mac802154_hwsim.c | 18 +++++++++++++++++- drivers/net/ieee802154/mac802154_hwsim.h | 2 ++ 2 files changed, 19 insertions(+), 1 deletion(-)
drivers/net/ieee802154/mac802154_hwsim.c +17 -1
@@ -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 ;
drivers/net/ieee802154/mac802154_hwsim.h +2 -0
@@ -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
Signature · 1 line
2.43.0
PATCH v2 1/1 mac802154_hwsim: define perm_extended_addr initialization
This establishes an initialization method for perm_extended_addr, aligning it with the approach used in mac80211_hwsim.
--- drivers/net/ieee802154/mac802154_hwsim.c | 18 +++++++++++++++++- drivers/net/ieee802154/mac802154_hwsim.h | 2 ++ 2 files changed, 19 insertions(+), 1 deletion(-)
drivers/net/ieee802154/mac802154_hwsim.c +17 -1
@@ -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 ;
drivers/net/ieee802154/mac802154_hwsim.h +2 -0
@@ -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
Signature · 1 line
2.43.0
Hi,
Quoted 3 lines · Ramon Fontes
This establishes an initialization method for
perm_extended_addr, aligning it with the approach used inmac80211_hwsim.
that is based on the phy index value instead of a random generated one?
Quoted 29 lines
Signed-off-by Ramon Fontes <[email protected]>--- drivers/net/ieee802154/mac802154_hwsim.c | 18 +++++++++++++++++- drivers/net/ieee802154/mac802154_hwsim.h | 2 ++ 2 files changed, 19 insertions(+), 1 deletion(-)drivers/net/ieee802154/mac802154_hwsim.c +11
-0@@ -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" , }, };
drivers/net/ieee802154/mac802154_hwsim.c static int hwsim_subscribe_all_others(struct hwsim_phy *phy) · line 910
Quoted 4 lines
drivers/net/ieee802154/mac802154_hwsim.c +1
-0@@ -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?
Quoted 21 lines
drivers/net/ieee802154/mac802154_hwsim.c +5
-1struct 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 ;drivers/net/ieee802154/mac802154_hwsim.h +0
-0
drivers/net/ieee802154/mac802154_hwsim.h line 5
Quoted 5 lines
drivers/net/ieee802154/mac802154_hwsim.h +2
-0@@ -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
Quoted 9 lines · Alexander Aring
Hi,
Quoted 3 lines · Ramon Fontes
This establishes an initialization method for
perm_extended_addr, aligning it with the approach used inmac80211_hwsim.that is based on the phy index value instead of a random generated one?
Yes, that's based on the phy index value.
Quoted 28 lines
Quoted 28 lines
Signed-off-by Ramon Fontes <[email protected]>--- drivers/net/ieee802154/mac802154_hwsim.c | 18 +++++++++++++++++- drivers/net/ieee802154/mac802154_hwsim.h | 2 ++ 2 files changed, 19 insertions(+), 1 deletion(-)drivers/net/ieee802154/mac802154_hwsim.c +11
-0@@ -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" , },
Quoted 8 lines
drivers/net/ieee802154/mac802154_hwsim.c static int hwsim_subscribe_all_others(struct hwsim_phy *phy) · line 910
Quoted 6 lines
drivers/net/ieee802154/mac802154_hwsim.c +1
-0};@@ -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.
Quoted 8 lines
Quoted 8 lines
drivers/net/ieee802154/mac802154_hwsim.c +0
-0struct 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 ;
Quoted 6 lines
drivers/net/ieee802154/mac802154_hwsim.c static int hwsim_add_one(struct genl_info *info, struct device *dev, · line 961
Quoted 6 lines
drivers/net/ieee802154/mac802154_hwsim.c +5
-1-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?
Quoted 11 lines
Quoted 11 lines
drivers/net/ieee802154/mac802154_hwsim.c +0
-0/* hwsim phy channel 13 as default */ hw->phy->current_channel =13 ;drivers/net/ieee802154/mac802154_hwsim.h +0
-0@@ -1,6 +1,8 @@#ifndef __MAC802154_HWSIM_H#define __MAC802154_HWSIM_H
Quoted 7 lines
drivers/net/ieee802154/mac802154_hwsim.h line 5
Quoted 2 lines
drivers/net/ieee802154/mac802154_hwsim.h +2
-0+__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.
Quoted 5 lines
Thanks.
- Alex