void * wmi_unified_attach(ol_scn_t scn_handle, wma_wow_tx_complete_cbk func) { struct wmi_unified *wmi_handle; wmi_handle = (struct wmi_unified *)OS_MALLOC(NULL, sizeof(struct wmi_unified), GFP_ATOMIC); if (wmi_handle == NULL) { printk("allocation of wmi handle failed %zu \n", sizeof(struct wmi_unified)); return NULL; } OS_MEMZERO(wmi_handle, sizeof(struct wmi_unified)); wmi_handle->scn_handle = scn_handle; adf_os_atomic_init(&wmi_handle->pending_cmds); adf_os_atomic_init(&wmi_handle->is_target_suspended); #ifdef FEATURE_RUNTIME_PM adf_os_atomic_init(&wmi_handle->runtime_pm_inprogress); #endif adf_os_spinlock_init(&wmi_handle->eventq_lock); adf_nbuf_queue_init(&wmi_handle->event_queue); #ifdef CONFIG_CNSS cnss_init_work(&wmi_handle->rx_event_work, wmi_rx_event_work); #else INIT_WORK(&wmi_handle->rx_event_work, wmi_rx_event_work); #endif #ifdef WMI_INTERFACE_EVENT_LOGGING adf_os_spinlock_init(&wmi_handle->wmi_record_lock); #endif wmi_handle->wma_wow_tx_complete_cbk = func; return wmi_handle; }
ieee80211_resmgr_t ol_resmgr_create(struct ieee80211com *ic, ieee80211_resmgr_mode mode) { struct ol_ath_softc_net80211 *scn = OL_ATH_SOFTC_NET80211(ic); ieee80211_resmgr_t resmgr; printk("OL Resmgr Init-ed\n"); if (ic->ic_resmgr) { printk("%s : ResMgr already exists \n", __func__); return NULL; } /* Allocate ResMgr data structures */ resmgr = (ieee80211_resmgr_t) adf_os_mem_alloc(scn->adf_dev, sizeof(struct ieee80211_resmgr)); if (resmgr == NULL) { printk("%s : ResMgr memory alloction failed\n", __func__); return NULL; } OS_MEMZERO(resmgr, sizeof(struct ieee80211_resmgr)); resmgr->ic = ic; resmgr->mode = mode; /* Indicate the device is capable of multi-chan operation*/ ic->ic_caps_ext |= IEEE80211_CEXT_MULTICHAN; /* initialize function pointer table */ resmgr->resmgr_func_table.resmgr_create_complete = _ieee80211_resmgr_create_complete; resmgr->resmgr_func_table.resmgr_delete = _ieee80211_resmgr_delete; resmgr->resmgr_func_table.resmgr_delete_prepare = _ieee80211_resmgr_delete_prepare; resmgr->resmgr_func_table.resmgr_register_notification_handler = _ieee80211_resmgr_register_notification_handler; resmgr->resmgr_func_table.resmgr_unregister_notification_handler = _ieee80211_resmgr_unregister_notification_handler; resmgr->resmgr_func_table.resmgr_request_offchan = _ieee80211_resmgr_request_offchan; resmgr->resmgr_func_table.resmgr_request_bsschan = _ieee80211_resmgr_request_bsschan; resmgr->resmgr_func_table.resmgr_request_chanswitch = _ieee80211_resmgr_request_chanswitch; resmgr->resmgr_func_table.resmgr_vap_start = _ieee80211_resmgr_vap_start; resmgr->resmgr_func_table.resmgr_vattach = _ieee80211_resmgr_vattach; resmgr->resmgr_func_table.resmgr_vdetach = _ieee80211_resmgr_vdetach; resmgr->resmgr_func_table.resmgr_get_notification_type_name = _ieee80211_resmgr_get_notification_type_name; resmgr->resmgr_func_table.resmgr_register_noa_event_handler = _ieee80211_resmgr_register_noa_event_handler; resmgr->resmgr_func_table.resmgr_unregister_noa_event_handler = _ieee80211_resmgr_unregister_noa_event_handler; resmgr->resmgr_func_table.resmgr_off_chan_sched_set_air_time_limit = _ieee80211_resmgr_off_chan_sched_set_air_time_limit; resmgr->resmgr_func_table.resmgr_off_chan_sched_get_air_time_limit = _ieee80211_resmgr_off_chan_sched_get_air_time_limit; resmgr->resmgr_func_table.resmgr_vap_stop = _ieee80211_resmgr_vap_stop; adf_os_spinlock_init(&resmgr->rm_lock); adf_os_spinlock_init(&resmgr->rm_handler_lock); /* Register WMI event handlers */ wmi_unified_register_event_handler(scn->wmi_handle, WMI_VDEV_START_RESP_EVENTID, ol_vdev_wmi_event_handler, resmgr); return resmgr; }
/* registered target arrival callback from the HIF layer */ HTC_HANDLE HTCCreate(void *hHIF, HTC_INIT_INFO *pInfo) { A_STATUS status = A_OK; HTC_TARGET *target = NULL; do { if ((target = (HTC_TARGET *)A_MALLOC(sizeof(HTC_TARGET))) == NULL) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("HTC : Unable to allocate memory\n")); status = A_ERROR; break; } A_MEMCPY(&target->HTCInitInfo,pInfo,sizeof(HTC_INIT_INFO)); adf_os_mem_zero(target, sizeof(HTC_TARGET)); adf_os_spinlock_init(&target->HTCLock); adf_os_spinlock_init(&target->HTCRxLock); adf_os_spinlock_init(&target->HTCTxLock); /* setup HIF layer callbacks */ adf_os_mem_zero(&htcCallbacks, sizeof(completion_callbacks_t)); htcCallbacks.Context = target; htcCallbacks.rxCompletionHandler = HTCRxCompletionHandler; htcCallbacks.txCompletionHandler = HTCTxCompletionHandler; HIFPostInit(hHIF, target, &htcCallbacks); target->hif_dev = hHIF; adf_os_init_mutex(&target->htc_rdy_mutex); adf_os_mutex_acquire(&target->htc_rdy_mutex); /* Get HIF default pipe for HTC message exchange */ pEndpoint = &target->EndPoint[ENDPOINT0]; HIFGetDefaultPipe(hHIF, &pEndpoint->UL_PipeID, &pEndpoint->DL_PipeID); adf_os_print("[Default Pipe]UL: %x, DL: %x\n", pEndpoint->UL_PipeID, pEndpoint->DL_PipeID); /* TODO : other init */ } while (FALSE); target->host_handle = htcInfo.pContext; /* TODO INTEGRATION supply from host os handle for any os specific calls*/ target->os_handle = NULL; if (A_FAILED(status)) { HTCCleanup(target); target = NULL; } return (HTC_HANDLE)target; }
int epping_cookie_init(epping_context_t*pEpping_ctx) { A_UINT32 i, j; pEpping_ctx->cookie_list = NULL; pEpping_ctx->cookie_count = 0; for (i = 0; i < MAX_COOKIE_SLOTS_NUM; i++) { pEpping_ctx->s_cookie_mem[i] = vos_mem_malloc(sizeof(struct epping_cookie)*MAX_COOKIE_SLOT_SIZE); if (pEpping_ctx->s_cookie_mem[i] == NULL) { EPPING_LOG(VOS_TRACE_LEVEL_FATAL, "%s: no mem for cookie (idx = %d)", __func__, i); goto error; } vos_mem_zero(pEpping_ctx->s_cookie_mem[i], sizeof(struct epping_cookie)*MAX_COOKIE_SLOT_SIZE); } adf_os_spinlock_init(&pEpping_ctx->cookie_lock); for (i = 0; i < MAX_COOKIE_SLOTS_NUM; i++) { struct epping_cookie *cookie_mem = pEpping_ctx->s_cookie_mem[i]; for (j = 0; j < MAX_COOKIE_SLOT_SIZE; j++) { epping_free_cookie(pEpping_ctx, &cookie_mem[j]); } } return 0; error: for (i = 0; i < MAX_COOKIE_SLOTS_NUM; i++) { if (pEpping_ctx->s_cookie_mem[i]) { vos_mem_free(pEpping_ctx->s_cookie_mem[i]); pEpping_ctx->s_cookie_mem[i] = NULL; } } return -ENOMEM; }
/* registered target arrival callback from the HIF layer */ HTC_HANDLE HTCCreate(void *hHIF, HTC_INIT_INFO *pInfo, adf_os_device_t osdev) { MSG_BASED_HIF_CALLBACKS htcCallbacks; HTC_ENDPOINT *pEndpoint=NULL; HTC_TARGET *target = NULL; int i; AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("+HTCCreate .. HIF :%p \n",hHIF)); A_REGISTER_MODULE_DEBUG_INFO(htc); if ((target = (HTC_TARGET *)A_MALLOC(sizeof(HTC_TARGET))) == NULL) { AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("HTC : Unable to allocate memory\n")); return NULL; } A_MEMZERO(target, sizeof(HTC_TARGET)); adf_os_spinlock_init(&target->HTCLock); adf_os_spinlock_init(&target->HTCRxLock); adf_os_spinlock_init(&target->HTCTxLock); do { A_MEMCPY(&target->HTCInitInfo,pInfo,sizeof(HTC_INIT_INFO)); target->host_handle = pInfo->pContext; target->osdev = osdev; ResetEndpointStates(target); INIT_HTC_PACKET_QUEUE(&target->ControlBufferTXFreeList); for (i = 0; i < HTC_PACKET_CONTAINER_ALLOCATION; i++) { HTC_PACKET *pPacket = (HTC_PACKET *)A_MALLOC(sizeof(HTC_PACKET)); if (pPacket != NULL) { A_MEMZERO(pPacket,sizeof(HTC_PACKET)); FreeHTCPacketContainer(target,pPacket); } } #ifdef TODO_FIXME for (i = 0; i < NUM_CONTROL_TX_BUFFERS; i++) { pPacket = BuildHTCTxCtrlPacket(); if (NULL == pPacket) { break; } HTCFreeControlTxPacket(target,pPacket); } #endif /* setup HIF layer callbacks */ A_MEMZERO(&htcCallbacks, sizeof(MSG_BASED_HIF_CALLBACKS)); htcCallbacks.Context = target; htcCallbacks.rxCompletionHandler = HTCRxCompletionHandler; htcCallbacks.txCompletionHandler = HTCTxCompletionHandler; htcCallbacks.txResourceAvailHandler = HTCTxResourceAvailHandler; htcCallbacks.fwEventHandler = HTCFwEventHandler; target->hif_dev = hHIF; /* Get HIF default pipe for HTC message exchange */ pEndpoint = &target->EndPoint[ENDPOINT_0]; HIFPostInit(hHIF, target, &htcCallbacks); HIFGetDefaultPipe(hHIF, &pEndpoint->UL_PipeID, &pEndpoint->DL_PipeID); } while (FALSE); HTCRecvInit(target); AR_DEBUG_PRINTF(ATH_DEBUG_INFO, ("-HTCCreate (0x%p) \n", target)); return (HTC_HANDLE)target; }
static int hif_usb_probe(struct usb_interface *interface, const struct usb_device_id *id) { int ret = 0; struct hif_usb_softc *sc; struct ol_softc *ol_sc; struct usb_device *pdev = interface_to_usbdev(interface); int vendor_id, product_id; pr_info("hif_usb_probe\n"); usb_get_dev(pdev); vendor_id = le16_to_cpu(pdev->descriptor.idVendor); product_id = le16_to_cpu(pdev->descriptor.idProduct); ret = 0; sc = A_MALLOC(sizeof(*sc)); if (!sc) { ret = -ENOMEM; goto err_alloc; } OS_MEMZERO(sc, sizeof(*sc)); sc->pdev = (void *)pdev; sc->dev = &pdev->dev; sc->aps_osdev.bdev = pdev; sc->aps_osdev.device = &pdev->dev; sc->aps_osdev.bc.bc_bustype = HAL_BUS_TYPE_AHB; sc->devid = id->idProduct; adf_os_spinlock_init(&sc->target_lock); ol_sc = A_MALLOC(sizeof(*ol_sc)); if (!ol_sc) goto err_attach; OS_MEMZERO(ol_sc, sizeof(*ol_sc)); ol_sc->sc_osdev = &sc->aps_osdev; ol_sc->hif_sc = (void *)sc; sc->ol_sc = ol_sc; if ((usb_control_msg(pdev, usb_sndctrlpipe(pdev, 0), USB_REQ_SET_CONFIGURATION, 0, 1, 0, NULL, 0, HZ)) < 0) { pr_info("%s[%d]\n\r", __func__, __LINE__); } usb_set_interface(pdev, 0, 0); if (hif_usb_configure(sc, &ol_sc->hif_hdl, interface)) goto err_config; ol_sc->enableuartprint = 1; ol_sc->enablefwlog = 0; ol_sc->enablesinglebinary = FALSE; ol_sc->max_no_of_peers = 1; init_waitqueue_head(&ol_sc->sc_osdev->event_queue); ret = hdd_wlan_startup(&pdev->dev, ol_sc); if (ret) { hif_nointrs(sc); if (sc->hif_device != NULL) { ((HIF_DEVICE_USB *)(sc->hif_device))->sc = NULL; } athdiag_procfs_remove(); goto err_config; } sc->hdd_removed = 0; sc->hdd_removed_processing = 0; sc->hdd_removed_wait_cnt = 0; #ifndef REMOVE_PKT_LOG if (vos_get_conparam() != VOS_FTM_MODE && !WLAN_IS_EPPING_ENABLED(vos_get_conparam())) { /* * pktlog initialization */ ol_pl_sethandle(&ol_sc->pdev_txrx_handle->pl_dev, ol_sc); if (pktlogmod_init(ol_sc)) pr_err("%s: pktlogmod_init failed\n", __func__); } #endif #ifdef WLAN_BTAMP_FEATURE /* Send WLAN UP indication to Nlink Service */ send_btc_nlink_msg(WLAN_MODULE_UP_IND, 0); #endif sc->interface = interface; sc->reboot_notifier.notifier_call = hif_usb_reboot; register_reboot_notifier(&sc->reboot_notifier); usb_sc = sc; return 0; err_config: A_FREE(ol_sc); err_attach: ret = -EIO; usb_sc = NULL; A_FREE(sc); err_alloc: usb_put_dev(pdev); return ret; }