/*===========================================================================
                    IMPORTANT NOTICE

                  OEM DISTRIBUTION ONLY

   Q O S S P E C   A P I   H E A D E R   F I L E
                   
DESCRIPTION

 The OEM Socket Quality of Service Specification Header File. 
 Contains declarations for Quality of Service OEM layer data structures.


        Copyright © 2000-2004 QUALCOMM Incorporated.
               All Rights Reserved.
            QUALCOMM Proprietary/GTDR
===========================================================================*/
#ifndef OEMSOCK_QOSSPEC_H
#define OEMSOCK_QOSSPEC_H


#include "AEE_OEMComdef.h"
#include "AEEComdef.h"
#include "AEEError.h"


/*===========================================================================

                      GLOBAL DATA DECLARATIONS

===========================================================================*/

/*---------------------------------------------------------------------------
  QoS general definitions
---------------------------------------------------------------------------*/

typedef uint32 oem_qos_handle_type;

/*---------------------------------------------------------------------------
  IP definitions
---------------------------------------------------------------------------*/

typedef enum
{
  OEM_IP_V4 = 4,
  OEM_IP_V6 = 6
} oem_ip_version_enum_type;

struct oem_in_addr
{
  uint32 s_addr;   /* socket address */
};

typedef enum
{
  OEM_IPPROTO_TCP          = 6,                                /* TCP Protocol */
  OEM_IPPROTO_UDP          = 17,                               /* UDP Protocol */
  OEM_NO_NEXT_HDR          = 59,
} oem_ip_protocol_enum_type;


/*---------------------------------------------------------------------------
  QoS flow definitions
---------------------------------------------------------------------------*/
typedef enum
{
  OEM_IP_TRF_CLASS_CONVERSATIONAL   = 0,
  OEM_IP_TRF_CLASS_STREAMING        = 1,
  OEM_IP_TRF_CLASS_INTERACTIVE      = 2,
  OEM_IP_TRF_CLASS_BACKGROUND       = 3
} oem_ip_traffic_class_enum_type;

typedef enum
{	
  OEM_UMTS_RES_BIT_ERR_RATE1        = 1,        /* 5*10-2 */
  OEM_UMTS_RES_BIT_ERR_RATE2        = 2,        /* 1*10-2 */
  OEM_UMTS_RES_BIT_ERR_RATE3        = 3,        /* 5*10-3 */
  OEM_UMTS_RES_BIT_ERR_RATE4        = 4,        /* 4*10-3 */
  OEM_UMTS_RES_BIT_ERR_RATE5        = 5,        /* 1*10-3 */
  OEM_UMTS_RES_BIT_ERR_RATE6        = 6,        /* 1*10-4 */
  OEM_UMTS_RES_BIT_ERR_RATE7        = 7,        /* 1*10-5 */
  OEM_UMTS_RES_BIT_ERR_RATE8        = 8,        /* 1*10-6 */
  OEM_UMTS_RES_BIT_ERR_RATE9        = 9,        /* 6*10-8 */
  OEM_UMTS_RES_BIT_ERR_RATE10       = 10        /* Reserved */
} oem_umts_residual_ber_enum_type;

typedef enum
{		
  OEM_UMTS_TRF_HANDLING_PRI1        = 1,        /* Priority Level 1 */
  OEM_UMTS_TRF_HANDLING_PRI2        = 2,        /* Priority Level 2 */
  OEM_UMTS_TRF_HANDLING_PRI3        = 3         /* Priority Level 3 */
} oem_umts_trf_handling_pri_enum_type;

typedef enum
{		
  OEM_CDMA_QOS_PROFILE_XXX          = 0x01               /* Profile 1 */
} oem_cdma_flow_spec_profile_id_type;

typedef enum
{
  OEM_IPFLOW_MASK_TRF_CLASS             = 0x00000001,
  OEM_IPFLOW_MASK_DATA_RATE             = 0x00000002,
  OEM_IPFLOW_MASK_LATENCY               = 0x00000004,
  OEM_IPFLOW_MASK_LATENCY_VAR           = 0x00000008,
  OEM_IPFLOW_MASK_PKT_ERR_RATE          = 0x00000010,
  OEM_IPFLOW_MASK_MIN_POLICED_PKT_SIZE  = 0x00000020,
  OEM_IPFLOW_MASK_MAX_ALLOWED_PKT_SIZE  = 0x00000040,
  OEM_IPFLOW_MASK_UMTS_RES_BER          = 0x00000080,
  OEM_IPFLOW_MASK_UMTS_TRF_PRI          = 0x00000100,
  OEM_IPFLOW_MASK_CDMA_PROFILE_ID       = 0x00000200
} oem_ipflow_field_mask_enum_type;

typedef uint32 oem_ipflow_field_mask_type;

typedef enum
{
  OEM_DATA_RATE_FORMAT_MIN_MAX_TYPE,
  OEM_DATA_RATE_FORMAT_TOKEN_BUCKET_TYPE
} oem_ipflow_data_rate_format_type;

typedef struct
{
  oem_ipflow_field_mask_type      field_mask;
  oem_ipflow_field_mask_type      err_mask;

  oem_ip_traffic_class_enum_type  trf_class;          /* TC */

  struct
  {
    oem_ipflow_data_rate_format_type  format_type;

    union
    {
      struct
      {
        uint32      max_rate;           /* bps, Rmax */
        uint32      guaranteed_rate;    /* bps, Rg */
      } min_max;
  
      struct
      {
        uint32      peak_rate;          /* bps, Rp */
        uint32      token_rate;         /* bps, Rb */
        uint32      size;               /* bytes, B */
      } token_bucket;
    } format;
  } data_rate;

  uint32        latency;            /* msec, L */
  uint32        latency_var;        /* msec, Lvar */

  struct                            /* ratio, Eper = m * 10 ** (-p) */
  {
    uint16      multiplier;         // Multiplication factor, m
    uint16      exponent;           // -ve of Base 10 exponent, p
  } pkt_err_rate;
        
  uint32      min_policed_pkt_size;   /* bytes, Smin */
  uint32      max_allowed_pkt_size;   /* bytes, Smax */

  /* 3GPP only QOS parameters */
  struct       
  {
    oem_umts_residual_ber_enum_type         res_ber;        /* Erber */
    oem_umts_trf_handling_pri_enum_type     trf_pri;        /* Ptrf */
  } umts_params;

  /* 3GPP2 only QOS parameters */
  struct
  {
    oem_cdma_flow_spec_profile_id_type  profile_id;     /* I */
  }	cdma_params;
} oem_ip_flow_type;


typedef struct
{
  oem_ip_flow_type      req_flow;       /* Required flow type           */
  oem_ip_flow_type      min_req_flow;   /* Minimum required flow type   */
} oem_ip_flow_spec_type;


/*---------------------------------------------------------------------------
  QoS filter definitions
---------------------------------------------------------------------------*/

/* IPV4 hdr fields */
typedef enum
{
  OEM_IPFLTR_MASK_IP4_SRC_ADDR      = 0x01,
  OEM_IPFLTR_MASK_IP4_DST_ADDR      = 0x02,
  OEM_IPFLTR_MASK_IP4_NEXT_HDR_PROT = 0x04,
  OEM_IPFLTR_MASK_IP4_TOS           = 0x08
} oem_ipfltr_ip4_hdr_field_mask_enum_type;


/* Higher level protocol hdr parameters */
 
/* TCP hdr fields */
typedef enum
{	
  OEM_IPFLTR_MASK_TCP_SRC_PORT      = 0x01,
  OEM_IPFLTR_MASK_TCP_DST_PORT      = 0x02
} oem_ipfltr_tcp_hdr_field_mask_enum_type;

/* UDP hdr fields */
typedef enum
{
  OEM_IPFLTR_MASK_UDP_SRC_PORT      = 0x01,
  OEM_IPFLTR_MASK_UDP_DST_PORT      = 0x02
} oem_ipfltr_udp_hdr_field_mask_enum_type;


typedef uint8 oem_ipfltr_ip4_hdr_field_mask_type;
typedef uint8 oem_ipfltr_tcp_hdr_field_mask_type;
typedef uint8 oem_ipfltr_udp_hdr_field_mask_type;

/*---------------------------------------------------------------------------
TYPEDEF IP_FILTER_TYPE

DESCRIPTION
  This data structure defines the IP filter parameters for an IP filter
  type.

  All the address/port number fields must be specified in network byte 
  order, everything else in host byte order.
  
  Rules:    

---------------------------------------------------------------------------*/
typedef struct
{
  /* Mandatory Parameter - IP version of the filter (v4 or v6)	*/
  oem_ip_version_enum_type  ip_vsn;

  /* Filter parameter values,  the ones set in field masks are only valid */
  /* Correspopnding err mask is set if a parameter value is invalid */
  union
  {
    struct
    {
      oem_ipfltr_ip4_hdr_field_mask_type      field_mask;  /* In mask   */
      oem_ipfltr_ip4_hdr_field_mask_type      err_mask;    /* Out mask  */

      struct
      {
        struct oem_in_addr  addr;
        struct oem_in_addr  subnet_mask;
      } src;

      struct
      {
        struct oem_in_addr  addr;
        struct oem_in_addr  subnet_mask;
      } dst;
      
      struct
      {
        uint8 val;
        uint8 mask;
      } tos;      
      
      uint8 next_hdr_prot;
    } v4;
  } ip_hdr;

  /* next_hdr_prot field in v4 or v6 hdr must be set to specify a    */
  /* parameter from the next_prot_hdr                                */
  union
  {
    struct
    {
      oem_ipfltr_tcp_hdr_field_mask_type      field_mask;  /* In mask   */
      oem_ipfltr_tcp_hdr_field_mask_type      err_mask;    /* Out mask  */

      struct
      {
        uint16    port;
        uint16    range;
      } src;
    
      struct
      {
        uint16    port;
        uint16    range;
      } dst;    
    } tcp;
    
    struct
    {
      oem_ipfltr_udp_hdr_field_mask_type      field_mask;  /* In mask   */
      oem_ipfltr_udp_hdr_field_mask_type      err_mask;    /* Out mask  */

      struct
      {
        uint16    port;
        uint16	  range;
      } src;
      
      struct
      {
        uint16    port;
        uint16    range;
      } dst;
    } udp;

  } next_prot_hdr;
} oem_ip_filter_type;

typedef struct
{
  uint8                  num_filters;      /* Num filters in the list     */
  oem_ip_filter_type    *list_ptr;         /* List of filters             */
} oem_ip_filter_spec_type;


/*---------------------------------------------------------------------------
  QoS Spec definitions
---------------------------------------------------------------------------*/

typedef enum 
{
  OEM_QOS_MASK_RX_FLOW      = 0x01,
  OEM_QOS_MASK_RX_MIN_FLOW  = 0x02,
  OEM_QOS_MASK_TX_FLOW      = 0x04,
  OEM_QOS_MASK_TX_MIN_FLOW  = 0x08
} oem_qos_spec_field_mask_enum_type;

typedef uint8 oem_qos_spec_field_mask_type;

typedef struct
{
  oem_qos_spec_field_mask_type  field_mask;

  struct 
  {
    oem_ip_flow_spec_type     flow_template;    /* traffic flow template   */
    oem_ip_filter_spec_type   fltr_template;    /* traffic filter template */
  } rx;

  struct 
  {
    oem_ip_flow_spec_type		flow_template;  /* traffic flow template   */
    oem_ip_filter_spec_type	fltr_template;  /* traffic filter template */
  } tx;
} oem_qos_spec_type;


#if defined(__cplusplus)
extern "C" {
#endif

   // function declarations

#if defined(__cplusplus)
}
#endif


#endif /* OEMSOCK_QOSSPEC_H */


