target_if_spectral_netlink.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  1. /*
  2. * Copyright (c) 2011,2017 The Linux Foundation. All rights reserved.
  3. *
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for
  6. * any purpose with or without fee is hereby granted, provided that the
  7. * above copyright notice and this permission notice appear in all
  8. * copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  11. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  12. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  13. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  14. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  15. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  16. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  17. * PERFORMANCE OF THIS SOFTWARE.
  18. */
  19. #include <osdep.h>
  20. #include <wlan_tgt_def_config.h>
  21. #include <hif.h>
  22. #include <hif_hw_version.h>
  23. #include <wmi_unified_api.h>
  24. #include <target_if_spectral.h>
  25. #include <wlan_lmac_if_def.h>
  26. #include <wlan_osif_priv.h>
  27. #include <reg_services_public_struct.h>
  28. #ifdef SPECTRAL_USE_NETLINK_SOCKETS
  29. struct sock *target_if_spectral_nl_sock;
  30. static atomic_t spectral_nl_users = ATOMIC_INIT(0);
  31. #if (KERNEL_VERSION(2, 6, 31) > LINUX_VERSION_CODE)
  32. void target_if_spectral_nl_data_ready(struct sock *sk, int len)
  33. {
  34. qdf_print("%s %d\n", __func__, __LINE__);
  35. }
  36. #else
  37. void target_if_spectral_nl_data_ready(struct sk_buff *skb)
  38. {
  39. qdf_print("%s %d\n", __func__, __LINE__);
  40. }
  41. #endif /* VERSION */
  42. int target_if_spectral_init_netlink(struct target_if_spectral *spectral)
  43. {
  44. #if KERNEL_VERSION(3, 6, 0) <= LINUX_VERSION_CODE
  45. struct netlink_kernel_cfg cfg = {
  46. .groups = 1,
  47. .input = target_if_spectral_nl_data_ready,
  48. };
  49. #endif
  50. if (!spectral) {
  51. qdf_print("%s: sc_spectral is NULL\n", __func__);
  52. return -EIO;
  53. }
  54. spectral->spectral_sent_msg = 0;
  55. if (!target_if_spectral_nl_sock) {
  56. #if KERNEL_VERSION(3, 7, 0) <= LINUX_VERSION_CODE
  57. target_if_spectral_nl_sock = (struct sock *)netlink_kernel_create(
  58. &init_net,
  59. NETLINK_ATHEROS,
  60. &cfg);
  61. #elif KERNEL_VERSION(3, 6, 0) <= LINUX_VERSION_CODE
  62. target_if_spectral_nl_sock = (struct sock *)netlink_kernel_create(
  63. &init_net,
  64. NETLINK_ATHEROS,
  65. THIS_MODULE,
  66. &cfg);
  67. #elif (KERNEL_VERSION(2, 6, 31) > LINUX_VERSION_CODE)
  68. target_if_spectral_nl_sock = (
  69. struct sock *)netlink_kernel_create(NETLINK_ATHEROS,
  70. 1,
  71. &target_if_spectral_nl_data_ready,
  72. THIS_MODULE);
  73. #else
  74. #if (KERNEL_VERSION(3, 10, 0) <= LINUX_VERSION_CODE)
  75. struct netlink_kernel_cfg cfg;
  76. memset(&cfg, 0, sizeof(cfg));
  77. cfg.groups = 1;
  78. cfg.input = &target_if_spectral_nl_data_ready;
  79. target_if_spectral_nl_sock = (struct sock *)netlink_kernel_create(
  80. &init_net, NETLINK_ATHEROS, &cfg);
  81. #else
  82. target_if_spectral_nl_sock = (struct sock *)netlink_kernel_create(
  83. &init_net,
  84. NETLINK_ATHEROS,
  85. 1,
  86. &target_if_spectral_nl_data_ready,
  87. NULL,
  88. THIS_MODULE);
  89. #endif
  90. #endif
  91. if (!target_if_spectral_nl_sock) {
  92. qdf_print("%s NETLINK_KERNEL_CREATE FAILED\n", __func__);
  93. return -ENODEV;
  94. }
  95. }
  96. atomic_inc(&spectral_nl_users);
  97. spectral->spectral_sock = target_if_spectral_nl_sock;
  98. if ((!spectral) || (!spectral->spectral_sock)) {
  99. qdf_print("%s NULL pointers (spectral=%d) (sock=%d)\n",
  100. __func__, (!spectral), (!spectral->spectral_sock));
  101. return -ENODEV;
  102. }
  103. if (!spectral->spectral_skb)
  104. qdf_print(KERN_ERR "%s %d NULL SKB\n", __func__, __LINE__);
  105. return 0;
  106. }
  107. int target_if_spectral_destroy_netlink(struct target_if_spectral *spectral)
  108. {
  109. spectral->spectral_sock = NULL;
  110. if (atomic_dec_and_test(&spectral_nl_users)) {
  111. sock_release(target_if_spectral_nl_sock->sk_socket);
  112. target_if_spectral_nl_sock = NULL;
  113. }
  114. return 0;
  115. }
  116. #endif /* SPECTRAL_USE_NETLINK_SOCKETS */
  117. static void spectral_process_noise_pwr_report(
  118. struct target_if_spectral *spectral,
  119. const SPECTRAL_SAMP_MSG *spec_samp_msg)
  120. {
  121. int i, done;
  122. /*
  123. * qdf_print(
  124. * "%s: #%d/%d datalen=%d tstamp=%x last_tstamp=%x "
  125. * "rssi=%d nb_lower=%d peak=%d\n",
  126. * __func__, spectral->noise_pwr_reports_recv,
  127. * spectral->noise_pwr_reports_reqd,
  128. * spec_samp_msg->samp_data.spectral_data_len,
  129. * spec_samp_msg->samp_data.spectral_tstamp,
  130. * spec_samp_msg->samp_data.spectral_last_tstamp,
  131. * spec_samp_msg->samp_data.spectral_lower_rssi,
  132. * spec_samp_msg->samp_data.spectral_nb_lower,
  133. * spec_samp_msg->samp_data.spectral_lower_max_index);
  134. */
  135. qdf_spin_lock(&spectral->noise_pwr_reports_lock);
  136. if (!spectral->noise_pwr_reports_reqd) {
  137. qdf_spin_unlock(&spectral->noise_pwr_reports_lock);
  138. return;
  139. }
  140. if (spectral->noise_pwr_reports_recv <
  141. spectral->noise_pwr_reports_reqd) {
  142. spectral->noise_pwr_reports_recv++;
  143. /*
  144. * qdf_print(
  145. * "#%d/%d: rssi=%3d,%3d,%3d %3d,%3d,%3d\n",
  146. * spectral->noise_pwr_reports_recv,
  147. * spectral->noise_pwr_reports_reqd,
  148. * spec_samp_msg->samp_data.spectral_chain_ctl_rssi[0],
  149. * spec_samp_msg->samp_data.spectral_chain_ctl_rssi[1],
  150. * spec_samp_msg->samp_data.spectral_chain_ctl_rssi[2],
  151. * spec_samp_msg->samp_data.spectral_chain_ext_rssi[0],
  152. * spec_samp_msg->samp_data.spectral_chain_ext_rssi[1],
  153. * spec_samp_msg->samp_data.spectral_chain_ext_rssi[2]);
  154. */
  155. for (i = 0; i < ATH_HOST_MAX_ANTENNA; i++) {
  156. uint32_t index;
  157. if (spectral->noise_pwr_chain_ctl[i]) {
  158. index = spectral->noise_pwr_chain_ctl[i]->rptcount++;
  159. spectral->noise_pwr_chain_ctl[i]->pwr[index] =
  160. spec_samp_msg->samp_data.spectral_chain_ctl_rssi[i];
  161. }
  162. if (spectral->noise_pwr_chain_ext[i]) {
  163. index = spectral->noise_pwr_chain_ext[i]->rptcount++;
  164. spectral->noise_pwr_chain_ext[i]->pwr[index] =
  165. spec_samp_msg->samp_data.spectral_chain_ext_rssi[i];
  166. }
  167. }
  168. }
  169. done = (spectral->noise_pwr_reports_recv >=
  170. spectral->noise_pwr_reports_reqd);
  171. qdf_spin_unlock(&spectral->noise_pwr_reports_lock);
  172. if (done) {
  173. qdf_spin_lock(&spectral->ath_spectral_lock);
  174. target_if_stop_spectral_scan(spectral->pdev_obj);
  175. spectral->sc_spectral_scan = 0;
  176. qdf_spin_unlock(&spectral->ath_spectral_lock);
  177. /*
  178. * qdf_print(
  179. * "%s: done: %d/%d recv - set sc_spectral_scan = 0\n",
  180. * __func__, spectral->noise_pwr_reports_recv,
  181. * spectral->noise_pwr_reports_reqd);
  182. */
  183. }
  184. }
  185. /*
  186. * Function : spectral_create_samp_msg
  187. * Description : create SAMP message and send it host
  188. * Input :
  189. * Output :
  190. *
  191. */
  192. void target_if_spectral_create_samp_msg(
  193. struct target_if_spectral *spectral,
  194. struct target_if_samp_msg_params *params)
  195. {
  196. /*
  197. * XXX : Non-Rentrant. Will be an issue with dual concurrent
  198. * operation on multi-processor system
  199. */
  200. int temp_samp_msg_len = 0;
  201. static SPECTRAL_SAMP_MSG spec_samp_msg;
  202. SPECTRAL_SAMP_MSG *msg = NULL;
  203. SPECTRAL_SAMP_DATA *data = NULL;
  204. u_int8_t *bin_pwr_data = NULL;
  205. SPECTRAL_CLASSIFIER_PARAMS *cp = NULL;
  206. SPECTRAL_CLASSIFIER_PARAMS *pcp = NULL;
  207. struct target_if_spectral_ops *p_sops = NULL;
  208. struct target_if_spectral_skb_event *sp_skb_event = NULL;
  209. #ifdef SPECTRAL_USE_NETLINK_SOCKETS
  210. static int samp_msg_index;
  211. #endif
  212. p_sops = GET_TIF_SPECTRAL_OPS(spectral);
  213. temp_samp_msg_len = sizeof(SPECTRAL_SAMP_MSG) -
  214. (MAX_NUM_BINS * sizeof(u_int8_t));
  215. temp_samp_msg_len += (params->pwr_count * sizeof(u_int8_t));
  216. if (spectral->ch_width == CH_WIDTH_160MHZ)
  217. temp_samp_msg_len +=
  218. (params->pwr_count_sec80 * sizeof(u_int8_t));
  219. bin_pwr_data = params->bin_pwr_data;
  220. memset(&spec_samp_msg, 0, sizeof(SPECTRAL_SAMP_MSG));
  221. data = &spec_samp_msg.samp_data;
  222. spec_samp_msg.signature = SPECTRAL_SIGNATURE;
  223. spec_samp_msg.freq = params->freq;
  224. spec_samp_msg.freq_loading = params->freq_loading;
  225. spec_samp_msg.samp_data.spectral_data_len = params->datalen;
  226. spec_samp_msg.samp_data.spectral_rssi = params->rssi;
  227. spec_samp_msg.samp_data.ch_width = spectral->ch_width;
  228. spec_samp_msg.samp_data.spectral_combined_rssi =
  229. (u_int8_t)params->rssi;
  230. spec_samp_msg.samp_data.spectral_upper_rssi = params->upper_rssi;
  231. spec_samp_msg.samp_data.spectral_lower_rssi = params->lower_rssi;
  232. OS_MEMCPY(
  233. spec_samp_msg.samp_data.spectral_chain_ctl_rssi,
  234. params->chain_ctl_rssi,
  235. sizeof(params->chain_ctl_rssi));
  236. OS_MEMCPY(
  237. spec_samp_msg.samp_data.spectral_chain_ext_rssi,
  238. params->chain_ext_rssi,
  239. sizeof(params->chain_ext_rssi));
  240. spec_samp_msg.samp_data.spectral_bwinfo = params->bwinfo;
  241. spec_samp_msg.samp_data.spectral_tstamp = params->tstamp;
  242. spec_samp_msg.samp_data.spectral_max_index = params->max_index;
  243. /* Classifier in user space needs access to these */
  244. spec_samp_msg.samp_data.spectral_lower_max_index =
  245. params->max_lower_index;
  246. spec_samp_msg.samp_data.spectral_upper_max_index =
  247. params->max_upper_index;
  248. spec_samp_msg.samp_data.spectral_nb_lower =
  249. params->nb_lower;
  250. spec_samp_msg.samp_data.spectral_nb_upper = params->nb_upper;
  251. spec_samp_msg.samp_data.spectral_last_tstamp =
  252. params->last_tstamp;
  253. spec_samp_msg.samp_data.spectral_max_mag = params->max_mag;
  254. spec_samp_msg.samp_data.bin_pwr_count =
  255. params->pwr_count;
  256. spec_samp_msg.samp_data.lb_edge_extrabins =
  257. spectral->lb_edge_extrabins;
  258. spec_samp_msg.samp_data.rb_edge_extrabins =
  259. spectral->rb_edge_extrabins;
  260. spec_samp_msg.samp_data.spectral_combined_rssi = params->rssi;
  261. spec_samp_msg.samp_data.spectral_max_scale = params->max_exp;
  262. #ifdef SPECTRAL_USE_NETLINK_SOCKETS
  263. /*
  264. * This is a dirty hack to get the Windows build pass.
  265. * Currently Windows and Linux builds source spectral_data.h
  266. * form two different place. The windows version do not
  267. * have noise_floor member in it.
  268. *
  269. * As a temp workaround this variable is set under the
  270. * SPECTRAL_USE_NETLINK_SOCKETS as this is called only
  271. * under the linux build and this saves the day
  272. *
  273. * The plan to sync of header files in under the way
  274. *
  275. */
  276. spec_samp_msg.samp_data.noise_floor = params->noise_floor;
  277. #endif /* SPECTRAL_USE_NETLINK_SOCKETS */
  278. /* Classifier in user space needs access to these */
  279. cp = &spec_samp_msg.samp_data.classifier_params;
  280. pcp = &params->classifier_params;
  281. OS_MEMCPY(cp, pcp, sizeof(SPECTRAL_CLASSIFIER_PARAMS));
  282. SPECTRAL_MSG_COPY_CHAR_ARRAY(
  283. &data->bin_pwr[0],
  284. bin_pwr_data,
  285. params->pwr_count);
  286. #ifdef SPECTRAL_USE_NETLINK_SOCKETS
  287. spec_samp_msg.vhtop_ch_freq_seg1 =
  288. params->vhtop_ch_freq_seg1;
  289. spec_samp_msg.vhtop_ch_freq_seg2 =
  290. params->vhtop_ch_freq_seg2;
  291. if (spectral->ch_width == CH_WIDTH_160MHZ) {
  292. spec_samp_msg.samp_data.spectral_rssi_sec80 = params->rssi_sec80;
  293. spec_samp_msg.samp_data.noise_floor_sec80 = params->noise_floor_sec80;
  294. spec_samp_msg.samp_data.spectral_data_len_sec80 =
  295. params->datalen_sec80;
  296. spec_samp_msg.samp_data.spectral_max_index_sec80 =
  297. params->max_index_sec80;
  298. spec_samp_msg.samp_data.spectral_max_mag_sec80 =
  299. params->max_mag_sec80;
  300. spec_samp_msg.samp_data.bin_pwr_count_sec80 =
  301. params->pwr_count_sec80;
  302. SPECTRAL_MSG_COPY_CHAR_ARRAY(&data->bin_pwr_sec80[0],
  303. (params->bin_pwr_data_sec80),
  304. params->pwr_count_sec80);
  305. /* Note: REVERSE_ORDER is not a known use case for secondary 80 data at
  306. * this point.
  307. */
  308. }
  309. #endif /* SPECTRAL_USE_NETLINK_SOCKETS */
  310. #ifdef SPECTRAL_CLASSIFIER_IN_KERNEL
  311. if (params->interf_list.count)
  312. OS_MEMCPY(
  313. &data->interf_list,
  314. &params->interf_list,
  315. sizeof(struct INTERF_SRC_RSP));
  316. else
  317. #endif
  318. data->interf_list.count = 0;
  319. #ifdef SPECTRAL_USE_NETLINK_SOCKETS
  320. target_if_spectral_prep_skb(spectral);
  321. if (spectral->spectral_skb) {
  322. p_sops->get_mac_address(spectral, spec_samp_msg.macaddr);
  323. spectral->spectral_nlh =
  324. (struct nlmsghdr *)spectral->spectral_skb->data;
  325. memcpy(NLMSG_DATA(spectral->spectral_nlh),
  326. &spec_samp_msg,
  327. sizeof(SPECTRAL_SAMP_MSG));
  328. msg = (SPECTRAL_SAMP_MSG *)NLMSG_DATA(spectral->spectral_nlh);
  329. /* Broadcast spectral data only if it is a edma supported device */
  330. if (!spectral->sc_spectral_non_edma)
  331. target_if_spectral_bcast_msg(spectral);
  332. samp_msg_index++;
  333. }
  334. /* Check if the device is non-edma and follow the required broadcast
  335. * path if true
  336. */
  337. if (spectral->sc_spectral_non_edma) {
  338. /* Allocating memory for the queue entity to hold the spectral socket
  339. * buffer
  340. */
  341. sp_skb_event = (struct target_if_spectral_skb_event
  342. *)qdf_mem_malloc(sizeof(struct target_if_spectral_skb_event));
  343. if (sp_skb_event) {
  344. OS_MEMZERO(
  345. sp_skb_event,
  346. sizeof(struct target_if_spectral_skb_event));
  347. sp_skb_event->sp_skb = spectral->spectral_skb;
  348. sp_skb_event->sp_nlh = spectral->spectral_nlh;
  349. spectral->spectral_skb = NULL;
  350. spectral->spectral_nlh = NULL;
  351. /* Queue spectral socket buffers to be broadcasted outside irq
  352. * lock
  353. */
  354. qdf_spin_lock(&spectral->spectral_skbqlock);
  355. STAILQ_INSERT_TAIL(
  356. &spectral->spectral_skbq,
  357. sp_skb_event,
  358. spectral_skb_list);
  359. qdf_spin_unlock(&spectral->spectral_skbqlock);
  360. }
  361. }
  362. #else
  363. /*
  364. * call the indicate function to pass the data to the net layer
  365. * Windows will pass to a spectral WIN32 service
  366. */
  367. msg = (SPECTRAL_SAMP_MSG *)qdf_mem_malloc(sizeof(SPECTRAL_SAMP_MSG));
  368. if (msg) {
  369. OS_MEMCPY(msg, &spec_samp_msg, sizeof(SPECTRAL_SAMP_MSG));
  370. ath_spectral_indicate(
  371. params->sc,
  372. (void *)msg,
  373. sizeof(SPECTRAL_SAMP_MSG));
  374. OS_FREE(msg);
  375. msg = NULL;
  376. } else {
  377. qdf_print("No buffer\n");
  378. }
  379. #endif /* SPECTRAL_USE_NETLINK_SOCKETS */
  380. if (spectral->sc_spectral_noise_pwr_cal)
  381. spectral_process_noise_pwr_report(spectral, &spec_samp_msg);
  382. }
  383. #ifdef SPECTRAL_USE_NETLINK_SOCKETS
  384. void target_if_spectral_prep_skb(struct target_if_spectral *spectral)
  385. {
  386. spectral->spectral_skb = dev_alloc_skb(MAX_SPECTRAL_PAYLOAD);
  387. if (spectral->spectral_skb) {
  388. skb_put(spectral->spectral_skb, MAX_SPECTRAL_PAYLOAD);
  389. spectral->spectral_nlh =
  390. (struct nlmsghdr *)spectral->spectral_skb->data;
  391. OS_MEMZERO(spectral->spectral_nlh, sizeof(*spectral->spectral_nlh));
  392. /* Possible bug that size of SPECTRAL_SAMP_MSG and SPECTRAL_MSG
  393. * differ by 3 bytes so we miss 3 bytes
  394. */
  395. spectral->spectral_nlh->nlmsg_len =
  396. NLMSG_SPACE(sizeof(SPECTRAL_SAMP_MSG));
  397. spectral->spectral_nlh->nlmsg_pid = 0;
  398. spectral->spectral_nlh->nlmsg_flags = 0;
  399. } else {
  400. spectral->spectral_skb = NULL;
  401. spectral->spectral_nlh = NULL;
  402. }
  403. }
  404. void target_if_spectral_unicast_msg(struct target_if_spectral *spectral)
  405. {
  406. if (!spectral) {
  407. qdf_print("%s Spectral is NULL\n", __func__);
  408. return;
  409. }
  410. if (!spectral->spectral_sock) {
  411. qdf_print("%s Spectral Socket is invalid\n", __func__);
  412. dev_kfree_skb(spectral->spectral_skb);
  413. spectral->spectral_skb = NULL;
  414. return;
  415. }
  416. if (spectral->spectral_skb) {
  417. #if (KERNEL_VERSION(2, 6, 31) > LINUX_VERSION_CODE)
  418. NETLINK_CB(spectral->spectral_skb).dst_pid = spectral->spectral_pid;
  419. #endif /* VERSION - field depracated by newer kernel */
  420. #if KERNEL_VERSION(3, 7, 0) > LINUX_VERSION_CODE
  421. NETLINK_CB(spectral->spectral_skb).pid = 0; /* from kernel */
  422. #else
  423. NETLINK_CB(spectral->spectral_skb).portid = 0; /* from kernel */
  424. #endif
  425. /* to mcast group 1<<0 */
  426. NETLINK_CB(spectral->spectral_skb).dst_group = 0;
  427. netlink_unicast(
  428. spectral->spectral_sock,
  429. spectral->spectral_skb,
  430. spectral->spectral_pid,
  431. MSG_DONTWAIT);
  432. }
  433. }
  434. /*
  435. * Function : target_if_spectral_bcast_msg
  436. * Description : Passes the Spectral Message to Host
  437. * Input : Pointer to spectral
  438. * Output : Void
  439. *
  440. */
  441. void target_if_spectral_bcast_msg(struct target_if_spectral *spectral)
  442. {
  443. #if (KERNEL_VERSION(2, 6, 31) >= LINUX_VERSION_CODE)
  444. fd_set write_set;
  445. #endif
  446. SPECTRAL_SAMP_MSG *msg = NULL;
  447. struct nlmsghdr *nlh = NULL;
  448. int status;
  449. #if (KERNEL_VERSION(2, 6, 31) >= LINUX_VERSION_CODE)
  450. FD_ZERO(&write_set);
  451. #endif
  452. if (!spectral)
  453. return;
  454. if (!spectral->spectral_sock) {
  455. dev_kfree_skb(spectral->spectral_skb);
  456. spectral->spectral_skb = NULL;
  457. return;
  458. }
  459. if (!spectral->spectral_skb)
  460. return;
  461. nlh = (struct nlmsghdr *)spectral->spectral_skb->data;
  462. msg = (SPECTRAL_SAMP_MSG *)NLMSG_DATA(spectral->spectral_nlh);
  463. /* print_samp_msg (msg, sc); */
  464. status = target_if_send_phydata(
  465. spectral->pdev_obj,
  466. spectral->spectral_sock,
  467. spectral->spectral_skb);
  468. if (status == 0)
  469. spectral->spectral_sent_msg++;
  470. /* netlink will have freed the skb */
  471. if (spectral->spectral_skb)
  472. spectral->spectral_skb = NULL;
  473. }
  474. void target_if_spectral_skb_dequeue(unsigned long data)
  475. {
  476. struct target_if_spectral *spectral =
  477. (struct target_if_spectral *)data;
  478. struct target_if_spectral_skb_event *sp_skb_event = NULL;
  479. qdf_spin_lock(&spectral->spectral_skbqlock);
  480. /* Deque all the spectral socket buffers queued */
  481. while (!STAILQ_EMPTY(&spectral->spectral_skbq)) {
  482. sp_skb_event = STAILQ_FIRST(&spectral->spectral_skbq);
  483. if (sp_skb_event) {
  484. spectral->spectral_skb = sp_skb_event->sp_skb;
  485. spectral->spectral_nlh = sp_skb_event->sp_nlh;
  486. STAILQ_REMOVE_HEAD(
  487. &spectral->spectral_skbq,
  488. spectral_skb_list);
  489. qdf_spin_unlock(&spectral->spectral_skbqlock);
  490. OS_FREE(sp_skb_event);
  491. /* Broadcast spectral data after dequeing */
  492. target_if_spectral_bcast_msg(spectral);
  493. qdf_spin_lock(&spectral->spectral_skbqlock);
  494. }
  495. }
  496. qdf_spin_unlock(&spectral->spectral_skbqlock);
  497. }
  498. #endif /* SPECTRAL_USE_NETLINK_SOCKETS */