/*--------------------------------------------------------------------------- wpalPacketGetLength – Get number of bytes in a wpt_packet. It include the bytes in a BD if it exist. Param: pPkt - pointer to a packet to be freed. Return: Length of the data include layer-2 headers. For example, if the frame is 802.3, the length includes the ethernet header. ---------------------------------------------------------------------------*/ wpt_uint32 wpalPacketGetLength(wpt_packet *pPkt) { v_U16_t len = 0, pktLen = 0; // Validate the parameter pointers if (unlikely(NULL == pPkt)) { WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_ERROR, "%s : NULL packet pointer", __func__); return eWLAN_PAL_STATUS_E_INVAL; } if( WPAL_PACKET_GET_BD_POINTER(pPkt) ) { len = WPAL_PACKET_GET_BD_LENGTH(pPkt); } if( VOS_IS_STATUS_SUCCESS(vos_pkt_get_packet_length(WPAL_TO_VOS_PKT(pPkt), &pktLen)) ) { len += pktLen; } else { WPAL_TRACE(eWLAN_MODULE_PAL, eWLAN_PAL_TRACE_LEVEL_ERROR, "%s failed", __func__); } return ((wpt_uint32)len); }/*wpalPacketGetLength*/
void WDI_DS_PrepareBDHeader (wpt_packet* palPacket, wpt_uint8 ucDisableHWFrmXtl, wpt_uint8 alignment) { void* pvBDHeader; wpt_uint8 ucHeaderOffset; wpt_uint8 ucHeaderLen; wpt_uint8 ucQosEnabled; wpt_uint8 ucWDSEnabled; wpt_uint32 ucMpduLen; wpt_uint32 ucPktLen; WDI_DS_TxMetaInfoType *pTxMetadata; pvBDHeader = WPAL_PACKET_GET_BD_POINTER(palPacket); pTxMetadata = WDI_DS_ExtractTxMetaData(palPacket); ucQosEnabled = pTxMetadata->qosEnabled; ucWDSEnabled = pTxMetadata->fenableWDS; WPAL_PACKET_SET_BD_LENGTH(palPacket, WDI_TX_BD_HEADER_SIZE); if ( ucDisableHWFrmXtl ) { ucHeaderOffset = WDI_TX_BD_HEADER_SIZE; ucHeaderLen = WDI_802_11_HEADER_LEN; if ( 0 != ucQosEnabled ) { ucHeaderLen += WDI_802_11_HEADER_QOS_CTL; } if ( 0 != ucWDSEnabled) { ucHeaderLen += WDI_802_11_HEADER_ADDR4_LEN; } } else { ucHeaderOffset = WDI_TX_BD_HEADER_SIZE+WDI_802_11_MAX_HEADER_LEN; ucHeaderLen = WDI_802_3_HEADER_LEN; } WDI_TX_BD_SET_MPDU_HEADER_LEN( pvBDHeader, ucHeaderLen); WDI_TX_BD_SET_MPDU_HEADER_OFFSET( pvBDHeader, ucHeaderOffset); WDI_TX_BD_SET_MPDU_DATA_OFFSET( pvBDHeader, ucHeaderOffset + ucHeaderLen + alignment); ucPktLen = wpalPacketGetLength( palPacket ); ucMpduLen = ucPktLen - WPAL_PACKET_GET_BD_LENGTH( palPacket ); WDI_TX_BD_SET_MPDU_LEN( pvBDHeader, ucMpduLen ); DTI_TRACE( DTI_TRACE_LEVEL_INFO, "WLAN DTI: VALUES ARE HLen=%x Hoff=%x doff=%x len=%x ex=%d", ucHeaderLen, ucHeaderOffset, (ucHeaderOffset + ucHeaderLen + alignment), pTxMetadata->fPktlen, alignment); }
/*========================================================================== * FUNCTION WDI_DS_PrepareBDHeader DESCRIPTION function for preparing BD header before HAL processing. PARAMETERS IN palPacket: PAL packet pointer RETURN VALUE No return. SIDE EFFECTS ============================================================================*/ void WDI_DS_PrepareBDHeader (wpt_packet* palPacket, wpt_uint8 ucDisableHWFrmXtl, wpt_uint8 alignment) { void* pvBDHeader; wpt_uint8 ucHeaderOffset; wpt_uint8 ucHeaderLen; wpt_uint8 ucQosEnabled; wpt_uint8 ucWDSEnabled; wpt_uint32 ucMpduLen; wpt_uint32 ucPktLen; WDI_DS_TxMetaInfoType *pTxMetadata; /* Extract reuqired information from Metadata */ pvBDHeader = WPAL_PACKET_GET_BD_POINTER(palPacket); pTxMetadata = WDI_DS_ExtractTxMetaData(palPacket); ucQosEnabled = pTxMetadata->qosEnabled; ucWDSEnabled = pTxMetadata->fenableWDS; WPAL_PACKET_SET_BD_LENGTH(palPacket, WDI_TX_BD_HEADER_SIZE); /*--------------------------------------------------------------------- Fill MPDU info fields: - MPDU data start offset - MPDU header start offset - MPDU header length - MPDU length - this is a 16b field - needs swapping --------------------------------------------------------------------*/ if ( ucDisableHWFrmXtl ) { ucHeaderOffset = WDI_TX_BD_HEADER_SIZE; ucHeaderLen = WDI_802_11_HEADER_LEN; if ( 0 != ucQosEnabled ) { ucHeaderLen += WDI_802_11_HEADER_QOS_CTL; } if ( 0 != ucWDSEnabled) { ucHeaderLen += WDI_802_11_HEADER_ADDR4_LEN; } } else { ucHeaderOffset = WDI_TX_BD_HEADER_SIZE+WDI_802_11_MAX_HEADER_LEN; ucHeaderLen = WDI_802_3_HEADER_LEN; } WDI_TX_BD_SET_MPDU_HEADER_LEN( pvBDHeader, ucHeaderLen); WDI_TX_BD_SET_MPDU_HEADER_OFFSET( pvBDHeader, ucHeaderOffset); WDI_TX_BD_SET_MPDU_DATA_OFFSET( pvBDHeader, ucHeaderOffset + ucHeaderLen + alignment); // pkt length from PAL API. Need to change in case of HW FT used ucPktLen = wpalPacketGetLength( palPacket ); // This includes BD length /** This is the length (in number of bytes) of the entire MPDU (header and data). Note that the length INCLUDES FCS field. */ ucMpduLen = ucPktLen - WPAL_PACKET_GET_BD_LENGTH( palPacket ); WDI_TX_BD_SET_MPDU_LEN( pvBDHeader, ucMpduLen ); DTI_TRACE( DTI_TRACE_LEVEL_INFO, "WLAN DTI: VALUES ARE HLen=%x Hoff=%x doff=%x len=%x ex=%d", ucHeaderLen, ucHeaderOffset, (ucHeaderOffset + ucHeaderLen + alignment), pTxMetadata->fPktlen, alignment); }/* WDI_DS_PrepareBDHeader */