Home | History | Annotate | Download | only in Slave_Dbl_Buf
      1 /****************************************************************************
      2 **+-----------------------------------------------------------------------+**
      3 **|                                                                       |**
      4 **| Copyright(c) 1998 - 2008 Texas Instruments. All rights reserved.      |**
      5 **| All rights reserved.                                                  |**
      6 **|                                                                       |**
      7 **| Redistribution and use in source and binary forms, with or without    |**
      8 **| modification, are permitted provided that the following conditions    |**
      9 **| are met:                                                              |**
     10 **|                                                                       |**
     11 **|  * Redistributions of source code must retain the above copyright     |**
     12 **|    notice, this list of conditions and the following disclaimer.      |**
     13 **|  * Redistributions in binary form must reproduce the above copyright  |**
     14 **|    notice, this list of conditions and the following disclaimer in    |**
     15 **|    the documentation and/or other materials provided with the         |**
     16 **|    distribution.                                                      |**
     17 **|  * Neither the name Texas Instruments nor the names of its            |**
     18 **|    contributors may be used to endorse or promote products derived    |**
     19 **|    from this software without specific prior written permission.      |**
     20 **|                                                                       |**
     21 **| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS   |**
     22 **| "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT     |**
     23 **| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |**
     24 **| A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT  |**
     25 **| OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |**
     26 **| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT      |**
     27 **| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |**
     28 **| DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |**
     29 **| THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT   |**
     30 **| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |**
     31 **| OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  |**
     32 **|                                                                       |**
     33 **+-----------------------------------------------------------------------+**
     34 ****************************************************************************/
     35 
     36 /***************************************************************************/
     37 /*                                                                         */
     38 /*    MODULE:   txXfer.h                                                   */
     39 /*    PURPOSE:  Tx-Xfer module Header file - slave-mode, double-buffer     */
     40 /*                                                                         */
     41 /***************************************************************************/
     42 #ifndef _TX_XFER_H_
     43 #define _TX_XFER_H_
     44 
     45 
     46 #include "TNETW_Driver_types.h"
     47 
     48 
     49 #define MAX_XFER_BUFFERS                2       /* The number of frames that can be handled in
     50                                                     the XFER module at a time. */
     51 #define TX_STATUS_DATA_OUT_COUNT_MASK   0x000F  /* Tx status register mask of the FW counter of
     52                                                     packets copied from its Tx double buffer. */
     53 #define ALIGN_32BIT_MASK                0x3     /* Masked LS bits for 32 bit aligned addresses or lengths.*/
     54 
     55 
     56 typedef enum
     57 {
     58     TX_XFER_STATE_IDLE,
     59     TX_XFER_STATE_WAIT_BUS,
     60     TX_XFER_STATE_WAIT_HW_BUFFER,
     61     TX_XFER_STATE_WAIT_XFER_DONE,
     62     TX_XFER_STATE_WAIT_TRIGGER_DONE
     63 } TxXferState_e;
     64 
     65 
     66 /* Callback function definition for Tx sendPacketTranfer */
     67 typedef void (* SendPacketTranferCB_t)(TI_HANDLE CBObj, txCtrlBlkEntry_t *pPktCtrlBlk);
     68 typedef void (* SendPacketDebugCB_t)  (TI_HANDLE CBObj, txCtrlBlkEntry_t *pPktCtrlBlk, UINT32 uDebugInfo);
     69 
     70 
     71 /* The TxXfer module object. */
     72 typedef struct
     73 {
     74     TI_HANDLE  hOs;
     75     TI_HANDLE  hReport;
     76     TI_HANDLE  hTNETWIF;
     77     TI_HANDLE  hTxResult;
     78 
     79     UINT32 numBufferedPkts; /* The number of packets buffered in the Xfer module (0, 1 or 2). */
     80     BOOL xferDonePostponed; /* Indicates if postponed the last Xfer-Done event to the upper driver. */
     81     BOOL syncXferIndication; /* Cleared once the sendPkt sequence is broken to Async mode. */
     82     TxXferState_e txXferState; /* The current state of the Xfer state machine. */
     83     txCtrlBlkEntry_t *pPktCtrlBlk[MAX_XFER_BUFFERS]; /* The pointers to the transfered packets ctrl-blk. */
     84     UINT32 dataInCount;  /* The number of packets transfered to FW modulu 16. */
     85     SendPacketTranferCB_t sendPacketTransferCB; /* Xfer-Done callback */
     86     TI_HANDLE sendPacketTransferHandle;         /* Xfer-Done callback handle */
     87     SendPacketDebugCB_t sendPacketDebugCB;      /* Xfer-Debug callback */
     88     TI_HANDLE sendPacketDebugHandle;            /* Xfer-Debug callback handle */
     89     UINT32 dblBufAddr[DP_TX_PACKET_RING_CHUNK_NUM];  /* The HW Tx double buffer. */
     90     UINT32 txPathStatusAddr;  /* The HW Tx status register address. */
     91 
     92     /* use a struct to read buffers from the bus - used for extra bytes reserving */
     93     PADDING (UINT32 hwTxPathStatusRead) /* Saves the last read from the HW Tx-Path-Status. */
     94 
     95     /*Error handling*/
     96     failureEventCB_t        failureEventFunc;   /* upper layer Failure Event CB.                                            * called when the scan command has been Timer Expiry*/
     97     TI_HANDLE           failureEventObj;    /* object parameter passed to the failureEventFunc when it is called */
     98 
     99     UINT32 hwStatusReadLoopCount; /* Count loops of HW status polling to detect endless loop. */
    100     UINT32 timeToTxStuckMs;       /* The time (in msec) from first attempt to get a HW buffer status
    101                                     until recovery is triggered */
    102     UINT32 TimeStampFirstHwBufferRead;
    103                                     /* Time stamp at the first attempt to read the HW buffer status */
    104     BOOL   bRecovery;             /* Recovery indicator */
    105 
    106 #ifdef TI_DBG  /* Debug Counters */
    107     UINT32 hwBufferReadCount;     /* Count total number of HW-Tx-Status Reads. */
    108     UINT32 hwBufferFullCount;     /* Count total number of status reads where the HW Xfer buffers were full. */
    109     UINT32 sendPacketCount;       /* Count number of SendPacket calls from upper driver. */
    110     UINT32 busStartSyncCount;     /* Count number of calls to arbiter bus Start request returned Complete. */
    111     UINT32 busStartAsyncCount;    /* Count number of calls to arbiter bus Start request returned Pending. */
    112     UINT32 pktTransferSyncCount;  /* Count number of transfered packets in sync mode. */
    113     UINT32 pktTransferAsyncCount; /* Count number of transfered packets in sync mode. */
    114     UINT32 busRestartCount;       /* Count number of calls to arbiter bus Restart request. */
    115     UINT32 xferDonePostponeCount; /* Count number of postponed XferDone calls. */
    116     UINT32 xferDoneSyncCount;     /* Count number of XferDone synchronous event. */
    117     UINT32 xferDoneCallCBCount;   /* Count number of XferDone synchronous event. */
    118 #endif
    119 
    120 } txXferObj_t;
    121 
    122 
    123 
    124 /* Local function definitions */
    125 static void         xferStateMachine(TI_HANDLE hTxXfer, UINT8 module_id, TI_STATUS status);
    126 static UINT32       hwBuffersOccupied(txXferObj_t *pTxXfer);
    127 static TI_STATUS    transferPacket(txXferObj_t *pTxXfer);
    128 
    129 
    130 
    131 #endif  /* _TX_XFER_H_ */
    132 
    133 
    134 
    135