target_if_spectral_netlink.c 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. /*
  2. * Copyright (c) 2011,2017-2018 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. void
  29. target_if_spectral_create_samp_msg(struct target_if_spectral *spectral,
  30. struct target_if_samp_msg_params *params)
  31. {
  32. /*
  33. * XXX : Non-Rentrant. Will be an issue with dual concurrent
  34. * operation on multi-processor system
  35. */
  36. int temp_samp_msg_len = 0;
  37. struct spectral_samp_msg *spec_samp_msg = NULL;
  38. uint8_t *bin_pwr_data = NULL;
  39. struct spectral_classifier_params *cp = NULL;
  40. struct spectral_classifier_params *pcp = NULL;
  41. struct target_if_spectral_ops *p_sops = NULL;
  42. uint32_t *binptr_32 = NULL;
  43. uint16_t *binptr_16 = NULL;
  44. int idx = 0;
  45. struct spectral_samp_data *samp_data;
  46. static int samp_msg_index;
  47. if (is_primaryseg_rx_inprog(spectral)) {
  48. spec_samp_msg = (struct spectral_samp_msg *)
  49. spectral->nl_cb.get_nbuff(spectral->pdev_obj);
  50. if (!spec_samp_msg)
  51. return;
  52. samp_data = &spec_samp_msg->samp_data;
  53. if (spectral->spectral_gen == SPECTRAL_GEN3)
  54. save_spectral_report_skb(spectral, spec_samp_msg);
  55. p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral);
  56. temp_samp_msg_len = sizeof(struct spectral_samp_msg) -
  57. (MAX_NUM_BINS * sizeof(uint8_t));
  58. temp_samp_msg_len += (params->pwr_count * sizeof(uint8_t));
  59. if (spectral->ch_width == CH_WIDTH_160MHZ)
  60. temp_samp_msg_len +=
  61. (params->pwr_count_sec80 * sizeof(uint8_t));
  62. bin_pwr_data = params->bin_pwr_data;
  63. spec_samp_msg->signature = SPECTRAL_SIGNATURE;
  64. spec_samp_msg->freq = params->freq;
  65. spec_samp_msg->freq_loading = params->freq_loading;
  66. samp_data->spectral_data_len = params->datalen;
  67. samp_data->spectral_rssi = params->rssi;
  68. samp_data->ch_width = spectral->ch_width;
  69. samp_data->spectral_agc_total_gain = params->agc_total_gain;
  70. samp_data->spectral_gainchange = params->gainchange;
  71. samp_data->spectral_combined_rssi =
  72. (uint8_t)params->rssi;
  73. samp_data->spectral_upper_rssi = params->upper_rssi;
  74. samp_data->spectral_lower_rssi = params->lower_rssi;
  75. qdf_mem_copy(samp_data->spectral_chain_ctl_rssi,
  76. params->chain_ctl_rssi,
  77. sizeof(params->chain_ctl_rssi));
  78. qdf_mem_copy(samp_data->spectral_chain_ext_rssi,
  79. params->chain_ext_rssi,
  80. sizeof(params->chain_ext_rssi));
  81. samp_data->spectral_bwinfo = params->bwinfo;
  82. samp_data->spectral_tstamp = params->tstamp;
  83. samp_data->spectral_max_index = params->max_index;
  84. /* Classifier in user space needs access to these */
  85. samp_data->spectral_lower_max_index =
  86. params->max_lower_index;
  87. samp_data->spectral_upper_max_index =
  88. params->max_upper_index;
  89. samp_data->spectral_nb_lower = params->nb_lower;
  90. samp_data->spectral_nb_upper = params->nb_upper;
  91. samp_data->spectral_last_tstamp = params->last_tstamp;
  92. samp_data->spectral_max_mag = params->max_mag;
  93. samp_data->bin_pwr_count = params->pwr_count;
  94. samp_data->lb_edge_extrabins =
  95. spectral->lb_edge_extrabins;
  96. samp_data->rb_edge_extrabins =
  97. spectral->rb_edge_extrabins;
  98. samp_data->spectral_combined_rssi = params->rssi;
  99. samp_data->spectral_max_scale = params->max_exp;
  100. samp_data->noise_floor = params->noise_floor;
  101. /* Classifier in user space needs access to these */
  102. cp = &samp_data->classifier_params;
  103. pcp = &params->classifier_params;
  104. qdf_mem_copy(cp, pcp,
  105. sizeof(struct spectral_classifier_params));
  106. if (spectral->fftbin_size_war ==
  107. SPECTRAL_FFTBIN_SIZE_WAR_4BYTE_TO_1BYTE) {
  108. binptr_32 = (uint32_t *)bin_pwr_data;
  109. for (idx = 0; idx < params->pwr_count; idx++)
  110. samp_data->bin_pwr[idx] = *(binptr_32++);
  111. } else if (spectral->fftbin_size_war ==
  112. SPECTRAL_FFTBIN_SIZE_WAR_2BYTE_TO_1BYTE) {
  113. binptr_16 = (uint16_t *)bin_pwr_data;
  114. for (idx = 0; idx < params->pwr_count; idx++)
  115. samp_data->bin_pwr[idx] = *(binptr_16++);
  116. } else {
  117. SPECTRAL_MESSAGE_COPY_CHAR_ARRAY(
  118. &samp_data->bin_pwr[0], bin_pwr_data,
  119. params->pwr_count);
  120. }
  121. p_sops->get_mac_address(spectral, spec_samp_msg->macaddr);
  122. }
  123. if (is_secondaryseg_rx_inprog(spectral)) {
  124. if (spectral->spectral_gen == SPECTRAL_GEN3)
  125. restore_spectral_report_skb(spectral,
  126. (void **)&spec_samp_msg);
  127. if (!spec_samp_msg) {
  128. spectral_err("Spectral SAMP message is NULL");
  129. return;
  130. }
  131. samp_data = &spec_samp_msg->samp_data;
  132. spec_samp_msg->vhtop_ch_freq_seg1 = params->vhtop_ch_freq_seg1;
  133. spec_samp_msg->vhtop_ch_freq_seg2 = params->vhtop_ch_freq_seg2;
  134. samp_data->spectral_rssi_sec80 =
  135. params->rssi_sec80;
  136. samp_data->noise_floor_sec80 =
  137. params->noise_floor_sec80;
  138. spec_samp_msg->samp_data.spectral_agc_total_gain_sec80 =
  139. params->agc_total_gain_sec80;
  140. spec_samp_msg->samp_data.spectral_gainchange_sec80 =
  141. params->gainchange_sec80;
  142. samp_data->spectral_data_len_sec80 =
  143. params->datalen_sec80;
  144. samp_data->spectral_max_index_sec80 =
  145. params->max_index_sec80;
  146. samp_data->spectral_max_mag_sec80 =
  147. params->max_mag_sec80;
  148. samp_data->bin_pwr_count_sec80 =
  149. params->pwr_count_sec80;
  150. bin_pwr_data = params->bin_pwr_data_sec80;
  151. if (spectral->fftbin_size_war ==
  152. SPECTRAL_FFTBIN_SIZE_WAR_4BYTE_TO_1BYTE) {
  153. binptr_32 = (uint32_t *)bin_pwr_data;
  154. for (idx = 0; idx < params->pwr_count_sec80; idx++)
  155. samp_data->bin_pwr_sec80[idx] = *(binptr_32++);
  156. } else if (spectral->fftbin_size_war ==
  157. SPECTRAL_FFTBIN_SIZE_WAR_2BYTE_TO_1BYTE) {
  158. binptr_16 = (uint16_t *)bin_pwr_data;
  159. for (idx = 0; idx < params->pwr_count_sec80; idx++)
  160. samp_data->bin_pwr_sec80[idx] = *(binptr_16++);
  161. } else {
  162. SPECTRAL_MESSAGE_COPY_CHAR_ARRAY(
  163. &samp_data->bin_pwr_sec80[0],
  164. params->bin_pwr_data_sec80,
  165. params->pwr_count_sec80);
  166. }
  167. }
  168. if ((spectral->ch_width != CH_WIDTH_160MHZ) ||
  169. is_secondaryseg_rx_inprog(spectral)) {
  170. if (spectral->send_phy_data(spectral->pdev_obj) == 0)
  171. spectral->spectral_sent_msg++;
  172. samp_msg_index++;
  173. if (spectral->spectral_gen == SPECTRAL_GEN3)
  174. clear_spectral_report_skb(spectral);
  175. }
  176. /* Take care of state transitions for 160MHz/ 80p80 */
  177. if (spectral->spectral_gen == SPECTRAL_GEN3)
  178. target_if_160mhz_delivery_state_change(
  179. spectral,
  180. SPECTRAL_REPORT_EVENT_DETECTORID_INVALID);
  181. }