Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ieee802154: add new interface command

This patch adds a new nl802154 command for adding a new interface
according to a wpan phy via nl802154.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>

authored by

Alexander Aring and committed by
Marcel Holtmann
f3ea5e44 133d3f31

+61
+5
include/net/cfg802154.h
··· 21 21 #include <linux/mutex.h> 22 22 #include <linux/bug.h> 23 23 24 + #include <net/nl802154.h> 25 + 24 26 /* According to the IEEE 802.15.4 stadard the upper most significant bits of 25 27 * the 32-bit channel bitmaps shall be used as an integer value to specify 32 26 28 * possible channel pages. The lower 27 bits of the channel bit map shall be ··· 39 37 int type); 40 38 void (*del_virtual_intf_deprecated)(struct wpan_phy *wpan_phy, 41 39 struct net_device *dev); 40 + int (*add_virtual_intf)(struct wpan_phy *wpan_phy, 41 + const char *name, 42 + enum nl802154_iftype type); 42 43 int (*set_channel)(struct wpan_phy *wpan_phy, u8 page, u8 channel); 43 44 int (*set_pan_id)(struct wpan_phy *wpan_phy, 44 45 struct wpan_dev *wpan_dev, u16 pan_id);
+34
net/ieee802154/nl802154.c
··· 551 551 return genlmsg_reply(msg, info); 552 552 } 553 553 554 + static int nl802154_new_interface(struct sk_buff *skb, struct genl_info *info) 555 + { 556 + struct cfg802154_registered_device *rdev = info->user_ptr[0]; 557 + enum nl802154_iftype type = NL802154_IFTYPE_UNSPEC; 558 + 559 + /* TODO avoid failing a new interface 560 + * creation due to pending removal? 561 + */ 562 + 563 + if (!info->attrs[NL802154_ATTR_IFNAME]) 564 + return -EINVAL; 565 + 566 + if (info->attrs[NL802154_ATTR_IFTYPE]) { 567 + type = nla_get_u32(info->attrs[NL802154_ATTR_IFTYPE]); 568 + if (type > NL802154_IFTYPE_MAX) 569 + return -EINVAL; 570 + } 571 + 572 + if (!rdev->ops->add_virtual_intf) 573 + return -EOPNOTSUPP; 574 + 575 + return rdev_add_virtual_intf(rdev, 576 + nla_data(info->attrs[NL802154_ATTR_IFNAME]), 577 + type); 578 + } 579 + 554 580 static int nl802154_set_channel(struct sk_buff *skb, struct genl_info *info) 555 581 { 556 582 struct cfg802154_registered_device *rdev = info->user_ptr[0]; ··· 842 816 .policy = nl802154_policy, 843 817 /* can be retrieved by unprivileged users */ 844 818 .internal_flags = NL802154_FLAG_NEED_WPAN_DEV | 819 + NL802154_FLAG_NEED_RTNL, 820 + }, 821 + { 822 + .cmd = NL802154_CMD_NEW_INTERFACE, 823 + .doit = nl802154_new_interface, 824 + .policy = nl802154_policy, 825 + .flags = GENL_ADMIN_PERM, 826 + .internal_flags = NL802154_FLAG_NEED_WPAN_PHY | 845 827 NL802154_FLAG_NEED_RTNL, 846 828 }, 847 829 {
+7
net/ieee802154/rdev-ops.h
··· 21 21 } 22 22 23 23 static inline int 24 + rdev_add_virtual_intf(struct cfg802154_registered_device *rdev, char *name, 25 + enum nl802154_iftype type) 26 + { 27 + return rdev->ops->add_virtual_intf(&rdev->wpan_phy, name, type); 28 + } 29 + 30 + static inline int 24 31 rdev_set_channel(struct cfg802154_registered_device *rdev, u8 page, u8 channel) 25 32 { 26 33 return rdev->ops->set_channel(&rdev->wpan_phy, page, channel);
+15
net/mac802154/cfg.c
··· 43 43 } 44 44 45 45 static int 46 + ieee802154_add_iface(struct wpan_phy *phy, const char *name, 47 + enum nl802154_iftype type) 48 + { 49 + struct ieee802154_local *local = wpan_phy_priv(phy); 50 + struct net_device *err; 51 + 52 + err = ieee802154_if_add(local, name, type); 53 + if (IS_ERR(err)) 54 + return PTR_ERR(err); 55 + 56 + return 0; 57 + } 58 + 59 + static int 46 60 ieee802154_set_channel(struct wpan_phy *wpan_phy, u8 page, u8 channel) 47 61 { 48 62 struct ieee802154_local *local = wpan_phy_priv(wpan_phy); ··· 189 175 const struct cfg802154_ops mac802154_config_ops = { 190 176 .add_virtual_intf_deprecated = ieee802154_add_iface_deprecated, 191 177 .del_virtual_intf_deprecated = ieee802154_del_iface_deprecated, 178 + .add_virtual_intf = ieee802154_add_iface, 192 179 .set_channel = ieee802154_set_channel, 193 180 .set_pan_id = ieee802154_set_pan_id, 194 181 .set_short_addr = ieee802154_set_short_addr,