OpenWrt – Blame information for rev 3

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2012 OpenWrt.org
3  
4 START=97
5 USE_PROCD=1
6  
7 EXTRA_COMMANDS="status lucistat"
8 EXTRA_HELP=" status Get DSL status information
9 lucistat Get status information if lua friendly format"
10  
11 [ -f /lib/functions/lantiq_dsl.sh ] && . /lib/functions/lantiq_dsl.sh
12  
13 #
14 # ITU-T G.997.1 (06/2012) - Section 7.3.1.1.1 (xTU transmission system enabling (XTSE))
15 # ITU-T G.997.1 Amendment 2 (04/2013) - Section 2.1 - (Vectoring mode enable (VECTORMODE_ENABLE))
16 #
17 # G.992.1 Annex A
18 # G.992.2 Annex A
19 # G.992.3 Annex A / L-US1 / L_US-2 / M
20 # G.992.5 Annex A / M
21 # G.993.2 Annex A/B/C
22 # G.993.5 Annex A/B/C
23 xtse_xdsl_a="05_01_04_00_4C_01_04_07"
24  
25 # G.992.1 Annex B
26 # G.992.3 Annex B
27 # G.992.5 Annex B
28 # G.993.2 Annex A/B/C
29 # G.993.5 Annex A/B/C
30 xtse_xdsl_b="10_00_10_00_00_04_00_07"
31  
32 # G.992.1 Annex B
33 # G.992.3 Annex B
34 # G.992.3 Annex J
35 # G.992.5 Annex B
36 # G.992.5 Annex J
37 # G.993.2 Annex A/B/C
38 # G.993.5 Annex A/B/C
39 xtse_xdsl_j="10_00_10_40_00_04_01_07"
40  
41 # G.992.1 Annex B
42 xtse_xdsl_bdmt="10_00_00_00_00_00_00_00"
43  
44 # G.992.3 Annex B
45 xtse_xdsl_b2="00_00_10_00_00_00_00_00"
46  
47 # G.992.5 Annex B
48 xtse_xdsl_b2p="00_00_00_00_00_04_00_00"
49  
50 # ANSI T1.413
51 xtse_xdsl_at1="01_00_00_00_00_00_00_00"
52  
53 # G.992.2 Annex A
54 xtse_xdsl_alite="00_01_00_00_00_00_00_00"
55  
56 # G.992.1 Annex A
57 xtse_xdsl_admt="04_00_00_00_00_00_00_00"
58  
59 # G.992.3 Annex A
60 xtse_xdsl_a2="00_00_04_00_00_00_00_00"
61  
62 # G.992.5 Annex A
63 xtse_xdsl_a2p="00_00_00_00_00_01_00_00"
64  
65 # G.992.3 Annex L
66 xtse_xdsl_l="00_00_00_00_0C_00_00_00"
67  
68 # G.992.3 Annex M
69 # G.992.5 Annex M
70 xtse_xdsl_m="00_00_00_00_40_00_04_00"
71  
72 # G.992.3 Annex M
73 xtse_xdsl_m2="00_00_00_00_40_00_00_00"
74  
75 # G.992.5 Annex M
76 xtse_xdsl_m2p="00_00_00_00_00_00_04_00"
77  
78 #
79 # ITU-T G.994.1 (06/2012) - Table 2 (Mandatory carrier sets)
80 #
81  
82 # A43
83 tone_adsl_a="0x142" # A43C + J43 + A43
84 tone_vdsl_a="0x142" # A43C + J43 + A43
85  
86 # A43 + V43
87 tone_adsl_av="0x142" # A43C + J43 + A43
88 tone_vdsl_av="0x146" # A43C + J43 + A43 + V43
89  
90 # B43
91 tone_adsl_b="0x81" # B43 + B43c
92 tone_vdsl_b="0x1" # B43
93  
94 # B43 + V43
95 tone_adsl_bv="0x81" # B43 + B43c
96 tone_vdsl_bv="0x5" # B43 + V43
97  
98 # create ADSL autoboot script. Used for SNR margin tweak
99 autoboot_script() {
100 echo "[WaitForConfiguration]={
101 locs 0 $1
102 }
103  
104 [WaitForLinkActivate]={
105 }
106  
107 [WaitForRestart]={
108 }
109  
110 [Common]={
111 }" > /tmp/dsl.scr
112 }
113  
114 lowlevel_cfg() {
115 echo "# VRX Low Level Configuration File
116 #
117 # Parameters must be separated by tabs or spaces.
118 # Empty lines and comments will be ignored.
119 #
120  
121 # nFilter
122 #
123 # NA = -1
124 # OFF = 0
125 # ISDN = 1
126 # POTS = 2
127 # POTS_2 = 3
128 # POTS_3 = 4
129 #
130 # (dec)
131 -1
132  
133 # nHsToneGroupMode nHsToneGroup_A nHsToneGroup_V nHsToneGroup_AV
134 #
135 # NA = -1 NA = -1 see see
136 # AUTO = 0 VDSL2_B43 = 0x0001 nHsToneGroup_A nHsToneGroup_A
137 # MANUAL = 1 VDSL2_A43 = 0x0002
138 # VDSL2_V43 = 0x0004
139 # VDSL1_V43P = 0x0008
140 # VDSL1_V43I = 0x0010
141 # ADSL1_C43 = 0x0020
142 # ADSL2_J43 = 0x0040
143 # ADSL2_B43C = 0x0080
144 # ADSL2_A43C = 0x0100
145 #
146 # (dec) (hex) (hex) (hex)
147 1 $1 $2 0x0
148  
149 # nBaseAddr nIrqNum
150 #
151 # (hex) (dec)
152 0x1e116000 63
153  
154 # nUtopiaPhyAdr nUtopiaBusWidth nPosPhyParity
155 # default(16b) = 0 NA = -1
156 # 8-bit = 1 ODD = 0
157 # 16-bit = 2
158 #
159 #
160 # (hex) (dec) (dec)
161 0xFF 0 0
162  
163 # bNtrEnable
164 #
165 # (dec)
166 0" > /tmp/lowlevel.cfg
167 }
168  
169 service_triggers() {
170 procd_add_reload_trigger network
171 }
172  
173 start_service() {
174 local annex
175 local firmware
176 local tone
177 local tone_adsl
178 local tone_vdsl
179 local xtse
180 local xfer_mode
181 local line_mode
182 local tc_layer
183 local mode
184 local lowlevel
185 local snr
186  
187 config_load network
188 config_get tone dsl tone
189 config_get annex dsl annex
190 config_get firmware dsl firmware
191 config_get xfer_mode dsl xfer_mode
192 config_get line_mode dsl line_mode
193 config_get snr dsl ds_snr_offset
194  
195 eval "xtse=\"\${xtse_xdsl_$annex}\""
196  
197 case "${xfer_mode}" in
198 atm)
199 tc_layer="-T1:0x1:0x1_1:0x1:0x1"
200 ;;
201 ptm)
202 tc_layer="-T2:0x1:0x1_2:0x1:0x1"
203 ;;
204 esac
205  
206 case "${line_mode}" in
207 adsl)
208 mode="-M1"
209  
210 # mask out VDSL bits when ADSL is requested
211 xtse="${xtse%_*}_00"
212 ;;
213 vdsl)
214 mode="-M2"
215  
216 # mask out ADSL bits when VDSL is requested
217 xtse="00_00_00_00_00_00_00_${xtse##*_}"
218 ;;
219 esac
220  
221 local annexgpio="/sys/class/gpio/annex"
222 if [ -d "${annexgpio}a" ] && [ -d "${annexgpio}b" ]; then
223 case "${annex}" in
224 a*|l*|m*)
225 echo 1 > "${annexgpio}a/value"
226 echo 0 > "${annexgpio}b/value"
227 ;;
228 b*|j*)
229 echo 0 > "${annexgpio}a/value"
230 echo 1 > "${annexgpio}b/value"
231 ;;
232 esac
233 fi
234  
235 if [ -z "${firmware}" ]; then
236 # search for the firmware provided by dsl-vrx200-firmware-xdsl-*
237 if grep -qE "system type.*: (VR9|xRX200)" /proc/cpuinfo; then
238 case "${annex}" in
239 a*|l*|m*)
240 if [ -f "/lib/firmware/lantiq-vrx200-a.bin" ]; then
241 firmware="/lib/firmware/lantiq-vrx200-a.bin"
242 elif [ -f "/tmp/lantiq-vrx200-a.bin" ]; then
243 firmware="/tmp/lantiq-vrx200-a.bin"
244 elif [ -f "/lib/firmware/lantiq-vrx200-b.bin" ] && [ -f "/lib/firmware/lantiq-vrx200-b-to-a.bspatch" ]; then
245 bspatch /lib/firmware/lantiq-vrx200-b.bin \
246 /tmp/lantiq-vrx200-a.bin \
247 /lib/firmware/lantiq-vrx200-b-to-a.bspatch
248 firmware="/tmp/lantiq-vrx200-a.bin"
249 else
250 echo "firmware for annex a not found"
251 return 1
252 fi
253 ;;
254 b*|j*)
3 office 255 if [ -f "/lib/firmware/lantiq-vrx200-b.bin" ]; then
1 office 256 firmware="/lib/firmware/lantiq-vrx200-b.bin"
257 elif [ -f "/tmp/lantiq-vrx200-b.bin" ]; then
258 firmware="/tmp/lantiq-vrx200-b.bin"
259 elif [ -f "/lib/firmware/lantiq-vrx200-a.bin" ] && [ -f "/lib/firmware/lantiq-vrx200-a-to-b.bspatch" ]; then
260 bspatch /lib/firmware/lantiq-vrx200-a.bin \
261 /tmp/lantiq-vrx200-b.bin \
262 /lib/firmware/lantiq-vrx200-a-to-b.bspatch
263 firmware="/tmp/lantiq-vrx200-b.bin"
264 else
265 echo "firmware for annex b not found"
266 return 1
267 fi
268 ;;
269 *)
270 echo "annex type not supported use a or b"
271 return 1
272 ;;
273 esac
274 fi
275 fi
276  
277 [ -z "${firmware}" ] && firmware=/lib/firmware/vdsl.bin
278 [ -f "${firmware}" ] || {
279 echo failed to find $firmware
280 return 1
281 }
282  
283 eval "tone_adsl=\"\${tone_adsl_$tone}\""
284 eval "tone_vdsl=\"\${tone_vdsl_$tone}\""
285 [ -n "${tone_adsl}" ] && [ -n "${tone_vdsl}" ] && {
286 lowlevel_cfg "${tone_adsl}" "${tone_vdsl}"
287 lowlevel="-l /tmp/lowlevel.cfg"
288 }
289  
290 [ -z "${snr}" ] || {
291 # for SNR offset setting
292 autoboot_script "$snr"
293 autoboot="-a /tmp/dsl.scr -A /tmp/dsl.scr"
294 }
295  
296 procd_open_instance
297 procd_set_param command /sbin/vdsl_cpe_control \
298 -i$xtse \
299 -n /sbin/dsl_notify.sh \
300 -f ${firmware} \
301 $lowlevel \
302 ${mode} \
303 ${tc_layer} \
304 $autoboot
305 procd_close_instance
306 }
307  
308 stop_service() {
309 # do not use dsl_cmd to not block when this is locked up by some other proess
310 echo quit > /tmp/pipe/dsl_cpe0_cmd
311 DSL_NOTIFICATION_TYPE="DSL_INTERFACE_STATUS" \
312 DSL_INTERFACE_STATUS="DOWN" \
313 /sbin/dsl_notify.sh
314 }