mib.c (036562f9c4d942f2fbc77ae3215309bde340546f) | mib.c (04e850fe06312a9f570fcc7dbd0f141c012df404) |
---|---|
1/* 2 * Copyright 2007-2012 Siemens AG 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License version 2 6 * as published by the Free Software Foundation. 7 * 8 * This program is distributed in the hope that it will be useful, --- 28 unchanged lines hidden (view full) --- 37}; 38 39static struct ieee802154_local *mac802154_slave_get_priv(struct net_device *dev) 40{ 41 struct ieee802154_sub_if_data *sdata = netdev_priv(dev); 42 43 BUG_ON(dev->type != ARPHRD_IEEE802154); 44 | 1/* 2 * Copyright 2007-2012 Siemens AG 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License version 2 6 * as published by the Free Software Foundation. 7 * 8 * This program is distributed in the hope that it will be useful, --- 28 unchanged lines hidden (view full) --- 37}; 38 39static struct ieee802154_local *mac802154_slave_get_priv(struct net_device *dev) 40{ 41 struct ieee802154_sub_if_data *sdata = netdev_priv(dev); 42 43 BUG_ON(dev->type != ARPHRD_IEEE802154); 44 |
45 return sdata->hw; | 45 return sdata->local; |
46} 47 48static void hw_addr_notify(struct work_struct *work) 49{ 50 struct hw_addr_filt_notify_work *nw = container_of(work, 51 struct hw_addr_filt_notify_work, work); 52 struct ieee802154_local *local = mac802154_slave_get_priv(nw->dev); 53 int res; --- 13 unchanged lines hidden (view full) --- 67 68 work = kzalloc(sizeof(*work), GFP_ATOMIC); 69 if (!work) 70 return; 71 72 INIT_WORK(&work->work, hw_addr_notify); 73 work->dev = dev; 74 work->changed = changed; | 46} 47 48static void hw_addr_notify(struct work_struct *work) 49{ 50 struct hw_addr_filt_notify_work *nw = container_of(work, 51 struct hw_addr_filt_notify_work, work); 52 struct ieee802154_local *local = mac802154_slave_get_priv(nw->dev); 53 int res; --- 13 unchanged lines hidden (view full) --- 67 68 work = kzalloc(sizeof(*work), GFP_ATOMIC); 69 if (!work) 70 return; 71 72 INIT_WORK(&work->work, hw_addr_notify); 73 work->dev = dev; 74 work->changed = changed; |
75 queue_work(sdata->hw->dev_workqueue, &work->work); | 75 queue_work(sdata->local->dev_workqueue, &work->work); |
76} 77 78void mac802154_dev_set_short_addr(struct net_device *dev, __le16 val) 79{ 80 struct ieee802154_sub_if_data *sdata = netdev_priv(dev); 81 82 BUG_ON(dev->type != ARPHRD_IEEE802154); 83 84 spin_lock_bh(&sdata->mib_lock); 85 sdata->short_addr = val; 86 spin_unlock_bh(&sdata->mib_lock); 87 | 76} 77 78void mac802154_dev_set_short_addr(struct net_device *dev, __le16 val) 79{ 80 struct ieee802154_sub_if_data *sdata = netdev_priv(dev); 81 82 BUG_ON(dev->type != ARPHRD_IEEE802154); 83 84 spin_lock_bh(&sdata->mib_lock); 85 sdata->short_addr = val; 86 spin_unlock_bh(&sdata->mib_lock); 87 |
88 if ((sdata->hw->ops->set_hw_addr_filt) && 89 (sdata->hw->hw.hw_filt.short_addr != sdata->short_addr)) { 90 sdata->hw->hw.hw_filt.short_addr = sdata->short_addr; | 88 if ((sdata->local->ops->set_hw_addr_filt) && 89 (sdata->local->hw.hw_filt.short_addr != sdata->short_addr)) { 90 sdata->local->hw.hw_filt.short_addr = sdata->short_addr; |
91 set_hw_addr_filt(dev, IEEE802154_AFILT_SADDR_CHANGED); 92 } 93} 94 95__le16 mac802154_dev_get_short_addr(const struct net_device *dev) 96{ 97 struct ieee802154_sub_if_data *sdata = netdev_priv(dev); 98 __le16 ret; --- 5 unchanged lines hidden (view full) --- 104 spin_unlock_bh(&sdata->mib_lock); 105 106 return ret; 107} 108 109void mac802154_dev_set_ieee_addr(struct net_device *dev) 110{ 111 struct ieee802154_sub_if_data *sdata = netdev_priv(dev); | 91 set_hw_addr_filt(dev, IEEE802154_AFILT_SADDR_CHANGED); 92 } 93} 94 95__le16 mac802154_dev_get_short_addr(const struct net_device *dev) 96{ 97 struct ieee802154_sub_if_data *sdata = netdev_priv(dev); 98 __le16 ret; --- 5 unchanged lines hidden (view full) --- 104 spin_unlock_bh(&sdata->mib_lock); 105 106 return ret; 107} 108 109void mac802154_dev_set_ieee_addr(struct net_device *dev) 110{ 111 struct ieee802154_sub_if_data *sdata = netdev_priv(dev); |
112 struct ieee802154_local *local = sdata->hw; | 112 struct ieee802154_local *local = sdata->local; |
113 114 sdata->extended_addr = ieee802154_devaddr_from_raw(dev->dev_addr); 115 116 if (local->ops->set_hw_addr_filt && 117 local->hw.hw_filt.ieee_addr != sdata->extended_addr) { 118 local->hw.hw_filt.ieee_addr = sdata->extended_addr; 119 set_hw_addr_filt(dev, IEEE802154_AFILT_IEEEADDR_CHANGED); 120 } --- 18 unchanged lines hidden (view full) --- 139 struct ieee802154_sub_if_data *sdata = netdev_priv(dev); 140 141 BUG_ON(dev->type != ARPHRD_IEEE802154); 142 143 spin_lock_bh(&sdata->mib_lock); 144 sdata->pan_id = val; 145 spin_unlock_bh(&sdata->mib_lock); 146 | 113 114 sdata->extended_addr = ieee802154_devaddr_from_raw(dev->dev_addr); 115 116 if (local->ops->set_hw_addr_filt && 117 local->hw.hw_filt.ieee_addr != sdata->extended_addr) { 118 local->hw.hw_filt.ieee_addr = sdata->extended_addr; 119 set_hw_addr_filt(dev, IEEE802154_AFILT_IEEEADDR_CHANGED); 120 } --- 18 unchanged lines hidden (view full) --- 139 struct ieee802154_sub_if_data *sdata = netdev_priv(dev); 140 141 BUG_ON(dev->type != ARPHRD_IEEE802154); 142 143 spin_lock_bh(&sdata->mib_lock); 144 sdata->pan_id = val; 145 spin_unlock_bh(&sdata->mib_lock); 146 |
147 if ((sdata->hw->ops->set_hw_addr_filt) && 148 (sdata->hw->hw.hw_filt.pan_id != sdata->pan_id)) { 149 sdata->hw->hw.hw_filt.pan_id = sdata->pan_id; | 147 if ((sdata->local->ops->set_hw_addr_filt) && 148 (sdata->local->hw.hw_filt.pan_id != sdata->pan_id)) { 149 sdata->local->hw.hw_filt.pan_id = sdata->pan_id; |
150 set_hw_addr_filt(dev, IEEE802154_AFILT_PANID_CHANGED); 151 } 152} 153 154u8 mac802154_dev_get_dsn(const struct net_device *dev) 155{ 156 struct ieee802154_sub_if_data *sdata = netdev_priv(dev); 157 --- 5 unchanged lines hidden (view full) --- 163static void phy_chan_notify(struct work_struct *work) 164{ 165 struct phy_chan_notify_work *nw = container_of(work, 166 struct phy_chan_notify_work, work); 167 struct ieee802154_local *local = mac802154_slave_get_priv(nw->dev); 168 struct ieee802154_sub_if_data *sdata = netdev_priv(nw->dev); 169 int res; 170 | 150 set_hw_addr_filt(dev, IEEE802154_AFILT_PANID_CHANGED); 151 } 152} 153 154u8 mac802154_dev_get_dsn(const struct net_device *dev) 155{ 156 struct ieee802154_sub_if_data *sdata = netdev_priv(dev); 157 --- 5 unchanged lines hidden (view full) --- 163static void phy_chan_notify(struct work_struct *work) 164{ 165 struct phy_chan_notify_work *nw = container_of(work, 166 struct phy_chan_notify_work, work); 167 struct ieee802154_local *local = mac802154_slave_get_priv(nw->dev); 168 struct ieee802154_sub_if_data *sdata = netdev_priv(nw->dev); 169 int res; 170 |
171 mutex_lock(&sdata->hw->phy->pib_lock); | 171 mutex_lock(&sdata->local->phy->pib_lock); |
172 res = local->ops->set_channel(&local->hw, sdata->page, sdata->chan); 173 if (res) { 174 pr_debug("set_channel failed\n"); 175 } else { | 172 res = local->ops->set_channel(&local->hw, sdata->page, sdata->chan); 173 if (res) { 174 pr_debug("set_channel failed\n"); 175 } else { |
176 sdata->hw->phy->current_channel = sdata->chan; 177 sdata->hw->phy->current_page = sdata->page; | 176 sdata->local->phy->current_channel = sdata->chan; 177 sdata->local->phy->current_page = sdata->page; |
178 } | 178 } |
179 mutex_unlock(&sdata->hw->phy->pib_lock); | 179 mutex_unlock(&sdata->local->phy->pib_lock); |
180 181 kfree(nw); 182} 183 184void mac802154_dev_set_page_channel(struct net_device *dev, u8 page, u8 chan) 185{ 186 struct ieee802154_sub_if_data *sdata = netdev_priv(dev); 187 struct phy_chan_notify_work *work; 188 189 BUG_ON(dev->type != ARPHRD_IEEE802154); 190 191 spin_lock_bh(&sdata->mib_lock); 192 sdata->page = page; 193 sdata->chan = chan; 194 spin_unlock_bh(&sdata->mib_lock); 195 | 180 181 kfree(nw); 182} 183 184void mac802154_dev_set_page_channel(struct net_device *dev, u8 page, u8 chan) 185{ 186 struct ieee802154_sub_if_data *sdata = netdev_priv(dev); 187 struct phy_chan_notify_work *work; 188 189 BUG_ON(dev->type != ARPHRD_IEEE802154); 190 191 spin_lock_bh(&sdata->mib_lock); 192 sdata->page = page; 193 sdata->chan = chan; 194 spin_unlock_bh(&sdata->mib_lock); 195 |
196 mutex_lock(&sdata->hw->phy->pib_lock); 197 if (sdata->hw->phy->current_channel != sdata->chan || 198 sdata->hw->phy->current_page != sdata->page) { 199 mutex_unlock(&sdata->hw->phy->pib_lock); | 196 mutex_lock(&sdata->local->phy->pib_lock); 197 if (sdata->local->phy->current_channel != sdata->chan || 198 sdata->local->phy->current_page != sdata->page) { 199 mutex_unlock(&sdata->local->phy->pib_lock); |
200 201 work = kzalloc(sizeof(*work), GFP_ATOMIC); 202 if (!work) 203 return; 204 205 INIT_WORK(&work->work, phy_chan_notify); 206 work->dev = dev; | 200 201 work = kzalloc(sizeof(*work), GFP_ATOMIC); 202 if (!work) 203 return; 204 205 INIT_WORK(&work->work, phy_chan_notify); 206 work->dev = dev; |
207 queue_work(sdata->hw->dev_workqueue, &work->work); | 207 queue_work(sdata->local->dev_workqueue, &work->work); |
208 } else { | 208 } else { |
209 mutex_unlock(&sdata->hw->phy->pib_lock); | 209 mutex_unlock(&sdata->local->phy->pib_lock); |
210 } 211} 212 213 214int mac802154_get_params(struct net_device *dev, 215 struct ieee802154_llsec_params *params) 216{ 217 struct ieee802154_sub_if_data *sdata = netdev_priv(dev); --- 181 unchanged lines hidden --- | 210 } 211} 212 213 214int mac802154_get_params(struct net_device *dev, 215 struct ieee802154_llsec_params *params) 216{ 217 struct ieee802154_sub_if_data *sdata = netdev_priv(dev); --- 181 unchanged lines hidden --- |