ieee802154_i.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) 2007-2012 Siemens AG
  4. *
  5. * Written by:
  6. * Pavel Smolenskiy <[email protected]>
  7. * Maxim Gorbachyov <[email protected]>
  8. * Dmitry Eremin-Solenikov <[email protected]>
  9. * Alexander Smirnov <[email protected]>
  10. */
  11. #ifndef __IEEE802154_I_H
  12. #define __IEEE802154_I_H
  13. #include <linux/interrupt.h>
  14. #include <linux/mutex.h>
  15. #include <linux/hrtimer.h>
  16. #include <net/cfg802154.h>
  17. #include <net/mac802154.h>
  18. #include <net/nl802154.h>
  19. #include <net/ieee802154_netdev.h>
  20. #include "llsec.h"
  21. /* mac802154 device private data */
  22. struct ieee802154_local {
  23. struct ieee802154_hw hw;
  24. const struct ieee802154_ops *ops;
  25. /* ieee802154 phy */
  26. struct wpan_phy *phy;
  27. int open_count;
  28. /* As in mac80211 slaves list is modified:
  29. * 1) under the RTNL
  30. * 2) protected by slaves_mtx;
  31. * 3) in an RCU manner
  32. *
  33. * So atomic readers can use any of this protection methods.
  34. */
  35. struct list_head interfaces;
  36. struct mutex iflist_mtx;
  37. /* This one is used for scanning and other jobs not to be interfered
  38. * with serial driver.
  39. */
  40. struct workqueue_struct *workqueue;
  41. struct hrtimer ifs_timer;
  42. bool started;
  43. bool suspended;
  44. struct tasklet_struct tasklet;
  45. struct sk_buff_head skb_queue;
  46. struct sk_buff *tx_skb;
  47. struct work_struct tx_work;
  48. /* A negative Linux error code or a null/positive MLME error status */
  49. int tx_result;
  50. };
  51. enum {
  52. IEEE802154_RX_MSG = 1,
  53. };
  54. enum ieee802154_sdata_state_bits {
  55. SDATA_STATE_RUNNING,
  56. };
  57. /* Slave interface definition.
  58. *
  59. * Slaves represent typical network interfaces available from userspace.
  60. * Each ieee802154 device/transceiver may have several slaves and able
  61. * to be associated with several networks at the same time.
  62. */
  63. struct ieee802154_sub_if_data {
  64. struct list_head list; /* the ieee802154_priv->slaves list */
  65. struct wpan_dev wpan_dev;
  66. struct ieee802154_local *local;
  67. struct net_device *dev;
  68. unsigned long state;
  69. char name[IFNAMSIZ];
  70. /* protects sec from concurrent access by netlink. access by
  71. * encrypt/decrypt/header_create safe without additional protection.
  72. */
  73. struct mutex sec_mtx;
  74. struct mac802154_llsec sec;
  75. };
  76. /* utility functions/constants */
  77. extern const void *const mac802154_wpan_phy_privid; /* for wpan_phy privid */
  78. static inline struct ieee802154_local *
  79. hw_to_local(struct ieee802154_hw *hw)
  80. {
  81. return container_of(hw, struct ieee802154_local, hw);
  82. }
  83. static inline struct ieee802154_sub_if_data *
  84. IEEE802154_DEV_TO_SUB_IF(const struct net_device *dev)
  85. {
  86. return netdev_priv(dev);
  87. }
  88. static inline struct ieee802154_sub_if_data *
  89. IEEE802154_WPAN_DEV_TO_SUB_IF(struct wpan_dev *wpan_dev)
  90. {
  91. return container_of(wpan_dev, struct ieee802154_sub_if_data, wpan_dev);
  92. }
  93. static inline bool
  94. ieee802154_sdata_running(struct ieee802154_sub_if_data *sdata)
  95. {
  96. return test_bit(SDATA_STATE_RUNNING, &sdata->state);
  97. }
  98. extern struct ieee802154_mlme_ops mac802154_mlme_wpan;
  99. void ieee802154_rx(struct ieee802154_local *local, struct sk_buff *skb);
  100. void ieee802154_xmit_worker(struct work_struct *work);
  101. netdev_tx_t
  102. ieee802154_monitor_start_xmit(struct sk_buff *skb, struct net_device *dev);
  103. netdev_tx_t
  104. ieee802154_subif_start_xmit(struct sk_buff *skb, struct net_device *dev);
  105. enum hrtimer_restart ieee802154_xmit_ifs_timer(struct hrtimer *timer);
  106. /* MIB callbacks */
  107. void mac802154_dev_set_page_channel(struct net_device *dev, u8 page, u8 chan);
  108. int mac802154_get_params(struct net_device *dev,
  109. struct ieee802154_llsec_params *params);
  110. int mac802154_set_params(struct net_device *dev,
  111. const struct ieee802154_llsec_params *params,
  112. int changed);
  113. int mac802154_add_key(struct net_device *dev,
  114. const struct ieee802154_llsec_key_id *id,
  115. const struct ieee802154_llsec_key *key);
  116. int mac802154_del_key(struct net_device *dev,
  117. const struct ieee802154_llsec_key_id *id);
  118. int mac802154_add_dev(struct net_device *dev,
  119. const struct ieee802154_llsec_device *llsec_dev);
  120. int mac802154_del_dev(struct net_device *dev, __le64 dev_addr);
  121. int mac802154_add_devkey(struct net_device *dev,
  122. __le64 device_addr,
  123. const struct ieee802154_llsec_device_key *key);
  124. int mac802154_del_devkey(struct net_device *dev,
  125. __le64 device_addr,
  126. const struct ieee802154_llsec_device_key *key);
  127. int mac802154_add_seclevel(struct net_device *dev,
  128. const struct ieee802154_llsec_seclevel *sl);
  129. int mac802154_del_seclevel(struct net_device *dev,
  130. const struct ieee802154_llsec_seclevel *sl);
  131. void mac802154_lock_table(struct net_device *dev);
  132. void mac802154_get_table(struct net_device *dev,
  133. struct ieee802154_llsec_table **t);
  134. void mac802154_unlock_table(struct net_device *dev);
  135. int mac802154_wpan_update_llsec(struct net_device *dev);
  136. /* interface handling */
  137. int ieee802154_iface_init(void);
  138. void ieee802154_iface_exit(void);
  139. void ieee802154_if_remove(struct ieee802154_sub_if_data *sdata);
  140. struct net_device *
  141. ieee802154_if_add(struct ieee802154_local *local, const char *name,
  142. unsigned char name_assign_type, enum nl802154_iftype type,
  143. __le64 extended_addr);
  144. void ieee802154_remove_interfaces(struct ieee802154_local *local);
  145. void ieee802154_stop_device(struct ieee802154_local *local);
  146. #endif /* __IEEE802154_I_H */