Example #1
0
ssize_t ar6000_htc_raw_read(AR_SOFTC_T *ar, HTC_RAW_STREAM_ID StreamID, 
                            char __user *buffer, size_t length)
{
    int readPtr;
    raw_htc_buffer *busy;

    if (arRawStream2EndpointID(ar,StreamID) == 0) {
        AR_DEBUG_PRINTF("StreamID(%d) not connected! \n", StreamID);
        return -EFAULT;    
    }
    
    if (down_interruptible(&ar->raw_htc_read_sem[StreamID])) {
        return -ERESTARTSYS;
    }

    busy = get_filled_buffer(ar,StreamID);
    while (!ar->read_buffer_available[StreamID]) {
        up(&ar->raw_htc_read_sem[StreamID]);

        /* Wait for the data */
        AR_DEBUG2_PRINTF("Sleeping StreamID(%d) read process\n", StreamID);
        if (wait_event_interruptible(ar->raw_htc_read_queue[StreamID],
                                     ar->read_buffer_available[StreamID]))
        {
            return -EINTR;
        }
        if (down_interruptible(&ar->raw_htc_read_sem[StreamID])) {
            return -ERESTARTSYS;
        }
        busy = get_filled_buffer(ar,StreamID);
    }

    /* Read the data */
    readPtr = busy->currPtr;
    if (length > busy->length - HTC_HEADER_LEN) {
        length = busy->length - HTC_HEADER_LEN;
    }
    if (copy_to_user(buffer, &busy->data[readPtr], length)) {
        up(&ar->raw_htc_read_sem[StreamID]);
        return -EFAULT;
    }

    busy->currPtr += length;
    
    //AR_DEBUG_PRINTF("raw read ioctl:  currPTR : 0x%X 0x%X \n", busy->currPtr,busy->length);
    
    if (busy->currPtr == busy->length)
    {    
        busy->currPtr = 0;
        busy->length = 0;        
        HTC_PACKET_RESET_RX(&busy->HTCPacket);                                          
        //AR_DEBUG_PRINTF("raw read ioctl:  ep for packet:%d \n", busy->HTCPacket.Endpoint);
        HTCAddReceivePkt(ar->arHtcTarget, &busy->HTCPacket);
    }
    ar->read_buffer_available[StreamID] = FALSE;
    up(&ar->raw_htc_read_sem[StreamID]);

    return length;
}
Example #2
0
void
CAR6KMini::ReceiveWMIDataPacket(HTC_PACKET *pHTCPacket)
//
//  This function processes data from an HTC_BUFFER_RECEIVED indication
//  not on the WMI_CONTROL_MBOX endpoint.
//
{
    ndis_mini_buf_t *pb = (ndis_mini_buf_t *)pHTCPacket->pPktContext;
    NDIS_STATUS      Status;
    NDIS_PACKET     *pPacket;
    NDIS_BUFFER     *pBuffer;
    PBYTE            pData;
    ULONG            cbData;
    BOOL             doDix = FALSE;
    USHORT           etherType;
    SNAP_HEADER      *pSnapHdr;
    MAC_ADDRESS      *pDestAddr,*tempAddr,*pSrcAddr;
    BOOL             mcForUs = FALSE;
    BOOL             bisAPUnicast = FALSE;
    A_UINT8          userPriority=0;
    STATION          *Station = NULL;

    UINT32           *magic;
    A_UINT16         powState = 0;
    A_UINT8          buf[512];
    BYTE  stationaddr[ETHERNET_MAC_ADDRESS_LENGTH];

    NDIS_DEBUG_PRINTF(ATH_LOG_TRC | ATH_DEBUG_RECV, "AR6K: +ReceiveWMIDataPacket");


    if (pHTCPacket->Status != A_OK) {
        NDIS_DEBUG_PRINTF(ATH_LOG_ERR, "AR6K: ERROR - ReceiveWMIPacket Error in receiving : Status = %x\n", pHTCPacket->Status);
        HTC_PACKET_RESET_RX(pHTCPacket);
        HTCAddReceivePkt(m_pHTCTarget, pHTCPacket);
        goto done;
    }

    // evInfo->actualLength is the length of the pb->data including
    //      2 bytes: WMI_DATA_HEADER [optional - only if HTC header is 46 00]
    //     14 bytes: 802.3 MAC header
    //      8 bytes: SNAP header (with EthType as last 2 bytes)
    //      N bytes: payload (e.g. IP packet)
    pData = pHTCPacket->pBuffer;
    cbData = pHTCPacket->ActualLength;

    if(AP_NETWORK == m_networkType) {
            powState = (((WMI_DATA_HDR *)pData)->info >> WMI_DATA_HDR_PS_SHIFT) & WMI_DATA_HDR_PS_MASK;
    }