mac802154.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /*
  2. * Copyright (C) 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,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License along
  14. * with this program; if not, write to the Free Software Foundation, Inc.,
  15. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  16. *
  17. * Written by:
  18. * Pavel Smolenskiy <pavel.smolenskiy@gmail.com>
  19. * Maxim Gorbachyov <maxim.gorbachev@siemens.com>
  20. * Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
  21. * Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
  22. */
  23. #ifndef MAC802154_H
  24. #define MAC802154_H
  25. #include <linux/mutex.h>
  26. #include <net/mac802154.h>
  27. #include <net/ieee802154_netdev.h>
  28. #include "llsec.h"
  29. /* mac802154 device private data */
  30. struct mac802154_priv {
  31. struct ieee802154_dev hw;
  32. struct ieee802154_ops *ops;
  33. /* ieee802154 phy */
  34. struct wpan_phy *phy;
  35. int open_count;
  36. /* As in mac80211 slaves list is modified:
  37. * 1) under the RTNL
  38. * 2) protected by slaves_mtx;
  39. * 3) in an RCU manner
  40. *
  41. * So atomic readers can use any of this protection methods.
  42. */
  43. struct list_head slaves;
  44. struct mutex slaves_mtx;
  45. /* This one is used for scanning and other jobs not to be interfered
  46. * with serial driver.
  47. */
  48. struct workqueue_struct *dev_workqueue;
  49. /* SoftMAC device is registered and running. One can add subinterfaces.
  50. * This flag should be modified under slaves_mtx and RTNL, so you can
  51. * read them using any of protection methods.
  52. */
  53. bool running;
  54. };
  55. #define MAC802154_DEVICE_STOPPED 0x00
  56. #define MAC802154_DEVICE_RUN 0x01
  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 mac802154_sub_if_data {
  64. struct list_head list; /* the ieee802154_priv->slaves list */
  65. struct mac802154_priv *hw;
  66. struct net_device *dev;
  67. int type;
  68. bool running;
  69. spinlock_t mib_lock;
  70. __le16 pan_id;
  71. __le16 short_addr;
  72. __le64 extended_addr;
  73. u8 chan;
  74. u8 page;
  75. struct ieee802154_mac_params mac_params;
  76. /* MAC BSN field */
  77. u8 bsn;
  78. /* MAC DSN field */
  79. u8 dsn;
  80. /* protects sec from concurrent access by netlink. access by
  81. * encrypt/decrypt/header_create safe without additional protection.
  82. */
  83. struct mutex sec_mtx;
  84. struct mac802154_llsec sec;
  85. };
  86. #define mac802154_to_priv(_hw) container_of(_hw, struct mac802154_priv, hw)
  87. #define MAC802154_CHAN_NONE 0xff /* No channel is assigned */
  88. extern struct ieee802154_reduced_mlme_ops mac802154_mlme_reduced;
  89. extern struct ieee802154_mlme_ops mac802154_mlme_wpan;
  90. int mac802154_slave_open(struct net_device *dev);
  91. int mac802154_slave_close(struct net_device *dev);
  92. void mac802154_monitors_rx(struct mac802154_priv *priv, struct sk_buff *skb);
  93. void mac802154_monitor_setup(struct net_device *dev);
  94. void mac802154_wpans_rx(struct mac802154_priv *priv, struct sk_buff *skb);
  95. void mac802154_wpan_setup(struct net_device *dev);
  96. netdev_tx_t mac802154_tx(struct mac802154_priv *priv, struct sk_buff *skb,
  97. u8 page, u8 chan);
  98. /* MIB callbacks */
  99. void mac802154_dev_set_short_addr(struct net_device *dev, __le16 val);
  100. __le16 mac802154_dev_get_short_addr(const struct net_device *dev);
  101. void mac802154_dev_set_ieee_addr(struct net_device *dev);
  102. __le16 mac802154_dev_get_pan_id(const struct net_device *dev);
  103. void mac802154_dev_set_pan_id(struct net_device *dev, __le16 val);
  104. void mac802154_dev_set_page_channel(struct net_device *dev, u8 page, u8 chan);
  105. u8 mac802154_dev_get_dsn(const struct net_device *dev);
  106. int mac802154_set_mac_params(struct net_device *dev,
  107. const struct ieee802154_mac_params *params);
  108. void mac802154_get_mac_params(struct net_device *dev,
  109. struct ieee802154_mac_params *params);
  110. int mac802154_get_params(struct net_device *dev,
  111. struct ieee802154_llsec_params *params);
  112. int mac802154_set_params(struct net_device *dev,
  113. const struct ieee802154_llsec_params *params,
  114. int changed);
  115. int mac802154_add_key(struct net_device *dev,
  116. const struct ieee802154_llsec_key_id *id,
  117. const struct ieee802154_llsec_key *key);
  118. int mac802154_del_key(struct net_device *dev,
  119. const struct ieee802154_llsec_key_id *id);
  120. int mac802154_add_dev(struct net_device *dev,
  121. const struct ieee802154_llsec_device *llsec_dev);
  122. int mac802154_del_dev(struct net_device *dev, __le64 dev_addr);
  123. int mac802154_add_devkey(struct net_device *dev,
  124. __le64 device_addr,
  125. const struct ieee802154_llsec_device_key *key);
  126. int mac802154_del_devkey(struct net_device *dev,
  127. __le64 device_addr,
  128. const struct ieee802154_llsec_device_key *key);
  129. int mac802154_add_seclevel(struct net_device *dev,
  130. const struct ieee802154_llsec_seclevel *sl);
  131. int mac802154_del_seclevel(struct net_device *dev,
  132. const struct ieee802154_llsec_seclevel *sl);
  133. void mac802154_lock_table(struct net_device *dev);
  134. void mac802154_get_table(struct net_device *dev,
  135. struct ieee802154_llsec_table **t);
  136. void mac802154_unlock_table(struct net_device *dev);
  137. #endif /* MAC802154_H */