Ejemplo n.º 1
0
void sendDataPacket (TI_HANDLE hOs)
{
    TI_UINT32       i;
	TTxCtrlBlk *    pPktCtrlBlk;
    TI_UINT8 *      pPktBuf;
    TEthernetHeader tEthHeader;
	char SrcBssid[6] = {0x88,0x88,0x88,0x88,0x88,0x88};
	char DesBssid[6] = {0x22,0x22,0x22,0x22,0x22,0x22};

	/* Allocate a TxCtrlBlk for the Tx packet and save timestamp, length and packet handle */
    pPktCtrlBlk = TWD_txCtrlBlk_Alloc (tmp_hTWD);

	if( NULL == pPktCtrlBlk )
	{
        os_printf("\n sendDataPacket() : pPktCtrlBlk returned as NULL from TWD_txCtrlBlk_Alloc() ");
        return;
	}

    pPktCtrlBlk->tTxDescriptor.startTime = os_timeStampMs (hOs);
    pPktCtrlBlk->tTxDescriptor.length    = (TI_UINT16)packetLength + ETHERNET_HDR_LEN;
    pPktCtrlBlk->tTxDescriptor.tid       = 0;
    pPktCtrlBlk->tTxPktParams.uPktType   = TX_PKT_TYPE_ETHER;

    /* Allocate buffer with headroom for getting the IP header in a 4-byte aligned address */
    pPktBuf = txCtrl_AllocPacketBuffer (tmp_hTxCtrl, pPktCtrlBlk, packetLength + ETHERNET_HDR_LEN + 2);

    /* Prepare Ethernet header */
    tEthHeader.type = HTOWLANS(ETHERTYPE_IP);
    MAC_COPY (tEthHeader.src, SrcBssid);
    MAC_COPY (tEthHeader.dst, DesBssid);

	if( pPktBuf )
	{
	    os_memoryCopy (hOs, pPktBuf + 2, &tEthHeader, ETHERNET_HDR_LEN);

        /* Build BDL */
        BUILD_TX_TWO_BUF_PKT_BDL (pPktCtrlBlk,
                                  pPktBuf + 2,
                                  ETHERNET_HDR_LEN,
                                  pPktBuf + 2 + ETHERNET_HDR_LEN,
                                  packetLength)

        /* Fill data buffer with incremented numbers */
        for (i = 0; i < packetLength; i++)
        {
            *(pPktBuf + 2 + ETHERNET_HDR_LEN + i) = i;
        }
	}
	else
	{
Ejemplo n.º 2
0
/****************************************************************************************
 *                               dummyPktReqCB                                          *
 ****************************************************************************************
DESCRIPTION: Callback for the TWD_OWN_EVENT_DUMMY_PKT_REQ event - transmits a dummy
             packet

INPUT:      - hTxMgmtQ      - Handle to the TxMgmtQ module
            - str			- Buffer containing the event data
            - strLen        - Event data length
OUTPUT:
RETURN:    void.\n
****************************************************************************************/
void dummyPktReqCB(TI_HANDLE hTxMgmtQ, char* str , TI_UINT32 strLen)
{
	TTxMgmtQ *pTxMgmtQ = (TTxMgmtQ*)hTxMgmtQ;
    TTxCtrlBlk* pTxCtrlBlk;
    void* pPayload;
    const TI_UINT16 uDummyPktBufLen = 1400;
    TI_STATUS status;

    /* Allocate control block for dummy packet */
    pTxCtrlBlk = TWD_txCtrlBlk_Alloc(pTxMgmtQ->hTWD);
    if (NULL == pTxCtrlBlk) {
        TRACE0(pTxMgmtQ->hReport, REPORT_SEVERITY_ERROR, "dummyPktReqCB: TxCtrlBlk allocation failed!\n");
        return;
    }

    /* Allocate payload buffer */
    pPayload  = txCtrl_AllocPacketBuffer(pTxMgmtQ->hTxCtrl, pTxCtrlBlk, WLAN_HDR_LEN + uDummyPktBufLen);
    if (NULL == pPayload)
    {
        TRACE0(pTxMgmtQ->hReport, REPORT_SEVERITY_ERROR, "dummyPktReqCB: Packet buffer allocation failed!\n");
        TWD_txCtrlBlk_Free (pTxMgmtQ->hTWD, pTxCtrlBlk);
        return;
    }

	/* Set packet parameters */
    {
		pTxCtrlBlk->tTxDescriptor.startTime = os_timeStampMs(pTxMgmtQ->hOs);

		/* Mark as a Dummy Blocks Packet */
		pTxCtrlBlk->tTxPktParams.uPktType = TX_PKT_TYPE_DUMMY_BLKS;

		BUILD_TX_TWO_BUF_PKT_BDL (pTxCtrlBlk, pTxCtrlBlk->aPktHdr, WLAN_HDR_LEN, pPayload, uDummyPktBufLen);
    }

    pTxMgmtQ->tDbgCounters.uDummyPackets++;

    /* Enqueue packet in the management-queues and run the scheduler. */
    status = txMgmtQ_Xmit(pTxMgmtQ, pTxCtrlBlk, TI_FALSE);

    if (TI_NOK == status)
    {
        TRACE0(pTxMgmtQ->hReport, REPORT_SEVERITY_ERROR, "dummyPktReqCB: xmit failed!\n");
    }
}
/** 
 * \fn     wlanDrvIf_Xmit
 * \brief  Packets transmission
 * 
 * The network stack calls this function in order to transmit a packet
 *     through the WLAN interface.
 * The packet is inserted to the drver Tx queues and its handling is continued
 *     after switching to the driver context.
 *
 * \note   
 * \param  skb - The Linux packet buffer structure
 * \param  dev - The driver network-interface handle
 * \return 0 (= OK)
 * \sa     
 */ 
static int wlanDrvIf_Xmit (struct sk_buff *skb, struct net_device *dev)
{
	TWlanDrvIfObj *drv = (TWlanDrvIfObj *)NETDEV_GET_PRIVATE(dev);
	TTxCtrlBlk *  pPktCtrlBlk;
	int status;

	CL_TRACE_START_L1();

	os_profile (drv, 0, 0);
	drv->stats.tx_packets++;
	drv->stats.tx_bytes += skb->len;

	/* Allocate a TxCtrlBlk for the Tx packet and save timestamp, length and packet handle */
	pPktCtrlBlk = TWD_txCtrlBlk_Alloc (drv->tCommon.hTWD);

	pPktCtrlBlk->tTxDescriptor.startTime    = os_timeStampMs(drv); /* remove use of skb->tstamp.off_usec */
	pPktCtrlBlk->tTxDescriptor.length       = skb->len;
	pPktCtrlBlk->tTxPktParams.pInputPkt     = skb;

	/* Point the first BDL buffer to the Ethernet header, and the second buffer to the rest of the packet */
	pPktCtrlBlk->tTxnStruct.aBuf[0] = skb->data;
	pPktCtrlBlk->tTxnStruct.aLen[0] = ETHERNET_HDR_LEN;
	pPktCtrlBlk->tTxnStruct.aBuf[1] = skb->data + ETHERNET_HDR_LEN;
	pPktCtrlBlk->tTxnStruct.aLen[1] = (TI_UINT16)skb->len - ETHERNET_HDR_LEN;
	pPktCtrlBlk->tTxnStruct.aLen[2] = 0;

	/* Send the packet to the driver for transmission. */
	status = txDataQ_InsertPacket (drv->tCommon.hTxDataQ, pPktCtrlBlk,(TI_UINT8)skb->priority);

	/* If failed (queue full or driver not running), drop the packet. */
    if (status != TI_OK)
    {
        drv->stats.tx_errors++;
    }
	os_profile (drv, 1, 0);

	CL_TRACE_END_L1("tiwlan_drv.ko", "OS", "TX", "");

	return 0;
}
Ejemplo n.º 4
0
TI_STATUS mlmeBuilder_sendFrame(TI_HANDLE hMlme, 
							 dot11MgmtSubType_e type, 
							 TI_UINT8   *pDataBuff, 
							 TI_UINT32  dataLen,
							 TI_UINT8	setWepOpt)
{
	mlme_t			*pHandle = (mlme_t*)hMlme;
	TI_STATUS		status;
    TTxCtrlBlk      *pPktCtrlBlk;
    TI_UINT8        *pPktBuffer;
	TMacAddr		daBssid, saBssid;
	dot11_mgmtHeader_t	*pDot11Header;

	/* Allocate a TxCtrlBlk and data buffer (large enough for the max management packet) */
    pPktCtrlBlk = TWD_txCtrlBlk_Alloc (pHandle->hTWD);
	if (pPktCtrlBlk == NULL)
		return TI_NOK;

    pPktBuffer  = txCtrl_AllocPacketBuffer (pHandle->hTxCtrl, 
                                            pPktCtrlBlk, 
                                            MAX_MANAGEMENT_FRAME_BODY_LEN + WLAN_HDR_LEN);
    if (pPktBuffer == NULL)
    {
        TRACE0(pHandle->hReport, REPORT_SEVERITY_ERROR , ": No memory\n");
        TWD_txCtrlBlk_Free (pHandle->hTWD, pPktCtrlBlk);
        return TI_NOK;
    }
	
	pDot11Header = (dot11_mgmtHeader_t *)(pPktCtrlBlk->aPktHdr);

	status = mlmeBuilder_buildFrameCtrl (pHandle, type, (TI_UINT16 *)&pDot11Header->fc, setWepOpt);
	if (status != TI_OK)
	{
        txCtrl_FreePacket (pHandle->hTxCtrl, pPktCtrlBlk, TI_NOK);
		return TI_NOK;
	}

    status = ctrlData_getParamBssid(pHandle->hCtrlData, CTRL_DATA_CURRENT_BSSID_PARAM, daBssid);
	if (status != TI_OK)
	{
        txCtrl_FreePacket (pHandle->hTxCtrl, pPktCtrlBlk, TI_NOK);
		return TI_NOK;
	}

	/* copy destination mac address */
	MAC_COPY (pDot11Header->DA, daBssid);

    status = ctrlData_getParamMacAddr(pHandle->hCtrlData, saBssid);
	if (status != TI_OK)
	{
        txCtrl_FreePacket (pHandle->hTxCtrl, pPktCtrlBlk, TI_NOK);
		return TI_NOK;
	}

	/* copy source mac address */
	MAC_COPY (pDot11Header->SA, saBssid);

	/* copy BSSID (destination mac address) */
	MAC_COPY (pDot11Header->BSSID, daBssid);

	if (pDataBuff != NULL)
	{
		os_memoryCopy (pHandle->hOs, pPktBuffer, pDataBuff, dataLen);
	}

    /* Update packet parameters (start-time, length, pkt-type) */
    pPktCtrlBlk->tTxDescriptor.startTime = os_timeStampMs (pHandle->hOs);
    pPktCtrlBlk->tTxPktParams.uPktType   = TX_PKT_TYPE_MGMT;
    BUILD_TX_TWO_BUF_PKT_BDL (pPktCtrlBlk, (TI_UINT8 *)pDot11Header, WLAN_HDR_LEN, pPktBuffer, dataLen)

	/* Enqueue packet in the mgmt-queues and run the scheduler. */
	status = txMgmtQ_Xmit (pHandle->hTxMgmtQ, pPktCtrlBlk, TI_FALSE);

	return status;
}
Ejemplo n.º 5
0
static int xmit_Bridge (struct sk_buff *skb, struct net_device *dev, TIntraBssBridge *pBssBridgeParam)
{
    TWlanDrvIfObj *drv = (TWlanDrvIfObj *)NETDEV_GET_PRIVATE(dev);
    TTxCtrlBlk *  pPktCtrlBlk;
    TEthernetHeader *pEthHead = (TEthernetHeader *)(skb->data);
    int status;

    CL_TRACE_START_L1();

    os_profile (drv, 0, 0);
    drv->stats.tx_packets++;
    drv->stats.tx_bytes += skb->len;

    /* Allocate a TxCtrlBlk for the Tx packet and save timestamp, length and packet handle */
    pPktCtrlBlk = TWD_txCtrlBlk_Alloc (drv->tCommon.hTWD);
    if (pPktCtrlBlk == NULL)
    {
        drv->stats.tx_errors++;
        os_profile (drv, 1, 0);
        CL_TRACE_END_L1("tiwlan_drv.ko", "OS", "TX", "");
        return 0;
    }

    /* Set interface type according to net device interface number */
    if (drv->tCommon.eIfRole == IF_ROLE_TYPE_AP) 
        SET_PKT_TYPE_IF_ROLE_AP(pPktCtrlBlk);
    else
        SET_PKT_TYPE_IF_ROLE_STA(pPktCtrlBlk);
    pPktCtrlBlk->tTxDescriptor.startTime    = os_timeStampMs(drv); /* remove use of skb->tstamp.off_usec */
    pPktCtrlBlk->tTxDescriptor.length       = skb->len;
    pPktCtrlBlk->tTxPktParams.pInputPkt     = skb;

    /* Check MGMT packet from hostapd, forward it to the Mgmt-Queue and exit without ethernet header */
    if (HTOWLANS(pEthHead->type) == AP_MGMT_ETH_TYPE)
    {
        /* Copy WLAN header into aPktHdr - format for MGMT packets */
        memcpy (pPktCtrlBlk->aPktHdr, skb->data + ETHERNET_HDR_LEN , WLAN_HDR_LEN );

        /* Skip ethernet header, send as management frame */
        pPktCtrlBlk->tTxPktParams.uPktType = TX_PKT_TYPE_MGMT;
        pPktCtrlBlk->tTxnStruct.aBuf[0] = (TI_UINT8 *)pPktCtrlBlk->aPktHdr;
        pPktCtrlBlk->tTxnStruct.aLen[0] = WLAN_HDR_LEN;
        pPktCtrlBlk->tTxnStruct.aBuf[1] = skb->data + ETHERNET_HDR_LEN + WLAN_HDR_LEN;
        pPktCtrlBlk->tTxnStruct.aLen[1] = (TI_UINT16)skb->len - ETHERNET_HDR_LEN - WLAN_HDR_LEN;
        pPktCtrlBlk->tTxnStruct.aLen[2] = 0;
        pPktCtrlBlk->tTxPktParams.uInputPktLen = skb->len;
        pPktCtrlBlk->tTxDescriptor.length = (TI_UINT16)((pPktCtrlBlk->tTxnStruct.aLen[0]) + (pPktCtrlBlk->tTxnStruct.aLen[1]));

        status = txMgmtQ_Xmit (drv->tCommon.hTxMgmtQ, pPktCtrlBlk, TI_TRUE);
    }
    else

    {
    /* Point the first BDL buffer to the Ethernet header, and the second buffer to the rest of the packet */
    pPktCtrlBlk->tTxnStruct.aBuf[0] = skb->data;
    pPktCtrlBlk->tTxnStruct.aLen[0] = ETHERNET_HDR_LEN;
    pPktCtrlBlk->tTxnStruct.aBuf[1] = skb->data + ETHERNET_HDR_LEN;
    pPktCtrlBlk->tTxnStruct.aLen[1] = (TI_UINT16)skb->len - ETHERNET_HDR_LEN;
    pPktCtrlBlk->tTxnStruct.aLen[2] = 0;

    /* Send the packet to the driver for transmission. */
    status = txDataQ_InsertPacket (drv->tCommon.hTxDataQ, pPktCtrlBlk,(TI_UINT8)skb->priority, pBssBridgeParam);
    }

    /* If failed (queue full or driver not running), drop the packet. */
    if (status != TI_OK)
    {
        drv->stats.tx_errors++;
    }
    os_profile (drv, 1, 0);

    CL_TRACE_END_L1("tiwlan_drv.ko", "OS", "TX", "");

    return 0;
}