//To reserve a vos_packet for Tx eapol frame
//If success, pPacket is the packet and pData points to the head.
static VOS_STATUS bapRsnAcquirePacket( vos_pkt_t **ppPacket, v_U8_t **ppData, v_U16_t size )
{
    VOS_STATUS status;
    vos_pkt_t *pPacket;

    status = vos_pkt_get_packet( &pPacket, VOS_PKT_TYPE_TX_802_11_MGMT, size, 1, 
                                    VOS_TRUE, NULL, NULL );
    if( VOS_IS_STATUS_SUCCESS( status ) )
    {
        status = vos_pkt_reserve_head( pPacket, (v_VOID_t **)ppData, size );
        if( !VOS_IS_STATUS_SUCCESS( status ) )
        {
            VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
                "bapRsnAcquirePacket failed to reserve size = %d\n", size );
            vos_pkt_return_packet( pPacket );
        }
        else
        {
            *ppPacket = pPacket;
        }
    }
    else
    {
        VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
                "bapRsnAcquirePacket failed to get vos_pkt\n" );
    }

    return ( status );
}
eHalStatus palPktAlloc(tHddHandle hHdd, eFrameType frmType, tANI_U16 size, void **data, void **ppPacket)
{
    eHalStatus halStatus = eHAL_STATUS_FAILURE;
    VOS_STATUS vosStatus;

    vos_pkt_t *pVosPacket;

    do
    {
        // we are only handling the 802_11_MGMT frame type for PE/LIM.  All other frame types should be
        // ported to use the VOSS APIs directly and should not be using this palPktAlloc API.
        VOS_ASSERT( HAL_TXRX_FRM_802_11_MGMT == frmType );

        if ( HAL_TXRX_FRM_802_11_MGMT != frmType ) break;

        // allocate one 802_11_MGMT VOS packet, zero the packet and fail the call if nothing is available.
        // if we cannot get this vos packet, fail.
        vosStatus = vos_pkt_get_packet( &pVosPacket, VOS_PKT_TYPE_TX_802_11_MGMT, size, 1, VOS_TRUE, NULL, NULL );
        if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) ) break;

        // Reserve the space at the head of the packet for the caller.  If we cannot reserve the space
        // then we have to fail (return the packet to voss first!)
        vosStatus = vos_pkt_reserve_head( pVosPacket, data, size );
        if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
        {
            vos_pkt_return_packet( pVosPacket );
            break;
        }

        // Everything went well if we get here.  Return the packet pointer to the caller and indicate
        // success to the caller.
        *ppPacket = (void *)pVosPacket;

        halStatus = eHAL_STATUS_SUCCESS;

    } while( 0 );

    return( halStatus );
}
Пример #3
0
eHalStatus palPktAlloc(tHddHandle hHdd, eFrameType frmType, tANI_U16 size, void **data, void **ppPacket)
{
   eHalStatus halStatus = eHAL_STATUS_FAILURE;
   VOS_STATUS vosStatus;
   
   vos_pkt_t *pVosPacket;
   
   do 
   {
      
      
      VOS_ASSERT( HAL_TXRX_FRM_802_11_MGMT == frmType );
    
      if ( HAL_TXRX_FRM_802_11_MGMT != frmType ) break;
   
      
      
      vosStatus = vos_pkt_get_packet( &pVosPacket, VOS_PKT_TYPE_TX_802_11_MGMT, size, 1, VOS_TRUE, NULL, NULL );
      if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) ) break;
      
      
      
      vosStatus = vos_pkt_reserve_head( pVosPacket, data, size );
      if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) ) 
      {
         vos_pkt_return_packet( pVosPacket );
         break;
      }
      
      
      
      *ppPacket = (void *)pVosPacket;
      
      halStatus = eHAL_STATUS_SUCCESS;
   
   } while( 0 );
   
   return( halStatus );
}
Пример #4
0
/*---------------------------------------------------------------------------
    wpalPacketAlloc – Allocate a wpt_packet from PAL.
    Param: 
        pktType – specify the type of wpt_packet to allocate
        nPktSize - packet size
    Return:
        A pointer to the wpt_packet. NULL means fail.
---------------------------------------------------------------------------*/
wpt_packet * wpalPacketAlloc(wpt_packet_type pktType, wpt_uint32 nPktSize,
                             wpalPacketLowPacketCB rxLowCB, void *usrData)
{
   VOS_STATUS   vosStatus = VOS_STATUS_E_FAILURE;
   wpt_packet*  pPkt      = NULL;
   vos_pkt_t*   pVosPkt   = NULL;
   void*        pData     = NULL;
   v_U16_t      allocLen;
   /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

   switch (pktType)
   {
   case eWLAN_PAL_PKT_TYPE_TX_802_11_MGMT:
      vosStatus = vos_pkt_get_packet(&pVosPkt, VOS_PKT_TYPE_TX_802_11_MGMT,
                                       nPktSize, 1, VOS_FALSE, 
                                       NULL, NULL /*no callback*/);
      break;

   case eWLAN_PAL_PKT_TYPE_RX_RAW:
      /* Set the wpalPacketAvailableCB before we try to get a VOS
       * packet from the 'free list' and reset it if vos_pkt_get_packet()
       * returns a valid packet. This order is required to avoid the
       * race condition:
       * 1. The below call to vos_pkt_get_packet() in RX_Thread determines
       *    that no more packets are available in the 'free list' and sets
       *    the low resource callbacks.
       * 2. in parallel vos_pkt_return_packet() is called in MC_Thread for a
       *    Management frame before wpalPacketAlloc() gets a chance to set
       *    wpalPacketAvailableCB and since the 'low resource callbacks'
       *    are set the callback function - wpalPacketRXLowResourceCB is
       *    executed,but since wpalPacketAvailableCB is still NULL the low
       *    resource recovery fails.
       */
      wpalPacketAvailableCB = rxLowCB;

      vosStatus = vos_pkt_get_packet(&pVosPkt, VOS_PKT_TYPE_RX_RAW,
                                       nPktSize, 1, VOS_FALSE, 
                                       wpalPacketRXLowResourceCB, usrData);

#ifndef FEATURE_R33D
      /* Reserve the entire raw rx buffer for DXE */
      if( vosStatus == VOS_STATUS_SUCCESS )
      {
        wpalPacketAvailableCB = NULL;
        vosStatus =  vos_pkt_reserve_head_fast( pVosPkt, &pData, nPktSize ); 
      }
#endif /* FEATURE_R33D */
      if((NULL != pVosPkt) && (VOS_STATUS_E_RESOURCES != vosStatus))
      {
         vos_pkt_get_packet_length(pVosPkt, &allocLen);
         if (nPktSize != allocLen)
         {
            WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_ERROR,
                       "RX packet alloc has problem, discard this frame, Len %d", allocLen);
            vos_pkt_return_packet(pVosPkt);
            return NULL;
         }
      }
      break;

   default:
      WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_ERROR, 
                  " try to allocate unsupported packet type (%d)", pktType);
      break;
   }

   if(VOS_IS_STATUS_SUCCESS(vosStatus))
   {
      pPkt = (wpt_packet *)pVosPkt;
   }


   return pPkt;
}/*wpalPacketAlloc*/
Пример #5
0
/*----------------------------------------------------------------------------
 * Function Declarations and Documentation
 * -------------------------------------------------------------------------*/
VOS_STATUS
WLANBAP_AcquireLSPacket( ptBtampContext pBtampCtx, vos_pkt_t **ppPacket, v_U16_t size, tANI_BOOLEAN isLsReq )
{
    VOS_STATUS vosStatus;
    vos_pkt_t *pPacket;
    WLANBAP_8023HeaderType   w8023Header;
    v_U8_t                   aucLLCHeader[WLANBAP_LLC_HEADER_LEN];
    v_U16_t                  headerLength;  /* The 802.3 frame length*/
    v_U16_t                  protoType;
    v_U8_t                   *pData = NULL;
     

    if(isLsReq)
    {
        protoType = WLANTL_BT_AMP_TYPE_LS_REQ;
    }
    else
    {
        protoType = WLANTL_BT_AMP_TYPE_LS_REP;
    }    

    //If success, vosTxLsPacket is the packet and pData points to the head.
   vosStatus = vos_pkt_get_packet( &pPacket, VOS_PKT_TYPE_TX_802_11_MGMT,size, 1, 
                                    VOS_TRUE, NULL, NULL );
   if( VOS_IS_STATUS_SUCCESS( vosStatus ) )
   {
       vosStatus = vos_pkt_reserve_head( pPacket, (v_VOID_t *)&pData, size );
       if( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
       {
                VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
                 "%s: failed to reserve size = %d\n",__FUNCTION__, size );
                 vos_pkt_return_packet( pPacket );
       }
   }

   if( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
   {
       VOS_TRACE( VOS_MODULE_ID_BAP, VOS_TRACE_LEVEL_ERROR,
                "WLANBAP_LinkSupervisionTimerHandler failed to get vos_pkt\n" );
       return vosStatus;
   }

         // Form the 802.3 header
   vos_mem_copy( w8023Header.vDA, pBtampCtx->peer_mac_addr, VOS_MAC_ADDR_SIZE);
   vos_mem_copy( w8023Header.vSA, pBtampCtx->self_mac_addr, VOS_MAC_ADDR_SIZE);

   headerLength = WLANBAP_LLC_HEADER_LEN;
        /* Now the 802.3 length field is big-endian?! */
   w8023Header.usLenType = vos_cpu_to_be16(headerLength); 
        
   /* Now adjust the protocol type bytes*/
   protoType = vos_cpu_to_be16( protoType);
         /* Now form the LLC header */
   vos_mem_copy(aucLLCHeader, 
            WLANBAP_LLC_HEADER,  
            sizeof(WLANBAP_LLC_HEADER));
   vos_mem_copy(&aucLLCHeader[WLANBAP_LLC_OUI_OFFSET], 
            WLANBAP_BT_AMP_OUI,  
            WLANBAP_LLC_OUI_SIZE);
   vos_mem_copy(&aucLLCHeader[WLANBAP_LLC_PROTO_TYPE_OFFSET], 
            &protoType,  //WLANBAP_BT_AMP_TYPE_LS_REQ
            WLANBAP_LLC_PROTO_TYPE_SIZE);
 
        /* Push on the LLC header */
   vos_pkt_push_head(pPacket, 
            aucLLCHeader, 
            WLANBAP_LLC_HEADER_LEN);  

        /* Push on the 802.3 header */
   vos_pkt_push_head(pPacket, &w8023Header, sizeof(w8023Header));
   *ppPacket = pPacket;
   return vosStatus;
}
wpt_packet * wpalPacketAlloc(wpt_packet_type pktType, wpt_uint32 nPktSize,
                             wpalPacketLowPacketCB rxLowCB, void *usrData)
{
   VOS_STATUS   vosStatus = VOS_STATUS_E_FAILURE;
   wpt_packet*  pPkt      = NULL;
   vos_pkt_t*   pVosPkt   = NULL;
   void*        pData     = NULL;
   v_U16_t      allocLen;
   /*                                                                      */

   switch (pktType)
   {
   case eWLAN_PAL_PKT_TYPE_TX_802_11_MGMT:
      vosStatus = vos_pkt_get_packet(&pVosPkt, VOS_PKT_TYPE_TX_802_11_MGMT,
                                       nPktSize, 1, VOS_FALSE, 
                                       NULL, NULL /*           */);
      break;

   case eWLAN_PAL_PKT_TYPE_RX_RAW:
      /*                                                         
                                                                         
                                                                    
                        
                                                                          
                                                                          
                                       
                                                                            
                                                                          
                                                                        
                                                                        
                                                                          
                                    
       */
      wpalPacketAvailableCB = rxLowCB;

      vosStatus = vos_pkt_get_packet(&pVosPkt, VOS_PKT_TYPE_RX_RAW,
                                       nPktSize, 1, VOS_FALSE, 
                                       wpalPacketRXLowResourceCB, usrData);

#ifndef FEATURE_R33D
      /*                                          */
      if( vosStatus == VOS_STATUS_SUCCESS )
      {
        wpalPacketAvailableCB = NULL;
        vosStatus =  vos_pkt_reserve_head_fast( pVosPkt, &pData, nPktSize ); 
      }
#endif /*              */
      if((NULL != pVosPkt) && (VOS_STATUS_E_RESOURCES != vosStatus))
      {
         vos_pkt_get_packet_length(pVosPkt, &allocLen);
         if (nPktSize != allocLen)
         {
            WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_ERROR,
                       "RX packet alloc has problem, discard this frame, Len %d", allocLen);
            vos_pkt_return_packet(pVosPkt);
            return NULL;
         }
      }
      break;

   default:
      WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_ERROR, 
                  " try to allocate unsupported packet type (%d)\n", pktType);
      break;
   }

   if(VOS_IS_STATUS_SUCCESS(vosStatus))
   {
      pPkt = (wpt_packet *)pVosPkt;
   }


   return pPkt;
}/*               */