Commit 00f59314 authored by Alexander Aring's avatar Alexander Aring Committed by Marcel Holtmann

6lowpan: add lowpan dev register helpers

This patch introduces register and unregister functionality for lowpan
interfaces. While register a lowpan interface there are several things
which need to be initialize by the 6lowpan subsystem. Upcoming
functionality need to register/unregister per interface components e.g.
debugfs entry.
Reviewed-by: default avatarStefan Schmidt <stefan@osg.samsung.com>
Signed-off-by: default avatarAlexander Aring <alex.aring@gmail.com>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent 43f26e17
...@@ -185,7 +185,12 @@ static inline void lowpan_push_hc_data(u8 **hc_ptr, const void *data, ...@@ -185,7 +185,12 @@ static inline void lowpan_push_hc_data(u8 **hc_ptr, const void *data,
*hc_ptr += len; *hc_ptr += len;
} }
void lowpan_netdev_setup(struct net_device *dev, enum lowpan_lltypes lltype); int lowpan_register_netdevice(struct net_device *dev,
enum lowpan_lltypes lltype);
int lowpan_register_netdev(struct net_device *dev,
enum lowpan_lltypes lltype);
void lowpan_unregister_netdevice(struct net_device *dev);
void lowpan_unregister_netdev(struct net_device *dev);
/** /**
* lowpan_header_decompress - replace 6LoWPAN header with IPv6 header * lowpan_header_decompress - replace 6LoWPAN header with IPv6 header
......
...@@ -15,7 +15,8 @@ ...@@ -15,7 +15,8 @@
#include <net/6lowpan.h> #include <net/6lowpan.h>
void lowpan_netdev_setup(struct net_device *dev, enum lowpan_lltypes lltype) int lowpan_register_netdevice(struct net_device *dev,
enum lowpan_lltypes lltype)
{ {
dev->addr_len = EUI64_ADDR_LEN; dev->addr_len = EUI64_ADDR_LEN;
dev->type = ARPHRD_6LOWPAN; dev->type = ARPHRD_6LOWPAN;
...@@ -23,8 +24,36 @@ void lowpan_netdev_setup(struct net_device *dev, enum lowpan_lltypes lltype) ...@@ -23,8 +24,36 @@ void lowpan_netdev_setup(struct net_device *dev, enum lowpan_lltypes lltype)
dev->priv_flags |= IFF_NO_QUEUE; dev->priv_flags |= IFF_NO_QUEUE;
lowpan_priv(dev)->lltype = lltype; lowpan_priv(dev)->lltype = lltype;
return register_netdevice(dev);
}
EXPORT_SYMBOL(lowpan_register_netdevice);
int lowpan_register_netdev(struct net_device *dev,
enum lowpan_lltypes lltype)
{
int ret;
rtnl_lock();
ret = lowpan_register_netdevice(dev, lltype);
rtnl_unlock();
return ret;
}
EXPORT_SYMBOL(lowpan_register_netdev);
void lowpan_unregister_netdevice(struct net_device *dev)
{
unregister_netdevice(dev);
}
EXPORT_SYMBOL(lowpan_unregister_netdevice);
void lowpan_unregister_netdev(struct net_device *dev)
{
rtnl_lock();
lowpan_unregister_netdevice(dev);
rtnl_unlock();
} }
EXPORT_SYMBOL(lowpan_netdev_setup); EXPORT_SYMBOL(lowpan_unregister_netdev);
static int __init lowpan_module_init(void) static int __init lowpan_module_init(void)
{ {
......
...@@ -825,9 +825,7 @@ static int setup_netdev(struct l2cap_chan *chan, struct lowpan_dev **dev) ...@@ -825,9 +825,7 @@ static int setup_netdev(struct l2cap_chan *chan, struct lowpan_dev **dev)
list_add_rcu(&(*dev)->list, &bt_6lowpan_devices); list_add_rcu(&(*dev)->list, &bt_6lowpan_devices);
spin_unlock(&devices_lock); spin_unlock(&devices_lock);
lowpan_netdev_setup(netdev, LOWPAN_LLTYPE_BTLE); err = lowpan_register_netdev(netdev, LOWPAN_LLTYPE_BTLE);
err = register_netdev(netdev);
if (err < 0) { if (err < 0) {
BT_INFO("register_netdev failed %d", err); BT_INFO("register_netdev failed %d", err);
spin_lock(&devices_lock); spin_lock(&devices_lock);
...@@ -890,7 +888,7 @@ static void delete_netdev(struct work_struct *work) ...@@ -890,7 +888,7 @@ static void delete_netdev(struct work_struct *work)
struct lowpan_dev *entry = container_of(work, struct lowpan_dev, struct lowpan_dev *entry = container_of(work, struct lowpan_dev,
delete_netdev); delete_netdev);
unregister_netdev(entry->netdev); lowpan_unregister_netdev(entry->netdev);
/* The entry pointer is deleted by the netdev destructor. */ /* The entry pointer is deleted by the netdev destructor. */
} }
...@@ -1348,7 +1346,7 @@ static void disconnect_devices(void) ...@@ -1348,7 +1346,7 @@ static void disconnect_devices(void)
ifdown(entry->netdev); ifdown(entry->netdev);
BT_DBG("Unregistering netdev %s %p", BT_DBG("Unregistering netdev %s %p",
entry->netdev->name, entry->netdev); entry->netdev->name, entry->netdev);
unregister_netdev(entry->netdev); lowpan_unregister_netdev(entry->netdev);
kfree(entry); kfree(entry);
} }
} }
......
...@@ -161,9 +161,7 @@ static int lowpan_newlink(struct net *src_net, struct net_device *ldev, ...@@ -161,9 +161,7 @@ static int lowpan_newlink(struct net *src_net, struct net_device *ldev,
wdev->needed_headroom; wdev->needed_headroom;
ldev->needed_tailroom = wdev->needed_tailroom; ldev->needed_tailroom = wdev->needed_tailroom;
lowpan_netdev_setup(ldev, LOWPAN_LLTYPE_IEEE802154); ret = lowpan_register_netdevice(ldev, LOWPAN_LLTYPE_IEEE802154);
ret = register_netdevice(ldev);
if (ret < 0) { if (ret < 0) {
dev_put(wdev); dev_put(wdev);
return ret; return ret;
...@@ -180,7 +178,7 @@ static void lowpan_dellink(struct net_device *ldev, struct list_head *head) ...@@ -180,7 +178,7 @@ static void lowpan_dellink(struct net_device *ldev, struct list_head *head)
ASSERT_RTNL(); ASSERT_RTNL();
wdev->ieee802154_ptr->lowpan_dev = NULL; wdev->ieee802154_ptr->lowpan_dev = NULL;
unregister_netdevice(ldev); lowpan_unregister_netdevice(ldev);
dev_put(wdev); dev_put(wdev);
} }
......
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