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 |
developer | 9b7cdad | 2022-03-10 14:24:55 +0800 | [diff] [blame] | 6 | interface_ori=${interface} |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 7 | |
| 8 | work_mode="RUN" # RUN/PRINT/DEBUG |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 9 | tmp_file="/tmp/iwpriv_wrapper" |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 10 | phy_idx=$(echo ${interface} | tr -dc '0-9') |
| 11 | |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 12 | function 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 | |
developer | 9b7cdad | 2022-03-10 14:24:55 +0800 | [diff] [blame] | 27 | function print_debug() { |
| 28 | if [ "${work_mode}" = "DEBUG" ]; then |
| 29 | echo "$1" |
| 30 | fi |
| 31 | } |
| 32 | |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 33 | function write_dmesg() { |
| 34 | echo "$1" > /dev/kmsg |
| 35 | } |
| 36 | |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 37 | function 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 | |
| 49 | function get_config() { |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 50 | 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 |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 60 | } |
| 61 | |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 62 | function 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 |
developer | 9b7cdad | 2022-03-10 14:24:55 +0800 | [diff] [blame] | 84 | echo "unknown param: $1" |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 85 | fi |
| 86 | } |
| 87 | |
| 88 | function 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 |
developer | 9b7cdad | 2022-03-10 14:24:55 +0800 | [diff] [blame] | 106 | echo "unknown tx mode: $1" |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 107 | fi |
| 108 | } |
| 109 | |
| 110 | function 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 | *) |
developer | 9b7cdad | 2022-03-10 14:24:55 +0800 | [diff] [blame] | 180 | print_debug "legacy mode no need gi" |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 181 | esac |
| 182 | |
| 183 | do_cmd "mt76-test ${interface} set tx_rate_sgi=${sgi} tx_ltf=${he_ltf}" |
| 184 | } |
| 185 | |
| 186 | function 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) |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 190 | local bw_str="HT20" |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 191 | |
developer | 9b7cdad | 2022-03-10 14:24:55 +0800 | [diff] [blame] | 192 | if [[ $1 != *":"* ]] || [ "${band}" = "0" ]; then |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 193 | case ${bw} in |
| 194 | "1") |
developer | 461cb54 | 2022-04-29 18:17:44 +0800 | [diff] [blame] | 195 | if [ "${ch}" -lt "3" ] || [ "${ch}" -gt "12" ]; then |
| 196 | local bw_str="HT20" |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 197 | else |
developer | 461cb54 | 2022-04-29 18:17:44 +0800 | [diff] [blame] | 198 | local bw_str="HT40+" |
| 199 | ch=$(expr ${ch} - "2") |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 200 | fi |
| 201 | ;; |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 202 | esac |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 203 | elif [ "${band}" = "1" ]; then |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 204 | case ${bw} in |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 205 | "5") |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 206 | 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 |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 216 | ;; |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 217 | "2") |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 218 | 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 |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 238 | ;; |
| 239 | "1") |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 240 | 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-") |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 294 | fi |
| 295 | ;; |
| 296 | "0") |
| 297 | local bw_str="HT20" |
| 298 | ;; |
| 299 | esac |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 300 | else |
| 301 | echo "6G Todo" |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 302 | fi |
| 303 | |
| 304 | do_cmd "iw dev mon${phy_idx} set channel ${ch} ${bw_str}" |
| 305 | } |
| 306 | |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 307 | function 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 | |
developer | 461cb54 | 2022-04-29 18:17:44 +0800 | [diff] [blame] | 316 | 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}" |
developer | 9b7cdad | 2022-03-10 14:24:55 +0800 | [diff] [blame] | 321 | write_dmesg "all_mac_rx_ok_cnt : ${rx_ok}" |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 322 | } |
| 323 | |
| 324 | function 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 | |
| 349 | function 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 | |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 369 | function 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" |
developer | 9b7cdad | 2022-03-10 14:24:55 +0800 | [diff] [blame] | 382 | do_cmd "iw reg set VV" |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 383 | 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" |
developer | 461cb54 | 2022-04-29 18:17:44 +0800 | [diff] [blame] | 394 | do_cmd "mt76-test ${interface} set aid=0" |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 395 | fi |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 396 | |
| 397 | rm ${tmp_file} > /dev/null 2>&1 |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 398 | ;; |
developer | 461cb54 | 2022-04-29 18:17:44 +0800 | [diff] [blame] | 399 | "TXCOMMIT") |
| 400 | do_cmd "mt76-test ${interface} set aid=1" |
| 401 | ;; |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 402 | "TXFRAME") |
| 403 | do_cmd "mt76-test ${interface} set state=tx_frames" |
| 404 | ;; |
developer | 9b7cdad | 2022-03-10 14:24:55 +0800 | [diff] [blame] | 405 | "TXSTOP"|"RXSTOP") |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 406 | do_cmd "mt76-test ${interface} set state=idle" |
| 407 | ;; |
developer | 461cb54 | 2022-04-29 18:17:44 +0800 | [diff] [blame] | 408 | "TXREVERT") |
| 409 | do_cmd "mt76-test ${interface} set aid=0" |
| 410 | ;; |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 411 | "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 | ;; |
developer | 9b7cdad | 2022-03-10 14:24:55 +0800 | [diff] [blame] | 417 | *) |
developer | 9b7cdad | 2022-03-10 14:24:55 +0800 | [diff] [blame] | 418 | print_debug "skip ${ate_cmd}" |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 419 | ;; |
| 420 | esac |
| 421 | } |
| 422 | |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 423 | # main start here |
| 424 | |
| 425 | if [[ ${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 |
| 434 | fi |
| 435 | |
| 436 | cmd=$(echo ${full_cmd} | sed s/=/' '/g | cut -d " " -f 1) |
| 437 | param=$(echo ${full_cmd} | sed s/=/' '/g | cut -d " " -f 2) |
| 438 | |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 439 | if [ "${cmd_type}" = "set" ]; then |
| 440 | skip=0 |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 441 | 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 | ;; |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 478 | "ATERXSTAT") |
| 479 | convert_rxstat |
| 480 | skip=1 |
| 481 | ;; |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 482 | "ATECTRLBANDIDX") |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 483 | change_band_idx ${param} |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 484 | skip=1 |
| 485 | ;; |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 486 | "ATEDA"|"ATESA"|"ATEBSSID") |
| 487 | set_mac_addr ${cmd} ${param} |
| 488 | skip=1 |
| 489 | ;; |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 490 | "bufferMode") |
| 491 | if [ "${param}" = "2" ]; then |
developer | 461cb54 | 2022-04-29 18:17:44 +0800 | [diff] [blame] | 492 | do_cmd "atenl -i ${interface} -c \"eeprom update buffermode\"" |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 493 | fi |
| 494 | skip=1 |
| 495 | ;; |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 496 | "ResetCounter"|"ATERXSTATRESET") |
| 497 | skip=1 |
| 498 | ;; |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 499 | *) |
developer | 9b7cdad | 2022-03-10 14:24:55 +0800 | [diff] [blame] | 500 | print_debug "Unknown command to set: ${cmd}" |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 501 | skip=1 |
| 502 | esac |
| 503 | |
| 504 | if [ "${skip}" != "1" ]; then |
| 505 | do_cmd "mt76-test ${interface} set ${cmd_new}=${param_new}" |
| 506 | fi |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 507 | |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 508 | elif [ "${cmd_type}" = "show" ]; then |
| 509 | do_cmd "mt76-test ${interface} dump" |
| 510 | do_cmd "mt76-test ${interface} dump stats" |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 511 | |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 512 | elif [ "${cmd_type}" = "e2p" ]; then |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 513 | 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}) |
developer | 461cb54 | 2022-04-29 18:17:44 +0800 | [diff] [blame] | 520 | do_cmd "atenl -i ${interface} -c \"eeprom set ${offset}=${tmp}\"" |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 521 | |
| 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}) |
developer | 461cb54 | 2022-04-29 18:17:44 +0800 | [diff] [blame] | 527 | do_cmd "atenl -i ${interface} -c \"eeprom set ${offset}=${tmp}\"" |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 528 | else |
developer | 461cb54 | 2022-04-29 18:17:44 +0800 | [diff] [blame] | 529 | v1=$(do_cmd "atenl -i ${interface} -c \"eeprom read ${param}\"") |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 530 | 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] | 531 | |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 532 | tmp=$(printf "0x%s" ${param}) |
| 533 | tmp=$((${tmp})) |
| 534 | param2=$(expr ${tmp} + "1") |
| 535 | param2=$(printf "%x" ${param2}) |
developer | 461cb54 | 2022-04-29 18:17:44 +0800 | [diff] [blame] | 536 | v2=$(do_cmd "atenl -i ${interface} -c \"eeprom read ${param2}\"") |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 537 | v2=$(echo "${v2}" | grep "val =" | cut -d '(' -f 2 | grep -o -E '[0-9]+') |
| 538 | |
| 539 | param=$(printf "0x%s" ${param}) |
developer | 461cb54 | 2022-04-29 18:17:44 +0800 | [diff] [blame] | 540 | param=$(printf "%04x" ${param}) |
| 541 | param=$(echo $param | tr 'a-z' 'A-Z') |
developer | 9b7cdad | 2022-03-10 14:24:55 +0800 | [diff] [blame] | 542 | printf "%s e2p:\n" ${interface_ori} |
developer | 461cb54 | 2022-04-29 18:17:44 +0800 | [diff] [blame] | 543 | printf "[0x%s]:0x%02x%02x\n" ${param} ${v2} ${v1} |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 544 | fi |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 545 | |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 546 | elif [ "${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} |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 556 | fi |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 557 | |
developer | 461cb54 | 2022-04-29 18:17:44 +0800 | [diff] [blame] | 558 | res=$(cat ${regval} | cut -d 'x' -f 2) |
| 559 | printf "%s mac:[%s]:%s\n" ${interface_ori} ${offset} ${res} |
| 560 | |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 561 | else |
| 562 | echo "Unknown command" |
| 563 | fi |