blob: a7980b469a74e4a7cae32062a05991f748e8dfdf [file] [log] [blame]
/* Crossdriver (bcmdhd/brcmfmac) logic extracted from bcmdhd dhd.h externs.
*
* Copyright 1999-2016, Broadcom Corporation
* All rights reserved,
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* This software is provided by the copyright holder "as is" and any express or
* implied warranties, including, but not limited to, the implied warranties of
* merchantability and fitness for a particular purpose are disclaimed. In no event
* shall copyright holder be liable for any direct, indirect, incidental, special,
* exemplary, or consequential damages (including, but not limited to, procurement
* of substitute goods or services; loss of use, data, or profits; or business
* interruption) however caused and on any theory of liability, whether in
* contract, strict liability, or tort (including negligence or otherwise) arising
* in any way out of the use of this software, even if advised of the possibility
* of such damage
*/
#include "dhd.h"
#include <memory>
#include "wl_cfg80211.h"
bool get_histograms(wl_wstats_cnt_t wl_stats_cnt, chanspec_t chanspec, uint32_t version,
uint32_t rxchain, histograms_report_t* out_report) {
if (wl_stats_cnt.version > WSTATS_CNT_T_VERSION) {
// Unexpected wl_stats_cnt version.
return false;
}
const chanspec_t real_chanspec = interpret_chanspec(chanspec, version);
if (real_chanspec == INVCHANSPEC) {
return false;
}
int band = chanspec & WL_CHANSPEC_BAND_MASK;
AntennaId antenna_id;
antenna_id.freq = (band == WL_CHANSPEC_BAND_5G) ? ANTENNA_5G : ANTENNA_2G;
antenna_id.idx = (rxchain == 1) ? 0 : 1;
std::memset(out_report, 0, sizeof(histograms_report_t));
std::memcpy(out_report->rxsnr, wl_stats_cnt.rxsnr, sizeof(out_report->rxsnr));
std::memcpy(out_report->rxnoiseflr, wl_stats_cnt.rxnoiseflr, sizeof(out_report->rxnoiseflr));
std::memcpy(out_report->rxrssi, wl_stats_cnt.rxrssi, sizeof(out_report->rxrssi));
std::memcpy(out_report->rx11b, wl_stats_cnt.rx11b, sizeof(out_report->rx11b));
std::memcpy(out_report->rx11g, wl_stats_cnt.rx11g, sizeof(out_report->rx11g));
std::memcpy(out_report->rx11n, wl_stats_cnt.rx11n, sizeof(out_report->rx11n));
std::memcpy(out_report->rx11ac, wl_stats_cnt.rx11ac, sizeof(out_report->rx11ac));
std::memcpy(&out_report->antennaid, &antenna_id, sizeof(out_report->antennaid));
return true;
}