Commit cb41c8dd authored by Alexander Aring's avatar Alexander Aring Committed by Marcel Holtmann

ieee802154: rename and move WPAN_NUM_ defines

This patch moves the 802.15.4 constraints WPAN_NUM_ defines into
"net/ieee802154.h" which should contain all necessary 802.15.4 related
information. Also rename these defines to a common name which is
IEEE802154_MAX_CHANNEL and IEEE802154_MAX_PAGE.
Signed-off-by: default avatarAlexander Aring <alex.aring@gmail.com>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent b821ecd4
...@@ -39,6 +39,9 @@ ...@@ -39,6 +39,9 @@
#define IEEE802154_LIFS_PERIOD 40 #define IEEE802154_LIFS_PERIOD 40
#define IEEE802154_SIFS_PERIOD 12 #define IEEE802154_SIFS_PERIOD 12
#define IEEE802154_MAX_CHANNEL 26
#define IEEE802154_MAX_PAGE 31
#define IEEE802154_FC_TYPE_BEACON 0x0 /* Frame is beacon */ #define IEEE802154_FC_TYPE_BEACON 0x0 /* Frame is beacon */
#define IEEE802154_FC_TYPE_DATA 0x1 /* Frame is data */ #define IEEE802154_FC_TYPE_DATA 0x1 /* Frame is data */
#define IEEE802154_FC_TYPE_ACK 0x2 /* Frame is acknowledgment */ #define IEEE802154_FC_TYPE_ACK 0x2 /* Frame is acknowledgment */
......
...@@ -17,20 +17,13 @@ ...@@ -17,20 +17,13 @@
#ifndef __NET_CFG802154_H #ifndef __NET_CFG802154_H
#define __NET_CFG802154_H #define __NET_CFG802154_H
#include <linux/ieee802154.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/bug.h> #include <linux/bug.h>
#include <net/nl802154.h> #include <net/nl802154.h>
/* According to the IEEE 802.15.4 stadard the upper most significant bits of
* the 32-bit channel bitmaps shall be used as an integer value to specify 32
* possible channel pages. The lower 27 bits of the channel bit map shall be
* used as a bit mask to specify channel numbers within a channel page.
*/
#define WPAN_NUM_CHANNELS 27
#define WPAN_NUM_PAGES 32
struct wpan_phy; struct wpan_phy;
struct cfg802154_ops { struct cfg802154_ops {
...@@ -81,7 +74,7 @@ struct wpan_phy { ...@@ -81,7 +74,7 @@ struct wpan_phy {
*/ */
u8 current_channel; u8 current_channel;
u8 current_page; u8 current_page;
u32 channels_supported[32]; u32 channels_supported[IEEE802154_MAX_PAGE + 1];
s8 transmit_power; s8 transmit_power;
u8 cca_mode; u8 cca_mode;
......
...@@ -245,7 +245,7 @@ nl802154_send_wpan_phy_channels(struct cfg802154_registered_device *rdev, ...@@ -245,7 +245,7 @@ nl802154_send_wpan_phy_channels(struct cfg802154_registered_device *rdev,
if (!nl_page) if (!nl_page)
return -ENOBUFS; return -ENOBUFS;
for (page = 0; page < WPAN_NUM_PAGES; page++) { for (page = 0; page <= IEEE802154_MAX_PAGE; page++) {
if (nla_put_u32(msg, NL802154_ATTR_SUPPORTED_CHANNEL, if (nla_put_u32(msg, NL802154_ATTR_SUPPORTED_CHANNEL,
rdev->wpan_phy.channels_supported[page])) rdev->wpan_phy.channels_supported[page]))
return -ENOBUFS; return -ENOBUFS;
...@@ -616,7 +616,7 @@ static int nl802154_set_channel(struct sk_buff *skb, struct genl_info *info) ...@@ -616,7 +616,7 @@ static int nl802154_set_channel(struct sk_buff *skb, struct genl_info *info)
channel = nla_get_u8(info->attrs[NL802154_ATTR_CHANNEL]); channel = nla_get_u8(info->attrs[NL802154_ATTR_CHANNEL]);
/* check 802.15.4 constraints */ /* check 802.15.4 constraints */
if (page >= WPAN_NUM_PAGES || channel >= WPAN_NUM_CHANNELS) if (page > IEEE802154_MAX_PAGE || channel > IEEE802154_MAX_CHANNEL)
return -EINVAL; return -EINVAL;
return rdev_set_channel(rdev, page, channel); return rdev_set_channel(rdev, page, channel);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment