diff --git a/dp/inc/cdp_txrx_mlo.h b/dp/inc/cdp_txrx_mlo.h new file mode 100644 index 0000000000..7fa22d008f --- /dev/null +++ b/dp/inc/cdp_txrx_mlo.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2021 Qualcomm Innovation Center, Inc. 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. + */ +#ifndef _CDP_TXRX_MLO_H_ +#define _CDP_TXRX_MLO_H_ +struct cdp_mlo_ctxt; + +/** + * cdp_ctrl_mlo_mgr - opaque handle for mlo manager context + */ +struct cdp_ctrl_mlo_mgr; + +struct +cdp_mlo_ctxt *dp_mlo_ctxt_attach_wifi3(struct cdp_ctrl_mlo_mgr *ctrl_ctxt); +void dp_mlo_ctxt_detach_wifi3(struct cdp_mlo_ctxt *ml_ctxt); + +static inline +struct cdp_mlo_ctxt *cdp_mlo_ctxt_attach(struct cdp_ctrl_mlo_mgr *ctrl_ctxt) +{ + return dp_mlo_ctxt_attach_wifi3(ctrl_ctxt); +} + +static inline +void cdp_mlo_ctxt_detach(struct cdp_mlo_ctxt *ml_ctxt) +{ + dp_mlo_ctxt_detach_wifi3(ml_ctxt); +} +#endif /*_CDP_TXRX_MLO_H_*/ diff --git a/dp/wifi3.0/be/dp_be.h b/dp/wifi3.0/be/dp_be.h index 4cd86041ee..0e9b43cd21 100644 --- a/dp/wifi3.0/be/dp_be.h +++ b/dp/wifi3.0/be/dp_be.h @@ -172,6 +172,9 @@ struct dp_tx_bank_profile { * @tx_cc_ctx: Cookie conversion context for tx desc pools * @rx_cc_ctx: Cookie conversion context for rx desc pools * @monitor_soc_be: BE specific monitor object + * @mlo_enabled: Flag to indicate MLO is enabled or not + * @ml_ctxt: pointer to global ml_context + * @mlo_chip_id: MLO chip_id */ struct dp_soc_be { struct dp_soc soc; @@ -190,6 +193,11 @@ struct dp_soc_be { #if !defined(DISABLE_MON_CONFIG) struct dp_mon_soc_be *monitor_soc_be; #endif +#ifdef WLAN_MLO_MULTI_CHIP + uint8_t mlo_enabled; + struct dp_mlo_context *ml_context; + uint8_t mlo_chip_id; +#endif }; /* convert struct dp_soc_be pointer to struct dp_soc pointer */ diff --git a/dp/wifi3.0/be/mlo/dp_mlo.c b/dp/wifi3.0/be/mlo/dp_mlo.c new file mode 100644 index 0000000000..fbd79b6888 --- /dev/null +++ b/dp/wifi3.0/be/mlo/dp_mlo.c @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2021 Qualcomm Innovation Center, Inc. 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. + */ +#include +#include +#include +#include +#include "dp_mlo.h" + +/* + * dp_mlo_ctxt_attach_wifi3 () – Attach DP MLO context + * + * Return: DP MLO context handle on success, NULL on failure + */ +struct cdp_mlo_ctxt * +dp_mlo_ctxt_attach_wifi3(struct cdp_ctrl_mlo_mgr *ctrl_ctxt) +{ + struct dp_mlo_ctxt *mlo_ctxt = + qdf_mem_malloc(sizeof(struct dp_mlo_ctxt)); + + if (!mlo_ctxt) { + dp_err("Failed to allocate DP MLO Context"); + return NULL; + } + + mlo_ctxt->ctrl_ctxt = ctrl_ctxt; + + return dp_mlo_ctx_to_cdp(mlo_ctxt); +} + +qdf_export_symbol(dp_mlo_ctxt_attach_wifi3); + +/* + * dp_mlo_ctxt_detach_wifi3 () – Detach DP MLO context + * + * @ml_ctxt: pointer to DP MLO context + * + * Return: void + */ +void dp_mlo_ctxt_detach_wifi3(struct cdp_mlo_ctxt *ml_ctxt) +{ + qdf_mem_free(ml_ctxt); +} + +qdf_export_symbol(dp_mlo_ctxt_detach_wifi3); + +/* + * dp_mlo_set_soc_by_chip_id() – Add DP soc to ML context soc list + * + * @ml_ctxt: DP ML context handle + * @soc: DP soc handle + * @chip_id: MLO chip id + * + * Return: void + */ +void dp_mlo_set_soc_by_chip_id(struct dp_mlo_ctxt *ml_ctxt, + struct dp_soc *soc, + uint8_t chip_id) +{ + qdf_spin_lock_bh(&ml_ctxt->ml_soc_list_lock); + ml_ctxt->ml_soc_list[chip_id] = soc; + qdf_spin_unlock_bh(&ml_ctxt->ml_soc_list_lock); +} + +/* + * dp_mlo_get_soc_ref_by_chip_id() – Get DP soc from DP ML context. + * This API will increment a reference count for DP soc. Caller has + * to take care for decrementing refcount. + * + * @ml_ctxt: DP ML context handle + * @chip_id: MLO chip id + * + * Return: dp_soc + */ +struct dp_soc* +dp_mlo_get_soc_ref_by_chip_id(struct dp_mlo_ctxt *ml_ctxt, + uint8_t chip_id) +{ + struct dp_soc *soc = NULL; + + qdf_spin_lock_bh(&ml_ctxt->ml_soc_list_lock); + qdf_atomic_inc(&soc->ref_count); + soc = ml_ctxt->ml_soc_list[chip_id]; + qdf_spin_unlock_bh(&ml_ctxt->ml_soc_list_lock); + + return soc; +} diff --git a/dp/wifi3.0/be/mlo/dp_mlo.h b/dp/wifi3.0/be/mlo/dp_mlo.h new file mode 100644 index 0000000000..e3845d6c4c --- /dev/null +++ b/dp/wifi3.0/be/mlo/dp_mlo.h @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2021 Qualcomm Innovation Center, Inc. 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. + */ +#ifndef __DP_MLO_H +#define __DP_MLO_H + +#include +#include + +/* Max number of chips that can participate in MLO */ +#define DP_MAX_MLO_CHIPS 3 + +/* + * dp_mlo_ctxt + * + * @ctrl_ctxt: opaque handle of cp mlo mgr + * @ml_soc_list: list of socs which are mlo enabled. This also maintains + * mlo_chip_id to dp_soc mapping + * @ml_soc_list_lock: lock to protect ml_soc_list + * @ml_peer_hash: peer hash table for ML peers + * Associated peer with this MAC address) + * @ml_peer_hash_lock: lock to protect ml_peer_hash + */ +struct dp_mlo_ctxt { + struct cdp_ctrl_mlo_mgr *ctrl_ctxt; + struct dp_soc *ml_soc_list[DP_MAX_MLO_CHIPS]; + qdf_spinlock_t ml_soc_list_lock; + struct { + uint32_t mask; + uint32_t idx_bits; + + TAILQ_HEAD(, dp_peer) * bins; + } ml_peer_hash; + + qdf_spinlock_t ml_peer_hash_lock; +}; + +/** + * dp_mlo_ctx_to_cdp() - typecast dp mlo context to CDP context + * @mlo_ctxt: DP MLO context + * + * Return: struct cdp_mlo_ctxt pointer + */ +static inline +struct cdp_mlo_ctxt *dp_mlo_ctx_to_cdp(struct dp_mlo_ctxt *mlo_ctxt) +{ + return (struct cdp_mlo_ctxt *)mlo_ctxt; +} + +/** + * cdp_mlo_ctx_to_dp() - typecast cdp_soc_t to + * dp soc handle + * @psoc: CDP psoc handle + * + * Return: struct dp_soc pointer + */ +static inline +struct dp_mlo_ctxt *cdp_mlo_ctx_to_dp(struct cdp_mlo_ctxt *mlo_ctxt) +{ + return (struct dp_mlo_ctxt *)mlo_ctxt; +} +#endif /* __DP_MLO_H */ diff --git a/dp/wifi3.0/dp_types.h b/dp/wifi3.0/dp_types.h index 2fd41f253b..3437fb9ae3 100644 --- a/dp/wifi3.0/dp_types.h +++ b/dp/wifi3.0/dp_types.h @@ -2213,6 +2213,7 @@ struct dp_soc { /* flag to indicate vote for runtime_pm for high tput castt*/ qdf_atomic_t rtpm_high_tput_flag; #endif + qdf_atomic_t ref_count; }; #ifdef IPA_OFFLOAD diff --git a/umac/cmn_services/obj_mgr/inc/wlan_objmgr_global_obj.h b/umac/cmn_services/obj_mgr/inc/wlan_objmgr_global_obj.h index 58a7b318fe..c391d7e9db 100644 --- a/umac/cmn_services/obj_mgr/inc/wlan_objmgr_global_obj.h +++ b/umac/cmn_services/obj_mgr/inc/wlan_objmgr_global_obj.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2016-2019, 2021 The Linux Foundation. All rights reserved. + * Copyright (c) 2021 Qualcomm Innovation Center, Inc. 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 @@ -556,6 +557,21 @@ struct mlo_mgr_context *wlan_objmgr_get_mlo_ctx(void); * Return: None */ void wlan_objmgr_set_mlo_ctx(struct mlo_mgr_context *ctx); + +/** + * wlan_objmgr_set_dp_mlo_ctx() - set dp handle in mlo context + * @dp_handle: Data path module handle + * + * Return: void + */ +void wlan_objmgr_set_dp_mlo_ctx(void *dp_handle); + +/** + * wlan_objmgr_get_dp_mlo_ctx() - get dp handle from mlo_context + * + * Return: dp handle + */ +void *wlan_objmgr_get_dp_mlo_ctx(void); #else static inline struct mlo_mgr_context *wlan_objmgr_get_mlo_ctx(void) { @@ -564,6 +580,15 @@ static inline struct mlo_mgr_context *wlan_objmgr_get_mlo_ctx(void) static inline void wlan_objmgr_set_mlo_ctx(struct mlo_mgr_context *ctx) {} + +static inline void *wlan_objmgr_get_dp_mlo_ctx(void) +{ + return NULL; +} + +static inline void wlan_objmgr_set_dp_mlo_ctx(void *dp_handle) +{ +} #endif /* WLAN_FEATURE_11BE_MLO */ #endif /* _WLAN_OBJMGR_GLOBAL_OBJ_H_*/ diff --git a/umac/cmn_services/obj_mgr/src/wlan_objmgr_global_obj.c b/umac/cmn_services/obj_mgr/src/wlan_objmgr_global_obj.c index 681d3800a5..7ce612ae78 100644 --- a/umac/cmn_services/obj_mgr/src/wlan_objmgr_global_obj.c +++ b/umac/cmn_services/obj_mgr/src/wlan_objmgr_global_obj.c @@ -878,4 +878,28 @@ void wlan_objmgr_set_mlo_ctx(struct mlo_mgr_context *ctx) { g_umac_glb_obj->mlo_ctx = ctx; } + +void wlan_objmgr_set_dp_mlo_ctx(void *dp_handle) +{ + struct mlo_mgr_context *mlo_ctx = wlan_objmgr_get_mlo_ctx(); + + if (!mlo_ctx) + return; + + mlo_ctx->dp_handle = dp_handle; +} + +qdf_export_symbol(wlan_objmgr_set_dp_mlo_ctx); + +void *wlan_objmgr_get_dp_mlo_ctx(void) +{ + struct mlo_mgr_context *mlo_ctx = wlan_objmgr_get_mlo_ctx(); + + if (!mlo_ctx) + return NULL; + + return mlo_ctx->dp_handle; +} + +qdf_export_symbol(wlan_objmgr_get_dp_mlo_ctx); #endif diff --git a/umac/mlo_mgr/inc/wlan_mlo_mgr_cmn.h b/umac/mlo_mgr/inc/wlan_mlo_mgr_cmn.h index 01ee4ba9c1..3607df7654 100644 --- a/umac/mlo_mgr/inc/wlan_mlo_mgr_cmn.h +++ b/umac/mlo_mgr/inc/wlan_mlo_mgr_cmn.h @@ -287,6 +287,7 @@ struct hw_link_id_iterator { struct wlan_objmgr_pdev * wlan_mlo_get_pdev_by_hw_link_id(uint16_t hw_link_id, wlan_objmgr_ref_dbgid refdbgid); + #else static inline struct wlan_objmgr_pdev * wlan_mlo_get_pdev_by_hw_link_id(uint16_t hw_link_id, diff --git a/umac/mlo_mgr/inc/wlan_mlo_mgr_public_structs.h b/umac/mlo_mgr/inc/wlan_mlo_mgr_public_structs.h index 01394239ea..2cc315e298 100644 --- a/umac/mlo_mgr/inc/wlan_mlo_mgr_public_structs.h +++ b/umac/mlo_mgr/inc/wlan_mlo_mgr_public_structs.h @@ -79,6 +79,7 @@ struct mlo_setup_info { * @msgq_ctx: Context switch mgr * @mlo_is_force_primary_umac: Force Primary UMAC enable * @mlo_forced_primary_umac_id: Force Primary UMAC ID + * @dp_handle: pointer to DP ML context */ struct mlo_mgr_context { #ifdef WLAN_MLO_USE_SPINLOCK @@ -98,6 +99,7 @@ struct mlo_mgr_context { struct ctxt_switch_mgr *msgq_ctx; bool mlo_is_force_primary_umac; uint8_t mlo_forced_primary_umac_id; + void *dp_handle; }; /*