| /* |
| * Copyright (c) 2017 The Linux Foundation. All rights reserved. |
| * |
| * Permission to use, copy, modify, and/or distribute this software for |
| * any purpose with or without fee is hereby granted, provided that the |
| * above copyright notice and this permission notice appear in all |
| * copies. |
| * |
| * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| * PERFORMANCE OF THIS SOFTWARE. |
| */ |
| |
| /* |
| * DOC: contains scan public utility functions |
| */ |
| |
| #ifndef _WLAN_SCAN_UTILS_H_ |
| #define _WLAN_SCAN_UTILS_H_ |
| |
| #include <wlan_objmgr_cmn.h> |
| #include <qdf_mc_timer.h> |
| #include <wlan_scan_public_structs.h> |
| #include<wlan_mgmt_txrx_utils_api.h> |
| |
| /** |
| * util_is_scan_entry_match() - func to check if both scan entry |
| * are from same AP |
| * @entry1: scan entry 1 |
| * @entry2: scan entry 2 |
| * |
| * match the two scan entries |
| * |
| * Return: true if entry match else false. |
| */ |
| bool util_is_scan_entry_match( |
| struct scan_cache_entry *entry1, |
| struct scan_cache_entry *entry2); |
| |
| /** |
| * util_scan_unpack_beacon_frame() - func to unpack beacon frame to scan entry |
| * @frame: beacon/probe frame |
| * @frame_len: beacon frame len |
| * @frm_subtype: beacon or probe |
| * @rx_param: rx meta data |
| * |
| * get the defaults scan params |
| * |
| * Return: unpacked scan entry. |
| */ |
| struct scan_cache_entry *util_scan_unpack_beacon_frame( |
| uint8_t *frame, qdf_size_t frame_len, uint32_t frm_subtype, |
| struct mgmt_rx_event_params *rx_param); |
| |
| /** |
| * util_scan_get_ev_type_name() - converts enum event to printable string |
| * @event: event of type scan_event_type |
| * |
| * API, converts enum event to printable character string |
| * |
| * Return: pointer to printable string |
| */ |
| const char *util_scan_get_ev_type_name(enum scan_event_type event); |
| |
| /** |
| * util_scan_get_ev_reason_name() - converts enum reason to printable string |
| * @reason enum of scan completion reason |
| * |
| * API, converts enum event to printable character string |
| * |
| * Return: pointer to printable string |
| */ |
| const char *util_scan_get_ev_reason_name(enum scan_completion_reason reason); |
| |
| /** |
| * util_scan_entry_macaddr() - function to read transmitter address |
| * @scan_entry: scan entry |
| * |
| * API, function to read transmitter address of scan entry |
| * |
| * Return: pointer to mac address |
| */ |
| static inline uint8_t* |
| util_scan_entry_macaddr(struct scan_cache_entry *scan_entry) |
| { |
| return &(scan_entry->mac_addr.bytes[0]); |
| } |
| |
| /** |
| * util_scan_entry_bssid() - function to read bssid |
| * @scan_entry: scan entry |
| * |
| * API, function to read bssid of scan entry |
| * |
| * Return: pointer to mac address |
| */ |
| static inline uint8_t* |
| util_scan_entry_bssid(struct scan_cache_entry *scan_entry) |
| { |
| return &(scan_entry->bssid.bytes[0]); |
| } |
| |
| /** |
| * util_scan_entry_capinfo() - function to read capibility info |
| * @scan_entry: scan entry |
| * |
| * API, function to read capibility info of scan entry |
| * |
| * Return: capability info |
| */ |
| static inline union wlan_capability |
| util_scan_entry_capinfo(struct scan_cache_entry *scan_entry) |
| { |
| return scan_entry->cap_info; |
| } |
| |
| /** |
| * util_scan_entry_beacon_interval() - function to read beacon interval |
| * @scan_entry: scan entry |
| * |
| * API, function to read beacon interval of scan entry |
| * |
| * Return: beacon interval |
| */ |
| static inline uint16_t |
| util_scan_entry_beacon_interval(struct scan_cache_entry *scan_entry) |
| { |
| return scan_entry->bcn_int; |
| } |
| |
| /** |
| * util_scan_entry_sequence_number() - function to read sequence number |
| * @scan_entry: scan entry |
| * |
| * API, function to read sequence number of scan entry |
| * |
| * Return: sequence number |
| */ |
| static inline uint16_t |
| util_scan_entry_sequence_number(struct scan_cache_entry *scan_entry) |
| { |
| return scan_entry->seq_num; |
| } |
| |
| /** |
| * util_scan_entry_tsf() - function to read tsf |
| * @scan_entry: scan entry |
| * |
| * API, function to read tsf of scan entry |
| * |
| * Return: tsf |
| */ |
| static inline uint8_t* |
| util_scan_entry_tsf(struct scan_cache_entry *scan_entry) |
| { |
| return scan_entry->tsf_info.data; |
| } |
| |
| /** |
| * util_scan_entry_reset_timestamp() - function to reset bcn receive timestamp |
| * @scan_entry: scan entry |
| * |
| * API, function to reset bcn receive timestamp of scan entry |
| * |
| * Return: void |
| */ |
| static inline void |
| util_scan_entry_reset_timestamp(struct scan_cache_entry *scan_entry) |
| { |
| scan_entry->scan_entry_time = 0; |
| } |
| |
| /* |
| * Macros used for RSSI calculation. |
| */ |
| |
| #define WLAN_RSSI_EP_MULTIPLIER (1<<7) /* pow2 to optimize out * and / */ |
| |
| #define WLAN_RSSI_LPF_LEN 10 |
| #define WLAN_RSSI_DUMMY_MARKER 0x127 |
| |
| #define WLAN_EP_MUL(x, mul) ((x) * (mul)) |
| |
| #define WLAN_EP_RND(x, mul) ((((x)%(mul)) >= ((mul)/2)) ?\ |
| ((x) + ((mul) - 1)) / (mul) : (x)/(mul)) |
| |
| #define WLAN_RSSI_GET(x) WLAN_EP_RND(x, WLAN_RSSI_EP_MULTIPLIER) |
| |
| #define RSSI_LPF_THRESHOLD -20 |
| |
| |
| #define WLAN_RSSI_OUT(x) (((x) != WLAN_RSSI_DUMMY_MARKER) ? \ |
| (WLAN_EP_RND((x), WLAN_RSSI_EP_MULTIPLIER)) : WLAN_RSSI_DUMMY_MARKER) |
| |
| |
| #define WLAN_RSSI_IN(x) (WLAN_EP_MUL((x), WLAN_RSSI_EP_MULTIPLIER)) |
| |
| #define WLAN_LPF_RSSI(x, y, len) \ |
| ((x != WLAN_RSSI_DUMMY_MARKER) ? ((((x) << 3) + (y) - (x)) >> 3) : (y)) |
| |
| #define WLAN_RSSI_LPF(x, y) do { \ |
| if ((y) >= RSSI_LPF_THRESHOLD) \ |
| x = WLAN_LPF_RSSI((x), WLAN_RSSI_IN((y)), WLAN_RSSI_LPF_LEN); \ |
| } while (0) |
| |
| #define WLAN_ABS_RSSI_LPF(x, y) do { \ |
| if ((y) >= (RSSI_LPF_THRESHOLD + WLAN_DEFAULT_NOISE_FLOOR)) \ |
| x = WLAN_LPF_RSSI((x), WLAN_RSSI_IN((y)), WLAN_RSSI_LPF_LEN); \ |
| } while (0) |
| |
| /** |
| * util_scan_entry_rssi() - function to read rssi of scan entry |
| * @scan_entry: scan entry |
| * |
| * API, function to read rssi value of scan entry |
| * |
| * Return: rssi |
| */ |
| static inline uint8_t |
| util_scan_entry_rssi(struct scan_cache_entry *scan_entry) |
| { |
| uint32_t rssi = WLAN_RSSI_OUT(scan_entry->avg_rssi); |
| /* |
| * An entry is in the BSS list means we've received at least one beacon |
| * from the corresponding AP, so the rssi must be initialized. |
| * |
| * If the RSSI is not initialized, return 0 (i.e. RSSI == Noise Floor). |
| * Once se_avgrssi field has been initialized, ATH_RSSI_OUT always |
| * returns values that fit in an 8-bit variable |
| * (RSSI values are typically 0-90). |
| */ |
| return (rssi >= WLAN_RSSI_DUMMY_MARKER) ? 0 : (uint8_t) rssi; |
| } |
| |
| /** |
| * util_scan_entry_phymode() - function to read phymode of scan entry |
| * @scan_entry: scan entry |
| * |
| * API, function to read phymode of scan entry |
| * |
| * Return: phymode |
| */ |
| static inline enum wlan_phymode |
| util_scan_entry_phymode(struct scan_cache_entry *scan_entry) |
| { |
| return scan_entry->phy_mode; |
| } |
| |
| /** |
| * util_is_ssid_match() - to check if ssid match |
| * @ssid1: ssid 1 |
| * @ssid2: ssid 2 |
| * |
| * Return: true if ssid match |
| */ |
| static inline bool |
| util_is_ssid_match(struct wlan_ssid *ssid1, |
| struct wlan_ssid *ssid2) |
| { |
| |
| if (ssid1->length == 0) |
| return true; |
| |
| if (ssid1->length != ssid2->length) |
| return false; |
| |
| if (!qdf_mem_cmp(ssid1->ssid, |
| ssid2->ssid, ssid1->length)) |
| return true; |
| |
| return false; |
| } |
| |
| /** |
| * util_is_bssid_match() - to check if bssid match |
| * @bssid1: bssid 1 |
| * @bssid2: bssid 2 |
| * |
| * Return: true if bssid match |
| */ |
| static inline bool util_is_bssid_match(struct qdf_mac_addr *bssid1, |
| struct qdf_mac_addr *bssid2) |
| { |
| |
| if (qdf_is_macaddr_zero(bssid1) || |
| qdf_is_macaddr_broadcast(bssid1)) |
| return true; |
| |
| if (qdf_is_macaddr_equal(bssid1, bssid2)) |
| return true; |
| |
| return false; |
| } |
| |
| /** |
| * util_is_bss_type_match() - to check if bss type |
| * @bss_type: bss type |
| * @cap: capability |
| * |
| * Return: true if bss type match |
| */ |
| static inline bool util_is_bss_type_match(enum wlan_bss_type bss_type, |
| union wlan_capability cap) |
| { |
| bool match = true; |
| |
| switch (bss_type) { |
| case WLAN_TYPE_ANY: |
| break; |
| case WLAN_TYPE_IBSS: |
| if (!cap.wlan_caps.ibss) |
| match = false; |
| break; |
| case WLAN_TYPE_BSS: |
| if (!cap.wlan_caps.ess) |
| match = false; |
| break; |
| default: |
| match = false; |
| } |
| |
| return match; |
| } |
| |
| /** |
| * util_country_code_match() - to check if country match |
| * @country: country code pointer |
| * @country_ie: country IE in beacon |
| * |
| * Return: true if country match |
| */ |
| static inline bool util_country_code_match(uint8_t *country, |
| uint8_t *country_ie) |
| { |
| struct wlan_country_ie *cc = |
| (struct wlan_country_ie *)country; |
| |
| if (!country || !country[0]) |
| return true; |
| |
| if (!cc) |
| return false; |
| |
| if (cc->cc[0] == country[0] && |
| cc->cc[1] == country[1]) |
| return true; |
| |
| return false; |
| } |
| |
| /** |
| * util_mdie_match() - to check if mdie match |
| * @mobility_domain: mobility domain |
| * @mdie: mobility domain ie |
| * |
| * Return: true if country match |
| */ |
| static inline bool util_mdie_match(uint16_t mobility_domain, |
| struct rsn_mdie *mdie) |
| { |
| uint16_t md; |
| |
| if (!mobility_domain) |
| return true; |
| |
| if (!mdie) |
| return false; |
| |
| md = |
| (mdie->mobility_domain[1] << 8) | |
| mdie->mobility_domain[0]; |
| |
| if (md == mobility_domain) |
| return true; |
| |
| return false; |
| } |
| |
| /** |
| * util_scan_entry_ssid() - function to read ssid of scan entry |
| * @scan_entry: scan entry |
| * |
| * API, function to read ssid of scan entry |
| * |
| * Return: ssid |
| */ |
| static inline struct wlan_ssid* |
| util_scan_entry_ssid(struct scan_cache_entry *scan_entry) |
| { |
| return &(scan_entry->ssid); |
| } |
| |
| /** |
| * util_scan_entry_dtimperiod() - function to read dtim period of scan entry |
| * @scan_entry: scan entry |
| * |
| * API, function to read dtim period of scan entry |
| * |
| * Return: dtim period |
| */ |
| static inline uint8_t |
| util_scan_entry_dtimperiod(struct scan_cache_entry *scan_entry) |
| { |
| return scan_entry->dtim_period; |
| } |
| |
| /** |
| * util_scan_entry_tim() - function to read tim ie of scan entry |
| * @scan_entry: scan entry |
| * |
| * API, function to read tim ie of scan entry |
| * |
| * Return: timie or NULL if ie is not present |
| */ |
| static inline uint8_t* |
| util_scan_entry_tim(struct scan_cache_entry *scan_entry) |
| { |
| return scan_entry->ie_list.tim; |
| } |
| |
| /** |
| * util_scan_entry_beacon_frame() - function to read full beacon or |
| * probe resp frame |
| * @scan_entry: scan entry |
| * |
| * API, function to read full beacon or probe resp frame including frame header |
| * |
| * Return: beacon/probe resp frame |
| */ |
| static inline struct element_info |
| util_scan_entry_beacon_frame(struct scan_cache_entry *scan_entry) |
| { |
| /* util_scan_entry_beacon_data */ |
| return scan_entry->raw_frame; |
| } |
| |
| /** |
| * util_scan_entry_ie_data() - function to read tagged IEs |
| * @scan_entry: scan entry |
| * |
| * API, function to read beacon/probe response frames starting from tagged IEs |
| * (excluding frame header and fixed parameters) |
| * |
| * Return: tagged IES of beacon/probe resp frame |
| */ |
| static inline uint8_t* |
| util_scan_entry_ie_data(struct scan_cache_entry *scan_entry) |
| { |
| struct element_info bcn_frm; |
| uint8_t *ie_data = NULL; |
| |
| bcn_frm = util_scan_entry_beacon_frame(scan_entry); |
| ie_data = (uint8_t *) (bcn_frm.ptr + |
| sizeof(struct wlan_frame_hdr) + |
| offsetof(struct wlan_bcn_frame, ie)); |
| return ie_data; |
| } |
| |
| /** |
| * util_scan_entry_ie_len() - function to read length of all tagged IEs |
| * @scan_entry: scan entry |
| * |
| * API, function to read length of all tagged IEs |
| * |
| * Return: length of all tagged IEs |
| */ |
| static inline uint16_t |
| util_scan_entry_ie_len(struct scan_cache_entry *scan_entry) |
| { |
| struct element_info bcn_frm; |
| uint16_t ie_len = 0; |
| |
| bcn_frm = util_scan_entry_beacon_frame(scan_entry); |
| ie_len = (uint16_t) (bcn_frm.len - |
| sizeof(struct wlan_frame_hdr) - |
| offsetof(struct wlan_bcn_frame, ie)); |
| return ie_len; |
| } |
| |
| /** |
| * util_scan_entry_frame_len() - function to frame length |
| * @scan_entry: scan entry |
| * |
| * API, function to read frame length |
| * |
| * Return: frame length |
| */ |
| static inline uint32_t |
| util_scan_entry_frame_len(struct scan_cache_entry *scan_entry) |
| { |
| return scan_entry->raw_frame.len; |
| } |
| |
| /** |
| * util_scan_entry_frame_ptr() - function to get frame ptr |
| * @scan_entry: scan entry |
| * |
| * API, function to read frame ptr |
| * |
| * Return: frame ptr |
| */ |
| static inline uint8_t* |
| util_scan_entry_frame_ptr(struct scan_cache_entry *scan_entry) |
| { |
| return scan_entry->raw_frame.ptr; |
| } |
| |
| /** |
| * util_scan_entry_copy_ie_data() - function to get a copy of all tagged IEs |
| * @scan_entry: scan entry |
| * |
| * API, function to get a copy of all tagged IEs in passed memory |
| * |
| * Return: QDF_STATUS_SUCCESS if tagged IEs copied successfully |
| * QDF_STATUS_E_NOMEM if passed memory/length can't hold all tagged IEs |
| */ |
| static inline QDF_STATUS |
| util_scan_entry_copy_ie_data(struct scan_cache_entry *scan_entry, |
| uint8_t *iebuf, uint16_t *ie_len) |
| { |
| u_int8_t *buff; |
| u_int16_t buff_len; |
| |
| /* iebuf can be NULL, ie_len must be a valid pointer. */ |
| QDF_ASSERT(ie_len != NULL); |
| |
| buff = util_scan_entry_ie_data(scan_entry); |
| buff_len = util_scan_entry_ie_len(scan_entry); |
| /* |
| * If caller passed a buffer, check the length to make sure |
| * it's large enough. |
| * If no buffer is passed, just return the length of the IE blob. |
| */ |
| if (iebuf != NULL) { |
| if (*ie_len >= buff_len) { |
| qdf_mem_copy(iebuf, buff, buff_len); |
| *ie_len = buff_len; |
| return QDF_STATUS_SUCCESS; |
| } |
| } |
| |
| *ie_len = buff_len; |
| return QDF_STATUS_E_NOMEM; |
| } |
| |
| /** |
| * util_scan_free_cache_entry() - function to free scan |
| * cache entry |
| * @scan_entry: scan entry |
| * |
| * API, function to free scan cache entry |
| * |
| * Return: void |
| */ |
| static inline void |
| util_scan_free_cache_entry(struct scan_cache_entry *scan_entry) |
| { |
| if (!scan_entry) |
| return; |
| if (scan_entry->alt_wcn_ie.ptr) |
| qdf_mem_free(scan_entry->alt_wcn_ie.ptr); |
| if (scan_entry->raw_frame.ptr) |
| qdf_mem_free(scan_entry->raw_frame.ptr); |
| qdf_mem_free(scan_entry); |
| } |
| |
| #define conv_ptr(_address, _base1, _base2) \ |
| ((_address != NULL) ? (((u_int8_t *) (_address) - \ |
| (u_int8_t *) (_base1)) + (u_int8_t *) (_base2)) : NULL) |
| |
| /** |
| * util_scan_copy_beacon_data() - copy beacon and update ie ptrs |
| * cache entry |
| * @new_entry: new scan entry |
| * @scan_entry: entry from where data is copied |
| * |
| * API, function to copy beacon and update ie ptrs |
| * |
| * Return: QDF_STATUS |
| */ |
| static inline QDF_STATUS |
| util_scan_copy_beacon_data(struct scan_cache_entry *new_entry, |
| struct scan_cache_entry *scan_entry) |
| { |
| u_int8_t *new_ptr, *old_ptr; |
| struct ie_list *ie_lst; |
| |
| new_entry->raw_frame.ptr = |
| qdf_mem_malloc(scan_entry->raw_frame.len); |
| if (!new_entry->raw_frame.ptr) |
| return QDF_STATUS_E_NOMEM; |
| |
| qdf_mem_copy(new_entry->raw_frame.ptr, |
| scan_entry->raw_frame.ptr, |
| scan_entry->raw_frame.len); |
| |
| new_ptr = new_entry->raw_frame.ptr; |
| old_ptr = scan_entry->raw_frame.ptr; |
| |
| new_entry->ie_list = scan_entry->ie_list; |
| |
| ie_lst = &new_entry->ie_list; |
| |
| /* New info_element needs also be added in ieee80211_parse_beacon */ |
| ie_lst->tim = conv_ptr(ie_lst->tim, old_ptr, new_ptr); |
| ie_lst->country = conv_ptr(ie_lst->country, old_ptr, new_ptr); |
| ie_lst->ssid = conv_ptr(ie_lst->ssid, old_ptr, new_ptr); |
| ie_lst->rates = conv_ptr(ie_lst->rates, old_ptr, new_ptr); |
| ie_lst->xrates = conv_ptr(ie_lst->xrates, old_ptr, new_ptr); |
| ie_lst->csa = conv_ptr(ie_lst->csa, old_ptr, new_ptr); |
| ie_lst->xcsa = conv_ptr(ie_lst->xcsa, old_ptr, new_ptr); |
| ie_lst->secchanoff = conv_ptr(ie_lst->secchanoff, old_ptr, new_ptr); |
| ie_lst->wpa = conv_ptr(ie_lst->wpa, old_ptr, new_ptr); |
| ie_lst->wcn = conv_ptr(ie_lst->wcn, old_ptr, new_ptr); |
| ie_lst->rsn = conv_ptr(ie_lst->rsn, old_ptr, new_ptr); |
| ie_lst->wps = conv_ptr(ie_lst->wps, old_ptr, new_ptr); |
| ie_lst->wmeinfo = conv_ptr(ie_lst->wmeinfo, old_ptr, new_ptr); |
| ie_lst->wmeparam = conv_ptr(ie_lst->wmeparam, old_ptr, new_ptr); |
| ie_lst->quiet = conv_ptr(ie_lst->quiet, old_ptr, new_ptr); |
| ie_lst->htcap = conv_ptr(ie_lst->htcap, old_ptr, new_ptr); |
| ie_lst->htinfo = conv_ptr(ie_lst->htinfo, old_ptr, new_ptr); |
| ie_lst->athcaps = conv_ptr(ie_lst->athcaps, old_ptr, new_ptr); |
| ie_lst->athextcaps = conv_ptr(ie_lst->athextcaps, old_ptr, new_ptr); |
| ie_lst->sfa = conv_ptr(ie_lst->sfa, old_ptr, new_ptr); |
| ie_lst->vendor = conv_ptr(ie_lst->vendor, old_ptr, new_ptr); |
| ie_lst->qbssload = conv_ptr(ie_lst->qbssload, old_ptr, new_ptr); |
| ie_lst->wapi = conv_ptr(ie_lst->wapi, old_ptr, new_ptr); |
| ie_lst->p2p = conv_ptr(ie_lst->p2p, old_ptr, new_ptr); |
| ie_lst->alt_wcn = conv_ptr(ie_lst->alt_wcn, old_ptr, new_ptr); |
| ie_lst->extcaps = conv_ptr(ie_lst->extcaps, old_ptr, new_ptr); |
| ie_lst->ibssdfs = conv_ptr(ie_lst->ibssdfs, old_ptr, new_ptr); |
| ie_lst->sonadv = conv_ptr(ie_lst->sonadv, old_ptr, new_ptr); |
| ie_lst->vhtcap = conv_ptr(ie_lst->vhtcap, old_ptr, new_ptr); |
| ie_lst->vhtop = conv_ptr(ie_lst->vhtop, old_ptr, new_ptr); |
| ie_lst->opmode = conv_ptr(ie_lst->opmode, old_ptr, new_ptr); |
| ie_lst->cswrp = conv_ptr(ie_lst->cswrp, old_ptr, new_ptr); |
| ie_lst->widebw = conv_ptr(ie_lst->widebw, old_ptr, new_ptr); |
| ie_lst->txpwrenvlp = conv_ptr(ie_lst->txpwrenvlp, old_ptr, new_ptr); |
| ie_lst->bwnss_map = conv_ptr(ie_lst->bwnss_map, old_ptr, new_ptr); |
| ie_lst->mdie = conv_ptr(ie_lst->mdie, old_ptr, new_ptr); |
| |
| return QDF_STATUS_SUCCESS; |
| } |
| /** |
| * util_scan_copy_cache_entry() - function to create a copy |
| * of scan cache entry |
| * @scan_entry: scan entry |
| * |
| * API, function to create a copy of scan cache entry |
| * |
| * Return: copy of scan_entry |
| */ |
| static inline struct scan_cache_entry * |
| util_scan_copy_cache_entry(struct scan_cache_entry *scan_entry) |
| { |
| struct scan_cache_entry *new_entry; |
| QDF_STATUS status; |
| |
| if (!scan_entry) |
| return NULL; |
| |
| new_entry = |
| qdf_mem_malloc(sizeof(*scan_entry)); |
| if (!new_entry) |
| return NULL; |
| |
| qdf_mem_copy(new_entry, |
| scan_entry, sizeof(*scan_entry)); |
| |
| if (scan_entry->alt_wcn_ie.ptr) { |
| new_entry->alt_wcn_ie.ptr = |
| qdf_mem_malloc(scan_entry->alt_wcn_ie.len); |
| if (!new_entry->alt_wcn_ie.ptr) { |
| qdf_mem_free(new_entry); |
| return NULL; |
| } |
| qdf_mem_copy(new_entry->alt_wcn_ie.ptr, |
| scan_entry->alt_wcn_ie.ptr, |
| scan_entry->alt_wcn_ie.len); |
| new_entry->alt_wcn_ie.len = |
| scan_entry->alt_wcn_ie.len; |
| } |
| |
| status = util_scan_copy_beacon_data(new_entry, scan_entry); |
| if (QDF_IS_STATUS_ERROR(status)) { |
| util_scan_free_cache_entry(new_entry); |
| return NULL; |
| } |
| |
| return new_entry; |
| } |
| |
| /** |
| * util_scan_entry_channel() - function to read channel info |
| * @scan_entry: scan entry |
| * |
| * API, function to read channel info |
| * |
| * Return: channel info |
| */ |
| static inline struct channel_info* |
| util_scan_entry_channel(struct scan_cache_entry *scan_entry) |
| { |
| return &(scan_entry->channel); |
| } |
| |
| /** |
| * util_scan_entry_channel_num() - function to read channel number |
| * @scan_entry: scan entry |
| * |
| * API, function to read channel number |
| * |
| * Return: channel number |
| */ |
| static inline uint8_t |
| util_scan_entry_channel_num(struct scan_cache_entry *scan_entry) |
| { |
| return scan_entry->channel.chan_idx; |
| } |
| |
| /** |
| * util_scan_entry_erpinfo() - function to read erp info |
| * @scan_entry: scan entry |
| * |
| * API, function to read erp info |
| * |
| * Return: erp info |
| */ |
| static inline uint8_t |
| util_scan_entry_erpinfo(struct scan_cache_entry *scan_entry) |
| { |
| return scan_entry->erp; |
| } |
| |
| /** |
| * util_scan_entry_rates() - function to read supported rates IE |
| * @scan_entry: scan entry |
| * |
| * API, function to read supported rates IE |
| * |
| * Return: basic ratesie or NULL if ie is not present |
| */ |
| static inline uint8_t* |
| util_scan_entry_rates(struct scan_cache_entry *scan_entry) |
| { |
| return scan_entry->ie_list.rates; |
| } |
| |
| /** |
| * util_scan_entry_xrates()- function to read extended supported rates IE |
| * @scan_entry: scan entry |
| * |
| * API, function to read extended supported rates IE |
| * |
| * Return: extended supported ratesie or NULL if ie is not present |
| */ |
| static inline uint8_t* |
| util_scan_entry_xrates(struct scan_cache_entry *scan_entry) |
| { |
| return scan_entry->ie_list.xrates; |
| } |
| |
| /** |
| * util_scan_entry_rsn()- function to read rsn IE |
| * @scan_entry: scan entry |
| * |
| * API, function to read rsn IE |
| * |
| * Return: rsnie or NULL if ie is not present |
| */ |
| static inline uint8_t* |
| util_scan_entry_rsn(struct scan_cache_entry *scan_entry) |
| { |
| return scan_entry->ie_list.rsn; |
| } |
| |
| /** |
| * util_scan_entry_wpa() - function to read wpa IE |
| * @scan_entry: scan entry |
| * |
| * API, function to read wpa IE |
| * |
| * Return: wpaie or NULL if ie is not present |
| */ |
| static inline uint8_t* |
| util_scan_entry_wpa(struct scan_cache_entry *scan_entry) |
| { |
| return scan_entry->ie_list.wpa; |
| } |
| |
| /** |
| * util_scan_entry_wapi() - function to read wapi IE |
| * @scan_entry: scan entry |
| * |
| * API, function to read wapi IE |
| * |
| * Return: wapiie or NULL if ie is not present |
| */ |
| static inline uint8_t* |
| util_scan_entry_wapi(struct scan_cache_entry *scan_entry) |
| { |
| return scan_entry->ie_list.wapi; |
| } |
| |
| /** |
| * util_scan_entry_wps() - function to read wps IE |
| * @scan_entry: scan entry |
| * |
| * API, function to read wps IE |
| * |
| * Return: wpsie or NULL if ie is not present |
| */ |
| static inline uint8_t* |
| util_scan_entry_wps(struct scan_cache_entry *scan_entry) |
| { |
| return scan_entry->ie_list.wps; |
| } |
| |
| /** |
| * util_scan_entry_sfa() - function to read sfa IE |
| * @scan_entry: scan entry |
| * |
| * API, function to read sfa IE |
| * |
| * Return: sfaie or NULL if ie is not present |
| */ |
| static inline uint8_t* |
| util_scan_entry_sfa(struct scan_cache_entry *scan_entry) |
| { |
| return scan_entry->ie_list.sfa; |
| } |
| |
| /** |
| * util_scan_entry_csa() - function to read csa IE |
| * @scan_entry: scan entry |
| * |
| * API, function to read csa IE |
| * |
| * Return: csaie or NULL if ie is not present |
| */ |
| static inline uint8_t* |
| util_scan_entry_csa(struct scan_cache_entry *scan_entry) |
| { |
| return scan_entry->ie_list.csa; |
| } |
| |
| /** |
| * util_scan_entry_xcsa() - function to read extended csa IE |
| * @scan_entry: scan entry |
| * |
| * API, function to read extended csa IE |
| * |
| * Return: extended csaie or NULL if ie is not present |
| */ |
| static inline uint8_t* |
| util_scan_entry_xcsa(struct scan_cache_entry *scan_entry) |
| { |
| return scan_entry->ie_list.xcsa; |
| } |
| |
| /** |
| * util_scan_entry_htinfo() - function to read htinfo IE |
| * @scan_entry: scan entry |
| * |
| * API, function to read htinfo IE |
| * |
| * Return: htinfoie or NULL if ie is not present |
| */ |
| static inline uint8_t* |
| util_scan_entry_htinfo(struct scan_cache_entry *scan_entry) |
| { |
| return scan_entry->ie_list.htinfo; |
| } |
| |
| |
| /** |
| * util_scan_entry_htcap() - function to read htcap IE |
| * @scan_entry: scan entry |
| * |
| * API, function to read htcap IE |
| * |
| * Return: htcapie or NULL if ie is not present |
| */ |
| static inline uint8_t* |
| util_scan_entry_htcap(struct scan_cache_entry *scan_entry) |
| { |
| return scan_entry->ie_list.htcap; |
| } |
| |
| /** |
| * util_scan_entry_vhtcap() - function to read vhtcap IE |
| * @scan_entry: scan entry |
| * |
| * API, function to read vhtcap IE |
| * |
| * Return: vhtcapie or NULL if ie is not present |
| */ |
| static inline uint8_t* |
| util_scan_entry_vhtcap(struct scan_cache_entry *scan_entry) |
| { |
| return scan_entry->ie_list.vhtcap; |
| } |
| |
| /** |
| * util_scan_entry_vhtop() - function to read vhtop IE |
| * @scan_entry: scan entry |
| * |
| * API, function to read vhtop IE |
| * |
| * Return: vhtopie or NULL if ie is not present |
| */ |
| static inline uint8_t* |
| util_scan_entry_vhtop(struct scan_cache_entry *scan_entry) |
| { |
| return scan_entry->ie_list.vhtop; |
| } |
| |
| /** |
| * util_scan_entry_quiet() - function to read quiet IE |
| * @scan_entry: scan entry |
| * |
| * API, function to read quiet IE |
| * |
| * Return: quietie or NULL if ie is not present |
| */ |
| static inline uint8_t* |
| util_scan_entry_quiet(struct scan_cache_entry *scan_entry) |
| { |
| return scan_entry->ie_list.quiet; |
| } |
| |
| /** |
| * util_scan_entry_qbssload() - function to read qbss load IE |
| * @scan_entry: scan entry |
| * |
| * API, function to read qbss load IE |
| * |
| * Return: qbss loadie or NULL if ie is not present |
| */ |
| static inline uint8_t* |
| util_scan_entry_qbssload(struct scan_cache_entry *scan_entry) |
| { |
| return scan_entry->ie_list.qbssload; |
| } |
| |
| /** |
| * util_scan_entry_vendor() - function to read vendor IE |
| * @scan_entry: scan entry |
| * |
| * API, function to read vendor IE |
| * |
| * Return: vendorie or NULL if ie is not present |
| */ |
| static inline uint8_t* |
| util_scan_entry_vendor(struct scan_cache_entry *scan_entry) |
| { |
| return scan_entry->ie_list.vendor; |
| } |
| |
| /** |
| * util_scan_entry_country() - function to read country IE |
| * @scan_entry: scan entry |
| * |
| * API, function to read country IE |
| * |
| * Return: countryie or NULL if ie is not present |
| */ |
| static inline uint8_t* |
| util_scan_entry_country(struct scan_cache_entry *scan_entry) |
| { |
| return scan_entry->ie_list.country; |
| } |
| |
| /** |
| * util_scan_entry_copy_country() - function to copy country name |
| * @scan_entry: scan entry |
| * @cntry: out buffer |
| * |
| * API, function to copy country name code string in given memory @centry |
| * |
| * Return: QDF_STATUS_SUCCESS if successfully copied country name |
| * QDF_STATUS_E_INVAL if passed buffer is null |
| * QDF_STATUS_E_NOMEM if scan entry dont have country IE |
| */ |
| static inline QDF_STATUS |
| util_scan_entry_copy_country(struct scan_cache_entry *scan_entry, |
| uint8_t *cntry) |
| { |
| struct wlan_country_ie *country_ie; |
| |
| if (!cntry) |
| return QDF_STATUS_E_INVAL; |
| |
| country_ie = (struct wlan_country_ie *) |
| util_scan_entry_country(scan_entry); |
| |
| if (!country_ie) |
| return QDF_STATUS_E_NOMEM; |
| |
| qdf_mem_copy(cntry, country_ie->cc, 3); |
| |
| return QDF_STATUS_SUCCESS; |
| } |
| |
| /** |
| * util_scan_entry_wmeinfo() - function to read wme info ie |
| * @scan_entry: scan entry |
| * |
| * API, function to read wme info ie |
| * |
| * Return: wme infoie or NULL if ie is not present |
| */ |
| static inline uint8_t* |
| util_scan_entry_wmeinfo(struct scan_cache_entry *scan_entry) |
| { |
| return scan_entry->ie_list.wmeinfo; |
| } |
| |
| /** |
| * util_scan_entry_wmeparam() - function to read wme param ie |
| * @scan_entry: scan entry |
| * |
| * API, function to read wme param ie |
| * |
| * Return: wme paramie or NULL if ie is not present |
| */ |
| static inline uint8_t* |
| util_scan_entry_wmeparam(struct scan_cache_entry *scan_entry) |
| { |
| return scan_entry->ie_list.wmeparam; |
| } |
| |
| /** |
| * util_scan_entry_age() - function to read age of scan entry |
| * @scan_entry: scan entry |
| * |
| * API, function to read age of scan entry |
| * |
| * Return: age in ms |
| */ |
| static inline uint32_t |
| util_scan_entry_age(struct scan_cache_entry *scan_entry) |
| { |
| unsigned long ts = scan_entry->scan_entry_time; |
| |
| return qdf_mc_timer_get_system_time() - ts; |
| } |
| |
| /** |
| * util_scan_mlme_info() - function to read mlme info struct |
| * @scan_entry: scan entry |
| * |
| * API, function to read mlme info struct |
| * |
| * Return: mlme info |
| */ |
| static inline struct mlme_info* |
| util_scan_mlme_info(struct scan_cache_entry *scan_entry) |
| { |
| return &scan_entry->mlme_info; |
| } |
| |
| /** |
| * util_scan_entry_bss_type() - function to read bss type |
| * @scan_entry: scan entry |
| * |
| * API, function to read bss type |
| * |
| * Return: bss type |
| */ |
| static inline enum wlan_bss_type |
| util_scan_entry_bss_type(struct scan_cache_entry *scan_entry) |
| { |
| if (scan_entry->cap_info.value & WLAN_CAPINFO_ESS) |
| return WLAN_TYPE_BSS; |
| else if (scan_entry->cap_info.value & WLAN_CAPINFO_IBSS) |
| return WLAN_TYPE_IBSS; |
| else |
| return WLAN_TYPE_ANY; |
| } |
| |
| /** |
| * util_scan_entry_privacy() - function to check if privacy is enebled |
| * @scan_entry: scan entry |
| * |
| * API, function to check if privacy is enebled |
| * |
| * Return: true if privacy is enabled, false other wise |
| */ |
| static inline bool |
| util_scan_entry_privacy(struct scan_cache_entry *scan_entry) |
| { |
| return (scan_entry->cap_info.value & |
| WLAN_CAPINFO_PRIVACY) ? true : false; |
| } |
| |
| /** |
| * util_scan_entry_athcaps() - function to read ath caps vendor ie |
| * @scan_entry: scan entry |
| * |
| * API, function to read ath caps vendor ie |
| * |
| * Return: ath caps vendorie or NULL if ie is not present |
| */ |
| static inline uint8_t* |
| util_scan_entry_athcaps(struct scan_cache_entry *scan_entry) |
| { |
| return scan_entry->ie_list.athcaps; |
| } |
| |
| /** |
| * util_scan_entry_athextcaps() - function to read ath extcaps vendor ie |
| * @scan_entry: scan entry |
| * |
| * API, function to read ath extcaps vendor ie |
| * |
| * Return: ath extcaps vendorie or NULL if ie is not present |
| */ |
| static inline uint8_t* |
| util_scan_entry_athextcaps(struct scan_cache_entry *scan_entry) |
| { |
| return scan_entry->ie_list.athextcaps; |
| } |
| |
| /** |
| * util_scan_entry_bwnss_map() - function to read bwnss_map ie |
| * @scan_entry: scan entry |
| * |
| * API, function to read bwnss_map ie |
| * |
| * Return: bwnss_map ie or NULL if ie is not present |
| */ |
| static inline uint8_t* |
| util_scan_entry_bwnss_map(struct scan_cache_entry *scan_entry) |
| { |
| return scan_entry->ie_list.bwnss_map; |
| } |
| |
| /** |
| * util_scan_entry_sonie() - function to read son ie |
| * @scan_entry: scan entry |
| * |
| * API, function to read son ie |
| * |
| * Return: son ie or NULL if ie is not present |
| */ |
| static inline uint8_t* |
| util_scan_entry_sonie(struct scan_cache_entry *scan_entry) |
| { |
| return scan_entry->ie_list.sonadv; |
| } |
| |
| /** |
| * util_scan_entry_widebw() - function to read wide band chan switch sub elem ie |
| * @scan_entry: scan entry |
| * |
| * API, function to read wide band chan switch sub elem ie |
| * |
| * Return: wide band chan switch sub elem or NULL if ie is not present |
| */ |
| static inline uint8_t* |
| util_scan_entry_widebw(struct scan_cache_entry *scan_entry) |
| { |
| return scan_entry->ie_list.widebw; |
| } |
| |
| /** |
| * util_scan_entry_secchanoff() - function to read secondary channel offset ie |
| * @scan_entry: scan entry |
| * |
| * API, function to read secondary channel offset ie |
| * |
| * Return: secondary channel offset element or NULL if ie is not present |
| */ |
| static inline uint8_t* |
| util_scan_entry_secchanoff(struct scan_cache_entry *scan_entry) |
| { |
| return scan_entry->ie_list.secchanoff; |
| } |
| |
| /** |
| * util_scan_entry_cswrp() - function to read channel switch wrapper ie |
| * @scan_entry: scan entry |
| * |
| * API, function to read channel switch wrapper ie |
| * |
| * Return: channel switch wrapper element or NULL if ie is not present |
| */ |
| static inline uint8_t* |
| util_scan_entry_cswrp(struct scan_cache_entry *scan_entry) |
| { |
| return scan_entry->ie_list.cswrp; |
| } |
| |
| /** |
| * util_scan_entry_omn() - function to read operating mode notification ie |
| * @scan_entry: scan entry |
| * |
| * API, function to read operating mode notification |
| * |
| * Return: operating mode notification element or NULL if ie is not present |
| */ |
| static inline uint8_t* |
| util_scan_entry_omn(struct scan_cache_entry *scan_entry) |
| { |
| return scan_entry->ie_list.opmode; |
| } |
| |
| /** |
| * util_scan_entry_extcaps() - function to read extcap ie |
| * @scan_entry: scan entry |
| * |
| * API, function to read extcap ie |
| * |
| * Return: extcap element or NULL if ie is not present |
| */ |
| static inline uint8_t* |
| util_scan_entry_extcaps(struct scan_cache_entry *scan_entry) |
| { |
| return scan_entry->ie_list.extcaps; |
| } |
| |
| /** |
| * util_scan_entry_athcaps() - function to read ath caps vendor ie |
| * @scan_entry: scan entry |
| * |
| * API, function to read ath caps vendor ie |
| * |
| * Return: ath caps vendorie or NULL if ie is not present |
| */ |
| static inline struct mlme_info* |
| util_scan_entry_mlme_info(struct scan_cache_entry *scan_entry) |
| { |
| return &(scan_entry->mlme_info); |
| } |
| |
| /** |
| * util_get_last_scan_time() - function to get last scan time on this pdev |
| * @vdev: vdev object |
| * |
| * API, function to read last scan time on this pdev |
| * |
| * Return: qdf_time_t |
| */ |
| qdf_time_t |
| util_get_last_scan_time(struct wlan_objmgr_vdev *vdev); |
| |
| #endif |
| |