rdev-ops.h 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __CFG802154_RDEV_OPS
  3. #define __CFG802154_RDEV_OPS
  4. #include <net/cfg802154.h>
  5. #include "core.h"
  6. #include "trace.h"
  7. static inline struct net_device *
  8. rdev_add_virtual_intf_deprecated(struct cfg802154_registered_device *rdev,
  9. const char *name,
  10. unsigned char name_assign_type,
  11. int type)
  12. {
  13. return rdev->ops->add_virtual_intf_deprecated(&rdev->wpan_phy, name,
  14. name_assign_type, type);
  15. }
  16. static inline void
  17. rdev_del_virtual_intf_deprecated(struct cfg802154_registered_device *rdev,
  18. struct net_device *dev)
  19. {
  20. rdev->ops->del_virtual_intf_deprecated(&rdev->wpan_phy, dev);
  21. }
  22. static inline int
  23. rdev_suspend(struct cfg802154_registered_device *rdev)
  24. {
  25. int ret;
  26. trace_802154_rdev_suspend(&rdev->wpan_phy);
  27. ret = rdev->ops->suspend(&rdev->wpan_phy);
  28. trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
  29. return ret;
  30. }
  31. static inline int
  32. rdev_resume(struct cfg802154_registered_device *rdev)
  33. {
  34. int ret;
  35. trace_802154_rdev_resume(&rdev->wpan_phy);
  36. ret = rdev->ops->resume(&rdev->wpan_phy);
  37. trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
  38. return ret;
  39. }
  40. static inline int
  41. rdev_add_virtual_intf(struct cfg802154_registered_device *rdev, char *name,
  42. unsigned char name_assign_type,
  43. enum nl802154_iftype type, __le64 extended_addr)
  44. {
  45. int ret;
  46. trace_802154_rdev_add_virtual_intf(&rdev->wpan_phy, name, type,
  47. extended_addr);
  48. ret = rdev->ops->add_virtual_intf(&rdev->wpan_phy, name,
  49. name_assign_type, type,
  50. extended_addr);
  51. trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
  52. return ret;
  53. }
  54. static inline int
  55. rdev_del_virtual_intf(struct cfg802154_registered_device *rdev,
  56. struct wpan_dev *wpan_dev)
  57. {
  58. int ret;
  59. trace_802154_rdev_del_virtual_intf(&rdev->wpan_phy, wpan_dev);
  60. ret = rdev->ops->del_virtual_intf(&rdev->wpan_phy, wpan_dev);
  61. trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
  62. return ret;
  63. }
  64. static inline int
  65. rdev_set_channel(struct cfg802154_registered_device *rdev, u8 page, u8 channel)
  66. {
  67. int ret;
  68. trace_802154_rdev_set_channel(&rdev->wpan_phy, page, channel);
  69. ret = rdev->ops->set_channel(&rdev->wpan_phy, page, channel);
  70. trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
  71. return ret;
  72. }
  73. static inline int
  74. rdev_set_cca_mode(struct cfg802154_registered_device *rdev,
  75. const struct wpan_phy_cca *cca)
  76. {
  77. int ret;
  78. trace_802154_rdev_set_cca_mode(&rdev->wpan_phy, cca);
  79. ret = rdev->ops->set_cca_mode(&rdev->wpan_phy, cca);
  80. trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
  81. return ret;
  82. }
  83. static inline int
  84. rdev_set_cca_ed_level(struct cfg802154_registered_device *rdev, s32 ed_level)
  85. {
  86. int ret;
  87. trace_802154_rdev_set_cca_ed_level(&rdev->wpan_phy, ed_level);
  88. ret = rdev->ops->set_cca_ed_level(&rdev->wpan_phy, ed_level);
  89. trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
  90. return ret;
  91. }
  92. static inline int
  93. rdev_set_tx_power(struct cfg802154_registered_device *rdev,
  94. s32 power)
  95. {
  96. int ret;
  97. trace_802154_rdev_set_tx_power(&rdev->wpan_phy, power);
  98. ret = rdev->ops->set_tx_power(&rdev->wpan_phy, power);
  99. trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
  100. return ret;
  101. }
  102. static inline int
  103. rdev_set_pan_id(struct cfg802154_registered_device *rdev,
  104. struct wpan_dev *wpan_dev, __le16 pan_id)
  105. {
  106. int ret;
  107. trace_802154_rdev_set_pan_id(&rdev->wpan_phy, wpan_dev, pan_id);
  108. ret = rdev->ops->set_pan_id(&rdev->wpan_phy, wpan_dev, pan_id);
  109. trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
  110. return ret;
  111. }
  112. static inline int
  113. rdev_set_short_addr(struct cfg802154_registered_device *rdev,
  114. struct wpan_dev *wpan_dev, __le16 short_addr)
  115. {
  116. int ret;
  117. trace_802154_rdev_set_short_addr(&rdev->wpan_phy, wpan_dev, short_addr);
  118. ret = rdev->ops->set_short_addr(&rdev->wpan_phy, wpan_dev, short_addr);
  119. trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
  120. return ret;
  121. }
  122. static inline int
  123. rdev_set_backoff_exponent(struct cfg802154_registered_device *rdev,
  124. struct wpan_dev *wpan_dev, u8 min_be, u8 max_be)
  125. {
  126. int ret;
  127. trace_802154_rdev_set_backoff_exponent(&rdev->wpan_phy, wpan_dev,
  128. min_be, max_be);
  129. ret = rdev->ops->set_backoff_exponent(&rdev->wpan_phy, wpan_dev,
  130. min_be, max_be);
  131. trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
  132. return ret;
  133. }
  134. static inline int
  135. rdev_set_max_csma_backoffs(struct cfg802154_registered_device *rdev,
  136. struct wpan_dev *wpan_dev, u8 max_csma_backoffs)
  137. {
  138. int ret;
  139. trace_802154_rdev_set_csma_backoffs(&rdev->wpan_phy, wpan_dev,
  140. max_csma_backoffs);
  141. ret = rdev->ops->set_max_csma_backoffs(&rdev->wpan_phy, wpan_dev,
  142. max_csma_backoffs);
  143. trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
  144. return ret;
  145. }
  146. static inline int
  147. rdev_set_max_frame_retries(struct cfg802154_registered_device *rdev,
  148. struct wpan_dev *wpan_dev, s8 max_frame_retries)
  149. {
  150. int ret;
  151. trace_802154_rdev_set_max_frame_retries(&rdev->wpan_phy, wpan_dev,
  152. max_frame_retries);
  153. ret = rdev->ops->set_max_frame_retries(&rdev->wpan_phy, wpan_dev,
  154. max_frame_retries);
  155. trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
  156. return ret;
  157. }
  158. static inline int
  159. rdev_set_lbt_mode(struct cfg802154_registered_device *rdev,
  160. struct wpan_dev *wpan_dev, bool mode)
  161. {
  162. int ret;
  163. trace_802154_rdev_set_lbt_mode(&rdev->wpan_phy, wpan_dev, mode);
  164. ret = rdev->ops->set_lbt_mode(&rdev->wpan_phy, wpan_dev, mode);
  165. trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
  166. return ret;
  167. }
  168. static inline int
  169. rdev_set_ackreq_default(struct cfg802154_registered_device *rdev,
  170. struct wpan_dev *wpan_dev, bool ackreq)
  171. {
  172. int ret;
  173. trace_802154_rdev_set_ackreq_default(&rdev->wpan_phy, wpan_dev,
  174. ackreq);
  175. ret = rdev->ops->set_ackreq_default(&rdev->wpan_phy, wpan_dev, ackreq);
  176. trace_802154_rdev_return_int(&rdev->wpan_phy, ret);
  177. return ret;
  178. }
  179. #ifdef CONFIG_IEEE802154_NL802154_EXPERIMENTAL
  180. /* TODO this is already a nl802154, so move into ieee802154 */
  181. static inline void
  182. rdev_get_llsec_table(struct cfg802154_registered_device *rdev,
  183. struct wpan_dev *wpan_dev,
  184. struct ieee802154_llsec_table **table)
  185. {
  186. rdev->ops->get_llsec_table(&rdev->wpan_phy, wpan_dev, table);
  187. }
  188. static inline void
  189. rdev_lock_llsec_table(struct cfg802154_registered_device *rdev,
  190. struct wpan_dev *wpan_dev)
  191. {
  192. rdev->ops->lock_llsec_table(&rdev->wpan_phy, wpan_dev);
  193. }
  194. static inline void
  195. rdev_unlock_llsec_table(struct cfg802154_registered_device *rdev,
  196. struct wpan_dev *wpan_dev)
  197. {
  198. rdev->ops->unlock_llsec_table(&rdev->wpan_phy, wpan_dev);
  199. }
  200. static inline int
  201. rdev_get_llsec_params(struct cfg802154_registered_device *rdev,
  202. struct wpan_dev *wpan_dev,
  203. struct ieee802154_llsec_params *params)
  204. {
  205. return rdev->ops->get_llsec_params(&rdev->wpan_phy, wpan_dev, params);
  206. }
  207. static inline int
  208. rdev_set_llsec_params(struct cfg802154_registered_device *rdev,
  209. struct wpan_dev *wpan_dev,
  210. const struct ieee802154_llsec_params *params,
  211. u32 changed)
  212. {
  213. return rdev->ops->set_llsec_params(&rdev->wpan_phy, wpan_dev, params,
  214. changed);
  215. }
  216. static inline int
  217. rdev_add_llsec_key(struct cfg802154_registered_device *rdev,
  218. struct wpan_dev *wpan_dev,
  219. const struct ieee802154_llsec_key_id *id,
  220. const struct ieee802154_llsec_key *key)
  221. {
  222. return rdev->ops->add_llsec_key(&rdev->wpan_phy, wpan_dev, id, key);
  223. }
  224. static inline int
  225. rdev_del_llsec_key(struct cfg802154_registered_device *rdev,
  226. struct wpan_dev *wpan_dev,
  227. const struct ieee802154_llsec_key_id *id)
  228. {
  229. return rdev->ops->del_llsec_key(&rdev->wpan_phy, wpan_dev, id);
  230. }
  231. static inline int
  232. rdev_add_seclevel(struct cfg802154_registered_device *rdev,
  233. struct wpan_dev *wpan_dev,
  234. const struct ieee802154_llsec_seclevel *sl)
  235. {
  236. return rdev->ops->add_seclevel(&rdev->wpan_phy, wpan_dev, sl);
  237. }
  238. static inline int
  239. rdev_del_seclevel(struct cfg802154_registered_device *rdev,
  240. struct wpan_dev *wpan_dev,
  241. const struct ieee802154_llsec_seclevel *sl)
  242. {
  243. return rdev->ops->del_seclevel(&rdev->wpan_phy, wpan_dev, sl);
  244. }
  245. static inline int
  246. rdev_add_device(struct cfg802154_registered_device *rdev,
  247. struct wpan_dev *wpan_dev,
  248. const struct ieee802154_llsec_device *dev_desc)
  249. {
  250. return rdev->ops->add_device(&rdev->wpan_phy, wpan_dev, dev_desc);
  251. }
  252. static inline int
  253. rdev_del_device(struct cfg802154_registered_device *rdev,
  254. struct wpan_dev *wpan_dev, __le64 extended_addr)
  255. {
  256. return rdev->ops->del_device(&rdev->wpan_phy, wpan_dev, extended_addr);
  257. }
  258. static inline int
  259. rdev_add_devkey(struct cfg802154_registered_device *rdev,
  260. struct wpan_dev *wpan_dev, __le64 extended_addr,
  261. const struct ieee802154_llsec_device_key *devkey)
  262. {
  263. return rdev->ops->add_devkey(&rdev->wpan_phy, wpan_dev, extended_addr,
  264. devkey);
  265. }
  266. static inline int
  267. rdev_del_devkey(struct cfg802154_registered_device *rdev,
  268. struct wpan_dev *wpan_dev, __le64 extended_addr,
  269. const struct ieee802154_llsec_device_key *devkey)
  270. {
  271. return rdev->ops->del_devkey(&rdev->wpan_phy, wpan_dev, extended_addr,
  272. devkey);
  273. }
  274. #endif /* CONFIG_IEEE802154_NL802154_EXPERIMENTAL */
  275. #endif /* __CFG802154_RDEV_OPS */