1 /*
2  * SBE 2T3E3 synchronous serial card driver for Linux
3  *
4  * Copyright (C) 2009-2010 Krzysztof Halasa <khc@pm.waw.pl>
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms of version 2 of the GNU General Public License
8  * as published by the Free Software Foundation.
9  *
10  * This code is based on a driver written by SBE Inc.
11  */
12 
13 #ifndef CTRL_H
14 #define CTRL_H
15 
16 #define SBE_2T3E3_OFF					0
17 #define SBE_2T3E3_ON					1
18 
19 #define SBE_2T3E3_LED_NONE				0
20 #define SBE_2T3E3_LED_GREEN				1
21 #define SBE_2T3E3_LED_YELLOW				2
22 
23 #define SBE_2T3E3_CABLE_LENGTH_LESS_THAN_255_FEET	0
24 #define SBE_2T3E3_CABLE_LENGTH_GREATER_THAN_255_FEET	1
25 
26 #define SBE_2T3E3_CRC_16				0
27 #define SBE_2T3E3_CRC_32				1
28 
29 #define SBE_2T3E3_PANEL_FRONT				0
30 #define SBE_2T3E3_PANEL_REAR				1
31 
32 #define SBE_2T3E3_FRAME_MODE_HDLC			0
33 #define SBE_2T3E3_FRAME_MODE_TRANSPARENT		1
34 #define SBE_2T3E3_FRAME_MODE_RAW			2
35 
36 #define SBE_2T3E3_FRAME_TYPE_E3_G751			0
37 #define SBE_2T3E3_FRAME_TYPE_E3_G832			1
38 #define SBE_2T3E3_FRAME_TYPE_T3_CBIT			2
39 #define SBE_2T3E3_FRAME_TYPE_T3_M13			3
40 
41 #define SBE_2T3E3_FRACTIONAL_MODE_NONE			0
42 #define SBE_2T3E3_FRACTIONAL_MODE_0			1
43 #define SBE_2T3E3_FRACTIONAL_MODE_1			2
44 #define SBE_2T3E3_FRACTIONAL_MODE_2			3
45 
46 #define SBE_2T3E3_SCRAMBLER_OFF				0
47 #define SBE_2T3E3_SCRAMBLER_LARSCOM			1
48 #define SBE_2T3E3_SCRAMBLER_ADC_KENTROX_DIGITAL		2
49 
50 #define SBE_2T3E3_TIMING_LOCAL				0
51 #define SBE_2T3E3_TIMING_LOOP				1
52 
53 #define SBE_2T3E3_LOOPBACK_NONE				0
54 #define SBE_2T3E3_LOOPBACK_ETHERNET			1
55 #define SBE_2T3E3_LOOPBACK_FRAMER			2
56 #define SBE_2T3E3_LOOPBACK_LIU_DIGITAL			3
57 #define SBE_2T3E3_LOOPBACK_LIU_ANALOG			4
58 #define SBE_2T3E3_LOOPBACK_LIU_REMOTE			5
59 
60 #define SBE_2T3E3_PAD_COUNT_1				1
61 #define SBE_2T3E3_PAD_COUNT_2				2
62 #define SBE_2T3E3_PAD_COUNT_3				3
63 #define SBE_2T3E3_PAD_COUNT_4				4
64 
65 #define SBE_2T3E3_CHIP_21143				0
66 #define SBE_2T3E3_CHIP_CPLD				1
67 #define SBE_2T3E3_CHIP_FRAMER				2
68 #define SBE_2T3E3_CHIP_LIU				3
69 
70 #define SBE_2T3E3_LOG_LEVEL_NONE			0
71 #define SBE_2T3E3_LOG_LEVEL_ERROR			1
72 #define SBE_2T3E3_LOG_LEVEL_WARNING			2
73 #define SBE_2T3E3_LOG_LEVEL_INFO			3
74 
75 /* commands */
76 #define SBE_2T3E3_PORT_GET				0
77 #define SBE_2T3E3_PORT_SET				1
78 #define SBE_2T3E3_PORT_GET_STATS			2
79 #define SBE_2T3E3_PORT_DEL_STATS			3
80 #define SBE_2T3E3_PORT_READ_REGS			4
81 #define SBE_2T3E3_LOG_LEVEL				5
82 #define SBE_2T3E3_PORT_WRITE_REGS			6
83 
84 #define NG_SBE_2T3E3_NODE_TYPE  "sbe2T3E3"
85 #define NG_SBE_2T3E3_COOKIE     0x03800891
86 
87 typedef struct t3e3_param {
88 	u_int8_t frame_mode;		/* FRAME_MODE_* */
89 	u_int8_t crc;			/* CRC_* */
90 	u_int8_t receiver_on;		/* ON/OFF */
91 	u_int8_t transmitter_on;	/* ON/OFF */
92 	u_int8_t frame_type;		/* FRAME_TYPE_* */
93 	u_int8_t panel;			/* PANEL_* */
94 	u_int8_t line_build_out;	/* ON/OFF */
95 	u_int8_t receive_equalization;	/* ON/OFF */
96 	u_int8_t transmit_all_ones;	/* ON/OFF */
97 	u_int8_t loopback;		/* LOOPBACK_* */
98 	u_int8_t clock_source;		/* TIMING_* */
99 	u_int8_t scrambler;		/* SCRAMBLER_* */
100 	u_int8_t pad_count;		/* PAD_COUNT_* */
101 	u_int8_t log_level;		/* LOG_LEVEL_* - unused */
102 	u_int8_t fractional_mode;	/* FRACTIONAL_MODE_* */
103 	u_int8_t bandwidth_start;	/* 0-255 */
104 	u_int8_t bandwidth_stop;	/* 0-255 */
105 } t3e3_param_t;
106 
107 typedef struct t3e3_stats {
108 	u_int64_t in_bytes;
109 	u32 in_packets, in_dropped;
110 	u32 in_errors, in_error_desc, in_error_coll, in_error_drib,
111 		in_error_crc, in_error_mii;
112 	u_int64_t out_bytes;
113 	u32 out_packets, out_dropped;
114 	u32 out_errors, out_error_jab, out_error_lost_carr,
115 		out_error_no_carr, out_error_link_fail, out_error_underflow,
116 		out_error_dereferred;
117 	u_int8_t LOC, LOF, OOF, LOS, AIS, FERF, IDLE, AIC, FEAC;
118 	u_int16_t FEBE_code;
119 	u32 LCV, FRAMING_BIT, PARITY_ERROR, FEBE_count, CP_BIT;
120 } t3e3_stats_t;
121 
122 
123 typedef struct t3e3_resp {
124 	union {
125 		t3e3_param_t param;
126 		t3e3_stats_t stats;
127 		u32 data;
128 	} u;
129 } t3e3_resp_t;
130 
131 #endif /* CTRL_H */
132