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