blob: c7c7f71c46bccd334e4a5f377701214daf7742e7 [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")
195 if [ "${ch}" -ge "1" ] && [ "${ch}" -le "7" ]; then
196 local bw_str="HT40+"
197 else
198 local bw_str="HT40-"
199 fi
200 ;;
developer3abe1ad2022-01-24 11:13:32 +0800201 esac
developera6267142022-01-26 20:50:22 +0800202 elif [ "${band}" = "1" ]; then
developer3abe1ad2022-01-24 11:13:32 +0800203 case ${bw} in
developera6267142022-01-26 20:50:22 +0800204 "5")
developer10946c32022-03-04 18:28:43 +0800205 bw_str="160MHz"
206 if [ ${ch} -lt "68" ]; then
207 ch="36"
208 elif [ ${ch} -lt "100" ]; then
209 ch="68"
210 elif [ ${ch} -lt "132" ]; then
211 ch="100"
212 elif [ ${ch} -lt "181" ]; then
213 ch="149"
214 fi
developera6267142022-01-26 20:50:22 +0800215 ;;
developer3abe1ad2022-01-24 11:13:32 +0800216 "2")
developer10946c32022-03-04 18:28:43 +0800217 bw_str="80MHz"
218 if [ ${ch} -lt "52" ]; then
219 ch="36"
220 elif [ ${ch} -lt "68" ]; then
221 ch="52"
222 elif [ ${ch} -lt "84" ]; then
223 ch="68"
224 elif [ ${ch} -lt "100" ]; then
225 ch="84"
226 elif [ ${ch} -lt "116" ]; then
227 ch="100"
228 elif [ ${ch} -lt "132" ]; then
229 ch="116"
230 elif [ ${ch} -lt "149" ]; then
231 ch="132"
232 elif [ ${ch} -lt "165" ]; then
233 ch="149"
234 elif [ ${ch} -lt "181" ]; then
235 ch="165"
236 fi
developer3abe1ad2022-01-24 11:13:32 +0800237 ;;
238 "1")
developer10946c32022-03-04 18:28:43 +0800239 if [ ${ch} -lt "44" ]; then
240 ch=$([ "${ch}" -lt "40" ] && echo "36" || echo "40")
241 bw_str=$([ "${ch}" -le "38" ] && echo "HT40+" || echo "HT40-")
242 elif [ ${ch} -lt "52" ]; then
243 ch=$([ "${ch}" -lt "48" ] && echo "44" || echo "48")
244 bw_str=$([ "${ch}" -le "46" ] && echo "HT40+" || echo "HT40-")
245 elif [ ${ch} -lt "60" ]; then
246 ch=$([ "${ch}" -lt "56" ] && echo "52" || echo "56")
247 bw_str=$([ "${ch}" -le "54" ] && echo "HT40+" || echo "HT40-")
248 elif [ ${ch} -lt "68" ]; then
249 ch=$([ "${ch}" -lt "64" ] && echo "60" || echo "64")
250 bw_str=$([ "${ch}" -le "62" ] && echo "HT40+" || echo "HT40-")
251 elif [ ${ch} -lt "76" ]; then
252 ch=$([ "${ch}" -lt "72" ] && echo "68" || echo "72")
253 bw_str=$([ "${ch}" -le "70" ] && echo "HT40+" || echo "HT40-")
254 elif [ ${ch} -lt "84" ]; then
255 ch=$([ "${ch}" -lt "80" ] && echo "76" || echo "80")
256 bw_str=$([ "${ch}" -le "78" ] && echo "HT40+" || echo "HT40-")
257 elif [ ${ch} -lt "92" ]; then
258 ch=$([ "${ch}" -lt "88" ] && echo "84" || echo "88")
259 bw_str=$([ "${ch}" -le "86" ] && echo "HT40+" || echo "HT40-")
260 elif [ ${ch} -lt "100" ]; then
261 ch=$([ "${ch}" -lt "96" ] && echo "92" || echo "96")
262 bw_str=$([ "${ch}" -le "94" ] && echo "HT40+" || echo "HT40-")
263 elif [ ${ch} -lt "108" ]; then
264 ch=$([ "${ch}" -lt "104" ] && echo "100" || echo "104")
265 bw_str=$([ "${ch}" -le "102" ] && echo "HT40+" || echo "HT40-")
266 elif [ ${ch} -lt "116" ]; then
267 ch=$([ "${ch}" -lt "112" ] && echo "108" || echo "112")
268 bw_str=$([ "${ch}" -le "110" ] && echo "HT40+" || echo "HT40-")
269 elif [ ${ch} -lt "124" ]; then
270 ch=$([ "${ch}" -lt "120" ] && echo "116" || echo "120")
271 bw_str=$([ "${ch}" -le "118" ] && echo "HT40+" || echo "HT40-")
272 elif [ ${ch} -lt "132" ]; then
273 ch=$([ "${ch}" -lt "128" ] && echo "124" || echo "128")
274 bw_str=$([ "${ch}" -le "126" ] && echo "HT40+" || echo "HT40-")
275 elif [ ${ch} -lt "140" ]; then
276 ch=$([ "${ch}" -lt "136" ] && echo "132" || echo "136")
277 bw_str=$([ "${ch}" -le "134" ] && echo "HT40+" || echo "HT40-")
278 elif [ ${ch} -lt "149" ]; then
279 ch=$([ "${ch}" -lt "144" ] && echo "140" || echo "144")
280 bw_str=$([ "${ch}" -le "142" ] && echo "HT40+" || echo "HT40-")
281 elif [ ${ch} -lt "157" ]; then
282 ch=$([ "${ch}" -lt "153" ] && echo "149" || echo "153")
283 bw_str=$([ "${ch}" -le "151" ] && echo "HT40+" || echo "HT40-")
284 elif [ ${ch} -lt "165" ]; then
285 ch=$([ "${ch}" -lt "161" ] && echo "157" || echo "161")
286 bw_str=$([ "${ch}" -le "159" ] && echo "HT40+" || echo "HT40-")
287 elif [ ${ch} -lt "173" ]; then
288 ch=$([ "${ch}" -lt "169" ] && echo "165" || echo "169")
289 bw_str=$([ "${ch}" -le "167" ] && echo "HT40+" || echo "HT40-")
290 elif [ ${ch} -lt "181" ]; then
291 ch=$([ "${ch}" -lt "177" ] && echo "173" || echo "177")
292 bw_str=$([ "${ch}" -le "175" ] && echo "HT40+" || echo "HT40-")
developer3abe1ad2022-01-24 11:13:32 +0800293 fi
294 ;;
295 "0")
296 local bw_str="HT20"
297 ;;
298 esac
developera6267142022-01-26 20:50:22 +0800299 else
300 echo "6G Todo"
developer3abe1ad2022-01-24 11:13:32 +0800301 fi
302
303 do_cmd "iw dev mon${phy_idx} set channel ${ch} ${bw_str}"
304}
305
developer10946c32022-03-04 18:28:43 +0800306function convert_rxstat {
307 local res=$(do_cmd "mt76-test ${interface} dump stats")
308 local mdrdy=$(echo "${res}" | grep "rx_packets" | cut -d "=" -f 2)
309 local fcs_error=$(echo "${res}" | grep "rx_fcs_error" | cut -d "=" -f 2)
310 local rcpi=$(echo "${res}" | grep "last_rcpi" | cut -d "=" -f 2 | sed 's/,/ /g')
311 local ib_rssi=$(echo "${res}" | grep "last_ib_rssi" | cut -d "=" -f 2 | sed 's/,/ /g')
312 local wb_rssi=$(echo "${res}" | grep "last_wb_rssi" | cut -d "=" -f 2 | sed 's/,/ /g')
313 local rx_ok=$(expr ${mdrdy} - ${fcs_error})
314
developer9b7cdad2022-03-10 14:24:55 +0800315 write_dmesg "rcpi : ${rcpi}"
316 write_dmesg "fagc rssi ib : ${ib_rssi}"
317 write_dmesg "fagc rssi wb : ${wb_rssi}"
318 write_dmesg "all_mac_rx_mdrdy_cnt : ${mdrdy}"
319 write_dmesg "all_mac_rx_fcs_err_cnt : ${fcs_error}"
320 write_dmesg "all_mac_rx_ok_cnt : ${rx_ok}"
developer10946c32022-03-04 18:28:43 +0800321}
322
323function change_band_idx {
324 local old_idx=$(get_config "ATECTRLBANDIDX")
325 local new_idx=$1
326
327 if [ -z "${old_idx}" ] && [ "${new_idx}" == "0" ]; then
328 return
329 fi
330
331 if [ "${old_idx}" != "${new_idx}" ]; then
332 if [ -z "${old_idx}" ]; then
333 old_idx=0
334 fi
335
336 interface="phy${old_idx}"
337 phy_idx=${old_idx}
338 do_ate_work "ATESTOP"
339
340 interface="phy${new_idx}"
341 phy_idx=${new_idx}
342 do_ate_work "ATESTART"
343
344 record_config "ATECTRLBANDIDX" ${new_idx}
345 fi
346}
347
348function set_mac_addr {
349 record_config ${cmd} ${param}
350
351 local addr1=$(get_config "ATEDA")
352 local addr2=$(get_config "ATESA")
353 local addr3=$(get_config "ATEBSSID")
354
355 if [ -z "${addr1}" ]; then
356 addr1="00:11:22:33:44:55"
357 fi
358 if [ -z "${addr2}" ]; then
359 addr2="00:11:22:33:44:55"
360 fi
361 if [ -z "${addr3}" ]; then
362 addr3="00:11:22:33:44:55"
363 fi
364
365 do_cmd "mt76-test phy${phy_idx} set mac_addrs=${addr1},${addr2},${addr3}"
366}
367
developera6267142022-01-26 20:50:22 +0800368function do_ate_work() {
369 local ate_cmd=$1
370
371 case ${ate_cmd} in
372 "ATESTART")
373 local if_str=$(ifconfig | grep mon${phy_idx})
374
375 if [ ! -z "${if_str}" -a "${if_str}" != " " ]; then
376 echo "ATE already starts."
377 else
378 do_cmd "iw phy ${interface} interface add mon${phy_idx} type monitor"
379 do_cmd "iw dev wlan${phy_idx} del"
380 do_cmd "ifconfig mon${phy_idx} up"
developer9b7cdad2022-03-10 14:24:55 +0800381 do_cmd "iw reg set VV"
382 do_cmd "mt76-test ${interface} set aid=1"
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"
developer9b7cdad2022-03-10 14:24:55 +0800392 do_cmd "mt76-test ${interface} set aid=0"
developera6267142022-01-26 20:50:22 +0800393 do_cmd "iw dev mon${phy_idx} del"
394 do_cmd "iw phy ${interface} interface add wlan${phy_idx} type managed"
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 ;;
399 "TXFRAME")
400 do_cmd "mt76-test ${interface} set state=tx_frames"
401 ;;
developer9b7cdad2022-03-10 14:24:55 +0800402 "TXSTOP"|"RXSTOP")
developera6267142022-01-26 20:50:22 +0800403 do_cmd "mt76-test ${interface} set state=idle"
404 ;;
405 "RXFRAME")
406 do_cmd "mt76-test ${interface} set state=rx_frames"
407 ;;
408 "TXCONT")
409 do_cmd "mt76-test ${interface} set state=tx_cont"
410 ;;
developer9b7cdad2022-03-10 14:24:55 +0800411 *)
412 # skip TXCOMMIT/TXREVERT
413 print_debug "skip ${ate_cmd}"
developera6267142022-01-26 20:50:22 +0800414 ;;
415 esac
416}
417
developer10946c32022-03-04 18:28:43 +0800418# main start here
419
420if [[ ${interface} == "ra"* ]]; then
421 tmp=$(get_config "ATECTRLBANDIDX")
422 if [ ! -z "${tmp}" ]; then
423 interface="phy${tmp}"
424 phy_idx=${tmp}
425 else
426 interface="phy0"
427 phy_idx=0
428 fi
429fi
430
431cmd=$(echo ${full_cmd} | sed s/=/' '/g | cut -d " " -f 1)
432param=$(echo ${full_cmd} | sed s/=/' '/g | cut -d " " -f 2)
433
developer3abe1ad2022-01-24 11:13:32 +0800434if [ "${cmd_type}" = "set" ]; then
435 skip=0
436 use_ated=0
437 case ${cmd} in
438 "ATE")
439 do_ate_work ${param}
440
441 skip=1
442 ;;
443 "ATETXCNT"|"ATETXLEN"|"ATETXMCS"|"ATEVHTNSS"|"ATETXLDPC"|"ATETXSTBC"| \
444 "ATEPKTTXTIME"|"ATEIPG"|"ATEDUTYCYCLE"|"ATETXFREQOFFSET")
445 cmd_new=$(simple_convert ${cmd})
446 param_new=${param}
447 ;;
448 "ATETXANT"|"ATERXANT")
449 cmd_new="tx_antenna"
450 param_new=${param}
451 ;;
452 "ATETXGI")
453 tx_mode=$(convert_tx_mode $(get_config "ATETXMODE"))
454 convert_gi ${tx_mode} ${param}
455 skip=1
456 ;;
457 "ATETXMODE")
458 cmd_new="tx_rate_mode"
459 param_new=$(convert_tx_mode ${param})
460 record_config ${cmd} ${param}
461 ;;
462 "ATETXPOW0"|"ATETXPOW1"|"ATETXPOW2"|"ATETXPOW3")
463 cmd_new="tx_power"
464 param_new="${param},0,0,0"
465 ;;
466 "ATETXBW")
467 record_config ${cmd} ${param}
468 skip=1
469 ;;
470 "ATECHANNEL")
471 convert_channel ${param}
472 skip=1
473 ;;
developer10946c32022-03-04 18:28:43 +0800474 "ATERXSTAT")
475 convert_rxstat
476 skip=1
477 ;;
developer3abe1ad2022-01-24 11:13:32 +0800478 "ATECTRLBANDIDX")
developer10946c32022-03-04 18:28:43 +0800479 change_band_idx ${param}
developer3abe1ad2022-01-24 11:13:32 +0800480 skip=1
481 ;;
developer10946c32022-03-04 18:28:43 +0800482 "ATEDA"|"ATESA"|"ATEBSSID")
483 set_mac_addr ${cmd} ${param}
484 skip=1
485 ;;
developer3abe1ad2022-01-24 11:13:32 +0800486 "bufferMode")
487 if [ "${param}" = "2" ]; then
developer9b7cdad2022-03-10 14:24:55 +0800488 do_cmd "ated -i ${interface} -c \"eeprom update buffermode\""
developer3abe1ad2022-01-24 11:13:32 +0800489 fi
490 skip=1
491 ;;
developera6267142022-01-26 20:50:22 +0800492 "ResetCounter"|"ATERXSTATRESET")
493 skip=1
494 ;;
developer3abe1ad2022-01-24 11:13:32 +0800495 *)
developer9b7cdad2022-03-10 14:24:55 +0800496 print_debug "Unknown command to set: ${cmd}"
developer3abe1ad2022-01-24 11:13:32 +0800497 skip=1
498 esac
499
500 if [ "${skip}" != "1" ]; then
501 do_cmd "mt76-test ${interface} set ${cmd_new}=${param_new}"
502 fi
developer10946c32022-03-04 18:28:43 +0800503
developer3abe1ad2022-01-24 11:13:32 +0800504elif [ "${cmd_type}" = "show" ]; then
505 do_cmd "mt76-test ${interface} dump"
506 do_cmd "mt76-test ${interface} dump stats"
developer10946c32022-03-04 18:28:43 +0800507
developer3abe1ad2022-01-24 11:13:32 +0800508elif [ "${cmd_type}" = "e2p" ]; then
developera6267142022-01-26 20:50:22 +0800509 offset=$(printf "0x%s" ${cmd})
510 val=$(printf "0x%s" ${param})
511
512 # eeprom offset write
513 if [[ ${full_cmd} == *"="* ]]; then
514 tmp=$((${val} & 0xff))
515 tmp=$(printf "0x%x" ${tmp})
516 do_cmd "ated -i ${interface} -c \"eeprom set ${offset}=${tmp}\""
517
518 offset=$((${offset}))
519 offset=$(expr ${offset} + "1")
520 offset=$(printf "0x%x" ${offset})
521 tmp=$(((${val} >> 8) & 0xff))
522 tmp=$(printf "0x%x" ${tmp})
523 do_cmd "ated -i ${interface} -c \"eeprom set ${offset}=${tmp}\""
524 else
525 v1=$(do_cmd "ated -i ${interface} -c \"eeprom read ${param}\"")
526 v1=$(echo "${v1}" | grep "val =" | cut -d '(' -f 2 | grep -o -E '[0-9]+')
developer3abe1ad2022-01-24 11:13:32 +0800527
developera6267142022-01-26 20:50:22 +0800528 tmp=$(printf "0x%s" ${param})
529 tmp=$((${tmp}))
530 param2=$(expr ${tmp} + "1")
531 param2=$(printf "%x" ${param2})
532 v2=$(do_cmd "ated -i ${interface} -c \"eeprom read ${param2}\"")
533 v2=$(echo "${v2}" | grep "val =" | cut -d '(' -f 2 | grep -o -E '[0-9]+')
534
535 param=$(printf "0x%s" ${param})
developer9b7cdad2022-03-10 14:24:55 +0800536 printf "%s e2p:\n" ${interface_ori}
developera6267142022-01-26 20:50:22 +0800537 printf "[0x%04x]:0x%02x%02x\n" ${param} ${v2} ${v1}
538 fi
developer10946c32022-03-04 18:28:43 +0800539
developera6267142022-01-26 20:50:22 +0800540elif [ "${cmd_type}" = "mac" ]; then
541 regidx=/sys/kernel/debug/ieee80211/phy${phy_idx}/mt76/regidx
542 regval=/sys/kernel/debug/ieee80211/phy${phy_idx}/mt76/regval
543 offset=$(printf "0x%s" ${cmd})
544 val=$(printf "0x%s" ${param})
545
546 echo ${offset} > ${regidx}
547 # reg write
548 if [[ ${full_cmd} == *"="* ]]; then
549 echo ${val} > ${regval}
550 else
551 res=$(cat ${regval} | cut -d 'x' -f 2)
552 printf "%s mac:[%s]:%s\n" ${interface} ${offset} ${res}
553 fi
developer10946c32022-03-04 18:28:43 +0800554
developer3abe1ad2022-01-24 11:13:32 +0800555else
556 echo "Unknown command"
557fi