Add support for the symbol duration in the softMAC hwsim driver. The symbol durations are provided in micro-seconds and are extracted from the IEEE 802.15.4 specification thanks to the other parameters and comments from this driver. Some of these durations are hard to find/derive, so they are left to 1 in order to avoid null values (for the upcoming changes related to scanning). In this case a comment is stating that the value in unknown. Signed-off-by: Miquel Raynal <miquel.raynal@xxxxxxxxxxx> --- drivers/net/ieee802154/mac802154_hwsim.c | 70 ++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/drivers/net/ieee802154/mac802154_hwsim.c b/drivers/net/ieee802154/mac802154_hwsim.c index b1a4ee7dceda..38be88db5f7a 100644 --- a/drivers/net/ieee802154/mac802154_hwsim.c +++ b/drivers/net/ieee802154/mac802154_hwsim.c @@ -92,6 +92,7 @@ static int hwsim_hw_channel(struct ieee802154_hw *hw, u8 page, u8 channel) { struct hwsim_phy *phy = hw->priv; struct hwsim_pib *pib, *pib_old; + int ret = 0; pib = kzalloc(sizeof(*pib), GFP_KERNEL); if (!pib) @@ -99,6 +100,75 @@ static int hwsim_hw_channel(struct ieee802154_hw *hw, u8 page, u8 channel) pib->page = page; pib->channel = channel; + switch (page) { + case 0: + if (BIT(channel) & 0x1) + /* 868 MHz BPSK 802.15.4-2003: 20 ksym/s */ + hw->phy->symbol_duration = 50; + else if (BIT(channel) & 0x7fe) + /* 915 MHz BPSK 802.15.4-2003: 40 ksym/s */ + hw->phy->symbol_duration = 25; + else if (BIT(channel) & 0x7FFF800) + /* 2.4 GHz O-QPSK 802.15.4-2003: 62.5 ksym/s */ + hw->phy->symbol_duration = 16; + else + ret = -EINVAL; + break; + case 1: + if (BIT(channel) & (0x1 | 0x7fe)) + /* unknown rate */ + hw->phy->symbol_duration = 1; + else + ret = -EINVAL; + break; + case 2: + if (BIT(channel) & 0x1) + /* 868 MHz O-QPSK 802.15.4-2006: 25 ksym/s */ + hw->phy->symbol_duration = 40; + else if (BIT(channel) & 0x7fe) + /* 915 MHz O-QPSK 802.15.4-2006: 62.5 ksym/s */ + hw->phy->symbol_duration = 16; + else + ret = -EINVAL; + break; + case 3: + if (BIT(channel) & 0x3fff) + /* 2.4 GHz CSS 802.15.4a-2007: 1/6 Msym/s */ + hw->phy->symbol_duration = 6; + else + ret = -EINVAL; + break; + case 4: + if (BIT(channel) & (0x1 | 0x1e | 0xffe0)) + /* UWB 802.15.4a-2007: 993.6 or 1017.6 or 3974.4 us */ + hw->phy->symbol_duration = 1; + else + ret = -EINVAL; + break; + case 5: + if (BIT(channel) & (0xf | 0xf0)) + /* unknown rate */ + hw->phy->symbol_duration = 1; + else + ret = -EINVAL; + break; + case 6: + if (BIT(channel) & (0x3ff | 0x3ffc00)) + /* unknown rate */ + hw->phy->symbol_duration = 1; + else + ret = -EINVAL; + break; + default: + ret = -EINVAL; + } + + if (ret) { + dev_err(hw->parent, "Invalid channel %d on page %d\n", + page, channel); + kfree(pib); + return ret; + } pib_old = rtnl_dereference(phy->pib); rcu_assign_pointer(phy->pib, pib); -- 2.27.0