Skip to content

Commit

Permalink
ieee802154: add nl802154 framework
Browse files Browse the repository at this point in the history
This patch adds a basic nl802154 framework. Most of this code was
grabbed from nl80211 framework.

Signed-off-by: Alexander Aring <[email protected]>
Signed-off-by: Marcel Holtmann <[email protected]>
  • Loading branch information
alexaring authored and holtmann committed Nov 9, 2014
1 parent 3ae75e0 commit 79fe1a2
Show file tree
Hide file tree
Showing 7 changed files with 350 additions and 4 deletions.
2 changes: 1 addition & 1 deletion net/ieee802154/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ obj-$(CONFIG_IEEE802154_6LOWPAN) += ieee802154_6lowpan.o

ieee802154_6lowpan-y := 6lowpan_rtnl.o reassembly.o
ieee802154-y := netlink.o nl-mac.o nl-phy.o nl_policy.o core.o \
header_ops.o sysfs.o
header_ops.o sysfs.o nl802154.o
af_802154-y := af_ieee802154.o raw.o dgram.o

ccflags-y += -D__CHECK_ENDIAN__
28 changes: 27 additions & 1 deletion net/ieee802154/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@
#include <net/rtnetlink.h>

#include "ieee802154.h"
#include "nl802154.h"
#include "sysfs.h"
#include "core.h"

/* RCU-protected (and RTNL for writers) */
static LIST_HEAD(cfg802154_rdev_list);
LIST_HEAD(cfg802154_rdev_list);
static int cfg802154_rdev_list_generation;

static int wpan_phy_match(struct device *dev, const void *data)
Expand Down Expand Up @@ -74,6 +75,23 @@ int wpan_phy_for_each(int (*fn)(struct wpan_phy *phy, void *data),
}
EXPORT_SYMBOL(wpan_phy_for_each);

struct cfg802154_registered_device *
cfg802154_rdev_by_wpan_phy_idx(int wpan_phy_idx)
{
struct cfg802154_registered_device *result = NULL, *rdev;

ASSERT_RTNL();

list_for_each_entry(rdev, &cfg802154_rdev_list, list) {
if (rdev->wpan_phy_idx == wpan_phy_idx) {
result = rdev;
break;
}
}

return result;
}

struct wpan_phy *
wpan_phy_new(const struct cfg802154_ops *ops, size_t priv_size)
{
Expand Down Expand Up @@ -270,8 +288,15 @@ static int __init wpan_phy_class_init(void)
if (rc)
goto err_notifier;

rc = nl802154_init();
if (rc)
goto err_ieee802154_nl;

return 0;

err_ieee802154_nl:
ieee802154_nl_exit();

err_notifier:
unregister_netdevice_notifier(&cfg802154_netdev_notifier);
err_nl:
Expand All @@ -283,6 +308,7 @@ subsys_initcall(wpan_phy_class_init);

static void __exit wpan_phy_class_exit(void)
{
nl802154_exit();
ieee802154_nl_exit();
unregister_netdevice_notifier(&cfg802154_netdev_notifier);
wpan_phy_sysfs_exit();
Expand Down
4 changes: 4 additions & 0 deletions net/ieee802154/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ wpan_phy_to_rdev(struct wpan_phy *wpan_phy)
wpan_phy);
}

extern struct list_head cfg802154_rdev_list;

/* free object */
void cfg802154_dev_free(struct cfg802154_registered_device *rdev);
struct cfg802154_registered_device *
cfg802154_rdev_by_wpan_phy_idx(int wpan_phy_idx);

#endif /* __IEEE802154_CORE_H */
2 changes: 1 addition & 1 deletion net/ieee802154/ieee802154.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#define IEEE_802154_LOCAL_H

int __init ieee802154_nl_init(void);
void __exit ieee802154_nl_exit(void);
void ieee802154_nl_exit(void);

#define IEEE802154_OP(_cmd, _func) \
{ \
Expand Down
2 changes: 1 addition & 1 deletion net/ieee802154/netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ int __init ieee802154_nl_init(void)
ieee802154_mcgrps);
}

void __exit ieee802154_nl_exit(void)
void ieee802154_nl_exit(void)
{
genl_unregister_family(&nl802154_family);
}
Loading

0 comments on commit 79fe1a2

Please sign in to comment.