diff options
Diffstat (limited to 'net/mac802154/main.c')
-rw-r--r-- | net/mac802154/main.c | 172 |
1 files changed, 86 insertions, 86 deletions
diff --git a/net/mac802154/main.c b/net/mac802154/main.c index b0bcc063e9af..387d4cf94853 100644 --- a/net/mac802154/main.c +++ b/net/mac802154/main.c | |||
@@ -33,7 +33,7 @@ int mac802154_slave_open(struct net_device *dev) | |||
33 | { | 33 | { |
34 | struct mac802154_sub_if_data *priv = netdev_priv(dev); | 34 | struct mac802154_sub_if_data *priv = netdev_priv(dev); |
35 | struct mac802154_sub_if_data *subif; | 35 | struct mac802154_sub_if_data *subif; |
36 | struct mac802154_priv *ipriv = priv->hw; | 36 | struct ieee802154_local *local = priv->hw; |
37 | int res = 0; | 37 | int res = 0; |
38 | 38 | ||
39 | ASSERT_RTNL(); | 39 | ASSERT_RTNL(); |
@@ -54,17 +54,17 @@ int mac802154_slave_open(struct net_device *dev) | |||
54 | priv->running = true; | 54 | priv->running = true; |
55 | mutex_unlock(&priv->hw->slaves_mtx); | 55 | mutex_unlock(&priv->hw->slaves_mtx); |
56 | 56 | ||
57 | if (ipriv->open_count++ == 0) { | 57 | if (local->open_count++ == 0) { |
58 | res = ipriv->ops->start(&ipriv->hw); | 58 | res = local->ops->start(&local->hw); |
59 | WARN_ON(res); | 59 | WARN_ON(res); |
60 | if (res) | 60 | if (res) |
61 | goto err; | 61 | goto err; |
62 | } | 62 | } |
63 | 63 | ||
64 | if (ipriv->ops->ieee_addr) { | 64 | if (local->ops->ieee_addr) { |
65 | __le64 addr = ieee802154_devaddr_from_raw(dev->dev_addr); | 65 | __le64 addr = ieee802154_devaddr_from_raw(dev->dev_addr); |
66 | 66 | ||
67 | res = ipriv->ops->ieee_addr(&ipriv->hw, addr); | 67 | res = local->ops->ieee_addr(&local->hw, addr); |
68 | WARN_ON(res); | 68 | WARN_ON(res); |
69 | if (res) | 69 | if (res) |
70 | goto err; | 70 | goto err; |
@@ -82,7 +82,7 @@ err: | |||
82 | int mac802154_slave_close(struct net_device *dev) | 82 | int mac802154_slave_close(struct net_device *dev) |
83 | { | 83 | { |
84 | struct mac802154_sub_if_data *priv = netdev_priv(dev); | 84 | struct mac802154_sub_if_data *priv = netdev_priv(dev); |
85 | struct mac802154_priv *ipriv = priv->hw; | 85 | struct ieee802154_local *local = priv->hw; |
86 | 86 | ||
87 | ASSERT_RTNL(); | 87 | ASSERT_RTNL(); |
88 | 88 | ||
@@ -92,8 +92,8 @@ int mac802154_slave_close(struct net_device *dev) | |||
92 | priv->running = false; | 92 | priv->running = false; |
93 | mutex_unlock(&priv->hw->slaves_mtx); | 93 | mutex_unlock(&priv->hw->slaves_mtx); |
94 | 94 | ||
95 | if (!--ipriv->open_count) | 95 | if (!--local->open_count) |
96 | ipriv->ops->stop(&ipriv->hw); | 96 | local->ops->stop(&local->hw); |
97 | 97 | ||
98 | return 0; | 98 | return 0; |
99 | } | 99 | } |
@@ -102,34 +102,34 @@ static int | |||
102 | mac802154_netdev_register(struct wpan_phy *phy, struct net_device *dev) | 102 | mac802154_netdev_register(struct wpan_phy *phy, struct net_device *dev) |
103 | { | 103 | { |
104 | struct mac802154_sub_if_data *priv; | 104 | struct mac802154_sub_if_data *priv; |
105 | struct mac802154_priv *ipriv; | 105 | struct ieee802154_local *local; |
106 | int err; | 106 | int err; |
107 | 107 | ||
108 | ipriv = wpan_phy_priv(phy); | 108 | local = wpan_phy_priv(phy); |
109 | 109 | ||
110 | priv = netdev_priv(dev); | 110 | priv = netdev_priv(dev); |
111 | priv->dev = dev; | 111 | priv->dev = dev; |
112 | priv->hw = ipriv; | 112 | priv->hw = local; |
113 | 113 | ||
114 | dev->needed_headroom = ipriv->hw.extra_tx_headroom; | 114 | dev->needed_headroom = local->hw.extra_tx_headroom; |
115 | 115 | ||
116 | SET_NETDEV_DEV(dev, &ipriv->phy->dev); | 116 | SET_NETDEV_DEV(dev, &local->phy->dev); |
117 | 117 | ||
118 | mutex_lock(&ipriv->slaves_mtx); | 118 | mutex_lock(&local->slaves_mtx); |
119 | if (!ipriv->running) { | 119 | if (!local->running) { |
120 | mutex_unlock(&ipriv->slaves_mtx); | 120 | mutex_unlock(&local->slaves_mtx); |
121 | return -ENODEV; | 121 | return -ENODEV; |
122 | } | 122 | } |
123 | mutex_unlock(&ipriv->slaves_mtx); | 123 | mutex_unlock(&local->slaves_mtx); |
124 | 124 | ||
125 | err = register_netdev(dev); | 125 | err = register_netdev(dev); |
126 | if (err < 0) | 126 | if (err < 0) |
127 | return err; | 127 | return err; |
128 | 128 | ||
129 | rtnl_lock(); | 129 | rtnl_lock(); |
130 | mutex_lock(&ipriv->slaves_mtx); | 130 | mutex_lock(&local->slaves_mtx); |
131 | list_add_tail_rcu(&priv->list, &ipriv->slaves); | 131 | list_add_tail_rcu(&priv->list, &local->slaves); |
132 | mutex_unlock(&ipriv->slaves_mtx); | 132 | mutex_unlock(&local->slaves_mtx); |
133 | rtnl_unlock(); | 133 | rtnl_unlock(); |
134 | 134 | ||
135 | return 0; | 135 | return 0; |
@@ -194,52 +194,52 @@ err: | |||
194 | 194 | ||
195 | static int mac802154_set_txpower(struct wpan_phy *phy, int db) | 195 | static int mac802154_set_txpower(struct wpan_phy *phy, int db) |
196 | { | 196 | { |
197 | struct mac802154_priv *priv = wpan_phy_priv(phy); | 197 | struct ieee802154_local *local = wpan_phy_priv(phy); |
198 | 198 | ||
199 | return priv->ops->set_txpower(&priv->hw, db); | 199 | return local->ops->set_txpower(&local->hw, db); |
200 | } | 200 | } |
201 | 201 | ||
202 | static int mac802154_set_lbt(struct wpan_phy *phy, bool on) | 202 | static int mac802154_set_lbt(struct wpan_phy *phy, bool on) |
203 | { | 203 | { |
204 | struct mac802154_priv *priv = wpan_phy_priv(phy); | 204 | struct ieee802154_local *local = wpan_phy_priv(phy); |
205 | 205 | ||
206 | return priv->ops->set_lbt(&priv->hw, on); | 206 | return local->ops->set_lbt(&local->hw, on); |
207 | } | 207 | } |
208 | 208 | ||
209 | static int mac802154_set_cca_mode(struct wpan_phy *phy, u8 mode) | 209 | static int mac802154_set_cca_mode(struct wpan_phy *phy, u8 mode) |
210 | { | 210 | { |
211 | struct mac802154_priv *priv = wpan_phy_priv(phy); | 211 | struct ieee802154_local *local = wpan_phy_priv(phy); |
212 | 212 | ||
213 | return priv->ops->set_cca_mode(&priv->hw, mode); | 213 | return local->ops->set_cca_mode(&local->hw, mode); |
214 | } | 214 | } |
215 | 215 | ||
216 | static int mac802154_set_cca_ed_level(struct wpan_phy *phy, s32 level) | 216 | static int mac802154_set_cca_ed_level(struct wpan_phy *phy, s32 level) |
217 | { | 217 | { |
218 | struct mac802154_priv *priv = wpan_phy_priv(phy); | 218 | struct ieee802154_local *local = wpan_phy_priv(phy); |
219 | 219 | ||
220 | return priv->ops->set_cca_ed_level(&priv->hw, level); | 220 | return local->ops->set_cca_ed_level(&local->hw, level); |
221 | } | 221 | } |
222 | 222 | ||
223 | static int mac802154_set_csma_params(struct wpan_phy *phy, u8 min_be, | 223 | static int mac802154_set_csma_params(struct wpan_phy *phy, u8 min_be, |
224 | u8 max_be, u8 retries) | 224 | u8 max_be, u8 retries) |
225 | { | 225 | { |
226 | struct mac802154_priv *priv = wpan_phy_priv(phy); | 226 | struct ieee802154_local *local = wpan_phy_priv(phy); |
227 | 227 | ||
228 | return priv->ops->set_csma_params(&priv->hw, min_be, max_be, retries); | 228 | return local->ops->set_csma_params(&local->hw, min_be, max_be, retries); |
229 | } | 229 | } |
230 | 230 | ||
231 | static int mac802154_set_frame_retries(struct wpan_phy *phy, s8 retries) | 231 | static int mac802154_set_frame_retries(struct wpan_phy *phy, s8 retries) |
232 | { | 232 | { |
233 | struct mac802154_priv *priv = wpan_phy_priv(phy); | 233 | struct ieee802154_local *local = wpan_phy_priv(phy); |
234 | 234 | ||
235 | return priv->ops->set_frame_retries(&priv->hw, retries); | 235 | return local->ops->set_frame_retries(&local->hw, retries); |
236 | } | 236 | } |
237 | 237 | ||
238 | struct ieee802154_hw * | 238 | struct ieee802154_hw * |
239 | ieee802154_alloc_hw(size_t priv_data_len, struct ieee802154_ops *ops) | 239 | ieee802154_alloc_hw(size_t priv_data_len, struct ieee802154_ops *ops) |
240 | { | 240 | { |
241 | struct wpan_phy *phy; | 241 | struct wpan_phy *phy; |
242 | struct mac802154_priv *priv; | 242 | struct ieee802154_local *local; |
243 | size_t priv_size; | 243 | size_t priv_size; |
244 | 244 | ||
245 | if (!ops || !ops->xmit || !ops->ed || !ops->start || | 245 | if (!ops || !ops->xmit || !ops->ed || !ops->start || |
@@ -249,24 +249,24 @@ ieee802154_alloc_hw(size_t priv_data_len, struct ieee802154_ops *ops) | |||
249 | } | 249 | } |
250 | 250 | ||
251 | /* Ensure 32-byte alignment of our private data and hw private data. | 251 | /* Ensure 32-byte alignment of our private data and hw private data. |
252 | * We use the wpan_phy priv data for both our mac802154_priv and for | 252 | * We use the wpan_phy priv data for both our ieee802154_local and for |
253 | * the driver's private data | 253 | * the driver's private data |
254 | * | 254 | * |
255 | * in memory it'll be like this: | 255 | * in memory it'll be like this: |
256 | * | 256 | * |
257 | * +-----------------------+ | 257 | * +-------------------------+ |
258 | * | struct wpan_phy | | 258 | * | struct wpan_phy | |
259 | * +-----------------------+ | 259 | * +-------------------------+ |
260 | * | struct mac802154_priv | | 260 | * | struct ieee802154_local | |
261 | * +-----------------------+ | 261 | * +-------------------------+ |
262 | * | driver's private data | | 262 | * | driver's private data | |
263 | * +-----------------------+ | 263 | * +-------------------------+ |
264 | * | 264 | * |
265 | * Due to ieee802154 layer isn't aware of driver and MAC structures, | 265 | * Due to ieee802154 layer isn't aware of driver and MAC structures, |
266 | * so lets align them here. | 266 | * so lets align them here. |
267 | */ | 267 | */ |
268 | 268 | ||
269 | priv_size = ALIGN(sizeof(*priv), NETDEV_ALIGN) + priv_data_len; | 269 | priv_size = ALIGN(sizeof(*local), NETDEV_ALIGN) + priv_data_len; |
270 | 270 | ||
271 | phy = wpan_phy_alloc(priv_size); | 271 | phy = wpan_phy_alloc(priv_size); |
272 | if (!phy) { | 272 | if (!phy) { |
@@ -274,106 +274,106 @@ ieee802154_alloc_hw(size_t priv_data_len, struct ieee802154_ops *ops) | |||
274 | return NULL; | 274 | return NULL; |
275 | } | 275 | } |
276 | 276 | ||
277 | priv = wpan_phy_priv(phy); | 277 | local = wpan_phy_priv(phy); |
278 | priv->phy = phy; | 278 | local->phy = phy; |
279 | priv->hw.phy = priv->phy; | 279 | local->hw.phy = local->phy; |
280 | priv->hw.priv = (char *)priv + ALIGN(sizeof(*priv), NETDEV_ALIGN); | 280 | local->hw.priv = (char *)local + ALIGN(sizeof(*local), NETDEV_ALIGN); |
281 | priv->ops = ops; | 281 | local->ops = ops; |
282 | 282 | ||
283 | INIT_LIST_HEAD(&priv->slaves); | 283 | INIT_LIST_HEAD(&local->slaves); |
284 | mutex_init(&priv->slaves_mtx); | 284 | mutex_init(&local->slaves_mtx); |
285 | 285 | ||
286 | return &priv->hw; | 286 | return &local->hw; |
287 | } | 287 | } |
288 | EXPORT_SYMBOL(ieee802154_alloc_hw); | 288 | EXPORT_SYMBOL(ieee802154_alloc_hw); |
289 | 289 | ||
290 | void ieee802154_free_hw(struct ieee802154_hw *hw) | 290 | void ieee802154_free_hw(struct ieee802154_hw *hw) |
291 | { | 291 | { |
292 | struct mac802154_priv *priv = mac802154_to_priv(hw); | 292 | struct ieee802154_local *local = mac802154_to_priv(hw); |
293 | 293 | ||
294 | BUG_ON(!list_empty(&priv->slaves)); | 294 | BUG_ON(!list_empty(&local->slaves)); |
295 | 295 | ||
296 | mutex_destroy(&priv->slaves_mtx); | 296 | mutex_destroy(&local->slaves_mtx); |
297 | 297 | ||
298 | wpan_phy_free(priv->phy); | 298 | wpan_phy_free(local->phy); |
299 | } | 299 | } |
300 | EXPORT_SYMBOL(ieee802154_free_hw); | 300 | EXPORT_SYMBOL(ieee802154_free_hw); |
301 | 301 | ||
302 | int ieee802154_register_hw(struct ieee802154_hw *hw) | 302 | int ieee802154_register_hw(struct ieee802154_hw *hw) |
303 | { | 303 | { |
304 | struct mac802154_priv *priv = mac802154_to_priv(hw); | 304 | struct ieee802154_local *local = mac802154_to_priv(hw); |
305 | int rc = -ENOSYS; | 305 | int rc = -ENOSYS; |
306 | 306 | ||
307 | if (hw->flags & IEEE802154_HW_TXPOWER) { | 307 | if (hw->flags & IEEE802154_HW_TXPOWER) { |
308 | if (!priv->ops->set_txpower) | 308 | if (!local->ops->set_txpower) |
309 | goto out; | 309 | goto out; |
310 | 310 | ||
311 | priv->phy->set_txpower = mac802154_set_txpower; | 311 | local->phy->set_txpower = mac802154_set_txpower; |
312 | } | 312 | } |
313 | 313 | ||
314 | if (hw->flags & IEEE802154_HW_LBT) { | 314 | if (hw->flags & IEEE802154_HW_LBT) { |
315 | if (!priv->ops->set_lbt) | 315 | if (!local->ops->set_lbt) |
316 | goto out; | 316 | goto out; |
317 | 317 | ||
318 | priv->phy->set_lbt = mac802154_set_lbt; | 318 | local->phy->set_lbt = mac802154_set_lbt; |
319 | } | 319 | } |
320 | 320 | ||
321 | if (hw->flags & IEEE802154_HW_CCA_MODE) { | 321 | if (hw->flags & IEEE802154_HW_CCA_MODE) { |
322 | if (!priv->ops->set_cca_mode) | 322 | if (!local->ops->set_cca_mode) |
323 | goto out; | 323 | goto out; |
324 | 324 | ||
325 | priv->phy->set_cca_mode = mac802154_set_cca_mode; | 325 | local->phy->set_cca_mode = mac802154_set_cca_mode; |
326 | } | 326 | } |
327 | 327 | ||
328 | if (hw->flags & IEEE802154_HW_CCA_ED_LEVEL) { | 328 | if (hw->flags & IEEE802154_HW_CCA_ED_LEVEL) { |
329 | if (!priv->ops->set_cca_ed_level) | 329 | if (!local->ops->set_cca_ed_level) |
330 | goto out; | 330 | goto out; |
331 | 331 | ||
332 | priv->phy->set_cca_ed_level = mac802154_set_cca_ed_level; | 332 | local->phy->set_cca_ed_level = mac802154_set_cca_ed_level; |
333 | } | 333 | } |
334 | 334 | ||
335 | if (hw->flags & IEEE802154_HW_CSMA_PARAMS) { | 335 | if (hw->flags & IEEE802154_HW_CSMA_PARAMS) { |
336 | if (!priv->ops->set_csma_params) | 336 | if (!local->ops->set_csma_params) |
337 | goto out; | 337 | goto out; |
338 | 338 | ||
339 | priv->phy->set_csma_params = mac802154_set_csma_params; | 339 | local->phy->set_csma_params = mac802154_set_csma_params; |
340 | } | 340 | } |
341 | 341 | ||
342 | if (hw->flags & IEEE802154_HW_FRAME_RETRIES) { | 342 | if (hw->flags & IEEE802154_HW_FRAME_RETRIES) { |
343 | if (!priv->ops->set_frame_retries) | 343 | if (!local->ops->set_frame_retries) |
344 | goto out; | 344 | goto out; |
345 | 345 | ||
346 | priv->phy->set_frame_retries = mac802154_set_frame_retries; | 346 | local->phy->set_frame_retries = mac802154_set_frame_retries; |
347 | } | 347 | } |
348 | 348 | ||
349 | priv->dev_workqueue = | 349 | local->dev_workqueue = |
350 | create_singlethread_workqueue(wpan_phy_name(priv->phy)); | 350 | create_singlethread_workqueue(wpan_phy_name(local->phy)); |
351 | if (!priv->dev_workqueue) { | 351 | if (!local->dev_workqueue) { |
352 | rc = -ENOMEM; | 352 | rc = -ENOMEM; |
353 | goto out; | 353 | goto out; |
354 | } | 354 | } |
355 | 355 | ||
356 | wpan_phy_set_dev(priv->phy, priv->hw.parent); | 356 | wpan_phy_set_dev(local->phy, local->hw.parent); |
357 | 357 | ||
358 | priv->phy->add_iface = mac802154_add_iface; | 358 | local->phy->add_iface = mac802154_add_iface; |
359 | priv->phy->del_iface = mac802154_del_iface; | 359 | local->phy->del_iface = mac802154_del_iface; |
360 | 360 | ||
361 | rc = wpan_phy_register(priv->phy); | 361 | rc = wpan_phy_register(local->phy); |
362 | if (rc < 0) | 362 | if (rc < 0) |
363 | goto out_wq; | 363 | goto out_wq; |
364 | 364 | ||
365 | rtnl_lock(); | 365 | rtnl_lock(); |
366 | 366 | ||
367 | mutex_lock(&priv->slaves_mtx); | 367 | mutex_lock(&local->slaves_mtx); |
368 | priv->running = MAC802154_DEVICE_RUN; | 368 | local->running = MAC802154_DEVICE_RUN; |
369 | mutex_unlock(&priv->slaves_mtx); | 369 | mutex_unlock(&local->slaves_mtx); |
370 | 370 | ||
371 | rtnl_unlock(); | 371 | rtnl_unlock(); |
372 | 372 | ||
373 | return 0; | 373 | return 0; |
374 | 374 | ||
375 | out_wq: | 375 | out_wq: |
376 | destroy_workqueue(priv->dev_workqueue); | 376 | destroy_workqueue(local->dev_workqueue); |
377 | out: | 377 | out: |
378 | return rc; | 378 | return rc; |
379 | } | 379 | } |
@@ -381,19 +381,19 @@ EXPORT_SYMBOL(ieee802154_register_hw); | |||
381 | 381 | ||
382 | void ieee802154_unregister_hw(struct ieee802154_hw *hw) | 382 | void ieee802154_unregister_hw(struct ieee802154_hw *hw) |
383 | { | 383 | { |
384 | struct mac802154_priv *priv = mac802154_to_priv(hw); | 384 | struct ieee802154_local *local = mac802154_to_priv(hw); |
385 | struct mac802154_sub_if_data *sdata, *next; | 385 | struct mac802154_sub_if_data *sdata, *next; |
386 | 386 | ||
387 | flush_workqueue(priv->dev_workqueue); | 387 | flush_workqueue(local->dev_workqueue); |
388 | destroy_workqueue(priv->dev_workqueue); | 388 | destroy_workqueue(local->dev_workqueue); |
389 | 389 | ||
390 | rtnl_lock(); | 390 | rtnl_lock(); |
391 | 391 | ||
392 | mutex_lock(&priv->slaves_mtx); | 392 | mutex_lock(&local->slaves_mtx); |
393 | priv->running = MAC802154_DEVICE_STOPPED; | 393 | local->running = MAC802154_DEVICE_STOPPED; |
394 | mutex_unlock(&priv->slaves_mtx); | 394 | mutex_unlock(&local->slaves_mtx); |
395 | 395 | ||
396 | list_for_each_entry_safe(sdata, next, &priv->slaves, list) { | 396 | list_for_each_entry_safe(sdata, next, &local->slaves, list) { |
397 | mutex_lock(&sdata->hw->slaves_mtx); | 397 | mutex_lock(&sdata->hw->slaves_mtx); |
398 | list_del(&sdata->list); | 398 | list_del(&sdata->list); |
399 | mutex_unlock(&sdata->hw->slaves_mtx); | 399 | mutex_unlock(&sdata->hw->slaves_mtx); |
@@ -403,7 +403,7 @@ void ieee802154_unregister_hw(struct ieee802154_hw *hw) | |||
403 | 403 | ||
404 | rtnl_unlock(); | 404 | rtnl_unlock(); |
405 | 405 | ||
406 | wpan_phy_unregister(priv->phy); | 406 | wpan_phy_unregister(local->phy); |
407 | } | 407 | } |
408 | EXPORT_SYMBOL(ieee802154_unregister_hw); | 408 | EXPORT_SYMBOL(ieee802154_unregister_hw); |
409 | 409 | ||