diff --git a/power_management_offloads/core/inc/wlan_pmo_arp.h b/power_management_offloads/core/inc/wlan_pmo_arp.h new file mode 100644 index 000000000000..8d97eec6cddf --- /dev/null +++ b/power_management_offloads/core/inc/wlan_pmo_arp.h @@ -0,0 +1,71 @@ +/* +* 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: Declare arp offload feature API's + */ + +#ifndef _WLAN_PMO_ARP_H_ +#define _WLAN_PMO_ARP_H_ + +#include "wlan_pmo_arp_public_struct.h" + +/** + * pmo_core_cache_arp_offload_req() - API to cache arp req in pmo vdev priv ctx + * @arp_req: arp offload request + * + * API To cache ARP offload in pmo vdev priv ctx + * + * Return: QDF_STATUS_SUCCESS in case of success else return error + */ +QDF_STATUS pmo_core_cache_arp_offload_req(struct pmo_arp_req *arp_req); + +/** + * pmo_core_flush_arp_offload_req() - API to flush arp req from pmo vdev ctx + * @vdev: objmgr vdev + * + * API To flush saved ARP request from pmo vdev prov ctx + * + * Return: QDF_STATUS_SUCCESS in case of success else return error + */ +QDF_STATUS pmo_core_flush_arp_offload_req(struct wlan_objmgr_vdev *vdev); + +/** + * pmo_core_enable_arp_offload_in_fwr() - API to enable arp offload in fwr + * @vdev: objmgr vdev + * @trigger: trigger reason + * + * API to enable arp offload in fwr from vdev priv ctx + * + * Return: QDF_STATUS_SUCCESS in case of success else return error + */ +QDF_STATUS pmo_core_enable_arp_offload_in_fwr(struct wlan_objmgr_vdev *vdev, + enum pmo_offload_trigger trigger); + +/** + * pmo_core_disable_arp_offload_in_fwr() - API to disable arp offload in fwr + * @vdev: objmgr vdev + * @trigger: trigger reason + * + * API to disable arp offload in fwr + * + * Return: QQDF_STATUS_SUCCESS in case of success else return error + */ +QDF_STATUS pmo_core_disable_arp_offload_in_fwr(struct wlan_objmgr_vdev *vdev, + enum pmo_offload_trigger trigger); + +#endif /* end of _WLAN_PMO_ARP_H_ */ diff --git a/power_management_offloads/core/inc/wlan_pmo_gtk.h b/power_management_offloads/core/inc/wlan_pmo_gtk.h new file mode 100644 index 000000000000..2a9d9f54ae1b --- /dev/null +++ b/power_management_offloads/core/inc/wlan_pmo_gtk.h @@ -0,0 +1,74 @@ +/* +* 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: Declare gtk offload feature API's + */ + +#ifndef _WLAN_PMO_GTK_H_ +#define _WLAN_PMO_GTK_H_ + +#include "wlan_pmo_gtk_public_struct.h" + +/** + * pmo_core_cache_gtk_offload_req(): API to cache gtk req in pmo vdev priv obj + * @vdev: objmgr vdev handle + * @gtk_req: pmo gtk req param + * + * Return QDF_STATUS_SUCCESS -in case of success else return error + */ +QDF_STATUS pmo_core_cache_gtk_offload_req(struct wlan_objmgr_vdev *vdev, + struct pmo_gtk_req *gtk_req); + +/** + * pmo_core_flush_gtk_offload_req(): Flush saved gtk req from pmo vdev priv obj + * @vdev: objmgr vdev handle + * + * Return QDF_STATUS_SUCCESS -in case of success else return error + */ +QDF_STATUS pmo_core_flush_gtk_offload_req(struct wlan_objmgr_vdev *vdev); + +/** + * pmo_core_enable_gtk_offload_in_fwr(): enable cached gtk request in fwr + * @vdev: objmgr vdev handle + * + * Return QDF_STATUS_SUCCESS -in case of success else return error + */ +QDF_STATUS pmo_core_enable_gtk_offload_in_fwr(struct wlan_objmgr_vdev *vdev); + +/** + * pmo_core_disable_gtk_offload_in_fwr(): disable cached gtk request in fwr + * @vdev: objmgr vdev handle + * + * Return QDF_STATUS_SUCCESS -in case of success else return error + */ +QDF_STATUS pmo_core_disable_gtk_offload_in_fwr(struct wlan_objmgr_vdev *vdev); + +/** + * pmo_core_get_gtk_rsp(): API to send gtk response request to fwr + * @vdev: objmgr vdev handle + * @gtk_rsp: pmo gtk response request + * + * This api will send gtk response request to fwr + * + * Return QDF_STATUS_SUCCESS -in case of success else return error + */ +QDF_STATUS pmo_core_get_gtk_rsp(struct wlan_objmgr_vdev *vdev, + struct pmo_gtk_rsp_req *gtk_rsp_req); + +#endif /* end of _WLAN_PMO_GTK_H_ */ + diff --git a/power_management_offloads/core/inc/wlan_pmo_main.h b/power_management_offloads/core/inc/wlan_pmo_main.h new file mode 100644 index 000000000000..405a76a31bb2 --- /dev/null +++ b/power_management_offloads/core/inc/wlan_pmo_main.h @@ -0,0 +1,211 @@ +/* +* 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: declare various api which shall be used by + * pmo user configuration and target interface + */ + +#ifndef _WLAN_PMO_MAIN_H_ +#define _WLAN_PMO_MAIN_H_ + +#include "wlan_cmn.h" +#include "wlan_objmgr_cmn.h" +#include "wlan_objmgr_global_obj.h" +#include "wlan_objmgr_psoc_obj.h" +#include "wlan_objmgr_pdev_obj.h" +#include "wlan_objmgr_vdev_obj.h" +#include "wlan_objmgr_peer_obj.h" +#include "qdf_status.h" +#include "qdf_types.h" +#include "qdf_lock.h" +#include "wlan_pmo_obj_mgmt_public_struct.h" + +#define pmo_log(level, args...) QDF_TRACE(QDF_MODULE_ID_HDD, level, ## args) +#define pmo_logfl(level, format, args...) pmo_log(level, FL(format), ## args) + +#define pmo_fatal(format, args...) \ + pmo_logfl(QDF_TRACE_LEVEL_FATAL, format, ## args) +#define pmo_err(format, args...) \ + pmo_logfl(QDF_TRACE_LEVEL_ERROR, format, ## args) +#define pmo_warn(format, args...) \ + pmo_logfl(QDF_TRACE_LEVEL_WARN, format, ## args) +#define pmo_info(format, args...) \ + pmo_logfl(QDF_TRACE_LEVEL_INFO, format, ## args) +#define pmo_debug(format, args...) \ + pmo_logfl(QDF_TRACE_LEVEL_DEBUG, format, ## args) + +#define PMO_ENTER() pmo_logfl(QDF_TRACE_LEVEL_INFO, "enter") +#define PMO_EXIT() pmo_logfl(QDF_TRACE_LEVEL_INFO, "exit") + +static inline enum tQDF_ADAPTER_MODE pmo_get_vdev_opmode( + struct wlan_objmgr_vdev *vdev) +{ + enum tQDF_ADAPTER_MODE opmode; + + wlan_vdev_obj_lock(vdev); + opmode = wlan_vdev_mlme_get_opmode(vdev); + wlan_vdev_obj_unlock(vdev); + + return opmode; +} + +static inline uint8_t pmo_get_vdev_id(struct wlan_objmgr_vdev *vdev) +{ + uint8_t vdev_id; + + wlan_vdev_obj_lock(vdev); + vdev_id = wlan_vdev_get_id(vdev); + wlan_vdev_obj_unlock(vdev); + + return vdev_id; +} + +/** + * pmo_allocate_ctx() - Api to allocate pmo ctx + * + * Helper function to allocate pmo ctx + * + * Return: Success or failure. + */ +QDF_STATUS pmo_allocate_ctx(void); + +/** + * pmo_free_ctx() - to free pmo context + * + * Helper function to free pmo context + * + * Return: None. + */ +void pmo_free_ctx(void); + +/** + * pmo_get_context() - to get pmo context + * + * Helper function to get pmo context + * + * Return: pmo context. + */ +struct wlan_pmo_ctx *pmo_get_context(void); + +/** + * pmo_get_psoc_priv_ctx() - return pmo psoc priv ctx from objmgr psoc + * @psoc: objmgr psoc + * + * Helper function to pmo psoc ctx from objmgr psoc + * + * Return: if success pmo psoc ctx else NULL + */ +struct pmo_psoc_priv_obj *pmo_get_psoc_priv_ctx(struct wlan_objmgr_psoc *psoc); + +/** + * pmo_get_vdev_priv_ctx() - return pmo vdev priv ctx from objmgr vdev + * @vdev: objmgr vdev + * + * Helper function to pmo vdev ctx from objmgr vdev + * + * Return: if success pmo vdev ctx else NULL + */ +struct pmo_vdev_priv_obj *pmo_get_vdev_priv_ctx(struct wlan_objmgr_vdev *vdev); + +/** + * pmo_get_vdev_bss_peer_mac_addr() - API to get bss peer mac address + * @vdev: objmgr vdev + * @bss_peer_mac_address: bss peer mac address + *. + * Helper function to get bss peer mac address + * + * Return: if success pmo vdev ctx else NULL + */ +QDF_STATUS pmo_get_vdev_bss_peer_mac_addr(struct wlan_objmgr_vdev *vdev, + struct qdf_mac_addr *bss_peer_mac_address); + +/** + * pmo_psoc_ctx_from_vdev_ctx() - return pmo psoc ctx from pmo vdev ctx + * @vdev: pmo vdev ctx + * + * Helper function to get pmo psoc ctx from pmo vdev ctx + * + * Return: pmo psoc ctx + */ +struct pmo_psoc_priv_obj *pmo_psoc_ctx_from_vdev_ctx( + struct pmo_vdev_priv_obj *vdev_ctx); + +/** + * pmo_is_vdev_in_beaconning_mode() - check if vdev is in a beaconning mode + * @vdev_opmode: vdev opmode + * + * Helper function to know whether given vdev + * is in a beaconning mode or not. + * + * Return: True if vdev needs to beacon. + */ +bool pmo_is_vdev_in_beaconning_mode(enum tQDF_ADAPTER_MODE vdev_opmode); + +/** + * pmo_core_is_ap_mode_supports_arp_ns() - To check ap mode supports arp/ns + * @vdev_opmode: vdev opmode + * + * API to check if ap mode supports arp/ns offload + * + * Return: True if ap mode supports arp/ns offload + */ + +bool pmo_core_is_ap_mode_supports_arp_ns(struct wlan_objmgr_psoc *psoc, + enum tQDF_ADAPTER_MODE vdev_opmode); + +/** + * pmo_core_is_vdev_connected() - to check whether peer is associated or not + * @vdev: objmgr vdev + * + * Return: true in case success else false + */ +bool pmo_core_is_vdev_connected(struct wlan_objmgr_vdev *vdev); + +/** + * pmo_core_is_vdev_supports_offload() - Check offload is supported on vdev + * @vdev: objmgr vdev + * + * Return: true in case success else false + */ +bool pmo_core_is_vdev_supports_offload(struct wlan_objmgr_vdev *vdev); + +/** + * pmo_core_get_psoc_config(): API to get the psoc user configurations of pmo + * @psoc: objmgr psoc handle + * @psoc_cfg: fill the current psoc user configurations. + * + * Return pmo psoc configurations + */ +QDF_STATUS pmo_core_get_psoc_config(struct wlan_objmgr_psoc *psoc, + struct pmo_psoc_cfg *psoc_cfg); + +/** + * pmo_core_update_psoc_config(): API to update the psoc user configurations + * @psoc: objmgr psoc handle + * @psoc_cfg: pmo psoc configurations + * + * This api shall be used for soc config initialization as well update. + * In case of update caller must first call pmo_get_psoc_cfg to get + * current config and then apply changes on top of current config. + * + * Return QDF_STATUS -in case of success else return error + */ +QDF_STATUS pmo_core_update_psoc_config(struct wlan_objmgr_psoc *psoc, + struct pmo_psoc_cfg *psoc_cfg); + +#endif /* end of _WLAN_PMO_MAIN_H_ */ diff --git a/power_management_offloads/core/inc/wlan_pmo_mc_addr_filtering.h b/power_management_offloads/core/inc/wlan_pmo_mc_addr_filtering.h new file mode 100644 index 000000000000..ddedb6403651 --- /dev/null +++ b/power_management_offloads/core/inc/wlan_pmo_mc_addr_filtering.h @@ -0,0 +1,129 @@ +/* +* 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: Declare mc addr filtering offload feature API's + */ + +#ifndef _WLAN_PMO_MC_ADDR_FILTERING_H_ +#define _WLAN_PMO_MC_ADDR_FILTERING_H_ + +#include "wlan_pmo_common_public_struct.h" +#include "wlan_pmo_mc_addr_filtering_public_struct.h" + +/** + * pmo_core_set_mc_filter_req() -send mc filter set request + * @vdev: objmgr vdev + * @mc_list: a list of mc addresses to set in fwr + * + * Return: QDF_STATUS_SUCCESS in success else error codes + */ +QDF_STATUS pmo_core_set_mc_filter_req(struct wlan_objmgr_vdev *vdev, + struct pmo_mc_addr_list *mc_list); + +/** + * pmo_clear_mc_filter_req() -send mc filter clear request + * @vdev: objmgr vdev + * @mc_list: a list of mc addresses to clear in fwr + * + * Return: QDF_STATUS_SUCCESS in success else error codes + */ +QDF_STATUS pmo_core_clear_mc_filter_req(struct wlan_objmgr_vdev *vdev, + struct pmo_mc_addr_list *mc_list); + +/** + * pmo_core_cache_mc_addr_list(): API to cache mc addr list in pmo vdev priv obj + * @psoc: objmgr psoc handle + * @vdev_id: vdev id + * @gtk_req: pmo gtk req param + * + * Return QDF_STATUS_SUCCESS -in case of success else return error + */ +QDF_STATUS pmo_core_cache_mc_addr_list( + struct pmo_mc_addr_list_params *mc_list_config); + +/** + * pmo_core_flush_mc_addr_list(): API to flush mc addr list in pmo vdev priv obj + * @psoc: objmgr psoc handle + * @vdev_id: vdev id + * + * Return QDF_STATUS_SUCCESS -in case of success else return error + */ +QDF_STATUS pmo_core_flush_mc_addr_list(struct wlan_objmgr_psoc *psoc, + uint8_t vdev_id); + +/** + * pmo_core_enable_mc_addr_filtering_in_fwr(): Enable cached mc add list in fwr + * @psoc: objmgr psoc handle + * @vdev_id: vdev id + * @gtk_req: pmo gtk req param + * @action: true for enable els false + * + * API to enable cached mc add list in fwr + * + * Return QDF_STATUS_SUCCESS -in case of success else return error + */ +QDF_STATUS pmo_core_enable_mc_addr_filtering_in_fwr( + struct wlan_objmgr_psoc *psoc, + uint8_t vdev_id, + enum pmo_offload_trigger trigger); + +/** + * pmo_core_disable_mc_addr_filtering_in_fwr(): Disable cached mc addr list + * @psoc: objmgr psoc handle + * @vdev_id: vdev id + * @gtk_req: pmo gtk req param + * @action: true for enable els false + * + * API to disable cached mc add list in fwr + * + * Return QDF_STATUS_SUCCESS -in case of success else return error + */ +QDF_STATUS pmo_core_disable_mc_addr_filtering_in_fwr( + struct wlan_objmgr_psoc *psoc, + uint8_t vdev_id, + enum pmo_offload_trigger trigger); + +/** + * pmo_core_get_mc_addr_list_count() -set mc address count + * @psoc: objmgr psoc + * @vdev_id: vdev id + * + * Return: set mc address count + */ +void pmo_core_set_mc_addr_list_count(struct wlan_objmgr_psoc *psoc, + uint8_t vdev_id, uint8_t count); + +/** + * pmo_core_get_mc_addr_list_count() -get current mc address count + * @psoc: objmgr psoc + * @vdev_id: vdev id + * + * Return: current mc address count + */ +int pmo_core_get_mc_addr_list_count(struct wlan_objmgr_psoc *psoc, + uint8_t vdev_id); + +/** + * pmo_core_max_mc_addr_supported() -get max supported mc addresses + * @psoc: objmgr psoc + * + * Return: max supported mc addresses + */ +uint8_t pmo_core_max_mc_addr_supported(struct wlan_objmgr_psoc *psoc); + +#endif /* end of _WLAN_PMO_MC_ADDR_FILTERING_H_ */ diff --git a/power_management_offloads/core/inc/wlan_pmo_ns.h b/power_management_offloads/core/inc/wlan_pmo_ns.h new file mode 100644 index 000000000000..de30ba9b2630 --- /dev/null +++ b/power_management_offloads/core/inc/wlan_pmo_ns.h @@ -0,0 +1,72 @@ +/* +* 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: Declare ns offload feature API's + */ + +#ifndef _WLAN_PMO_NS_H_ +#define _WLAN_PMO_NS_H_ + +#include "wlan_pmo_common_public_struct.h" +#include "wlan_pmo_ns_public_struct.h" + +/** + * pmo_core_cache_ns_offload_req() - API to cache ns req in pmo vdev priv ctx + * @ns_req: ns offload request + * + * API to cache ns offload in pmo vdev priv ctx + * + * Return:QDF_STATUS_SUCCESS in case of success else return error + */ +QDF_STATUS pmo_core_cache_ns_offload_req(struct pmo_ns_req *ns_req); + +/** + * pmo_core_flush_ns_offload_req() - API to flush ns req from pmo vdev priv ctx + * @vdev: vdev objmgr handle + * + * API to flush ns offload from pmo vdev priv ctx + * + * Return: QDF_STATUS_SUCCESS in case of success else return error + */ +QDF_STATUS pmo_core_flush_ns_offload_req(struct wlan_objmgr_vdev *vdev); + +/** + * pmo_core_enable_ns_offload_in_fwr() - API to enable ns offload in fwr + * @vdev: objmgr vdev + * @trigger: trigger reason enable ns offload + * + * API to enable ns offload in fwr from vdev priv ctx + * + * Return: QDF_STATUS_SUCCESS in case of success else return error + */ +QDF_STATUS pmo_core_enable_ns_offload_in_fwr(struct wlan_objmgr_vdev *vdev, + enum pmo_offload_trigger trigger); + +/** + * pmo_core_disable_ns_offload_in_fwr() - API to disable ns offload in fwr + * @vdev: objmgr vdev + * @trigger: trigger reason disable ns offload + * + * API to disable arp offload in fwr + * + * Return: QDF_STATUS_SUCCESS in case of success else return error + */ +QDF_STATUS pmo_core_disable_ns_offload_in_fwr(struct wlan_objmgr_vdev *vdev, + enum pmo_offload_trigger trigger); + +#endif /* end of _WLAN_PMO_NS_H_ */ diff --git a/power_management_offloads/core/inc/wlan_pmo_static_config.h b/power_management_offloads/core/inc/wlan_pmo_static_config.h new file mode 100644 index 000000000000..a504578bdb56 --- /dev/null +++ b/power_management_offloads/core/inc/wlan_pmo_static_config.h @@ -0,0 +1,87 @@ +/* +* 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: Declare static configuration on vdev attach + */ + +#ifndef _WLAN_PMO_STATIC_CONFIG_H_ +#define _WLAN_PMO_STATIC_CONFIG_H_ + +#include "wlan_pmo_common_public_struct.h" +#include "wlan_pmo_wow.h" + +/** + * pmo_register_wow_wakeup_events() - register vdev specific wake events with fw + * @vdev: objmgr vdev + * + * WoW wake up event rule is following: + * 1) STA mode and P2P CLI mode wake up events are same + * 2) SAP mode and P2P GO mode wake up events are same + * 3) IBSS mode wake events are same as STA mode plus WOW_BEACON_EVENT + * + * Return: none + */ +void pmo_register_wow_wakeup_events(struct wlan_objmgr_vdev *vdev); + +/** + * pmo_register_wow_default_patterns() - register default wow patterns with fw + * @vdev_id: vdev id + * + * WoW default wake up pattern rule is: + * - For STA & P2P CLI mode register for same STA specific wow patterns + * - For SAP/P2P GO & IBSS mode register for same SAP specific wow patterns + * + * Return: none + */ +void pmo_register_wow_default_patterns(struct wlan_objmgr_vdev *vdev); + +/** + * pmo_register_action_frame_patterns() - register action frame map to fw + * @vdev: objmgr vdev + * + * This is called to push action frames wow patterns from local + * cache to firmware. + * + * Return: None + */ +void pmo_register_action_frame_patterns( + struct wlan_objmgr_vdev *vdev); + +/** + * pmo_update_target_service(): API to update wmi target service info to PMO. + * @psoc: objmgr psoc + * @wmi_service: wmi service number + * @value: true when wmi service is enabled in firmware otherwise false. + * + * Return void + */ +void pmo_update_target_service(struct wlan_objmgr_psoc *psoc, + WMI_SERVICE service, bool value); + +/** + * pmo_update_ra_limit() - update ra limit based on bpf filter + * enabled or not + * @psoc: objmgr psoc + * @bpf_enabled: true when bpf service is enabled else false + * + * Return: none + */ +void pmo_update_ra_limit(struct wlan_objmgr_psoc *psoc, + bool bpf_enabled); + +#endif /* end of _WLAN_PMO_STATIC_CONFIG_H_ */ diff --git a/power_management_offloads/core/inc/wlan_pmo_wow.h b/power_management_offloads/core/inc/wlan_pmo_wow.h new file mode 100644 index 000000000000..dc31c8bc67fd --- /dev/null +++ b/power_management_offloads/core/inc/wlan_pmo_wow.h @@ -0,0 +1,257 @@ +/* + * 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: Declare API's for wow pattern addition and deletion in fwr + */ + +#ifndef _WLAN_PMO_WOW_H_ +#define _WLAN_PMO_WOW_H_ + +#include "wlan_pmo_main.h" +#include "wlan_pmo_wow_public_struct.h" +#include "wlan_pmo_tgt_api.h" +#include "wlan_pmo_common_public_struct.h" +#include "wlan_pmo_obj_mgmt_public_struct.h" + +/** + * DOC: wlan_pmo_wowl + * + * This module houses all the logic for WOW(wake on wireless) in + * PMO(Power Management and Offload). + * + * It provides the following APIs + * + * - Ability to enable/disable following WoWL modes + * 1) Magic packet (MP) mode + * 2) Pattern Byte Matching (PBM) mode + * - Ability to add/remove patterns for PBM + * + * A Magic Packet is a packet that contains 6 0xFFs followed by 16 + * contiguous copies of the receiving NIC's Ethernet address. There is + * no API to configure Magic Packet Pattern. + * + * Wakeup pattern (used for PBM) is defined as following: + * struct + * { + * U8 PatternSize; // Non-Zero pattern size + * U8 PatternMaskSize; // Non-zero pattern mask size + * U8 PatternMask[PatternMaskSize]; // Pattern mask + * U8 Pattern[PatternSize]; // Pattern + * } hdd_wowl_ptrn_t; + * + * PatternSize and PatternMaskSize indicate size of the variable + * length Pattern and PatternMask. PatternMask indicates which bytes + * of an incoming packet should be compared with corresponding bytes + * in the pattern. + * + * Maximum allowed pattern size is 128 bytes. Maximum allowed + * PatternMaskSize is 16 bytes. + * + * Maximum number of patterns that can be configured is 8 + * + * PMO will add following 2 commonly used patterns for PBM by default: + * 1) ARP Broadcast Pattern + * 2) Unicast Pattern + * + * However note that WoWL will not be enabled by default by PMO. WoWL + * needs to enabled explcitly by exercising the iwpriv command. + * + * PMO will expose an API that accepts patterns as Hex string in the + * following format: + * "PatternSize:PatternMaskSize:PatternMask:Pattern" + * + * Multiple patterns can be specified by deleimiting each pattern with + * the ';' token: + * "PatternSize1:PatternMaskSize1:PatternMask1:Pattern1;PatternSize2:..." + * + * Patterns can be configured dynamically via iwpriv cmd or statically + * via qcom_cfg.ini file + * + * PBM (when enabled) can perform filtering on unicast data or + * broadcast data or both. These configurations are part of factory + * default (cfg.dat) and the default behavior is to perform filtering + * on both unicast and data frames. + * + * MP filtering (when enabled) is performed ALWAYS on both unicast and + * broadcast data frames. + * + * Management frames are not subjected to WoWL filtering and are + * discarded when WoWL is enabled. + * + * Whenever a patern match succeeds, RX path is restored and packets + * (both management and data) will be pushed to the host from that + * point onwards. Therefore, exit from WoWL is implicit and happens + * automatically when the first packet match succeeds. + * + * WoWL works on top of BMPS. So when WoWL is requested, SME will + * attempt to put the device in BMPS mode (if not already in BMPS). If + * attempt to BMPS fails, request for WoWL will be rejected. + */ + +/** + * pmo_get_and_increment_wow_default_ptrn() -Get and increment wow default ptrn + * @vdev_ctx: pmo vdev priv ctx + * + * API to get and increment wow default ptrn + * + * Return: current wow default ptrn count + */ +static inline uint8_t pmo_get_and_increment_wow_default_ptrn( + struct pmo_vdev_priv_obj *vdev_ctx) +{ + uint8_t count; + + qdf_spin_lock_bh(&vdev_ctx->pmo_vdev_lock); + count = vdev_ctx->num_wow_default_patterns++; + qdf_spin_unlock_bh(&vdev_ctx->pmo_vdev_lock); + + return count; +} + +/** + * pmo_increment_wow_default_ptrn() -increment wow default ptrn + * @vdev_ctx: pmo vdev priv ctx + * + * API to increment wow default ptrn + * + * Return: None + */ +static inline void pmo_increment_wow_default_ptrn( + struct pmo_vdev_priv_obj *vdev_ctx) +{ + qdf_spin_lock_bh(&vdev_ctx->pmo_vdev_lock); + vdev_ctx->num_wow_default_patterns++; + qdf_spin_unlock_bh(&vdev_ctx->pmo_vdev_lock); +} + +/** + * pmo_decrement_wow_default_ptrn() -decrement wow default ptrn + * @vdev_ctx: pmo vdev priv ctx + * + * API to decrement wow default ptrn + * + * Return: None + */ +static inline void pmo_decrement_wow_default_ptrn( + struct pmo_vdev_priv_obj *vdev_ctx) +{ + qdf_spin_lock_bh(&vdev_ctx->pmo_vdev_lock); + vdev_ctx->num_wow_default_patterns--; + qdf_spin_unlock_bh(&vdev_ctx->pmo_vdev_lock); +} + +/** + * pmo_increment_wow_user_ptrn() -increment wow user ptrn + * @vdev_ctx: pmo vdev priv ctx + * + * API to increment wow user ptrn + * + * Return: None + */ +static inline void pmo_increment_wow_user_ptrn( + struct pmo_vdev_priv_obj *vdev_ctx) +{ + qdf_spin_lock_bh(&vdev_ctx->pmo_vdev_lock); + vdev_ctx->num_wow_user_patterns++; + qdf_spin_unlock_bh(&vdev_ctx->pmo_vdev_lock); +} + +/** + * pmo_decrement_wow_user_ptrn() -decrement wow user ptrn + * @vdev_ctx: pmo vdev priv ctx + * + * API to decrement wow user ptrn + * + * Return: None + */ +static inline void pmo_decrement_wow_user_ptrn( + struct pmo_vdev_priv_obj *vdev_ctx) +{ + qdf_spin_lock_bh(&vdev_ctx->pmo_vdev_lock); + vdev_ctx->num_wow_user_patterns--; + qdf_spin_unlock_bh(&vdev_ctx->pmo_vdev_lock); +} + +void pmo_dump_wow_ptrn(struct pmo_wow_add_pattern *ptrn); + +/** + * pmo_core_add_wow_pattern() - Function which will add the WoWL pattern to be + * used when PBM filtering is enabled + * @vdev: pointer to the vdev + * @ptrn: pointer to the pattern string to be added + * + * Return: false if any errors encountered, QDF_STATUS_SUCCESS otherwise + */ +QDF_STATUS pmo_core_add_wow_pattern(struct wlan_objmgr_vdev *vdev, + const char *ptrn); + +/** + * pmo_core_del_wow_pattern() - Function which will delete the WoWL pattern + * @vdev: pointer to the vdev + * @ptrn: pointer to the pattern string to be added + * + * Return: error if any errors encountered, QDF_STATUS_SUCCESS otherwise + */ +QDF_STATUS pmo_core_del_wow_pattern(struct wlan_objmgr_vdev *vdev, + const char *ptrn); + +/** + * pmo_core_wow_enter() - store enable/disable status for pattern + * @wma: wma handle + * @info: wow parameters + * + * Records pattern enable/disable status locally. This choice will + * take effect when the driver enter into suspend state. + * + * Return: QDF status + */ +QDF_STATUS pmo_core_wow_enter(struct wlan_objmgr_vdev *vdev, + struct pmo_wow_enter_params *wow_enter_param); + +/** + * pmo_core_wow_exit() - clear all wma states + * @wma: wma handle + * @info: wow params + * + * Return: QDF status + */ +QDF_STATUS pmo_core_wow_exit(struct wlan_objmgr_vdev *vdev); + +/** + * pmo_core_enable_wakeup_event() - enable wow wakeup events + * @psoc: objmgr psoc + * @vdev_id: vdev id + * @bitmap: Event bitmap + * + * Return: none + */ +void pmo_core_enable_wakeup_event(struct wlan_objmgr_psoc *psoc, + uint32_t vdev_id, uint32_t bitmap); + +/** + * pmo_core_disable_wakeup_event() - disable wow wakeup events + * @psoc: objmgr psoc + * @vdev_id: vdev id + * @bitmap: Event bitmap + * + * Return: none + */ +void pmo_core_disable_wakeup_event(struct wlan_objmgr_psoc *psoc, + uint32_t vdev_id, uint32_t bitmap); + +#endif /* end of _WLAN_PMO_WOW_H_ */ diff --git a/power_management_offloads/core/src/wlan_pmo_arp.c b/power_management_offloads/core/src/wlan_pmo_arp.c new file mode 100644 index 000000000000..b3285987698b --- /dev/null +++ b/power_management_offloads/core/src/wlan_pmo_arp.c @@ -0,0 +1,393 @@ +/* +* 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: Implements arp offload feature API's + */ + +#include "wlan_pmo_arp.h" +#include "wlan_pmo_tgt_api.h" +#include "wlan_pmo_main.h" +#include "wlan_pmo_obj_mgmt_public_struct.h" + +static QDF_STATUS pmo_core_cache_arp_in_vdev_priv( + struct pmo_arp_req *arp_req, + struct wlan_objmgr_vdev *vdev) +{ + QDF_STATUS status = QDF_STATUS_SUCCESS; + struct pmo_arp_offload_params *request = NULL; + struct pmo_psoc_priv_obj *psoc_ctx; + struct pmo_vdev_priv_obj *vdev_ctx; + int index; + struct qdf_mac_addr peer_bssid; + + PMO_ENTER(); + psoc_ctx = pmo_get_psoc_priv_ctx(arp_req->psoc); + if (!psoc_ctx) { + pmo_err("psoc_ctx is NULL"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + vdev_ctx = pmo_get_vdev_priv_ctx(vdev); + if (!vdev_ctx) { + pmo_err("vdev_ctx is NULL"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + request = qdf_mem_malloc(sizeof(*request)); + if (!request) { + pmo_err("cannot allocate arp request"); + status = QDF_STATUS_E_NOMEM; + goto out; + } + + status = pmo_get_vdev_bss_peer_mac_addr(vdev, + &peer_bssid); + if (status != QDF_STATUS_SUCCESS) + goto out; + + qdf_mem_copy(&request->bssid.bytes, &peer_bssid.bytes, + QDF_MAC_ADDR_SIZE); + pmo_info("vdev self mac addr: %pM bss peer mac addr: %pM", + wlan_vdev_mlme_get_macaddr(vdev), + peer_bssid.bytes); + + request->enable = PMO_OFFLOAD_ENABLE; + /* converting u32 to IPV4 address */ + for (index = 0; index < PMO_IPV4_ADDR_LEN; index++) + request->host_ipv4_addr[index] = + (arp_req->ipv4_addr >> (index * 8)) & 0xFF; + + /* cache arp request */ + qdf_spin_lock_bh(&vdev_ctx->pmo_vdev_lock); + qdf_mem_copy(&vdev_ctx->vdev_arp_req, request, + sizeof(vdev_ctx->vdev_arp_req)); + qdf_spin_unlock_bh(&vdev_ctx->pmo_vdev_lock); + pmo_info("arp offload ipv4 addr: %d.%d.%d.%d enable: %d", + request->host_ipv4_addr[0], + request->host_ipv4_addr[1], + request->host_ipv4_addr[2], + request->host_ipv4_addr[3], + request->enable); +out: + if (request) + qdf_mem_free(request); + PMO_EXIT(); + + return status; +} + +static QDF_STATUS pmo_core_flush_arp_from_vdev_priv( + struct wlan_objmgr_vdev *vdev) +{ + struct pmo_vdev_priv_obj *vdev_ctx; + QDF_STATUS status = QDF_STATUS_SUCCESS; + + PMO_ENTER(); + vdev_ctx = pmo_get_vdev_priv_ctx(vdev); + if (!vdev_ctx) { + pmo_err("vdev_ctx is NULL"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + /* clear arp request */ + qdf_spin_lock_bh(&vdev_ctx->pmo_vdev_lock); + qdf_mem_zero(&vdev_ctx->vdev_arp_req, sizeof(vdev_ctx->vdev_arp_req)); + vdev_ctx->vdev_arp_req.enable = PMO_OFFLOAD_DISABLE; + qdf_spin_unlock_bh(&vdev_ctx->pmo_vdev_lock); +out: + PMO_EXIT(); + + return status; +} + +static QDF_STATUS pmo_core_do_enable_arp_offload(struct wlan_objmgr_vdev *vdev, + uint8_t vdev_id, enum pmo_offload_trigger trigger) +{ + QDF_STATUS status = QDF_STATUS_SUCCESS; + struct pmo_psoc_priv_obj *psoc_ctx; + struct pmo_vdev_priv_obj *vdev_ctx; + + PMO_ENTER(); + vdev_ctx = pmo_get_vdev_priv_ctx(vdev); + if (!vdev_ctx) { + pmo_err("vdev_ctx is NULL"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + psoc_ctx = vdev_ctx->pmo_psoc_ctx; + if (!psoc_ctx) { + pmo_err("psoc_ctx is NULL"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + switch (trigger) { + case pmo_ipv4_change_notify: + if (!psoc_ctx->psoc_cfg.active_mode_offload) { + pmo_info("active offload is disabled, skip in mode:%d", + trigger); + status = QDF_STATUS_E_INVAL; + goto out; + } + /* enable arp when active offload is true (ipv4 notifier) */ + status = pmo_tgt_enable_arp_offload_req(vdev, vdev_id); + break; + case pmo_apps_suspend: + if (psoc_ctx->psoc_cfg.active_mode_offload) { + pmo_info("active offload is enabled, skip in mode: %d", + trigger); + status = QDF_STATUS_E_INVAL; + goto out; + } + /* enable arp when active offload is false (apps suspend) */ + status = pmo_tgt_enable_arp_offload_req(vdev, vdev_id); + break; + default: + status = QDF_STATUS_E_INVAL; + pmo_err("invalid pmo trigger"); + break; + } +out: + PMO_EXIT(); + + return status; +} + +static QDF_STATUS pmo_core_do_disable_arp_offload(struct wlan_objmgr_vdev *vdev, + uint8_t vdev_id, enum pmo_offload_trigger trigger) +{ + QDF_STATUS status = QDF_STATUS_SUCCESS; + struct pmo_psoc_priv_obj *psoc_ctx; + struct pmo_vdev_priv_obj *vdev_ctx; + + PMO_ENTER(); + vdev_ctx = pmo_get_vdev_priv_ctx(vdev); + if (!vdev_ctx) { + pmo_err("vdev_ctx is NULL"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + psoc_ctx = vdev_ctx->pmo_psoc_ctx; + if (!psoc_ctx) { + pmo_err("psoc_ctx is NULL"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + switch (trigger) { + case pmo_apps_resume: + if (psoc_ctx->psoc_cfg.active_mode_offload) { + pmo_info("active offload is enabled, skip in mode: %d", + trigger); + status = QDF_STATUS_E_INVAL; + goto out; + } + /* disable arp on apps resume when active offload is disable */ + status = pmo_tgt_disable_arp_offload_req(vdev, vdev_id); + break; + default: + status = QDF_STATUS_E_INVAL; + pmo_err("invalid pmo trigger"); + break; + } +out: + PMO_EXIT(); + + return status; +} + +static QDF_STATUS pmo_core_arp_offload_sanity( + struct wlan_objmgr_vdev *vdev) +{ + struct pmo_vdev_priv_obj *vdev_ctx; + + if (!vdev) { + pmo_err("vdev is NULL"); + return QDF_STATUS_E_NULL_VALUE; + } + + vdev_ctx = pmo_get_vdev_priv_ctx(vdev); + if (!vdev_ctx) { + pmo_err("vdev_ctx is NULL"); + return QDF_STATUS_E_NULL_VALUE; + } + + if (!vdev_ctx->pmo_psoc_ctx->psoc_cfg.arp_offload_enable) { + pmo_err("user disabled arp offload using ini"); + return QDF_STATUS_E_INVAL; + } + + if (!pmo_core_is_vdev_supports_offload(vdev)) { + pmo_info("vdev in invalid opmode for arp offload %d", + pmo_get_vdev_opmode(vdev)); + return QDF_STATUS_E_INVAL; + } + + if (!pmo_core_is_vdev_connected(vdev)) + return QDF_STATUS_E_INVAL; + + return QDF_STATUS_SUCCESS; +} + +QDF_STATUS pmo_core_cache_arp_offload_req(struct pmo_arp_req *arp_req) +{ + QDF_STATUS status; + struct wlan_objmgr_vdev *vdev; + + PMO_ENTER(); + if (!arp_req) { + pmo_err("arp_req is NULL"); + status = QDF_STATUS_E_INVAL; + goto out; + } + + if (!arp_req->psoc) { + pmo_err("psoc is NULL"); + status = QDF_STATUS_E_INVAL; + goto out; + } + + vdev = wlan_objmgr_get_vdev_by_id_from_psoc(arp_req->psoc, + arp_req->vdev_id, WLAN_PMO_ID); + if (!vdev) { + pmo_err("vdev is NULL"); + status = QDF_STATUS_E_INVAL; + goto out; + } + + status = pmo_core_arp_offload_sanity(vdev); + if (status != QDF_STATUS_SUCCESS) + goto dec_ref; + + pmo_info("Cache arp for vdev id: %d psoc: %p vdev: %p", + arp_req->vdev_id, arp_req->psoc, vdev); + + status = pmo_core_cache_arp_in_vdev_priv(arp_req, vdev); +dec_ref: + wlan_objmgr_vdev_release_ref(vdev, WLAN_PMO_ID); +out: + PMO_EXIT(); + + return status; +} + +QDF_STATUS pmo_core_flush_arp_offload_req(struct wlan_objmgr_vdev *vdev) +{ + QDF_STATUS status; + uint8_t vdev_id; + + PMO_ENTER(); + if (!vdev) { + pmo_err("vdev is NULL"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + status = wlan_objmgr_vdev_try_get_ref(vdev, WLAN_PMO_ID); + if (status != QDF_STATUS_SUCCESS) + goto out; + + status = pmo_core_arp_offload_sanity(vdev); + if (status != QDF_STATUS_SUCCESS) + goto def_ref; + + vdev_id = pmo_get_vdev_id(vdev); + pmo_info("Flush arp for vdev id: %d vdev: %p", vdev_id, vdev); + + status = pmo_core_flush_arp_from_vdev_priv(vdev); +def_ref: + wlan_objmgr_vdev_release_ref(vdev, WLAN_PMO_ID); +out: + PMO_EXIT(); + + return status; +} + +QDF_STATUS pmo_core_enable_arp_offload_in_fwr(struct wlan_objmgr_vdev *vdev, + enum pmo_offload_trigger trigger) +{ + QDF_STATUS status; + uint8_t vdev_id; + + PMO_ENTER(); + if (!vdev) { + pmo_err("vdev is NULL"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + status = wlan_objmgr_vdev_try_get_ref(vdev, WLAN_PMO_ID); + if (status != QDF_STATUS_SUCCESS) + goto out; + + status = pmo_core_arp_offload_sanity(vdev); + if (status != QDF_STATUS_SUCCESS) + goto def_ref; + + vdev_id = pmo_get_vdev_id(vdev); + pmo_info("Enable arp offload in fwr vdev id: %d vdev: %p", + vdev_id, vdev); + + status = pmo_core_do_enable_arp_offload(vdev, vdev_id, trigger); +def_ref: + wlan_objmgr_vdev_release_ref(vdev, WLAN_PMO_ID); +out: + PMO_EXIT(); + + return status; +} + +QDF_STATUS pmo_core_disable_arp_offload_in_fwr(struct wlan_objmgr_vdev *vdev, + enum pmo_offload_trigger trigger) +{ + QDF_STATUS status; + uint8_t vdev_id; + + PMO_ENTER(); + if (!vdev) { + pmo_err("vdev is NULL"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + status = wlan_objmgr_vdev_try_get_ref(vdev, WLAN_PMO_ID); + if (status != QDF_STATUS_SUCCESS) + goto out; + + status = pmo_core_arp_offload_sanity(vdev); + if (status != QDF_STATUS_SUCCESS) + goto def_ref; + + vdev_id = pmo_get_vdev_id(vdev); + pmo_info("Disable arp offload in fwr vdev id: %d vdev: %p", + vdev_id, vdev); + + status = pmo_core_do_disable_arp_offload(vdev, vdev_id, trigger); +def_ref: + wlan_objmgr_vdev_release_ref(vdev, WLAN_PMO_ID); +out: + PMO_EXIT(); + + return status; +} + diff --git a/power_management_offloads/core/src/wlan_pmo_gtk.c b/power_management_offloads/core/src/wlan_pmo_gtk.c new file mode 100644 index 000000000000..646ef5d0c58f --- /dev/null +++ b/power_management_offloads/core/src/wlan_pmo_gtk.c @@ -0,0 +1,382 @@ +/* +* 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: Implements gtk offload feature API's + */ + +#include "wlan_pmo_gtk.h" +#include "wlan_pmo_tgt_api.h" +#include "wlan_pmo_main.h" +#include "wlan_pmo_obj_mgmt_public_struct.h" + +static QDF_STATUS pmo_core_cache_gtk_req_in_vdev_priv( + struct wlan_objmgr_vdev *vdev, + struct pmo_gtk_req *gtk_req) +{ + struct pmo_vdev_priv_obj *vdev_ctx; + QDF_STATUS status; + struct qdf_mac_addr peer_bssid; + + vdev_ctx = pmo_get_vdev_priv_ctx(vdev); + if (!vdev_ctx) { + pmo_err("vdev_ctx is NULL"); + return QDF_STATUS_E_INVAL; + } + + status = pmo_get_vdev_bss_peer_mac_addr(vdev, + &peer_bssid); + if (status != QDF_STATUS_SUCCESS) + return QDF_STATUS_E_INVAL; + + qdf_spin_lock_bh(&vdev_ctx->pmo_vdev_lock); + qdf_mem_copy(&vdev_ctx->vdev_gtk_req, gtk_req, + sizeof(vdev_ctx->vdev_gtk_req)); + qdf_mem_copy(&vdev_ctx->vdev_gtk_req.bssid, + &peer_bssid, QDF_MAC_ADDR_SIZE); + vdev_ctx->vdev_gtk_req.flags = PMO_GTK_OFFLOAD_ENABLE; + qdf_spin_unlock_bh(&vdev_ctx->pmo_vdev_lock); + + return status; +} + +static QDF_STATUS pmo_core_flush_gtk_req_from_vdev_priv( + struct wlan_objmgr_vdev *vdev) +{ + struct pmo_vdev_priv_obj *vdev_ctx; + + vdev_ctx = pmo_get_vdev_priv_ctx(vdev); + if (!vdev_ctx) { + pmo_err("vdev_ctx is NULL"); + return QDF_STATUS_E_INVAL; + } + + qdf_spin_lock_bh(&vdev_ctx->pmo_vdev_lock); + qdf_mem_zero(&vdev_ctx->vdev_gtk_req, sizeof(vdev_ctx->vdev_gtk_req)); + vdev_ctx->vdev_gtk_req.flags = PMO_GTK_OFFLOAD_DISABLE; + qdf_spin_unlock_bh(&vdev_ctx->pmo_vdev_lock); + + return QDF_STATUS_SUCCESS; +} + +static QDF_STATUS pmo_core_do_enable_gtk_offload( + struct wlan_objmgr_vdev *vdev, + struct pmo_vdev_priv_obj *vdev_ctx, + struct pmo_gtk_req *op_gtk_req) +{ + QDF_STATUS status = QDF_STATUS_SUCCESS; + uint8_t vdev_id; + + if (!pmo_core_is_vdev_supports_offload(vdev)) { + pmo_info("vdev in invalid opmode for gtk offload %d", + pmo_get_vdev_opmode(vdev)); + return QDF_STATUS_E_INVAL; + } + + if (!pmo_core_is_vdev_connected(vdev)) + return QDF_STATUS_E_INVAL; + + vdev_id = pmo_get_vdev_id(vdev); + + qdf_spin_lock_bh(&vdev_ctx->pmo_vdev_lock); + qdf_mem_copy(op_gtk_req, &vdev_ctx->vdev_gtk_req, + sizeof(*op_gtk_req)); + qdf_spin_unlock_bh(&vdev_ctx->pmo_vdev_lock); + + if ((op_gtk_req->flags == PMO_GTK_OFFLOAD_ENABLE) && + (qdf_atomic_read(&vdev_ctx->gtk_err_enable) == 1)) { + pmo_info("GTK Offload already enabled, Disabling vdev_id: %d", + vdev_id); + op_gtk_req->flags = PMO_GTK_OFFLOAD_DISABLE; + status = pmo_tgt_send_gtk_offload_req(vdev, op_gtk_req); + if (status != QDF_STATUS_SUCCESS) { + pmo_err("Failed to disable GTK Offload"); + goto out; + } + pmo_debug("Enable GTK Offload again with updated inputs"); + op_gtk_req->flags = PMO_GTK_OFFLOAD_ENABLE; + } + + status = pmo_tgt_send_gtk_offload_req(vdev, op_gtk_req); +out: + + return status; +} + +static QDF_STATUS pmo_core_is_gtk_enabled_in_fwr( + struct wlan_objmgr_vdev *vdev, + struct pmo_vdev_priv_obj *vdev_ctx) +{ + QDF_STATUS status; + struct qdf_mac_addr peer_bssid; + + if (!pmo_core_is_vdev_supports_offload(vdev)) { + pmo_info("vdev in invalid opmode for gtk offload enable %d", + pmo_get_vdev_opmode(vdev)); + return QDF_STATUS_E_INVAL; + } + + if (!pmo_core_is_vdev_connected(vdev)) + return QDF_STATUS_E_INVAL; + + status = pmo_get_vdev_bss_peer_mac_addr(vdev, + &peer_bssid); + if (status != QDF_STATUS_SUCCESS) + return QDF_STATUS_E_INVAL; + + qdf_spin_lock_bh(&vdev_ctx->pmo_vdev_lock); + if (qdf_mem_cmp(&vdev_ctx->vdev_gtk_req.bssid, + &peer_bssid, QDF_MAC_ADDR_SIZE)) { + qdf_spin_unlock_bh(&vdev_ctx->pmo_vdev_lock); + pmo_err("cache request mac:%pM, peer mac:%pM are not same", + vdev_ctx->vdev_gtk_req.bssid.bytes, + peer_bssid.bytes); + return QDF_STATUS_E_INVAL; + } + + if (vdev_ctx->vdev_gtk_req.flags != PMO_GTK_OFFLOAD_ENABLE) { + qdf_spin_unlock_bh(&vdev_ctx->pmo_vdev_lock); + pmo_err("gtk flag is disabled hence no gtk rsp required"); + return QDF_STATUS_E_INVAL; + } + qdf_spin_unlock_bh(&vdev_ctx->pmo_vdev_lock); + + return QDF_STATUS_SUCCESS; +} + +static QDF_STATUS pmo_core_do_disable_gtk_offload( + struct wlan_objmgr_vdev *vdev, + struct pmo_vdev_priv_obj *vdev_ctx, + struct pmo_gtk_req *op_gtk_req) +{ + QDF_STATUS status = QDF_STATUS_SUCCESS; + + status = pmo_core_is_gtk_enabled_in_fwr(vdev, vdev_ctx); + if (status != QDF_STATUS_SUCCESS) + return status; + + op_gtk_req->flags = PMO_GTK_OFFLOAD_DISABLE; + status = pmo_tgt_send_gtk_offload_req(vdev, op_gtk_req); + + return status; +} + +QDF_STATUS pmo_core_cache_gtk_offload_req(struct wlan_objmgr_vdev *vdev, + struct pmo_gtk_req *gtk_req) +{ + QDF_STATUS status; + enum tQDF_ADAPTER_MODE opmode; + uint8_t vdev_id; + + PMO_ENTER(); + if (!gtk_req) { + pmo_err("gtk_req is NULL"); + status = QDF_STATUS_E_INVAL; + goto out; + } + + if (!vdev) { + pmo_err("vdev is NULL"); + status = QDF_STATUS_E_INVAL; + goto out; + } + + status = wlan_objmgr_vdev_try_get_ref(vdev, WLAN_PMO_ID); + if (status != QDF_STATUS_SUCCESS) + goto out; + + opmode = pmo_get_vdev_opmode(vdev); + vdev_id = pmo_get_vdev_id(vdev); + pmo_info("vdev opmode: %d vdev_id: %d", opmode, vdev_id); + if (!pmo_core_is_vdev_supports_offload(vdev)) { + pmo_info("vdev in invalid opmode for caching gtk request %d", + opmode); + status = QDF_STATUS_E_INVAL; + goto dec_ref; + } + + status = pmo_core_cache_gtk_req_in_vdev_priv(vdev, gtk_req); +dec_ref: + wlan_objmgr_vdev_release_ref(vdev, WLAN_PMO_ID); +out: + PMO_EXIT(); + + return status; +} + +QDF_STATUS pmo_core_flush_gtk_offload_req(struct wlan_objmgr_vdev *vdev) +{ + enum tQDF_ADAPTER_MODE opmode; + uint8_t vdev_id; + QDF_STATUS status; + + PMO_ENTER(); + if (!vdev) { + pmo_err("psoc is NULL"); + status = QDF_STATUS_E_INVAL; + goto out; + } + + status = wlan_objmgr_vdev_try_get_ref(vdev, WLAN_PMO_ID); + if (status != QDF_STATUS_SUCCESS) + goto out; + + opmode = pmo_get_vdev_opmode(vdev); + vdev_id = pmo_get_vdev_id(vdev); + pmo_info("vdev opmode: %d vdev_id: %d", opmode, vdev_id); + if (!pmo_core_is_vdev_supports_offload(vdev)) { + pmo_info("vdev in invalid opmode for flushing gtk request %d", + opmode); + status = QDF_STATUS_E_INVAL; + goto dec_ref; + } + + status = pmo_core_flush_gtk_req_from_vdev_priv(vdev); +dec_ref: + wlan_objmgr_vdev_release_ref(vdev, WLAN_PMO_ID); +out: + PMO_EXIT(); + + return status; +} + +QDF_STATUS pmo_core_enable_gtk_offload_in_fwr(struct wlan_objmgr_vdev *vdev) +{ + QDF_STATUS status; + struct pmo_vdev_priv_obj *vdev_ctx; + struct pmo_gtk_req *op_gtk_req = NULL; + + PMO_ENTER(); + if (!vdev) { + pmo_err("vdev is NULL"); + status = QDF_STATUS_E_INVAL; + goto out; + } + + status = wlan_objmgr_vdev_try_get_ref(vdev, WLAN_PMO_ID); + if (status != QDF_STATUS_SUCCESS) + goto out; + + vdev_ctx = pmo_get_vdev_priv_ctx(vdev); + if (!vdev_ctx) { + pmo_err("vdev_ctx is NULL"); + status = QDF_STATUS_E_INVAL; + goto dec_ref; + } + + op_gtk_req = qdf_mem_malloc(sizeof(*op_gtk_req)); + if (!op_gtk_req) { + pmo_err("op_gtk_req is NULL"); + status = QDF_STATUS_E_INVAL; + goto dec_ref; + } + status = pmo_core_do_enable_gtk_offload(vdev, vdev_ctx, op_gtk_req); +dec_ref: + wlan_objmgr_vdev_release_ref(vdev, WLAN_PMO_ID); +out: + if (op_gtk_req) + qdf_mem_free(op_gtk_req); + PMO_EXIT(); + + return status; +} + +QDF_STATUS pmo_core_disable_gtk_offload_in_fwr(struct wlan_objmgr_vdev *vdev) +{ + QDF_STATUS status; + struct pmo_vdev_priv_obj *vdev_ctx; + struct pmo_gtk_req *op_gtk_req = NULL; + + PMO_ENTER(); + if (!vdev) { + pmo_err("vdev is NULL"); + status = QDF_STATUS_E_INVAL; + goto out; + } + + status = wlan_objmgr_vdev_try_get_ref(vdev, WLAN_PMO_ID); + if (status != QDF_STATUS_SUCCESS) + goto out; + + vdev_ctx = pmo_get_vdev_priv_ctx(vdev); + if (!vdev_ctx) { + pmo_err("vdev_ctx is NULL"); + status = QDF_STATUS_E_INVAL; + goto dec_ref; + } + + op_gtk_req = qdf_mem_malloc(sizeof(*op_gtk_req)); + if (!op_gtk_req) { + pmo_err("op_gtk_req is NULL"); + status = QDF_STATUS_E_NOMEM; + goto dec_ref; + } + + status = pmo_core_do_disable_gtk_offload(vdev, vdev_ctx, op_gtk_req); +dec_ref: + wlan_objmgr_vdev_release_ref(vdev, WLAN_PMO_ID); +out: + if (op_gtk_req) + qdf_mem_free(op_gtk_req); + PMO_EXIT(); + + return status; +} + +QDF_STATUS pmo_core_get_gtk_rsp(struct wlan_objmgr_vdev *vdev, + struct pmo_gtk_rsp_req *gtk_rsp_req) +{ + QDF_STATUS status = QDF_STATUS_SUCCESS; + struct pmo_vdev_priv_obj *vdev_ctx; + + PMO_ENTER(); + if (!gtk_rsp_req || !vdev) { + pmo_err("%s is null", !vdev ? "vdev":"gtk_rsp_req"); + status = QDF_STATUS_E_INVAL; + goto out; + } + + status = wlan_objmgr_vdev_try_get_ref(vdev, WLAN_PMO_ID); + if (status != QDF_STATUS_SUCCESS) + goto out; + + vdev_ctx = pmo_get_vdev_priv_ctx(vdev); + if (!vdev_ctx) { + pmo_err("vdev_ctx is NULL"); + status = QDF_STATUS_E_INVAL; + goto dec_ref; + } + + status = pmo_core_is_gtk_enabled_in_fwr(vdev, vdev_ctx); + if (status != QDF_STATUS_SUCCESS) + goto dec_ref; + + /* cache gtk rsp request */ + qdf_spin_lock_bh(&vdev_ctx->pmo_vdev_lock); + qdf_mem_copy(&vdev_ctx->vdev_gtk_rsp_req, gtk_rsp_req, + sizeof(vdev_ctx->vdev_gtk_rsp_req)); + qdf_spin_unlock_bh(&vdev_ctx->pmo_vdev_lock); + /* send cmd to fwr */ + status = pmo_tgt_get_gtk_rsp(vdev); +dec_ref: + wlan_objmgr_vdev_release_ref(vdev, WLAN_PMO_ID); +out: + PMO_EXIT(); + + return status; +} + diff --git a/power_management_offloads/core/src/wlan_pmo_main.c b/power_management_offloads/core/src/wlan_pmo_main.c new file mode 100644 index 000000000000..642d37df6227 --- /dev/null +++ b/power_management_offloads/core/src/wlan_pmo_main.c @@ -0,0 +1,267 @@ +/* +* 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: Implement various api / helper function which shall be used + * PMO user and target interface. + */ + +#include "wlan_pmo_main.h" +#include "wlan_pmo_obj_mgmt_public_struct.h" + +static struct wlan_pmo_ctx *gp_pmo_ctx; + +QDF_STATUS pmo_allocate_ctx(void) +{ + /* If it is already created, ignore */ + if (gp_pmo_ctx != NULL) { + pmo_debug("already allocated pmo_ctx"); + return QDF_STATUS_SUCCESS; + } + + /* allocate offload mgr ctx */ + gp_pmo_ctx = (struct wlan_pmo_ctx *)qdf_mem_malloc( + sizeof(*gp_pmo_ctx)); + if (!gp_pmo_ctx) { + pmo_err("unable to allocate pmo_ctx"); + QDF_ASSERT(0); + return QDF_STATUS_E_NOMEM; + } + qdf_spinlock_create(&gp_pmo_ctx->lock); + + return QDF_STATUS_SUCCESS; +} + +void pmo_free_ctx(void) +{ + if (!gp_pmo_ctx) { + pmo_err("pmo ctx is already freed"); + QDF_ASSERT(0); + return; + } + qdf_spinlock_destroy(&gp_pmo_ctx->lock); + qdf_mem_free(gp_pmo_ctx); + gp_pmo_ctx = NULL; +} + +struct wlan_pmo_ctx *pmo_get_context(void) +{ + return gp_pmo_ctx; +} + +struct pmo_psoc_priv_obj *pmo_get_psoc_priv_ctx( + struct wlan_objmgr_psoc *psoc) +{ + struct pmo_psoc_priv_obj *psoc_ctx; + + wlan_psoc_obj_lock(psoc); + psoc_ctx = wlan_objmgr_psoc_get_comp_private_obj(psoc, + WLAN_UMAC_COMP_PMO); + wlan_psoc_obj_unlock(psoc); + return psoc_ctx; +} + +struct pmo_vdev_priv_obj *pmo_get_vdev_priv_ctx(struct wlan_objmgr_vdev *vdev) +{ + struct pmo_vdev_priv_obj *vdev_ctx = NULL; + + wlan_vdev_obj_lock(vdev); + vdev_ctx = wlan_objmgr_vdev_get_comp_private_obj(vdev, + WLAN_UMAC_COMP_PMO); + wlan_vdev_obj_unlock(vdev); + + return vdev_ctx; +} + +struct pmo_psoc_priv_obj *pmo_psoc_ctx_from_vdev_ctx( + struct pmo_vdev_priv_obj *vdev_ctx) +{ + return vdev_ctx->pmo_psoc_ctx; +} + +bool pmo_is_vdev_in_beaconning_mode( + enum tQDF_ADAPTER_MODE vdev_opmode) +{ + bool val; + + switch (vdev_opmode) { + case QDF_SAP_MODE: + case QDF_P2P_GO_MODE: + case QDF_IBSS_MODE: + val = true; + break; + default: + val = false; + break; + } + + return val; +} + +QDF_STATUS pmo_get_vdev_bss_peer_mac_addr(struct wlan_objmgr_vdev *vdev, + struct qdf_mac_addr *bss_peer_mac_address) +{ + struct wlan_objmgr_peer *peer; + + if (!vdev) { + pmo_err("vdev is null"); + return QDF_STATUS_E_INVAL; + } + + wlan_vdev_obj_lock(vdev); + peer = wlan_vdev_get_bsspeer(vdev); + if (!peer) { + wlan_vdev_obj_unlock(vdev); + pmo_err("peer is null"); + return QDF_STATUS_E_INVAL; + } + wlan_vdev_obj_unlock(vdev); + + wlan_peer_obj_lock(peer); + qdf_mem_copy(bss_peer_mac_address->bytes, wlan_peer_get_macaddr(peer), + QDF_MAC_ADDR_SIZE); + wlan_peer_obj_unlock(peer); + + return QDF_STATUS_SUCCESS; +} + +bool pmo_core_is_ap_mode_supports_arp_ns(struct wlan_objmgr_psoc *psoc, + enum tQDF_ADAPTER_MODE vdev_opmode) +{ + struct pmo_psoc_priv_obj *psoc_ctx; + + psoc_ctx = pmo_get_psoc_priv_ctx(psoc); + if (!psoc_ctx) { + pmo_err("psoc_ctx is NULL"); + return false; + } + + if ((vdev_opmode == QDF_SAP_MODE || + vdev_opmode == QDF_P2P_GO_MODE) && + !psoc_ctx->psoc_cfg.ap_arpns_support) { + pmo_info("ARP/NS Offload is not supported in SAP/P2PGO mode"); + return false; + } + + return true; +} + +bool pmo_core_is_vdev_connected(struct wlan_objmgr_vdev *vdev) +{ + struct wlan_objmgr_peer *peer; + enum wlan_peer_state peer_state; + + wlan_vdev_obj_lock(vdev); + peer = wlan_vdev_get_bsspeer(vdev); + wlan_vdev_obj_unlock(vdev); + + if (!peer) { + pmo_err("peer is null"); + return false; + } + wlan_peer_obj_lock(peer); + peer_state = wlan_peer_mlme_get_state(peer); + wlan_peer_obj_unlock(peer); + + if (peer_state != WLAN_ASSOC_STATE) { + pmo_err("peer is not associated.peer state: %d", + peer_state); + return false; + } + + return true; +} + +bool pmo_core_is_vdev_supports_offload(struct wlan_objmgr_vdev *vdev) +{ + enum tQDF_ADAPTER_MODE opmode; + bool val; + + opmode = pmo_get_vdev_opmode(vdev); + pmo_info("vdev opmode: %d", opmode); + switch (opmode) { + case QDF_STA_MODE: + case QDF_P2P_CLIENT_MODE: + case QDF_NDI_MODE: + val = true; + break; + default: + val = false; + break; + } + + return val; +} + +QDF_STATUS pmo_core_get_psoc_config(struct wlan_objmgr_psoc *psoc, + struct pmo_psoc_cfg *psoc_cfg) +{ + struct pmo_psoc_priv_obj *psoc_ctx; + QDF_STATUS status = QDF_STATUS_SUCCESS; + + PMO_ENTER(); + if (!psoc || !psoc_cfg) { + pmo_err("%s is null", !psoc ? "psoc":"psoc_cfg"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + psoc_ctx = pmo_get_psoc_priv_ctx(psoc); + if (!psoc_ctx) { + pmo_err("pmo psoc ctx is null"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + qdf_spin_lock(&psoc_ctx->lock); + qdf_mem_copy(psoc_cfg, &psoc_ctx->psoc_cfg, sizeof(*psoc_cfg)); + qdf_spin_unlock(&psoc_ctx->lock); +out: + PMO_EXIT(); + + return status; +} + +QDF_STATUS pmo_core_update_psoc_config(struct wlan_objmgr_psoc *psoc, + struct pmo_psoc_cfg *psoc_cfg) +{ + struct pmo_psoc_priv_obj *psoc_ctx; + QDF_STATUS status = QDF_STATUS_SUCCESS; + + PMO_ENTER(); + if (!psoc || !psoc_cfg) { + pmo_err("%s is null", !psoc ? "psoc":"psoc_cfg"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + psoc_ctx = pmo_get_psoc_priv_ctx(psoc); + if (!psoc_ctx) { + pmo_err("pmo psoc ctx is null"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + qdf_spin_lock(&psoc_ctx->lock); + qdf_mem_copy(&psoc_ctx->psoc_cfg, psoc_cfg, sizeof(*psoc_cfg)); + qdf_spin_unlock(&psoc_ctx->lock); +out: + PMO_EXIT(); + + return status; +} + diff --git a/power_management_offloads/core/src/wlan_pmo_mc_addr_filtering.c b/power_management_offloads/core/src/wlan_pmo_mc_addr_filtering.c new file mode 100644 index 000000000000..bff5bb2d3cc4 --- /dev/null +++ b/power_management_offloads/core/src/wlan_pmo_mc_addr_filtering.c @@ -0,0 +1,648 @@ +/* +* 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: Implements mc addr filtering offload feature API's + */ + +#include "wlan_pmo_mc_addr_filtering.h" +#include "wlan_pmo_tgt_api.h" +#include "wlan_pmo_main.h" +#include "wlan_pmo_obj_mgmt_public_struct.h" + + +#define PMO_INVALID_MC_ADDR_COUNT (-1) + +static void pmo_core_fill_mc_list(struct pmo_vdev_priv_obj **vdev_ctx, + struct pmo_mc_addr_list_params *ip) +{ + struct pmo_mc_addr_list *op_list; + int i; + static const uint8_t ipv6_rs[] = { + 0x33, 0x33, 0x00, 0x00, 0x00, 0x02}; + struct pmo_vdev_priv_obj *temp_ctx; + uint8_t addr_fp; + + temp_ctx = *vdev_ctx; + addr_fp = temp_ctx->addr_filter_pattern; + op_list = &temp_ctx->vdev_mc_list_req; + + qdf_spin_lock_bh(&temp_ctx->pmo_vdev_lock); + op_list->mc_cnt = ip->count; + qdf_spin_unlock_bh(&temp_ctx->pmo_vdev_lock); + + for (i = 0; i < ip->count; i++) { + pmo_debug("%pM", ip->mc_addr[i].bytes); + /* + * Skip following addresses: + * 1)IPv6 router solicitation address + * 2)Any other address pattern if its set during + * RXFILTER REMOVE driver command based on + * addr_filter_pattern + */ + if ((!qdf_mem_cmp(ip->mc_addr[i].bytes, ipv6_rs, + QDF_MAC_ADDR_SIZE)) || + (addr_fp && + (!qdf_mem_cmp(ip->mc_addr[i].bytes, &addr_fp, 1)))) { + pmo_debug("MC/BC filtering Skip addr %pM", + ip->mc_addr[i].bytes); + qdf_spin_lock_bh(&temp_ctx->pmo_vdev_lock); + op_list->mc_cnt--; + qdf_spin_unlock_bh(&temp_ctx->pmo_vdev_lock); + continue; + } + qdf_spin_lock_bh(&temp_ctx->pmo_vdev_lock); + qdf_mem_set(&(op_list->mc_addr[i].bytes), 0, + QDF_MAC_ADDR_SIZE); + qdf_mem_copy(&(op_list->mc_addr[i].bytes), + ip->mc_addr[i].bytes, QDF_MAC_ADDR_SIZE); + qdf_spin_unlock_bh(&temp_ctx->pmo_vdev_lock); + pmo_debug("mlist[%pM] = ", op_list->mc_addr[i].bytes); + } +} + +static QDF_STATUS pmo_core_cache_mc_addr_list_in_vdev_priv( + struct pmo_mc_addr_list_params *mc_list_config, + struct wlan_objmgr_vdev *vdev) +{ + struct pmo_vdev_priv_obj *vdev_ctx; + QDF_STATUS status = QDF_STATUS_SUCCESS; + + vdev_ctx = pmo_get_vdev_priv_ctx(vdev); + if (!vdev_ctx) { + pmo_err("vdev_ctx is NULL"); + return QDF_STATUS_E_INVAL; + } + + pmo_core_fill_mc_list(&vdev_ctx, mc_list_config); + + return status; +} + +static QDF_STATUS pmo_core_flush_mc_addr_list_from_vdev_priv( + struct wlan_objmgr_vdev *vdev) +{ + struct pmo_vdev_priv_obj *vdev_ctx; + + vdev_ctx = pmo_get_vdev_priv_ctx(vdev); + if (!vdev_ctx) { + pmo_err("vdev_ctx is NULL"); + return QDF_STATUS_E_INVAL; + } + + qdf_spin_lock_bh(&vdev_ctx->pmo_vdev_lock); + qdf_mem_zero(&vdev_ctx->vdev_mc_list_req, + sizeof(vdev_ctx->vdev_mc_list_req)); + qdf_spin_unlock_bh(&vdev_ctx->pmo_vdev_lock); + + return QDF_STATUS_SUCCESS; +} + +QDF_STATUS pmo_core_set_mc_filter_req(struct wlan_objmgr_vdev *vdev, + struct pmo_mc_addr_list *mc_list) +{ + struct pmo_vdev_priv_obj *vdev_ctx; + uint8_t vdev_id; + int i; + QDF_STATUS status = QDF_STATUS_SUCCESS; + + PMO_ENTER(); + vdev_ctx = pmo_get_vdev_priv_ctx(vdev); + if (!vdev_ctx) { + pmo_err("vdev_ctx is NULL"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + vdev_id = pmo_get_vdev_id(vdev); + /* + * Configure enhance multicast offload feature for filtering out + * multicast IP data packets transmitted using unicast MAC address + */ + + /* + * TODO + {//(WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap, + //WMI_SERVICE_ENHANCED_MCAST_FILTER)) { + */ + if (1) { + pmo_info("FW supports enhance multicast offload"); + pmo_tgt_send_enhance_multicast_offload_req(vdev, vdev_id, + false); + } else { + pmo_info("FW does not support enhance multicast offload"); + } + + /* + * set mc_param->action to clear MCList and reset + * to configure the MCList in FW + */ + for (i = 0; i < mc_list->mc_cnt; i++) { + pmo_tgt_set_mc_filter_req(vdev, + mc_list->mc_addr[i]); + } +out: + PMO_EXIT(); + + return status; +} + +QDF_STATUS pmo_core_clear_mc_filter_req(struct wlan_objmgr_vdev *vdev, + struct pmo_mc_addr_list *mc_list) +{ + struct pmo_vdev_priv_obj *vdev_ctx; + uint8_t vdev_id; + int i; + QDF_STATUS status = QDF_STATUS_SUCCESS; + + PMO_ENTER(); + vdev_ctx = pmo_get_vdev_priv_ctx(vdev); + if (!vdev_ctx) { + pmo_err("vdev_ctx is NULL"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + vdev_id = pmo_get_vdev_id(vdev); + + /* + * Configure enhance multicast offload feature for filtering out + * multicast IP data packets transmitted using unicast MAC address + */ + + /* + * TODO + {//(WMI_SERVICE_IS_ENABLED(wma_handle->wmi_service_bitmap, + //WMI_SERVICE_ENHANCED_MCAST_FILTER)) { + */ + if (1) { + pmo_info("FW supports enhance multicast offload"); + pmo_tgt_send_enhance_multicast_offload_req(vdev, vdev_id, + true); + } else { + pmo_info("FW does not support enhance multicast offload"); + } + + /* + * set mcbc_param->action to clear MCList and reset + * to configure the MCList in FW + */ + for (i = 0; i < mc_list->mc_cnt; i++) { + pmo_tgt_clear_mc_filter_req(vdev, + mc_list->mc_addr[i]); + } +out: + PMO_EXIT(); + + return status; +} + +static QDF_STATUS pmo_core_do_enable_mc_addr_list(struct wlan_objmgr_vdev *vdev, + struct pmo_vdev_priv_obj *vdev_ctx, + struct pmo_mc_addr_list *op_mc_list_req) +{ + QDF_STATUS status; + + PMO_ENTER(); + qdf_spin_lock_bh(&vdev_ctx->pmo_vdev_lock); + if (!vdev_ctx->vdev_mc_list_req.mc_cnt) { + qdf_spin_unlock_bh(&vdev_ctx->pmo_vdev_lock); + pmo_err("mc_cnt is zero so skip to add mc list"); + status = QDF_STATUS_E_INVAL; + goto out; + } + qdf_mem_copy(op_mc_list_req, &vdev_ctx->vdev_mc_list_req, + sizeof(*op_mc_list_req)); + qdf_spin_unlock_bh(&vdev_ctx->pmo_vdev_lock); + + status = pmo_core_set_mc_filter_req(vdev, op_mc_list_req); + if (status != QDF_STATUS_SUCCESS) { + pmo_err("cannot apply mc filter request"); + status = QDF_STATUS_E_INVAL; + goto out; + } + + qdf_spin_lock_bh(&vdev_ctx->pmo_vdev_lock); + vdev_ctx->vdev_mc_list_req.is_filter_applied = true; + qdf_spin_unlock_bh(&vdev_ctx->pmo_vdev_lock); +out: + PMO_EXIT(); + + return status; +} + +static QDF_STATUS pmo_core_do_disable_mc_addr_list( + struct wlan_objmgr_vdev *vdev, + struct pmo_vdev_priv_obj *vdev_ctx, + struct pmo_mc_addr_list *op_mc_list_req) +{ + QDF_STATUS status; + + PMO_ENTER(); + qdf_spin_lock_bh(&vdev_ctx->pmo_vdev_lock); + /* validate filter is applied before clearing in fwr */ + if (!vdev_ctx->vdev_mc_list_req.is_filter_applied) { + qdf_spin_unlock_bh(&vdev_ctx->pmo_vdev_lock); + pmo_err("mc filter is not applied in fwr"); + status = QDF_STATUS_E_INVAL; + goto out; + } + qdf_mem_copy(op_mc_list_req, &vdev_ctx->vdev_mc_list_req, + sizeof(*op_mc_list_req)); + qdf_spin_unlock_bh(&vdev_ctx->pmo_vdev_lock); + + status = pmo_core_clear_mc_filter_req(vdev, op_mc_list_req); + if (status != QDF_STATUS_SUCCESS) { + pmo_err("cannot apply mc filter request"); + status = QDF_STATUS_E_INVAL; + goto out; + } + + qdf_spin_lock_bh(&vdev_ctx->pmo_vdev_lock); + vdev_ctx->vdev_mc_list_req.is_filter_applied = false; + qdf_spin_unlock_bh(&vdev_ctx->pmo_vdev_lock); +out: + PMO_EXIT(); + + return status; +} + +uint8_t pmo_core_max_mc_addr_supported(struct wlan_objmgr_psoc *psoc) +{ + return PMO_MAX_MC_ADDR_LIST; +} + +int pmo_core_get_mc_addr_list_count(struct wlan_objmgr_psoc *psoc, + uint8_t vdev_id) +{ + struct pmo_psoc_priv_obj *psoc_ctx; + struct wlan_objmgr_vdev *vdev; + struct pmo_vdev_priv_obj *vdev_ctx; + uint8_t mc_cnt; + + psoc_ctx = pmo_get_psoc_priv_ctx(psoc); + if (!psoc_ctx) { + pmo_err("psoc_ctx is"); + mc_cnt = PMO_INVALID_MC_ADDR_COUNT; + goto out; + } + + vdev = wlan_objmgr_get_vdev_by_id_from_psoc(psoc, vdev_id, WLAN_PMO_ID); + if (!vdev) { + pmo_err("vdev is NULL"); + mc_cnt = PMO_INVALID_MC_ADDR_COUNT; + goto out; + } + + vdev_ctx = pmo_get_vdev_priv_ctx(vdev); + if (!vdev_ctx) { + pmo_err("vdev_ctx is NULL"); + mc_cnt = PMO_INVALID_MC_ADDR_COUNT; + goto dec_ref; + } + qdf_spin_lock_bh(&vdev_ctx->pmo_vdev_lock); + mc_cnt = vdev_ctx->vdev_mc_list_req.mc_cnt; + qdf_spin_unlock_bh(&vdev_ctx->pmo_vdev_lock); +dec_ref: + wlan_objmgr_vdev_release_ref(vdev, WLAN_PMO_ID); +out: + + return mc_cnt; +} + +void pmo_core_set_mc_addr_list_count(struct wlan_objmgr_psoc *psoc, + uint8_t vdev_id, uint8_t count) +{ + struct pmo_psoc_priv_obj *psoc_ctx; + struct pmo_vdev_priv_obj *vdev_ctx; + struct wlan_objmgr_vdev *vdev; + + psoc_ctx = pmo_get_psoc_priv_ctx(psoc); + if (!psoc_ctx) { + pmo_err("psoc_ctx is NULL"); + goto out; + } + + vdev = wlan_objmgr_get_vdev_by_id_from_psoc(psoc, vdev_id, WLAN_PMO_ID); + if (!vdev) { + pmo_err("vdev is NULL"); + goto out; + } + + vdev_ctx = pmo_get_vdev_priv_ctx(vdev); + if (!vdev_ctx) { + pmo_err("vdev_ctx is NULL"); + goto dec_ref; + } + qdf_spin_lock_bh(&vdev_ctx->pmo_vdev_lock); + vdev_ctx->vdev_mc_list_req.mc_cnt = count; + qdf_spin_unlock_bh(&vdev_ctx->pmo_vdev_lock); + +dec_ref: + wlan_objmgr_vdev_release_ref(vdev, WLAN_PMO_ID); +out: + + return; +} + +static QDF_STATUS pmo_core_mc_addr_flitering_sanity( + struct wlan_objmgr_vdev *vdev) +{ + struct pmo_vdev_priv_obj *vdev_ctx; + + if (!vdev) { + pmo_err("vdev is NULL"); + return QDF_STATUS_E_NULL_VALUE; + } + + vdev_ctx = pmo_get_vdev_priv_ctx(vdev); + if (!vdev_ctx) { + pmo_err("vdev_ctx is NULL"); + return QDF_STATUS_E_NULL_VALUE; + } + + /* Check if INI is enabled or not, otherwise just return */ + if (!vdev_ctx->pmo_psoc_ctx->psoc_cfg.enable_mc_list) { + pmo_info("user disabled mc_addr_list using INI"); + return QDF_STATUS_E_INVAL; + } + + if (!pmo_core_is_vdev_supports_offload(vdev)) { + pmo_info("vdev in invalid opmode for mc addr filtering %d", + pmo_get_vdev_opmode(vdev)); + return QDF_STATUS_E_INVAL; + } + + if (!pmo_core_is_vdev_connected(vdev)) + return QDF_STATUS_E_INVAL; + + return QDF_STATUS_SUCCESS; +} +QDF_STATUS pmo_core_cache_mc_addr_list( + struct pmo_mc_addr_list_params *mc_list_config) +{ + struct wlan_objmgr_vdev *vdev; + QDF_STATUS status; + + PMO_ENTER(); + if (!mc_list_config->psoc) { + pmo_err("psoc is NULL"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + vdev = wlan_objmgr_get_vdev_by_id_from_psoc(mc_list_config->psoc, + mc_list_config->vdev_id, WLAN_PMO_ID); + if (!vdev) { + pmo_err("vdev is NULL"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + status = pmo_core_mc_addr_flitering_sanity(vdev); + if (status != QDF_STATUS_SUCCESS) + goto dec_ref; + + pmo_info("Cache mc addr list for vdev id: %d psoc: %p vdev: %p", + mc_list_config->vdev_id, mc_list_config->psoc, vdev); + + status = pmo_core_cache_mc_addr_list_in_vdev_priv(mc_list_config, vdev); +dec_ref: + wlan_objmgr_vdev_release_ref(vdev, WLAN_PMO_ID); +out: + PMO_EXIT(); + + return status; +} + +QDF_STATUS pmo_core_flush_mc_addr_list(struct wlan_objmgr_psoc *psoc, + uint8_t vdev_id) +{ + struct wlan_objmgr_vdev *vdev; + QDF_STATUS status = QDF_STATUS_SUCCESS; + + PMO_ENTER(); + if (!psoc) { + pmo_err("psoc is NULL"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + vdev = wlan_objmgr_get_vdev_by_id_from_psoc(psoc, vdev_id, WLAN_PMO_ID); + if (!vdev) { + pmo_err("vdev is NULL"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + status = pmo_core_mc_addr_flitering_sanity(vdev); + if (status != QDF_STATUS_SUCCESS) + goto dec_ref; + + pmo_info("Flush mc addr list for vdev id: %d psoc: %p vdev: %p", + vdev_id, psoc, vdev); + + status = pmo_core_flush_mc_addr_list_from_vdev_priv(vdev); +dec_ref: + wlan_objmgr_vdev_release_ref(vdev, WLAN_PMO_ID); +out: + PMO_EXIT(); + + return status; +} + +static QDF_STATUS pmo_core_handle_enable_mc_list_trigger( + struct wlan_objmgr_vdev *vdev, + enum pmo_offload_trigger trigger) +{ + struct pmo_vdev_priv_obj *vdev_ctx; + QDF_STATUS status; + struct pmo_mc_addr_list *op_mc_list_req = NULL; + + vdev_ctx = pmo_get_vdev_priv_ctx(vdev); + if (!vdev_ctx) { + pmo_err("vdev_ctx is NULL"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + op_mc_list_req = qdf_mem_malloc(sizeof(*op_mc_list_req)); + if (!op_mc_list_req) { + pmo_err("op_mc_list_req is NULL"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + switch (trigger) { + case pmo_mc_list_change_notify: + if (!vdev_ctx->pmo_psoc_ctx->psoc_cfg.active_mode_offload) { + pmo_info("active offload is disabled, skip in mode: %d", + trigger); + status = QDF_STATUS_E_INVAL; + goto out; + } + status = pmo_core_do_enable_mc_addr_list(vdev, vdev_ctx, + op_mc_list_req); + break; + case pmo_apps_suspend: + if (vdev_ctx->pmo_psoc_ctx->psoc_cfg.active_mode_offload) { + pmo_info("active offload is enabled, skip in mode: %d", + trigger); + status = QDF_STATUS_E_INVAL; + goto out; + } + status = pmo_core_do_enable_mc_addr_list(vdev, vdev_ctx, + op_mc_list_req); + break; + default: + status = QDF_STATUS_E_INVAL; + pmo_err("invalid pmo trigger for enable mc list"); + break; + } +out: + if (op_mc_list_req) + qdf_mem_free(op_mc_list_req); + + return status; +} + +QDF_STATUS pmo_core_enable_mc_addr_filtering_in_fwr( + struct wlan_objmgr_psoc *psoc, + uint8_t vdev_id, + enum pmo_offload_trigger trigger) +{ + QDF_STATUS status; + struct wlan_objmgr_vdev *vdev; + + PMO_ENTER(); + if (!psoc) { + pmo_err("psoc is NULL"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + vdev = wlan_objmgr_get_vdev_by_id_from_psoc(psoc, vdev_id, WLAN_PMO_ID); + if (!vdev) { + pmo_err("vdev is NULL"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + status = pmo_core_mc_addr_flitering_sanity(vdev); + if (status != QDF_STATUS_SUCCESS) + goto dec_ref; + + pmo_info("enable mclist trigger: %d", trigger); + status = pmo_core_handle_enable_mc_list_trigger(vdev, trigger); +dec_ref: + wlan_objmgr_vdev_release_ref(vdev, WLAN_PMO_ID); +out: + PMO_EXIT(); + + return status; +} + +static QDF_STATUS pmo_core_handle_disable_mc_list_trigger( + struct wlan_objmgr_vdev *vdev, + enum pmo_offload_trigger trigger) +{ + struct pmo_vdev_priv_obj *vdev_ctx; + QDF_STATUS status; + struct pmo_mc_addr_list *op_mc_list_req = NULL; + + vdev_ctx = pmo_get_vdev_priv_ctx(vdev); + if (!vdev_ctx) { + pmo_err("vdev_ctx is NULL"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + op_mc_list_req = qdf_mem_malloc(sizeof(*op_mc_list_req)); + if (!op_mc_list_req) { + pmo_err("op_mc_list_req is NULL"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + switch (trigger) { + case pmo_peer_disconnect: + case pmo_mc_list_change_notify: + if (!vdev_ctx->pmo_psoc_ctx->psoc_cfg.active_mode_offload) { + pmo_info("active offload is disabled, skip in mode: %d", + trigger); + status = QDF_STATUS_E_INVAL; + goto out; + } + status = pmo_core_do_disable_mc_addr_list(vdev, vdev_ctx, + op_mc_list_req); + break; + case pmo_apps_resume: + if (vdev_ctx->pmo_psoc_ctx->psoc_cfg.active_mode_offload) { + pmo_info("active offload is enabled, skip in mode: %d", + trigger); + status = QDF_STATUS_E_INVAL; + goto out; + } + status = pmo_core_do_disable_mc_addr_list(vdev, vdev_ctx, + op_mc_list_req); + break; + default: + status = QDF_STATUS_E_INVAL; + pmo_err("invalid pmo trigger for disable mc list"); + break; + } +out: + if (op_mc_list_req) + qdf_mem_free(op_mc_list_req); + + return status; +} + +QDF_STATUS pmo_core_disable_mc_addr_filtering_in_fwr( + struct wlan_objmgr_psoc *psoc, + uint8_t vdev_id, + enum pmo_offload_trigger trigger) +{ + QDF_STATUS status; + struct wlan_objmgr_vdev *vdev; + + PMO_ENTER(); + if (!psoc) { + pmo_err("psoc is NULL"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + vdev = wlan_objmgr_get_vdev_by_id_from_psoc(psoc, vdev_id, WLAN_PMO_ID); + if (!vdev) { + pmo_err("vdev is NULL"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + status = pmo_core_mc_addr_flitering_sanity(vdev); + if (status != QDF_STATUS_SUCCESS) + goto dec_ref; + + pmo_info("disable mclist trigger: %d", trigger); + status = pmo_core_handle_disable_mc_list_trigger(vdev, trigger); +dec_ref: + wlan_objmgr_vdev_release_ref(vdev, WLAN_PMO_ID); +out: + PMO_EXIT(); + + return status; +} + diff --git a/power_management_offloads/core/src/wlan_pmo_ns.c b/power_management_offloads/core/src/wlan_pmo_ns.c new file mode 100644 index 000000000000..c15b49268aea --- /dev/null +++ b/power_management_offloads/core/src/wlan_pmo_ns.c @@ -0,0 +1,497 @@ +/* +* 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: Implements ns offload feature API's + */ + +#include "wlan_pmo_ns.h" +#include "wlan_pmo_tgt_api.h" +#include "wlan_pmo_main.h" +#include "wlan_pmo_obj_mgmt_public_struct.h" + +static void pmo_core_fill_ns_addr(struct pmo_ns_offload_params *request, + struct pmo_ns_req *ns_req) +{ + int i; + + for (i = 0; i < ns_req->count; i++) { + /* + * Filling up the request structure + * Filling the selfIPv6Addr with solicited address + * A Solicited-Node multicast address is created by + * taking the last 24 bits of a unicast or anycast + * address and appending them to the prefix + * + * FF02:0000:0000:0000:0000:0001:FFXX:XXXX + * + * here XX is the unicast/anycast bits + */ + request->self_ipv6_addr[i][0] = 0xFF; + request->self_ipv6_addr[i][1] = 0x02; + request->self_ipv6_addr[i][11] = 0x01; + request->self_ipv6_addr[i][12] = 0xFF; + request->self_ipv6_addr[i][13] = + ns_req->ipv6_addr[i][13]; + request->self_ipv6_addr[i][14] = + ns_req->ipv6_addr[i][14]; + request->self_ipv6_addr[i][15] = + ns_req->ipv6_addr[i][15]; + request->slot_idx = i; + qdf_mem_copy(&request->target_ipv6_addr[i], + &ns_req->ipv6_addr[i][0], PMO_MAC_IPV6_ADDR_LEN); + + request->target_ipv6_addr_valid[i] = + PMO_IPV6_ADDR_VALID; + request->target_ipv6_addr_ac_type[i] = + ns_req->ipv6_addr_type[i]; + + pmo_info("NSoffload solicitIp: %pI6 targetIp: %pI6 Index: %d", + &request->self_ipv6_addr[i], + &request->target_ipv6_addr[i], i); + } +} + +static QDF_STATUS pmo_core_cache_ns_in_vdev_priv( + struct pmo_ns_req *ns_req, + struct wlan_objmgr_vdev *vdev) +{ + QDF_STATUS status = QDF_STATUS_SUCCESS; + struct pmo_psoc_priv_obj *psoc_ctx; + struct pmo_vdev_priv_obj *vdev_ctx; + struct pmo_ns_offload_params request; + struct wlan_objmgr_peer *peer; + + PMO_ENTER(); + psoc_ctx = pmo_get_psoc_priv_ctx(ns_req->psoc); + if (!psoc_ctx) { + pmo_err("psoc_ctx is NULL"); + status = QDF_STATUS_E_INVAL; + goto out; + } + + vdev_ctx = pmo_get_vdev_priv_ctx(vdev); + if (!vdev_ctx) { + pmo_err("vdev_ctx is NULL"); + status = QDF_STATUS_E_INVAL; + goto out; + } + + qdf_mem_zero(&request, sizeof(request)); + pmo_core_fill_ns_addr(&request, ns_req); + + request.enable = PMO_OFFLOAD_ENABLE; + qdf_mem_copy(&request.self_macaddr.bytes, + wlan_vdev_mlme_get_macaddr(vdev), + QDF_MAC_ADDR_SIZE); + + /* set number of ns offload address count */ + request.num_ns_offload_count = ns_req->count; + + peer = wlan_vdev_get_bsspeer(vdev); + if (!peer) { + pmo_err("peer is null"); + status = QDF_STATUS_E_INVAL; + goto out; + } + pmo_info("vdev self mac addr: %pM bss peer mac addr: %pM", + wlan_vdev_mlme_get_macaddr(vdev), + wlan_peer_get_macaddr(peer)); + /* get peer and peer mac accdress aka ap mac address */ + qdf_mem_copy(&request.bssid, + wlan_peer_get_macaddr(peer), + QDF_MAC_ADDR_SIZE); + /* cache ns request */ + qdf_spin_lock_bh(&vdev_ctx->pmo_vdev_lock); + qdf_mem_copy(&vdev_ctx->vdev_ns_req, &request, + sizeof(vdev_ctx->vdev_ns_req)); + qdf_spin_unlock_bh(&vdev_ctx->pmo_vdev_lock); +out: + PMO_EXIT(); + + return status; +} + +static QDF_STATUS pmo_core_flush_ns_from_vdev_priv( + struct wlan_objmgr_vdev *vdev) +{ + struct pmo_vdev_priv_obj *vdev_ctx; + QDF_STATUS status = QDF_STATUS_SUCCESS; + + PMO_ENTER(); + vdev_ctx = pmo_get_vdev_priv_ctx(vdev); + if (!vdev_ctx) { + pmo_err("vdev_ctx is NULL"); + status = QDF_STATUS_E_INVAL; + goto out; + } + + /* clear ns request */ + qdf_spin_lock_bh(&vdev_ctx->pmo_vdev_lock); + qdf_mem_zero(&vdev_ctx->vdev_ns_req, sizeof(vdev_ctx->vdev_ns_req)); + vdev_ctx->vdev_ns_req.enable = PMO_OFFLOAD_DISABLE; + qdf_spin_unlock_bh(&vdev_ctx->pmo_vdev_lock); +out: + PMO_EXIT(); + + return status; +} + +static QDF_STATUS pmo_core_do_enable_ns_offload(struct wlan_objmgr_vdev *vdev, + uint8_t vdev_id, enum pmo_offload_trigger trigger) +{ + QDF_STATUS status = QDF_STATUS_SUCCESS; + struct pmo_psoc_priv_obj *psoc_ctx; + struct pmo_vdev_priv_obj *vdev_ctx; + + PMO_ENTER(); + vdev_ctx = pmo_get_vdev_priv_ctx(vdev); + if (!vdev_ctx) { + pmo_err("vdev_ctx is NULL"); + status = QDF_STATUS_E_INVAL; + goto out; + } + + psoc_ctx = vdev_ctx->pmo_psoc_ctx; + if (!psoc_ctx) { + pmo_err("psoc_ctx is NULL"); + status = QDF_STATUS_E_INVAL; + goto out; + } + + switch (trigger) { + case pmo_ipv6_change_notify: + case pmo_ns_offload_dynamic_update: + if (!psoc_ctx->psoc_cfg.active_mode_offload) { + pmo_info("active offload is disabled, skip in mode:%d", + trigger); + status = QDF_STATUS_E_INVAL; + goto out; + } + /* enable arp when active offload is true (ipv6 notifier) */ + status = pmo_tgt_enable_ns_offload_req(vdev, vdev_id); + break; + case pmo_apps_suspend: + if (psoc_ctx->psoc_cfg.active_mode_offload) { + pmo_info("active offload is enabled, skip in mode: %d", + trigger); + status = QDF_STATUS_E_INVAL; + goto out; + } + /* enable arp when active offload is false (apps suspend) */ + status = pmo_tgt_enable_ns_offload_req(vdev, vdev_id); + break; + default: + status = QDF_STATUS_E_INVAL; + pmo_err("invalid pmo trigger"); + break; + } +out: + PMO_EXIT(); + + return status; +} + +static QDF_STATUS pmo_core_do_disable_ns_offload(struct wlan_objmgr_vdev *vdev, + uint8_t vdev_id, enum pmo_offload_trigger trigger) +{ + QDF_STATUS status = QDF_STATUS_SUCCESS; + struct pmo_psoc_priv_obj *psoc_ctx; + struct pmo_vdev_priv_obj *vdev_ctx; + + PMO_ENTER(); + vdev_ctx = pmo_get_vdev_priv_ctx(vdev); + if (!vdev_ctx) { + pmo_err("vdev_ctx is NULL"); + status = QDF_STATUS_E_INVAL; + goto out; + } + + psoc_ctx = vdev_ctx->pmo_psoc_ctx; + if (!psoc_ctx) { + pmo_err("psoc_ctx is NULL"); + status = QDF_STATUS_E_INVAL; + goto out; + } + + switch (trigger) { + case pmo_ipv6_change_notify: + case pmo_ns_offload_dynamic_update: + if (!psoc_ctx->psoc_cfg.active_mode_offload) { + pmo_info("active offload is disabled, skip in mode:%d", + trigger); + status = QDF_STATUS_E_INVAL; + goto out; + } + /* config ns when active offload is enable */ + status = pmo_tgt_disable_ns_offload_req(vdev, vdev_id); + break; + case pmo_apps_resume: + if (psoc_ctx->psoc_cfg.active_mode_offload) { + pmo_info("active offload is enabled, skip in mode: %d", + trigger); + status = QDF_STATUS_E_INVAL; + goto out; + } + /* config arp/ns when active offload is disable */ + status = pmo_tgt_disable_ns_offload_req(vdev, vdev_id); + break; + default: + status = QDF_STATUS_E_INVAL; + pmo_err("invalid pmo trigger"); + break; + } +out: + PMO_EXIT(); + + return status; +} + + +static QDF_STATUS pmo_core_ns_offload_sanity(struct wlan_objmgr_vdev *vdev) +{ + struct pmo_vdev_priv_obj *vdev_ctx; + + vdev_ctx = pmo_get_vdev_priv_ctx(vdev); + if (!vdev_ctx) { + pmo_err("vdev_ctx is NULL"); + return QDF_STATUS_E_INVAL; + } + + if (!vdev_ctx->pmo_psoc_ctx->psoc_cfg.ns_offload_enable_static) { + pmo_info("ns offload statically disable"); + return QDF_STATUS_E_INVAL; + } + + if (!vdev_ctx->pmo_psoc_ctx->psoc_cfg.ns_offload_enable_dynamic) { + pmo_info("ns offload dynamically disable"); + return QDF_STATUS_E_INVAL; + } + + if (!pmo_core_is_vdev_supports_offload(vdev)) { + pmo_info("vdev in invalid opmode for ns offload %d", + pmo_get_vdev_opmode(vdev)); + return QDF_STATUS_E_INVAL; + } + + if (pmo_core_is_vdev_connected(vdev) == false) + return QDF_STATUS_E_INVAL; + + return QDF_STATUS_SUCCESS; +} + +QDF_STATUS pmo_core_cache_ns_offload_req( + struct pmo_ns_req *ns_req) +{ + QDF_STATUS status; + struct wlan_objmgr_vdev *vdev; + + PMO_ENTER(); + if (!ns_req) { + pmo_err("ns is NULL"); + status = QDF_STATUS_E_INVAL; + goto out; + } + + if (!ns_req->psoc) { + pmo_err("psoc is NULL"); + status = QDF_STATUS_E_INVAL; + goto out; + } + vdev = wlan_objmgr_get_vdev_by_id_from_psoc(ns_req->psoc, + ns_req->vdev_id, WLAN_PMO_ID); + if (!vdev) { + pmo_err("vdev is NULL"); + status = QDF_STATUS_E_INVAL; + goto out; + } + + status = pmo_core_ns_offload_sanity(vdev); + if (status != QDF_STATUS_SUCCESS) + goto dec_ref; + + if (ns_req->count == 0) { + pmo_info("skip ns offload caching as ns count is 0"); + status = QDF_STATUS_E_INVAL; + goto dec_ref; + } + + status = pmo_core_cache_ns_in_vdev_priv(ns_req, vdev); +dec_ref: + wlan_objmgr_vdev_release_ref(vdev, WLAN_PMO_ID); +out: + PMO_EXIT(); + + return status; +} + +QDF_STATUS pmo_core_flush_ns_offload_req(struct wlan_objmgr_vdev *vdev) +{ + QDF_STATUS status; + uint8_t vdev_id; + + PMO_ENTER(); + if (!vdev) { + pmo_err("vdev is NULL"); + status = QDF_STATUS_E_INVAL; + goto out; + } + + status = wlan_objmgr_vdev_try_get_ref(vdev, WLAN_PMO_ID); + if (status != QDF_STATUS_SUCCESS) + goto out; + + status = pmo_core_ns_offload_sanity(vdev); + if (status != QDF_STATUS_SUCCESS) + goto dec_ref; + + vdev_id = pmo_get_vdev_id(vdev); + pmo_info("Flush ns offload on vdev id: %d vdev: %p", vdev_id, vdev); + + status = pmo_core_flush_ns_from_vdev_priv(vdev); +dec_ref: + wlan_objmgr_vdev_release_ref(vdev, WLAN_PMO_ID); +out: + PMO_EXIT(); + + return status; +} + +QDF_STATUS pmo_core_enable_ns_offload_in_fwr(struct wlan_objmgr_vdev *vdev, + enum pmo_offload_trigger trigger) +{ + QDF_STATUS status; + struct pmo_vdev_priv_obj *vdev_ctx; + uint8_t vdev_id; + + PMO_ENTER(); + if (!vdev) { + pmo_err("vdev is NULL"); + status = QDF_STATUS_E_INVAL; + goto out; + } + + status = wlan_objmgr_vdev_try_get_ref(vdev, WLAN_PMO_ID); + if (status != QDF_STATUS_SUCCESS) + goto out; + + vdev_ctx = pmo_get_vdev_priv_ctx(vdev); + if (!vdev_ctx) { + pmo_err("vdev_ctx is NULL"); + status = QDF_STATUS_E_INVAL; + goto dec_ref; + } + + status = pmo_core_ns_offload_sanity(vdev); + if (status != QDF_STATUS_SUCCESS) + goto dec_ref; + + if (trigger == pmo_ns_offload_dynamic_update) { + /* + * user disable ns offload using ioctl/vendor cmd dynamically. + */ + vdev_ctx->pmo_psoc_ctx->psoc_cfg.ns_offload_enable_dynamic = + true; + goto skip_ns_dynamic_check; + } + + if (!vdev_ctx->pmo_psoc_ctx->psoc_cfg.ns_offload_enable_dynamic) { + pmo_info("ns offload dynamically disable"); + status = QDF_STATUS_E_INVAL; + goto dec_ref; + } + +skip_ns_dynamic_check: + qdf_spin_lock_bh(&vdev_ctx->pmo_vdev_lock); + if (vdev_ctx->vdev_ns_req.num_ns_offload_count == 0) { + qdf_spin_unlock_bh(&vdev_ctx->pmo_vdev_lock); + pmo_info("skip ns offload enable as ns count is 0"); + status = QDF_STATUS_E_INVAL; + goto out; + } + qdf_spin_unlock_bh(&vdev_ctx->pmo_vdev_lock); + + vdev_id = pmo_get_vdev_id(vdev); + pmo_info("Enable ns offload in fwr vdev id: %d vdev: %p trigger: %d", + vdev_id, vdev, trigger); + status = pmo_core_do_enable_ns_offload(vdev, vdev_id, trigger); +dec_ref: + wlan_objmgr_vdev_release_ref(vdev, WLAN_PMO_ID); +out: + PMO_EXIT(); + + return status; +} + +QDF_STATUS pmo_core_disable_ns_offload_in_fwr(struct wlan_objmgr_vdev *vdev, + enum pmo_offload_trigger trigger) +{ + QDF_STATUS status; + uint8_t vdev_id; + struct pmo_vdev_priv_obj *vdev_ctx; + + PMO_ENTER(); + if (!vdev) { + pmo_err("vdev is NULL"); + status = QDF_STATUS_E_INVAL; + goto out; + } + + status = wlan_objmgr_vdev_try_get_ref(vdev, WLAN_PMO_ID); + if (status != QDF_STATUS_SUCCESS) + goto out; + + vdev_ctx = pmo_get_vdev_priv_ctx(vdev); + if (!vdev_ctx) { + pmo_err("vdev_ctx is NULL"); + status = QDF_STATUS_E_INVAL; + goto dec_ref; + } + + status = pmo_core_ns_offload_sanity(vdev); + if (status != QDF_STATUS_SUCCESS) + goto dec_ref; + + if (trigger == pmo_ns_offload_dynamic_update) { + /* + * user disable ns offload using ioctl/vendor cmd dynamically. + */ + vdev_ctx->pmo_psoc_ctx->psoc_cfg.ns_offload_enable_dynamic = + false; + goto skip_ns_dynamic_check; + } + + if (!vdev_ctx->pmo_psoc_ctx->psoc_cfg.ns_offload_enable_dynamic) { + pmo_info("ns offload dynamically disable"); + status = QDF_STATUS_E_INVAL; + goto dec_ref; + } + +skip_ns_dynamic_check: + vdev_id = pmo_get_vdev_id(vdev); + pmo_info("disable ns offload in fwr vdev id: %d vdev: %p trigger: %d", + vdev_id, vdev, trigger); + + status = pmo_core_do_disable_ns_offload(vdev, vdev_id, trigger); +dec_ref: + wlan_objmgr_vdev_release_ref(vdev, WLAN_PMO_ID); +out: + PMO_EXIT(); + + return status; +} + diff --git a/power_management_offloads/core/src/wlan_pmo_static_config.c b/power_management_offloads/core/src/wlan_pmo_static_config.c new file mode 100644 index 000000000000..62826a576cba --- /dev/null +++ b/power_management_offloads/core/src/wlan_pmo_static_config.c @@ -0,0 +1,437 @@ +/* +* 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: Implements static configuration on vdev attach + */ + +#include "wlan_pmo_static_config.h" +#include "wlan_pmo_tgt_api.h" +#include "wlan_pmo_main.h" +#include "wlan_pmo_wow.h" +#include "wlan_pmo_obj_mgmt_public_struct.h" + +#define PMO_WOW_STA_WAKE_UP_EVENTS ((1 << WOW_CSA_IE_EVENT) |\ + (1 << WOW_CLIENT_KICKOUT_EVENT) |\ + (1 << WOW_PATTERN_MATCH_EVENT) |\ + (1 << WOW_MAGIC_PKT_RECVD_EVENT) |\ + (1 << WOW_DEAUTH_RECVD_EVENT) |\ + (1 << WOW_DISASSOC_RECVD_EVENT) |\ + (1 << WOW_BMISS_EVENT) |\ + (1 << WOW_GTK_ERR_EVENT) |\ + (1 << WOW_BETTER_AP_EVENT) |\ + (1 << WOW_HTT_EVENT) |\ + (1 << WOW_RA_MATCH_EVENT) |\ + (1 << WOW_NLO_DETECTED_EVENT) |\ + (1 << WOW_EXTSCAN_EVENT) |\ + (1 << WOW_OEM_RESPONSE_EVENT)|\ + (1 << WOW_TDLS_CONN_TRACKER_EVENT)) \ + +#define PMO_WOW_SAP_WAKE_UP_EVENTS ((1 << WOW_PROBE_REQ_WPS_IE_EVENT) |\ + (1 << WOW_PATTERN_MATCH_EVENT) |\ + (1 << WOW_AUTH_REQ_EVENT) |\ + (1 << WOW_ASSOC_REQ_EVENT) |\ + (1 << WOW_DEAUTH_RECVD_EVENT) |\ + (1 << WOW_DISASSOC_RECVD_EVENT) |\ + (1 << WOW_HTT_EVENT)) \ + +static const uint8_t arp_ptrn[] = {0x08, 0x06}; +static const uint8_t arp_mask[] = {0xff, 0xff}; +static const uint8_t ns_ptrn[] = {0x86, 0xDD}; +static const uint8_t discvr_ptrn[] = {0xe0, 0x00, 0x00, 0xf8}; +static const uint8_t discvr_mask[] = {0xf0, 0x00, 0x00, 0xf8}; + +void pmo_register_wow_wakeup_events(struct wlan_objmgr_vdev *vdev) +{ + uint32_t event_bitmap; + uint8_t vdev_id; + struct wlan_objmgr_psoc *psoc; + enum tQDF_ADAPTER_MODE vdev_opmode = QDF_MAX_NO_OF_MODE; + + psoc = wlan_vdev_get_psoc(vdev); + if (psoc == NULL) { + pmo_err("psoc is NULL"); + return; + } + + vdev_opmode = pmo_get_vdev_opmode(vdev); + vdev_id = pmo_get_vdev_id(vdev); + pmo_info("vdev_opmode %d vdev_id %d", vdev_opmode, vdev_id); + + switch (vdev_opmode) { + case QDF_STA_MODE: + case QDF_P2P_DEVICE_MODE: + /* Configure STA/P2P CLI mode specific default wake up events */ + event_bitmap = PMO_WOW_STA_WAKE_UP_EVENTS; + pmo_info("STA specific default wake up event 0x%x vdev id %d", + event_bitmap, vdev_id); + break; + case QDF_IBSS_MODE: + /* Configure IBSS mode specific default wake up events */ + event_bitmap = (PMO_WOW_STA_WAKE_UP_EVENTS | + (1 << WOW_BEACON_EVENT)); + pmo_info("IBSS specific default wake up event 0x%x vdev id %d", + event_bitmap, vdev_id); + break; + case QDF_SAP_MODE: + /* Configure SAP/GO mode specific default wake up events */ + event_bitmap = PMO_WOW_SAP_WAKE_UP_EVENTS; + pmo_info("SAP specific default wake up event 0x%x vdev id %d", + event_bitmap, vdev_id); + break; + case QDF_NDI_MODE: + /* + * Configure NAN data path specific default wake up events. + * Following routine sends the command to firmware. + */ +#ifdef WLAN_FEATURE_NAN_DATAPATH + event_bitmap = (1 << WOW_NAN_DATA_EVENT); + pmo_info("NDI specific default wake up event 0x%x vdev id %d", + event_bitmap, vdev_id); +#endif + break; + default: + pmo_info("unknown vdev_opmode %d", vdev_opmode); + return; + } + pmo_tgt_enable_wow_wakeup_event(vdev, event_bitmap); + +} + +/** + * pmo_configure_wow_ap() - set WOW patterns in ap mode + * @vdev: objmgr vdev handle + * + * Configures default WOW pattern for the given vdev_id which is in AP mode. + * + * Return: QDF status + */ +static QDF_STATUS pmo_configure_wow_ap(struct wlan_objmgr_vdev *vdev) +{ + QDF_STATUS ret; + uint8_t arp_offset = 20; + uint8_t mac_mask[PMO_80211_ADDR_LEN]; + struct pmo_vdev_priv_obj *vdev_ctx; + + vdev_ctx = pmo_get_vdev_priv_ctx(vdev); + if (!vdev_ctx) { + pmo_err("vdev_ctx is NULL"); + return QDF_STATUS_E_FAILURE; + } + + /* + * Setup unicast pkt pattern + * WoW pattern id should be unique for each vdev + * WoW pattern id can be same on 2 different VDEVs + */ + qdf_mem_set(&mac_mask, PMO_80211_ADDR_LEN, 0xFF); + ret = pmo_tgt_send_wow_patterns_to_fw(vdev, + pmo_get_and_increment_wow_default_ptrn(vdev_ctx), + wlan_vdev_mlme_get_macaddr(vdev), + PMO_80211_ADDR_LEN, 0, mac_mask, + PMO_80211_ADDR_LEN, false); + if (ret != QDF_STATUS_SUCCESS) { + pmo_err("Failed to add WOW unicast pattern ret %d", ret); + return ret; + } + + /* + * Setup all ARP pkt pattern. This is dummy pattern hence the length + * is zero. Pattern ID should be unique per vdev. + */ + ret = pmo_tgt_send_wow_patterns_to_fw(vdev, + pmo_get_and_increment_wow_default_ptrn(vdev_ctx), + arp_ptrn, 0, arp_offset, arp_mask, 0, false); + if (ret != QDF_STATUS_SUCCESS) + pmo_err("Failed to add WOW ARP pattern ret %d", ret); + + return ret; +} + +/** + * pmo_configure_mc_ssdp() - API to configure SSDP address as MC list + *@vdev: objmgr vdev handle. + * + * SSDP address 239.255.255.250 is converted to Multicast Mac address + * and configure it to FW. Firmware will apply this pattern on the incoming + * packets to filter them out during chatter/wow mode. + * + * Return: Success/Failure + */ +static QDF_STATUS pmo_configure_mc_ssdp( + struct wlan_objmgr_vdev *vdev) +{ + struct wlan_objmgr_psoc *psoc; + const uint8_t ssdp_addr[QDF_MAC_ADDR_SIZE] = { + 0x01, 0x00, 0x5e, 0x7f, 0xff, 0xfa}; + struct qdf_mac_addr multicast_addr; + QDF_STATUS status = QDF_STATUS_SUCCESS; + + psoc = wlan_vdev_get_psoc(vdev); + if (!psoc) { + pmo_err("psoc is NULL"); + return QDF_STATUS_E_INVAL; + } + qdf_mem_copy(&multicast_addr.bytes, &ssdp_addr, QDF_MAC_ADDR_SIZE); + status = pmo_tgt_set_mc_filter_req(vdev, + multicast_addr); + if (status != QDF_STATUS_SUCCESS) + pmo_err("unable to set ssdp as mc addr list filter"); + + return status; +} + +/** + * pmo_configure_wow_ssdp() - API to configure WoW SSDP + *@vdev: objmgr vdev handle + * + * API to configure SSDP pattern as WoW pattern + * + * Return: Success/Failure + */ +static QDF_STATUS pmo_configure_wow_ssdp( + struct wlan_objmgr_vdev *vdev) +{ + QDF_STATUS status = QDF_STATUS_SUCCESS; + uint8_t discvr_offset = 30; + struct pmo_vdev_priv_obj *vdev_ctx; + + vdev_ctx = pmo_get_vdev_priv_ctx(vdev); + if (!vdev_ctx) { + pmo_err("vdev_ctx is NULL"); + return QDF_STATUS_E_INVAL; + } + /* + * WoW pattern ID should be unique for each vdev + * Different WoW patterns can use same pattern ID + */ + status = pmo_tgt_send_wow_patterns_to_fw(vdev, + pmo_get_and_increment_wow_default_ptrn(vdev_ctx), + discvr_ptrn, sizeof(discvr_ptrn), discvr_offset, + discvr_mask, sizeof(discvr_ptrn), false); + + if (status != QDF_STATUS_SUCCESS) + pmo_err("Failed to add WOW mDNS/SSDP/LLMNR pattern"); + + return status; +} + +/** + * pmo_configure_ssdp() - API to Configure SSDP pattern to FW + *@vdev: objmgr vdev handle + * + * Setup multicast pattern for mDNS 224.0.0.251, SSDP 239.255.255.250 and LLMNR + * 224.0.0.252 + * + * Return: Success/Failure. + */ +static QDF_STATUS pmo_configure_ssdp(struct wlan_objmgr_vdev *vdev) +{ + struct pmo_vdev_priv_obj *vdev_ctx; + uint8_t vdev_id; + + vdev_ctx = pmo_get_vdev_priv_ctx(vdev); + if (!vdev_ctx) { + pmo_err("vdev_ctx is NULL"); + return QDF_STATUS_E_INVAL; + } + vdev_id = pmo_get_vdev_id(vdev); + + if (!vdev_ctx->pmo_psoc_ctx->psoc_cfg.ssdp) { + pmo_err("mDNS, SSDP, LLMNR patterns are disabled from ini"); + return QDF_STATUS_SUCCESS; + } + + pmo_debug("enable_mc_list:%d", + vdev_ctx->pmo_psoc_ctx->psoc_cfg.enable_mc_list); + + if (vdev_ctx->pmo_psoc_ctx->psoc_cfg.enable_mc_list) + return pmo_configure_mc_ssdp(vdev); + + return pmo_configure_wow_ssdp(vdev); +} + +/** + * pmo_configure_wow_sta() - set WOW patterns in sta mode + * @vdev: objmgr vdev handle + * + * Configures default WOW pattern for the given vdev_id which is in sta mode. + * + * Return: QDF status + */ +static QDF_STATUS pmo_configure_wow_sta(struct wlan_objmgr_vdev *vdev) +{ + uint8_t arp_offset = 12; + uint8_t mac_mask[PMO_80211_ADDR_LEN]; + QDF_STATUS ret = QDF_STATUS_SUCCESS; + struct pmo_vdev_priv_obj *vdev_ctx; + + vdev_ctx = pmo_get_vdev_priv_ctx(vdev); + if (!vdev_ctx) { + pmo_err("vdev_ctx is NULL"); + return QDF_STATUS_E_INVAL; + } + + qdf_mem_set(&mac_mask, PMO_80211_ADDR_LEN, 0xFF); + /* + * Set up unicast wow pattern + * WoW pattern ID should be unique for each vdev + * Different WoW patterns can use same pattern ID + */ + ret = pmo_tgt_send_wow_patterns_to_fw(vdev, + pmo_get_and_increment_wow_default_ptrn(vdev_ctx), + wlan_vdev_mlme_get_macaddr(vdev), + PMO_80211_ADDR_LEN, 0, mac_mask, + PMO_80211_ADDR_LEN, false); + if (ret != QDF_STATUS_SUCCESS) { + pmo_err("Failed to add WOW unicast pattern ret %d", ret); + return ret; + } + + ret = pmo_configure_ssdp(vdev); + if (ret != QDF_STATUS_SUCCESS) + pmo_err("Failed to configure SSDP patterns to FW"); + + /* + * when arp offload or ns offloaded is disabled + * from ini file, configure broad cast arp pattern + * to fw, so that host can wake up + */ + if (!vdev_ctx->pmo_psoc_ctx->psoc_cfg.arp_offload_enable) { + /* Setup all ARP pkt pattern */ + pmo_info("ARP offload is disabled in INI enable WoW for ARP"); + ret = pmo_tgt_send_wow_patterns_to_fw(vdev, + pmo_get_and_increment_wow_default_ptrn( + vdev_ctx), + arp_ptrn, sizeof(arp_ptrn), arp_offset, + arp_mask, sizeof(arp_mask), false); + if (ret != QDF_STATUS_SUCCESS) { + pmo_err("Failed to add WOW ARP pattern"); + return ret; + } + } + /* for NS or NDP offload packets */ + if (!vdev_ctx->pmo_psoc_ctx->psoc_cfg.ns_offload_enable_static) { + /* Setup all NS pkt pattern */ + pmo_info("NS offload is disabled in INI enable WoW for NS"); + ret = pmo_tgt_send_wow_patterns_to_fw(vdev, + pmo_get_and_increment_wow_default_ptrn( + vdev_ctx), + ns_ptrn, sizeof(arp_ptrn), arp_offset, + arp_mask, sizeof(arp_mask), false); + if (ret != QDF_STATUS_SUCCESS) { + pmo_err("Failed to add WOW NS pattern"); + return ret; + } + } + + return ret; +} + +void pmo_register_wow_default_patterns(struct wlan_objmgr_vdev *vdev) +{ + enum tQDF_ADAPTER_MODE vdev_opmode = QDF_MAX_NO_OF_MODE; + struct pmo_vdev_priv_obj *vdev_ctx; + uint8_t vdev_id; + struct pmo_psoc_priv_obj *psoc_ctx; + + vdev_ctx = pmo_get_vdev_priv_ctx(vdev); + if (!vdev_ctx) { + pmo_err("vdev_ctx is NULL"); + return; + } + + vdev_id = pmo_get_vdev_id(vdev); + if (vdev_id > WLAN_UMAC_PSOC_MAX_VDEVS) { + pmo_err("Invalid vdev id %d", vdev_id); + return; + } + + vdev_opmode = pmo_get_vdev_opmode(vdev); + if (vdev_opmode == QDF_MAX_NO_OF_MODE) { + pmo_err("Invalid vdev opmode %d", vdev_id); + return; + } + + if (!vdev_ctx->ptrn_match_enable) { + pmo_err("ptrn_match is disable for vdev %d", vdev_id); + return; + } + + if (pmo_is_vdev_in_beaconning_mode(vdev_opmode)) { + /* Configure SAP/GO/IBSS mode default wow patterns */ + pmo_info("Config SAP default wow patterns vdev_id %d", + vdev_id); + pmo_configure_wow_ap(vdev); + } else { + /* Configure STA/P2P CLI mode default wow patterns */ + pmo_info("Config STA default wow patterns vdev_id %d", + vdev_id); + pmo_configure_wow_sta(vdev); + psoc_ctx = vdev_ctx->pmo_psoc_ctx; + if (psoc_ctx && psoc_ctx->psoc_cfg.ra_ratelimit_enable) { + pmo_info("Config STA RA wow pattern vdev_id %d", + vdev_id); + pmo_tgt_send_ra_filter_req(vdev); + } + } + +} + +void pmo_register_action_frame_patterns( + struct wlan_objmgr_vdev *vdev) +{ + + struct pmo_action_wakeup_set_params cmd = {0}; + int i = 0; + uint8_t vdev_id; + QDF_STATUS status; + + vdev_id = pmo_get_vdev_id(vdev); + if (vdev_id > WLAN_UMAC_PSOC_MAX_VDEVS) { + pmo_err("Invalid vdev id %d", vdev_id); + return; + } + + cmd.vdev_id = vdev_id; + cmd.operation = pmo_action_wakeup_set; + + cmd.action_category_map[i++] = ALLOWED_ACTION_FRAMES_BITMAP0; + cmd.action_category_map[i++] = ALLOWED_ACTION_FRAMES_BITMAP1; + cmd.action_category_map[i++] = ALLOWED_ACTION_FRAMES_BITMAP2; + cmd.action_category_map[i++] = ALLOWED_ACTION_FRAMES_BITMAP3; + cmd.action_category_map[i++] = ALLOWED_ACTION_FRAMES_BITMAP4; + cmd.action_category_map[i++] = ALLOWED_ACTION_FRAMES_BITMAP5; + cmd.action_category_map[i++] = ALLOWED_ACTION_FRAMES_BITMAP6; + cmd.action_category_map[i++] = ALLOWED_ACTION_FRAMES_BITMAP7; + + for (i = 0; i < PMO_SUPPORTED_ACTION_CATE_ELE_LIST; i++) { + if (i < ALLOWED_ACTION_FRAME_MAP_WORDS) + pmo_debug("%s: %d action Wakeup pattern 0x%x in fw", + __func__, i, cmd.action_category_map[i]); + else + cmd.action_category_map[i] = 0; + } + + /* config action frame patterns */ + status = pmo_tgt_send_action_frame_pattern_req(vdev, &cmd); + if (status != QDF_STATUS_SUCCESS) + pmo_err("Failed to config wow action frame map, ret %d", + status); + +} + diff --git a/power_management_offloads/core/src/wlan_pmo_wow.c b/power_management_offloads/core/src/wlan_pmo_wow.c new file mode 100644 index 000000000000..951c4816b807 --- /dev/null +++ b/power_management_offloads/core/src/wlan_pmo_wow.c @@ -0,0 +1,113 @@ +/* +* 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: Define API's for wow pattern addition and deletion in fwr + */ + +#include "wlan_pmo_wow.h" +#include "wlan_pmo_tgt_api.h" +#include "wlan_pmo_main.h" +#include "wlan_pmo_obj_mgmt_public_struct.h" + +static inline int pmo_find_wow_ptrn_len(const char *ptrn) +{ + int len = 0; + + while (*ptrn != '\0' && *ptrn != PMO_WOW_INTER_PTRN_TOKENIZER) { + len++; + ptrn++; + } + + return len; +} + +QDF_STATUS pmo_core_add_wow_pattern(struct wlan_objmgr_vdev *vdev, + const char *ptrn) +{ + return QDF_STATUS_SUCCESS; +} + +QDF_STATUS pmo_core_del_wow_pattern(struct wlan_objmgr_vdev *vdev, + const char *ptrn) +{ + return QDF_STATUS_SUCCESS; +} + +QDF_STATUS pmo_core_wow_enter(struct wlan_objmgr_vdev *vdev, + struct pmo_wow_enter_params *wow_enter_param) +{ + return QDF_STATUS_SUCCESS; +} + +QDF_STATUS pmo_core_wow_exit(struct wlan_objmgr_vdev *vdev) +{ + return QDF_STATUS_SUCCESS; +} + +void pmo_core_enable_wakeup_event(struct wlan_objmgr_psoc *psoc, + uint32_t vdev_id, uint32_t bitmap) +{ + struct wlan_objmgr_vdev *vdev; + + PMO_ENTER(); + if (!psoc) { + pmo_err("psoc is null"); + goto out; + } + + vdev = wlan_objmgr_get_vdev_by_id_from_psoc(psoc, vdev_id, WLAN_PMO_ID); + if (!vdev) { + pmo_err("vdev is NULL"); + goto out; + } + + pmo_info("enable wakeup event vdev_id %d wake up event 0x%x", + vdev_id, bitmap); + pmo_tgt_enable_wow_wakeup_event(vdev, bitmap); + wlan_objmgr_vdev_release_ref(vdev, WLAN_PMO_ID); +out: + PMO_EXIT(); + +} + +void pmo_core_disable_wakeup_event(struct wlan_objmgr_psoc *psoc, + uint32_t vdev_id, uint32_t bitmap) +{ + struct wlan_objmgr_vdev *vdev; + + PMO_ENTER(); + if (!psoc) { + pmo_err("psoc is null"); + goto out; + } + + vdev = wlan_objmgr_get_vdev_by_id_from_psoc(psoc, vdev_id, WLAN_PMO_ID); + if (!vdev) { + pmo_err("vdev is NULL"); + goto out; + } + + pmo_info("Disable wakeup eventvdev_id %d wake up event 0x%x", + vdev_id, bitmap); + pmo_tgt_disable_wow_wakeup_event(vdev, bitmap); + wlan_objmgr_vdev_release_ref(vdev, WLAN_PMO_ID); +out: + PMO_EXIT(); + +} + diff --git a/power_management_offloads/dispatcher/inc/wlan_pmo_arp_public_struct.h b/power_management_offloads/dispatcher/inc/wlan_pmo_arp_public_struct.h new file mode 100644 index 000000000000..533b80998632 --- /dev/null +++ b/power_management_offloads/dispatcher/inc/wlan_pmo_arp_public_struct.h @@ -0,0 +1,58 @@ +/* +* 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: Declare various struct, macros which shall be used in + * pmo arp offload feature. + * + * Note: This file shall not contain public API's prototype/declarations. + * + */ + +#ifndef _WLAN_PMO_ARP_PUBLIC_STRUCT_H_ +#define _WLAN_PMO_ARP_PUBLIC_STRUCT_H_ + +#include "wlan_pmo_common_public_struct.h" + +/** + * struct pmo_arp_req - pmo arp request + * @psoc: objmgr psoc + * @vdev_id: vdev id on which arp offload needed + * @ipv4_addr: ipv4 address for the interface + * @trigger: context from where arp offload triggered + */ +struct pmo_arp_req { + struct wlan_objmgr_psoc *psoc; + uint8_t vdev_id; + uint32_t ipv4_addr; + enum pmo_offload_trigger trigger; +}; + +/** + * struct pmo_arp_req - pmo arp offload param for target interface + * @enable: true when arp offload is enabled else false + * @host_ipv4_addr: host interface ipv4 address + * @bssid: peer ap address + */ +struct pmo_arp_offload_params { + uint8_t enable; + uint8_t host_ipv4_addr[PMO_IPV4_ADDR_LEN]; + struct qdf_mac_addr bssid; +}; + +#endif /* end of _WLAN_PMO_ARP_PUBLIC_STRUCT_H_ */ + diff --git a/power_management_offloads/dispatcher/inc/wlan_pmo_common_public_struct.h b/power_management_offloads/dispatcher/inc/wlan_pmo_common_public_struct.h new file mode 100644 index 000000000000..90bc1b4fd7f1 --- /dev/null +++ b/power_management_offloads/dispatcher/inc/wlan_pmo_common_public_struct.h @@ -0,0 +1,148 @@ +/* +* 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: Declare various struct, macros which are common for + * various pmo related features. + * + * Note: This file shall not contain public API's prototype/declartions. + * + */ + +#ifndef _WLAN_PMO_COMMONP_PUBLIC_STRUCT_H_ +#define _WLAN_PMO_COMMONP_PUBLIC_STRUCT_H_ + +#include "wlan_cmn.h" +#include "wlan_objmgr_cmn.h" +#include "wlan_objmgr_global_obj.h" +#include "wlan_objmgr_psoc_obj.h" +#include "wlan_objmgr_pdev_obj.h" +#include "wlan_objmgr_vdev_obj.h" +#include "wlan_objmgr_peer_obj.h" +#include "wmi_unified.h" +#include "qdf_status.h" +#include "qdf_lock.h" + +#define PMO_IPV4_ADDR_LEN 4 + +#define PMO_IPV4_ARP_REPLY_OFFLOAD 0 +#define PMO_IPV6_NEIGHBOR_DISCOVERY_OFFLOAD 1 +#define PMO_IPV6_NS_OFFLOAD 2 +#define PMO_OFFLOAD_DISABLE 0 +#define PMO_OFFLOAD_ENABLE 1 + +#define PMO_MAC_NS_OFFLOAD_SIZE 1 +#define PMO_MAC_NUM_TARGET_IPV6_NS_OFFLOAD_NA 16 +#define PMO_MAC_IPV6_ADDR_LEN 16 +#define PMO_IPV6_ADDR_VALID 1 +#define PMO_IPV6_ADDR_UC_TYPE 0 +#define PMO_IPV6_ADDR_AC_TYPE 1 + +#define PMO_80211_ADDR_LEN 6 /* size of 802.11 address */ +/** + * enum pmo_offload_type: tell offload type + * @pmo_arp_offload: arp offload + * @pmo_ns_offload: ns offload + * @pmo_gtk_offload: gtk offload + */ +enum pmo_offload_type { + pmo_arp_offload = 0, + pmo_ns_offload, + pmo_gtk_offload, +}; + +/** + * typedef for psoc suspend handler + */ +typedef QDF_STATUS(*pmo_psoc_suspend_handler) + (struct wlan_objmgr_psoc *psoc, void *arg); +/** + * typedef for psoc resume handler + */ +typedef QDF_STATUS(*pmo_psoc_resume_handler) + (struct wlan_objmgr_psoc *psoc, void *arg); + +/** + * enum pmo_offload_trigger: trigger information + * @pmo_apps_suspend: trigger is apps suspend + * @pmo_apps_resume: trigger is apps resume + * @pmo_runtime_suspend: trigger is runtime suspend + * @pmo_runtime_resume: trigger is runtime resume + * @pmo_ipv4_change_notify: trigger is ipv4 change handler + * @pmo_ipv6_change_notify: trigger is ipv6 change handler + * @pmo_ns_offload_dynamic_update: enable/disable ns offload on the fly + * @pmo_peer_disconnect: trigger is peer disconnect + * @pmo_mcbc_setting_dynamic_update: mcbc value update on the fly + * + * @pmo_offload_trigger_max: Max trigger value + */ +enum pmo_offload_trigger { + pmo_apps_suspend = 0, + pmo_apps_resume, + pmo_runtime_suspend, + pmo_runtime_resume, + pmo_ipv4_change_notify, + pmo_ipv6_change_notify, + pmo_mc_list_change_notify, + pmo_ns_offload_dynamic_update, + pmo_peer_disconnect, + pmo_mcbc_setting_dynamic_update, + + pmo_offload_trigger_max, +}; + +/** + * struct pmo_psoc_cfg - user configuration required for pmo + * @ptrn_match_enable_all_vdev: true when pattern match is enable for all vdev + * @bpf_enable: true if psoc supports bpf else false + * @arp_offload_enable: true if arp offload is supported for psoc else false + * @ns_offload_enable_static: true if psoc supports ns offload in ini else false + * @ns_offload_enable_dynamic: to enable / disable the ns offload using + * ioctl or vendor command. + * @ssdp: true if psoc supports if ssdp configuration in wow mode + * @enable_mc_list: true if psoc supports mc addr list else false + * @active_mode_offload: true if psoc supports active mode offload else false + * @ap_arpns_support: true if psoc supports arp ns for ap mode + * @max_wow_filters: maximum number of wow filter supported + * @ra_ratelimit_enable: true when ra filtering ins eanbled else false + * @ra_ratelimit_interval: ra packets interval + * @magic_ptrn_enable: true when magic pattern is enabled else false + * @deauth_enable: true when wake up on deauth is enabled else false + * @disassoc_enable: true when wake up on disassoc is enabled else false + * @bmiss_enable: true when wake up on bmiss is enabled else false + */ +struct pmo_psoc_cfg { + bool ptrn_match_enable_all_vdev; + bool bpf_enable; + bool arp_offload_enable; + bool ns_offload_enable_static; + bool ns_offload_enable_dynamic; + bool ssdp; + bool enable_mc_list; + bool active_mode_offload; + bool ap_arpns_support; + uint8_t max_wow_filters; + bool ra_ratelimit_enable; + uint16_t ra_ratelimit_interval; + bool magic_ptrn_enable; + bool deauth_enable; + bool disassoc_enable; + bool bmiss_enable; +}; + +#endif /* end of _WLAN_PMO_COMMONP_STRUCT_H_ */ + diff --git a/power_management_offloads/dispatcher/inc/wlan_pmo_gtk_public_struct.h b/power_management_offloads/dispatcher/inc/wlan_pmo_gtk_public_struct.h new file mode 100644 index 000000000000..8c27cc0ab276 --- /dev/null +++ b/power_management_offloads/dispatcher/inc/wlan_pmo_gtk_public_struct.h @@ -0,0 +1,95 @@ +/* +* 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: Declare various struct, macros which shall be used in + * pmo gtk related feature. + * + * Note: This file shall not contain public API's prototype/declarations. + * + */ + +#ifndef _WLAN_PMO_GTK_PUBLIC_STRUCT_H +#define _WLAN_PMO_GTK_PUBLIC_STRUCT_H + +#include "wlan_pmo_common_public_struct.h" + +#define PMO_GTK_OFFLOAD_ENABLE 0 +#define PMO_GTK_OFFLOAD_DISABLE 1 +#define PMO_KEK_LEN 16 +#define PMO_KCK_LEN 16 +#define PMO_REPLAY_COUNTER_LEN 8 +#define PMO_MAC_MAX_KEY_LENGTH 32 +#define PMO_IGTK_PN_SIZE 6 + +/** + * struct pmo_gtk_req - pmo gtk request + * @flags: optional flags + * @kck: Key confirmation key + * @kek: key encryption key + * @replay_counter: replay_counter + * @bssid: bssid + */ +struct pmo_gtk_req { + uint32_t flags; + uint8_t kck[PMO_KCK_LEN]; + uint8_t kek[PMO_KEK_LEN]; + uint64_t replay_counter; + struct qdf_mac_addr bssid; +}; + +/** + * struct pmo_gtk_rsp_params - pmo gtk response + * @psoc: objmgr psoc + * @vdev_id: vdev id on which arp offload needed + * @status_flag: status flags + * @refresh_cnt: number of successful GTK refresh exchanges since SET operation + * @igtk_key_index: igtk key index + * @igtk_key_length: igtk key length + * @igtk_key_rsc: igtk key index + * @igtk_key: igtk key length + */ +struct pmo_gtk_rsp_params { + uint8_t vdev_id; + uint32_t status_flag; + uint32_t refresh_cnt; + uint64_t replay_counter; + uint8_t igtk_key_index; + uint8_t igtk_key_length; + uint8_t igtk_key_rsc[PMO_IGTK_PN_SIZE]; + uint8_t igtk_key[PMO_MAC_MAX_KEY_LENGTH]; + struct qdf_mac_addr bssid; +}; + +/** + * typedef for gtk response callback + */ +typedef void (*pmo_gtk_rsp_callback)(void *callback_context, + struct pmo_gtk_rsp_params *gtk_rsp); + +/** + * struct pmo_gtk_rsp_req -gtk respsonse request + * @callback: client callback for providing gtk resposne when fwr send event + * @callback_context: client callback response + */ +struct pmo_gtk_rsp_req { + pmo_gtk_rsp_callback callback; + void *callback_context; +}; + +#endif /* end of _WLAN_PMO_GTK_PUBLIC_STRUCT_H */ + diff --git a/power_management_offloads/dispatcher/inc/wlan_pmo_mc_addr_filtering_public_struct.h b/power_management_offloads/dispatcher/inc/wlan_pmo_mc_addr_filtering_public_struct.h new file mode 100644 index 000000000000..8607c171319c --- /dev/null +++ b/power_management_offloads/dispatcher/inc/wlan_pmo_mc_addr_filtering_public_struct.h @@ -0,0 +1,60 @@ +/* +* 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: Declare various struct, macros which shall be used in + * pmo mc address filterign related features. + * + * Note: This file shall not contain public API's prototype/declarations. + * + */ + + +#ifndef _WLAN_PMO_MC_ADDR_FILTERING_STRUCT_H_ +#define _WLAN_PMO_MC_ADDR_FILTERING_STRUCT_H_ + +#include "wlan_pmo_common_public_struct.h" + +#define PMO_MAX_MC_ADDR_LIST 32 + +/** + * struct pmo_mc_addr_list_params -pmo mc address list request params + * @psoc: objmgr psoc + * @vdev_id: vdev id on which arp offload needed + * @count: multicast address count + * @mc_addr: multicast address array + */ +struct pmo_mc_addr_list_params { + struct wlan_objmgr_psoc *psoc; + uint8_t vdev_id; + uint8_t count; + struct qdf_mac_addr mc_addr[PMO_MAX_MC_ADDR_LIST]; +}; + +/** + * struct pmo_mc_addr_list -pmo mc address list params for vdev + * @is_filter_applied: is mc list filter applied on vdev + * @mc_cnt: mc address count + * @mc_addr:mc address list + */ +struct pmo_mc_addr_list { + uint8_t is_filter_applied; + uint8_t mc_cnt; + struct qdf_mac_addr mc_addr[PMO_MAX_MC_ADDR_LIST]; +}; + +#endif /* end of _WLAN_PMO_MC_ADDR_FILTERING_STRUCT_H_ */ diff --git a/power_management_offloads/dispatcher/inc/wlan_pmo_ns_public_struct.h b/power_management_offloads/dispatcher/inc/wlan_pmo_ns_public_struct.h new file mode 100644 index 000000000000..27a0c0499fed --- /dev/null +++ b/power_management_offloads/dispatcher/inc/wlan_pmo_ns_public_struct.h @@ -0,0 +1,79 @@ +/* +* 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: Declare various struct, macros which shall be used in + * pmo ns offload feature. + * + * Note: This file shall not contain public API's prototype/declarations. + * + */ + + +#ifndef _WLAN_PMO_NS_PUBLIC_STRUCT_H_ +#define _WLAN_PMO_NS_PUBLIC_STRUCT_H_ + +#include "wlan_pmo_common_public_struct.h" + +/** + * struct pmo_ns_offload_params - pmo ns offload parameters + * @enable: true when ns offload enable + * @num_ns_offload_count: total ns entries + * @src_ipv6_addr: in request source ipv 6 address + * @self_ipv6_addr: self ipv6 address + * @target_ipv6_addr: target ipv6 address + * @self_macaddr: self mac address + * @src_ipv6_addr_valid: true if source ipv6 address is valid else false + * @target_ipv6_addr_valid: target ipv6 address are valid or not + * @target_ipv6_addr_ac_type: target ipv6 address type (unicast or anycast) + * @slot_idx: slot index + */ +struct pmo_ns_offload_params { + uint8_t enable; + uint32_t num_ns_offload_count; + uint8_t src_ipv6_addr[PMO_MAC_IPV6_ADDR_LEN]; + uint8_t self_ipv6_addr[PMO_MAC_NUM_TARGET_IPV6_NS_OFFLOAD_NA] + [PMO_MAC_IPV6_ADDR_LEN]; + uint8_t target_ipv6_addr[PMO_MAC_NUM_TARGET_IPV6_NS_OFFLOAD_NA] + [PMO_MAC_IPV6_ADDR_LEN]; + struct qdf_mac_addr self_macaddr; + uint8_t src_ipv6_addr_valid; + uint8_t target_ipv6_addr_valid[PMO_MAC_NUM_TARGET_IPV6_NS_OFFLOAD_NA]; + uint8_t target_ipv6_addr_ac_type[PMO_MAC_NUM_TARGET_IPV6_NS_OFFLOAD_NA]; + uint8_t slot_idx; + struct qdf_mac_addr bssid; +}; + +/** + * struct pmo_ns_req - pmo ns request + * @psoc: objmgr psoc + * @vdev_id: vdev id on which arp offload needed + * @trigger: context from where arp offload triggered + * @count: ns entries count + * @ipv6_addr: ipv6 address array + * @ipv6_addr_type: ipv6 address type (unicast/anycast) array + */ +struct pmo_ns_req { + struct wlan_objmgr_psoc *psoc; + uint8_t vdev_id; + enum pmo_offload_trigger trigger; + uint32_t count; + uint8_t ipv6_addr[PMO_MAC_NUM_TARGET_IPV6_NS_OFFLOAD_NA] + [PMO_MAC_IPV6_ADDR_LEN]; + uint8_t ipv6_addr_type[PMO_MAC_NUM_TARGET_IPV6_NS_OFFLOAD_NA]; +}; +#endif /* end of _WLAN_PMO_NS_PUBLIC_STRUCT_H_ */ diff --git a/power_management_offloads/dispatcher/inc/wlan_pmo_obj_mgmt_api.h b/power_management_offloads/dispatcher/inc/wlan_pmo_obj_mgmt_api.h new file mode 100644 index 000000000000..2b6650b9c61d --- /dev/null +++ b/power_management_offloads/dispatcher/inc/wlan_pmo_obj_mgmt_api.h @@ -0,0 +1,141 @@ +/* +* 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: declare utility API related to the pmo component + * called by other components + */ + +#ifndef _WLAN_PMO_OBJ_MGMT_API_H_ +#define _WLAN_PMO_OBJ_MGMT_API_H_ + +#include "wlan_pmo_common_public_struct.h" +#include "wlan_pmo_obj_mgmt_public_struct.h" + +/** + * pmo_init() - initialize pmo_ctx context. + * + * This function initializes the power manager offloads (a.k.a pmo) context. + * + * Return: QDF_STATUS_SUCCESS - in case of success else return error + */ +QDF_STATUS pmo_init(void); + +/** + * pmo_deinit() - De initialize pmo_ctx context. + * + * This function De initializes power manager offloads (a.k.a pmo) contex. + * + * Return: QDF_STATUS_SUCCESS - in case of success else return error + */ +QDF_STATUS pmo_deinit(void); + +/** + * pmo_psoc_object_created_notification(): pmo psoc create handler + * @psoc: psoc which is going to created by objmgr + * @arg: argument for vdev create handler + * + * PMO, register this api with objmgr to detect psoc is created in fwr + * + * Return QDF_STATUS status in case of success else return error + */ +QDF_STATUS pmo_psoc_object_created_notification( + struct wlan_objmgr_psoc *psoc, void *arg); + +/** + * pmo_psoc_object_destroyed_notification(): pmo psoc delete handler + * @psco: psoc which is going to delete by objmgr + * @arg: argument for vdev delete handler + * + * PMO, register this api with objmgr to detect psoc is deleted in fwr + * + * Return QDF_STATUS status in case of success else return error + */ +QDF_STATUS pmo_psoc_object_destroyed_notification( + struct wlan_objmgr_psoc *psoc, void *arg); + +/** + * pmo_vdev_object_created_notification(): pmo vdev create handler + * @vdev: vdev which is going to created by objmgr + * @arg: argument for vdev create handler + * + * PMO, register this api with objmgr to detect vdev is created in fwr + * + * Return QDF_STATUS status in case of success else return error + */ +QDF_STATUS pmo_vdev_object_created_notification( + struct wlan_objmgr_vdev *vdev, void *arg); + +/** + * pmo_vdev_object_destroyed_notification(): pmo vdev delete handler + * @vdev: vdev which is going to delete by objmgr + * @arg: argument for vdev delete handler + * + * PMO, register this api with objmgr to detect vdev is deleted in fwr + * + * Return QDF_STATUS status in case of success else return error + */ +QDF_STATUS pmo_vdev_object_destroyed_notification( + struct wlan_objmgr_vdev *vdev, void *arg); + +/** + * pmo_register_suspend_handler(): register suspend handler for components + * @id: component id + * @handler: resume handler for the mention component + * @arg: argument to pass while calling resume handler + * + * Return QDF_STATUS status -in case of success else return error + */ +QDF_STATUS pmo_register_suspend_handler( + enum wlan_umac_comp_id id, + pmo_psoc_suspend_handler handler, + void *arg); + +/** + * pmo_register_resume_handler(): API to register resume handler for components + * @id: component id + * @handler: resume handler for the mention component + * @arg: argument to pass while calling resume handler + * + * Return QDF_STATUS status - in case of success else return error + */ +QDF_STATUS pmo_register_resume_handler( + enum wlan_umac_comp_id id, + pmo_psoc_resume_handler handler, + void *arg); + +/** + * pmo_suspend_psoc(): API to suspend psoc + * @psoc:objmgr psoc + * @is_runtime_suspend: true for run time suspend else false + * + * Return QDF_STATUS status - in case of success else return error + */ +QDF_STATUS pmo_suspend_psoc(struct wlan_objmgr_psoc *psoc, + bool is_runtime_suspend); + +/** + * pmo_resume_psoc(): API to resume psoc + * @psoc:objmgr psoc + * @is_runtime_resume: true for run time resume else false + * + * Return QDF_STATUS status - in case of success else return error + */ +QDF_STATUS pmo_resume_psoc(struct wlan_objmgr_psoc *psoc, + bool is_runtime_resume); + +#endif /* end of _WLAN_PMO_OBJ_MGMT_API_H_ */ diff --git a/power_management_offloads/dispatcher/inc/wlan_pmo_obj_mgmt_public_struct.h b/power_management_offloads/dispatcher/inc/wlan_pmo_obj_mgmt_public_struct.h new file mode 100644 index 000000000000..1777818cf8be --- /dev/null +++ b/power_management_offloads/dispatcher/inc/wlan_pmo_obj_mgmt_public_struct.h @@ -0,0 +1,103 @@ +/* +* 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: Declare various struct, macros which are used for object mgmt in pmo. + * + * Note: This file shall not contain public API's prototype/declarations. + * + */ + + +#ifndef _WLAN_PMO_OBJ_MGMT_PUBLIC_STRUCT_H_ +#define _WLAN_PMO_OBJ_MGMT_PUBLIC_STRUCT_H_ + +#include "wlan_pmo_common_public_struct.h" +#include "wlan_pmo_arp_public_struct.h" +#include "wlan_pmo_ns_public_struct.h" +#include "wlan_pmo_gtk_public_struct.h" +#include "wlan_pmo_wow_public_struct.h" +#include "wlan_pmo_mc_addr_filtering_public_struct.h" + +/** + * struct pmo_psoc_priv_obj - psoc related data require for pmo + * @wow: place holder for psoc wow configuration + * @ps_config: place holder for psoc power configuration + * @psoc_cfg: place holder for psoc configuration + * @wow: true wow configuration + * @lphb_cache: lphb cache + * @lock: spin lock for pmo psoc + */ +struct pmo_psoc_priv_obj { + struct pmo_psoc_cfg psoc_cfg; + struct pmo_wow wow; + qdf_spinlock_t lock; +}; + +/** + * struct wlan_pmo_ctx -offload mgr context + * @psoc_context: psoc context + * @pmo_suspend_handler: suspend handler table for all componenets + * @pmo_suspend_handler_arg: suspend handler argument sfor all componenets + * @pmo_resume_handler: resume handler table for all componenets + * @pmo_resume_handler_arg: resume handler argument for all componenets + * @lock: lock for global pmo ctx + */ +struct wlan_pmo_ctx { + pmo_psoc_suspend_handler + pmo_suspend_handler[WLAN_UMAC_MAX_COMPONENTS]; + void *pmo_suspend_handler_arg[WLAN_UMAC_MAX_COMPONENTS]; + pmo_psoc_resume_handler + pmo_resume_handler[WLAN_UMAC_MAX_COMPONENTS]; + void *pmo_resume_handler_arg[WLAN_UMAC_MAX_COMPONENTS]; + qdf_spinlock_t lock; +}; + +/** + * struct pmo_vdev_priv_obj -vdev specific user configuration required for pmo + * @pmo_psoc_ctx: pmo psoc ctx + * @vdev_arp_req: place holder for arp request for vdev + * @vdev_ns_req: place holder for ns request for vdev + * @vdev_mc_list_req: place holder for mc addr list for vdev + * @addr_filter_pattern: addr filter pattern for vdev + * @vdev_gtk_params: place holder for gtk request for vdev + * @gtk_err_enable: gtk error is enabled or not + * @vdev_bpf_req: place holder for apf/bpf for vdev + * @vdev_pkt_filter: place holder for vdev packet filter + * @dtim_period: dtim period + * @ptrn_match_enable: true when pattern match is enabled else false + * @num_wow_default_patterns: number of wow default patterns for vdev + * @num_wow_user_patterns: number of user wow patterns for vdev + * @pmo_vdev_lock: spin lock for pmo vdev priv ctx + */ +struct pmo_vdev_priv_obj { + struct pmo_psoc_priv_obj *pmo_psoc_ctx; + struct pmo_arp_offload_params vdev_arp_req; + struct pmo_ns_offload_params vdev_ns_req; + struct pmo_mc_addr_list vdev_mc_list_req; + uint8_t addr_filter_pattern; + struct pmo_gtk_req vdev_gtk_req; + struct pmo_gtk_rsp_req vdev_gtk_rsp_req; + qdf_atomic_t gtk_err_enable; + uint8_t dtim_period; + bool ptrn_match_enable; + uint8_t num_wow_default_patterns; + uint8_t num_wow_user_patterns; + qdf_spinlock_t pmo_vdev_lock; +}; + +#endif /* end of _WLAN_PMO_OBJ_MGMT_PUBLIC_STRUCT_H_ */ diff --git a/power_management_offloads/dispatcher/inc/wlan_pmo_tgt_api.h b/power_management_offloads/dispatcher/inc/wlan_pmo_tgt_api.h new file mode 100644 index 000000000000..0e87ef6eefd7 --- /dev/null +++ b/power_management_offloads/dispatcher/inc/wlan_pmo_tgt_api.h @@ -0,0 +1,187 @@ +/* +* 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: Declare public API for pmo to interact with target/WMI + */ + +#ifndef _WLAN_PMO_TGT_API_H_ +#define _WLAN_PMO_TGT_API_H_ + +#include "wlan_pmo_main.h" + +#define GET_PMO_TX_OPS_FROM_PSOC(psoc) (psoc->soc_cb.tx_ops.pmo_tx_ops) + +/** + * pmo_tgt_enable_arp_offload_req() - Enable arp offload req to target + * @vdev: objmgr vdev + * @vdev_id: vdev id + * + * Return: QDF status + */ +QDF_STATUS pmo_tgt_enable_arp_offload_req(struct wlan_objmgr_vdev *vdev, + uint8_t vdev_id); + +/** + * pmo_tgt_disable_arp_offload_req() - Disable arp offload req to target + * @vdev: objmgr vdev + * @vdev_id: vdev id + * + * Return: QDF status + */ +QDF_STATUS pmo_tgt_disable_arp_offload_req(struct wlan_objmgr_vdev *vdev, + uint8_t vdev_id); + +/** + * pmo_tgt_enable_ns_offload_req() - Send ns offload req to targe + * @vdev: objmgr vdev + * @vdev_id: vdev id + * + * Return: QDF status + */ +QDF_STATUS pmo_tgt_enable_ns_offload_req(struct wlan_objmgr_vdev *vdev, + uint8_t vdev_id); + +/** + * pmo_tgt_disable_ns_offload_req() - Disable arp offload req to target + * @vdev: objmgr vdev + * @vdev_id: vdev id + * + * Return: QDF status + */ +QDF_STATUS pmo_tgt_disable_ns_offload_req(struct wlan_objmgr_vdev *vdev, + uint8_t vdev_id); + +/** + * pmo_tgt_enable_wow_wakeup_event() - Send Enable wow wakeup events req to fwr + * @vdev: objmgr vdev handle + * @bitmap: Event bitmap + * + * Return: QDF status + */ +QDF_STATUS pmo_tgt_enable_wow_wakeup_event(struct wlan_objmgr_vdev *vdev, + uint32_t bitmap); + +/** + * pmo_tgt_disable_wow_wakeup_event() - Send Disable wow wakeup events to fwr + * @vdev: objmgr vdev handle + * @bitmap: Event bitmap + * + * Return: QDF status + */ +QDF_STATUS pmo_tgt_disable_wow_wakeup_event(struct wlan_objmgr_vdev *vdev, + uint32_t bitmap); + +/** + * pmo_tgt_send_wow_patterns_to_fw() - Sends WOW patterns to FW. + * @vdev: objmgr vdev + * @ptrn_id: pattern id + * @ptrn: pattern + * @ptrn_len: pattern length + * @ptrn_offset: pattern offset + * @mask: mask + * @mask_len: mask length + * @user: true for user configured pattern and false for default pattern + * + * Return: QDF status + */ +QDF_STATUS pmo_tgt_send_wow_patterns_to_fw(struct wlan_objmgr_vdev *vdev, + uint8_t ptrn_id, const uint8_t *ptrn, uint8_t ptrn_len, + uint8_t ptrn_offset, const uint8_t *mask, + uint8_t mask_len, bool user); + +/** + * pmo_tgt_set_mc_filter_req() - Set mcast filter command to fw + * @vdev: objmgr vdev + * @multicastAddr: mcast address + * + * Return: QDF_STATUS_SUCCESS for success or error code + */ +QDF_STATUS pmo_tgt_set_mc_filter_req(struct wlan_objmgr_vdev *vdev, + struct qdf_mac_addr multicast_addr); + +/** + * pmo_tgt_clear_mc_filter_req() - Clear mcast filter command to fw + * @vdev: objmgr vdev + * @multicastAddr: mcast address + * + * Return: QDF_STATUS_SUCCESS for success or error code + */ +QDF_STATUS pmo_tgt_clear_mc_filter_req(struct wlan_objmgr_vdev *vdev, + struct qdf_mac_addr multicast_addr); + +/** + * pmo_tgt_send_enhance_multicast_offload_req() - send enhance mc offload req + * @wma_handle: wma handle + * @vdev_id: vdev id + * @action: enable or disable enhance multicast offload + * + * Return: QDF_STATUS_SUCCESS on success else error code + */ +QDF_STATUS pmo_tgt_send_enhance_multicast_offload_req( + struct wlan_objmgr_vdev *vdev, + uint8_t vdev_id, + uint8_t action); + +/** + * pmo_tgt_send_ra_filter_req() - send ra filter request to target + * @vdev: objmgr vdev handle + * + * Return: QDF_STATUS_SUCCESS on success else error code + */ +QDF_STATUS pmo_tgt_send_ra_filter_req(struct wlan_objmgr_vdev *vdev); + +/** + * pmo_tgt_send_action_frame_pattern_req - send wow action frame patterns req + * @vdev: objmgr vdev handle + * @cmd: action frame pattern cmd + * + * Return: QDF_STATUS_SUCCESS on success else error code + */ +QDF_STATUS pmo_tgt_send_action_frame_pattern_req( + struct wlan_objmgr_vdev *vdev, + struct pmo_action_wakeup_set_params *cmd); + +/** + * pmo_tgt_send_gtk_offload_req() - send GTK offload command to fw + * @vdev: objmgr vdev + * @gtk_req: pmo gtk req + * + * Return: QDF status + */ +QDF_STATUS pmo_tgt_send_gtk_offload_req(struct wlan_objmgr_vdev *vdev, + struct pmo_gtk_req *gtk_req); + +/** + * pmo_tgt_get_gtk_rsp() - send get gtk rsp command to fw + * @vdev: objmgr vdev + * + * Return: QDF status + */ +QDF_STATUS pmo_tgt_get_gtk_rsp(struct wlan_objmgr_vdev *vdev); + +/** + * pmo_tgt_gtk_rsp_evt() - receive gtk rsp event from fwr + * @psoc: objmgr psoc + * @gtk_rsp_param: gtk response parameters + * + * Return: QDF status + */ +QDF_STATUS pmo_tgt_gtk_rsp_evt(struct wlan_objmgr_psoc *psoc, + struct pmo_gtk_rsp_params *rsp_param); + +#endif /* end of _WLAN_PMO_TGT_API_H_ */ diff --git a/power_management_offloads/dispatcher/inc/wlan_pmo_ucfg_api.h b/power_management_offloads/dispatcher/inc/wlan_pmo_ucfg_api.h new file mode 100644 index 000000000000..a4d8d0c03cfe --- /dev/null +++ b/power_management_offloads/dispatcher/inc/wlan_pmo_ucfg_api.h @@ -0,0 +1,290 @@ +/* +* 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: Declare public API related to the pmo called by north bound HDD/OSIF + */ + +#ifndef _WLAN_PMO_UCFG_API_H_ +#define _WLAN_PMO_UCFG_API_H_ + +#include "wlan_pmo_arp_public_struct.h" +#include "wlan_pmo_ns_public_struct.h" +#include "wlan_pmo_gtk_public_struct.h" +#include "wlan_pmo_mc_addr_filtering_public_struct.h" +#include "wlan_pmo_wow_public_struct.h" +#include "wlan_pmo_common_public_struct.h" + +/** + * pmo_ucfg_is_ap_mode_supports_arp_ns() - Check ap mode support arp&ns offload + * @psoc: objmgr psoc + * @vdev_opmode: vdev opmode + * + * Return: true in case support else false + */ +bool pmo_ucfg_is_ap_mode_supports_arp_ns(struct wlan_objmgr_psoc *psoc, + enum tQDF_ADAPTER_MODE vdev_opmode); + +/** + * pmo_ucfg_is_vdev_connected() - to check whether peer is associated or not + * @vdev: objmgr vdev + * + * Return: true in case success else false + */ +bool pmo_ucfg_is_vdev_connected(struct wlan_objmgr_vdev *vdev); + +/** + * pmo_ucfg_is_vdev_supports_offload() - check offload is supported on vdev + * @vdev: objmgr vdev + * + * Return: true in case success else false + */ +bool pmo_ucfg_is_vdev_supports_offload(struct wlan_objmgr_vdev *vdev); + +/** + * pmo_ucfg_get_psoc_config(): API to get the psoc user configurations of pmo + * @psoc: objmgr psoc handle + * @psoc_cfg: fill the current psoc user configurations. + * + * Return pmo psoc configurations + */ +QDF_STATUS pmo_ucfg_get_psoc_config(struct wlan_objmgr_psoc *psoc, + struct pmo_psoc_cfg *psoc_cfg); + +/** + * pmo_ucfg_update_psoc_config(): API to update the psoc user configurations + * @psoc: objmgr psoc handle + * @psoc_cfg: pmo psoc configurations + * + * This api shall be used for soc config initialization as well update. + * In case of update caller must first call pmo_get_psoc_cfg to get + * current config and then apply changes on top of current config. + * + * Return QDF_STATUS -in case of success else return error + */ +QDF_STATUS pmo_ucfg_update_psoc_config(struct wlan_objmgr_psoc *psoc, + struct pmo_psoc_cfg *psoc_cfg); + +/** + * pmo_ucfg_enable_wakeup_event() - enable wow wakeup events + * @psoc: objmgr psoc + * @vdev_id: vdev id + * @bitmap: Event bitmap + * + * Return: none + */ +void pmo_ucfg_enable_wakeup_event(struct wlan_objmgr_psoc *psoc, + uint32_t vdev_id, uint32_t bitmap); + +/** + * pmo_ucfg_disable_wakeup_event() - disable wow wakeup events + * @psoc: objmgr psoc + * @vdev_id: vdev id + * @bitmap: Event bitmap + * + * Return: none + */ +void pmo_ucfg_disable_wakeup_event(struct wlan_objmgr_psoc *psoc, + uint32_t vdev_id, uint32_t bitmap); + +/** + * pmo_ucfg_cache_arp_offload_req(): API to cache arp req in pmo vdev priv ctx + * @arp_req: pmo arp req param + * + * Return QDF_STATUS -in case of success else return error + */ +QDF_STATUS pmo_ucfg_cache_arp_offload_req(struct pmo_arp_req *arp_req); + +/** + * pmo_ucfg_flush_arp_offload_req(): API to flush arp req from pmo vdev priv ctx + * @vdev: objmgr vdev param + * + * Return QDF_STATUS -in case of success else return error + */ +QDF_STATUS pmo_ucfg_flush_arp_offload_req(struct wlan_objmgr_vdev *vdev); + +/** + * pmo_ucfg_enable_arp_offload_in_fwr(): API to enable arp req in fwr + * @vdev: objmgr vdev param + * @trigger: triger reason for enable arp offload + * + * API to enable cache arp req in fwr from pmo vdev priv ctx + * + * Return QDF_STATUS -in case of success else return error + */ +QDF_STATUS pmo_ucfg_enable_arp_offload_in_fwr(struct wlan_objmgr_vdev *vdev, + enum pmo_offload_trigger trigger); + +/** + * pmo_ucfg_disable_arp_offload_in_fwr(): API to disable arp req in fwr + * @vdev: objmgr vdev param + * @trigger: triger reason for disable arp offload + * API to disable cache arp req in fwr + * + * Return QDF_STATUS -in case of success else return error + */ +QDF_STATUS pmo_ucfg_disable_arp_offload_in_fwr(struct wlan_objmgr_vdev *vdev, + enum pmo_offload_trigger trigger); + +/** + * pmo_ucfg_cache_ns_offload_req(): API to cache ns req in pmo vdev priv ctx + * @ns_req: pmo ns req param + * + * Return QDF_STATUS -in case of success else return error + */ +QDF_STATUS pmo_ucfg_cache_ns_offload_req(struct pmo_ns_req *ns_req); + +/** + * pmo_ucfg_flush_ns_offload_req(): API to flush ns req from pmo vdev priv ctx + * @vdev: vdev ojbmgr handle + * + * Return QDF_STATUS -in case of success else return error + */ +QDF_STATUS pmo_ucfg_flush_ns_offload_req(struct wlan_objmgr_vdev *vdev); + +/** + * pmo_ucfg_enable_ns_offload_in_fwr(): API to enable ns req in fwr + * @arp_req: pmo arp req param + * @trigger: trigger reason to enable ns offload + * + * API to enable cache ns req in fwr from pmo vdev priv ctx + * + * Return QDF_STATUS -in case of success else return error + */ +QDF_STATUS pmo_ucfg_enable_ns_offload_in_fwr(struct wlan_objmgr_vdev *vdev, + enum pmo_offload_trigger trigger); + +/** + * pmo_ucfg_disable_ns_offload_in_fwr(): API to disable ns req in fwr + * @arp_req: pmo arp req param + * @trigger: trigger reason to disable ns offload + * + * API to disable ns req in fwr + * + * Return QDF_STATUS -in case of success else return error + */ +QDF_STATUS pmo_ucfg_disable_ns_offload_in_fwr(struct wlan_objmgr_vdev *vdev, + enum pmo_offload_trigger trigger); + +/** + * pmo_ucfg_max_mc_addr_supported() - to get max support mc address + * @psoc: objmgr psoc + * + * Return: max mc addr supported count for all vdev in corresponding psoc + */ +uint8_t pmo_ucfg_max_mc_addr_supported(struct wlan_objmgr_psoc *psoc); + +/** + * pmo_ucfg_cache_mc_addr_list(): API to cache mc addr list in pmo vdev priv obj + * @psoc: objmgr psoc handle + * @vdev_id: vdev id + * @gtk_req: pmo gtk req param + * + * Return QDF_STATUS_SUCCESS -in case of success else return error + */ +QDF_STATUS pmo_ucfg_cache_mc_addr_list( + struct pmo_mc_addr_list_params *mc_list_config); + +/** + * pmo_ucfg_flush_mc_addr_list(): API to flush mc addr list in pmo vdev priv obj + * @psoc: objmgr psoc handle + * @vdev_id: vdev id + * + * Return QDF_STATUS_SUCCESS -in case of success else return error + */ +QDF_STATUS pmo_ucfg_flush_mc_addr_list(struct wlan_objmgr_psoc *psoc, + uint8_t vdev_id); + +/** + * pmo_ucfg_enable_mc_addr_filtering_in_fwr(): Enable cached mc add list in fwr + * @psoc: objmgr psoc handle + * @vdev_id: vdev id + * @gtk_req: pmo gtk req param + * @action: true for enable els false + * + * API to enable cached mc add list in fwr + * + * Return QDF_STATUS_SUCCESS -in case of success else return error + */ +QDF_STATUS pmo_ucfg_enable_mc_addr_filtering_in_fwr( + struct wlan_objmgr_psoc *psoc, + uint8_t vdev_id, + enum pmo_offload_trigger trigger); + +/** + * pmo_ucfg_disable_mc_addr_filtering_in_fwr(): Disable cached mc addr list + * @psoc: objmgr psoc handle + * @vdev_id: vdev id + * @gtk_req: pmo gtk req param + * @action: true for enable els false + * + * API to disable cached mc add list in fwr + * + * Return QDF_STATUS_SUCCESS -in case of success else return error + */ +QDF_STATUS pmo_ucfg_disable_mc_addr_filtering_in_fwr( + struct wlan_objmgr_psoc *psoc, + uint8_t vdev_id, + enum pmo_offload_trigger trigger); + +/** + * pmo_ucfg_cache_gtk_offload_req(): API to cache gtk req in pmo vdev priv obj + * @vdev: objmgr vdev handle + * @gtk_req: pmo gtk req param + * + * Return QDF_STATUS_SUCCESS -in case of success else return error + */ +QDF_STATUS pmo_ucfg_cache_gtk_offload_req(struct wlan_objmgr_vdev *vdev, + struct pmo_gtk_req *gtk_req); + +/** + * pmo_ucfg_flush_gtk_offload_req(): Flush saved gtk req from pmo vdev priv obj + * @vdev: objmgr vdev handle + * + * Return QDF_STATUS_SUCCESS -in case of success else return error + */ +QDF_STATUS pmo_ucfg_flush_gtk_offload_req(struct wlan_objmgr_vdev *vdev); + +/** + * pmo_ucfg_enable_gtk_offload_in_fwr(): enable cached gtk request in fwr + * @vdev: objmgr vdev handle + * + * Return QDF_STATUS_SUCCESS -in case of success else return error + */ +QDF_STATUS pmo_ucfg_enable_gtk_offload_in_fwr(struct wlan_objmgr_vdev *vdev); + +/** + * pmo_ucfg_disable_gtk_offload_in_fwr(): disable cached gtk request in fwr + * @vdev: objmgr vdev handle + * + * Return QDF_STATUS_SUCCESS -in case of success else return error + */ +QDF_STATUS pmo_ucfg_disable_gtk_offload_in_fwr(struct wlan_objmgr_vdev *vdev); + +/** + * pmo_ucfg_get_gtk_rsp(): API to send gtk response request to fwr + * @vdev: objmgr vdev handle + * @gtk_rsp: pmo gtk response request + * + * This api will send gtk response request to fwr + * + * Return QDF_STATUS_SUCCESS -in case of success else return error + */ +QDF_STATUS pmo_ucfg_get_gtk_rsp(struct wlan_objmgr_vdev *vdev, + struct pmo_gtk_rsp_req *gtk_rsp_req); + +#endif /* end of _WLAN_PMO_UCFG_API_H_ */ diff --git a/power_management_offloads/dispatcher/inc/wlan_pmo_wow_public_struct.h b/power_management_offloads/dispatcher/inc/wlan_pmo_wow_public_struct.h new file mode 100644 index 000000000000..92f8ed937aa2 --- /dev/null +++ b/power_management_offloads/dispatcher/inc/wlan_pmo_wow_public_struct.h @@ -0,0 +1,232 @@ +/* +* 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: Declare various struct, macros which shall be used in + * pmo wow related features. + * + * Note: This file shall not contain public API's prototype/declarations. + * + */ + +#ifndef _WLAN_PMO_WOW_PUBLIC_STRUCT_H_ +#define _WLAN_PMO_WOW_PUBLIC_STRUCT_H_ + +#define PMO_WOWL_PTRN_MAX_SIZE 146 +#define PMO_WOWL_PTRN_MASK_MAX_SIZE 19 +#define PMO_WOWL_MAX_PTRNS_ALLOWED CFG_MAX_WOW_FILTERS_MAX +#define PMO_WOWL_BCAST_PATTERN_MAX_SIZE 146 + +#define PMO_WOW_INTER_PTRN_TOKENIZER ';' +#define PMO_WOW_INTRA_PTRN_TOKENIZER ':' + + +/* Action frame categories */ + +#define PMO_MAC_ACTION_SPECTRUM_MGMT 0 +#define PMO_MAC_ACTION_QOS_MGMT 1 +#define PMO_MAC_ACTION_DLP 2 +#define PMO_MAC_ACTION_BLKACK 3 +#define PMO_MAC_ACTION_PUBLIC_USAGE 4 +#define PMO_MAC_ACTION_RRM 5 +#define PMO_MAC_ACTION_FAST_BSS_TRNST 6 +#define PMO_MAC_ACTION_HT 7 +#define PMO_MAC_ACTION_SA_QUERY 8 +#define PMO_MAC_ACTION_PROT_DUAL_PUB 9 +#define PMO_MAC_ACTION_WNM 10 +#define PMO_MAC_ACTION_UNPROT_WNM 11 +#define PMO_MAC_ACTION_TDLS 12 +#define PMO_MAC_ACITON_MESH 13 +#define PMO_MAC_ACTION_MHF 14 +#define PMO_MAC_SELF_PROTECTED 15 +#define PMO_MAC_ACTION_WME 17 +#define PMO_MAC_ACTION_FST 18 +#define PMO_MAC_ACTION_VHT 21 +#define PMO_MAC_ACTION_MAX 256 + +/* + * ALLOWED_ACTION_FRAMES_BITMAP + * + * Bitmask is based on the below. The frames with 0's + * set to their corresponding bit can be dropped in FW. + * + * -----------------------------+-----+-------+ + * Type | Bit | Allow | + * -----------------------------+-----+-------+ + * PMO_ACTION_SPECTRUM_MGMT 0 1 + * PMO_ACTION_QOS_MGMT 1 1 + * PMO_ACTION_DLP 2 0 + * PMO_ACTION_BLKACK 3 0 + * PMO_ACTION_PUBLIC_USAGE 4 1 + * PMO_ACTION_RRM 5 1 + * PMO_ACTION_FAST_BSS_TRNST 6 0 + * PMO_ACTION_HT 7 0 + * PMO_ACTION_SA_QUERY 8 1 + * PMO_ACTION_PROT_DUAL_PUB 9 1 + * PMO_ACTION_WNM 10 1 + * PMO_ACTION_UNPROT_WNM 11 0 + * PMO_ACTION_TDLS 12 0 + * PMO_ACITON_MESH 13 0 + * PMO_ACTION_MHF 14 0 + * PMO_SELF_PROTECTED 15 0 + * PMO_ACTION_WME 17 1 + * PMO_ACTION_FST 18 1 + * PMO_ACTION_VHT 21 1 + * ----------------------------+------+-------+ + */ +#define ALLOWED_ACTION_FRAMES_BITMAP0 \ + ((1 << PMO_MAC_ACTION_SPECTRUM_MGMT) | \ + (1 << PMO_MAC_ACTION_QOS_MGMT) | \ + (1 << PMO_MAC_ACTION_PUBLIC_USAGE) | \ + (1 << PMO_MAC_ACTION_RRM) | \ + (1 << PMO_MAC_ACTION_SA_QUERY) | \ + (1 << PMO_MAC_ACTION_PROT_DUAL_PUB) | \ + (1 << PMO_MAC_ACTION_WNM) | \ + (1 << PMO_MAC_ACTION_WME) | \ + (1 << PMO_MAC_ACTION_FST) | \ + (1 << PMO_MAC_ACTION_VHT)) + +#define ALLOWED_ACTION_FRAMES_BITMAP1 0x0 +#define ALLOWED_ACTION_FRAMES_BITMAP2 0x0 +#define ALLOWED_ACTION_FRAMES_BITMAP3 0x0 +#define ALLOWED_ACTION_FRAMES_BITMAP4 0x0 +#define ALLOWED_ACTION_FRAMES_BITMAP5 0x0 +#define ALLOWED_ACTION_FRAMES_BITMAP6 0x0 +#define ALLOWED_ACTION_FRAMES_BITMAP7 0x0 + +#define ALLOWED_ACTION_FRAME_MAP_WORDS (PMO_MAC_ACTION_MAX / 32) + + +#define PMO_SUPPORTED_ACTION_CATE 256 +#define PMO_SUPPORTED_ACTION_CATE_ELE_LIST (PMO_SUPPORTED_ACTION_CATE/32) + +/** + * struct pmo_action_wakeup_set_params - action wakeup set params + * @vdev_id: virtual device id + * @operation: 0 reset to fw default, 1 set the bits, + * 2 add the setting bits, 3 delete the setting bits + * @action_category_map: bit mapping. + */ +struct pmo_action_wakeup_set_params { + uint32_t vdev_id; + uint32_t operation; + uint32_t action_category_map[PMO_SUPPORTED_ACTION_CATE_ELE_LIST]; +}; + +/** + * enum pmo_wow_action_wakeup_opertion: describe action wakeup operation + * @pmo_action_wakeup_reset: reset + * @pmo_action_wakeup_set: set + * @pmo_action_wakeup_add_set: add and set + * @pmo_action_wakeup_del_set: delete and set + */ +enum pmo_wow_action_wakeup_opertion { + pmo_action_wakeup_reset = 0, + pmo_action_wakeup_set, + pmo_action_wakeup_add_set, + pmo_action_wakeup_del_set, +}; + +/** + * struct pmo_lphb_enable_req -pmo lphb enable request + * @enable: true if enable else false + * @item: item number + * @session: session number + */ +struct pmo_lphb_enable_req { + bool enable; + uint8_t item; + uint8_t session; +}; + +/** + * struct pmo_lphb_req -pmo lphb request + * @cmd: command + * @dummy: true if dummy else false + * @params: place holder for lphb enable request + */ +struct pmo_lphb_req { + uint16_t cmd; + uint16_t dummy; + union { + struct pmo_lphb_enable_req lphb_enable_req; + } params; +}; + +/** + * struct pmo_wow - store wow patterns + * @magic_ptrn_enable: magic pattern enable/disable + * @wow_enable: wow enable/disable + * @wow_enable_cmd_sent: is wow enable command sent to fw + * @deauth_enable: is deauth wakeup enable/disable + * @disassoc_enable: is disassoc wakeup enable/disable + * @bmiss_enable: is bmiss wakeup enable/disable + * @gtk_pdev_enable: is GTK based wakeup enable/disable + * @lphb_cache: lphb cache + * + * This structure stores wow patterns and + * wow related parameters in host. + */ +struct pmo_wow { + bool wow_enable; + bool wow_enable_cmd_sent; + /* + * currently supports only vdev 0. + * cache has two entries: one for TCP and one for UDP. + */ + struct pmo_lphb_req lphb_cache[2]; +}; + +/* WOW related structures */ +/** + * struct pmo_wow_add_pattern - wow pattern add structure + * @pattern_id: pattern id + * @pattern_byte_offset: pattern byte offset from beginning of the 802.11 + * packet to start of the wake-up pattern + * @pattern_size: pattern size + * @pattern: pattern byte stream + * @pattern_mask_size: pattern mask size + * @pattern_mask: pattern mask + * @session_id: session id + */ +struct pmo_wow_add_pattern { + uint8_t pattern_id; + uint8_t pattern_byte_offset; + uint8_t pattern_size; + uint8_t pattern[PMO_WOWL_BCAST_PATTERN_MAX_SIZE]; + uint8_t pattern_mask_size; + uint8_t pattern_mask[PMO_WOWL_BCAST_PATTERN_MAX_SIZE]; + uint8_t session_id; +}; + +/** + * struct pmo_wow_add_pattern - wow pattern add structure + * @magic_pkt_enable: enables or disables magic packet filtering + * @wow_deauth_rcv: This configuration is valid only when magicPktEnable=1, + * It requests hardware to wake up when it receives the + * Deauthentication Frame. + * @pattern_filtering_enable: Enables/disables packet pattern filtering + * @wow_bss_conn_loss: wake up host when bss connection lost + */ +struct pmo_wow_enter_params { + uint8_t magic_pkt_enable; + uint8_t wow_deauth_rcv; + uint8_t pattern_filtering_enable; + uint8_t wow_bss_conn_loss; +}; + +#endif /* end of _WLAN_PMO_WOW_PUBLIC_STRUCT_H_ */ diff --git a/power_management_offloads/dispatcher/src/wlan_pmo_obj_mgmt_api.c b/power_management_offloads/dispatcher/src/wlan_pmo_obj_mgmt_api.c new file mode 100644 index 000000000000..28d76bfbc0d2 --- /dev/null +++ b/power_management_offloads/dispatcher/src/wlan_pmo_obj_mgmt_api.c @@ -0,0 +1,374 @@ +/* +* 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: define utility API related to the pmo component + * called by other components + */ + +#include "wlan_pmo_obj_mgmt_api.h" +#include "wlan_pmo_tgt_api.h" +#include "wlan_pmo_static_config.h" + +QDF_STATUS pmo_init(void) +{ + QDF_STATUS status; + struct wlan_pmo_ctx *pmo_ctx; + + PMO_ENTER(); + if (pmo_allocate_ctx() != QDF_STATUS_SUCCESS) { + pmo_err("unable to allocate psoc ctx"); + status = QDF_STATUS_E_FAULT; + goto out; + } + + pmo_ctx = pmo_get_context(); + if (!pmo_ctx) { + pmo_err("unable to get pmo ctx"); + status = QDF_STATUS_E_INVAL; + goto out; + } + + status = wlan_objmgr_register_psoc_create_handler( + WLAN_UMAC_COMP_PMO, + pmo_psoc_object_created_notification, + (void *)pmo_ctx); + if (status != QDF_STATUS_SUCCESS) { + pmo_err("unable to register psoc create handle"); + goto out; + } + + status = wlan_objmgr_register_psoc_destroy_handler( + WLAN_UMAC_COMP_PMO, + pmo_psoc_object_destroyed_notification, + (void *)pmo_ctx); + if (status != QDF_STATUS_SUCCESS) { + pmo_err("unable to register psoc create handle"); + goto out; + } + + status = wlan_objmgr_register_vdev_create_handler( + WLAN_UMAC_COMP_PMO, + pmo_vdev_object_created_notification, + (void *)pmo_ctx); + if (status != QDF_STATUS_SUCCESS) { + pmo_err("unable to register vdev create handle"); + goto out; + } + + status = wlan_objmgr_register_vdev_destroy_handler( + WLAN_UMAC_COMP_PMO, + pmo_vdev_object_destroyed_notification, + (void *)pmo_ctx); + if (status != QDF_STATUS_SUCCESS) + pmo_err("unable to register vdev create handle"); +out: + PMO_EXIT(); + + return status; +} + +QDF_STATUS pmo_deinit(void) +{ + QDF_STATUS status; + struct wlan_pmo_ctx *pmo_ctx; + + PMO_ENTER(); + pmo_ctx = pmo_get_context(); + if (!pmo_ctx) { + pmo_err("unable to get pmo ctx"); + status = QDF_STATUS_E_FAILURE; + goto out; + } + + status = wlan_objmgr_unregister_psoc_create_handler( + WLAN_UMAC_COMP_PMO, + pmo_psoc_object_created_notification, + (void *)pmo_ctx); + if (status != QDF_STATUS_SUCCESS) { + pmo_err("unable to unregister psoc create handle"); + goto out; + } + + status = wlan_objmgr_unregister_psoc_destroy_handler( + WLAN_UMAC_COMP_PMO, + pmo_psoc_object_destroyed_notification, + (void *)pmo_ctx); + if (status != QDF_STATUS_SUCCESS) { + pmo_err("unable to unregister psoc create handle"); + goto out; + } + + status = wlan_objmgr_unregister_vdev_create_handler( + WLAN_UMAC_COMP_PMO, + pmo_vdev_object_created_notification, + (void *)pmo_ctx); + if (status != QDF_STATUS_SUCCESS) { + pmo_err("unable to unregister vdev create handle"); + goto out; + } + + status = wlan_objmgr_unregister_vdev_destroy_handler( + WLAN_UMAC_COMP_PMO, + pmo_vdev_object_destroyed_notification, + (void *)pmo_ctx); + if (status != QDF_STATUS_SUCCESS) { + pmo_err("unable to unregister vdev create handle"); + goto out; + } + +out: + pmo_free_ctx(); + PMO_EXIT(); + + return status; +} + +QDF_STATUS pmo_psoc_object_created_notification( + struct wlan_objmgr_psoc *psoc, void *arg) +{ + struct pmo_psoc_priv_obj *psoc_ctx = NULL; + QDF_STATUS status; + struct wlan_pmo_ctx *pmo_ctx; + + PMO_ENTER(); + pmo_ctx = pmo_get_context(); + if (!pmo_ctx) { + QDF_ASSERT(0); + pmo_err("unable to get pmo ctx"); + status = QDF_STATUS_E_FAILURE; + goto out; + } + + psoc_ctx = qdf_mem_malloc(sizeof(*pmo_ctx)); + if (psoc_ctx == NULL) { + pmo_err("Failed to allocate pmo_psoc"); + status = QDF_STATUS_E_NOMEM; + goto out; + } + + status = wlan_objmgr_psoc_component_obj_attach(psoc, + WLAN_UMAC_COMP_PMO, + psoc_ctx, + QDF_STATUS_SUCCESS); + if (status != QDF_STATUS_SUCCESS) { + pmo_err("Failed to attach psoc_ctx with psoc"); + qdf_mem_free(psoc_ctx); + status = QDF_STATUS_E_FAILURE; + goto out; + } + qdf_spinlock_create(&psoc_ctx->lock); +out: + PMO_EXIT(); + + return status; +} + +QDF_STATUS pmo_psoc_object_destroyed_notification( + struct wlan_objmgr_psoc *psoc, void *arg) +{ + struct pmo_psoc_priv_obj *psoc_ctx = NULL; + QDF_STATUS status; + + PMO_ENTER(); + psoc_ctx = pmo_get_psoc_priv_ctx(psoc); + if (!psoc_ctx) { + pmo_err("psoc_ctx is NULL"); + status = QDF_STATUS_E_FAILURE; + goto out; + } + + status = wlan_objmgr_psoc_component_obj_detach(psoc, + WLAN_UMAC_COMP_PMO, + psoc_ctx); + if (status != QDF_STATUS_SUCCESS) { + pmo_err("Failed to detach psoc_ctx from psoc"); + status = QDF_STATUS_E_FAILURE; + goto out; + } + + qdf_spinlock_destroy(&psoc_ctx->lock); + qdf_mem_free(psoc_ctx); +out: + PMO_EXIT(); + + return status; +} + +QDF_STATUS pmo_vdev_object_created_notification( + struct wlan_objmgr_vdev *vdev, void *arg) +{ + struct pmo_psoc_priv_obj *psoc_ctx = NULL; + struct wlan_objmgr_psoc *psoc; + struct pmo_vdev_priv_obj *vdev_ctx; + QDF_STATUS status; + + PMO_ENTER(); + psoc = wlan_vdev_get_psoc(vdev); + if (psoc == NULL) { + pmo_err("psoc is NULL"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + psoc_ctx = pmo_get_psoc_priv_ctx(psoc); + if (!psoc_ctx) { + pmo_err("psoc_ctx is NULL"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + vdev_ctx = qdf_mem_malloc(sizeof(*vdev_ctx)); + if (vdev_ctx == NULL) { + pmo_err("Failed to allocate vdev_ctx"); + status = QDF_STATUS_E_NOMEM; + goto out; + } + + status = wlan_objmgr_vdev_component_obj_attach(vdev, + WLAN_UMAC_COMP_PMO, + (void *)vdev_ctx, QDF_STATUS_SUCCESS); + if (status != QDF_STATUS_SUCCESS) { + pmo_err("Failed to attach vdev_ctx with vdev"); + qdf_mem_free(vdev_ctx); + goto out; + } + + qdf_spinlock_create(&vdev_ctx->pmo_vdev_lock); + vdev_ctx->ptrn_match_enable = + psoc_ctx->psoc_cfg.ptrn_match_enable_all_vdev; + vdev_ctx->pmo_psoc_ctx = psoc_ctx; + qdf_atomic_init(&vdev_ctx->gtk_err_enable); + + /* Register static configuration with firmware */ + pmo_register_wow_wakeup_events(vdev); + pmo_register_action_frame_patterns(vdev); + /* Register default wow patterns with firmware */ + pmo_register_wow_default_patterns(vdev); +out: + PMO_EXIT(); + + return QDF_STATUS_SUCCESS; +} + +QDF_STATUS pmo_vdev_object_destroyed_notification( + struct wlan_objmgr_vdev *vdev, void *arg) +{ + struct pmo_vdev_priv_obj *vdev_ctx = NULL; + QDF_STATUS status = QDF_STATUS_SUCCESS; + + PMO_ENTER(); + vdev_ctx = pmo_get_vdev_priv_ctx(vdev); + if (!vdev_ctx) { + pmo_err("vdev_ctx is NULL"); + status = QDF_STATUS_E_INVAL; + goto out; + } + + status = wlan_objmgr_vdev_component_obj_detach(vdev, + WLAN_UMAC_COMP_PMO, + (void *)vdev_ctx); + if (status != QDF_STATUS_SUCCESS) + pmo_err("Failed to detach vdev_ctx with vdev"); + + qdf_spinlock_destroy(&vdev_ctx->pmo_vdev_lock); + qdf_mem_free(vdev_ctx); +out: + PMO_EXIT(); + + return status; +} + +QDF_STATUS pmo_register_suspend_handler( + enum wlan_umac_comp_id id, + pmo_psoc_suspend_handler handler, + void *arg) +{ + struct wlan_pmo_ctx *pmo_ctx; + QDF_STATUS status = QDF_STATUS_SUCCESS; + + PMO_ENTER(); + pmo_ctx = pmo_get_context(); + if (!pmo_ctx) { + QDF_ASSERT(0); + pmo_err("unable to get pmo ctx"); + status = QDF_STATUS_E_FAILURE; + goto out; + } + + if (id > WLAN_UMAC_MAX_COMPONENTS || id < 0) { + pmo_err("component id: %d is %s then valid components id", + id, id < 0 ? "Less" : "More"); + status = QDF_STATUS_E_FAILURE; + goto out; + } + + qdf_spin_lock(&pmo_ctx->lock); + pmo_ctx->pmo_suspend_handler[id] = handler; + pmo_ctx->pmo_suspend_handler_arg[id] = handler; + qdf_spin_unlock(&pmo_ctx->lock); +out: + PMO_EXIT(); + + return status; +} + +QDF_STATUS pmo_register_resume_handler( + enum wlan_umac_comp_id id, + pmo_psoc_resume_handler handler, + void *arg) +{ + struct wlan_pmo_ctx *pmo_ctx; + QDF_STATUS status = QDF_STATUS_SUCCESS; + + PMO_ENTER(); + pmo_ctx = pmo_get_context(); + if (!pmo_ctx) { + pmo_err("unable to get pmo ctx"); + status = QDF_STATUS_E_FAILURE; + goto out; + } + + if (id > WLAN_UMAC_MAX_COMPONENTS || id < 0) { + pmo_err("component id: %d is %s then valid components id", + id, id < 0 ? "Less" : "More"); + status = QDF_STATUS_E_FAILURE; + goto out; + } + + qdf_spin_lock(&pmo_ctx->lock); + pmo_ctx->pmo_resume_handler[id] = handler; + pmo_ctx->pmo_resume_handler_arg[id] = handler; + qdf_spin_unlock(&pmo_ctx->lock); +out: + PMO_EXIT(); + + return status; +} + +QDF_STATUS pmo_suspend_psoc(struct wlan_objmgr_psoc *psoc, + bool is_runtime_suspend) +{ + return QDF_STATUS_SUCCESS; +} + +QDF_STATUS pmo_resume_psoc(struct wlan_objmgr_psoc *psoc, + bool is_runtime_resume) +{ + return QDF_STATUS_SUCCESS; +} + diff --git a/power_management_offloads/dispatcher/src/wlan_pmo_tgt_arp.c b/power_management_offloads/dispatcher/src/wlan_pmo_tgt_arp.c new file mode 100644 index 000000000000..ef962be2c315 --- /dev/null +++ b/power_management_offloads/dispatcher/src/wlan_pmo_tgt_arp.c @@ -0,0 +1,175 @@ +/* +* 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: Implements public API for pmo to interact with target/WMI + */ + +#include "wlan_pmo_tgt_api.h" +#include "wlan_pmo_arp_public_struct.h" +#include "wlan_pmo_ns_public_struct.h" +#include "wlan_pmo_obj_mgmt_public_struct.h" + +QDF_STATUS pmo_tgt_enable_arp_offload_req(struct wlan_objmgr_vdev *vdev, + uint8_t vdev_id) +{ + struct pmo_arp_offload_params *arp_offload_req = NULL; + struct pmo_ns_offload_params *ns_offload_req = NULL; + struct pmo_vdev_priv_obj *vdev_ctx; + struct wlan_objmgr_psoc *psoc; + QDF_STATUS status; + struct wlan_lmac_if_pmo_tx_ops pmo_tx_ops; + + PMO_ENTER(); + vdev_ctx = pmo_get_vdev_priv_ctx(vdev); + if (!vdev_ctx) { + pmo_err("vdev_ctx is NULL"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + psoc = wlan_vdev_get_psoc(vdev); + if (!psoc) { + pmo_err("psoc unavailable for vdev %p", vdev); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + arp_offload_req = qdf_mem_malloc(sizeof(*arp_offload_req)); + if (!arp_offload_req) { + pmo_err("unable to allocate arp_offload_req"); + status = QDF_STATUS_E_NOMEM; + goto out; + } + + ns_offload_req = qdf_mem_malloc(sizeof(*ns_offload_req)); + if (!ns_offload_req) { + pmo_err("unable to allocate ns_offload_req"); + status = QDF_STATUS_E_NOMEM; + goto out; + } + + qdf_spin_lock_bh(&vdev_ctx->pmo_vdev_lock); + qdf_mem_copy(arp_offload_req, &vdev_ctx->vdev_arp_req, + sizeof(*arp_offload_req)); + qdf_mem_copy(ns_offload_req, &vdev_ctx->vdev_ns_req, + sizeof(*ns_offload_req)); + qdf_spin_unlock_bh(&vdev_ctx->pmo_vdev_lock); + + pmo_debug("ARP Offload vdev_id: %d enable: %d", + vdev_id, + arp_offload_req->enable); + pmo_debug("NS Offload vdev_id: %d enable: %d ns_count: %u", + vdev_id, + ns_offload_req->enable, + ns_offload_req->num_ns_offload_count); + + pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc); + if (!pmo_tx_ops.send_arp_offload_req) { + pmo_err("send_arp_offload_req is null"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + status = pmo_tx_ops.send_arp_offload_req( + vdev, arp_offload_req, ns_offload_req); + if (status != QDF_STATUS_SUCCESS) + pmo_err("Failed to send ARP offload"); +out: + if (arp_offload_req) + qdf_mem_free(arp_offload_req); + if (ns_offload_req) + qdf_mem_free(ns_offload_req); + PMO_EXIT(); + + return status; +} + +QDF_STATUS pmo_tgt_disable_arp_offload_req(struct wlan_objmgr_vdev *vdev, + uint8_t vdev_id) +{ + struct pmo_arp_offload_params *arp_offload_req = NULL; + struct pmo_ns_offload_params *ns_offload_req = NULL; + struct pmo_vdev_priv_obj *vdev_ctx; + struct wlan_objmgr_psoc *psoc; + QDF_STATUS status; + struct wlan_lmac_if_pmo_tx_ops pmo_tx_ops; + + PMO_ENTER(); + vdev_ctx = pmo_get_vdev_priv_ctx(vdev); + if (!vdev_ctx) { + pmo_err("vdev_ctx is NULL"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + psoc = wlan_vdev_get_psoc(vdev); + if (!psoc) { + pmo_err("psoc unavailable for vdev %p", vdev); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + arp_offload_req = qdf_mem_malloc(sizeof(*arp_offload_req)); + if (!arp_offload_req) { + pmo_err("unable to allocate arp_offload_req"); + status = QDF_STATUS_E_NOMEM; + goto out; + } + + ns_offload_req = qdf_mem_malloc(sizeof(*ns_offload_req)); + if (!ns_offload_req) { + pmo_err("unable to allocate ns_offload_req"); + status = QDF_STATUS_E_NOMEM; + goto out; + } + + qdf_spin_lock_bh(&vdev_ctx->pmo_vdev_lock); + qdf_mem_copy(arp_offload_req, &vdev_ctx->vdev_arp_req, + sizeof(*arp_offload_req)); + qdf_mem_copy(ns_offload_req, &vdev_ctx->vdev_ns_req, + sizeof(*ns_offload_req)); + qdf_spin_unlock_bh(&vdev_ctx->pmo_vdev_lock); + + pmo_debug("ARP Offload vdev_id: %d enable: %d", + vdev_id, + arp_offload_req->enable); + pmo_debug("NS Offload vdev_id: %d enable: %d ns_count: %u", + vdev_id, + ns_offload_req->enable, + ns_offload_req->num_ns_offload_count); + + pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc); + if (!pmo_tx_ops.send_arp_offload_req) { + pmo_err("send_arp_offload_req is null"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + status = pmo_tx_ops.send_arp_offload_req( + vdev, arp_offload_req, ns_offload_req); + if (status != QDF_STATUS_SUCCESS) + pmo_err("Failed to send ARP offload"); + +out: + if (arp_offload_req) + qdf_mem_free(arp_offload_req); + if (ns_offload_req) + qdf_mem_free(ns_offload_req); + PMO_EXIT(); + + return status; +} + diff --git a/power_management_offloads/dispatcher/src/wlan_pmo_tgt_gtk.c b/power_management_offloads/dispatcher/src/wlan_pmo_tgt_gtk.c new file mode 100644 index 000000000000..46670ec50143 --- /dev/null +++ b/power_management_offloads/dispatcher/src/wlan_pmo_tgt_gtk.c @@ -0,0 +1,185 @@ +/* +* 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: Implements public API for PMO GTK offload feature to interact + * with target/wmi. + */ + +#include "wlan_pmo_tgt_api.h" +#include "wlan_pmo_gtk_public_struct.h" +#include "wlan_pmo_obj_mgmt_public_struct.h" + +QDF_STATUS pmo_tgt_send_gtk_offload_req(struct wlan_objmgr_vdev *vdev, + struct pmo_gtk_req *gtk_req) +{ + struct pmo_gtk_req *op_gtk_req = NULL; + QDF_STATUS status; + struct wlan_objmgr_psoc *psoc; + struct pmo_vdev_priv_obj *vdev_ctx; + uint8_t vdev_id; + struct wlan_lmac_if_pmo_tx_ops pmo_tx_ops; + + PMO_ENTER(); + psoc = wlan_vdev_get_psoc(vdev); + if (!psoc) { + pmo_err("Failed to find psoc from from vdev:%p", + vdev); + status = QDF_STATUS_E_INVAL; + goto out; + } + + vdev_ctx = pmo_get_vdev_priv_ctx(vdev); + if (!vdev_ctx) { + pmo_err("vdev_ctx is NULL"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + vdev_id = pmo_get_vdev_id(vdev); + + pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc); + if (!pmo_tx_ops.send_gtk_offload_req) { + pmo_err("send_gtk_offload_req is null"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + op_gtk_req = qdf_mem_malloc(sizeof(*op_gtk_req)); + if (!op_gtk_req) { + pmo_err("cannot allocate op_gtk_req "); + status = QDF_STATUS_E_NOMEM; + goto out; + } + + if (gtk_req->flags == PMO_GTK_OFFLOAD_ENABLE) { + qdf_atomic_set(&vdev_ctx->gtk_err_enable, true); + qdf_mem_copy(op_gtk_req->kck, gtk_req->kck, + PMO_KCK_LEN); + qdf_mem_copy(op_gtk_req->kek, gtk_req->kek, + PMO_KEK_LEN); + qdf_mem_copy(&op_gtk_req->replay_counter, + >k_req->replay_counter, PMO_REPLAY_COUNTER_LEN); + } else { + qdf_atomic_set(&vdev_ctx->gtk_err_enable, false); + } + + pmo_info("replay counter %llu", op_gtk_req->replay_counter); + op_gtk_req->flags = gtk_req->flags; + status = pmo_tx_ops.send_gtk_offload_req(vdev, op_gtk_req); + if (status != QDF_STATUS_SUCCESS) + pmo_err("Failed to send gtk offload req event"); +out: + if (op_gtk_req) + qdf_mem_free(op_gtk_req); + PMO_EXIT(); + + return status; +} + +QDF_STATUS pmo_tgt_get_gtk_rsp(struct wlan_objmgr_vdev *vdev) +{ + + struct wlan_objmgr_psoc *psoc; + QDF_STATUS status; + struct wlan_lmac_if_pmo_tx_ops pmo_tx_ops; + + PMO_ENTER(); + psoc = wlan_vdev_get_psoc(vdev); + if (!psoc) { + pmo_err("Failed to find psoc from from vdev:%p", + vdev); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc); + if (!pmo_tx_ops.send_get_gtk_rsp_cmd) { + pmo_err("send_get_gtk_rsp_cmd is null"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + status = pmo_tx_ops.send_get_gtk_rsp_cmd(vdev); + if (status != QDF_STATUS_SUCCESS) + pmo_err("Failed to send_get_gtk_rsp_cmd event"); +out: + PMO_EXIT(); + + return status; +} + +QDF_STATUS pmo_tgt_gtk_rsp_evt(struct wlan_objmgr_psoc *psoc, + struct pmo_gtk_rsp_params *rsp_param) +{ + QDF_STATUS status; + struct wlan_objmgr_vdev *vdev; + struct pmo_vdev_priv_obj *vdev_ctx; + + PMO_ENTER(); + if (!rsp_param) { + pmo_err("gtk rsp param is null"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + vdev = wlan_objmgr_get_vdev_by_id_from_psoc(psoc, + rsp_param->vdev_id, WLAN_PMO_ID); + if (!vdev) { + pmo_err("vdev is null vdev_id:%d psoc:%p", + rsp_param->vdev_id, psoc); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + vdev_ctx = pmo_get_vdev_priv_ctx(vdev); + if (!vdev_ctx) { + pmo_err("vdev_ctx is NULL"); + status = QDF_STATUS_E_NULL_VALUE; + goto dec_ref; + } + + status = pmo_get_vdev_bss_peer_mac_addr(vdev, &rsp_param->bssid); + if (status != QDF_STATUS_SUCCESS) { + pmo_err("cannot find peer mac address"); + goto dec_ref; + } + + /* update cached replay counter */ + qdf_spin_lock_bh(&vdev_ctx->pmo_vdev_lock); + vdev_ctx->vdev_gtk_req.replay_counter = rsp_param->replay_counter; + qdf_spin_unlock_bh(&vdev_ctx->pmo_vdev_lock); + + if (vdev_ctx->vdev_gtk_rsp_req.callback) { + pmo_info("callback:%p context:%p psoc:%p vdev_id:%d", + vdev_ctx->vdev_gtk_rsp_req.callback, + vdev_ctx->vdev_gtk_rsp_req.callback_context, + psoc, rsp_param->vdev_id); + vdev_ctx->vdev_gtk_rsp_req.callback( + vdev_ctx->vdev_gtk_rsp_req.callback_context, + rsp_param); + } else { + pmo_err("gtk rsp callback is null for vdev_id:%d psoc %p", + rsp_param->vdev_id, + psoc); + } +dec_ref: + wlan_objmgr_vdev_release_ref(vdev, WLAN_PMO_ID); +out: + PMO_EXIT(); + + return status; +} + diff --git a/power_management_offloads/dispatcher/src/wlan_pmo_tgt_mc_addr_filtering.c b/power_management_offloads/dispatcher/src/wlan_pmo_tgt_mc_addr_filtering.c new file mode 100644 index 000000000000..30d6e9422986 --- /dev/null +++ b/power_management_offloads/dispatcher/src/wlan_pmo_tgt_mc_addr_filtering.c @@ -0,0 +1,92 @@ +/* +* 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: Implements public API for pmo to interact with target/WMI + */ + +#include "wlan_pmo_tgt_api.h" +#include "wlan_pmo_mc_addr_filtering_public_struct.h" +#include "wlan_pmo_obj_mgmt_public_struct.h" + +QDF_STATUS pmo_tgt_set_mc_filter_req(struct wlan_objmgr_vdev *vdev, + struct qdf_mac_addr multicast_addr) +{ + QDF_STATUS status; + struct wlan_objmgr_psoc *psoc; + struct wlan_lmac_if_pmo_tx_ops pmo_tx_ops; + + PMO_ENTER(); + psoc = wlan_vdev_get_psoc(vdev); + if (!psoc) { + pmo_err("Failed to find psoc from from vdev:%p", + vdev); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc); + if (!pmo_tx_ops.send_set_mc_filter_req) { + pmo_err("send_add_clear_mcbc_filter_request is null"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + status = pmo_tx_ops.send_set_mc_filter_req( + vdev, multicast_addr); + if (status != QDF_STATUS_SUCCESS) + pmo_err("Failed to add/clear mc filter"); +out: + PMO_EXIT(); + + return status; +} + +QDF_STATUS pmo_tgt_clear_mc_filter_req(struct wlan_objmgr_vdev *vdev, + struct qdf_mac_addr multicast_addr) +{ + QDF_STATUS status; + struct wlan_objmgr_psoc *psoc; + struct wlan_lmac_if_pmo_tx_ops pmo_tx_ops; + + PMO_ENTER(); + psoc = wlan_vdev_get_psoc(vdev); + if (!psoc) { + pmo_err("Failed to find psoc from from vdev:%p", + vdev); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc); + if (!pmo_tx_ops.send_clear_mc_filter_req) { + pmo_err("send_add_clear_mcbc_filter_request is null"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + status = pmo_tx_ops.send_clear_mc_filter_req( + vdev, multicast_addr); + if (status != QDF_STATUS_SUCCESS) + pmo_err("Failed to add/clear mc filter"); +out: + PMO_EXIT(); + + return status; +} + + diff --git a/power_management_offloads/dispatcher/src/wlan_pmo_tgt_ns.c b/power_management_offloads/dispatcher/src/wlan_pmo_tgt_ns.c new file mode 100644 index 000000000000..9feb56f3fad2 --- /dev/null +++ b/power_management_offloads/dispatcher/src/wlan_pmo_tgt_ns.c @@ -0,0 +1,177 @@ +/* +* 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: Implements public API for PMO NS offload feature to interact + * with target/wmi. + */ + +#include "wlan_pmo_tgt_api.h" +#include "wlan_pmo_arp_public_struct.h" +#include "wlan_pmo_ns_public_struct.h" +#include "wlan_pmo_obj_mgmt_public_struct.h" + +QDF_STATUS pmo_tgt_enable_ns_offload_req(struct wlan_objmgr_vdev *vdev, + uint8_t vdev_id) +{ + struct pmo_arp_offload_params *arp_offload_req = NULL; + struct pmo_ns_offload_params *ns_offload_req = NULL; + struct pmo_vdev_priv_obj *vdev_ctx; + struct wlan_objmgr_psoc *psoc; + QDF_STATUS status; + struct wlan_lmac_if_pmo_tx_ops pmo_tx_ops; + + PMO_ENTER(); + vdev_ctx = pmo_get_vdev_priv_ctx(vdev); + if (!vdev_ctx) { + pmo_err("vdev_ctx is NULL"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + psoc = wlan_vdev_get_psoc(vdev); + if (!psoc) { + pmo_err("psoc unavailable for vdev %p", vdev); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + arp_offload_req = qdf_mem_malloc(sizeof(*arp_offload_req)); + if (!arp_offload_req) { + pmo_err("unable to allocate arp_offload_req"); + status = QDF_STATUS_E_NOMEM; + goto out; + } + + ns_offload_req = qdf_mem_malloc(sizeof(*ns_offload_req)); + if (!ns_offload_req) { + pmo_err("unable to allocate ns_offload_req"); + status = QDF_STATUS_E_NOMEM; + goto out; + } + + qdf_spin_lock_bh(&vdev_ctx->pmo_vdev_lock); + qdf_mem_copy(arp_offload_req, &vdev_ctx->vdev_arp_req, + sizeof(*arp_offload_req)); + qdf_mem_copy(ns_offload_req, &vdev_ctx->vdev_ns_req, + sizeof(*ns_offload_req)); + qdf_spin_unlock_bh(&vdev_ctx->pmo_vdev_lock); + + pmo_debug("ARP Offload vdev_id: %d enable: %d", + vdev_id, + arp_offload_req->enable); + pmo_debug("NS Offload vdev_id: %d enable: %d ns_count: %u", + vdev_id, + ns_offload_req->enable, + ns_offload_req->num_ns_offload_count); + + pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc); + if (!pmo_tx_ops.send_ns_offload_req) { + pmo_err("send_ns_offload_req is null"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + status = pmo_tx_ops.send_ns_offload_req( + vdev, arp_offload_req, ns_offload_req); + if (status != QDF_STATUS_SUCCESS) + pmo_err("Failed to send NS offload"); + +out: + if (arp_offload_req) + qdf_mem_free(arp_offload_req); + if (ns_offload_req) + qdf_mem_free(ns_offload_req); + PMO_EXIT(); + + return status; +} + +QDF_STATUS pmo_tgt_disable_ns_offload_req(struct wlan_objmgr_vdev *vdev, + uint8_t vdev_id) +{ + struct pmo_arp_offload_params *arp_offload_req = NULL; + struct pmo_ns_offload_params *ns_offload_req = NULL; + struct pmo_vdev_priv_obj *vdev_ctx; + struct wlan_objmgr_psoc *psoc; + QDF_STATUS status; + struct wlan_lmac_if_pmo_tx_ops pmo_tx_ops; + + PMO_ENTER(); + vdev_ctx = pmo_get_vdev_priv_ctx(vdev); + if (!vdev_ctx) { + pmo_err("vdev_ctx is NULL"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + psoc = wlan_vdev_get_psoc(vdev); + if (!psoc) { + pmo_err("psoc unavailable for vdev %p", vdev); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + arp_offload_req = qdf_mem_malloc(sizeof(*arp_offload_req)); + if (!arp_offload_req) { + pmo_err("unable to allocate arp_offload_req"); + status = QDF_STATUS_E_NOMEM; + goto out; + } + + ns_offload_req = qdf_mem_malloc(sizeof(*ns_offload_req)); + if (!ns_offload_req) { + pmo_err("unable to allocate ns_offload_req"); + status = QDF_STATUS_E_NOMEM; + goto out; + } + + qdf_spin_lock_bh(&vdev_ctx->pmo_vdev_lock); + qdf_mem_copy(arp_offload_req, &vdev_ctx->vdev_arp_req, + sizeof(*arp_offload_req)); + qdf_mem_copy(ns_offload_req, &vdev_ctx->vdev_ns_req, + sizeof(*ns_offload_req)); + qdf_spin_unlock_bh(&vdev_ctx->pmo_vdev_lock); + + pmo_debug("ARP Offload vdev_id: %d enable: %d", + vdev_id, + arp_offload_req->enable); + pmo_debug("NS Offload vdev_id: %d enable: %d ns_count: %u", + vdev_id, + ns_offload_req->enable, + ns_offload_req->num_ns_offload_count); + + pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc); + if (!pmo_tx_ops.send_ns_offload_req) { + pmo_err("send_ns_offload_req is null"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + status = pmo_tx_ops.send_ns_offload_req( + vdev, arp_offload_req, ns_offload_req); + if (status != QDF_STATUS_SUCCESS) + pmo_err("Failed to send NS offload"); + +out: + if (arp_offload_req) + qdf_mem_free(arp_offload_req); + if (ns_offload_req) + qdf_mem_free(ns_offload_req); + PMO_EXIT(); + + return status; +} + diff --git a/power_management_offloads/dispatcher/src/wlan_pmo_tgt_static_config.c b/power_management_offloads/dispatcher/src/wlan_pmo_tgt_static_config.c new file mode 100644 index 000000000000..89f077d0d3e0 --- /dev/null +++ b/power_management_offloads/dispatcher/src/wlan_pmo_tgt_static_config.c @@ -0,0 +1,147 @@ +/* +* 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: Implements public API for pmo to interact with target/WMI + */ + +#include "wlan_pmo_tgt_api.h" +#include "wlan_pmo_wow.h" +#include "wlan_pmo_obj_mgmt_public_struct.h" + +QDF_STATUS pmo_tgt_send_enhance_multicast_offload_req( + struct wlan_objmgr_vdev *vdev, + uint8_t vdev_id, + uint8_t action) +{ + QDF_STATUS status; + struct wlan_objmgr_psoc *psoc; + struct wlan_lmac_if_pmo_tx_ops pmo_tx_ops; + + PMO_ENTER(); + psoc = wlan_vdev_get_psoc(vdev); + if (!psoc) { + pmo_err("Failed to find psoc from from vdev:%p", + vdev); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc); + if (!pmo_tx_ops.send_enhance_mc_offload_req) { + pmo_err("send_enhance_multicast_offload is null"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + status = pmo_tx_ops.send_enhance_mc_offload_req(vdev, action); + if (status != QDF_STATUS_SUCCESS) + pmo_err("Failed to config enhance multicast offload"); +out: + PMO_EXIT(); + + return status; +} + +QDF_STATUS pmo_tgt_send_ra_filter_req(struct wlan_objmgr_vdev *vdev) +{ + + QDF_STATUS status; + uint8_t default_pattern; + uint16_t ra_interval; + struct pmo_vdev_priv_obj *vdev_ctx; + uint8_t vdev_id; + struct wlan_objmgr_psoc *psoc; + struct wlan_lmac_if_pmo_tx_ops pmo_tx_ops; + + PMO_ENTER(); + psoc = wlan_vdev_get_psoc(vdev); + if (!psoc) { + pmo_err("Failed to find psoc from from vdev:%p", + vdev); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + vdev_ctx = pmo_get_vdev_priv_ctx(vdev); + if (!vdev_ctx) { + pmo_err("vdev_ctx is NULL"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + vdev_id = pmo_get_vdev_id(vdev); + qdf_spin_lock_bh(&vdev_ctx->pmo_vdev_lock); + ra_interval = vdev_ctx->pmo_psoc_ctx->psoc_cfg.ra_ratelimit_interval; + qdf_spin_unlock_bh(&vdev_ctx->pmo_vdev_lock); + + pmo_debug("send RA rate limit [%d] to fw vdev = %d", + ra_interval, vdev_id); + + default_pattern = pmo_get_and_increment_wow_default_ptrn(vdev_ctx); + pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc); + if (!pmo_tx_ops.send_ra_filter_req) { + pmo_err("send_ra_filter_cmd is null"); + status = QDF_STATUS_E_INVAL; + goto out; + } + + status = pmo_tx_ops.send_ra_filter_req( + vdev, default_pattern, ra_interval); + if (status != QDF_STATUS_SUCCESS) { + pmo_err("Failed to send RA rate limit to fw"); + pmo_decrement_wow_default_ptrn(vdev_ctx); + } +out: + PMO_EXIT(); + + return status; +} + +QDF_STATUS pmo_tgt_send_action_frame_pattern_req( + struct wlan_objmgr_vdev *vdev, + struct pmo_action_wakeup_set_params *cmd) +{ + QDF_STATUS status; + struct wlan_objmgr_psoc *psoc; + struct wlan_lmac_if_pmo_tx_ops pmo_tx_ops; + + PMO_ENTER(); + psoc = wlan_vdev_get_psoc(vdev); + if (!psoc) { + pmo_err("Failed to find psoc from from vdev:%p", + vdev); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc); + if (!pmo_tx_ops.send_action_frame_pattern_req) { + pmo_err("send_add_action_frame_pattern_cmd is null"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + status = pmo_tx_ops.send_action_frame_pattern_req(vdev, cmd); + if (status != QDF_STATUS_SUCCESS) + pmo_err("Failed to add filter"); +out: + PMO_EXIT(); + + return status; +} + diff --git a/power_management_offloads/dispatcher/src/wlan_pmo_tgt_wow.c b/power_management_offloads/dispatcher/src/wlan_pmo_tgt_wow.c new file mode 100644 index 000000000000..71fe2574baa2 --- /dev/null +++ b/power_management_offloads/dispatcher/src/wlan_pmo_tgt_wow.c @@ -0,0 +1,141 @@ +/* +* 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: Implements public API for pmo to interact with target/WMI + */ + +#include "wlan_pmo_tgt_api.h" +#include "wlan_pmo_wow.h" +#include "wlan_pmo_obj_mgmt_public_struct.h" + +QDF_STATUS pmo_tgt_enable_wow_wakeup_event( + struct wlan_objmgr_vdev *vdev, + uint32_t bitmap) +{ + QDF_STATUS status; + struct wlan_objmgr_psoc *psoc; + struct wlan_lmac_if_pmo_tx_ops pmo_tx_ops; + + PMO_ENTER(); + psoc = wlan_vdev_get_psoc(vdev); + if (!psoc) { + pmo_err("Failed to find psoc from from vdev:%p", + vdev); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc); + if (!pmo_tx_ops.send_enable_wow_wakeup_event_req) { + pmo_err("send_enable_wow_wakeup_event_req is null"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + status = pmo_tx_ops.send_enable_wow_wakeup_event_req(vdev, bitmap); + if (status != QDF_STATUS_SUCCESS) + pmo_err("Failed to enable wow wakeup event"); +out: + PMO_EXIT(); + + return status; +} + +QDF_STATUS pmo_tgt_disable_wow_wakeup_event( + struct wlan_objmgr_vdev *vdev, + uint32_t bitmap) +{ + QDF_STATUS status; + struct wlan_objmgr_psoc *psoc; + struct wlan_lmac_if_pmo_tx_ops pmo_tx_ops; + + PMO_ENTER(); + psoc = wlan_vdev_get_psoc(vdev); + if (!psoc) { + pmo_err("Failed to find psoc from from vdev:%p", + vdev); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc); + if (!pmo_tx_ops.send_disable_wow_wakeup_event_req) { + pmo_err("send_disable_wow_wakeup_event_req is null"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + status = pmo_tx_ops.send_disable_wow_wakeup_event_req(vdev, bitmap); + if (status != QDF_STATUS_SUCCESS) + pmo_err("Failed to disable wow wakeup event"); +out: + PMO_EXIT(); + + return status; +} + +QDF_STATUS pmo_tgt_send_wow_patterns_to_fw( + struct wlan_objmgr_vdev *vdev, uint8_t ptrn_id, + const uint8_t *ptrn, uint8_t ptrn_len, + uint8_t ptrn_offset, const uint8_t *mask, + uint8_t mask_len, bool user) +{ + QDF_STATUS status; + struct pmo_vdev_priv_obj *vdev_ctx; + struct wlan_objmgr_psoc *psoc; + struct wlan_lmac_if_pmo_tx_ops pmo_tx_ops; + + PMO_ENTER(); + psoc = wlan_vdev_get_psoc(vdev); + if (!psoc) { + pmo_err("Failed to find psoc from from vdev:%p", + vdev); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + vdev_ctx = pmo_get_vdev_priv_ctx(vdev); + if (!vdev_ctx) { + pmo_err("vdev_ctx is NULL"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + + pmo_tx_ops = GET_PMO_TX_OPS_FROM_PSOC(psoc); + if (!pmo_tx_ops.send_add_wow_pattern) { + pmo_err("send_add_wow_pattern is null"); + status = QDF_STATUS_E_NULL_VALUE; + goto out; + } + status = pmo_tx_ops.send_add_wow_pattern( + vdev, ptrn_id, ptrn, + ptrn_len, ptrn_offset, mask, + mask_len, user); + if (status != QDF_STATUS_SUCCESS) { + if (!user) + pmo_decrement_wow_default_ptrn(vdev_ctx); + pmo_err("Failed to sen wow pattern event"); + goto out; + } + + if (user) + pmo_increment_wow_user_ptrn(vdev_ctx); +out: + PMO_EXIT(); + + return status; +} + diff --git a/power_management_offloads/dispatcher/src/wlan_pmo_ucfg_api.c b/power_management_offloads/dispatcher/src/wlan_pmo_ucfg_api.c new file mode 100644 index 000000000000..b7ab0f22a5e3 --- /dev/null +++ b/power_management_offloads/dispatcher/src/wlan_pmo_ucfg_api.c @@ -0,0 +1,176 @@ +/* +* 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: public API related to the pmo called by north bound HDD/OSIF + */ + +#include "wlan_pmo_ucfg_api.h" +#include "wlan_pmo_arp.h" +#include "wlan_pmo_ns.h" +#include "wlan_pmo_gtk.h" +#include "wlan_pmo_wow.h" +#include "wlan_pmo_mc_addr_filtering.h" +#include "wlan_pmo_main.h" + +QDF_STATUS pmo_ucfg_get_psoc_config(struct wlan_objmgr_psoc *psoc, + struct pmo_psoc_cfg *psoc_cfg) +{ + return pmo_core_get_psoc_config(psoc, psoc_cfg); +} + +QDF_STATUS pmo_ucfg_update_psoc_config(struct wlan_objmgr_psoc *psoc, + struct pmo_psoc_cfg *psoc_cfg) +{ + return pmo_core_update_psoc_config(psoc, psoc_cfg); +} + +bool pmo_ucfg_is_ap_mode_supports_arp_ns(struct wlan_objmgr_psoc *psoc, + enum tQDF_ADAPTER_MODE vdev_opmode) +{ + return pmo_core_is_ap_mode_supports_arp_ns(psoc, vdev_opmode); +} + +bool pmo_ucfg_is_vdev_connected(struct wlan_objmgr_vdev *vdev) +{ + return pmo_core_is_vdev_connected(vdev); +} + +bool pmo_ucfg_is_vdev_supports_offload(struct wlan_objmgr_vdev *vdev) +{ + return pmo_core_is_vdev_supports_offload(vdev); +} + +void pmo_ucfg_enable_wakeup_event(struct wlan_objmgr_psoc *psoc, + uint32_t vdev_id, uint32_t bitmap) +{ + pmo_core_enable_wakeup_event(psoc, vdev_id, bitmap); +} + +void pmo_ucfg_disable_wakeup_event(struct wlan_objmgr_psoc *psoc, + uint32_t vdev_id, uint32_t bitmap) +{ + pmo_core_disable_wakeup_event(psoc, vdev_id, bitmap); +} + +QDF_STATUS pmo_ucfg_cache_arp_offload_req(struct pmo_arp_req *arp_req) +{ + return pmo_core_cache_arp_offload_req(arp_req); +} + +QDF_STATUS pmo_ucfg_flush_arp_offload_req(struct wlan_objmgr_vdev *vdev) +{ + return pmo_core_flush_arp_offload_req(vdev); +} + +QDF_STATUS pmo_ucfg_enable_arp_offload_in_fwr(struct wlan_objmgr_vdev *vdev, + enum pmo_offload_trigger trigger) +{ + return pmo_core_enable_arp_offload_in_fwr(vdev, trigger); +} + +QDF_STATUS pmo_ucfg_disable_arp_offload_in_fwr(struct wlan_objmgr_vdev *vdev, + enum pmo_offload_trigger trigger) +{ + return pmo_core_disable_arp_offload_in_fwr(vdev, trigger); +} + +QDF_STATUS pmo_ucfg_cache_ns_offload_req(struct pmo_ns_req *ns_req) +{ + return pmo_core_cache_ns_offload_req(ns_req); +} + +QDF_STATUS pmo_ucfg_flush_ns_offload_req(struct wlan_objmgr_vdev *vdev) +{ + return pmo_core_flush_ns_offload_req(vdev); +} + +QDF_STATUS pmo_ucfg_enable_ns_offload_in_fwr(struct wlan_objmgr_vdev *vdev, + enum pmo_offload_trigger trigger) +{ + return pmo_core_enable_ns_offload_in_fwr(vdev, trigger); +} + +QDF_STATUS pmo_ucfg_disable_ns_offload_in_fwr(struct wlan_objmgr_vdev *vdev, + enum pmo_offload_trigger trigger) +{ + return pmo_core_disable_ns_offload_in_fwr(vdev, trigger); +} + +QDF_STATUS pmo_ucfg_cache_mc_addr_list( + struct pmo_mc_addr_list_params *mc_list_config) +{ + return pmo_core_cache_mc_addr_list(mc_list_config); +} + +QDF_STATUS pmo_ucfg_flush_mc_addr_list(struct wlan_objmgr_psoc *psoc, + uint8_t vdev_id) +{ + return pmo_core_flush_mc_addr_list(psoc, vdev_id); +} + +QDF_STATUS pmo_ucfg_enable_mc_addr_filtering_in_fwr( + struct wlan_objmgr_psoc *psoc, + uint8_t vdev_id, + enum pmo_offload_trigger trigger) +{ + return pmo_core_enable_mc_addr_filtering_in_fwr(psoc, + vdev_id, trigger); +} + +QDF_STATUS pmo_ucfg_disable_mc_addr_filtering_in_fwr( + struct wlan_objmgr_psoc *psoc, + uint8_t vdev_id, + enum pmo_offload_trigger trigger) +{ + return pmo_core_disable_mc_addr_filtering_in_fwr(psoc, + vdev_id, trigger); +} + +uint8_t pmo_ucfg_max_mc_addr_supported(struct wlan_objmgr_psoc *psoc) +{ + return pmo_core_max_mc_addr_supported(psoc); +} + +QDF_STATUS pmo_ucfg_cache_gtk_offload_req(struct wlan_objmgr_vdev *vdev, + struct pmo_gtk_req *gtk_req) +{ + return pmo_core_cache_gtk_offload_req(vdev, gtk_req); +} + +QDF_STATUS pmo_ucfg_flush_gtk_offload_req(struct wlan_objmgr_vdev *vdev) +{ + return pmo_core_flush_gtk_offload_req(vdev); +} + +QDF_STATUS pmo_ucfg_enable_gtk_offload_in_fwr(struct wlan_objmgr_vdev *vdev) +{ + return pmo_core_enable_gtk_offload_in_fwr(vdev); +} + +QDF_STATUS pmo_ucfg_disable_gtk_offload_in_fwr(struct wlan_objmgr_vdev *vdev) +{ + return pmo_core_disable_gtk_offload_in_fwr(vdev); +} + +QDF_STATUS pmo_ucfg_get_gtk_rsp(struct wlan_objmgr_vdev *vdev, + struct pmo_gtk_rsp_req *gtk_rsp_req) +{ + return pmo_core_get_gtk_rsp(vdev, gtk_rsp_req); +} + +