lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 22 Dec 2021 16:57:27 +0100
From:   Miquel Raynal <miquel.raynal@...tlin.com>
To:     "David S. Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>, netdev@...r.kernel.org,
        Alexander Aring <alex.aring@...il.com>,
        Stefan Schmidt <stefan@...enfreihafen.org>,
        linux-wpan@...r.kernel.org
Cc:     David Girault <david.girault@...vo.com>,
        Romuald Despres <romuald.despres@...vo.com>,
        Frederic Blain <frederic.blain@...vo.com>,
        Thomas Petazzoni <thomas.petazzoni@...tlin.com>,
        <linux-kernel@...r.kernel.org>,
        Miquel Raynal <miquel.raynal@...tlin.com>
Subject: [net-next 02/18] ieee802154: hwsim: Provide a symbol duration

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@...tlin.com>
---
 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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ