Home | History | Annotate | Download | only in Data_link
      1 /*
      2  * TrafficMonitor.h
      3  *
      4  * Copyright(c) 1998 - 2009 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 /*        MODULE:       TrafficMonitor.h                                    */
     38 /*    PURPOSE:  TrafficMonitor module Header file                           */
     39 /*                                                                          */
     40 /***************************************************************************/
     41 #ifndef _TRAFFIC_MONITOR_H
     42 #define _TRAFFIC_MONITOR_H
     43 
     44 
     45 #include "tidef.h"
     46 #include "GeneralUtilApi.h"
     47 #include "TrafficMonitorAPI.h"
     48 
     49 /* time interval to load for the down limit alert Timer *
     50  *(TrafficMonitor_t->TrafficMonTimer)                   */
     51 #define MIN_MONITOR_INTERVAL  50 /*mSec*/
     52 
     53 /*The max number of Alert Element that the traffic monitor will be able to Manage.*/
     54 #define MAX_MONITORED_REQ     32
     55 
     56 /* The max number of Alert element that can                *
     57  * be associated to other alert element for reset condition*/
     58 #define MAX_RST_ELMENT_PER_ALERT 3
     59 
     60 /* BW Window in MS. changing this number must take NUM_OF_SLIDING_WINDOWS into consideration  */
     61 #define BW_WINDOW_MS			1000
     62 
     63 #define NUM_OF_SLIDING_WINDOWS 8							/* Must be power of 2 !!!							 */
     64 #define CYCLIC_COUNTER_ELEMENT (NUM_OF_SLIDING_WINDOWS - 1)	/* Note that it is aligned to NUM_OF_SLIDING_WINDOWS */
     65 
     66 #define SIZE_OF_WINDOW_MS	   ( BW_WINDOW_MS / NUM_OF_SLIDING_WINDOWS) /* 125 Ms */
     67 
     68 /* BandWidth_t
     69 	This struct is used for the sliding windows algorithm used to calculate the band width */
     70 typedef struct
     71 {
     72     TI_UINT32           uCurrentWindow;
     73     TI_UINT32           auFirstEventsTS[NUM_OF_SLIDING_WINDOWS];
     74     TI_UINT32           auWindowCounter[NUM_OF_SLIDING_WINDOWS];
     75 }BandWidth_t;
     76 
     77 
     78 /* The traffic manger class structure */
     79 typedef struct
     80 {
     81     TI_BOOL             Active;
     82     TI_HANDLE           NotificationRegList;
     83 
     84     TI_HANDLE           hOs;
     85     TI_HANDLE           hTimer;
     86     TI_HANDLE           hRxData;
     87     TI_HANDLE           hTxCtrl;
     88 
     89     TI_HANDLE           TxRegReqHandle;
     90     TI_HANDLE           RxRegReqHandle;
     91 
     92     BandWidth_t         DirectTxFrameBW;
     93     BandWidth_t         DirectRxFrameBW;
     94 
     95     TI_UINT8		    trafficDownTestIntervalPercent;	/* Percentage of max down events test interval     */
     96                                                         /*to use in our "traffic down" timer               */
     97     TI_BOOL             DownTimerEnabled;	/* Indicates whether the "down traffic" timer is active or not */
     98 
     99     TI_HANDLE           hTrafficMonTimer;
    100 
    101 }TrafficMonitor_t;
    102 
    103 
    104 /* Function definition that used for event Aggregation/filtering/etc.. */
    105 typedef void (*TraffActionFunc_t)(TI_HANDLE TraffElem,int Count);
    106 
    107 /* This enum holds the event providers that are optional in the system */
    108 typedef enum
    109 {
    110         TX_TRAFF_MODULE                                 = 0,
    111         RX_TRAFF_MODULE                         = 1,
    112     MAX_NUM_MONITORED_MODULES  /* Don't move this enum this index defines the
    113                                   number of module that can be monitored.*/
    114 }MonModuleTypes_t;
    115 
    116 
    117 
    118 /*
    119  *      Alert State option enum
    120  *  0.  disabled
    121  *  1.  ON but not active
    122  *  2.  ON and active
    123  */
    124 typedef enum {
    125     ALERT_WAIT_FOR_RESET = 0,          /* Event has been triggered, awaiting reset event to occur */
    126         ALERT_OFF,
    127     ALERT_ON
    128 }TraffAlertState_t;
    129 
    130 
    131 /* Basic Alert element structure */
    132 typedef struct AlertElement_t
    133 {
    134     /*initial param*/
    135     TraffAlertState_t   CurrentState;
    136     int                             EventCounter;
    137     int                             Threshold;
    138     TI_UINT32                              TimeOut;
    139     TraffDirection_t    Direction;
    140     TraffTrigger_t      Trigger;
    141     TI_BOOL                Enabled;
    142     int                             LastCounte;
    143         TraffEevntCall_t        CallBack;
    144     TI_HANDLE           Context ;
    145     TI_UINT32              Cookie;
    146     TI_UINT32              TimeIntervalMs;
    147     TI_BOOL                AutoCreated;
    148     TI_BOOL                RstWasAssigned;
    149     TraffActionFunc_t   ActionFunc;
    150     TI_UINT32              MonitorMask[MAX_NUM_MONITORED_MODULES];
    151     struct AlertElement_t  *ResetElment[MAX_RST_ELMENT_PER_ALERT];
    152 }TrafficAlertElement_t;
    153 
    154 #endif
    155