cfg.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. *
  4. * Authors:
  5. * Alexander Aring <aar@pengutronix.de>
  6. *
  7. * Based on: net/mac80211/cfg.c
  8. */
  9. #include <net/rtnetlink.h>
  10. #include <net/cfg802154.h>
  11. #include "ieee802154_i.h"
  12. #include "driver-ops.h"
  13. #include "cfg.h"
  14. static struct net_device *
  15. ieee802154_add_iface_deprecated(struct wpan_phy *wpan_phy,
  16. const char *name,
  17. unsigned char name_assign_type, int type)
  18. {
  19. struct ieee802154_local *local = wpan_phy_priv(wpan_phy);
  20. struct net_device *dev;
  21. rtnl_lock();
  22. dev = ieee802154_if_add(local, name, name_assign_type, type,
  23. cpu_to_le64(0x0000000000000000ULL));
  24. rtnl_unlock();
  25. return dev;
  26. }
  27. static void ieee802154_del_iface_deprecated(struct wpan_phy *wpan_phy,
  28. struct net_device *dev)
  29. {
  30. struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
  31. ieee802154_if_remove(sdata);
  32. }
  33. #ifdef CONFIG_PM
  34. static int ieee802154_suspend(struct wpan_phy *wpan_phy)
  35. {
  36. struct ieee802154_local *local = wpan_phy_priv(wpan_phy);
  37. if (!local->open_count)
  38. goto suspend;
  39. ieee802154_sync_and_hold_queue(local);
  40. synchronize_net();
  41. /* stop hardware - this must stop RX */
  42. ieee802154_stop_device(local);
  43. suspend:
  44. local->suspended = true;
  45. return 0;
  46. }
  47. static int ieee802154_resume(struct wpan_phy *wpan_phy)
  48. {
  49. struct ieee802154_local *local = wpan_phy_priv(wpan_phy);
  50. int ret;
  51. /* nothing to do if HW shouldn't run */
  52. if (!local->open_count)
  53. goto wake_up;
  54. /* restart hardware */
  55. ret = drv_start(local, local->phy->filtering, &local->addr_filt);
  56. if (ret)
  57. return ret;
  58. wake_up:
  59. ieee802154_release_queue(local);
  60. local->suspended = false;
  61. return 0;
  62. }
  63. #else
  64. #define ieee802154_suspend NULL
  65. #define ieee802154_resume NULL
  66. #endif
  67. static int
  68. ieee802154_add_iface(struct wpan_phy *phy, const char *name,
  69. unsigned char name_assign_type,
  70. enum nl802154_iftype type, __le64 extended_addr)
  71. {
  72. struct ieee802154_local *local = wpan_phy_priv(phy);
  73. struct net_device *err;
  74. err = ieee802154_if_add(local, name, name_assign_type, type,
  75. extended_addr);
  76. return PTR_ERR_OR_ZERO(err);
  77. }
  78. static int
  79. ieee802154_del_iface(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev)
  80. {
  81. ieee802154_if_remove(IEEE802154_WPAN_DEV_TO_SUB_IF(wpan_dev));
  82. return 0;
  83. }
  84. static int
  85. ieee802154_set_channel(struct wpan_phy *wpan_phy, u8 page, u8 channel)
  86. {
  87. struct ieee802154_local *local = wpan_phy_priv(wpan_phy);
  88. int ret;
  89. ASSERT_RTNL();
  90. if (wpan_phy->current_page == page &&
  91. wpan_phy->current_channel == channel)
  92. return 0;
  93. /* Refuse to change channels during scanning or beaconing */
  94. if (mac802154_is_scanning(local) || mac802154_is_beaconing(local))
  95. return -EBUSY;
  96. ret = drv_set_channel(local, page, channel);
  97. if (!ret) {
  98. wpan_phy->current_page = page;
  99. wpan_phy->current_channel = channel;
  100. ieee802154_configure_durations(wpan_phy, page, channel);
  101. }
  102. return ret;
  103. }
  104. static int
  105. ieee802154_set_cca_mode(struct wpan_phy *wpan_phy,
  106. const struct wpan_phy_cca *cca)
  107. {
  108. struct ieee802154_local *local = wpan_phy_priv(wpan_phy);
  109. int ret;
  110. ASSERT_RTNL();
  111. if (wpan_phy_cca_cmp(&wpan_phy->cca, cca))
  112. return 0;
  113. ret = drv_set_cca_mode(local, cca);
  114. if (!ret)
  115. wpan_phy->cca = *cca;
  116. return ret;
  117. }
  118. static int
  119. ieee802154_set_cca_ed_level(struct wpan_phy *wpan_phy, s32 ed_level)
  120. {
  121. struct ieee802154_local *local = wpan_phy_priv(wpan_phy);
  122. int ret;
  123. ASSERT_RTNL();
  124. if (wpan_phy->cca_ed_level == ed_level)
  125. return 0;
  126. ret = drv_set_cca_ed_level(local, ed_level);
  127. if (!ret)
  128. wpan_phy->cca_ed_level = ed_level;
  129. return ret;
  130. }
  131. static int
  132. ieee802154_set_tx_power(struct wpan_phy *wpan_phy, s32 power)
  133. {
  134. struct ieee802154_local *local = wpan_phy_priv(wpan_phy);
  135. int ret;
  136. ASSERT_RTNL();
  137. if (wpan_phy->transmit_power == power)
  138. return 0;
  139. ret = drv_set_tx_power(local, power);
  140. if (!ret)
  141. wpan_phy->transmit_power = power;
  142. return ret;
  143. }
  144. static int
  145. ieee802154_set_pan_id(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
  146. __le16 pan_id)
  147. {
  148. int ret;
  149. ASSERT_RTNL();
  150. if (wpan_dev->pan_id == pan_id)
  151. return 0;
  152. ret = mac802154_wpan_update_llsec(wpan_dev->netdev);
  153. if (!ret)
  154. wpan_dev->pan_id = pan_id;
  155. return ret;
  156. }
  157. static int
  158. ieee802154_set_backoff_exponent(struct wpan_phy *wpan_phy,
  159. struct wpan_dev *wpan_dev,
  160. u8 min_be, u8 max_be)
  161. {
  162. ASSERT_RTNL();
  163. wpan_dev->min_be = min_be;
  164. wpan_dev->max_be = max_be;
  165. return 0;
  166. }
  167. static int
  168. ieee802154_set_short_addr(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
  169. __le16 short_addr)
  170. {
  171. ASSERT_RTNL();
  172. wpan_dev->short_addr = short_addr;
  173. return 0;
  174. }
  175. static int
  176. ieee802154_set_max_csma_backoffs(struct wpan_phy *wpan_phy,
  177. struct wpan_dev *wpan_dev,
  178. u8 max_csma_backoffs)
  179. {
  180. ASSERT_RTNL();
  181. wpan_dev->csma_retries = max_csma_backoffs;
  182. return 0;
  183. }
  184. static int
  185. ieee802154_set_max_frame_retries(struct wpan_phy *wpan_phy,
  186. struct wpan_dev *wpan_dev,
  187. s8 max_frame_retries)
  188. {
  189. ASSERT_RTNL();
  190. wpan_dev->frame_retries = max_frame_retries;
  191. return 0;
  192. }
  193. static int
  194. ieee802154_set_lbt_mode(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
  195. bool mode)
  196. {
  197. ASSERT_RTNL();
  198. wpan_dev->lbt = mode;
  199. return 0;
  200. }
  201. static int
  202. ieee802154_set_ackreq_default(struct wpan_phy *wpan_phy,
  203. struct wpan_dev *wpan_dev, bool ackreq)
  204. {
  205. ASSERT_RTNL();
  206. wpan_dev->ackreq = ackreq;
  207. return 0;
  208. }
  209. static int mac802154_trigger_scan(struct wpan_phy *wpan_phy,
  210. struct cfg802154_scan_request *request)
  211. {
  212. struct ieee802154_sub_if_data *sdata;
  213. sdata = IEEE802154_WPAN_DEV_TO_SUB_IF(request->wpan_dev);
  214. ASSERT_RTNL();
  215. return mac802154_trigger_scan_locked(sdata, request);
  216. }
  217. static int mac802154_abort_scan(struct wpan_phy *wpan_phy,
  218. struct wpan_dev *wpan_dev)
  219. {
  220. struct ieee802154_local *local = wpan_phy_priv(wpan_phy);
  221. struct ieee802154_sub_if_data *sdata;
  222. sdata = IEEE802154_WPAN_DEV_TO_SUB_IF(wpan_dev);
  223. ASSERT_RTNL();
  224. return mac802154_abort_scan_locked(local, sdata);
  225. }
  226. static int mac802154_send_beacons(struct wpan_phy *wpan_phy,
  227. struct cfg802154_beacon_request *request)
  228. {
  229. struct ieee802154_sub_if_data *sdata;
  230. sdata = IEEE802154_WPAN_DEV_TO_SUB_IF(request->wpan_dev);
  231. ASSERT_RTNL();
  232. return mac802154_send_beacons_locked(sdata, request);
  233. }
  234. static int mac802154_stop_beacons(struct wpan_phy *wpan_phy,
  235. struct wpan_dev *wpan_dev)
  236. {
  237. struct ieee802154_local *local = wpan_phy_priv(wpan_phy);
  238. struct ieee802154_sub_if_data *sdata;
  239. sdata = IEEE802154_WPAN_DEV_TO_SUB_IF(wpan_dev);
  240. ASSERT_RTNL();
  241. return mac802154_stop_beacons_locked(local, sdata);
  242. }
  243. static int mac802154_associate(struct wpan_phy *wpan_phy,
  244. struct wpan_dev *wpan_dev,
  245. struct ieee802154_addr *coord)
  246. {
  247. struct ieee802154_local *local = wpan_phy_priv(wpan_phy);
  248. u64 ceaddr = swab64((__force u64)coord->extended_addr);
  249. struct ieee802154_sub_if_data *sdata;
  250. struct ieee802154_pan_device *parent;
  251. __le16 short_addr;
  252. int ret;
  253. ASSERT_RTNL();
  254. sdata = IEEE802154_WPAN_DEV_TO_SUB_IF(wpan_dev);
  255. if (wpan_dev->parent) {
  256. dev_err(&sdata->dev->dev,
  257. "Device %8phC is already associated\n", &ceaddr);
  258. return -EPERM;
  259. }
  260. if (coord->mode == IEEE802154_SHORT_ADDRESSING)
  261. return -EINVAL;
  262. parent = kzalloc(sizeof(*parent), GFP_KERNEL);
  263. if (!parent)
  264. return -ENOMEM;
  265. parent->pan_id = coord->pan_id;
  266. parent->mode = coord->mode;
  267. parent->extended_addr = coord->extended_addr;
  268. parent->short_addr = cpu_to_le16(IEEE802154_ADDR_SHORT_BROADCAST);
  269. /* Set the PAN ID hardware address filter beforehand to avoid dropping
  270. * the association response with a destination PAN ID field set to the
  271. * "new" PAN ID.
  272. */
  273. if (local->hw.flags & IEEE802154_HW_AFILT) {
  274. ret = drv_set_pan_id(local, coord->pan_id);
  275. if (ret < 0)
  276. goto free_parent;
  277. }
  278. ret = mac802154_perform_association(sdata, parent, &short_addr);
  279. if (ret)
  280. goto reset_panid;
  281. if (local->hw.flags & IEEE802154_HW_AFILT) {
  282. ret = drv_set_short_addr(local, short_addr);
  283. if (ret < 0)
  284. goto reset_panid;
  285. }
  286. wpan_dev->pan_id = coord->pan_id;
  287. wpan_dev->short_addr = short_addr;
  288. wpan_dev->parent = parent;
  289. return 0;
  290. reset_panid:
  291. if (local->hw.flags & IEEE802154_HW_AFILT)
  292. drv_set_pan_id(local, cpu_to_le16(IEEE802154_PAN_ID_BROADCAST));
  293. free_parent:
  294. kfree(parent);
  295. return ret;
  296. }
  297. static int mac802154_disassociate_from_parent(struct wpan_phy *wpan_phy,
  298. struct wpan_dev *wpan_dev)
  299. {
  300. struct ieee802154_local *local = wpan_phy_priv(wpan_phy);
  301. struct ieee802154_pan_device *child, *tmp;
  302. struct ieee802154_sub_if_data *sdata;
  303. unsigned int max_assoc;
  304. u64 eaddr;
  305. int ret;
  306. sdata = IEEE802154_WPAN_DEV_TO_SUB_IF(wpan_dev);
  307. /* Start by disassociating all the children and preventing new ones to
  308. * attempt associations.
  309. */
  310. max_assoc = cfg802154_set_max_associations(wpan_dev, 0);
  311. list_for_each_entry_safe(child, tmp, &wpan_dev->children, node) {
  312. ret = mac802154_send_disassociation_notif(sdata, child,
  313. IEEE802154_COORD_WISHES_DEVICE_TO_LEAVE);
  314. if (ret) {
  315. eaddr = swab64((__force u64)child->extended_addr);
  316. dev_err(&sdata->dev->dev,
  317. "Disassociation with %8phC may have failed (%d)\n",
  318. &eaddr, ret);
  319. }
  320. list_del(&child->node);
  321. }
  322. ret = mac802154_send_disassociation_notif(sdata, wpan_dev->parent,
  323. IEEE802154_DEVICE_WISHES_TO_LEAVE);
  324. if (ret) {
  325. eaddr = swab64((__force u64)wpan_dev->parent->extended_addr);
  326. dev_err(&sdata->dev->dev,
  327. "Disassociation from %8phC may have failed (%d)\n",
  328. &eaddr, ret);
  329. }
  330. ret = 0;
  331. kfree(wpan_dev->parent);
  332. wpan_dev->parent = NULL;
  333. wpan_dev->pan_id = cpu_to_le16(IEEE802154_PAN_ID_BROADCAST);
  334. wpan_dev->short_addr = cpu_to_le16(IEEE802154_ADDR_SHORT_BROADCAST);
  335. if (local->hw.flags & IEEE802154_HW_AFILT) {
  336. ret = drv_set_pan_id(local, wpan_dev->pan_id);
  337. if (ret < 0)
  338. goto reset_mac_assoc;
  339. ret = drv_set_short_addr(local, wpan_dev->short_addr);
  340. if (ret < 0)
  341. goto reset_mac_assoc;
  342. }
  343. reset_mac_assoc:
  344. cfg802154_set_max_associations(wpan_dev, max_assoc);
  345. return ret;
  346. }
  347. static int mac802154_disassociate_child(struct wpan_phy *wpan_phy,
  348. struct wpan_dev *wpan_dev,
  349. struct ieee802154_pan_device *child)
  350. {
  351. struct ieee802154_sub_if_data *sdata;
  352. int ret;
  353. sdata = IEEE802154_WPAN_DEV_TO_SUB_IF(wpan_dev);
  354. ret = mac802154_send_disassociation_notif(sdata, child,
  355. IEEE802154_COORD_WISHES_DEVICE_TO_LEAVE);
  356. if (ret)
  357. return ret;
  358. list_del(&child->node);
  359. wpan_dev->nchildren--;
  360. kfree(child);
  361. return 0;
  362. }
  363. static int mac802154_disassociate(struct wpan_phy *wpan_phy,
  364. struct wpan_dev *wpan_dev,
  365. struct ieee802154_addr *target)
  366. {
  367. u64 teaddr = swab64((__force u64)target->extended_addr);
  368. struct ieee802154_pan_device *pan_device;
  369. ASSERT_RTNL();
  370. if (cfg802154_device_is_parent(wpan_dev, target))
  371. return mac802154_disassociate_from_parent(wpan_phy, wpan_dev);
  372. pan_device = cfg802154_device_is_child(wpan_dev, target);
  373. if (pan_device)
  374. return mac802154_disassociate_child(wpan_phy, wpan_dev,
  375. pan_device);
  376. dev_err(&wpan_dev->netdev->dev,
  377. "Device %8phC is not associated with us\n", &teaddr);
  378. return -EINVAL;
  379. }
  380. #ifdef CONFIG_IEEE802154_NL802154_EXPERIMENTAL
  381. static void
  382. ieee802154_get_llsec_table(struct wpan_phy *wpan_phy,
  383. struct wpan_dev *wpan_dev,
  384. struct ieee802154_llsec_table **table)
  385. {
  386. struct net_device *dev = wpan_dev->netdev;
  387. struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
  388. *table = &sdata->sec.table;
  389. }
  390. static void
  391. ieee802154_lock_llsec_table(struct wpan_phy *wpan_phy,
  392. struct wpan_dev *wpan_dev)
  393. {
  394. struct net_device *dev = wpan_dev->netdev;
  395. struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
  396. mutex_lock(&sdata->sec_mtx);
  397. }
  398. static void
  399. ieee802154_unlock_llsec_table(struct wpan_phy *wpan_phy,
  400. struct wpan_dev *wpan_dev)
  401. {
  402. struct net_device *dev = wpan_dev->netdev;
  403. struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
  404. mutex_unlock(&sdata->sec_mtx);
  405. }
  406. static int
  407. ieee802154_set_llsec_params(struct wpan_phy *wpan_phy,
  408. struct wpan_dev *wpan_dev,
  409. const struct ieee802154_llsec_params *params,
  410. int changed)
  411. {
  412. struct net_device *dev = wpan_dev->netdev;
  413. struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
  414. int res;
  415. mutex_lock(&sdata->sec_mtx);
  416. res = mac802154_llsec_set_params(&sdata->sec, params, changed);
  417. mutex_unlock(&sdata->sec_mtx);
  418. return res;
  419. }
  420. static int
  421. ieee802154_get_llsec_params(struct wpan_phy *wpan_phy,
  422. struct wpan_dev *wpan_dev,
  423. struct ieee802154_llsec_params *params)
  424. {
  425. struct net_device *dev = wpan_dev->netdev;
  426. struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
  427. int res;
  428. mutex_lock(&sdata->sec_mtx);
  429. res = mac802154_llsec_get_params(&sdata->sec, params);
  430. mutex_unlock(&sdata->sec_mtx);
  431. return res;
  432. }
  433. static int
  434. ieee802154_add_llsec_key(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
  435. const struct ieee802154_llsec_key_id *id,
  436. const struct ieee802154_llsec_key *key)
  437. {
  438. struct net_device *dev = wpan_dev->netdev;
  439. struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
  440. int res;
  441. mutex_lock(&sdata->sec_mtx);
  442. res = mac802154_llsec_key_add(&sdata->sec, id, key);
  443. mutex_unlock(&sdata->sec_mtx);
  444. return res;
  445. }
  446. static int
  447. ieee802154_del_llsec_key(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
  448. const struct ieee802154_llsec_key_id *id)
  449. {
  450. struct net_device *dev = wpan_dev->netdev;
  451. struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
  452. int res;
  453. mutex_lock(&sdata->sec_mtx);
  454. res = mac802154_llsec_key_del(&sdata->sec, id);
  455. mutex_unlock(&sdata->sec_mtx);
  456. return res;
  457. }
  458. static int
  459. ieee802154_add_seclevel(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
  460. const struct ieee802154_llsec_seclevel *sl)
  461. {
  462. struct net_device *dev = wpan_dev->netdev;
  463. struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
  464. int res;
  465. mutex_lock(&sdata->sec_mtx);
  466. res = mac802154_llsec_seclevel_add(&sdata->sec, sl);
  467. mutex_unlock(&sdata->sec_mtx);
  468. return res;
  469. }
  470. static int
  471. ieee802154_del_seclevel(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
  472. const struct ieee802154_llsec_seclevel *sl)
  473. {
  474. struct net_device *dev = wpan_dev->netdev;
  475. struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
  476. int res;
  477. mutex_lock(&sdata->sec_mtx);
  478. res = mac802154_llsec_seclevel_del(&sdata->sec, sl);
  479. mutex_unlock(&sdata->sec_mtx);
  480. return res;
  481. }
  482. static int
  483. ieee802154_add_device(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
  484. const struct ieee802154_llsec_device *dev_desc)
  485. {
  486. struct net_device *dev = wpan_dev->netdev;
  487. struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
  488. int res;
  489. mutex_lock(&sdata->sec_mtx);
  490. res = mac802154_llsec_dev_add(&sdata->sec, dev_desc);
  491. mutex_unlock(&sdata->sec_mtx);
  492. return res;
  493. }
  494. static int
  495. ieee802154_del_device(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
  496. __le64 extended_addr)
  497. {
  498. struct net_device *dev = wpan_dev->netdev;
  499. struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
  500. int res;
  501. mutex_lock(&sdata->sec_mtx);
  502. res = mac802154_llsec_dev_del(&sdata->sec, extended_addr);
  503. mutex_unlock(&sdata->sec_mtx);
  504. return res;
  505. }
  506. static int
  507. ieee802154_add_devkey(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
  508. __le64 extended_addr,
  509. const struct ieee802154_llsec_device_key *key)
  510. {
  511. struct net_device *dev = wpan_dev->netdev;
  512. struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
  513. int res;
  514. mutex_lock(&sdata->sec_mtx);
  515. res = mac802154_llsec_devkey_add(&sdata->sec, extended_addr, key);
  516. mutex_unlock(&sdata->sec_mtx);
  517. return res;
  518. }
  519. static int
  520. ieee802154_del_devkey(struct wpan_phy *wpan_phy, struct wpan_dev *wpan_dev,
  521. __le64 extended_addr,
  522. const struct ieee802154_llsec_device_key *key)
  523. {
  524. struct net_device *dev = wpan_dev->netdev;
  525. struct ieee802154_sub_if_data *sdata = IEEE802154_DEV_TO_SUB_IF(dev);
  526. int res;
  527. mutex_lock(&sdata->sec_mtx);
  528. res = mac802154_llsec_devkey_del(&sdata->sec, extended_addr, key);
  529. mutex_unlock(&sdata->sec_mtx);
  530. return res;
  531. }
  532. #endif /* CONFIG_IEEE802154_NL802154_EXPERIMENTAL */
  533. const struct cfg802154_ops mac802154_config_ops = {
  534. .add_virtual_intf_deprecated = ieee802154_add_iface_deprecated,
  535. .del_virtual_intf_deprecated = ieee802154_del_iface_deprecated,
  536. .suspend = ieee802154_suspend,
  537. .resume = ieee802154_resume,
  538. .add_virtual_intf = ieee802154_add_iface,
  539. .del_virtual_intf = ieee802154_del_iface,
  540. .set_channel = ieee802154_set_channel,
  541. .set_cca_mode = ieee802154_set_cca_mode,
  542. .set_cca_ed_level = ieee802154_set_cca_ed_level,
  543. .set_tx_power = ieee802154_set_tx_power,
  544. .set_pan_id = ieee802154_set_pan_id,
  545. .set_short_addr = ieee802154_set_short_addr,
  546. .set_backoff_exponent = ieee802154_set_backoff_exponent,
  547. .set_max_csma_backoffs = ieee802154_set_max_csma_backoffs,
  548. .set_max_frame_retries = ieee802154_set_max_frame_retries,
  549. .set_lbt_mode = ieee802154_set_lbt_mode,
  550. .set_ackreq_default = ieee802154_set_ackreq_default,
  551. .trigger_scan = mac802154_trigger_scan,
  552. .abort_scan = mac802154_abort_scan,
  553. .send_beacons = mac802154_send_beacons,
  554. .stop_beacons = mac802154_stop_beacons,
  555. .associate = mac802154_associate,
  556. .disassociate = mac802154_disassociate,
  557. #ifdef CONFIG_IEEE802154_NL802154_EXPERIMENTAL
  558. .get_llsec_table = ieee802154_get_llsec_table,
  559. .lock_llsec_table = ieee802154_lock_llsec_table,
  560. .unlock_llsec_table = ieee802154_unlock_llsec_table,
  561. /* TODO above */
  562. .set_llsec_params = ieee802154_set_llsec_params,
  563. .get_llsec_params = ieee802154_get_llsec_params,
  564. .add_llsec_key = ieee802154_add_llsec_key,
  565. .del_llsec_key = ieee802154_del_llsec_key,
  566. .add_seclevel = ieee802154_add_seclevel,
  567. .del_seclevel = ieee802154_del_seclevel,
  568. .add_device = ieee802154_add_device,
  569. .del_device = ieee802154_del_device,
  570. .add_devkey = ieee802154_add_devkey,
  571. .del_devkey = ieee802154_del_devkey,
  572. #endif /* CONFIG_IEEE802154_NL802154_EXPERIMENTAL */
  573. };