int epping_wlan_startup(struct device *parent_dev, v_VOID_t *hif_sc)
{
    int ret = 0;
    epping_context_t *pEpping_ctx = NULL;
    VosContextType *pVosContext = NULL;
    HTC_INIT_INFO  htcInfo;
    struct ol_softc *scn;
    tSirMacAddr adapter_macAddr;
    adf_os_device_t adf_ctx;

    EPPING_LOG(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Enter", __func__);

    pVosContext = vos_get_global_context(VOS_MODULE_ID_SYS, NULL);

    if(pVosContext == NULL)
    {
        EPPING_LOG(VOS_TRACE_LEVEL_FATAL,
                   "%s: Failed vos_get_global_context", __func__);
        ret = -1;
        return ret;
    }

    pEpping_ctx = vos_get_context(VOS_MODULE_ID_HDD, pVosContext);
    if(pEpping_ctx == NULL)
    {
        EPPING_LOG(VOS_TRACE_LEVEL_FATAL,
                   "%s: Failed to get pEpping_ctx", __func__);
        ret = -1;
        return ret;
    }
    pEpping_ctx->parent_dev = (void *)parent_dev;
    epping_get_dummy_mac_addr(adapter_macAddr);

    ((VosContextType*)pVosContext)->pHIFContext = hif_sc;

    /* store target type and target version info in hdd ctx */
    pEpping_ctx->target_type = ((struct ol_softc *)hif_sc)->target_type;

    /* Initialize the timer module */
    vos_timer_module_init();

    scn = vos_get_context(VOS_MODULE_ID_HIF, pVosContext);
    if (!scn) {
        VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
                  "%s: scn is null!", __func__);
        return -1;
    }
    scn->enableuartprint = 0;
    scn->enablefwlog     = 0;

    /* Initialize BMI and Download firmware */
    if (bmi_download_firmware(scn)) {
        VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
                  "%s: BMI failed to download target", __func__);
        BMICleanup(scn);
        return -1;
    }

    EPPING_LOG(VOS_TRACE_LEVEL_INFO_HIGH,
               "%s: bmi_download_firmware done", __func__);

    htcInfo.pContext = pVosContext->pHIFContext;
    htcInfo.TargetFailure = ol_target_failure;
    htcInfo.TargetSendSuspendComplete = epping_target_suspend_acknowledge;
    adf_ctx = vos_get_context(VOS_MODULE_ID_ADF, pVosContext);

    /* Create HTC */
    pVosContext->htc_ctx = HTCCreate(htcInfo.pContext, &htcInfo, adf_ctx);
    if (!pVosContext->htc_ctx) {
        VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
                  "%s: Failed to Create HTC", __func__);
        BMICleanup(scn);
        return -1;
    }
    pEpping_ctx->HTCHandle = vos_get_context(VOS_MODULE_ID_HTC, pVosContext);
    if (pEpping_ctx->HTCHandle == NULL) {
        EPPING_LOG(VOS_TRACE_LEVEL_FATAL,
                   "%s: HTCHandle is NULL", __func__);
        return -1;
    }
    scn->htc_handle = pEpping_ctx->HTCHandle;

    HIFClaimDevice(scn->hif_hdl, scn);

    if (bmi_done(scn)) {
        EPPING_LOG(VOS_TRACE_LEVEL_FATAL,
                   "%s: Failed to complete BMI phase", __func__);
        goto error_end;
    }
    /* start HIF */
    if (HTCWaitTarget(scn->htc_handle) != A_OK) {
        EPPING_LOG(VOS_TRACE_LEVEL_FATAL,
                   "%s: HTCWaitTarget error", __func__);
        goto error_end;
    }
    EPPING_LOG(VOS_TRACE_LEVEL_INFO_HIGH,
               "%s: HTC ready", __func__);

    ret = epping_connect_service(pEpping_ctx);
    if (ret != 0) {
        EPPING_LOG(VOS_TRACE_LEVEL_FATAL,
                   "%s: HTCWaitTargetdone", __func__);
        goto error_end;
    }
    if (HTCStart(pEpping_ctx->HTCHandle) != A_OK) {
        goto error_end;
    }
    EPPING_LOG(VOS_TRACE_LEVEL_INFO_HIGH,
               "%s: HTC started", __func__);

    /* init the tx cookie resource */
    ret = epping_cookie_init(pEpping_ctx);
    if (ret == 0) {
        pEpping_ctx->epping_adapter = epping_add_adapter(pEpping_ctx,
                                      adapter_macAddr,
                                      WLAN_HDD_INFRA_STATION);
    }
    if (ret < 0 || pEpping_ctx->epping_adapter == NULL) {
        EPPING_LOG(VOS_TRACE_LEVEL_FATAL,
                   "%s: epping_add_adaptererror error", __func__);
        HTCStop(pEpping_ctx->HTCHandle);
        epping_cookie_cleanup(pEpping_ctx);
        goto error_end;
    }
#ifdef HIF_PCI
    {
        int i;
        for (i = 0; i < EPPING_MAX_NUM_EPIDS; i++) {
            epping_register_tx_copier(i, pEpping_ctx);
        }
    }
#endif /* HIF_PCI */
    EPPING_LOG(VOS_TRACE_LEVEL_INFO_HIGH, "%s: Exit", __func__);
    complete(&pEpping_ctx->wlan_start_comp);
    return ret;

error_end:
    HTCDestroy(pVosContext->htc_ctx);
    pVosContext->htc_ctx = NULL;
    BMICleanup(scn);
    return -1;
}
Exemple #2
0
VOS_STATUS vos_open( v_CONTEXT_t *pVosContext, v_SIZE_t hddContextSize )

{
   VOS_STATUS vStatus      = VOS_STATUS_SUCCESS;
   int iter                = 0;
   tSirRetStatus sirStatus = eSIR_SUCCESS;
   tMacOpenParameters macOpenParms;
   WLANTL_ConfigInfoType TLConfig;

   VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
               "%s: Opening VOSS", __func__);

   if (NULL == gpVosContext)
   {
      VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
                    "%s: Trying to open VOSS without a PreOpen", __func__);
      VOS_ASSERT(0);
      return VOS_STATUS_E_FAILURE;
   }

   
   vos_timer_module_init();


   
   if (vos_event_init(&gpVosContext->ProbeEvent) != VOS_STATUS_SUCCESS)
   {
      VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
                    "%s: Unable to init probeEvent", __func__);
      VOS_ASSERT(0);
      return VOS_STATUS_E_FAILURE;
   }
   if (vos_event_init( &(gpVosContext->wdaCompleteEvent) ) != VOS_STATUS_SUCCESS )
   {
      VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
                  "%s: Unable to init wdaCompleteEvent", __func__);
      VOS_ASSERT(0);
    
      goto err_probe_event;
   }

   
   vStatus = vos_mq_init(&gpVosContext->freeVosMq);
   if (! VOS_IS_STATUS_SUCCESS(vStatus))
   {

      
      VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
                "%s: Failed to initialize VOS free message queue", __func__);
      VOS_ASSERT(0);
      goto err_wda_complete_event;
   }

   for (iter = 0; iter < VOS_CORE_MAX_MESSAGES; iter++)
   {
      (gpVosContext->aMsgWrappers[iter]).pVosMsg = 
         &(gpVosContext->aMsgBuffers[iter]); 
      INIT_LIST_HEAD(&gpVosContext->aMsgWrappers[iter].msgNode);
      vos_mq_put(&gpVosContext->freeVosMq, &(gpVosContext->aMsgWrappers[iter]));
   }

   
   vStatus= vos_sched_open(gpVosContext, &gpVosContext->vosSched,
                           sizeof(VosSchedContext));

   if (!VOS_IS_STATUS_SUCCESS(vStatus))
   {
      
      VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
                "%s: Failed to open VOS Scheduler", __func__);
      VOS_ASSERT(0);
      goto err_msg_queue;
   }


   
   vos_mem_set(&macOpenParms, sizeof(macOpenParms), 0);
   macOpenParms.frameTransRequired = 1;
   macOpenParms.driverType         = eDRIVER_TYPE_PRODUCTION;
   vStatus = WDA_open( gpVosContext, gpVosContext->pHDDContext, &macOpenParms );

   if (!VOS_IS_STATUS_SUCCESS(vStatus))
   {
      
      VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
                "%s: Failed to open WDA module", __func__);
      VOS_ASSERT(0);
      goto err_sched_close;
   }

   
   vStatus = vos_packet_open( gpVosContext, &gpVosContext->vosPacket,
                              sizeof( vos_pkt_context_t ) );

   if ( !VOS_IS_STATUS_SUCCESS( vStatus ) )
   {
      
      VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
                "%s: Failed to open VOS Packet Module", __func__);
      VOS_ASSERT(0);
      goto err_wda_close;
   }

   
   vStatus = sysOpen(gpVosContext);

   if (!VOS_IS_STATUS_SUCCESS(vStatus))
   {
      
      VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
                "%s: Failed to open SYS module", __func__);
      VOS_ASSERT(0);
      goto err_packet_close;
   }

#ifndef CONFIG_ENABLE_LINUX_REG
   
   vStatus = vos_nv_open();
   if (!VOS_IS_STATUS_SUCCESS(vStatus))
   {
     
     VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
                "%s: Failed to initialize the NV module", __func__);
     goto err_sys_close;
   }
#endif

   
   
   

   macOpenParms.frameTransRequired = 1;
   sirStatus = macOpen(&(gpVosContext->pMACContext), gpVosContext->pHDDContext,
                         &macOpenParms);
   
   if (eSIR_SUCCESS != sirStatus)
   {
     
     VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
               "%s: Failed to open MAC", __func__);
     VOS_ASSERT(0);
     goto err_nv_close;
   }

   
   vStatus = sme_Open(gpVosContext->pMACContext);
   if (!VOS_IS_STATUS_SUCCESS(vStatus))
   {
     
     VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
               "%s: Failed to open SME", __func__);
     VOS_ASSERT(0);
     goto err_mac_close;
   }

   
   vos_fetch_tl_cfg_parms ( &TLConfig, 
       ((hdd_context_t*)(gpVosContext->pHDDContext))->cfg_ini);

   vStatus = WLANTL_Open(gpVosContext, &TLConfig);
   if (!VOS_IS_STATUS_SUCCESS(vStatus))
   {
     
     VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_FATAL,
               "%s: Failed to open TL", __func__);
     VOS_ASSERT(0);
     goto err_sme_close;
   }

   VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO_HIGH,
               "%s: VOSS successfully Opened", __func__);

   *pVosContext = gpVosContext;

   return VOS_STATUS_SUCCESS;


err_sme_close:
   sme_Close(gpVosContext->pMACContext);

err_mac_close:
   macClose(gpVosContext->pMACContext);

err_nv_close:

#ifndef CONFIG_ENABLE_LINUX_REG
   vos_nv_close();

err_sys_close:
#endif

   sysClose(gpVosContext);

err_packet_close:
   vos_packet_close( gpVosContext );

err_wda_close:
   WDA_close(gpVosContext);

err_sched_close:
   vos_sched_close(gpVosContext);


err_msg_queue:
   vos_mq_deinit(&gpVosContext->freeVosMq);

err_wda_complete_event:
   vos_event_destroy( &gpVosContext->wdaCompleteEvent );

err_probe_event:
   vos_event_destroy(&gpVosContext->ProbeEvent);

   return VOS_STATUS_E_FAILURE;

}