File: /usr/include/linux/sdla_chdlc.h

1     /*************************************************************************
2      sdla_chdlc.h	Sangoma Cisco HDLC firmware API definitions
3     
4      Author:      	Gideon Hack
5     		Nenad Corbic <ncorbic@sangoma.com>	
6     
7      Copyright:	(c) 1995-1999 Sangoma Technologies Inc.
8     
9     		This program is free software; you can redistribute it and/or
10     		modify it under the term of the GNU General Public License
11     		as published by the Free Software Foundation; either version
12     		2 of the License, or (at your option) any later version.
13     
14     ===========================================================================
15       Oct 04, 1999  Nenad Corbic    Updated API support
16       Jun 02, 1999  Gideon Hack     Changes for S514 usage.
17       Oct 28, 1998	Jaspreet Singh	Made changes for Dual Port CHDLC.
18       Jun 11, 1998	David Fong	Initial version.
19     ===========================================================================
20     
21      Organization
22     	- Compatibility notes
23     	- Constants defining the shared memory control block (mailbox)
24     	- Interface commands
25     	- Return code from interface commands
26     	- Constants for the commands (structures for casting data)
27     	- UDP Management constants and structures
28     
29     *************************************************************************/
30     
31     #ifndef _SDLA_CHDLC_H
32     #  define _SDLC_CHDLC_H
33     
34     /*------------------------------------------------------------------------
35        Notes:
36     
37     	All structres defined in this file are byte-aligned.  
38     
39     	Compiler	Platform
40     	------------------------
41     	GNU C		Linux
42     
43     ------------------------------------------------------------------------*/
44     
45     #ifndef	PACKED
46     #define	PACKED __attribute__((packed))
47     #endif	/* PACKED */
48     
49     
50     /* ----------------------------------------------------------------------------
51      *        Constants defining the shared memory control block (mailbox)
52      * --------------------------------------------------------------------------*/
53     
54     #define PRI_BASE_ADDR_MB_STRUCT 	0xE000 	/* the base address of the mailbox structure on the adapter */
55     #define SEC_BASE_ADDR_MB_STRUCT 	0xE800 	/* the base address of the mailbox structure on the adapter */
56     #define SIZEOF_MB_DATA_BFR		2032	/* the size of the actual mailbox data area */
57     #define NUMBER_MB_RESERVED_BYTES	0x0B	/* the number of reserved bytes in the mailbox header area */
58     
59     
60     #define MIN_LGTH_CHDLC_DATA_CFG  	300 	/* min length of the CHDLC data field (for configuration purposes) */
61     #define PRI_MAX_NO_DATA_BYTES_IN_FRAME  15354 /* PRIMARY - max length of the CHDLC data field */
62     
63     typedef struct {
64     	unsigned char opp_flag PACKED;			/* the opp flag */
65     	unsigned char command PACKED;			/* the user command */
66     	unsigned short buffer_length PACKED;		/* the data length */
67       	unsigned char return_code PACKED;		/* the return code */
68     	unsigned char MB_reserved[NUMBER_MB_RESERVED_BYTES] PACKED;	/* reserved for later */
69     	unsigned char data[SIZEOF_MB_DATA_BFR] PACKED;	/* the data area */
70     } CHDLC_MAILBOX_STRUCT;
71     
72     typedef struct {
73             pid_t                   pid_num PACKED;
74             CHDLC_MAILBOX_STRUCT     cmdarea PACKED;
75     
76     } CMDBLOCK_STRUCT;
77     
78     
79     
80     
81     /* ----------------------------------------------------------------------------
82      *                        Interface commands
83      * --------------------------------------------------------------------------*/
84     
85     /* global interface commands */
86     #define READ_GLOBAL_EXCEPTION_CONDITION	0x01
87     #define SET_GLOBAL_CONFIGURATION	0x02
88     #define READ_GLOBAL_CONFIGURATION	0x03
89     #define READ_GLOBAL_STATISTICS		0x04
90     #define FLUSH_GLOBAL_STATISTICS		0x05
91     #define SET_MODEM_STATUS		0x06	/* set status of DTR or RTS */
92     #define READ_MODEM_STATUS		0x07	/* read status of CTS and DCD */
93     #define READ_COMMS_ERROR_STATS		0x08	
94     #define FLUSH_COMMS_ERROR_STATS		0x09
95     #define SET_TRACE_CONFIGURATION		0x0A	/* set the line trace config */
96     #define READ_TRACE_CONFIGURATION	0x0B	/* read the line trace config */
97     #define READ_TRACE_STATISTICS		0x0C	/* read the trace statistics */
98     #define FLUSH_TRACE_STATISTICS		0x0D	/* flush the trace statistics */
99     #define FT1_MONITOR_STATUS_CTRL		0x1C	/* set the status of the S508/FT1 monitoring */
100     #define SET_FT1_CONFIGURATION		0x18	/* set the FT1 configuration */
101     #define READ_FT1_CONFIGURATION		0x19	/* read the FT1 configuration */
102     #define TRANSMIT_ASYNC_DATA_TO_FT1	0x1A	/* output asynchronous data to the FT1 */
103     #define RECEIVE_ASYNC_DATA_FROM_FT1	0x1B	/* receive asynchronous data from the FT1 */
104     #define FT1_MONITOR_STATUS_CTRL		0x1C	/* set the status of the FT1 monitoring */
105     
106     #define READ_FT1_OPERATIONAL_STATS	0x1D	/* read the S508/FT1 operational statistics */
107     #define SET_FT1_MODE			0x1E	/* set the operational mode of the S508/FT1 module */
108     
109     /* CHDLC-level interface commands */
110     #define READ_CHDLC_CODE_VERSION		0x20	
111     #define READ_CHDLC_EXCEPTION_CONDITION	0x21	/* read exception condition from the adapter */
112     #define SET_CHDLC_CONFIGURATION		0x22
113     #define READ_CHDLC_CONFIGURATION	0x23
114     #define ENABLE_CHDLC_COMMUNICATIONS	0x24
115     #define DISABLE_CHDLC_COMMUNICATIONS	0x25
116     #define READ_CHDLC_LINK_STATUS		0x26
117     #define READ_CHDLC_OPERATIONAL_STATS	0x27
118     #define FLUSH_CHDLC_OPERATIONAL_STATS	0x28
119     #define SET_CHDLC_INTERRUPT_TRIGGERS	0x30	/* set application interrupt triggers */
120     #define READ_CHDLC_INTERRUPT_TRIGGERS	0x31	/* read application interrupt trigger configuration */
121     
122     /* Special UDP drivers management commands */
123     #define CPIPE_ENABLE_TRACING				0x50
124     #define CPIPE_DISABLE_TRACING				0x51
125     #define CPIPE_GET_TRACE_INFO				0x52
126     #define CPIPE_GET_IBA_DATA				0x53
127     #define CPIPE_FT1_READ_STATUS				0x54
128     #define CPIPE_DRIVER_STAT_IFSEND			0x55
129     #define CPIPE_DRIVER_STAT_INTR				0x56
130     #define CPIPE_DRIVER_STAT_GEN				0x57
131     #define CPIPE_FLUSH_DRIVER_STATS			0x58
132     #define CPIPE_ROUTER_UP_TIME				0x59
133     
134     /* Driver specific commands for API */
135     #define	CHDLC_READ_TRACE_DATA		0xE4	/* read trace data */
136     #define TRACE_ALL                       0x00
137     #define TRACE_PROT			0x01
138     #define TRACE_DATA			0x02
139     
140     /* ----------------------------------------------------------------------------
141      *                     Return codes from interface commands
142      * --------------------------------------------------------------------------*/
143     
144     #define COMMAND_OK				0x00
145     
146     /* return codes from global interface commands */
147     #define NO_GLOBAL_EXCEP_COND_TO_REPORT		0x01	/* there is no CHDLC exception condition to report */
148     #define LGTH_GLOBAL_CFG_DATA_INVALID		0x01	/* the length of the passed global configuration data is invalid */
149     #define LGTH_TRACE_CFG_DATA_INVALID		0x01	/* the length of the passed trace configuration data is invalid */
150     #define IRQ_TIMEOUT_VALUE_INVALID		0x02	/* an invalid application IRQ timeout value was selected */
151     #define TRACE_CONFIG_INVALID			0x02	/* the passed line trace configuration is invalid */
152     #define ADAPTER_OPERATING_FREQ_INVALID		0x03	/* an invalid adapter operating frequency was selected */
153     #define TRC_DEAC_TMR_INVALID			0x03	/* the trace deactivation timer is invalid */
154     #define S508_FT1_ADPTR_NOT_PRESENT		0x0C	/* the S508/FT1 adapter is not present */
155     #define INVALID_FT1_STATUS_SELECTION            0x0D    /* the S508/FT1 status selection is invalid */
156     #define FT1_OP_STATS_NOT_ENABLED		0x0D    /* the FT1 operational statistics have not been enabled */
157     #define FT1_OP_STATS_NOT_AVAILABLE		0x0E    /* the FT1 operational statistics are not currently available */
158     #define S508_FT1_MODE_SELECTION_BUSY		0x0E	/* the S508/FT1 adapter is busy selecting the operational mode */
159     
160     /* return codes from command READ_GLOBAL_EXCEPTION_CONDITION */
161     #define EXCEP_MODEM_STATUS_CHANGE		0x10		/* a modem status change occurred */
162     #define EXCEP_TRC_DISABLED			0x11		/* the trace has been disabled */
163     #define EXCEP_IRQ_TIMEOUT			0x12		/* IRQ timeout */
164     
165     /* return codes from CHDLC-level interface commands */
166     #define NO_CHDLC_EXCEP_COND_TO_REPORT		0x21	/* there is no CHDLC exception condition to report */
167     #define CHDLC_COMMS_DISABLED			0x21	/* communications are not currently enabled */
168     #define CHDLC_COMMS_ENABLED			0x21	/* communications are currently enabled */
169     #define DISABLE_CHDLC_COMMS_BEFORE_CFG		0x21	/* CHDLC communications must be disabled before setting the configuration */
170     #define ENABLE_CHDLC_COMMS_BEFORE_CONN		0x21	/* communications must be enabled before using the CHDLC_CONNECT conmmand */
171     #define CHDLC_CFG_BEFORE_COMMS_ENABLED		0x22	/* perform a SET_CHDLC_CONFIGURATION before enabling comms */
172     #define LGTH_CHDLC_CFG_DATA_INVALID 		0x22	/* the length of the passed CHDLC configuration data is invalid */
173     #define LGTH_INT_TRIGGERS_DATA_INVALID		0x22	/* the length of the passed interrupt trigger data is invalid */
174     #define INVALID_IRQ_SELECTED			0x23	/* in invalid IRQ was selected in the SET_CHDLC_INTERRUPT_TRIGGERS */
175     #define INVALID_CHDLC_CFG_DATA			0x23	/* the passed CHDLC configuration data is invalid */
176     #define IRQ_TMR_VALUE_INVALID			0x24	/* an invalid application IRQ timer value was selected */
177     #define LARGER_PERCENT_TX_BFR_REQUIRED		0x24	/* a larger Tx buffer percentage is required */
178     #define LARGER_PERCENT_RX_BFR_REQUIRED		0x25	/* a larger Rx buffer percentage is required */
179     #define S514_BOTH_PORTS_SAME_CLK_MODE		0x26	/* S514 - both ports must have same clock mode */
180     #define INVALID_CMND_HDLC_STREAM_MODE           0x4E    /* the CHDLC interface command is invalid for HDLC streaming mode */
181     #define INVALID_CHDLC_COMMAND			0x4F	/* the defined CHDLC interface command is invalid */
182     
183     /* return codes from command READ_CHDLC_EXCEPTION_CONDITION */
184     #define EXCEP_LINK_ACTIVE			0x30	/* the CHDLC link has become active */
185     #define EXCEP_LINK_INACTIVE_MODEM		0x31	/* the CHDLC link has become inactive (modem status) */
186     #define EXCEP_LINK_INACTIVE_KPALV		0x32	/* the CHDLC link has become inactive (keepalive status) */
187     #define EXCEP_IP_ADDRESS_DISCOVERED		0x33	/* the IP address has been discovered */
188     #define EXCEP_LOOPBACK_CONDITION		0x34	/* a loopback condition has occurred */
189     
190     
191     /* return code from command CHDLC_SEND_WAIT and CHDLC_SEND_NO_WAIT */
192     #define LINK_DISCONNECTED			0x21
193     #define NO_TX_BFRS_AVAIL			0x24
194     
195     
196     /* ----------------------------------------------------------------------------
197      * Constants for the SET_GLOBAL_CONFIGURATION/READ_GLOBAL_CONFIGURATION commands
198      * --------------------------------------------------------------------------*/
199     
200     /* the global configuration structure */
201     typedef struct {
202     	unsigned short adapter_config_options PACKED;	/* adapter config options */
203     	unsigned short app_IRQ_timeout PACKED;		/* application IRQ timeout */
204     	unsigned long adapter_operating_frequency PACKED;	/* adapter operating frequency */
205     } GLOBAL_CONFIGURATION_STRUCT;
206     
207     /* settings for the 'app_IRQ_timeout' */
208     #define MAX_APP_IRQ_TIMEOUT_VALUE	5000	/* the maximum permitted IRQ timeout */
209     
210     
211     
212     /* ----------------------------------------------------------------------------
213      *             Constants for the READ_GLOBAL_STATISTICS command
214      * --------------------------------------------------------------------------*/
215     
216     /* the global statistics structure */
217     typedef struct {
218     	unsigned short app_IRQ_timeout_count PACKED;
219     } GLOBAL_STATS_STRUCT;
220     
221     
222     
223     /* ----------------------------------------------------------------------------
224      *             Constants for the READ_COMMS_ERROR_STATS command
225      * --------------------------------------------------------------------------*/
226     
227     /* the communications error statistics structure */
228     typedef struct {
229     	unsigned short Rx_overrun_err_count PACKED;
230     	unsigned short CRC_err_count PACKED;	/* receiver CRC error count */
231     	unsigned short Rx_abort_count PACKED; 	/* abort frames recvd count */
232     	unsigned short Rx_dis_pri_bfrs_full_count PACKED;/* receiver disabled */
233     	unsigned short comms_err_stat_reserved_1 PACKED;/* reserved for later */
234     	unsigned short sec_Tx_abort_msd_Tx_int_count PACKED; /* secondary - abort frames transmitted count (missed Tx interrupt) */
235     	unsigned short missed_Tx_und_int_count PACKED;	/* missed tx underrun interrupt count */
236             unsigned short sec_Tx_abort_count PACKED;   /*secondary-abort frames tx count */
237     	unsigned short DCD_state_change_count PACKED; /* DCD state change */
238     	unsigned short CTS_state_change_count PACKED; /* CTS state change */
239     } COMMS_ERROR_STATS_STRUCT;
240     
241     
242     
243     /* ----------------------------------------------------------------------------
244      *                  Constants used for line tracing
245      * --------------------------------------------------------------------------*/
246     
247     /* the trace configuration structure (SET_TRACE_CONFIGURATION/READ_TRACE_CONFIGURATION commands) */
248     typedef struct {
249     	unsigned char trace_config PACKED;		/* trace configuration */
250     	unsigned short trace_deactivation_timer PACKED;	/* trace deactivation timer */
251     	unsigned long ptr_trace_stat_el_cfg_struct PACKED;	/* a pointer to the line trace element configuration structure */
252     } LINE_TRACE_CONFIG_STRUCT;
253     
254     /* 'trace_config' bit settings */
255     #define TRACE_INACTIVE		0x00	/* trace is inactive */
256     #define TRACE_ACTIVE		0x01	/* trace is active */
257     #define TRACE_DELAY_MODE	0x04	/* operate the trace in delay mode */
258     #define TRACE_DATA_FRAMES	0x08	/* trace Data frames */
259     #define TRACE_SLARP_FRAMES	0x10	/* trace SLARP frames */
260     #define TRACE_CDP_FRAMES	0x20	/* trace CDP frames */
261     
262     /* the line trace status element configuration structure */
263     typedef struct {
264     	unsigned short number_trace_status_elements PACKED;	/* number of line trace elements */
265     	unsigned long base_addr_trace_status_elements PACKED;	/* base address of the trace element list */
266     	unsigned long next_trace_element_to_use PACKED;	/* pointer to the next trace element to be used */
267     	unsigned long base_addr_trace_buffer PACKED;		/* base address of the trace data buffer */
268     	unsigned long end_addr_trace_buffer PACKED;		/* end address of the trace data buffer */
269     } TRACE_STATUS_EL_CFG_STRUCT;
270     
271     /* the line trace status element structure */
272     typedef struct {
273     	unsigned char opp_flag PACKED;			/* opp flag */
274     	unsigned short trace_length PACKED;		/* trace length */
275     	unsigned char trace_type PACKED;		/* trace type */
276     	unsigned short trace_time_stamp PACKED;	/* time stamp */
277     	unsigned short trace_reserved_1 PACKED;	/* reserved for later use */
278     	unsigned long trace_reserved_2 PACKED;		/* reserved for later use */
279     	unsigned long ptr_data_bfr PACKED;		/* ptr to the trace data buffer */
280     } TRACE_STATUS_ELEMENT_STRUCT;
281     
282     /* "trace_type" bit settings */
283     #define TRACE_INCOMING 			0x00
284     #define TRACE_OUTGOINGING 		0x01
285     #define TRACE_INCOMING_ABORTED 		0x10
286     #define TRACE_INCOMING_CRC_ERROR 	0x20
287     #define TRACE_INCOMING_OVERRUN_ERROR 	0x40
288     
289     
290     
291     /* the line trace statistics structure */
292     typedef struct {
293     	unsigned long frames_traced_count PACKED;	/* number of frames traced */
294     	unsigned long trc_frms_not_recorded_count PACKED;	/* number of trace frames discarded */
295     } LINE_TRACE_STATS_STRUCT;
296     
297     
298     /* ----------------------------------------------------------------------------
299      *               Constants for the FT1_MONITOR_STATUS_CTRL command
300      * --------------------------------------------------------------------------*/
301     
302     #define DISABLE_FT1_STATUS_STATISTICS	0x00    /* disable the FT1 status and statistics monitoring */
303     #define ENABLE_READ_FT1_STATUS		0x01    /* read the FT1 operational status */
304     #define ENABLE_READ_FT1_OP_STATS	0x02    /* read the FT1 operational statistics */
305     #define FLUSH_FT1_OP_STATS		0x04 	/* flush the FT1 operational statistics */
306     
307     
308     
309     
310     /* ----------------------------------------------------------------------------
311      *               Constants for the SET_CHDLC_CONFIGURATION command
312      * --------------------------------------------------------------------------*/
313     
314     /* the CHDLC configuration structure */
315     typedef struct {
316     	unsigned long baud_rate PACKED;		/* the baud rate */	
317     	unsigned short line_config_options PACKED;	/* line configuration options */
318     	unsigned short modem_config_options PACKED;	/* modem configration options */
319     	unsigned short modem_status_timer PACKED;	/* timer for monitoring modem status changes */
320     	unsigned short CHDLC_API_options PACKED;	/* CHDLC API options */
321     	unsigned short CHDLC_protocol_options PACKED;	/* CHDLC protocol options */
322     	unsigned short percent_data_buffer_for_Tx PACKED;	/* percentage data buffering used for Tx */
323     	unsigned short CHDLC_statistics_options PACKED;	/* CHDLC operational statistics options */
324     	unsigned short max_CHDLC_data_field_length PACKED;	/* the maximum length of the CHDLC Data field */
325     	unsigned short transmit_keepalive_timer PACKED;		/* the transmit keepalive timer */
326     	unsigned short receive_keepalive_timer PACKED;		/* the receive keepalive timer */
327     	unsigned short keepalive_error_tolerance PACKED;	/* the receive keepalive error tolerance */
328     	unsigned short SLARP_request_timer PACKED;		/* the SLARP request timer */
329     	unsigned long IP_address PACKED;			/* the IP address */
330     	unsigned long IP_netmask PACKED;			/* the IP netmask */
331     	unsigned long ptr_shared_mem_info_struct PACKED;	/* a pointer to the shared memory area information structure */
332     	unsigned long ptr_CHDLC_Tx_stat_el_cfg_struct PACKED;	/* a pointer to the transmit status element configuration structure */
333     	unsigned long ptr_CHDLC_Rx_stat_el_cfg_struct PACKED;	/* a pointer to the receive status element configuration structure */
334     } CHDLC_CONFIGURATION_STRUCT;
335     
336     /* settings for the 'line_config_options' */
337     #define INTERFACE_LEVEL_V35					0x0000 /* V.35 interface level */
338     #define INTERFACE_LEVEL_RS232					0x0001 /* RS-232 interface level */
339     
340     /* settings for the 'modem_config_options' */
341     
342     #define DONT_RAISE_DTR_RTS_ON_EN_COMMS		0x0001
343     /* don't automatically raise DTR and RTS when performing an
344        ENABLE_CHDLC_COMMUNICATIONS command */
345     
346     #define DONT_REPORT_CHG_IN_MODEM_STAT 		0x0002
347     /* don't report changes in modem status to the application */
348     
349     
350     /* bit settings for the 'CHDLC_protocol_options' byte */
351     
352     #define IGNORE_DCD_FOR_LINK_STAT		0x0001
353     /* ignore DCD in determining the CHDLC link status */
354     
355     #define IGNORE_CTS_FOR_LINK_STAT		0x0002
356     /* ignore CTS in determining the CHDLC link status */
357     
358     #define IGNORE_KPALV_FOR_LINK_STAT		0x0004
359     /* ignore keepalive frames in determining the CHDLC link status */ 
360     
361     #define HDLC_STREAMING_MODE			0x8000
362     
363     /*   settings for the 'CHDLC_statistics_options' */
364     
365     #define CHDLC_TX_DATA_BYTE_COUNT_STAT		0x0001
366     /* record the number of Data bytes transmitted */
367     
368     #define CHDLC_RX_DATA_BYTE_COUNT_STAT		0x0002
369     /* record the number of Data bytes received */
370     
371     #define CHDLC_TX_THROUGHPUT_STAT		0x0004
372     /* compute the Data frame transmit throughput */
373     
374     #define CHDLC_RX_THROUGHPUT_STAT		0x0008
375     /* compute the Data frame receive throughput */
376     
377     
378     /* permitted minimum and maximum values for setting the CHDLC configuration */
379     #define PRI_MAX_BAUD_RATE_S508	2666666 /* PRIMARY   - maximum baud rate (S508) */
380     #define SEC_MAX_BAUD_RATE_S508	258064 	/* SECONDARY - maximum baud rate (S508) */
381     #define PRI_MAX_BAUD_RATE_S514  2750000 /* PRIMARY   - maximum baud rate (S508) */
382     #define SEC_MAX_BAUD_RATE_S514  515625  /* SECONDARY - maximum baud rate (S508) */
383      
384     #define MIN_MODEM_TIMER	0			/* minimum modem status timer */
385     #define MAX_MODEM_TIMER	5000			/* maximum modem status timer */
386     
387     #define SEC_MAX_NO_DATA_BYTES_IN_FRAME  2048 /* SECONDARY - max length of the CHDLC data field */
388     
389     #define MIN_Tx_KPALV_TIMER	0	  /* minimum transmit keepalive timer */
390     #define MAX_Tx_KPALV_TIMER	60000	  /* maximum transmit keepalive timer */
391     #define DEFAULT_Tx_KPALV_TIMER	10000	  /* default transmit keepalive timer */
392     
393     #define MIN_Rx_KPALV_TIMER	10	  /* minimum receive keepalive timer */
394     #define MAX_Rx_KPALV_TIMER	60000	  /* maximum receive keepalive timer */
395     #define DEFAULT_Rx_KPALV_TIMER	10000	  /* default receive keepalive timer */
396     
397     #define MIN_KPALV_ERR_TOL	1	  /* min kpalv error tolerance count */
398     #define MAX_KPALV_ERR_TOL	20	  /* max kpalv error tolerance count */
399     #define DEFAULT_KPALV_ERR_TOL	3	  /* default value */
400     
401     #define MIN_SLARP_REQ_TIMER	0	  /* min transmit SLARP Request timer */
402     #define MAX_SLARP_REQ_TIMER	60000	  /* max transmit SLARP Request timer */
403     #define DEFAULT_SLARP_REQ_TIMER	0	  /* default value -- no SLARP */
404     
405     
406     
407     /* ----------------------------------------------------------------------------
408      *             Constants for the READ_CHDLC_LINK_STATUS command
409      * --------------------------------------------------------------------------*/
410     
411     /* the CHDLC status structure */
412     typedef struct {
413     	unsigned char CHDLC_link_status PACKED;	/* CHDLC link status */
414     	unsigned char no_Data_frms_for_app PACKED;	/* number of Data frames available for the application */
415     	unsigned char receiver_status PACKED;	/* enabled/disabled */
416     	unsigned char SLARP_state PACKED;	/* internal SLARP state */
417     } CHDLC_LINK_STATUS_STRUCT;
418     
419     /* settings for the 'CHDLC_link_status' variable */
420     #define CHDLC_LINK_INACTIVE		0x00	/* the CHDLC link is inactive */
421     #define CHDLC_LINK_ACTIVE		0x01	/* the CHDLC link is active */
422     
423     
424     
425     /* ----------------------------------------------------------------------------
426      *           Constants for the READ_CHDLC_OPERATIONAL_STATS command
427      * --------------------------------------------------------------------------*/
428     
429     /* the CHDLC operational statistics structure */
430     typedef struct {
431     
432     	/* Data frame transmission statistics */
433     	unsigned long Data_frames_Tx_count PACKED;	/* # of frames transmitted */
434     	unsigned long Data_bytes_Tx_count PACKED; 	/* # of bytes transmitted */
435     	unsigned long Data_Tx_throughput PACKED;	/* transmit throughput */
436     	unsigned long no_ms_for_Data_Tx_thruput_comp PACKED;	/* millisecond time used for the Tx throughput computation */
437     	unsigned long Tx_Data_discard_lgth_err_count PACKED;	/* number of Data frames discarded (length error) */
438     	unsigned long reserved_Data_frm_Tx_stat1 PACKED;	/* reserved for later */
439     	unsigned long reserved_Data_frm_Tx_stat2 PACKED;	/* reserved for later */
440     	unsigned long reserved_Data_frm_Tx_stat3 PACKED;	/* reserved for later */
441     
442     	/* Data frame reception statistics */
443     	unsigned long Data_frames_Rx_count PACKED;	/* number of frames received */
444     	unsigned long Data_bytes_Rx_count PACKED;	/* number of bytes received */
445     	unsigned long Data_Rx_throughput PACKED;	/* receive throughput */
446     	unsigned long no_ms_for_Data_Rx_thruput_comp PACKED;	/* millisecond time used for the Rx throughput computation */
447     	unsigned long Rx_Data_discard_short_count PACKED;	/* received Data frames discarded (too short) */
448     	unsigned long Rx_Data_discard_long_count PACKED;	/* received Data frames discarded (too long) */
449     	unsigned long Rx_Data_discard_inactive_count PACKED;	/* received Data frames discarded (link inactive) */
450     	unsigned long reserved_Data_frm_Rx_stat1 PACKED;	/* reserved for later */
451     
452     	/* SLARP frame transmission/reception statistics */
453     	unsigned long CHDLC_SLARP_REQ_Tx_count PACKED;		/* number of SLARP Request frames transmitted */
454     	unsigned long CHDLC_SLARP_REQ_Rx_count PACKED;		/* number of SLARP Request frames received */
455     	unsigned long CHDLC_SLARP_REPLY_Tx_count PACKED;	/* number of SLARP Reply frames transmitted */
456     	unsigned long CHDLC_SLARP_REPLY_Rx_count PACKED;	/* number of SLARP Reply frames received */
457     	unsigned long CHDLC_SLARP_KPALV_Tx_count PACKED;	/* number of SLARP keepalive frames transmitted */
458     	unsigned long CHDLC_SLARP_KPALV_Rx_count PACKED;	/* number of SLARP keepalive frames received */
459     	unsigned long reserved_SLARP_stat1 PACKED;		/* reserved for later */
460     	unsigned long reserved_SLARP_stat2 PACKED;		/* reserved for later */
461     
462     	/* CDP frame transmission/reception statistics */
463     	unsigned long CHDLC_CDP_Tx_count PACKED;		/* number of CDP frames transmitted */
464     	unsigned long CHDLC_CDP_Rx_count PACKED;		/* number of CDP frames received */
465     	unsigned long reserved_CDP_stat1 PACKED;		/* reserved for later */
466     	unsigned long reserved_CDP_stat2 PACKED;		/* reserved for later */
467     	unsigned long reserved_CDP_stat3 PACKED;		/* reserved for later */
468     	unsigned long reserved_CDP_stat4 PACKED;		/* reserved for later */
469     	unsigned long reserved_CDP_stat5 PACKED;		/* reserved for later */
470     	unsigned long reserved_CDP_stat6 PACKED;		/* reserved for later */
471     
472     	/* Incoming frames with a format error statistics */
473     	unsigned short Rx_frm_incomp_CHDLC_hdr_count PACKED;	/* frames received of with incomplete Cisco HDLC header */
474     	unsigned short Rx_frms_too_long_count PACKED;		/* frames received of excessive length count */
475     	unsigned short Rx_invalid_CHDLC_addr_count PACKED;	/* frames received with an invalid CHDLC address count */
476     	unsigned short Rx_invalid_CHDLC_ctrl_count PACKED;	/* frames received with an invalid CHDLC control field count */
477     	unsigned short Rx_invalid_CHDLC_type_count PACKED;	/* frames received of an invalid CHDLC frame type count */
478     	unsigned short Rx_SLARP_invalid_code_count PACKED;	/* SLARP frame received with an invalid packet code */
479     	unsigned short Rx_SLARP_Reply_bad_IP_addr PACKED;	/* SLARP Reply received - bad IP address */
480     	unsigned short Rx_SLARP_Reply_bad_netmask PACKED;	/* SLARP Reply received - bad netmask */
481     	unsigned long reserved_frm_format_err1 PACKED;		/* reserved for later */
482     	unsigned long reserved_frm_format_err2 PACKED;		/* reserved for later */
483     	unsigned long reserved_frm_format_err3 PACKED;		/* reserved for later */
484     	unsigned long reserved_frm_format_err4 PACKED;		/* reserved for later */
485     
486     	/* CHDLC timeout/retry statistics */
487     	unsigned short SLARP_Rx_keepalive_TO_count PACKED;	/* timeout count for incoming SLARP frames */
488     	unsigned short SLARP_Request_TO_count PACKED;		/* timeout count for SLARP Request frames */
489     	unsigned long To_retry_reserved_stat1 PACKED;		/* reserved for later */
490     	unsigned long To_retry_reserved_stat2 PACKED;		/* reserved for later */
491     	unsigned long To_retry_reserved_stat3 PACKED;		/* reserved for later */
492     
493     	/* CHDLC link active/inactive and loopback statistics */
494     	unsigned short link_active_count PACKED;		/* number of times that the link went active */
495     	unsigned short link_inactive_modem_count PACKED;	/* number of times that the link went inactive (modem failure) */
496     	unsigned short link_inactive_keepalive_count PACKED;	/* number of times that the link went inactive (keepalive failure) */
497     	unsigned short link_looped_count PACKED;		/* link looped count */
498     	unsigned long link_status_reserved_stat1 PACKED;	/* reserved for later use */
499     	unsigned long link_status_reserved_stat2 PACKED;	/* reserved for later use */
500     
501     	/* miscellaneous statistics */
502     	unsigned long reserved_misc_stat1 PACKED;		/* reserved for later */
503     	unsigned long reserved_misc_stat2 PACKED;		/* reserved for later */
504     	unsigned long reserved_misc_stat3 PACKED;		/* reserved for later */
505     	unsigned long reserved_misc_stat4 PACKED;		/* reserved for later */
506     
507     } CHDLC_OPERATIONAL_STATS_STRUCT;
508     
509     
510     
511     /* ----------------------------------------------------------------------------
512      *                 Constants for using application interrupts
513      * --------------------------------------------------------------------------*/
514     
515     /* the structure used for the SET_CHDLC_INTERRUPT_TRIGGERS/READ_CHDLC_INTERRUPT_TRIGGERS command */
516     typedef struct {
517     	unsigned char CHDLC_interrupt_triggers PACKED;	/* CHDLC interrupt trigger configuration */
518     	unsigned char IRQ PACKED;			/* IRQ to be used */
519     	unsigned short interrupt_timer PACKED;		/* interrupt timer */
520     	unsigned short misc_interrupt_bits PACKED;	/* miscellaneous bits */
521     } CHDLC_INT_TRIGGERS_STRUCT;
522     
523     /* 'CHDLC_interrupt_triggers' bit settings */
524     #define APP_INT_ON_RX_FRAME		0x01	/* interrupt on Data frame reception */
525     #define APP_INT_ON_TX_FRAME		0x02	/* interrupt when an Data frame may be transmitted */
526     #define APP_INT_ON_COMMAND_COMPLETE	0x04	/* interrupt when an interface command is complete */
527     #define APP_INT_ON_TIMER		0x08	/* interrupt on a defined millisecond timeout */
528     #define APP_INT_ON_GLOBAL_EXCEP_COND 	0x10	/* interrupt on a global exception condition */
529     #define APP_INT_ON_CHDLC_EXCEP_COND	0x20	/* interrupt on an CHDLC exception condition */
530     #define APP_INT_ON_TRACE_DATA_AVAIL	0x80	/* interrupt when trace data is available */
531     
532     /* interrupt types indicated at 'interrupt_type' byte of the INTERRUPT_INFORMATION_STRUCT */
533     #define NO_APP_INTS_PEND		0x00	/* no interrups are pending */
534     #define RX_APP_INT_PEND			0x01	/* a receive interrupt is pending */
535     #define TX_APP_INT_PEND			0x02	/* a transmit interrupt is pending */
536     #define COMMAND_COMPLETE_APP_INT_PEND	0x04	/* a 'command complete' interrupt is pending */
537     #define TIMER_APP_INT_PEND		0x08	/* a timer interrupt is pending */
538     #define GLOBAL_EXCEP_COND_APP_INT_PEND 	0x10	/* a global exception condition interrupt is pending */
539     #define CHDLC_EXCEP_COND_APP_INT_PEND 	0x20	/* an CHDLC exception condition interrupt is pending */
540     #define TRACE_DATA_AVAIL_APP_INT_PEND	0x80	/* a trace data available interrupt is pending */
541     
542     
543     /* modem status changes */
544     #define DCD_HIGH			0x08
545     #define CTS_HIGH			0x20
546     
547     
548     /* ----------------------------------------------------------------------------
549      *                   Constants for Data frame transmission
550      * --------------------------------------------------------------------------*/
551     
552     /* the Data frame transmit status element configuration structure */
553     typedef struct {
554     	unsigned short number_Tx_status_elements PACKED;	/* number of transmit status elements */
555     	unsigned long base_addr_Tx_status_elements PACKED;	/* base address of the transmit element list */
556     	unsigned long next_Tx_status_element_to_use PACKED;	/* pointer to the next transmit element to be used */
557     } CHDLC_TX_STATUS_EL_CFG_STRUCT;
558     
559     /* the Data frame transmit status element structure */
560     typedef struct {
561     	unsigned char opp_flag PACKED;		/* opp flag */
562     	unsigned short frame_length PACKED;	/* length of the frame to be transmitted */
563     	unsigned char reserved_1 PACKED;	/* reserved for internal use */
564     	unsigned long reserved_2 PACKED;	/* reserved for internal use */
565     	unsigned long reserved_3 PACKED;	/* reserved for internal use */
566     	unsigned long ptr_data_bfr PACKED;	/* pointer to the data area */
567     } CHDLC_DATA_TX_STATUS_EL_STRUCT;
568     
569     
570     
571     /* ----------------------------------------------------------------------------
572      *                   Constants for Data frame reception
573      * --------------------------------------------------------------------------*/
574     
575     /* the Data frame receive status element configuration structure */
576     typedef struct {
577     	unsigned short number_Rx_status_elements PACKED;	/* number of receive status elements */
578     	unsigned long base_addr_Rx_status_elements PACKED;	/* base address of the receive element list */
579     	unsigned long next_Rx_status_element_to_use PACKED;	/* pointer to the next receive element to be used */
580     	unsigned long base_addr_Rx_buffer PACKED;		/* base address of the receive data buffer */
581     	unsigned long end_addr_Rx_buffer PACKED;		/* end address of the receive data buffer */
582     } CHDLC_RX_STATUS_EL_CFG_STRUCT;
583     
584     /* the Data frame receive status element structure */
585     typedef struct {
586     	unsigned char opp_flag PACKED;		/* opp flag */
587     	unsigned short frame_length PACKED;   /* length of the received frame */
588             unsigned char error_flag PACKED; /* frame errors (HDLC_STREAMING_MODE)*/
589             unsigned short time_stamp PACKED; /* receive time stamp (HDLC_STREAMING_MODE) */
590             unsigned long reserved_1 PACKED; 	/* reserved for internal use */
591             unsigned short reserved_2 PACKED; 	/* reserved for internal use */
592             unsigned long ptr_data_bfr PACKED;	/* pointer to the data area */
593     } CHDLC_DATA_RX_STATUS_EL_STRUCT;
594     
595     
596     
597     /* ----------------------------------------------------------------------------
598      *         Constants defining the shared memory information area
599      * --------------------------------------------------------------------------*/
600     
601     /* the global information structure */
602     typedef struct {
603      	unsigned char global_status PACKED;		/* global status */
604      	unsigned char modem_status PACKED;		/* current modem status */
605      	unsigned char global_excep_conditions PACKED;	/* global exception conditions */
606     	unsigned char glob_info_reserved[5] PACKED;	/* reserved */
607     	unsigned char codename[4] PACKED;		/* Firmware name */
608     	unsigned char codeversion[4] PACKED;		/* Firmware version */
609     } GLOBAL_INFORMATION_STRUCT;
610     
611     /* the CHDLC information structure */
612     typedef struct {
613     	unsigned char CHDLC_status PACKED;		/* CHDLC status */
614      	unsigned char CHDLC_excep_conditions PACKED;	/* CHDLC exception conditions */
615     	unsigned char CHDLC_info_reserved[14] PACKED;	/* reserved */
616     } CHDLC_INFORMATION_STRUCT;
617     
618     /* the interrupt information structure */
619     typedef struct {
620      	unsigned char interrupt_type PACKED;		/* type of interrupt triggered */
621      	unsigned char interrupt_permission PACKED;	/* interrupt permission mask */
622     	unsigned char int_info_reserved[14] PACKED;	/* reserved */
623     } INTERRUPT_INFORMATION_STRUCT;
624     
625     /* the S508/FT1 information structure */
626     typedef struct {
627      	unsigned char parallel_port_A_input PACKED;	/* input - parallel port A */
628      	unsigned char parallel_port_B_input PACKED;	/* input - parallel port B */
629     	unsigned char FT1_info_reserved[14] PACKED;	/* reserved */
630     } FT1_INFORMATION_STRUCT;
631     
632     /* the shared memory area information structure */
633     typedef struct {
634     	GLOBAL_INFORMATION_STRUCT global_info_struct PACKED;		/* the global information structure */
635     	CHDLC_INFORMATION_STRUCT CHDLC_info_struct PACKED;		/* the CHDLC information structure */
636     	INTERRUPT_INFORMATION_STRUCT interrupt_info_struct PACKED;	/* the interrupt information structure */
637     	FT1_INFORMATION_STRUCT FT1_info_struct PACKED;			/* the S508/FT1 information structure */
638     } SHARED_MEMORY_INFO_STRUCT;
639     
640     /* ----------------------------------------------------------------------------
641      *        UDP Management constants and structures 
642      * --------------------------------------------------------------------------*/
643     
644     /* The embedded control block for UDP mgmt 
645        This is essentially a mailbox structure, without the large data field */
646     
647     typedef struct {
648             unsigned char  opp_flag PACKED;                  /* the opp flag */
649             unsigned char  command PACKED;                   /* the user command */
650             unsigned short buffer_length PACKED;             /* the data length */
651             unsigned char  return_code PACKED;               /* the return code */
652     	unsigned char  MB_reserved[NUMBER_MB_RESERVED_BYTES] PACKED;	/* reserved for later */
653     } cblock_t;
654     
655     
656     /* UDP management packet layout (data area of ip packet) */
657     /*
658     typedef struct {
659     	unsigned char		signature[8]	PACKED;
660     	unsigned char		request_reply	PACKED;
661     	unsigned char		id		PACKED;
662     	unsigned char		reserved[6]	PACKED;
663     	cblock_t		cblock		PACKED;
664     	unsigned char		num_frames	PACKED;
665     	unsigned char		ismoredata	PACKED;
666     	unsigned char 		data[SIZEOF_MB_DATA_BFR] 	PACKED;
667     } udp_management_packet_t;
668     
669     */
670     
671     typedef struct {
672     	unsigned char		num_frames	PACKED;
673     	unsigned char		ismoredata	PACKED;
674     } trace_info_t;
675     
676     typedef struct {
677     	ip_pkt_t 		ip_pkt		PACKED;
678     	udp_pkt_t		udp_pkt		PACKED;
679     	wp_mgmt_t		wp_mgmt		PACKED;
680     	cblock_t                cblock          PACKED;
681     	trace_info_t       	trace_info      PACKED;
682     	unsigned char           data[SIZEOF_MB_DATA_BFR]      PACKED;
683     } chdlc_udp_pkt_t;
684     
685     typedef struct ft1_exec_cmd{
686     	unsigned char  command PACKED;                   /* the user command */
687             unsigned short buffer_length PACKED;             /* the data length */
688             unsigned char  return_code PACKED;               /* the return code */
689     	unsigned char  MB_reserved[NUMBER_MB_RESERVED_BYTES] PACKED;
690     } ft1_exec_cmd_t;
691     
692     typedef struct {
693     	unsigned char  opp_flag 			PACKED;
694     	ft1_exec_cmd_t cmd				PACKED;
695     	unsigned char  data[SIZEOF_MB_DATA_BFR]      	PACKED;
696     } ft1_exec_t;
697     
698     #define UDPMGMT_SIGNATURE	"CTPIPEAB"
699     
700     
701     /* UDP/IP packet (for UDP management) layout */
702     /*
703     typedef struct {
704     	unsigned char	reserved[2]	PACKED;
705     	unsigned short	ip_length	PACKED;
706     	unsigned char	reserved2[4]	PACKED;
707     	unsigned char	ip_ttl		PACKED;
708     	unsigned char	ip_protocol	PACKED;
709     	unsigned short	ip_checksum	PACKED;
710     	unsigned long	ip_src_address	PACKED;
711     	unsigned long	ip_dst_address	PACKED;
712     	unsigned short	udp_src_port	PACKED;
713     	unsigned short	udp_dst_port	PACKED;
714     	unsigned short	udp_length	PACKED;
715     	unsigned short	udp_checksum	PACKED;
716     	udp_management_packet_t um_packet PACKED;
717     } ip_packet_t;
718     */
719     
720     /* valid ip_protocol for UDP management */
721     #define UDPMGMT_UDP_PROTOCOL 0x11
722     
723     
724     typedef struct {
725     	unsigned char	status		PACKED;
726     	unsigned char	data_avail	PACKED;
727     	unsigned short	real_length	PACKED;
728     	unsigned short	time_stamp	PACKED;
729     	unsigned char	data[1]		PACKED;
730     } trace_pkt_t;
731     
732     typedef struct {
733     	unsigned char	error_flag	PACKED;
734     	unsigned short	time_stamp	PACKED;
735     	unsigned char	reserved[13]	PACKED;
736     } api_rx_hdr_t;
737     
738     typedef struct {
739             api_rx_hdr_t	api_rx_hdr      PACKED;
740             void *   	data    	PACKED;
741     } api_rx_element_t;
742     
743     typedef struct {
744     	unsigned char 	attr		PACKED;
745     	unsigned char  	reserved[15]	PACKED;
746     } api_tx_hdr_t;
747     
748     typedef struct {
749     	api_tx_hdr_t 	api_tx_hdr	PACKED;
750     	void *		data		PACKED;
751     } api_tx_element_t;
752     
753     /* ----------------------------------------------------------------------------
754      *   Constants for the SET_FT1_CONFIGURATION/READ_FT1_CONFIGURATION command
755      * --------------------------------------------------------------------------*/
756     
757     /* the FT1 configuration structure */
758     typedef struct {
759     	unsigned short framing_mode;
760     	unsigned short encoding_mode;
761     	unsigned short line_build_out;
762     	unsigned short channel_base;
763     	unsigned short baud_rate_kbps;					/* the baud rate (in kbps) */	
764     	unsigned short clock_mode;
765     } ft1_config_t;
766     
767     /* settings for the 'framing_mode' */
768     #define ESF_FRAMING 	0x00	/* ESF framing */
769     #define D4_FRAMING  	0x01	/* D4 framing */
770     
771     /* settings for the 'encoding_mode' */
772     #define B8ZS_ENCODING 	0x00	/* B8ZS encoding */
773     #define AMI_ENCODING	0x01	/* AMI encoding */
774     
775     /* settings for the 'line_build_out' */
776     #define LN_BLD_CSU_0dB_DSX1_0_to_133	0x00	/* set build out to CSU (0db) or DSX-1 (0-133ft) */
777     #define LN_BLD_DSX1_133_to_266		0x01	/* set build out DSX-1 (133-266ft) */
778     #define LN_BLD_DSX1_266_to_399		0x02	/* set build out DSX-1 (266-399ft) */
779     #define LN_BLD_DSX1_399_to_533		0x03	/* set build out DSX-1 (399-533ft) */
780     #define LN_BLD_DSX1_533_to_655		0x04	/* set build out DSX-1 (533-655ft) */
781     #define LN_BLD_CSU_NEG_7dB		0x05	/* set build out to CSU (-7.5db) */
782     #define LN_BLD_CSU_NEG_15dB		0x06	/* set build out to CSU (-15db) */
783     #define LN_BLD_CSU_NEG_22dB		0x07	/* set build out to CSU (-22.5db) */
784     
785     /* settings for the 'channel_base' */
786     #define MIN_CHANNEL_BASE_VALUE		1		/* the minimum permitted channel base value */
787     #define MAX_CHANNEL_BASE_VALUE		24		/* the maximum permitted channel base value */
788     
789     /* settings for the 'baud_rate_kbps' */
790     #define MIN_BAUD_RATE_KBPS		0		/* the minimum permitted baud rate (kbps) */
791     #define MAX_BAUD_RATE_KBPS 		1536	/* the maximum permitted baud rate (kbps) */
792     #define BAUD_RATE_FT1_AUTO_CONFIG	0xFFFF /* the baud rate used to trigger an automatic FT1 configuration */
793     
794     /* settings for the 'clock_mode' */
795     #define CLOCK_MODE_NORMAL		0x00	/* clock mode set to normal (slave) */
796     #define CLOCK_MODE_MASTER		0x01	/* clock mode set to master */
797     
798     
799     #define BAUD_RATE_FT1_AUTO_CONFIG   	0xFFFF
800     #define AUTO_FT1_CONFIG_NOT_COMPLETE	0x08
801     #define AUTO_FT1_CFG_FAIL_OP_MODE	0x0C
802     #define AUTO_FT1_CFG_FAIL_INVALID_LINE 	0x0D
803     
804      
805     #ifdef		_MSC_
806     #  pragma	pack()
807     #endif
808     #endif	/* _SDLA_CHDLC_H */
809