developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 1 | #!/bin/ash |
| 2 | |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 3 | interface=$1 # phy0/phy1/ra0 |
| 4 | cmd_type=$2 # set/show/e2p/mac |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 5 | full_cmd=$3 |
| 6 | |
| 7 | work_mode="RUN" # RUN/PRINT/DEBUG |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 8 | tmp_file="/tmp/iwpriv_wrapper" |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 9 | phy_idx=$(echo ${interface} | tr -dc '0-9') |
| 10 | |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 11 | function do_cmd() { |
| 12 | case ${work_mode} in |
| 13 | "RUN") |
| 14 | eval "$1" |
| 15 | ;; |
| 16 | "PRINT") |
| 17 | echo "$1" |
| 18 | ;; |
| 19 | "DEBUG") |
| 20 | eval "$1" |
| 21 | echo "$1" |
| 22 | ;; |
| 23 | esac |
| 24 | } |
| 25 | |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 26 | function write_dmesg() { |
| 27 | echo "$1" > /dev/kmsg |
| 28 | } |
| 29 | |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 30 | function record_config() { |
| 31 | if [ -f ${tmp_file} ]; then |
| 32 | if grep -q $1 ${tmp_file}; then |
| 33 | sed -i "/$1/c\\$1=$2" ${tmp_file} |
| 34 | else |
| 35 | echo "$1=$2" >> ${tmp_file} |
| 36 | fi |
| 37 | else |
| 38 | echo "$1=$2" >> ${tmp_file} |
| 39 | fi |
| 40 | } |
| 41 | |
| 42 | function get_config() { |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 43 | if [ ! -f ${tmp_file} ]; then |
| 44 | echo "" |
| 45 | return |
| 46 | fi |
| 47 | |
| 48 | if grep -q $1 ${tmp_file}; then |
| 49 | echo "$(cat ${tmp_file} | grep $1 | sed s/=/' '/g | cut -d " " -f 2)" |
| 50 | else |
| 51 | echo "" |
| 52 | fi |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 53 | } |
| 54 | |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 55 | function simple_convert() { |
| 56 | if [ "$1" = "ATETXCNT" ]; then |
| 57 | echo "tx_count" |
| 58 | elif [ "$1" = "ATETXLEN" ]; then |
| 59 | echo "tx_length" |
| 60 | elif [ "$1" = "ATETXMCS" ]; then |
| 61 | echo "tx_rate_idx" |
| 62 | elif [ "$1" = "ATEVHTNSS" ]; then |
| 63 | echo "tx_rate_nss" |
| 64 | elif [ "$1" = "ATETXLDPC" ]; then |
| 65 | echo "tx_rate_ldpc" |
| 66 | elif [ "$1" = "ATETXSTBC" ]; then |
| 67 | echo "tx_rate_stbc" |
| 68 | elif [ "$1" = "ATEPKTTXTIME" ]; then |
| 69 | echo "tx_time" |
| 70 | elif [ "$1" = "ATEIPG" ]; then |
| 71 | echo "tx_ipg" |
| 72 | elif [ "$1" = "ATEDUTYCYCLE" ]; then |
| 73 | echo "tx_duty_cycle" |
| 74 | elif [ "$1" = "ATETXFREQOFFSET" ]; then |
| 75 | echo "freq_offset" |
| 76 | else |
| 77 | echo "unknown" |
| 78 | fi |
| 79 | } |
| 80 | |
| 81 | function convert_tx_mode() { |
| 82 | if [ "$1" = "0" ]; then |
| 83 | echo "cck" |
| 84 | elif [ "$1" = "1" ]; then |
| 85 | echo "ofdm" |
| 86 | elif [ "$1" = "2" ]; then |
| 87 | echo "ht" |
| 88 | elif [ "$1" = "4" ]; then |
| 89 | echo "vht" |
| 90 | elif [ "$1" = "8" ]; then |
| 91 | echo "he_su" |
| 92 | elif [ "$1" = "9" ]; then |
| 93 | echo "he_er" |
| 94 | elif [ "$1" = "10" ]; then |
| 95 | echo "he_tb" |
| 96 | elif [ "$1" = "11" ]; then |
| 97 | echo "he_mu" |
| 98 | else |
| 99 | echo "unknown" |
| 100 | fi |
| 101 | } |
| 102 | |
| 103 | function convert_gi { |
| 104 | local tx_mode=$1 |
| 105 | local val=$2 |
| 106 | local sgi="0" |
| 107 | local he_ltf="0" |
| 108 | |
| 109 | case ${tx_mode} in |
| 110 | "ht"|"vht") |
| 111 | sgi=${val} |
| 112 | ;; |
| 113 | "he_su"|"he_er") |
| 114 | case ${val} in |
| 115 | "0") |
| 116 | ;; |
| 117 | "1") |
| 118 | he_ltf="1" |
| 119 | ;; |
| 120 | "2") |
| 121 | sgi="1" |
| 122 | he_ltf="1" |
| 123 | ;; |
| 124 | "3") |
| 125 | sgi="2" |
| 126 | he_ltf="2" |
| 127 | ;; |
| 128 | "4") |
| 129 | he_ltf="2" |
| 130 | ;; |
| 131 | *) |
| 132 | echo "unknown gi" |
| 133 | esac |
| 134 | ;; |
| 135 | "he_mu") |
| 136 | case ${val} in |
| 137 | "0") |
| 138 | he_ltf="2" |
| 139 | ;; |
| 140 | "1") |
| 141 | he_ltf="1" |
| 142 | ;; |
| 143 | "2") |
| 144 | sgi="1" |
| 145 | he_ltf="1" |
| 146 | ;; |
| 147 | "3") |
| 148 | sgi="2" |
| 149 | he_ltf="2" |
| 150 | ;; |
| 151 | *) |
| 152 | echo "unknown gi" |
| 153 | esac |
| 154 | ;; |
| 155 | "he_tb") |
| 156 | case ${val} in |
| 157 | "0") |
| 158 | sgi="1" |
| 159 | ;; |
| 160 | "1") |
| 161 | sgi="1" |
| 162 | he_ltf="1" |
| 163 | ;; |
| 164 | "2") |
| 165 | sgi="2" |
| 166 | he_ltf="2" |
| 167 | ;; |
| 168 | *) |
| 169 | echo "unknown gi" |
| 170 | esac |
| 171 | ;; |
| 172 | *) |
| 173 | echo "unknown tx_rate_mode, can't transform gi" |
| 174 | esac |
| 175 | |
| 176 | do_cmd "mt76-test ${interface} set tx_rate_sgi=${sgi} tx_ltf=${he_ltf}" |
| 177 | } |
| 178 | |
| 179 | function convert_channel { |
| 180 | local band=$(echo $1 | sed s/:/' '/g | cut -d " " -f 2) |
| 181 | local ch=$(echo $1 | sed s/:/' '/g | cut -d " " -f 1) |
| 182 | local bw=$(get_config "ATETXBW" | cut -d ":" -f 1) |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 183 | local bw_str="HT20" |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 184 | |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 185 | if [ -z "${band}" ] || [ "${band}" = "0" ]; then |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 186 | case ${bw} in |
| 187 | "1") |
| 188 | if [ "${ch}" -ge "1" ] && [ "${ch}" -le "7" ]; then |
| 189 | local bw_str="HT40+" |
| 190 | else |
| 191 | local bw_str="HT40-" |
| 192 | fi |
| 193 | ;; |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 194 | esac |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 195 | elif [ "${band}" = "1" ]; then |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 196 | case ${bw} in |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 197 | "5") |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 198 | bw_str="160MHz" |
| 199 | if [ ${ch} -lt "68" ]; then |
| 200 | ch="36" |
| 201 | elif [ ${ch} -lt "100" ]; then |
| 202 | ch="68" |
| 203 | elif [ ${ch} -lt "132" ]; then |
| 204 | ch="100" |
| 205 | elif [ ${ch} -lt "181" ]; then |
| 206 | ch="149" |
| 207 | fi |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 208 | ;; |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 209 | "2") |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 210 | bw_str="80MHz" |
| 211 | if [ ${ch} -lt "52" ]; then |
| 212 | ch="36" |
| 213 | elif [ ${ch} -lt "68" ]; then |
| 214 | ch="52" |
| 215 | elif [ ${ch} -lt "84" ]; then |
| 216 | ch="68" |
| 217 | elif [ ${ch} -lt "100" ]; then |
| 218 | ch="84" |
| 219 | elif [ ${ch} -lt "116" ]; then |
| 220 | ch="100" |
| 221 | elif [ ${ch} -lt "132" ]; then |
| 222 | ch="116" |
| 223 | elif [ ${ch} -lt "149" ]; then |
| 224 | ch="132" |
| 225 | elif [ ${ch} -lt "165" ]; then |
| 226 | ch="149" |
| 227 | elif [ ${ch} -lt "181" ]; then |
| 228 | ch="165" |
| 229 | fi |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 230 | ;; |
| 231 | "1") |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 232 | if [ ${ch} -lt "44" ]; then |
| 233 | ch=$([ "${ch}" -lt "40" ] && echo "36" || echo "40") |
| 234 | bw_str=$([ "${ch}" -le "38" ] && echo "HT40+" || echo "HT40-") |
| 235 | elif [ ${ch} -lt "52" ]; then |
| 236 | ch=$([ "${ch}" -lt "48" ] && echo "44" || echo "48") |
| 237 | bw_str=$([ "${ch}" -le "46" ] && echo "HT40+" || echo "HT40-") |
| 238 | elif [ ${ch} -lt "60" ]; then |
| 239 | ch=$([ "${ch}" -lt "56" ] && echo "52" || echo "56") |
| 240 | bw_str=$([ "${ch}" -le "54" ] && echo "HT40+" || echo "HT40-") |
| 241 | elif [ ${ch} -lt "68" ]; then |
| 242 | ch=$([ "${ch}" -lt "64" ] && echo "60" || echo "64") |
| 243 | bw_str=$([ "${ch}" -le "62" ] && echo "HT40+" || echo "HT40-") |
| 244 | elif [ ${ch} -lt "76" ]; then |
| 245 | ch=$([ "${ch}" -lt "72" ] && echo "68" || echo "72") |
| 246 | bw_str=$([ "${ch}" -le "70" ] && echo "HT40+" || echo "HT40-") |
| 247 | elif [ ${ch} -lt "84" ]; then |
| 248 | ch=$([ "${ch}" -lt "80" ] && echo "76" || echo "80") |
| 249 | bw_str=$([ "${ch}" -le "78" ] && echo "HT40+" || echo "HT40-") |
| 250 | elif [ ${ch} -lt "92" ]; then |
| 251 | ch=$([ "${ch}" -lt "88" ] && echo "84" || echo "88") |
| 252 | bw_str=$([ "${ch}" -le "86" ] && echo "HT40+" || echo "HT40-") |
| 253 | elif [ ${ch} -lt "100" ]; then |
| 254 | ch=$([ "${ch}" -lt "96" ] && echo "92" || echo "96") |
| 255 | bw_str=$([ "${ch}" -le "94" ] && echo "HT40+" || echo "HT40-") |
| 256 | elif [ ${ch} -lt "108" ]; then |
| 257 | ch=$([ "${ch}" -lt "104" ] && echo "100" || echo "104") |
| 258 | bw_str=$([ "${ch}" -le "102" ] && echo "HT40+" || echo "HT40-") |
| 259 | elif [ ${ch} -lt "116" ]; then |
| 260 | ch=$([ "${ch}" -lt "112" ] && echo "108" || echo "112") |
| 261 | bw_str=$([ "${ch}" -le "110" ] && echo "HT40+" || echo "HT40-") |
| 262 | elif [ ${ch} -lt "124" ]; then |
| 263 | ch=$([ "${ch}" -lt "120" ] && echo "116" || echo "120") |
| 264 | bw_str=$([ "${ch}" -le "118" ] && echo "HT40+" || echo "HT40-") |
| 265 | elif [ ${ch} -lt "132" ]; then |
| 266 | ch=$([ "${ch}" -lt "128" ] && echo "124" || echo "128") |
| 267 | bw_str=$([ "${ch}" -le "126" ] && echo "HT40+" || echo "HT40-") |
| 268 | elif [ ${ch} -lt "140" ]; then |
| 269 | ch=$([ "${ch}" -lt "136" ] && echo "132" || echo "136") |
| 270 | bw_str=$([ "${ch}" -le "134" ] && echo "HT40+" || echo "HT40-") |
| 271 | elif [ ${ch} -lt "149" ]; then |
| 272 | ch=$([ "${ch}" -lt "144" ] && echo "140" || echo "144") |
| 273 | bw_str=$([ "${ch}" -le "142" ] && echo "HT40+" || echo "HT40-") |
| 274 | elif [ ${ch} -lt "157" ]; then |
| 275 | ch=$([ "${ch}" -lt "153" ] && echo "149" || echo "153") |
| 276 | bw_str=$([ "${ch}" -le "151" ] && echo "HT40+" || echo "HT40-") |
| 277 | elif [ ${ch} -lt "165" ]; then |
| 278 | ch=$([ "${ch}" -lt "161" ] && echo "157" || echo "161") |
| 279 | bw_str=$([ "${ch}" -le "159" ] && echo "HT40+" || echo "HT40-") |
| 280 | elif [ ${ch} -lt "173" ]; then |
| 281 | ch=$([ "${ch}" -lt "169" ] && echo "165" || echo "169") |
| 282 | bw_str=$([ "${ch}" -le "167" ] && echo "HT40+" || echo "HT40-") |
| 283 | elif [ ${ch} -lt "181" ]; then |
| 284 | ch=$([ "${ch}" -lt "177" ] && echo "173" || echo "177") |
| 285 | bw_str=$([ "${ch}" -le "175" ] && echo "HT40+" || echo "HT40-") |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 286 | fi |
| 287 | ;; |
| 288 | "0") |
| 289 | local bw_str="HT20" |
| 290 | ;; |
| 291 | esac |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 292 | else |
| 293 | echo "6G Todo" |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 294 | fi |
| 295 | |
| 296 | do_cmd "iw dev mon${phy_idx} set channel ${ch} ${bw_str}" |
| 297 | } |
| 298 | |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 299 | function convert_rxstat { |
| 300 | local res=$(do_cmd "mt76-test ${interface} dump stats") |
| 301 | local mdrdy=$(echo "${res}" | grep "rx_packets" | cut -d "=" -f 2) |
| 302 | local fcs_error=$(echo "${res}" | grep "rx_fcs_error" | cut -d "=" -f 2) |
| 303 | local rcpi=$(echo "${res}" | grep "last_rcpi" | cut -d "=" -f 2 | sed 's/,/ /g') |
| 304 | local ib_rssi=$(echo "${res}" | grep "last_ib_rssi" | cut -d "=" -f 2 | sed 's/,/ /g') |
| 305 | local wb_rssi=$(echo "${res}" | grep "last_wb_rssi" | cut -d "=" -f 2 | sed 's/,/ /g') |
| 306 | local rx_ok=$(expr ${mdrdy} - ${fcs_error}) |
| 307 | |
| 308 | write_dmesg "rcpi: ${rcpi}" |
| 309 | write_dmesg "fagc rssi ib: ${ib_rssi}" |
| 310 | write_dmesg "fagc rssi wb: ${wb_rssi}" |
| 311 | write_dmesg "all_mac_rx_mdrdy_cnt: ${mdrdy}" |
| 312 | write_dmesg "all_mac_rx_fcs_err_cnt: ${fcs_error}" |
| 313 | write_dmesg "all_mac_rx_ok_cnt: ${rx_ok}" |
| 314 | } |
| 315 | |
| 316 | function change_band_idx { |
| 317 | local old_idx=$(get_config "ATECTRLBANDIDX") |
| 318 | local new_idx=$1 |
| 319 | |
| 320 | if [ -z "${old_idx}" ] && [ "${new_idx}" == "0" ]; then |
| 321 | return |
| 322 | fi |
| 323 | |
| 324 | if [ "${old_idx}" != "${new_idx}" ]; then |
| 325 | if [ -z "${old_idx}" ]; then |
| 326 | old_idx=0 |
| 327 | fi |
| 328 | |
| 329 | interface="phy${old_idx}" |
| 330 | phy_idx=${old_idx} |
| 331 | do_ate_work "ATESTOP" |
| 332 | |
| 333 | interface="phy${new_idx}" |
| 334 | phy_idx=${new_idx} |
| 335 | do_ate_work "ATESTART" |
| 336 | |
| 337 | record_config "ATECTRLBANDIDX" ${new_idx} |
| 338 | fi |
| 339 | } |
| 340 | |
| 341 | function set_mac_addr { |
| 342 | record_config ${cmd} ${param} |
| 343 | |
| 344 | local addr1=$(get_config "ATEDA") |
| 345 | local addr2=$(get_config "ATESA") |
| 346 | local addr3=$(get_config "ATEBSSID") |
| 347 | |
| 348 | if [ -z "${addr1}" ]; then |
| 349 | addr1="00:11:22:33:44:55" |
| 350 | fi |
| 351 | if [ -z "${addr2}" ]; then |
| 352 | addr2="00:11:22:33:44:55" |
| 353 | fi |
| 354 | if [ -z "${addr3}" ]; then |
| 355 | addr3="00:11:22:33:44:55" |
| 356 | fi |
| 357 | |
| 358 | do_cmd "mt76-test phy${phy_idx} set mac_addrs=${addr1},${addr2},${addr3}" |
| 359 | } |
| 360 | |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 361 | function do_ate_work() { |
| 362 | local ate_cmd=$1 |
| 363 | |
| 364 | case ${ate_cmd} in |
| 365 | "ATESTART") |
| 366 | local if_str=$(ifconfig | grep mon${phy_idx}) |
| 367 | |
| 368 | if [ ! -z "${if_str}" -a "${if_str}" != " " ]; then |
| 369 | echo "ATE already starts." |
| 370 | else |
| 371 | do_cmd "iw phy ${interface} interface add mon${phy_idx} type monitor" |
| 372 | do_cmd "iw dev wlan${phy_idx} del" |
| 373 | do_cmd "ifconfig mon${phy_idx} up" |
| 374 | fi |
| 375 | ;; |
| 376 | "ATESTOP") |
| 377 | local if_str=$(ifconfig | grep mon${phy_idx}) |
| 378 | |
| 379 | if [ -z "${if_str}" -a "${if_str}" != " " ]; then |
| 380 | echo "ATE does not start." |
| 381 | else |
| 382 | do_cmd "mt76-test ${interface} set state=off" |
| 383 | do_cmd "iw dev mon${phy_idx} del" |
| 384 | do_cmd "iw phy ${interface} interface add wlan${phy_idx} type managed" |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 385 | fi |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 386 | |
| 387 | rm ${tmp_file} > /dev/null 2>&1 |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 388 | ;; |
| 389 | "TXFRAME") |
| 390 | do_cmd "mt76-test ${interface} set state=tx_frames" |
| 391 | ;; |
| 392 | "TXSTOP"|"RXSTOP"|"TXREVERT") |
| 393 | do_cmd "mt76-test ${interface} set state=idle" |
| 394 | ;; |
| 395 | "RXFRAME") |
| 396 | do_cmd "mt76-test ${interface} set state=rx_frames" |
| 397 | ;; |
| 398 | "TXCONT") |
| 399 | do_cmd "mt76-test ${interface} set state=tx_cont" |
| 400 | ;; |
| 401 | "TXCOMMIT") |
| 402 | tx_mode=$(convert_tx_mode $(get_config "ATETXMODE")) |
| 403 | case ${tx_mode} in |
| 404 | "ht"|"vht"|"he_su") |
| 405 | do_cmd "mt76-test ${interface} set aid=1" |
| 406 | ;; |
| 407 | *) |
| 408 | ;; |
| 409 | esac |
| 410 | do_cmd "mt76-test ${interface} set state=idle" |
| 411 | ;; |
| 412 | esac |
| 413 | } |
| 414 | |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 415 | # main start here |
| 416 | |
| 417 | if [[ ${interface} == "ra"* ]]; then |
| 418 | tmp=$(get_config "ATECTRLBANDIDX") |
| 419 | if [ ! -z "${tmp}" ]; then |
| 420 | interface="phy${tmp}" |
| 421 | phy_idx=${tmp} |
| 422 | else |
| 423 | interface="phy0" |
| 424 | phy_idx=0 |
| 425 | fi |
| 426 | fi |
| 427 | |
| 428 | cmd=$(echo ${full_cmd} | sed s/=/' '/g | cut -d " " -f 1) |
| 429 | param=$(echo ${full_cmd} | sed s/=/' '/g | cut -d " " -f 2) |
| 430 | |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 431 | if [ "${cmd_type}" = "set" ]; then |
| 432 | skip=0 |
| 433 | use_ated=0 |
| 434 | case ${cmd} in |
| 435 | "ATE") |
| 436 | do_ate_work ${param} |
| 437 | |
| 438 | skip=1 |
| 439 | ;; |
| 440 | "ATETXCNT"|"ATETXLEN"|"ATETXMCS"|"ATEVHTNSS"|"ATETXLDPC"|"ATETXSTBC"| \ |
| 441 | "ATEPKTTXTIME"|"ATEIPG"|"ATEDUTYCYCLE"|"ATETXFREQOFFSET") |
| 442 | cmd_new=$(simple_convert ${cmd}) |
| 443 | param_new=${param} |
| 444 | ;; |
| 445 | "ATETXANT"|"ATERXANT") |
| 446 | cmd_new="tx_antenna" |
| 447 | param_new=${param} |
| 448 | ;; |
| 449 | "ATETXGI") |
| 450 | tx_mode=$(convert_tx_mode $(get_config "ATETXMODE")) |
| 451 | convert_gi ${tx_mode} ${param} |
| 452 | skip=1 |
| 453 | ;; |
| 454 | "ATETXMODE") |
| 455 | cmd_new="tx_rate_mode" |
| 456 | param_new=$(convert_tx_mode ${param}) |
| 457 | record_config ${cmd} ${param} |
| 458 | ;; |
| 459 | "ATETXPOW0"|"ATETXPOW1"|"ATETXPOW2"|"ATETXPOW3") |
| 460 | cmd_new="tx_power" |
| 461 | param_new="${param},0,0,0" |
| 462 | ;; |
| 463 | "ATETXBW") |
| 464 | record_config ${cmd} ${param} |
| 465 | skip=1 |
| 466 | ;; |
| 467 | "ATECHANNEL") |
| 468 | convert_channel ${param} |
| 469 | skip=1 |
| 470 | ;; |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 471 | "ATERXSTAT") |
| 472 | convert_rxstat |
| 473 | skip=1 |
| 474 | ;; |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 475 | "ATECTRLBANDIDX") |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 476 | change_band_idx ${param} |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 477 | skip=1 |
| 478 | ;; |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 479 | "ATEDA"|"ATESA"|"ATEBSSID") |
| 480 | set_mac_addr ${cmd} ${param} |
| 481 | skip=1 |
| 482 | ;; |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 483 | "bufferMode") |
| 484 | if [ "${param}" = "2" ]; then |
| 485 | do_cmd "ated -i ${interface} -c \"eeprom update\"" |
| 486 | fi |
| 487 | skip=1 |
| 488 | ;; |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 489 | "ResetCounter"|"ATERXSTATRESET") |
| 490 | skip=1 |
| 491 | ;; |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 492 | *) |
| 493 | echo "Unknown command to set" |
| 494 | skip=1 |
| 495 | esac |
| 496 | |
| 497 | if [ "${skip}" != "1" ]; then |
| 498 | do_cmd "mt76-test ${interface} set ${cmd_new}=${param_new}" |
| 499 | fi |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 500 | |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 501 | elif [ "${cmd_type}" = "show" ]; then |
| 502 | do_cmd "mt76-test ${interface} dump" |
| 503 | do_cmd "mt76-test ${interface} dump stats" |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 504 | |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 505 | elif [ "${cmd_type}" = "e2p" ]; then |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 506 | offset=$(printf "0x%s" ${cmd}) |
| 507 | val=$(printf "0x%s" ${param}) |
| 508 | |
| 509 | # eeprom offset write |
| 510 | if [[ ${full_cmd} == *"="* ]]; then |
| 511 | tmp=$((${val} & 0xff)) |
| 512 | tmp=$(printf "0x%x" ${tmp}) |
| 513 | do_cmd "ated -i ${interface} -c \"eeprom set ${offset}=${tmp}\"" |
| 514 | |
| 515 | offset=$((${offset})) |
| 516 | offset=$(expr ${offset} + "1") |
| 517 | offset=$(printf "0x%x" ${offset}) |
| 518 | tmp=$(((${val} >> 8) & 0xff)) |
| 519 | tmp=$(printf "0x%x" ${tmp}) |
| 520 | do_cmd "ated -i ${interface} -c \"eeprom set ${offset}=${tmp}\"" |
| 521 | else |
| 522 | v1=$(do_cmd "ated -i ${interface} -c \"eeprom read ${param}\"") |
| 523 | v1=$(echo "${v1}" | grep "val =" | cut -d '(' -f 2 | grep -o -E '[0-9]+') |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 524 | |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 525 | tmp=$(printf "0x%s" ${param}) |
| 526 | tmp=$((${tmp})) |
| 527 | param2=$(expr ${tmp} + "1") |
| 528 | param2=$(printf "%x" ${param2}) |
| 529 | v2=$(do_cmd "ated -i ${interface} -c \"eeprom read ${param2}\"") |
| 530 | v2=$(echo "${v2}" | grep "val =" | cut -d '(' -f 2 | grep -o -E '[0-9]+') |
| 531 | |
| 532 | param=$(printf "0x%s" ${param}) |
| 533 | printf "[0x%04x]:0x%02x%02x\n" ${param} ${v2} ${v1} |
| 534 | fi |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 535 | |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 536 | elif [ "${cmd_type}" = "mac" ]; then |
| 537 | regidx=/sys/kernel/debug/ieee80211/phy${phy_idx}/mt76/regidx |
| 538 | regval=/sys/kernel/debug/ieee80211/phy${phy_idx}/mt76/regval |
| 539 | offset=$(printf "0x%s" ${cmd}) |
| 540 | val=$(printf "0x%s" ${param}) |
| 541 | |
| 542 | echo ${offset} > ${regidx} |
| 543 | # reg write |
| 544 | if [[ ${full_cmd} == *"="* ]]; then |
| 545 | echo ${val} > ${regval} |
| 546 | else |
| 547 | res=$(cat ${regval} | cut -d 'x' -f 2) |
| 548 | printf "%s mac:[%s]:%s\n" ${interface} ${offset} ${res} |
| 549 | fi |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 550 | |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 551 | else |
| 552 | echo "Unknown command" |
| 553 | fi |