aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/sdla_chdlc.h
blob: d2e35a29903417638b99946343cf991112269f30 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
/*************************************************************************
 sdla_chdlc.h	Sangoma Cisco HDLC firmware API definitions

 Author:      	Gideon Hack
		Nenad Corbic <ncorbic@sangoma.com>	

 Copyright:	(c) 1995-2000 Sangoma Technologies Inc.

		This program is free software; you can redistribute it and/or
		modify it under the term of the GNU General Public License
		as published by the Free Software Foundation; either version
		2 of the License, or (at your option) any later version.

===========================================================================
  Oct 04, 1999  Nenad Corbic    Updated API support
  Jun 02, 1999  Gideon Hack     Changes for S514 usage.
  Oct 28, 1998	Jaspreet Singh	Made changes for Dual Port CHDLC.
  Jun 11, 1998	David Fong	Initial version.
===========================================================================

 Organization
	- Compatibility notes
	- Constants defining the shared memory control block (mailbox)
	- Interface commands
	- Return code from interface commands
	- Constants for the commands (structures for casting data)
	- UDP Management constants and structures

*************************************************************************/

#ifndef _SDLA_CHDLC_H
#  define _SDLC_CHDLC_H

/*------------------------------------------------------------------------
   Notes:

	All structres defined in this file are byte-aligned.  

	Compiler	Platform
	------------------------
	GNU C		Linux

------------------------------------------------------------------------*/

#ifndef	PACKED
#define	PACKED __attribute__((packed))
#endif	/* PACKED */


/* ----------------------------------------------------------------------------
 *        Constants defining the shared memory control block (mailbox)
 * --------------------------------------------------------------------------*/

#define PRI_BASE_ADDR_MB_STRUCT 	0xE000 	/* the base address of the mailbox structure on the adapter */
#define SEC_BASE_ADDR_MB_STRUCT 	0xE800 	/* the base address of the mailbox structure on the adapter */
#define SIZEOF_MB_DATA_BFR		2032	/* the size of the actual mailbox data area */
#define NUMBER_MB_RESERVED_BYTES	0x0B	/* the number of reserved bytes in the mailbox header area */


#define MIN_LGTH_CHDLC_DATA_CFG  	300 	/* min length of the CHDLC data field (for configuration purposes) */
#define PRI_MAX_NO_DATA_BYTES_IN_FRAME  15354 /* PRIMARY - max length of the CHDLC data field */

typedef struct {
	unsigned char opp_flag PACKED;			/* the opp flag */
	unsigned char command PACKED;			/* the user command */
	unsigned short buffer_length PACKED;		/* the data length */
  	unsigned char return_code PACKED;		/* the return code */
	unsigned char MB_reserved[NUMBER_MB_RESERVED_BYTES] PACKED;	/* reserved for later */
	unsigned char data[SIZEOF_MB_DATA_BFR] PACKED;	/* the data area */
} CHDLC_MAILBOX_STRUCT;

typedef struct {
        pid_t                   pid_num PACKED;
        CHDLC_MAILBOX_STRUCT     cmdarea PACKED;

} CMDBLOCK_STRUCT;




/* ----------------------------------------------------------------------------
 *                        Interface commands
 * --------------------------------------------------------------------------*/

/* global interface commands */
#define READ_GLOBAL_EXCEPTION_CONDITION	0x01
#define SET_GLOBAL_CONFIGURATION	0x02
#define READ_GLOBAL_CONFIGURATION	0x03
#define READ_GLOBAL_STATISTICS		0x04
#define FLUSH_GLOBAL_STATISTICS		0x05
#define SET_MODEM_STATUS		0x06	/* set status of DTR or RTS */
#define READ_MODEM_STATUS		0x07	/* read status of CTS and DCD */
#define READ_COMMS_ERROR_STATS		0x08	
#define FLUSH_COMMS_ERROR_STATS		0x09
#define SET_TRACE_CONFIGURATION		0x0A	/* set the line trace config */
#define READ_TRACE_CONFIGURATION	0x0B	/* read the line trace config */
#define READ_TRACE_STATISTICS		0x0C	/* read the trace statistics */
#define FLUSH_TRACE_STATISTICS		0x0D	/* flush the trace statistics */
#define FT1_MONITOR_STATUS_CTRL		0x1C	/* set the status of the S508/FT1 monitoring */
#define SET_FT1_CONFIGURATION		0x18	/* set the FT1 configuration */
#define READ_FT1_CONFIGURATION		0x19	/* read the FT1 configuration */
#define TRANSMIT_ASYNC_DATA_TO_FT1	0x1A	/* output asynchronous data to the FT1 */
#define RECEIVE_ASYNC_DATA_FROM_FT1	0x1B	/* receive asynchronous data from the FT1 */
#define FT1_MONITOR_STATUS_CTRL		0x1C	/* set the status of the FT1 monitoring */

#define READ_FT1_OPERATIONAL_STATS	0x1D	/* read the S508/FT1 operational statistics */
#define SET_FT1_MODE			0x1E	/* set the operational mode of the S508/FT1 module */

/* CHDLC-level interface commands */
#define READ_CHDLC_CODE_VERSION		0x20	
#define READ_CHDLC_EXCEPTION_CONDITION	0x21	/* read exception condition from the adapter */
#define SET_CHDLC_CONFIGURATION		0x22
#define READ_CHDLC_CONFIGURATION	0x23
#define ENABLE_CHDLC_COMMUNICATIONS	0x24
#define DISABLE_CHDLC_COMMUNICATIONS	0x25
#define READ_CHDLC_LINK_STATUS		0x26
#define READ_CHDLC_OPERATIONAL_STATS	0x27
#define FLUSH_CHDLC_OPERATIONAL_STATS	0x28
#define SET_CHDLC_INTERRUPT_TRIGGERS	0x30	/* set application interrupt triggers */
#define READ_CHDLC_INTERRUPT_TRIGGERS	0x31	/* read application interrupt trigger configuration */

/* Special UDP drivers management commands */
#define CPIPE_ENABLE_TRACING				0x50
#define CPIPE_DISABLE_TRACING				0x51
#define CPIPE_GET_TRACE_INFO				0x52
#define CPIPE_GET_IBA_DATA				0x53
#define CPIPE_FT1_READ_STATUS				0x54
#define CPIPE_DRIVER_STAT_IFSEND			0x55
#define CPIPE_DRIVER_STAT_INTR				0x56
#define CPIPE_DRIVER_STAT_GEN				0x57
#define CPIPE_FLUSH_DRIVER_STATS			0x58
#define CPIPE_ROUTER_UP_TIME				0x59

/* Driver specific commands for API */
#define	CHDLC_READ_TRACE_DATA		0xE4	/* read trace data */
#define TRACE_ALL                       0x00
#define TRACE_PROT			0x01
#define TRACE_DATA			0x02

#define DISCARD_RX_ERROR_FRAMES	0x0001

/* ----------------------------------------------------------------------------
 *                     Return codes from interface commands
 * --------------------------------------------------------------------------*/

#define COMMAND_OK				0x00

/* return codes from global interface commands */
#define NO_GLOBAL_EXCEP_COND_TO_REPORT		0x01	/* there is no CHDLC exception condition to report */
#define LGTH_GLOBAL_CFG_DATA_INVALID		0x01	/* the length of the passed global configuration data is invalid */
#define LGTH_TRACE_CFG_DATA_INVALID		0x01	/* the length of the passed trace configuration data is invalid */
#define IRQ_TIMEOUT_VALUE_INVALID		0x02	/* an invalid application IRQ timeout value was selected */
#define TRACE_CONFIG_INVALID			0x02	/* the passed line trace configuration is invalid */
#define ADAPTER_OPERATING_FREQ_INVALID		0x03	/* an invalid adapter operating frequency was selected */
#define TRC_DEAC_TMR_INVALID			0x03	/* the trace deactivation timer is invalid */
#define S508_FT1_ADPTR_NOT_PRESENT		0x0C	/* the S508/FT1 adapter is not present */
#define INVALID_FT1_STATUS_SELECTION            0x0D    /* the S508/FT1 status selection is invalid */
#define FT1_OP_STATS_NOT_ENABLED		0x0D    /* the FT1 operational statistics have not been enabled */
#define FT1_OP_STATS_NOT_AVAILABLE		0x0E    /* the FT1 operational statistics are not currently available */
#define S508_FT1_MODE_SELECTION_BUSY		0x0E	/* the S508/FT1 adapter is busy selecting the operational mode */

/* return codes from command READ_GLOBAL_EXCEPTION_CONDITION */
#define EXCEP_MODEM_STATUS_CHANGE		0x10		/* a modem status change occurred */
#define EXCEP_TRC_DISABLED			0x11		/* the trace has been disabled */
#define EXCEP_IRQ_TIMEOUT			0x12		/* IRQ timeout */

/* return codes from CHDLC-level interface commands */
#define NO_CHDLC_EXCEP_COND_TO_REPORT		0x21	/* there is no CHDLC exception condition to report */
#define CHDLC_COMMS_DISABLED			0x21	/* communications are not currently enabled */
#define CHDLC_COMMS_ENABLED			0x21	/* communications are currently enabled */
#define DISABLE_CHDLC_COMMS_BEFORE_CFG		0x21	/* CHDLC communications must be disabled before setting the configuration */
#define ENABLE_CHDLC_COMMS_BEFORE_CONN		0x21	/* communications must be enabled before using the CHDLC_CONNECT conmmand */
#define CHDLC_CFG_BEFORE_COMMS_ENABLED		0x22	/* perform a SET_CHDLC_CONFIGURATION before enabling comms */
#define LGTH_CHDLC_CFG_DATA_INVALID 		0x22	/* the length of the passed CHDLC configuration data is invalid */
#define LGTH_INT_TRIGGERS_DATA_INVALID		0x22	/* the length of the passed interrupt trigger data is invalid */
#define INVALID_IRQ_SELECTED			0x23	/* in invalid IRQ was selected in the SET_CHDLC_INTERRUPT_TRIGGERS */
#define INVALID_CHDLC_CFG_DATA			0x23	/* the passed CHDLC configuration data is invalid */
#define IRQ_TMR_VALUE_INVALID			0x24	/* an invalid application IRQ timer value was selected */
#define LARGER_PERCENT_TX_BFR_REQUIRED		0x24	/* a larger Tx buffer percentage is required */
#define LARGER_PERCENT_RX_BFR_REQUIRED		0x25	/* a larger Rx buffer percentage is required */
#define S514_BOTH_PORTS_SAME_CLK_MODE		0x26	/* S514 - both ports must have same clock mode */
#define INVALID_CMND_HDLC_STREAM_MODE           0x4E    /* the CHDLC interface command is invalid for HDLC streaming mode */
#define INVALID_CHDLC_COMMAND			0x4F	/* the defined CHDLC interface command is invalid */

/* return codes from command READ_CHDLC_EXCEPTION_CONDITION */
#define EXCEP_LINK_ACTIVE			0x30	/* the CHDLC link has become active */
#define EXCEP_LINK_INACTIVE_MODEM		0x31	/* the CHDLC link has become inactive (modem status) */
#define EXCEP_LINK_INACTIVE_KPALV		0x32	/* the CHDLC link has become inactive (keepalive status) */
#define EXCEP_IP_ADDRESS_DISCOVERED		0x33	/* the IP address has been discovered */
#define EXCEP_LOOPBACK_CONDITION		0x34	/* a loopback condition has occurred */


/* return code from command CHDLC_SEND_WAIT and CHDLC_SEND_NO_WAIT */
#define LINK_DISCONNECTED			0x21
#define NO_TX_BFRS_AVAIL			0x24


/* ----------------------------------------------------------------------------
 * Constants for the SET_GLOBAL_CONFIGURATION/READ_GLOBAL_CONFIGURATION commands
 * --------------------------------------------------------------------------*/

/* the global configuration structure */
typedef struct {
	unsigned short adapter_config_options PACKED;	/* adapter config options */
	unsigned short app_IRQ_timeout PACKED;		/* application IRQ timeout */
	unsigned long adapter_operating_frequency PACKED;	/* adapter operating frequency */
} GLOBAL_CONFIGURATION_STRUCT;

/* settings for the 'app_IRQ_timeout' */
#define MAX_APP_IRQ_TIMEOUT_VALUE	5000	/* the maximum permitted IRQ timeout */



/* ----------------------------------------------------------------------------
 *             Constants for the READ_GLOBAL_STATISTICS command
 * --------------------------------------------------------------------------*/

/* the global statistics structure */
typedef struct {
	unsigned short app_IRQ_timeout_count PACKED;
} GLOBAL_STATS_STRUCT;



/* ----------------------------------------------------------------------------
 *             Constants for the READ_COMMS_ERROR_STATS command
 * --------------------------------------------------------------------------*/

/* the communications error statistics structure */
typedef struct {
	unsigned short Rx_overrun_err_count PACKED;
	unsigned short CRC_err_count PACKED;	/* receiver CRC error count */
	unsigned short Rx_abort_count PACKED; 	/* abort frames recvd count */
	unsigned short Rx_dis_pri_bfrs_full_count PACKED;/* receiver disabled */
	unsigned short comms_err_stat_reserved_1 PACKED;/* reserved for later */
	unsigned short sec_Tx_abort_msd_Tx_int_count PACKED; /* secondary - abort frames transmitted count (missed Tx interrupt) */
	unsigned short missed_Tx_und_int_count PACKED;	/* missed tx underrun interrupt count */
        unsigned short sec_Tx_abort_count PACKED;   /*secondary-abort frames tx count */
	unsigned short DCD_state_change_count PACKED; /* DCD state change */
	unsigned short CTS_state_change_count PACKED; /* CTS state change */
} COMMS_ERROR_STATS_STRUCT;



/* ----------------------------------------------------------------------------
 *                  Constants used for line tracing
 * --------------------------------------------------------------------------*/

/* the trace configuration structure (SET_TRACE_CONFIGURATION/READ_TRACE_CONFIGURATION commands) */
typedef struct {
	unsigned char trace_config PACKED;		/* trace configuration */
	unsigned short trace_deactivation_timer PACKED;	/* trace deactivation timer */
	unsigned long ptr_trace_stat_el_cfg_struct PACKED;	/* a pointer to the line trace element configuration structure */
} LINE_TRACE_CONFIG_STRUCT;

/* 'trace_config' bit settings */
#define TRACE_INACTIVE		0x00	/* trace is inactive */
#define TRACE_ACTIVE		0x01	/* trace is active */
#define TRACE_DELAY_MODE	0x04	/* operate the trace in delay mode */
#define TRACE_DATA_FRAMES	0x08	/* trace Data frames */
#define TRACE_SLARP_FRAMES	0x10	/* trace SLARP frames */
#define TRACE_CDP_FRAMES	0x20	/* trace CDP frames */

/* the line trace status element configuration structure */
typedef struct {
	unsigned short number_trace_status_elements PACKED;	/* number of line trace elements */
	unsigned long base_addr_trace_status_elements PACKED;	/* base address of the trace element list */
	unsigned long next_trace_element_to_use PACKED;	/* pointer to the next trace element to be used */
	unsigned long base_addr_trace_buffer PACKED;		/* base address of the trace data buffer */
	unsigned long end_addr_trace_buffer PACKED;		/* end address of the trace data buffer */
} TRACE_STATUS_EL_CFG_STRUCT;

/* the line trace status element structure */
typedef struct {
	unsigned char opp_flag PACKED;			/* opp flag */
	unsigned short trace_length PACKED;		/* trace length */
	unsigned char trace_type PACKED;		/* trace type */
	unsigned short trace_time_stamp PACKED;	/* time stamp */
	unsigned short trace_reserved_1 PACKED;	/* reserved for later use */
	unsigned long trace_reserved_2 PACKED;		/* reserved for later use */
	unsigned long ptr_data_bfr PACKED;		/* ptr to the trace data buffer */
} TRACE_STATUS_ELEMENT_STRUCT;

/* "trace_type" bit settings */
#define TRACE_INCOMING 			0x00
#define TRACE_OUTGOINGING 		0x01
#define TRACE_INCOMING_ABORTED 		0x10
#define TRACE_INCOMING_CRC_ERROR 	0x20
#define TRACE_INCOMING_OVERRUN_ERROR 	0x40



/* the line trace statistics structure */
typedef struct {
	unsigned long frames_traced_count PACKED;	/* number of frames traced */
	unsigned long trc_frms_not_recorded_count PACKED;	/* number of trace frames discarded */
} LINE_TRACE_STATS_STRUCT;