#ifndef SAR_RA867X_ATM_H
#define SAR_RA867X_ATM_H

//atm.h
/*linux-2.6.19*/
typedef struct ch_stat{                                                                           
	/* RX program flow related */                                                             
	int rcv_cnt;		/* count of Receive Functiont calls */            
	int rcv_ok;		/* packet return count */                                 

	/* RX data statistics related */                                                          
	int rx_desc_cnt;	/* count of descriptors that receive Functiont walks through */   
	int rx_byte_cnt;	/* received byte count */                                         
	int rx_pkt_cnt;                                                                       
	int rx_pkt_fail;                                                                      

	int rx_FS_cnt;		/* count of FS desc */                                    
	int rx_LS_cnt;		/* count of LS desc */                                    
	int rx_desc_ok_cnt;	/* rx ok descriptors */                                           
	int rx_oam_count;	/* rx oam cell count */                                           
	int rx_buf_alloc;	/* rx buffer allocated */                                         
	int rx_buf_lack;		/* lack of rx buffer */                                   
	int rx_desc_fail;	/* rx desc errors */                                              
	int rx_crc_error;	/* rx AAL5 CRC error count */                                     
	int rx_lenb_error;	/* rx packet length too large */                                  
	int rx_lens_error;	/* rx packet length too small */
	int rx_rbf_count;	/* rbf interrupt count */

	int rx_netif_cnt;	/* count for netif calls */                                       
	//int	rx_cell_cnt;                                                                      

	/* TX program flow related */                                                             
	int send_cnt;		/* count of Send function calls */                        
	int send_ok;		/* count of Send function ok */                           
	int send_fail;		/* count of Send function errors */                       
	int send_desc_full;	/* descriptors full */                                            
	int send_desc_lack;	/* not enough free descriptors */                                 

	/* TX data statistics related */                                                          
	int tx_desc_ok_cnt;	/* tx ok descriptors (successfully transmitted) */                
	int tx_buf_free;	/* tx buffer freed */                                     
	int tx_pkt_ok_cnt;	/* tx ok packets (successfully transmitted)*/                     
	int tx_pkt_fail_cnt;	/* tx fail packets (send into descritprtor ring failed) */
	int tx_byte_cnt;	/* send byte count (send into descriptor ring) */         
	//int	tx_cell_cnt;                                                                      

#ifdef STAI_DEBUG
	int tx_starvation;
	int forceDrop;
#endif

}ch_stat;                                                                                         

typedef struct Traffic_Manage{           
	unsigned int	tick_now;        
	int		cell_cnt;	 
	char		Type;            
	unsigned short	PCR;             
	unsigned short	SCR;             
	/*linux-2.6.19*/ /*fixme*/
	//#ifndef CONFIG_RTL8672_ATM_QoS
	//	unsigned char	MBS;             
	//#else
	unsigned short 	MBS;
	//#endif
	unsigned char	CRD;             
	unsigned int	CDVT;            
}Traffic_Manage;                         

struct SAR_IOCTL_CFG {                                                                       
	char		ch_no;                                                       
	unsigned char	vpi;		//vpi number         
	unsigned short	vci;		//vci number         
	int		rfc;                                                         
	int		framing;                                                     
	int		created;                                                     
	int		loopback;	                                             
	unsigned char	MAC[6];                                                      
	Traffic_Manage	QoS;                                                         
	ch_stat		stat;                                                        
};                                                                                           

struct SAR_IOCTL_DEBUG {
	int enable;
	int chno;
	int etype;
	int ipproto;
	int hr;	// human readable
	struct {
		unsigned long ip;
		unsigned short port;
	} src;
	struct {
		unsigned long ip;
		unsigned short port;
	} dst;
};
//tylo, for linux 2.6
// ioctl command called by system & user space applications                                         
#define SAR_GET_MODEMSTATE		SIOCDEVPRIVATE                                              
#define SAR_GET_STATS			(SIOCDEVPRIVATE+1)                                          
#define SAR_ENABLE			(SIOCDEVPRIVATE+2)                                          
#define SAR_DISABLE			(SIOCDEVPRIVATE+3)                                          
#define SAR_GET_CONFIG			(SIOCDEVPRIVATE+4)                                          
#define SAR_SET_CONFIG			(SIOCDEVPRIVATE+5)                                          
#define SAR_ATM_OAM_SET_ID		(SIOCDEVPRIVATE+6)                                          
#define SAR_ATM_OAM_START		(SIOCDEVPRIVATE+7)                                          
#define SAR_ATM_OAM_STOP		(SIOCDEVPRIVATE+8)                                          
#define SAR_ATM_OAM_STATUS		(SIOCDEVPRIVATE+9)                                          
#define SAR_ATM_OAM_STATUS_FE		(SIOCDEVPRIVATE+10)                                         
#define SAR_ATM_OAM_RPT_LB		(SIOCDEVPRIVATE+11)                                         
#define SAR_ATM_OAM_STOP_LB		(SIOCDEVPRIVATE+12)                                         
#define SAR_CREATE_VC			(SIOCDEVPRIVATE+13)                                         
#define SAR_DELETE_VC			(SIOCDEVPRIVATE+14)                                         
#define SAR_ENABLE_UTOPIA		(SIOCDEVPRIVATE+15)                                         
#define SAR_UTOPIA_FAST			(SIOCDEVPRIVATE+16)                                         
#define SAR_UTOPIA_SLOW			(SIOCDEVPRIVATE+17)                                         
#define SAR_SETMAC			(SIOCDEVPRIVATE+18)                                         
#define SAR_EnableLOOPBACK		(SIOCDEVPRIVATE+19)                                         
#define SAR_DisableLOOPBACK		(SIOCDEVPRIVATE+20)                                         
#define SAR_SET_PVC_NUMBER		(SIOCDEVPRIVATE+21)                                         
#define SAR_READ_MEM			(SIOCDEVPRIVATE+22)                                         
#define SAR_WRITE_MEM			(SIOCDEVPRIVATE+23)                                         
#define SAR_SET_ENCAPS			(SIOCDEVPRIVATE+24)                                         

#ifdef AUTO_PVC_SEARCH	                                                                            
#define	SENT_STARTUP_PID		(SIOCDEVPRIVATE+25)                                         
#define SENT_BOA_PID			SENT_STARTUP_PID
#endif                                                                                              

#define	SENT_SNTP_PID			(SIOCDEVPRIVATE+26)                                         
#define SENT_TR069_PID			(SIOCDEVPRIVATE+27)                                         
#define SENT_TERM_REQ			(SIOCDEVPRIVATE+28)
//ql
#if 0
#define SAR_SET_TRAFFIC_CTL		(SIOCDEVPRIVATE+29)
#endif
#define QOS_ENABLE_IMQ			(SIOCDEVPRIVATE+29)

#define SAR_SET_BRIDGE_MODE 		(SIOCDEVPRIVATE+30)
//#ifdef CONFIG_RTL8672
#define SAR_SET_SARHDR		 	(SIOCDEVPRIVATE+31)	
#define SAR_SET_PKTA	 		(SIOCDEVPRIVATE+32)	
//#endif
#define PVC_QOS_TYPE			(SIOCDEVPRIVATE+35)

// for debug                                                                                        
#define SAR_DEBUG_PVC_ENABLE		(SIOCDEVPRIVATE+50)                                         
#define SAR_DEBUG_OBAAL5_ENABLE		(SIOCDEVPRIVATE+51)                                         
#define SAR_DEBUG_OBCELL_ENABLE		(SIOCDEVPRIVATE+52)                                         
#define SAR_DEBUG_NUM2PRINT		(SIOCDEVPRIVATE+55)                                         
#define SAR_DEBUG_STATUS		(SIOCDEVPRIVATE+56)                                         

//#ifdef CONFIG_PORT_MIRROR
#define SAR_PORT_MIRROR			(SIOCDEVPRIVATE+57)
//#endif
#define SAR_UPGRADE_FW			(SIOCDEVPRIVATE+58)
#define SAR_RESET_STATS			(SIOCDEVPRIVATE+59)

enum RFC_MODE{	                                                                                    
	RFC1483_BRIDGED, 	/* Ethernet over ATM (bridged) */                                   
	RFC1483_ROUTED,		/* Ethernet over ATM (routed IP) */                                         
	RFC1577,		/* IP over ATM */                                           
	RFC2364,		/* PPP over ATM */                                          
	RFC2516			/* PPP over Ethernet */                                             
};                                                                                                  

enum FRAMING_MODE{                                                                                  
	LLC_SNAP,                                                                                   
	VC_MUX                                                                                      
};                                                                                                  

typedef struct tATMOAMLBReq {                                                                       
	unsigned long 	vpi;		// vpi (input)                                              
	unsigned long 	vci;		// vci (input)                                              
	unsigned char	Scope;		// segment-to-segment(0)/end-to-end(1) (input)              
	unsigned char 	Channel;	// ATM0/ATM1 (input)                                        
	unsigned char 	LocID[16];	// location ID (input)                                      
	unsigned char 	SrcID[16];	// source ID (input)                                        
	unsigned long	Tag;		// message tag (output for start, input for stop)           
} ATMOAMLBReq;                                                                                      

typedef struct tATMOAMLBID                                                                          
{                                                                                                   
	unsigned long vpi;		// Near End vpi (input)                             
	unsigned long vci;		// Near End vci (input)                             
	unsigned char LocID[16];	// Near End connection point ID (input)                     
} ATMOAMLBID;                                                                                       

typedef struct tATMOAMLBState                                                                       
{                                                                                                   
	unsigned long  	vpi;		// Near End vpi (input)                                     
	unsigned long 	vci;		// Near End vci (input)                                     
	unsigned char 	LocID[6][16];	// location ID (output)                                     
	unsigned long 	Tag;		// message tag (input)                                      
	unsigned long 	count[6];	// statistic counter (output)                               
	unsigned long 	rtt[6];		// round-trip time (output)                                 
	long	      	status[6];	// state (output: waiting(1)/stop(2) )                      
}ATMOAMLBState;                                                                                     

typedef struct tATMOAMLBRXState                                                                     
{                                                                                                   
	unsigned long 	vpi;		// Near End vpi (input)                     
	unsigned long 	vci;		// Near End vci (input)                     
	unsigned char 	LocID[6][16]; 	// location ID                                              
	unsigned long 	count[6];       // statistic counter (output)                       
	long 		status[6];      // state (output: empty (0) /occupy(1))     
} ATMOAMLBRXState;                                                                                  

//atmdev.h
/*linux-2.6.19*/
/*patch from linux 2.4*/ 
/*the io num must be corrected, from 6 to 8*/
// Added by Mason Yu for PPPoE PassThrough
// W.H. Hung: This ioctl has been replaced by ebtables rules
// Reserve it to avoid miss use
#define ATM_SETBRIDGEPPPOE 	_IOW('a',ATMIOC_SPECIAL+4,atm_backend_t)
//#ifdef CONFIG_EXT_SWITCH
#define ATM_SETVLAN		_IOW('a',ATMIOC_SPECIAL+5,atm_backend_t)	/* set VLAN mapping */
#define ATM_SETITFGRP		_IOW('a',ATMIOC_SPECIAL+6,atm_backend_t)	/* set interface group */
//#ifdef  //CONFIG_NEW_PORTMAPPING
#define ATM_SETFGROUP 		_IOW('a',ATMIOC_SPECIAL+7,atm_backend_t)
//#endif
//#endif

//shlee 2.6
#define ATM_SAR_GETSTAT 	_IOW('a',ATMIOC_SARPRV+1,struct atmif_sioc)	/* get channel statistics */
#define ATM_OAM_SET_ID 		_IOW('a',ATMIOC_SARPRV+2,struct atmif_sioc)	/* start OAM near-end ID */
#define ATM_OAM_LB_START 	_IOW('a',ATMIOC_SARPRV+3,struct atmif_sioc)	/* start OAM loopback ping */
#define ATM_OAM_LB_STOP	 	_IOW('a',ATMIOC_SARPRV+4,struct atmif_sioc)	/* stop OAM loopback ping */
#define ATM_OAM_LB_STATUS 	_IOW('a',ATMIOC_SARPRV+5,struct atmif_sioc)	/* get OAM loopback ping status*/
#define ATM_OAM_STATUS_FE 	_IOW('a',ATMIOC_SARPRV+6,struct atmif_sioc)	/* get OAM loopback far-end ping status*/
#define ATM_SAR_GETCONFIG 	_IOW('a',ATMIOC_SARPRV+7,struct atmif_sioc)	/* get channel configuration */

//#ifdef CONFIG_PORT_MIRROR
#define PORT_MIRROR_IN  0x1
#define PORT_MIRROR_OUT 0x2
//#endif

//atmarp.h
// Jenny
#define ATMARP_IP       _IO('a',ATMIOC_CLIP+6)  /* change ip */
#define ATMARP_SRV      _IO('a',ATMIOC_CLIP+7)  /* arp server ip */
#define ATMARP_INARPREP _IO('a',ATMIOC_CLIP+8)  /* send InATMArpReply */

// Jenny
/* RFC 1577 ATM ARP header */
struct atmarphdr {
        uint16_t ar_hrd;        /* Hardware type */
        uint16_t ar_pro;        /* Protocol type */
        uint8_t ar_shtl;        /* Type & length of source ATM number (q) */
        uint8_t ar_sstl;        /* Type & length of source ATM subaddress (r) */
        uint16_t ar_op; /* Operation code (request, reply, or NAK) */
        uint8_t ar_spln;        /* Length of source protocol address (s) */
        uint8_t ar_thtl;        /* Type & length of target ATM number (x) */
        uint8_t ar_tstl;        /* Type & length of target ATM subaddress (y) */
        uint8_t ar_tpln;        /* Length of target protocol address (z) */
        /* ar_sha, at_ssa, ar_spa, ar_tha, ar_tsa, ar_tpa */
        unsigned char data[1];
};

#define TL_LEN 0x3f     /* ATMARP Type/Length field structure */

#endif //SAR_RA867X_ATM_H