1 /* 2 * Copyright (c) 2017-2018 The Linux Foundation. All rights reserved. 3 * 4 * Permission to use, copy, modify, and/or distribute this software for 5 * any purpose with or without fee is hereby granted, provided that the 6 * above copyright notice and this permission notice appear in all 7 * copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 16 * PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19 /** 20 * DOC: Contains mandatory API from legacy 21 */ 22 23 #ifndef _WLAN_UTILITY_H_ 24 #define _WLAN_UTILITY_H_ 25 26 #include <qdf_types.h> 27 #include <wlan_objmgr_psoc_obj.h> 28 #include <wlan_objmgr_pdev_obj.h> 29 #include <wlan_objmgr_vdev_obj.h> 30 31 /** 32 * struct wlan_find_vdev_filter - find vdev filter object. this can be extended 33 * @ifname: interface name of vdev 34 * @found_vdev: found vdev object matching one or more of above params 35 */ 36 struct wlan_find_vdev_filter { 37 char *ifname; 38 struct wlan_objmgr_vdev *found_vdev; 39 }; 40 41 /** 42 * wlan_chan_to_freq() - converts channel to frequency 43 * @chan: channel number 44 * 45 * @return frequency of the channel 46 */ 47 uint32_t wlan_chan_to_freq(uint8_t chan); 48 49 /* 50 * wlan_is_dsrc_channel() - is the channel DSRC 51 * @center_freq: center freq of the channel 52 * 53 * Return: true if DSRC channel or false otherwise 54 */ 55 bool wlan_is_dsrc_channel(uint16_t center_freq); 56 57 /** 58 * wlan_freq_to_chan() - converts frequency to channel 59 * @freq: frequency 60 * 61 * Return: channel of frequency 62 */ 63 uint8_t wlan_freq_to_chan(uint32_t freq); 64 65 /** 66 * wlan_is_ie_valid() - Determine if an IE sequence is valid 67 * @ie: Pointer to the IE buffer 68 * @ie_len: Length of the IE buffer @ie 69 * 70 * This function validates that the IE sequence is valid by verifying 71 * that the sum of the lengths of the embedded elements match the 72 * length of the sequence. 73 * 74 * Note well that a 0-length IE sequence is considered valid. 75 * 76 * Return: true if the IE sequence is valid, false if it is invalid 77 */ 78 bool wlan_is_ie_valid(const uint8_t *ie, size_t ie_len); 79 80 /** 81 * wlan_get_ie_ptr_from_eid() - Find out ie from eid 82 * @eid: element id 83 * @ie: source ie address 84 * @ie_len: source ie length 85 * 86 * Return: vendor ie address - success 87 * NULL - failure 88 */ 89 const uint8_t *wlan_get_ie_ptr_from_eid(uint8_t eid, 90 const uint8_t *ie, 91 int ie_len); 92 93 /** 94 * wlan_get_vendor_ie_ptr_from_oui() - Find out vendor ie 95 * @oui: oui buffer 96 * @oui_size: oui size 97 * @ie: source ie address 98 * @ie_len: source ie length 99 * 100 * This function find out vendor ie by pass source ie and vendor oui. 101 * 102 * Return: vendor ie address - success 103 * NULL - failure 104 */ 105 const uint8_t *wlan_get_vendor_ie_ptr_from_oui(const uint8_t *oui, 106 uint8_t oui_size, 107 const uint8_t *ie, 108 uint16_t ie_len); 109 110 /** 111 * wlan_get_ext_ie_ptr_from_ext_id() - Find out ext ie 112 * @oui: oui buffer 113 * @oui_size: oui size 114 * @ie: source ie address 115 * @ie_len: source ie length 116 * 117 * This function find out ext ie from ext id (passed oui) 118 * 119 * Return: vendor ie address - success 120 * NULL - failure 121 */ 122 const uint8_t *wlan_get_ext_ie_ptr_from_ext_id(const uint8_t *oui, 123 uint8_t oui_size, 124 const uint8_t *ie, 125 uint16_t ie_len); 126 127 /** 128 * wlan_is_emulation_platform() - check if platform is emulation based 129 * @phy_version - psoc nif phy_version 130 * 131 * Return: boolean value based on platform type 132 */ 133 bool wlan_is_emulation_platform(uint32_t phy_version); 134 135 /** 136 * wlan_get_pdev_id_from_vdev_id() - Helper func to derive pdev id from vdev_id 137 * @psoc : psoc object 138 * @vdev_id : vdev identifier 139 * @dbg_id : object manager debug id 140 * 141 * This function is used to derive the pdev id from vdev id for a psoc 142 * 143 * Return : pdev_id - +ve integer for success and WLAN_INVALID_PDEV_ID 144 * for failure 145 */ 146 uint32_t wlan_get_pdev_id_from_vdev_id(struct wlan_objmgr_psoc *psoc, 147 uint8_t vdev_id, 148 wlan_objmgr_ref_dbgid dbg_id); 149 150 /** 151 * wlan_util_get_vdev_by_ifname() - function to return vdev object from psoc 152 * matching given interface name 153 * @psoc : psoc object 154 * @ifname : interface name 155 * @ref_id : object manager ref id 156 * 157 * This function returns vdev object from psoc by interface name. If found this 158 * will also take reference with given ref_id 159 * 160 * Return : vdev object if found, NULL otherwise 161 */ 162 struct wlan_objmgr_vdev *wlan_util_get_vdev_by_ifname( 163 struct wlan_objmgr_psoc *psoc, char *ifname, 164 wlan_objmgr_ref_dbgid ref_id); 165 166 /** 167 * wlan_util_vdev_get_if_name() - get vdev's interface name 168 * @vdev: VDEV object 169 * 170 * API to get vdev's interface name 171 * 172 * Return: 173 * @id: vdev's interface name 174 */ 175 uint8_t *wlan_util_vdev_get_if_name(struct wlan_objmgr_vdev *vdev); 176 177 /* 178 * wlan_util_is_vap_active() - Check for vap active 179 * @pdev: pdev pointer 180 * 181 * @Return: QDF_STATUS_SUCCESS in case of vap active 182 */ 183 QDF_STATUS wlan_util_is_vap_active(struct wlan_objmgr_pdev *pdev); 184 185 #endif /* _WLAN_UTILITY_H_ */ 186