1 // SPDX-License-Identifier: GPL-2.0-only << 2 /* 1 /* 3 * MAC commands interface 2 * MAC commands interface 4 * 3 * 5 * Copyright 2007-2012 Siemens AG 4 * Copyright 2007-2012 Siemens AG 6 * 5 * >> 6 * This program is free software; you can redistribute it and/or modify >> 7 * it under the terms of the GNU General Public License version 2 >> 8 * as published by the Free Software Foundation. >> 9 * >> 10 * This program is distributed in the hope that it will be useful, >> 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of >> 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >> 13 * GNU General Public License for more details. >> 14 * >> 15 * You should have received a copy of the GNU General Public License along >> 16 * with this program; if not, write to the Free Software Foundation, Inc., >> 17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >> 18 * 7 * Written by: 19 * Written by: 8 * Sergey Lapin <slapin@ossfans.org> 20 * Sergey Lapin <slapin@ossfans.org> 9 * Dmitry Eremin-Solenikov <dbaryshkov@gmail.c 21 * Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> 10 * Alexander Smirnov <alex.bluesman.smirnov@gm 22 * Alexander Smirnov <alex.bluesman.smirnov@gmail.com> 11 */ 23 */ 12 24 13 #include <linux/skbuff.h> 25 #include <linux/skbuff.h> 14 #include <linux/if_arp.h> 26 #include <linux/if_arp.h> 15 #include <linux/ieee802154.h> << 16 27 >> 28 #include <net/ieee802154.h> 17 #include <net/ieee802154_netdev.h> 29 #include <net/ieee802154_netdev.h> 18 #include <net/cfg802154.h> !! 30 #include <net/wpan-phy.h> 19 #include <net/mac802154.h> 31 #include <net/mac802154.h> >> 32 #include <net/nl802154.h> 20 33 21 #include "ieee802154_i.h" !! 34 #include "mac802154.h" 22 #include "driver-ops.h" << 23 35 24 static int mac802154_mlme_start_req(struct net 36 static int mac802154_mlme_start_req(struct net_device *dev, 25 struct iee 37 struct ieee802154_addr *addr, 26 u8 channel 38 u8 channel, u8 page, 27 u8 bcn_ord 39 u8 bcn_ord, u8 sf_ord, 28 u8 pan_coo 40 u8 pan_coord, u8 blx, 29 u8 coord_r 41 u8 coord_realign) 30 { 42 { 31 struct ieee802154_llsec_params params; !! 43 BUG_ON(addr->addr_type != IEEE802154_ADDR_SHORT); 32 int changed = 0; << 33 << 34 ASSERT_RTNL(); << 35 44 36 BUG_ON(addr->mode != IEEE802154_ADDR_S !! 45 mac802154_dev_set_pan_id(dev, addr->pan_id); 37 !! 46 mac802154_dev_set_short_addr(dev, addr->short_addr); 38 dev->ieee802154_ptr->pan_id = addr->pa !! 47 mac802154_dev_set_ieee_addr(dev); 39 dev->ieee802154_ptr->short_addr = addr << 40 mac802154_dev_set_page_channel(dev, pa 48 mac802154_dev_set_page_channel(dev, page, channel); 41 49 42 params.pan_id = addr->pan_id; !! 50 /* FIXME: add validation for unused parameters to be sane 43 changed |= IEEE802154_LLSEC_PARAM_PAN_ !! 51 * for SoftMAC 44 !! 52 */ 45 params.hwaddr = ieee802154_devaddr_fro !! 53 ieee802154_nl_start_confirm(dev, IEEE802154_SUCCESS); 46 changed |= IEEE802154_LLSEC_PARAM_HWAD << 47 << 48 params.coord_hwaddr = params.hwaddr; << 49 changed |= IEEE802154_LLSEC_PARAM_COOR << 50 << 51 params.coord_shortaddr = addr->short_a << 52 changed |= IEEE802154_LLSEC_PARAM_COOR << 53 << 54 return mac802154_set_params(dev, ¶ << 55 } << 56 << 57 static int mac802154_set_mac_params(struct net << 58 const stru << 59 { << 60 struct ieee802154_sub_if_data *sdata = << 61 struct ieee802154_local *local = sdata << 62 struct wpan_dev *wpan_dev = &sdata->wp << 63 int ret; << 64 << 65 ASSERT_RTNL(); << 66 << 67 /* PHY */ << 68 wpan_dev->wpan_phy->transmit_power = p << 69 wpan_dev->wpan_phy->cca = params->cca; << 70 wpan_dev->wpan_phy->cca_ed_level = par << 71 << 72 /* MAC */ << 73 wpan_dev->min_be = params->min_be; << 74 wpan_dev->max_be = params->max_be; << 75 wpan_dev->csma_retries = params->csma_ << 76 wpan_dev->frame_retries = params->fram << 77 wpan_dev->lbt = params->lbt; << 78 << 79 if (local->hw.phy->flags & WPAN_PHY_FL << 80 ret = drv_set_tx_power(local, << 81 if (ret < 0) << 82 return ret; << 83 } << 84 << 85 if (local->hw.phy->flags & WPAN_PHY_FL << 86 ret = drv_set_cca_mode(local, << 87 if (ret < 0) << 88 return ret; << 89 } << 90 << 91 if (local->hw.phy->flags & WPAN_PHY_FL << 92 ret = drv_set_cca_ed_level(loc << 93 if (ret < 0) << 94 return ret; << 95 } << 96 54 97 return 0; 55 return 0; 98 } 56 } 99 57 100 static void mac802154_get_mac_params(struct ne !! 58 static struct wpan_phy *mac802154_get_phy(const struct net_device *dev) 101 struct ie << 102 { 59 { 103 struct ieee802154_sub_if_data *sdata = !! 60 struct mac802154_sub_if_data *priv = netdev_priv(dev); 104 struct wpan_dev *wpan_dev = &sdata->wp << 105 61 106 ASSERT_RTNL(); !! 62 BUG_ON(dev->type != ARPHRD_IEEE802154); 107 63 108 /* PHY */ !! 64 return to_phy(get_device(&priv->hw->phy->dev)); 109 params->transmit_power = wpan_dev->wpa << 110 params->cca = wpan_dev->wpan_phy->cca; << 111 params->cca_ed_level = wpan_dev->wpan_ << 112 << 113 /* MAC */ << 114 params->min_be = wpan_dev->min_be; << 115 params->max_be = wpan_dev->max_be; << 116 params->csma_retries = wpan_dev->csma_ << 117 params->frame_retries = wpan_dev->fram << 118 params->lbt = wpan_dev->lbt; << 119 } 65 } 120 66 121 static const struct ieee802154_llsec_ops mac80 !! 67 struct ieee802154_reduced_mlme_ops mac802154_mlme_reduced = { 122 .get_params = mac802154_get_params, !! 68 .get_phy = mac802154_get_phy, 123 .set_params = mac802154_set_params, << 124 .add_key = mac802154_add_key, << 125 .del_key = mac802154_del_key, << 126 .add_dev = mac802154_add_dev, << 127 .del_dev = mac802154_del_dev, << 128 .add_devkey = mac802154_add_devkey, << 129 .del_devkey = mac802154_del_devkey, << 130 .add_seclevel = mac802154_add_seclevel << 131 .del_seclevel = mac802154_del_seclevel << 132 .lock_table = mac802154_lock_table, << 133 .get_table = mac802154_get_table, << 134 .unlock_table = mac802154_unlock_table << 135 }; 69 }; 136 70 137 struct ieee802154_mlme_ops mac802154_mlme_wpan 71 struct ieee802154_mlme_ops mac802154_mlme_wpan = { >> 72 .get_phy = mac802154_get_phy, 138 .start_req = mac802154_mlme_start_req, 73 .start_req = mac802154_mlme_start_req, 139 !! 74 .get_pan_id = mac802154_dev_get_pan_id, 140 .llsec = &mac802154_llsec_ops, !! 75 .get_short_addr = mac802154_dev_get_short_addr, 141 !! 76 .get_dsn = mac802154_dev_get_dsn, 142 .set_mac_params = mac802154_set_mac_pa << 143 .get_mac_params = mac802154_get_mac_pa << 144 }; 77 }; 145 78
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.