blob: 0832a5e1c18f2fa1285860a259d2e28412e6c410 [file] [log] [blame]
developer3abe1ad2022-01-24 11:13:32 +08001#!/bin/ash
2
developer10946c32022-03-04 18:28:43 +08003interface=$1 # phy0/phy1/ra0
4cmd_type=$2 # set/show/e2p/mac
developer3abe1ad2022-01-24 11:13:32 +08005full_cmd=$3
developer9b7cdad2022-03-10 14:24:55 +08006interface_ori=${interface}
developer3abe1ad2022-01-24 11:13:32 +08007
8work_mode="RUN" # RUN/PRINT/DEBUG
developer10946c32022-03-04 18:28:43 +08009tmp_file="/tmp/iwpriv_wrapper"
developer3abe1ad2022-01-24 11:13:32 +080010phy_idx=$(echo ${interface} | tr -dc '0-9')
11
developer3abe1ad2022-01-24 11:13:32 +080012function do_cmd() {
13 case ${work_mode} in
14 "RUN")
15 eval "$1"
16 ;;
17 "PRINT")
18 echo "$1"
19 ;;
20 "DEBUG")
21 eval "$1"
22 echo "$1"
23 ;;
24 esac
25}
26
developer9b7cdad2022-03-10 14:24:55 +080027function print_debug() {
28 if [ "${work_mode}" = "DEBUG" ]; then
29 echo "$1"
30 fi
31}
32
developer10946c32022-03-04 18:28:43 +080033function write_dmesg() {
34 echo "$1" > /dev/kmsg
35}
36
developer3abe1ad2022-01-24 11:13:32 +080037function record_config() {
38 if [ -f ${tmp_file} ]; then
39 if grep -q $1 ${tmp_file}; then
40 sed -i "/$1/c\\$1=$2" ${tmp_file}
41 else
42 echo "$1=$2" >> ${tmp_file}
43 fi
44 else
45 echo "$1=$2" >> ${tmp_file}
46 fi
47}
48
49function get_config() {
developer10946c32022-03-04 18:28:43 +080050 if [ ! -f ${tmp_file} ]; then
51 echo ""
52 return
53 fi
54
55 if grep -q $1 ${tmp_file}; then
56 echo "$(cat ${tmp_file} | grep $1 | sed s/=/' '/g | cut -d " " -f 2)"
57 else
58 echo ""
59 fi
developer3abe1ad2022-01-24 11:13:32 +080060}
61
developer3abe1ad2022-01-24 11:13:32 +080062function simple_convert() {
63 if [ "$1" = "ATETXCNT" ]; then
64 echo "tx_count"
65 elif [ "$1" = "ATETXLEN" ]; then
66 echo "tx_length"
67 elif [ "$1" = "ATETXMCS" ]; then
68 echo "tx_rate_idx"
69 elif [ "$1" = "ATEVHTNSS" ]; then
70 echo "tx_rate_nss"
71 elif [ "$1" = "ATETXLDPC" ]; then
72 echo "tx_rate_ldpc"
73 elif [ "$1" = "ATETXSTBC" ]; then
74 echo "tx_rate_stbc"
75 elif [ "$1" = "ATEPKTTXTIME" ]; then
76 echo "tx_time"
77 elif [ "$1" = "ATEIPG" ]; then
78 echo "tx_ipg"
79 elif [ "$1" = "ATEDUTYCYCLE" ]; then
80 echo "tx_duty_cycle"
81 elif [ "$1" = "ATETXFREQOFFSET" ]; then
82 echo "freq_offset"
83 else
developer9b7cdad2022-03-10 14:24:55 +080084 echo "unknown param: $1"
developer3abe1ad2022-01-24 11:13:32 +080085 fi
86}
87
88function convert_tx_mode() {
89 if [ "$1" = "0" ]; then
90 echo "cck"
91 elif [ "$1" = "1" ]; then
92 echo "ofdm"
93 elif [ "$1" = "2" ]; then
94 echo "ht"
95 elif [ "$1" = "4" ]; then
96 echo "vht"
97 elif [ "$1" = "8" ]; then
98 echo "he_su"
99 elif [ "$1" = "9" ]; then
100 echo "he_er"
101 elif [ "$1" = "10" ]; then
102 echo "he_tb"
103 elif [ "$1" = "11" ]; then
104 echo "he_mu"
105 else
developer9b7cdad2022-03-10 14:24:55 +0800106 echo "unknown tx mode: $1"
developer3abe1ad2022-01-24 11:13:32 +0800107 fi
108}
109
110function convert_gi {
111 local tx_mode=$1
112 local val=$2
113 local sgi="0"
114 local he_ltf="0"
115
116 case ${tx_mode} in
117 "ht"|"vht")
118 sgi=${val}
119 ;;
120 "he_su"|"he_er")
121 case ${val} in
122 "0")
123 ;;
124 "1")
125 he_ltf="1"
126 ;;
127 "2")
128 sgi="1"
129 he_ltf="1"
130 ;;
131 "3")
132 sgi="2"
133 he_ltf="2"
134 ;;
135 "4")
136 he_ltf="2"
137 ;;
138 *)
139 echo "unknown gi"
140 esac
141 ;;
142 "he_mu")
143 case ${val} in
144 "0")
145 he_ltf="2"
146 ;;
147 "1")
148 he_ltf="1"
149 ;;
150 "2")
151 sgi="1"
152 he_ltf="1"
153 ;;
154 "3")
155 sgi="2"
156 he_ltf="2"
157 ;;
158 *)
159 echo "unknown gi"
160 esac
161 ;;
162 "he_tb")
163 case ${val} in
164 "0")
165 sgi="1"
166 ;;
167 "1")
168 sgi="1"
169 he_ltf="1"
170 ;;
171 "2")
172 sgi="2"
173 he_ltf="2"
174 ;;
175 *)
176 echo "unknown gi"
177 esac
178 ;;
179 *)
developer9b7cdad2022-03-10 14:24:55 +0800180 print_debug "legacy mode no need gi"
developer3abe1ad2022-01-24 11:13:32 +0800181 esac
182
183 do_cmd "mt76-test ${interface} set tx_rate_sgi=${sgi} tx_ltf=${he_ltf}"
184}
185
186function convert_channel {
187 local band=$(echo $1 | sed s/:/' '/g | cut -d " " -f 2)
188 local ch=$(echo $1 | sed s/:/' '/g | cut -d " " -f 1)
189 local bw=$(get_config "ATETXBW" | cut -d ":" -f 1)
developer10946c32022-03-04 18:28:43 +0800190 local bw_str="HT20"
developer3abe1ad2022-01-24 11:13:32 +0800191
developer9b7cdad2022-03-10 14:24:55 +0800192 if [[ $1 != *":"* ]] || [ "${band}" = "0" ]; then
developer3abe1ad2022-01-24 11:13:32 +0800193 case ${bw} in
194 "1")
developer461cb542022-04-29 18:17:44 +0800195 if [ "${ch}" -lt "3" ] || [ "${ch}" -gt "12" ]; then
196 local bw_str="HT20"
developer3abe1ad2022-01-24 11:13:32 +0800197 else
developer461cb542022-04-29 18:17:44 +0800198 local bw_str="HT40+"
199 ch=$(expr ${ch} - "2")
developer3abe1ad2022-01-24 11:13:32 +0800200 fi
201 ;;
developer3abe1ad2022-01-24 11:13:32 +0800202 esac
developera6267142022-01-26 20:50:22 +0800203 elif [ "${band}" = "1" ]; then
developer3abe1ad2022-01-24 11:13:32 +0800204 case ${bw} in
developera6267142022-01-26 20:50:22 +0800205 "5")
developer10946c32022-03-04 18:28:43 +0800206 bw_str="160MHz"
207 if [ ${ch} -lt "68" ]; then
208 ch="36"
209 elif [ ${ch} -lt "100" ]; then
210 ch="68"
211 elif [ ${ch} -lt "132" ]; then
212 ch="100"
213 elif [ ${ch} -lt "181" ]; then
214 ch="149"
215 fi
developera6267142022-01-26 20:50:22 +0800216 ;;
developer3abe1ad2022-01-24 11:13:32 +0800217 "2")
developer10946c32022-03-04 18:28:43 +0800218 bw_str="80MHz"
219 if [ ${ch} -lt "52" ]; then
220 ch="36"
221 elif [ ${ch} -lt "68" ]; then
222 ch="52"
223 elif [ ${ch} -lt "84" ]; then
224 ch="68"
225 elif [ ${ch} -lt "100" ]; then
226 ch="84"
227 elif [ ${ch} -lt "116" ]; then
228 ch="100"
229 elif [ ${ch} -lt "132" ]; then
230 ch="116"
231 elif [ ${ch} -lt "149" ]; then
232 ch="132"
233 elif [ ${ch} -lt "165" ]; then
234 ch="149"
235 elif [ ${ch} -lt "181" ]; then
236 ch="165"
237 fi
developer3abe1ad2022-01-24 11:13:32 +0800238 ;;
239 "1")
developer10946c32022-03-04 18:28:43 +0800240 if [ ${ch} -lt "44" ]; then
241 ch=$([ "${ch}" -lt "40" ] && echo "36" || echo "40")
242 bw_str=$([ "${ch}" -le "38" ] && echo "HT40+" || echo "HT40-")
243 elif [ ${ch} -lt "52" ]; then
244 ch=$([ "${ch}" -lt "48" ] && echo "44" || echo "48")
245 bw_str=$([ "${ch}" -le "46" ] && echo "HT40+" || echo "HT40-")
246 elif [ ${ch} -lt "60" ]; then
247 ch=$([ "${ch}" -lt "56" ] && echo "52" || echo "56")
248 bw_str=$([ "${ch}" -le "54" ] && echo "HT40+" || echo "HT40-")
249 elif [ ${ch} -lt "68" ]; then
250 ch=$([ "${ch}" -lt "64" ] && echo "60" || echo "64")
251 bw_str=$([ "${ch}" -le "62" ] && echo "HT40+" || echo "HT40-")
252 elif [ ${ch} -lt "76" ]; then
253 ch=$([ "${ch}" -lt "72" ] && echo "68" || echo "72")
254 bw_str=$([ "${ch}" -le "70" ] && echo "HT40+" || echo "HT40-")
255 elif [ ${ch} -lt "84" ]; then
256 ch=$([ "${ch}" -lt "80" ] && echo "76" || echo "80")
257 bw_str=$([ "${ch}" -le "78" ] && echo "HT40+" || echo "HT40-")
258 elif [ ${ch} -lt "92" ]; then
259 ch=$([ "${ch}" -lt "88" ] && echo "84" || echo "88")
260 bw_str=$([ "${ch}" -le "86" ] && echo "HT40+" || echo "HT40-")
261 elif [ ${ch} -lt "100" ]; then
262 ch=$([ "${ch}" -lt "96" ] && echo "92" || echo "96")
263 bw_str=$([ "${ch}" -le "94" ] && echo "HT40+" || echo "HT40-")
264 elif [ ${ch} -lt "108" ]; then
265 ch=$([ "${ch}" -lt "104" ] && echo "100" || echo "104")
266 bw_str=$([ "${ch}" -le "102" ] && echo "HT40+" || echo "HT40-")
267 elif [ ${ch} -lt "116" ]; then
268 ch=$([ "${ch}" -lt "112" ] && echo "108" || echo "112")
269 bw_str=$([ "${ch}" -le "110" ] && echo "HT40+" || echo "HT40-")
270 elif [ ${ch} -lt "124" ]; then
271 ch=$([ "${ch}" -lt "120" ] && echo "116" || echo "120")
272 bw_str=$([ "${ch}" -le "118" ] && echo "HT40+" || echo "HT40-")
273 elif [ ${ch} -lt "132" ]; then
274 ch=$([ "${ch}" -lt "128" ] && echo "124" || echo "128")
275 bw_str=$([ "${ch}" -le "126" ] && echo "HT40+" || echo "HT40-")
276 elif [ ${ch} -lt "140" ]; then
277 ch=$([ "${ch}" -lt "136" ] && echo "132" || echo "136")
278 bw_str=$([ "${ch}" -le "134" ] && echo "HT40+" || echo "HT40-")
279 elif [ ${ch} -lt "149" ]; then
280 ch=$([ "${ch}" -lt "144" ] && echo "140" || echo "144")
281 bw_str=$([ "${ch}" -le "142" ] && echo "HT40+" || echo "HT40-")
282 elif [ ${ch} -lt "157" ]; then
283 ch=$([ "${ch}" -lt "153" ] && echo "149" || echo "153")
284 bw_str=$([ "${ch}" -le "151" ] && echo "HT40+" || echo "HT40-")
285 elif [ ${ch} -lt "165" ]; then
286 ch=$([ "${ch}" -lt "161" ] && echo "157" || echo "161")
287 bw_str=$([ "${ch}" -le "159" ] && echo "HT40+" || echo "HT40-")
288 elif [ ${ch} -lt "173" ]; then
289 ch=$([ "${ch}" -lt "169" ] && echo "165" || echo "169")
290 bw_str=$([ "${ch}" -le "167" ] && echo "HT40+" || echo "HT40-")
291 elif [ ${ch} -lt "181" ]; then
292 ch=$([ "${ch}" -lt "177" ] && echo "173" || echo "177")
293 bw_str=$([ "${ch}" -le "175" ] && echo "HT40+" || echo "HT40-")
developer3abe1ad2022-01-24 11:13:32 +0800294 fi
295 ;;
296 "0")
297 local bw_str="HT20"
298 ;;
299 esac
developera6267142022-01-26 20:50:22 +0800300 else
301 echo "6G Todo"
developer3abe1ad2022-01-24 11:13:32 +0800302 fi
303
304 do_cmd "iw dev mon${phy_idx} set channel ${ch} ${bw_str}"
305}
306
developer10946c32022-03-04 18:28:43 +0800307function convert_rxstat {
308 local res=$(do_cmd "mt76-test ${interface} dump stats")
309 local mdrdy=$(echo "${res}" | grep "rx_packets" | cut -d "=" -f 2)
310 local fcs_error=$(echo "${res}" | grep "rx_fcs_error" | cut -d "=" -f 2)
311 local rcpi=$(echo "${res}" | grep "last_rcpi" | cut -d "=" -f 2 | sed 's/,/ /g')
312 local ib_rssi=$(echo "${res}" | grep "last_ib_rssi" | cut -d "=" -f 2 | sed 's/,/ /g')
313 local wb_rssi=$(echo "${res}" | grep "last_wb_rssi" | cut -d "=" -f 2 | sed 's/,/ /g')
314 local rx_ok=$(expr ${mdrdy} - ${fcs_error})
315
developer461cb542022-04-29 18:17:44 +0800316 write_dmesg "rcpi: ${rcpi}"
317 write_dmesg "fagc rssi ib: ${ib_rssi}"
318 write_dmesg "fagc rssi wb: ${wb_rssi}"
319 write_dmesg "all_mac_rx_mdrdy_cnt: ${mdrdy}"
320 write_dmesg "all_mac_rx_fcs_err_cnt: ${fcs_error}"
developer9b7cdad2022-03-10 14:24:55 +0800321 write_dmesg "all_mac_rx_ok_cnt : ${rx_ok}"
developer10946c32022-03-04 18:28:43 +0800322}
323
324function change_band_idx {
325 local old_idx=$(get_config "ATECTRLBANDIDX")
326 local new_idx=$1
327
328 if [ -z "${old_idx}" ] && [ "${new_idx}" == "0" ]; then
329 return
330 fi
331
332 if [ "${old_idx}" != "${new_idx}" ]; then
333 if [ -z "${old_idx}" ]; then
334 old_idx=0
335 fi
336
337 interface="phy${old_idx}"
338 phy_idx=${old_idx}
339 do_ate_work "ATESTOP"
340
341 interface="phy${new_idx}"
342 phy_idx=${new_idx}
343 do_ate_work "ATESTART"
344
345 record_config "ATECTRLBANDIDX" ${new_idx}
346 fi
347}
348
349function set_mac_addr {
350 record_config ${cmd} ${param}
351
352 local addr1=$(get_config "ATEDA")
353 local addr2=$(get_config "ATESA")
354 local addr3=$(get_config "ATEBSSID")
355
356 if [ -z "${addr1}" ]; then
357 addr1="00:11:22:33:44:55"
358 fi
359 if [ -z "${addr2}" ]; then
360 addr2="00:11:22:33:44:55"
361 fi
362 if [ -z "${addr3}" ]; then
363 addr3="00:11:22:33:44:55"
364 fi
365
366 do_cmd "mt76-test phy${phy_idx} set mac_addrs=${addr1},${addr2},${addr3}"
367}
368
developera6267142022-01-26 20:50:22 +0800369function do_ate_work() {
370 local ate_cmd=$1
371
372 case ${ate_cmd} in
373 "ATESTART")
374 local if_str=$(ifconfig | grep mon${phy_idx})
375
376 if [ ! -z "${if_str}" -a "${if_str}" != " " ]; then
377 echo "ATE already starts."
378 else
379 do_cmd "iw phy ${interface} interface add mon${phy_idx} type monitor"
380 do_cmd "iw dev wlan${phy_idx} del"
381 do_cmd "ifconfig mon${phy_idx} up"
developer9b7cdad2022-03-10 14:24:55 +0800382 do_cmd "iw reg set VV"
developera6267142022-01-26 20:50:22 +0800383 fi
384 ;;
385 "ATESTOP")
386 local if_str=$(ifconfig | grep mon${phy_idx})
387
388 if [ -z "${if_str}" -a "${if_str}" != " " ]; then
389 echo "ATE does not start."
390 else
391 do_cmd "mt76-test ${interface} set state=off"
392 do_cmd "iw dev mon${phy_idx} del"
393 do_cmd "iw phy ${interface} interface add wlan${phy_idx} type managed"
developer461cb542022-04-29 18:17:44 +0800394 do_cmd "mt76-test ${interface} set aid=0"
developera6267142022-01-26 20:50:22 +0800395 fi
developer10946c32022-03-04 18:28:43 +0800396
397 rm ${tmp_file} > /dev/null 2>&1
developera6267142022-01-26 20:50:22 +0800398 ;;
developer461cb542022-04-29 18:17:44 +0800399 "TXCOMMIT")
400 do_cmd "mt76-test ${interface} set aid=1"
401 ;;
developera6267142022-01-26 20:50:22 +0800402 "TXFRAME")
403 do_cmd "mt76-test ${interface} set state=tx_frames"
404 ;;
developer9b7cdad2022-03-10 14:24:55 +0800405 "TXSTOP"|"RXSTOP")
developera6267142022-01-26 20:50:22 +0800406 do_cmd "mt76-test ${interface} set state=idle"
407 ;;
developer461cb542022-04-29 18:17:44 +0800408 "TXREVERT")
409 do_cmd "mt76-test ${interface} set aid=0"
410 ;;
developera6267142022-01-26 20:50:22 +0800411 "RXFRAME")
412 do_cmd "mt76-test ${interface} set state=rx_frames"
413 ;;
414 "TXCONT")
415 do_cmd "mt76-test ${interface} set state=tx_cont"
416 ;;
developer9b7cdad2022-03-10 14:24:55 +0800417 *)
developer9b7cdad2022-03-10 14:24:55 +0800418 print_debug "skip ${ate_cmd}"
developera6267142022-01-26 20:50:22 +0800419 ;;
420 esac
421}
422
developer10946c32022-03-04 18:28:43 +0800423# main start here
424
425if [[ ${interface} == "ra"* ]]; then
426 tmp=$(get_config "ATECTRLBANDIDX")
427 if [ ! -z "${tmp}" ]; then
428 interface="phy${tmp}"
429 phy_idx=${tmp}
430 else
431 interface="phy0"
432 phy_idx=0
433 fi
434fi
435
436cmd=$(echo ${full_cmd} | sed s/=/' '/g | cut -d " " -f 1)
437param=$(echo ${full_cmd} | sed s/=/' '/g | cut -d " " -f 2)
438
developer3abe1ad2022-01-24 11:13:32 +0800439if [ "${cmd_type}" = "set" ]; then
440 skip=0
developer3abe1ad2022-01-24 11:13:32 +0800441 case ${cmd} in
442 "ATE")
443 do_ate_work ${param}
444
445 skip=1
446 ;;
447 "ATETXCNT"|"ATETXLEN"|"ATETXMCS"|"ATEVHTNSS"|"ATETXLDPC"|"ATETXSTBC"| \
448 "ATEPKTTXTIME"|"ATEIPG"|"ATEDUTYCYCLE"|"ATETXFREQOFFSET")
449 cmd_new=$(simple_convert ${cmd})
450 param_new=${param}
451 ;;
452 "ATETXANT"|"ATERXANT")
453 cmd_new="tx_antenna"
454 param_new=${param}
455 ;;
456 "ATETXGI")
457 tx_mode=$(convert_tx_mode $(get_config "ATETXMODE"))
458 convert_gi ${tx_mode} ${param}
459 skip=1
460 ;;
461 "ATETXMODE")
462 cmd_new="tx_rate_mode"
463 param_new=$(convert_tx_mode ${param})
464 record_config ${cmd} ${param}
465 ;;
466 "ATETXPOW0"|"ATETXPOW1"|"ATETXPOW2"|"ATETXPOW3")
467 cmd_new="tx_power"
468 param_new="${param},0,0,0"
469 ;;
470 "ATETXBW")
471 record_config ${cmd} ${param}
472 skip=1
473 ;;
474 "ATECHANNEL")
475 convert_channel ${param}
476 skip=1
477 ;;
developer10946c32022-03-04 18:28:43 +0800478 "ATERXSTAT")
479 convert_rxstat
480 skip=1
481 ;;
developer3abe1ad2022-01-24 11:13:32 +0800482 "ATECTRLBANDIDX")
developer10946c32022-03-04 18:28:43 +0800483 change_band_idx ${param}
developer3abe1ad2022-01-24 11:13:32 +0800484 skip=1
485 ;;
developer10946c32022-03-04 18:28:43 +0800486 "ATEDA"|"ATESA"|"ATEBSSID")
487 set_mac_addr ${cmd} ${param}
488 skip=1
489 ;;
developer3abe1ad2022-01-24 11:13:32 +0800490 "bufferMode")
491 if [ "${param}" = "2" ]; then
developer461cb542022-04-29 18:17:44 +0800492 do_cmd "atenl -i ${interface} -c \"eeprom update buffermode\""
developer3abe1ad2022-01-24 11:13:32 +0800493 fi
494 skip=1
495 ;;
developera6267142022-01-26 20:50:22 +0800496 "ResetCounter"|"ATERXSTATRESET")
497 skip=1
498 ;;
developer3abe1ad2022-01-24 11:13:32 +0800499 *)
developer9b7cdad2022-03-10 14:24:55 +0800500 print_debug "Unknown command to set: ${cmd}"
developer3abe1ad2022-01-24 11:13:32 +0800501 skip=1
502 esac
503
504 if [ "${skip}" != "1" ]; then
505 do_cmd "mt76-test ${interface} set ${cmd_new}=${param_new}"
506 fi
developer10946c32022-03-04 18:28:43 +0800507
developer3abe1ad2022-01-24 11:13:32 +0800508elif [ "${cmd_type}" = "show" ]; then
509 do_cmd "mt76-test ${interface} dump"
510 do_cmd "mt76-test ${interface} dump stats"
developer10946c32022-03-04 18:28:43 +0800511
developer3abe1ad2022-01-24 11:13:32 +0800512elif [ "${cmd_type}" = "e2p" ]; then
developera6267142022-01-26 20:50:22 +0800513 offset=$(printf "0x%s" ${cmd})
514 val=$(printf "0x%s" ${param})
515
516 # eeprom offset write
517 if [[ ${full_cmd} == *"="* ]]; then
518 tmp=$((${val} & 0xff))
519 tmp=$(printf "0x%x" ${tmp})
developer461cb542022-04-29 18:17:44 +0800520 do_cmd "atenl -i ${interface} -c \"eeprom set ${offset}=${tmp}\""
developera6267142022-01-26 20:50:22 +0800521
522 offset=$((${offset}))
523 offset=$(expr ${offset} + "1")
524 offset=$(printf "0x%x" ${offset})
525 tmp=$(((${val} >> 8) & 0xff))
526 tmp=$(printf "0x%x" ${tmp})
developer461cb542022-04-29 18:17:44 +0800527 do_cmd "atenl -i ${interface} -c \"eeprom set ${offset}=${tmp}\""
developera6267142022-01-26 20:50:22 +0800528 else
developer461cb542022-04-29 18:17:44 +0800529 v1=$(do_cmd "atenl -i ${interface} -c \"eeprom read ${param}\"")
developera6267142022-01-26 20:50:22 +0800530 v1=$(echo "${v1}" | grep "val =" | cut -d '(' -f 2 | grep -o -E '[0-9]+')
developer3abe1ad2022-01-24 11:13:32 +0800531
developera6267142022-01-26 20:50:22 +0800532 tmp=$(printf "0x%s" ${param})
533 tmp=$((${tmp}))
534 param2=$(expr ${tmp} + "1")
535 param2=$(printf "%x" ${param2})
developer461cb542022-04-29 18:17:44 +0800536 v2=$(do_cmd "atenl -i ${interface} -c \"eeprom read ${param2}\"")
developera6267142022-01-26 20:50:22 +0800537 v2=$(echo "${v2}" | grep "val =" | cut -d '(' -f 2 | grep -o -E '[0-9]+')
538
539 param=$(printf "0x%s" ${param})
developer461cb542022-04-29 18:17:44 +0800540 param=$(printf "%04x" ${param})
541 param=$(echo $param | tr 'a-z' 'A-Z')
developer9b7cdad2022-03-10 14:24:55 +0800542 printf "%s e2p:\n" ${interface_ori}
developer461cb542022-04-29 18:17:44 +0800543 printf "[0x%s]:0x%02x%02x\n" ${param} ${v2} ${v1}
developera6267142022-01-26 20:50:22 +0800544 fi
developer10946c32022-03-04 18:28:43 +0800545
developera6267142022-01-26 20:50:22 +0800546elif [ "${cmd_type}" = "mac" ]; then
547 regidx=/sys/kernel/debug/ieee80211/phy${phy_idx}/mt76/regidx
548 regval=/sys/kernel/debug/ieee80211/phy${phy_idx}/mt76/regval
549 offset=$(printf "0x%s" ${cmd})
550 val=$(printf "0x%s" ${param})
551
552 echo ${offset} > ${regidx}
553 # reg write
554 if [[ ${full_cmd} == *"="* ]]; then
555 echo ${val} > ${regval}
developera6267142022-01-26 20:50:22 +0800556 fi
developer10946c32022-03-04 18:28:43 +0800557
developer461cb542022-04-29 18:17:44 +0800558 res=$(cat ${regval} | cut -d 'x' -f 2)
559 printf "%s mac:[%s]:%s\n" ${interface_ori} ${offset} ${res}
560
developer3abe1ad2022-01-24 11:13:32 +0800561else
562 echo "Unknown command"
563fi