1 /* 2 * Copyright (c) 2011,2017-2021 The Linux Foundation. All rights reserved. 3 * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved. 4 * 5 * 6 * Permission to use, copy, modify, and/or distribute this software for 7 * any purpose with or without fee is hereby granted, provided that the 8 * above copyright notice and this permission notice appear in all 9 * copies. 10 * 11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 15 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 16 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 17 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 18 * PERFORMANCE OF THIS SOFTWARE. 19 */ 20 21 #include <osdep.h> 22 #include <wlan_tgt_def_config.h> 23 #include <hif.h> 24 #include <hif_hw_version.h> 25 #include <wmi_unified_api.h> 26 #include <target_if_spectral.h> 27 #include <wlan_lmac_if_def.h> 28 #include <wlan_osif_priv.h> 29 #include <reg_services_public_struct.h> 30 31 extern int spectral_debug_level; 32 33 #ifdef OPTIMIZED_SAMP_MESSAGE 34 QDF_STATUS 35 target_if_spectral_fill_samp_msg(struct target_if_spectral *spectral, 36 struct target_if_samp_msg_params *params) 37 { 38 struct spectral_samp_msg *spec_samp_msg; 39 struct per_session_det_map *det_map; 40 enum spectral_msg_type msg_type; 41 QDF_STATUS ret; 42 uint16_t dest_det_idx; 43 enum spectral_scan_mode spectral_mode; 44 uint16_t pwr_format; 45 struct spectral_data_stats *spectral_dp_stats; 46 47 if (!spectral) { 48 spectral_err_rl("Spectral LMAC object is null"); 49 return QDF_STATUS_E_NULL_VALUE; 50 } 51 52 spectral_dp_stats = &spectral->data_stats; 53 spectral_dp_stats->fill_samp_msg_calls++; 54 55 if (!params) { 56 spectral_err_rl("SAMP msg params structure is null"); 57 return QDF_STATUS_E_NULL_VALUE; 58 } 59 60 if (params->hw_detector_id >= SPECTRAL_DETECTOR_ID_MAX) { 61 spectral_err_rl("Invalid detector ID"); 62 return QDF_STATUS_E_FAILURE; 63 } 64 65 spectral_mode = 66 spectral->rparams.detid_mode_table[params->hw_detector_id]; 67 if (spectral_mode >= SPECTRAL_SCAN_MODE_MAX) { 68 spectral_err_rl("No valid Spectral mode for detector id %u", 69 params->hw_detector_id); 70 return QDF_STATUS_E_FAILURE; 71 } 72 73 ret = target_if_get_spectral_msg_type(spectral_mode, 74 &msg_type); 75 if (QDF_IS_STATUS_ERROR(ret)) { 76 spectral_err_rl("Invalid spectral msg type"); 77 return QDF_STATUS_E_FAILURE; 78 } 79 80 pwr_format = spectral->params[spectral_mode].ss_pwr_format; 81 82 qdf_spin_lock_bh(&spectral->session_det_map_lock); 83 84 if (!spectral->det_map[params->hw_detector_id]. 85 det_map_valid[spectral_mode]) { 86 qdf_spin_unlock_bh(&spectral->session_det_map_lock); 87 spectral_info("Detector Map not valid for det id = %d and spectral mode = %d", 88 params->hw_detector_id, spectral_mode); 89 return QDF_STATUS_E_FAILURE; 90 } 91 92 det_map = &spectral->det_map[params->hw_detector_id]; 93 94 spec_samp_msg = spectral->nl_cb.get_sbuff(spectral->pdev_obj, 95 msg_type, 96 det_map->buf_type); 97 if (!spec_samp_msg) { 98 qdf_spin_unlock_bh(&spectral->session_det_map_lock); 99 spectral_err_rl("Spectral SAMP message is NULL"); 100 return QDF_STATUS_E_FAILURE; 101 } 102 103 for (dest_det_idx = 0; dest_det_idx < det_map->num_dest_det_info; 104 dest_det_idx++) { 105 struct per_session_dest_det_info *map_det_info; 106 struct samp_freq_span_info *span_info; 107 struct samp_detector_info *detector_info; 108 uint8_t dest_detector_id; 109 uint8_t span_id; 110 struct samp_edge_extra_bin_info *lb_edge_bins; 111 struct samp_edge_extra_bin_info *rb_edge_bins; 112 uint8_t *bin_pwr_data; 113 size_t pwr_count; 114 uint16_t num_edge_bins; 115 uint16_t start_bin_index; 116 uint32_t bytes_copied; 117 118 119 map_det_info = &det_map->dest_det_info[dest_det_idx]; 120 span_id = map_det_info->freq_span_id; 121 span_info = &spec_samp_msg->freq_span_info[span_id]; 122 span_info->num_detectors++; 123 124 dest_detector_id = map_det_info->det_id; 125 detector_info = &span_info->detector_info[dest_detector_id]; 126 lb_edge_bins = &detector_info->left_edge_bins; 127 rb_edge_bins = &detector_info->right_edge_bins; 128 129 detector_info->start_frequency = map_det_info->start_freq; 130 detector_info->end_frequency = map_det_info->end_freq; 131 detector_info->start_bin_idx = map_det_info->dest_start_bin_idx; 132 detector_info->end_bin_idx = map_det_info->dest_end_bin_idx; 133 lb_edge_bins->start_bin_idx = 134 map_det_info->lb_extrabins_start_idx; 135 lb_edge_bins->num_bins = map_det_info->lb_extrabins_num; 136 rb_edge_bins->start_bin_idx = 137 map_det_info->rb_extrabins_start_idx; 138 rb_edge_bins->num_bins = map_det_info->rb_extrabins_num; 139 start_bin_index = detector_info->start_bin_idx; 140 141 detector_info->rssi = params->rssi; 142 143 detector_info->last_raw_timestamp = params->last_raw_timestamp; 144 detector_info->reset_delay = params->reset_delay; 145 detector_info->raw_timestamp = params->raw_timestamp; 146 detector_info->timestamp = params->timestamp; 147 detector_info->timestamp_war_offset = spectral->timestamp_war. 148 timestamp_war_offset[spectral_mode]; 149 150 detector_info->max_magnitude = params->max_mag; 151 detector_info->max_index = params->max_index; 152 153 detector_info->noise_floor = params->noise_floor; 154 detector_info->agc_total_gain = params->agc_total_gain; 155 detector_info->gainchange = params->gainchange; 156 detector_info->is_sec80 = map_det_info->is_sec80; 157 detector_info->blanking_status = params->blanking_status; 158 /* In 165MHz, Pri80 indication to be set for Span ID 0 only */ 159 if (span_id == SPECTRAL_FREQ_SPAN_ID_0) 160 detector_info->pri80ind = params->pri80ind; 161 162 bin_pwr_data = ¶ms->bin_pwr_data 163 [map_det_info->src_start_bin_idx]; 164 pwr_count = detector_info->end_bin_idx - 165 detector_info->start_bin_idx + 1; 166 num_edge_bins = lb_edge_bins->num_bins + 167 rb_edge_bins->num_bins; 168 169 /* Copy left edge bins */ 170 if (lb_edge_bins->num_bins > 0) { 171 ret = target_if_spectral_copy_fft_bins( 172 spectral, bin_pwr_data, 173 &spec_samp_msg->bin_pwr[ 174 lb_edge_bins->start_bin_idx], 175 lb_edge_bins->num_bins, 176 &bytes_copied, pwr_format); 177 178 if (QDF_IS_STATUS_ERROR(ret)) { 179 qdf_spin_unlock_bh( 180 &spectral->session_det_map_lock); 181 spectral_err_rl("Unable to copy left edge FFT bins"); 182 return QDF_STATUS_E_FAILURE; 183 } 184 185 /* Advance the fft bin pointer in the report */ 186 bin_pwr_data += bytes_copied; 187 } 188 189 /* Copy the in-band and out-band bins */ 190 ret = target_if_spectral_copy_fft_bins( 191 spectral, bin_pwr_data, 192 &spec_samp_msg->bin_pwr[start_bin_index], 193 pwr_count, 194 &bytes_copied, pwr_format); 195 196 if (QDF_IS_STATUS_ERROR(ret)) { 197 qdf_spin_unlock_bh( 198 &spectral->session_det_map_lock); 199 spectral_err_rl("Unable to copy in-band/out-band FFT bins"); 200 return QDF_STATUS_E_FAILURE; 201 } 202 /* Advance the fft bin pointer in the report */ 203 bin_pwr_data += bytes_copied; 204 205 /* Copy right edge bins */ 206 if (rb_edge_bins->num_bins > 0) { 207 ret = target_if_spectral_copy_fft_bins( 208 spectral, bin_pwr_data, 209 &spec_samp_msg->bin_pwr[ 210 rb_edge_bins->start_bin_idx], 211 rb_edge_bins->num_bins, 212 &bytes_copied, pwr_format); 213 214 if (QDF_IS_STATUS_ERROR(ret)) { 215 qdf_spin_unlock_bh( 216 &spectral->session_det_map_lock); 217 spectral_err_rl("Unable to copy right edge FFT bins"); 218 return QDF_STATUS_E_FAILURE; 219 } 220 221 /* Advance the fft bin pointer in the report */ 222 bin_pwr_data += bytes_copied; 223 } 224 225 spec_samp_msg->bin_pwr_count += (pwr_count + num_edge_bins); 226 } 227 228 if (det_map->send_to_upper_layers) { 229 /* Fill per-report information */ 230 struct per_session_report_info *rpt_info; 231 struct target_if_spectral_ops *p_sops; 232 233 p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral); 234 235 qdf_spin_lock_bh(&spectral->session_report_info_lock); 236 237 rpt_info = &spectral->report_info[spectral_mode]; 238 239 if (!rpt_info->valid) { 240 qdf_spin_unlock_bh(&spectral->session_report_info_lock); 241 qdf_spin_unlock_bh(&spectral->session_det_map_lock); 242 spectral_info("per-session report info is not valid"); 243 return QDF_STATUS_E_FAILURE; 244 } 245 246 spec_samp_msg->signature = SPECTRAL_SIGNATURE; 247 p_sops->get_mac_address(spectral, spec_samp_msg->macaddr); 248 spec_samp_msg->spectral_mode = spectral_mode; 249 spec_samp_msg->target_reset_count = 250 spectral->timestamp_war.target_reset_count; 251 spec_samp_msg->operating_bw = spectral->nl_cb. 252 convert_to_nl_ch_width(rpt_info->operating_bw); 253 if (spec_samp_msg->operating_bw < 0) { 254 spectral_err_rl("Invalid operating channel width %d", 255 rpt_info->operating_bw); 256 return QDF_STATUS_E_FAILURE; 257 } 258 spec_samp_msg->pri20_freq = rpt_info->pri20_freq; 259 spec_samp_msg->cfreq1 = rpt_info->cfreq1; 260 spec_samp_msg->cfreq2 = rpt_info->cfreq2; 261 spec_samp_msg->sscan_cfreq1 = rpt_info->sscan_cfreq1; 262 spec_samp_msg->sscan_cfreq2 = rpt_info->sscan_cfreq2; 263 spec_samp_msg->sscan_bw = spectral->nl_cb. 264 convert_to_nl_ch_width(rpt_info->sscan_bw); 265 if (spec_samp_msg->sscan_bw < 0) { 266 spectral_err_rl("Invalid sscan channel width %d", 267 rpt_info->sscan_bw); 268 return QDF_STATUS_E_FAILURE; 269 } 270 spec_samp_msg->fft_width = FFT_BIN_SIZE_1BYTE; 271 spec_samp_msg->num_freq_spans = rpt_info->num_spans; 272 273 qdf_spin_unlock_bh(&spectral->session_report_info_lock); 274 275 spec_samp_msg->spectral_upper_rssi = params->upper_rssi; 276 spec_samp_msg->spectral_lower_rssi = params->lower_rssi; 277 qdf_mem_copy(spec_samp_msg->spectral_chain_ctl_rssi, 278 params->chain_ctl_rssi, 279 sizeof(params->chain_ctl_rssi)); 280 qdf_mem_copy(spec_samp_msg->spectral_chain_ext_rssi, 281 params->chain_ext_rssi, 282 sizeof(params->chain_ext_rssi)); 283 284 if (spectral_debug_level & DEBUG_SPECTRAL4) 285 target_if_dbg_print_samp_msg(spec_samp_msg); 286 287 spectral_dp_stats->msgs_ready_for_user++; 288 if (spectral->send_phy_data(spectral->pdev_obj, 289 msg_type) == 0) { 290 spectral->spectral_sent_msg++; 291 spectral_dp_stats->msgs_queued_to_user++; 292 } 293 if (spectral->spectral_gen == SPECTRAL_GEN3) 294 reset_160mhz_delivery_state_machine(spectral, 295 spectral_mode); 296 } 297 qdf_spin_unlock_bh(&spectral->session_det_map_lock); 298 299 return QDF_STATUS_SUCCESS; 300 } 301 #endif /* OPTIMIZED_SAMP_MESSAGE */ 302 303 #ifndef OPTIMIZED_SAMP_MESSAGE 304 void 305 target_if_spectral_create_samp_msg(struct target_if_spectral *spectral, 306 struct target_if_samp_msg_params *params) 307 { 308 /* 309 * XXX : Non-Rentrant. Will be an issue with dual concurrent 310 * operation on multi-processor system 311 */ 312 313 struct spectral_samp_msg *spec_samp_msg = NULL; 314 315 uint8_t *bin_pwr_data = NULL; 316 struct spectral_classifier_params *cp = NULL; 317 struct spectral_classifier_params *pcp = NULL; 318 struct target_if_spectral_ops *p_sops = NULL; 319 uint32_t *binptr_32 = NULL; 320 uint16_t *binptr_16 = NULL; 321 uint16_t pwr_16; 322 int idx = 0; 323 struct spectral_samp_data *samp_data; 324 static int samp_msg_index; 325 size_t pwr_count = 0; 326 size_t pwr_count_sec80 = 0; 327 size_t pwr_count_5mhz = 0; 328 enum spectral_msg_type msg_type; 329 QDF_STATUS ret; 330 struct spectral_fft_bin_len_adj_swar *swar = &spectral->len_adj_swar; 331 332 ret = target_if_get_spectral_msg_type(params->smode, &msg_type); 333 if (QDF_IS_STATUS_ERROR(ret)) 334 return; 335 336 if (is_primaryseg_rx_inprog(spectral, params->smode)) { 337 spec_samp_msg = (struct spectral_samp_msg *) 338 spectral->nl_cb.get_sbuff(spectral->pdev_obj, 339 msg_type, 340 SPECTRAL_MSG_BUF_NEW); 341 342 if (!spec_samp_msg) 343 return; 344 345 samp_data = &spec_samp_msg->samp_data; 346 p_sops = GET_TARGET_IF_SPECTRAL_OPS(spectral); 347 bin_pwr_data = params->bin_pwr_data; 348 349 spec_samp_msg->signature = SPECTRAL_SIGNATURE; 350 spec_samp_msg->freq = params->freq; 351 spec_samp_msg->agile_freq1 = params->agile_freq1; 352 spec_samp_msg->agile_freq2 = params->agile_freq2; 353 spec_samp_msg->freq_loading = params->freq_loading; 354 spec_samp_msg->vhtop_ch_freq_seg1 = params->vhtop_ch_freq_seg1; 355 spec_samp_msg->vhtop_ch_freq_seg2 = params->vhtop_ch_freq_seg2; 356 samp_data->spectral_mode = params->smode; 357 samp_data->spectral_data_len = params->datalen; 358 samp_data->spectral_rssi = params->rssi; 359 samp_data->ch_width = 360 spectral->ch_width[SPECTRAL_SCAN_MODE_NORMAL]; 361 samp_data->agile_ch_width = 362 spectral->ch_width[SPECTRAL_SCAN_MODE_AGILE]; 363 samp_data->spectral_agc_total_gain = params->agc_total_gain; 364 samp_data->spectral_gainchange = params->gainchange; 365 samp_data->spectral_pri80ind = params->pri80ind; 366 samp_data->last_raw_timestamp = params->last_raw_timestamp; 367 samp_data->timestamp_war_offset = params->timestamp_war_offset; 368 samp_data->raw_timestamp = params->raw_timestamp; 369 samp_data->reset_delay = params->reset_delay; 370 samp_data->target_reset_count = params->target_reset_count; 371 372 samp_data->spectral_combined_rssi = 373 (uint8_t)params->rssi; 374 samp_data->spectral_upper_rssi = params->upper_rssi; 375 samp_data->spectral_lower_rssi = params->lower_rssi; 376 377 qdf_mem_copy(samp_data->spectral_chain_ctl_rssi, 378 params->chain_ctl_rssi, 379 sizeof(params->chain_ctl_rssi)); 380 qdf_mem_copy(samp_data->spectral_chain_ext_rssi, 381 params->chain_ext_rssi, 382 sizeof(params->chain_ext_rssi)); 383 384 samp_data->spectral_bwinfo = params->bwinfo; 385 samp_data->spectral_tstamp = params->tstamp; 386 samp_data->spectral_max_index = params->max_index; 387 388 /* Classifier in user space needs access to these */ 389 samp_data->spectral_lower_max_index = 390 params->max_lower_index; 391 samp_data->spectral_upper_max_index = 392 params->max_upper_index; 393 samp_data->spectral_nb_lower = params->nb_lower; 394 samp_data->spectral_nb_upper = params->nb_upper; 395 samp_data->spectral_last_tstamp = params->last_tstamp; 396 samp_data->spectral_max_mag = params->max_mag; 397 398 /* 399 * Currently, we compute pwr_count considering the size of the 400 * samp_data->bin_pwr array rather than the number of elements 401 * in this array. The reasons are that 402 * SPECTRAL_MESSAGE_COPY_CHAR_ARRAY() where pwr_count will be 403 * used maps directly to OS_MEMCPY() on little endian platforms, 404 * and that samp_data->bin_pwr is an array of u_int8_t elements 405 * due to which the number of elements in the array == the size 406 * of the array. In case FFT bin size is increased from 8 bits 407 * in the future, this code would have to be changed along with 408 * rest of framework on which it depends. 409 */ 410 pwr_count = qdf_min((size_t)params->pwr_count, 411 sizeof(samp_data->bin_pwr)); 412 413 samp_data->bin_pwr_count = pwr_count; 414 samp_data->lb_edge_extrabins = 415 spectral->lb_edge_extrabins; 416 samp_data->rb_edge_extrabins = 417 spectral->rb_edge_extrabins; 418 samp_data->spectral_combined_rssi = params->rssi; 419 samp_data->spectral_max_scale = params->max_exp; 420 421 samp_data->noise_floor = params->noise_floor; 422 423 /* Classifier in user space needs access to these */ 424 cp = &samp_data->classifier_params; 425 pcp = ¶ms->classifier_params; 426 427 qdf_mem_copy(cp, pcp, 428 sizeof(struct spectral_classifier_params)); 429 430 /* 431 * To check whether FFT bin values exceed 8 bits, we add a 432 * check before copying values to samp_data->bin_pwr. 433 * If it crosses 8 bits, we cap the values to maximum value 434 * supported by 8 bits ie. 255. This needs to be done as the 435 * destination array in SAMP message is 8 bits. This is a 436 * temporary solution till an array of 16 bits is used for 437 * SAMP message. 438 */ 439 if (swar->fftbin_size_war == 440 SPECTRAL_FFTBIN_SIZE_WAR_4BYTE_TO_1BYTE) { 441 binptr_32 = (uint32_t *)bin_pwr_data; 442 for (idx = 0; idx < pwr_count; idx++) { 443 /* Read only the first 2 bytes of the DWORD */ 444 pwr_16 = *((uint16_t *)binptr_32++); 445 if (qdf_unlikely(pwr_16 > MAX_FFTBIN_VALUE)) 446 pwr_16 = MAX_FFTBIN_VALUE; 447 samp_data->bin_pwr[idx] = pwr_16; 448 } 449 } else if (swar->fftbin_size_war == 450 SPECTRAL_FFTBIN_SIZE_WAR_2BYTE_TO_1BYTE) { 451 binptr_16 = (uint16_t *)bin_pwr_data; 452 for (idx = 0; idx < pwr_count; idx++) { 453 pwr_16 = *(binptr_16++); 454 if (qdf_unlikely(pwr_16 > MAX_FFTBIN_VALUE)) 455 pwr_16 = MAX_FFTBIN_VALUE; 456 samp_data->bin_pwr[idx] = pwr_16; 457 } 458 } else { 459 SPECTRAL_MESSAGE_COPY_CHAR_ARRAY( 460 &samp_data->bin_pwr[0], bin_pwr_data, 461 pwr_count); 462 } 463 464 p_sops->get_mac_address(spectral, spec_samp_msg->macaddr); 465 } 466 467 if (is_secondaryseg_rx_inprog(spectral, params->smode)) { 468 spec_samp_msg = (struct spectral_samp_msg *) 469 spectral->nl_cb.get_sbuff(spectral->pdev_obj, 470 msg_type, 471 SPECTRAL_MSG_BUF_SAVED); 472 473 if (!spec_samp_msg) { 474 spectral_err("Spectral SAMP message is NULL"); 475 return; 476 } 477 478 samp_data = &spec_samp_msg->samp_data; 479 samp_data->spectral_rssi_sec80 = 480 params->rssi_sec80; 481 samp_data->noise_floor_sec80 = 482 params->noise_floor_sec80; 483 spec_samp_msg->samp_data.spectral_agc_total_gain_sec80 = 484 params->agc_total_gain_sec80; 485 spec_samp_msg->samp_data.spectral_gainchange_sec80 = 486 params->gainchange_sec80; 487 spec_samp_msg->samp_data.spectral_pri80ind_sec80 = 488 params->pri80ind_sec80; 489 490 samp_data->spectral_data_len_sec80 = 491 params->datalen_sec80; 492 samp_data->spectral_max_index_sec80 = 493 params->max_index_sec80; 494 samp_data->spectral_max_mag_sec80 = 495 params->max_mag_sec80; 496 497 samp_data->raw_timestamp_sec80 = params->raw_timestamp_sec80; 498 499 /* 500 * Currently, we compute pwr_count_sec80 considering the size of 501 * the samp_data->bin_pwr_sec80 array rather than the number of 502 * elements in this array. The reasons are that 503 * SPECTRAL_MESSAGE_COPY_CHAR_ARRAY() where pwr_count_sec80 will 504 * be used maps directly to OS_MEMCPY() on little endian 505 * platforms, and that samp_data->bin_pwr_sec80 is an array of 506 * u_int8_t elements due to which the number of elements in the 507 * array == the size of the array. In case FFT bin size is 508 * increased from 8 bits in the future, this code would have to 509 * be changed along with rest of framework on which it depends. 510 */ 511 pwr_count_sec80 = qdf_min((size_t)params->pwr_count_sec80, 512 sizeof(samp_data->bin_pwr_sec80)); 513 pwr_count_5mhz = qdf_min((size_t)params->pwr_count_5mhz, 514 sizeof(samp_data->bin_pwr_5mhz)); 515 516 samp_data->bin_pwr_count_sec80 = pwr_count_sec80; 517 samp_data->bin_pwr_count_5mhz = pwr_count_5mhz; 518 519 bin_pwr_data = params->bin_pwr_data_sec80; 520 521 /* 522 * To check whether FFT bin values exceed 8 bits, we add a 523 * check before copying values to samp_data->bin_pwr_sec80. 524 * If it crosses 8 bits, we cap the values to maximum value 525 * supported by 8 bits ie. 255. This needs to be done as the 526 * destination array in SAMP message is 8 bits. This is a 527 * temporary solution till an array of 16 bits is used for 528 * SAMP message. 529 */ 530 if (swar->fftbin_size_war == 531 SPECTRAL_FFTBIN_SIZE_WAR_4BYTE_TO_1BYTE) { 532 binptr_32 = (uint32_t *)bin_pwr_data; 533 for (idx = 0; idx < pwr_count_sec80; idx++) { 534 /* Read only the first 2 bytes of the DWORD */ 535 pwr_16 = *((uint16_t *)binptr_32++); 536 if (qdf_unlikely(pwr_16 > MAX_FFTBIN_VALUE)) 537 pwr_16 = MAX_FFTBIN_VALUE; 538 samp_data->bin_pwr_sec80[idx] = pwr_16; 539 } 540 } else if (swar->fftbin_size_war == 541 SPECTRAL_FFTBIN_SIZE_WAR_2BYTE_TO_1BYTE) { 542 binptr_16 = (uint16_t *)bin_pwr_data; 543 for (idx = 0; idx < pwr_count_sec80; idx++) { 544 pwr_16 = *(binptr_16++); 545 if (qdf_unlikely(pwr_16 > MAX_FFTBIN_VALUE)) 546 pwr_16 = MAX_FFTBIN_VALUE; 547 samp_data->bin_pwr_sec80[idx] = pwr_16; 548 } 549 550 binptr_16 = (uint16_t *)params->bin_pwr_data_5mhz; 551 for (idx = 0; idx < pwr_count_5mhz; idx++) { 552 pwr_16 = *(binptr_16++); 553 if (qdf_unlikely(pwr_16 > MAX_FFTBIN_VALUE)) 554 pwr_16 = MAX_FFTBIN_VALUE; 555 samp_data->bin_pwr_5mhz[idx] = pwr_16; 556 } 557 } else { 558 SPECTRAL_MESSAGE_COPY_CHAR_ARRAY( 559 &samp_data->bin_pwr_sec80[0], 560 params->bin_pwr_data_sec80, 561 pwr_count_sec80); 562 } 563 } 564 565 if (!is_ch_width_160_or_80p80(spectral->ch_width[params->smode]) || 566 is_secondaryseg_rx_inprog(spectral, params->smode)) { 567 if (spectral->send_phy_data(spectral->pdev_obj, 568 msg_type) == 0) 569 spectral->spectral_sent_msg++; 570 samp_msg_index++; 571 } 572 573 /* Take care of state transitions for 160MHz/ 80p80 */ 574 if (spectral->spectral_gen == SPECTRAL_GEN3 && 575 is_ch_width_160_or_80p80(spectral->ch_width[params->smode]) && 576 spectral->rparams.fragmentation_160[params->smode]) 577 target_if_160mhz_delivery_state_change( 578 spectral, params->smode, 579 SPECTRAL_DETECTOR_ID_INVALID); 580 } 581 #endif 582