developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 1 | #!/bin/ash |
| 2 | |
developer | 071927d | 2022-08-31 20:39:29 +0800 | [diff] [blame] | 3 | interface=$1 # phy0/phy1/ra0 |
developer | f90c9af | 2022-12-28 22:40:23 +0800 | [diff] [blame^] | 4 | cmd_type=$2 # set/show/e2p/mac/dump |
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 | f90c9af | 2022-12-28 22:40:23 +0800 | [diff] [blame^] | 7 | SOC_start_idx="0" |
| 8 | is_eagle="0" |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 9 | |
| 10 | work_mode="RUN" # RUN/PRINT/DEBUG |
developer | 679a6aa | 2022-09-07 09:52:41 +0800 | [diff] [blame] | 11 | iwpriv_file="/tmp/iwpriv_wrapper" |
| 12 | interface_file="/tmp/interface" |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 13 | phy_idx=$(echo ${interface} | tr -dc '0-9') |
| 14 | |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 15 | function do_cmd() { |
| 16 | case ${work_mode} in |
| 17 | "RUN") |
| 18 | eval "$1" |
| 19 | ;; |
| 20 | "PRINT") |
| 21 | echo "$1" |
| 22 | ;; |
| 23 | "DEBUG") |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 24 | echo "$1" |
developer | 887da63 | 2022-10-28 09:35:38 +0800 | [diff] [blame] | 25 | eval "$1" |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 26 | ;; |
| 27 | esac |
| 28 | } |
| 29 | |
developer | 9b7cdad | 2022-03-10 14:24:55 +0800 | [diff] [blame] | 30 | function print_debug() { |
| 31 | if [ "${work_mode}" = "DEBUG" ]; then |
| 32 | echo "$1" |
| 33 | fi |
| 34 | } |
| 35 | |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 36 | function write_dmesg() { |
| 37 | echo "$1" > /dev/kmsg |
| 38 | } |
| 39 | |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 40 | function record_config() { |
developer | 679a6aa | 2022-09-07 09:52:41 +0800 | [diff] [blame] | 41 | local config=$1 |
| 42 | local tmp_file=$3 |
| 43 | |
developer | f90c9af | 2022-12-28 22:40:23 +0800 | [diff] [blame^] | 44 | # check it is SOC(mt7986)/Eagle or PCIE card (mt7915/7916), and write its config |
| 45 | if [ ${config} != "STARTIDX" ] && [ ${config} != "IS_EAGLE" ]; then |
| 46 | if [ $phy_idx -lt $SOC_start_idx ]; then |
developer | 679a6aa | 2022-09-07 09:52:41 +0800 | [diff] [blame] | 47 | config="${config}_PCIE" |
developer | f90c9af | 2022-12-28 22:40:23 +0800 | [diff] [blame^] | 48 | elif [ $phy_idx -ge $SOC_start_idx ]; then |
| 49 | config="${config}_SOC" |
developer | 679a6aa | 2022-09-07 09:52:41 +0800 | [diff] [blame] | 50 | fi |
| 51 | fi |
| 52 | |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 53 | if [ -f ${tmp_file} ]; then |
developer | 679a6aa | 2022-09-07 09:52:41 +0800 | [diff] [blame] | 54 | if grep -q ${config} ${tmp_file}; then |
| 55 | sed -i "/${config}/c\\${config}=$2" ${tmp_file} |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 56 | else |
developer | 679a6aa | 2022-09-07 09:52:41 +0800 | [diff] [blame] | 57 | echo "${config}=$2" >> ${tmp_file} |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 58 | fi |
| 59 | else |
developer | 679a6aa | 2022-09-07 09:52:41 +0800 | [diff] [blame] | 60 | echo "${config}=$2" >> ${tmp_file} |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 61 | fi |
| 62 | } |
| 63 | |
| 64 | function get_config() { |
developer | 679a6aa | 2022-09-07 09:52:41 +0800 | [diff] [blame] | 65 | local config=$1 |
| 66 | local tmp_file=$2 |
| 67 | |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 68 | if [ ! -f ${tmp_file} ]; then |
| 69 | echo "" |
| 70 | return |
| 71 | fi |
| 72 | |
developer | f90c9af | 2022-12-28 22:40:23 +0800 | [diff] [blame^] | 73 | # check it is SOC(mt7986)/Eagle or PCIE card (mt7915/7916), and write its config |
| 74 | if [ ${config} != "STARTIDX" ] && [ ${config} != "IS_EAGLE" ]; then |
| 75 | if [ $phy_idx -lt $SOC_start_idx ]; then |
developer | 679a6aa | 2022-09-07 09:52:41 +0800 | [diff] [blame] | 76 | config="${config}_PCIE" |
developer | f90c9af | 2022-12-28 22:40:23 +0800 | [diff] [blame^] | 77 | elif [ $phy_idx -ge $SOC_start_idx ]; then |
| 78 | config="${config}_SOC" |
developer | 679a6aa | 2022-09-07 09:52:41 +0800 | [diff] [blame] | 79 | fi |
| 80 | fi |
| 81 | |
| 82 | if grep -q ${config} ${tmp_file}; then |
| 83 | echo "$(cat ${tmp_file} | grep ${config} | sed s/=/' '/g | cut -d " " -f 2)" |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 84 | else |
| 85 | echo "" |
| 86 | fi |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 87 | } |
| 88 | |
developer | eebce5c | 2022-08-26 19:05:56 +0800 | [diff] [blame] | 89 | function convert_interface { |
developer | f90c9af | 2022-12-28 22:40:23 +0800 | [diff] [blame^] | 90 | SOC_start_idx=$(get_config "STARTIDX" ${interface_file}) |
| 91 | is_eagle=$(get_config "IS_EAGLE" ${interface_file}) |
developer | 679a6aa | 2022-09-07 09:52:41 +0800 | [diff] [blame] | 92 | local eeprom_file=/sys/kernel/debug/ieee80211/phy0/mt76/eeprom |
developer | f90c9af | 2022-12-28 22:40:23 +0800 | [diff] [blame^] | 93 | if [ -z "${SOC_start_idx}" ] || [ -z "${is_eagle}" ]; then |
developer | 679a6aa | 2022-09-07 09:52:41 +0800 | [diff] [blame] | 94 | if [ ! -z "$(head -c 2 ${eeprom_file} | hexdump | grep "7916")" ]; then |
developer | f90c9af | 2022-12-28 22:40:23 +0800 | [diff] [blame^] | 95 | SOC_start_idx="2" |
| 96 | is_eagle="0" |
developer | 679a6aa | 2022-09-07 09:52:41 +0800 | [diff] [blame] | 97 | elif [ ! -z "$(head -c 2 ${eeprom_file} | hexdump | grep "7915")" ]; then |
developer | f90c9af | 2022-12-28 22:40:23 +0800 | [diff] [blame^] | 98 | SOC_start_idx="1" |
| 99 | is_eagle="0" |
developer | 679a6aa | 2022-09-07 09:52:41 +0800 | [diff] [blame] | 100 | elif [ ! -z "$(head -c 2 ${eeprom_file} | hexdump | grep "7986")" ]; then |
developer | f90c9af | 2022-12-28 22:40:23 +0800 | [diff] [blame^] | 101 | SOC_start_idx="0" |
| 102 | is_eagle="0" |
| 103 | elif [ ! -z "$(head -c 2 ${eeprom_file} | hexdump | grep "7990")" ]; then |
| 104 | SOC_start_idx="0" |
| 105 | is_eagle="1" |
developer | eebce5c | 2022-08-26 19:05:56 +0800 | [diff] [blame] | 106 | else |
developer | 679a6aa | 2022-09-07 09:52:41 +0800 | [diff] [blame] | 107 | echo "Interface Conversion Failed!" |
| 108 | echo "Please use iwpriv <phy0/phy1/..> set <...> or configure the sku of your board manually by the following commands" |
developer | f90c9af | 2022-12-28 22:40:23 +0800 | [diff] [blame^] | 109 | echo "For AX6000/Eagle: echo STARTIDX=0 >> ${interface_file}" |
developer | 679a6aa | 2022-09-07 09:52:41 +0800 | [diff] [blame] | 110 | echo "For AX7800: echo STARTIDX=2 >> ${interface_file}" |
| 111 | echo "For AX8400: echo STARTIDX=1 >> ${interface_file}" |
| 112 | exit 0 |
developer | eebce5c | 2022-08-26 19:05:56 +0800 | [diff] [blame] | 113 | fi |
developer | f90c9af | 2022-12-28 22:40:23 +0800 | [diff] [blame^] | 114 | record_config "STARTIDX" ${SOC_start_idx} ${interface_file} |
| 115 | record_config "IS_EAGLE" ${is_eagle} ${interface_file} |
developer | eebce5c | 2022-08-26 19:05:56 +0800 | [diff] [blame] | 116 | fi |
| 117 | |
developer | 679a6aa | 2022-09-07 09:52:41 +0800 | [diff] [blame] | 118 | |
developer | f90c9af | 2022-12-28 22:40:23 +0800 | [diff] [blame^] | 119 | if [ ${is_eagle} == "0" ]; then |
developer | 679a6aa | 2022-09-07 09:52:41 +0800 | [diff] [blame] | 120 | if [[ $1 == "raix"* ]]; then |
developer | f90c9af | 2022-12-28 22:40:23 +0800 | [diff] [blame^] | 121 | phy_idx=1 |
| 122 | elif [[ $1 == "rai"* ]]; then |
developer | 679a6aa | 2022-09-07 09:52:41 +0800 | [diff] [blame] | 123 | phy_idx=0 |
| 124 | elif [[ $1 == "rax"* ]]; then |
developer | f90c9af | 2022-12-28 22:40:23 +0800 | [diff] [blame^] | 125 | phy_idx=$((SOC_start_idx+1)) |
| 126 | else |
| 127 | phy_idx=$SOC_start_idx |
developer | 679a6aa | 2022-09-07 09:52:41 +0800 | [diff] [blame] | 128 | fi |
developer | f90c9af | 2022-12-28 22:40:23 +0800 | [diff] [blame^] | 129 | |
| 130 | # convert phy index according to band idx |
| 131 | local band_idx=$(get_config "ATECTRLBANDIDX" ${iwpriv_file}) |
| 132 | if [ "${band_idx}" = "0" ]; then |
| 133 | if [[ $1 == "raix"* ]]; then |
| 134 | phy_idx=0 |
| 135 | elif [[ $1 == "rax"* ]]; then |
| 136 | phy_idx=$SOC_start_idx |
| 137 | fi |
| 138 | elif [ "${band_idx}" = "1" ]; then |
| 139 | if [[ $1 == "rai"* ]]; then |
| 140 | # AX8400: mt7915 remain phy0 |
| 141 | # AX7800: mt7916 becomes phy1 |
| 142 | phy_idx=$((SOC_start_idx-1)) |
| 143 | elif [[ $1 == "ra"* ]]; then |
| 144 | phy_idx=$((SOC_start_idx+1)) |
| 145 | fi |
| 146 | fi |
| 147 | else |
| 148 | # Eagle has different mapping method |
| 149 | # phy0: ra0 |
| 150 | # phy1: rai0 |
| 151 | # phy2: rax0 |
developer | 679a6aa | 2022-09-07 09:52:41 +0800 | [diff] [blame] | 152 | if [[ $1 == "rai"* ]]; then |
developer | f90c9af | 2022-12-28 22:40:23 +0800 | [diff] [blame^] | 153 | phy_idx=1 |
| 154 | elif [[ $1 == "rax"* ]]; then |
| 155 | phy_idx=2 |
| 156 | else |
| 157 | phy_idx=0 |
developer | 679a6aa | 2022-09-07 09:52:41 +0800 | [diff] [blame] | 158 | fi |
| 159 | fi |
| 160 | |
| 161 | interface="phy${phy_idx}" |
| 162 | } |
| 163 | |
| 164 | function change_band_idx { |
| 165 | local new_idx=$1 |
| 166 | local new_phy_idx=$phy_idx |
| 167 | |
| 168 | local old_idx=$(get_config "ATECTRLBANDIDX" ${iwpriv_file}) |
| 169 | |
| 170 | |
| 171 | if [[ ${interface_ori} == "ra"* ]]; then |
| 172 | if [ -z "${old_idx}" ] || [ "${old_idx}" != "${new_idx}" ]; then |
| 173 | if [ "${new_idx}" = "0" ]; then |
| 174 | # raix0 & rai0 becomes rai0 |
| 175 | if [[ $interface_ori == "rai"* ]]; then |
| 176 | new_phy_idx=0 |
| 177 | # rax0 & ra0 becomes ra0 |
| 178 | elif [[ $interface_ori == "ra"* ]]; then |
developer | f90c9af | 2022-12-28 22:40:23 +0800 | [diff] [blame^] | 179 | new_phy_idx=$SOC_start_idx |
developer | 679a6aa | 2022-09-07 09:52:41 +0800 | [diff] [blame] | 180 | fi |
| 181 | elif [ "${new_idx}" = "1" ]; then |
| 182 | # raix0 & rai0 becomes raix0 |
| 183 | if [[ $interface_ori == "rai"* ]]; then |
developer | 1346ce5 | 2022-12-15 21:36:14 +0800 | [diff] [blame] | 184 | # For AX8400 => don't change phy idx |
developer | f90c9af | 2022-12-28 22:40:23 +0800 | [diff] [blame^] | 185 | if [ ${SOC_start_idx} != "1" ]; then |
developer | 1346ce5 | 2022-12-15 21:36:14 +0800 | [diff] [blame] | 186 | new_phy_idx=1 |
| 187 | fi |
developer | 679a6aa | 2022-09-07 09:52:41 +0800 | [diff] [blame] | 188 | # rax0 & ra0 becomes rax0 |
| 189 | elif [[ $interface_ori == "ra"* ]]; then |
developer | f90c9af | 2022-12-28 22:40:23 +0800 | [diff] [blame^] | 190 | new_phy_idx=$((SOC_start_idx+1)) |
developer | 679a6aa | 2022-09-07 09:52:41 +0800 | [diff] [blame] | 191 | fi |
| 192 | fi |
| 193 | fi |
| 194 | |
| 195 | if [ ${new_phy_idx} != ${phy_idx} ]; then |
| 196 | do_ate_work "ATESTOP" |
| 197 | phy_idx=$new_phy_idx |
| 198 | interface="phy${phy_idx}" |
| 199 | do_ate_work "ATESTART" |
| 200 | fi |
developer | eebce5c | 2022-08-26 19:05:56 +0800 | [diff] [blame] | 201 | fi |
developer | 679a6aa | 2022-09-07 09:52:41 +0800 | [diff] [blame] | 202 | record_config "ATECTRLBANDIDX" ${new_idx} ${iwpriv_file} |
developer | eebce5c | 2022-08-26 19:05:56 +0800 | [diff] [blame] | 203 | } |
| 204 | |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 205 | function simple_convert() { |
| 206 | if [ "$1" = "ATETXCNT" ]; then |
| 207 | echo "tx_count" |
| 208 | elif [ "$1" = "ATETXLEN" ]; then |
| 209 | echo "tx_length" |
| 210 | elif [ "$1" = "ATETXMCS" ]; then |
| 211 | echo "tx_rate_idx" |
| 212 | elif [ "$1" = "ATEVHTNSS" ]; then |
| 213 | echo "tx_rate_nss" |
| 214 | elif [ "$1" = "ATETXLDPC" ]; then |
| 215 | echo "tx_rate_ldpc" |
| 216 | elif [ "$1" = "ATETXSTBC" ]; then |
| 217 | echo "tx_rate_stbc" |
| 218 | elif [ "$1" = "ATEPKTTXTIME" ]; then |
| 219 | echo "tx_time" |
| 220 | elif [ "$1" = "ATEIPG" ]; then |
| 221 | echo "tx_ipg" |
| 222 | elif [ "$1" = "ATEDUTYCYCLE" ]; then |
| 223 | echo "tx_duty_cycle" |
| 224 | elif [ "$1" = "ATETXFREQOFFSET" ]; then |
| 225 | echo "freq_offset" |
| 226 | else |
developer | 679a6aa | 2022-09-07 09:52:41 +0800 | [diff] [blame] | 227 | echo "undefined" |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 228 | fi |
| 229 | } |
| 230 | |
| 231 | function convert_tx_mode() { |
developer | 1346ce5 | 2022-12-15 21:36:14 +0800 | [diff] [blame] | 232 | # Remove leading zeros |
| 233 | local tx_mode=$(echo $1 | sed 's/^0*//') |
| 234 | |
| 235 | if [ "$tx_mode" = "0" ]; then |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 236 | echo "cck" |
developer | 1346ce5 | 2022-12-15 21:36:14 +0800 | [diff] [blame] | 237 | elif [ "$tx_mode" = "1" ]; then |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 238 | echo "ofdm" |
developer | 1346ce5 | 2022-12-15 21:36:14 +0800 | [diff] [blame] | 239 | elif [ "$tx_mode" = "2" ]; then |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 240 | echo "ht" |
developer | 1346ce5 | 2022-12-15 21:36:14 +0800 | [diff] [blame] | 241 | elif [ "$tx_mode" = "4" ]; then |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 242 | echo "vht" |
developer | 1346ce5 | 2022-12-15 21:36:14 +0800 | [diff] [blame] | 243 | elif [ "$tx_mode" = "8" ]; then |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 244 | echo "he_su" |
developer | 1346ce5 | 2022-12-15 21:36:14 +0800 | [diff] [blame] | 245 | elif [ "$tx_mode" = "9" ]; then |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 246 | echo "he_er" |
developer | 1346ce5 | 2022-12-15 21:36:14 +0800 | [diff] [blame] | 247 | elif [ "$tx_mode" = "10" ]; then |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 248 | echo "he_tb" |
developer | 1346ce5 | 2022-12-15 21:36:14 +0800 | [diff] [blame] | 249 | elif [ "$tx_mode" = "11" ]; then |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 250 | echo "he_mu" |
| 251 | else |
developer | 679a6aa | 2022-09-07 09:52:41 +0800 | [diff] [blame] | 252 | echo "undefined" |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 253 | fi |
| 254 | } |
| 255 | |
| 256 | function convert_gi { |
| 257 | local tx_mode=$1 |
| 258 | local val=$2 |
| 259 | local sgi="0" |
| 260 | local he_ltf="0" |
| 261 | |
| 262 | case ${tx_mode} in |
| 263 | "ht"|"vht") |
| 264 | sgi=${val} |
| 265 | ;; |
| 266 | "he_su"|"he_er") |
| 267 | case ${val} in |
| 268 | "0") |
| 269 | ;; |
| 270 | "1") |
| 271 | he_ltf="1" |
| 272 | ;; |
| 273 | "2") |
| 274 | sgi="1" |
| 275 | he_ltf="1" |
| 276 | ;; |
| 277 | "3") |
| 278 | sgi="2" |
| 279 | he_ltf="2" |
| 280 | ;; |
| 281 | "4") |
| 282 | he_ltf="2" |
| 283 | ;; |
| 284 | *) |
| 285 | echo "unknown gi" |
| 286 | esac |
| 287 | ;; |
| 288 | "he_mu") |
| 289 | case ${val} in |
| 290 | "0") |
| 291 | he_ltf="2" |
| 292 | ;; |
| 293 | "1") |
| 294 | he_ltf="1" |
| 295 | ;; |
| 296 | "2") |
| 297 | sgi="1" |
| 298 | he_ltf="1" |
| 299 | ;; |
| 300 | "3") |
| 301 | sgi="2" |
| 302 | he_ltf="2" |
| 303 | ;; |
| 304 | *) |
| 305 | echo "unknown gi" |
| 306 | esac |
| 307 | ;; |
| 308 | "he_tb") |
| 309 | case ${val} in |
| 310 | "0") |
| 311 | sgi="1" |
| 312 | ;; |
| 313 | "1") |
| 314 | sgi="1" |
| 315 | he_ltf="1" |
| 316 | ;; |
| 317 | "2") |
| 318 | sgi="2" |
| 319 | he_ltf="2" |
| 320 | ;; |
| 321 | *) |
| 322 | echo "unknown gi" |
| 323 | esac |
| 324 | ;; |
| 325 | *) |
developer | 9b7cdad | 2022-03-10 14:24:55 +0800 | [diff] [blame] | 326 | print_debug "legacy mode no need gi" |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 327 | esac |
| 328 | |
| 329 | do_cmd "mt76-test ${interface} set tx_rate_sgi=${sgi} tx_ltf=${he_ltf}" |
| 330 | } |
| 331 | |
| 332 | function convert_channel { |
developer | 679a6aa | 2022-09-07 09:52:41 +0800 | [diff] [blame] | 333 | local ctrl_band_idx=$(get_config "ATECTRLBANDIDX" ${iwpriv_file}) |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 334 | local ch=$(echo $1 | sed s/:/' '/g | cut -d " " -f 1) |
developer | 679a6aa | 2022-09-07 09:52:41 +0800 | [diff] [blame] | 335 | local bw=$(get_config "ATETXBW" ${iwpriv_file} | cut -d ":" -f 1) |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 336 | local bw_str="HT20" |
developer | eebce5c | 2022-08-26 19:05:56 +0800 | [diff] [blame] | 337 | local base_chan=1 |
| 338 | local control_freq=0 |
| 339 | local base_freq=0 |
developer | 1346ce5 | 2022-12-15 21:36:14 +0800 | [diff] [blame] | 340 | local band=$(echo $1 | sed s/:/' '/g | cut -d " " -f 2) |
| 341 | local temp=$((phy_idx+1)) |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 342 | |
developer | 1346ce5 | 2022-12-15 21:36:14 +0800 | [diff] [blame] | 343 | # Handle ATECTRLBANDIDX |
| 344 | if [ ! -z ${ctrl_band_idx} ]; then |
| 345 | if [ "${ctrl_band_idx}" == "1" ] && [ ${band} == "0" ]; then |
| 346 | local temp=$(cat "/etc/config/wireless"| grep "option band" | sed -n ${temp}p | cut -c 15) |
| 347 | if [ "${temp}" == "2" ]; then |
| 348 | local band=0 |
| 349 | elif [ "${temp}" == "5" ]; then |
| 350 | local band=1 |
| 351 | elif [ "${temp}" == "6" ]; then |
| 352 | local band=2 |
| 353 | else |
| 354 | echo "iwpriv wrapper band translate error!" |
| 355 | fi |
| 356 | else |
| 357 | # mt7915 in AX8400 case: band should be determined by only the input band |
developer | f90c9af | 2022-12-28 22:40:23 +0800 | [diff] [blame^] | 358 | if [ "${SOC_start_idx}" == "1" ] && [ ${phy_idx} == "0" ]; then |
developer | 1346ce5 | 2022-12-15 21:36:14 +0800 | [diff] [blame] | 359 | local band=$((band)) |
| 360 | else |
| 361 | local band=$((ctrl_band_idx * band)) |
| 362 | fi |
| 363 | fi |
developer | 679a6aa | 2022-09-07 09:52:41 +0800 | [diff] [blame] | 364 | fi |
| 365 | |
developer | 9b7cdad | 2022-03-10 14:24:55 +0800 | [diff] [blame] | 366 | if [[ $1 != *":"* ]] || [ "${band}" = "0" ]; then |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 367 | case ${bw} in |
| 368 | "1") |
developer | 461cb54 | 2022-04-29 18:17:44 +0800 | [diff] [blame] | 369 | if [ "${ch}" -lt "3" ] || [ "${ch}" -gt "12" ]; then |
| 370 | local bw_str="HT20" |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 371 | else |
developer | 461cb54 | 2022-04-29 18:17:44 +0800 | [diff] [blame] | 372 | local bw_str="HT40+" |
| 373 | ch=$(expr ${ch} - "2") |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 374 | fi |
| 375 | ;; |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 376 | esac |
developer | eebce5c | 2022-08-26 19:05:56 +0800 | [diff] [blame] | 377 | local base_freq=2412 |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 378 | elif [ "${band}" = "1" ]; then |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 379 | case ${bw} in |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 380 | "5") |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 381 | bw_str="160MHz" |
| 382 | if [ ${ch} -lt "68" ]; then |
| 383 | ch="36" |
| 384 | elif [ ${ch} -lt "100" ]; then |
| 385 | ch="68" |
| 386 | elif [ ${ch} -lt "132" ]; then |
| 387 | ch="100" |
| 388 | elif [ ${ch} -lt "181" ]; then |
| 389 | ch="149" |
| 390 | fi |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 391 | ;; |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 392 | "2") |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 393 | bw_str="80MHz" |
| 394 | if [ ${ch} -lt "52" ]; then |
| 395 | ch="36" |
| 396 | elif [ ${ch} -lt "68" ]; then |
| 397 | ch="52" |
| 398 | elif [ ${ch} -lt "84" ]; then |
| 399 | ch="68" |
| 400 | elif [ ${ch} -lt "100" ]; then |
| 401 | ch="84" |
| 402 | elif [ ${ch} -lt "116" ]; then |
| 403 | ch="100" |
| 404 | elif [ ${ch} -lt "132" ]; then |
| 405 | ch="116" |
| 406 | elif [ ${ch} -lt "149" ]; then |
| 407 | ch="132" |
| 408 | elif [ ${ch} -lt "165" ]; then |
| 409 | ch="149" |
| 410 | elif [ ${ch} -lt "181" ]; then |
| 411 | ch="165" |
| 412 | fi |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 413 | ;; |
| 414 | "1") |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 415 | if [ ${ch} -lt "44" ]; then |
| 416 | ch=$([ "${ch}" -lt "40" ] && echo "36" || echo "40") |
| 417 | bw_str=$([ "${ch}" -le "38" ] && echo "HT40+" || echo "HT40-") |
| 418 | elif [ ${ch} -lt "52" ]; then |
| 419 | ch=$([ "${ch}" -lt "48" ] && echo "44" || echo "48") |
| 420 | bw_str=$([ "${ch}" -le "46" ] && echo "HT40+" || echo "HT40-") |
| 421 | elif [ ${ch} -lt "60" ]; then |
| 422 | ch=$([ "${ch}" -lt "56" ] && echo "52" || echo "56") |
| 423 | bw_str=$([ "${ch}" -le "54" ] && echo "HT40+" || echo "HT40-") |
| 424 | elif [ ${ch} -lt "68" ]; then |
| 425 | ch=$([ "${ch}" -lt "64" ] && echo "60" || echo "64") |
| 426 | bw_str=$([ "${ch}" -le "62" ] && echo "HT40+" || echo "HT40-") |
| 427 | elif [ ${ch} -lt "76" ]; then |
| 428 | ch=$([ "${ch}" -lt "72" ] && echo "68" || echo "72") |
| 429 | bw_str=$([ "${ch}" -le "70" ] && echo "HT40+" || echo "HT40-") |
| 430 | elif [ ${ch} -lt "84" ]; then |
| 431 | ch=$([ "${ch}" -lt "80" ] && echo "76" || echo "80") |
| 432 | bw_str=$([ "${ch}" -le "78" ] && echo "HT40+" || echo "HT40-") |
| 433 | elif [ ${ch} -lt "92" ]; then |
| 434 | ch=$([ "${ch}" -lt "88" ] && echo "84" || echo "88") |
| 435 | bw_str=$([ "${ch}" -le "86" ] && echo "HT40+" || echo "HT40-") |
| 436 | elif [ ${ch} -lt "100" ]; then |
| 437 | ch=$([ "${ch}" -lt "96" ] && echo "92" || echo "96") |
| 438 | bw_str=$([ "${ch}" -le "94" ] && echo "HT40+" || echo "HT40-") |
| 439 | elif [ ${ch} -lt "108" ]; then |
| 440 | ch=$([ "${ch}" -lt "104" ] && echo "100" || echo "104") |
| 441 | bw_str=$([ "${ch}" -le "102" ] && echo "HT40+" || echo "HT40-") |
| 442 | elif [ ${ch} -lt "116" ]; then |
| 443 | ch=$([ "${ch}" -lt "112" ] && echo "108" || echo "112") |
| 444 | bw_str=$([ "${ch}" -le "110" ] && echo "HT40+" || echo "HT40-") |
| 445 | elif [ ${ch} -lt "124" ]; then |
| 446 | ch=$([ "${ch}" -lt "120" ] && echo "116" || echo "120") |
| 447 | bw_str=$([ "${ch}" -le "118" ] && echo "HT40+" || echo "HT40-") |
| 448 | elif [ ${ch} -lt "132" ]; then |
| 449 | ch=$([ "${ch}" -lt "128" ] && echo "124" || echo "128") |
| 450 | bw_str=$([ "${ch}" -le "126" ] && echo "HT40+" || echo "HT40-") |
| 451 | elif [ ${ch} -lt "140" ]; then |
| 452 | ch=$([ "${ch}" -lt "136" ] && echo "132" || echo "136") |
| 453 | bw_str=$([ "${ch}" -le "134" ] && echo "HT40+" || echo "HT40-") |
| 454 | elif [ ${ch} -lt "149" ]; then |
| 455 | ch=$([ "${ch}" -lt "144" ] && echo "140" || echo "144") |
| 456 | bw_str=$([ "${ch}" -le "142" ] && echo "HT40+" || echo "HT40-") |
| 457 | elif [ ${ch} -lt "157" ]; then |
| 458 | ch=$([ "${ch}" -lt "153" ] && echo "149" || echo "153") |
| 459 | bw_str=$([ "${ch}" -le "151" ] && echo "HT40+" || echo "HT40-") |
| 460 | elif [ ${ch} -lt "165" ]; then |
| 461 | ch=$([ "${ch}" -lt "161" ] && echo "157" || echo "161") |
| 462 | bw_str=$([ "${ch}" -le "159" ] && echo "HT40+" || echo "HT40-") |
| 463 | elif [ ${ch} -lt "173" ]; then |
| 464 | ch=$([ "${ch}" -lt "169" ] && echo "165" || echo "169") |
| 465 | bw_str=$([ "${ch}" -le "167" ] && echo "HT40+" || echo "HT40-") |
| 466 | elif [ ${ch} -lt "181" ]; then |
| 467 | ch=$([ "${ch}" -lt "177" ] && echo "173" || echo "177") |
| 468 | bw_str=$([ "${ch}" -le "175" ] && echo "HT40+" || echo "HT40-") |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 469 | fi |
| 470 | ;; |
| 471 | "0") |
| 472 | local bw_str="HT20" |
| 473 | ;; |
| 474 | esac |
developer | eebce5c | 2022-08-26 19:05:56 +0800 | [diff] [blame] | 475 | local base_freq=5180 |
| 476 | local base_chan=36 |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 477 | else |
developer | eebce5c | 2022-08-26 19:05:56 +0800 | [diff] [blame] | 478 | case ${bw} in |
| 479 | "5") |
| 480 | bw_str="160MHz" |
| 481 | if [ ${ch} -lt "33" ]; then |
| 482 | ch="1" |
| 483 | elif [ ${ch} -lt "65" ]; then |
| 484 | ch="33" |
| 485 | elif [ ${ch} -lt "97" ]; then |
| 486 | ch="65" |
| 487 | elif [ ${ch} -lt "129" ]; then |
| 488 | ch="97" |
| 489 | elif [ ${ch} -lt "161" ]; then |
| 490 | ch="129" |
| 491 | elif [ ${ch} -lt "193" ]; then |
| 492 | ch="161" |
| 493 | elif [ ${ch} -lt "225" ]; then |
| 494 | ch="193" |
| 495 | fi |
| 496 | ;; |
| 497 | "2") |
| 498 | bw_str="80MHz" |
| 499 | if [ ${ch} -lt "17" ]; then |
| 500 | ch="1" |
| 501 | elif [ ${ch} -lt "33" ]; then |
| 502 | ch="17" |
| 503 | elif [ ${ch} -lt "49" ]; then |
| 504 | ch="33" |
| 505 | elif [ ${ch} -lt "65" ]; then |
| 506 | ch="49" |
| 507 | elif [ ${ch} -lt "81" ]; then |
| 508 | ch="65" |
| 509 | elif [ ${ch} -lt "97" ]; then |
| 510 | ch="81" |
| 511 | elif [ ${ch} -lt "113" ]; then |
| 512 | ch="97" |
| 513 | elif [ ${ch} -lt "129" ]; then |
| 514 | ch="113" |
| 515 | elif [ ${ch} -lt "145" ]; then |
| 516 | ch="129" |
| 517 | elif [ ${ch} -lt "161" ]; then |
| 518 | ch="145" |
| 519 | elif [ ${ch} -lt "177" ]; then |
| 520 | ch="161" |
| 521 | elif [ ${ch} -lt "193" ]; then |
| 522 | ch="177" |
| 523 | elif [ ${ch} -lt "209" ]; then |
| 524 | ch="193" |
| 525 | elif [ ${ch} -lt "225" ]; then |
| 526 | ch="209" |
| 527 | fi |
| 528 | ;; |
| 529 | "1") |
| 530 | if [ ${ch} -lt "9" ]; then |
| 531 | ch=$([ "${ch}" -lt "5" ] && echo "1" || echo "5") |
| 532 | bw_str=$([ "${ch}" -le "3" ] && echo "HT40+" || echo "HT40-") |
| 533 | elif [ ${ch} -lt "17" ]; then |
| 534 | ch=$([ "${ch}" -lt "13" ] && echo "9" || echo "13") |
| 535 | bw_str=$([ "${ch}" -le "11" ] && echo "HT40+" || echo "HT40-") |
| 536 | elif [ ${ch} -lt "25" ]; then |
| 537 | ch=$([ "${ch}" -lt "21" ] && echo "17" || echo "21") |
| 538 | bw_str=$([ "${ch}" -le "19" ] && echo "HT40+" || echo "HT40-") |
| 539 | elif [ ${ch} -lt "33" ]; then |
| 540 | ch=$([ "${ch}" -lt "29" ] && echo "25" || echo "29") |
| 541 | bw_str=$([ "${ch}" -le "27" ] && echo "HT40+" || echo "HT40-") |
| 542 | elif [ ${ch} -lt "33" ]; then |
| 543 | ch=$([ "${ch}" -lt "29" ] && echo "25" || echo "29") |
| 544 | bw_str=$([ "${ch}" -le "27" ] && echo "HT40+" || echo "HT40-") |
| 545 | elif [ ${ch} -lt "41" ]; then |
| 546 | ch=$([ "${ch}" -lt "37" ] && echo "33" || echo "37") |
| 547 | bw_str=$([ "${ch}" -le "35" ] && echo "HT40+" || echo "HT40-") |
| 548 | elif [ ${ch} -lt "49" ]; then |
| 549 | ch=$([ "${ch}" -lt "45" ] && echo "41" || echo "45") |
| 550 | bw_str=$([ "${ch}" -le "43" ] && echo "HT40+" || echo "HT40-") |
| 551 | elif [ ${ch} -lt "57" ]; then |
| 552 | ch=$([ "${ch}" -lt "53" ] && echo "49" || echo "53") |
| 553 | bw_str=$([ "${ch}" -le "51" ] && echo "HT40+" || echo "HT40-") |
| 554 | elif [ ${ch} -lt "65" ]; then |
| 555 | ch=$([ "${ch}" -lt "61" ] && echo "57" || echo "61") |
| 556 | bw_str=$([ "${ch}" -le "59" ] && echo "HT40+" || echo "HT40-") |
| 557 | elif [ ${ch} -lt "73" ]; then |
| 558 | ch=$([ "${ch}" -lt "69" ] && echo "65" || echo "69") |
| 559 | bw_str=$([ "${ch}" -le "67" ] && echo "HT40+" || echo "HT40-") |
| 560 | elif [ ${ch} -lt "81" ]; then |
| 561 | ch=$([ "${ch}" -lt "77" ] && echo "73" || echo "77") |
| 562 | bw_str=$([ "${ch}" -le "75" ] && echo "HT40+" || echo "HT40-") |
| 563 | elif [ ${ch} -lt "89" ]; then |
| 564 | ch=$([ "${ch}" -lt "85" ] && echo "81" || echo "85") |
| 565 | bw_str=$([ "${ch}" -le "83" ] && echo "HT40+" || echo "HT40-") |
| 566 | elif [ ${ch} -lt "97" ]; then |
| 567 | ch=$([ "${ch}" -lt "93" ] && echo "89" || echo "93") |
| 568 | bw_str=$([ "${ch}" -le "91" ] && echo "HT40+" || echo "HT40-") |
| 569 | elif [ ${ch} -lt "105" ]; then |
| 570 | ch=$([ "${ch}" -lt "101" ] && echo "97" || echo "101") |
| 571 | bw_str=$([ "${ch}" -le "99" ] && echo "HT40+" || echo "HT40-") |
| 572 | elif [ ${ch} -lt "113" ]; then |
| 573 | ch=$([ "${ch}" -lt "109" ] && echo "105" || echo "109") |
| 574 | bw_str=$([ "${ch}" -le "107" ] && echo "HT40+" || echo "HT40-") |
| 575 | elif [ ${ch} -lt "121" ]; then |
| 576 | ch=$([ "${ch}" -lt "117" ] && echo "113" || echo "117") |
| 577 | bw_str=$([ "${ch}" -le "115" ] && echo "HT40+" || echo "HT40-") |
| 578 | elif [ ${ch} -lt "129" ]; then |
| 579 | ch=$([ "${ch}" -lt "125" ] && echo "121" || echo "125") |
| 580 | bw_str=$([ "${ch}" -le "123" ] && echo "HT40+" || echo "HT40-") |
| 581 | elif [ ${ch} -lt "137" ]; then |
| 582 | ch=$([ "${ch}" -lt "133" ] && echo "129" || echo "133") |
| 583 | bw_str=$([ "${ch}" -le "131" ] && echo "HT40+" || echo "HT40-") |
| 584 | elif [ ${ch} -lt "145" ]; then |
| 585 | ch=$([ "${ch}" -lt "141" ] && echo "137" || echo "141") |
| 586 | bw_str=$([ "${ch}" -le "139" ] && echo "HT40+" || echo "HT40-") |
| 587 | elif [ ${ch} -lt "153" ]; then |
| 588 | ch=$([ "${ch}" -lt "149" ] && echo "145" || echo "149") |
| 589 | bw_str=$([ "${ch}" -le "147" ] && echo "HT40+" || echo "HT40-") |
| 590 | elif [ ${ch} -lt "161" ]; then |
| 591 | ch=$([ "${ch}" -lt "157" ] && echo "153" || echo "157") |
| 592 | bw_str=$([ "${ch}" -le "155" ] && echo "HT40+" || echo "HT40-") |
| 593 | elif [ ${ch} -lt "169" ]; then |
| 594 | ch=$([ "${ch}" -lt "165" ] && echo "161" || echo "165") |
| 595 | bw_str=$([ "${ch}" -le "163" ] && echo "HT40+" || echo "HT40-") |
| 596 | elif [ ${ch} -lt "177" ]; then |
| 597 | ch=$([ "${ch}" -lt "173" ] && echo "169" || echo "173") |
| 598 | bw_str=$([ "${ch}" -le "171" ] && echo "HT40+" || echo "HT40-") |
| 599 | elif [ ${ch} -lt "185" ]; then |
| 600 | ch=$([ "${ch}" -lt "181" ] && echo "177" || echo "181") |
| 601 | bw_str=$([ "${ch}" -le "179" ] && echo "HT40+" || echo "HT40-") |
| 602 | elif [ ${ch} -lt "193" ]; then |
| 603 | ch=$([ "${ch}" -lt "189" ] && echo "185" || echo "189") |
| 604 | bw_str=$([ "${ch}" -le "187" ] && echo "HT40+" || echo "HT40-") |
| 605 | elif [ ${ch} -lt "201" ]; then |
| 606 | ch=$([ "${ch}" -lt "197" ] && echo "193" || echo "197") |
| 607 | bw_str=$([ "${ch}" -le "195" ] && echo "HT40+" || echo "HT40-") |
| 608 | elif [ ${ch} -lt "209" ]; then |
| 609 | ch=$([ "${ch}" -lt "205" ] && echo "201" || echo "205") |
| 610 | bw_str=$([ "${ch}" -le "203" ] && echo "HT40+" || echo "HT40-") |
| 611 | elif [ ${ch} -lt "217" ]; then |
| 612 | ch=$([ "${ch}" -lt "213" ] && echo "209" || echo "213") |
| 613 | bw_str=$([ "${ch}" -le "211" ] && echo "HT40+" || echo "HT40-") |
| 614 | elif [ ${ch} -lt "225" ]; then |
| 615 | ch=$([ "${ch}" -lt "221" ] && echo "217" || echo "221") |
| 616 | bw_str=$([ "${ch}" -le "219" ] && echo "HT40+" || echo "HT40-") |
| 617 | elif [ ${ch} -lt "233" ]; then |
| 618 | ch=$([ "${ch}" -lt "229" ] && echo "225" || echo "229") |
| 619 | bw_str=$([ "${ch}" -le "227" ] && echo "HT40+" || echo "HT40-") |
| 620 | fi |
| 621 | ;; |
| 622 | "0") |
| 623 | local bw_str="HT20" |
| 624 | ;; |
| 625 | esac |
| 626 | local base_freq=5955 |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 627 | fi |
| 628 | |
developer | eebce5c | 2022-08-26 19:05:56 +0800 | [diff] [blame] | 629 | local control_freq=$(((ch - base_chan) * 5 + base_freq)) |
| 630 | do_cmd "iw dev mon${phy_idx} set freq ${control_freq} ${bw_str}" |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 631 | } |
| 632 | |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 633 | function convert_rxstat { |
| 634 | local res=$(do_cmd "mt76-test ${interface} dump stats") |
| 635 | local mdrdy=$(echo "${res}" | grep "rx_packets" | cut -d "=" -f 2) |
| 636 | local fcs_error=$(echo "${res}" | grep "rx_fcs_error" | cut -d "=" -f 2) |
| 637 | local rcpi=$(echo "${res}" | grep "last_rcpi" | cut -d "=" -f 2 | sed 's/,/ /g') |
| 638 | local ib_rssi=$(echo "${res}" | grep "last_ib_rssi" | cut -d "=" -f 2 | sed 's/,/ /g') |
| 639 | local wb_rssi=$(echo "${res}" | grep "last_wb_rssi" | cut -d "=" -f 2 | sed 's/,/ /g') |
| 640 | local rx_ok=$(expr ${mdrdy} - ${fcs_error}) |
| 641 | |
developer | 461cb54 | 2022-04-29 18:17:44 +0800 | [diff] [blame] | 642 | write_dmesg "rcpi: ${rcpi}" |
| 643 | write_dmesg "fagc rssi ib: ${ib_rssi}" |
| 644 | write_dmesg "fagc rssi wb: ${wb_rssi}" |
| 645 | write_dmesg "all_mac_rx_mdrdy_cnt: ${mdrdy}" |
| 646 | write_dmesg "all_mac_rx_fcs_err_cnt: ${fcs_error}" |
developer | 9b7cdad | 2022-03-10 14:24:55 +0800 | [diff] [blame] | 647 | write_dmesg "all_mac_rx_ok_cnt : ${rx_ok}" |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 648 | } |
| 649 | |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 650 | function set_mac_addr { |
developer | 679a6aa | 2022-09-07 09:52:41 +0800 | [diff] [blame] | 651 | record_config ${cmd} ${param} ${iwpriv_file} |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 652 | |
developer | 679a6aa | 2022-09-07 09:52:41 +0800 | [diff] [blame] | 653 | local addr1=$(get_config "ATEDA" ${iwpriv_file}) |
| 654 | local addr2=$(get_config "ATESA" ${iwpriv_file}) |
| 655 | local addr3=$(get_config "ATEBSSID" ${iwpriv_file}) |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 656 | |
| 657 | if [ -z "${addr1}" ]; then |
| 658 | addr1="00:11:22:33:44:55" |
| 659 | fi |
| 660 | if [ -z "${addr2}" ]; then |
| 661 | addr2="00:11:22:33:44:55" |
| 662 | fi |
| 663 | if [ -z "${addr3}" ]; then |
| 664 | addr3="00:11:22:33:44:55" |
| 665 | fi |
| 666 | |
| 667 | do_cmd "mt76-test phy${phy_idx} set mac_addrs=${addr1},${addr2},${addr3}" |
| 668 | } |
| 669 | |
developer | f9843e2 | 2022-09-13 10:57:15 +0800 | [diff] [blame] | 670 | function convert_ibf { |
| 671 | local cmd=$1 |
| 672 | local param=$2 |
| 673 | local new_cmd="" |
| 674 | local new_param=$(echo ${param} | sed s/":"/","/g) |
| 675 | |
| 676 | case ${cmd} in |
| 677 | "ATETxBfInit") |
| 678 | new_cmd="init" |
developer | 1346ce5 | 2022-12-15 21:36:14 +0800 | [diff] [blame] | 679 | new_param="1" |
| 680 | do_cmd "mt76-test phy${phy_idx} set state=idle" |
| 681 | ;; |
| 682 | "ATETxBfGdInit") |
| 683 | new_cmd="golden_init" |
| 684 | new_param="1" |
developer | f9843e2 | 2022-09-13 10:57:15 +0800 | [diff] [blame] | 685 | do_cmd "mt76-test phy${phy_idx} set state=idle" |
| 686 | ;; |
| 687 | "ATEIBFPhaseComp") |
| 688 | new_cmd="phase_comp" |
developer | 1346ce5 | 2022-12-15 21:36:14 +0800 | [diff] [blame] | 689 | new_param="${new_param}" |
developer | f9843e2 | 2022-09-13 10:57:15 +0800 | [diff] [blame] | 690 | ;; |
| 691 | "ATEEBfProfileConfig") |
| 692 | new_cmd="ebf_prof_update" |
| 693 | ;; |
| 694 | "ATEIBfProfileConfig") |
| 695 | new_cmd="ibf_prof_update" |
| 696 | ;; |
| 697 | "ATEIBfInstCal") |
| 698 | new_cmd="phase_cal" |
| 699 | ;; |
| 700 | "ATEIBfGdCal") |
| 701 | new_cmd="phase_cal" |
| 702 | new_param="${new_param},00" |
| 703 | ;; |
| 704 | "TxBfTxApply") |
| 705 | new_cmd="apply_tx" |
| 706 | ;; |
| 707 | "ATETxPacketWithBf") |
| 708 | local bf_on=${new_param:0:2} |
| 709 | local aid="01" |
| 710 | local wlan_idx=${new_param:3:2} |
| 711 | local update="00" |
| 712 | local tx_len=${new_param:6} |
| 713 | |
| 714 | new_cmd="tx_prep" |
| 715 | new_param="${bf_on},${aid},${wlan_idx},${update}" |
| 716 | if [ "${tx_len}" = "00" ]; then |
| 717 | new_param="${new_param} aid=1 tx_count=10000000 tx_length=1024" |
| 718 | else |
| 719 | new_param="${new_param} aid=1 tx_count=${tx_len} tx_length=1024" |
| 720 | fi |
| 721 | do_cmd "mt76-test phy${phy_idx} set state=idle" |
| 722 | ;; |
| 723 | "TxBfProfileData20MAllWrite") |
| 724 | new_cmd="prof_update_all" |
| 725 | ;; |
| 726 | "ATEIBFPhaseE2pUpdate") |
| 727 | new_cmd="e2p_update" |
| 728 | ;; |
developer | 1346ce5 | 2022-12-15 21:36:14 +0800 | [diff] [blame] | 729 | "ATEIBFPhaseVerify") |
| 730 | local group=${new_param:0:2} |
| 731 | local group_l_m_h=${new_param:3:2} |
| 732 | local band_idx=${new_param:6:2} |
| 733 | local phase_cal_type=${new_param:9:2} |
| 734 | local LNA_gain_level=${new_param:12:2} |
| 735 | local read_from_e2p=${new_param:15:2} |
| 736 | |
| 737 | do_cmd "mt76-test phy${phy_idx} set txbf_act=phase_comp txbf_param=1,${band_idx},${group},${read_from_e2p},0" |
| 738 | new_cmd="phase_cal" |
| 739 | new_param="${group},${group_l_m_h},${band_idx},${phase_cal_type},${LNA_gain_level}" |
| 740 | ;; |
| 741 | "TxBfProfileTagRead") |
| 742 | new_cmd="pfmu_tag_read" |
| 743 | ;; |
| 744 | "TxBfProfileTagWrite") |
| 745 | new_cmd="pfmu_tag_write" |
| 746 | ;; |
| 747 | "TxBfProfileTagInValid") |
| 748 | new_cmd="set_invalid_prof" |
| 749 | ;; |
| 750 | "StaRecBfRead") |
| 751 | new_cmd="sta_rec_read" |
| 752 | ;; |
| 753 | "TriggerSounding") |
| 754 | new_cmd="trigger_sounding" |
| 755 | ;; |
| 756 | "StopSounding") |
| 757 | new_cmd="stop_sounding" |
| 758 | new_param="0" |
| 759 | ;; |
| 760 | "ATEConTxETxBfGdProc") |
| 761 | local tx_rate_mode=$(convert_tx_mode ${new_param:0:2}) |
| 762 | local tx_rate_idx=${new_param:3:2} |
| 763 | local bw=$(echo ${new_param:6:2} | sed 's/^0//') |
| 764 | local channel=${new_param:9:3} |
| 765 | local channel2=${new_param:13:3} |
| 766 | local band=${new_param:17} |
| 767 | |
| 768 | new_cmd="ebf_golden_init" |
| 769 | do_ate_work "ATESTART" |
| 770 | do_cmd "mt76-test phy${phy_idx} set state=idle" |
| 771 | record_config "ATETXBW" ${bw} ${iwpriv_file} |
| 772 | convert_channel "${channel}:${band}" |
| 773 | if [ "${bw}" = "5" ]; then |
| 774 | new_param="1,1" |
| 775 | else |
| 776 | new_param="1,0" |
| 777 | fi |
| 778 | do_cmd "mt76-test phy${phy_idx} set tx_rate_mode=${tx_rate_mode} tx_rate_idx=${tx_rate_idx} tx_rate_sgi=0" |
| 779 | ;; |
| 780 | "ATEConTxETxBfInitProc") |
| 781 | local tx_rate_mode=$(convert_tx_mode ${new_param:0:2}) |
| 782 | local tx_rate_idx=${new_param:3:2} |
| 783 | local bw=$(echo ${new_param:6:2} | sed 's/^0//') |
| 784 | local tx_rate_nss=${new_param:9:2} |
| 785 | local tx_stream=${new_param:12:2} |
| 786 | local tx_power=${new_param:15:2} |
| 787 | local channel=${new_param:18:3} |
| 788 | local channel2=${new_param:22:3} |
| 789 | local band=${new_param:26:1} |
| 790 | local tx_length=${new_param:28:5} |
| 791 | |
| 792 | new_cmd="ebf_init" |
| 793 | do_ate_work "ATESTART" |
| 794 | do_cmd "mt76-test phy${phy_idx} set state=idle" |
| 795 | record_config "ATETXBW" ${bw} ${iwpriv_file} |
| 796 | convert_channel "${channel}:${band}" |
| 797 | new_param="1" |
| 798 | do_cmd "mt76-test phy${phy_idx} set tx_rate_mode=${tx_rate_mode} tx_rate_idx=${tx_rate_idx} tx_rate_nss=${tx_rate_nss} tx_rate_sgi=0 tx_rate_ldpc=1 tx_power=${tx_power},0,0,0 tx_count=10000000 tx_length=${tx_length} tx_ipg=4" |
| 799 | ;; |
developer | f9843e2 | 2022-09-13 10:57:15 +0800 | [diff] [blame] | 800 | *) |
| 801 | esac |
| 802 | |
| 803 | do_cmd "mt76-test phy${phy_idx} set txbf_act=${new_cmd} txbf_param=${new_param}" |
| 804 | |
| 805 | if [ "${cmd}" = "ATETxPacketWithBf" ]; then |
| 806 | do_cmd "mt76-test phy${phy_idx} set state=tx_frames" |
developer | 1346ce5 | 2022-12-15 21:36:14 +0800 | [diff] [blame] | 807 | elif [ "${cmd}" = "ATEConTxETxBfInitProc" ]; then |
| 808 | do_cmd "mt76-test phy${phy_idx} set aid=1" |
| 809 | do_cmd "mt76-test phy${phy_idx} set txbf_act=stop_sounding txbf_param=1" |
| 810 | do_cmd "mt76-test phy${phy_idx} set txbf_act=update_ch txbf_param=1" |
| 811 | do_cmd "mt76-test phy${phy_idx} set txbf_act=ebf_prof_update txbf_param=0,0,0" |
| 812 | do_cmd "mt76-test phy${phy_idx} set txbf_act=apply_tx txbf_param=1,1,0,0,0" |
| 813 | do_cmd "mt76-test phy${phy_idx} set txbf_act=pfmu_tag_read txbf_param=0,1" |
| 814 | do_cmd "mt76-test phy${phy_idx} set txbf_act=sta_rec_read txbf_param=1" |
| 815 | do_cmd "mt76-test phy${phy_idx} set txbf_act=trigger_sounding txbf_param=0,1,0,1,0,0,0" |
| 816 | do_cmd "mt76-test phy${phy_idx} set txbf_act=trigger_sounding txbf_param=2,1,ff,1,0,0,0" |
| 817 | do_cmd "mt76-test phy${phy_idx} set state=rx_frames" |
| 818 | elif [ "${cmd}" = "ATEConTxETxBfGdProc" ]; then |
| 819 | do_cmd "mt76-test phy${phy_idx} set aid=1" |
| 820 | do_cmd "mt76-test phy${phy_idx} set state=rx_frames" |
| 821 | elif [ "${cmd}" = "ATETxBfInit" ]; then |
| 822 | do_cmd "mt76-test phy${phy_idx} set aid=1" |
| 823 | elif [ "${cmd}" = "ATETxBfGdInit" ]; then |
| 824 | do_cmd "mt76-test phy${phy_idx} set aid=1" |
developer | f9843e2 | 2022-09-13 10:57:15 +0800 | [diff] [blame] | 825 | fi |
| 826 | } |
| 827 | |
developer | 887da63 | 2022-10-28 09:35:38 +0800 | [diff] [blame] | 828 | function convert_dfs { |
| 829 | local cmd=$1 |
| 830 | local param=$2 |
| 831 | |
| 832 | case ${cmd} in |
| 833 | "DfsRxCtrl") |
| 834 | local offchan_ch="$(echo $param | cut -d ':' -f1)" |
| 835 | local offchan_bw="$(echo $param | cut -d ':' -f2)" |
| 836 | |
| 837 | if [ "$offchan_bw" = "0" ]; then |
| 838 | offchan_bw="20" |
| 839 | elif [ "$offchan_bw" = "1" ]; then |
| 840 | offchan_bw="40" |
| 841 | elif [ "$offchan_bw" = "2" ]; then |
| 842 | offchan_bw="80" |
| 843 | fi |
| 844 | |
| 845 | do_cmd "mt76-test phy${phy_idx} set state=idle" |
| 846 | do_cmd "mt76-test phy${phy_idx} set offchan_ch=${offchan_ch} offchan_bw=${offchan_bw}" |
| 847 | ;; |
| 848 | "DfsRxHist") |
| 849 | local ipi_th="$(echo $param | cut -d ':' -f 1)" |
| 850 | local ipi_period="$(echo $param | cut -d ':' -f 2)" |
| 851 | local ipi_antenna="$(echo $param | cut -d ':' -f 3)" |
| 852 | |
| 853 | if [ -z $ipi_antenna ]; then |
| 854 | do_cmd "mt76-test phy${phy_idx} set ipi_threshold=${ipi_th} ipi_period=${ipi_period}" |
| 855 | else |
| 856 | do_cmd "mt76-test phy${phy_idx} set ipi_threshold=${ipi_th} ipi_period=${ipi_period} ipi_antenna_idx=${ipi_antenna}" |
| 857 | fi |
| 858 | ;; |
| 859 | *) |
| 860 | esac |
| 861 | } |
| 862 | |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 863 | function do_ate_work() { |
| 864 | local ate_cmd=$1 |
| 865 | |
| 866 | case ${ate_cmd} in |
| 867 | "ATESTART") |
| 868 | local if_str=$(ifconfig | grep mon${phy_idx}) |
| 869 | |
| 870 | if [ ! -z "${if_str}" -a "${if_str}" != " " ]; then |
| 871 | echo "ATE already starts." |
| 872 | else |
| 873 | do_cmd "iw phy ${interface} interface add mon${phy_idx} type monitor" |
| 874 | do_cmd "iw dev wlan${phy_idx} del" |
| 875 | do_cmd "ifconfig mon${phy_idx} up" |
developer | 9b7cdad | 2022-03-10 14:24:55 +0800 | [diff] [blame] | 876 | do_cmd "iw reg set VV" |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 877 | fi |
| 878 | ;; |
| 879 | "ATESTOP") |
| 880 | local if_str=$(ifconfig | grep mon${phy_idx}) |
| 881 | |
| 882 | if [ -z "${if_str}" -a "${if_str}" != " " ]; then |
| 883 | echo "ATE does not start." |
| 884 | else |
| 885 | do_cmd "mt76-test ${interface} set state=off" |
| 886 | do_cmd "iw dev mon${phy_idx} del" |
| 887 | do_cmd "iw phy ${interface} interface add wlan${phy_idx} type managed" |
developer | 461cb54 | 2022-04-29 18:17:44 +0800 | [diff] [blame] | 888 | do_cmd "mt76-test ${interface} set aid=0" |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 889 | fi |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 890 | |
developer | f90c9af | 2022-12-28 22:40:23 +0800 | [diff] [blame^] | 891 | if [ ${phy_idx} -lt ${SOC_start_idx} ]; then |
developer | 679a6aa | 2022-09-07 09:52:41 +0800 | [diff] [blame] | 892 | sed -i '/_PCIE=/d' ${iwpriv_file} |
developer | f90c9af | 2022-12-28 22:40:23 +0800 | [diff] [blame^] | 893 | elif [ ${phy_idx} -ge ${SOC_start_idx} ]; then |
| 894 | sed -i '/_SOC=/d' ${iwpriv_file} |
developer | 679a6aa | 2022-09-07 09:52:41 +0800 | [diff] [blame] | 895 | fi |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 896 | ;; |
developer | 461cb54 | 2022-04-29 18:17:44 +0800 | [diff] [blame] | 897 | "TXCOMMIT") |
| 898 | do_cmd "mt76-test ${interface} set aid=1" |
| 899 | ;; |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 900 | "TXFRAME") |
| 901 | do_cmd "mt76-test ${interface} set state=tx_frames" |
| 902 | ;; |
developer | 9b7cdad | 2022-03-10 14:24:55 +0800 | [diff] [blame] | 903 | "TXSTOP"|"RXSTOP") |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 904 | do_cmd "mt76-test ${interface} set state=idle" |
| 905 | ;; |
developer | 461cb54 | 2022-04-29 18:17:44 +0800 | [diff] [blame] | 906 | "TXREVERT") |
| 907 | do_cmd "mt76-test ${interface} set aid=0" |
| 908 | ;; |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 909 | "RXFRAME") |
| 910 | do_cmd "mt76-test ${interface} set state=rx_frames" |
| 911 | ;; |
| 912 | "TXCONT") |
| 913 | do_cmd "mt76-test ${interface} set state=tx_cont" |
| 914 | ;; |
developer | 071927d | 2022-08-31 20:39:29 +0800 | [diff] [blame] | 915 | "GROUPREK") |
| 916 | do_cmd "mt76-test ${interface} set state=group_prek" |
| 917 | do_cmd "atenl -i ${interface} -c \"eeprom precal sync group\"" |
| 918 | ;; |
| 919 | "GROUPREKDump") |
| 920 | do_cmd "mt76-test ${interface} set state=group_prek_dump" |
| 921 | ;; |
| 922 | "GROUPREKClean") |
| 923 | do_cmd "mt76-test ${interface} set state=group_prek_clean" |
| 924 | do_cmd "atenl -i ${interface} -c \"eeprom precal group clean\"" |
| 925 | ;; |
| 926 | "DPD2G") |
| 927 | do_cmd "mt76-test ${interface} set state=dpd_2g" |
| 928 | do_cmd "atenl -i ${interface} -c \"eeprom precal sync dpd 2g\"" |
| 929 | ;; |
| 930 | "DPD5G") |
| 931 | do_cmd "mt76-test ${interface} set state=dpd_5g" |
| 932 | do_cmd "atenl -i ${interface} -c \"eeprom precal sync dpd 5g\"" |
| 933 | ;; |
| 934 | "DPD6G") |
| 935 | do_cmd "mt76-test ${interface} set state=dpd_6g" |
| 936 | do_cmd "atenl -i ${interface} -c \"eeprom precal sync dpd 6g\"" |
| 937 | ;; |
| 938 | "DPDDump") |
| 939 | do_cmd "mt76-test ${interface} set state=dpd_dump" |
| 940 | ;; |
| 941 | "DPDClean") |
| 942 | do_cmd "mt76-test ${interface} set state=dpd_clean" |
| 943 | do_cmd "atenl -i ${interface} -c \"eeprom precal dpd clean\"" |
| 944 | ;; |
developer | 9b7cdad | 2022-03-10 14:24:55 +0800 | [diff] [blame] | 945 | *) |
developer | 9b7cdad | 2022-03-10 14:24:55 +0800 | [diff] [blame] | 946 | print_debug "skip ${ate_cmd}" |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 947 | ;; |
| 948 | esac |
| 949 | } |
| 950 | |
developer | f90c9af | 2022-12-28 22:40:23 +0800 | [diff] [blame^] | 951 | function dump_usage { |
| 952 | echo "Usage:" |
| 953 | echo " mwctl <interface> set csi ctrl=<opt1>,<opt2>,<opt3>,<opt4> (macaddr=<macaddr>)" |
| 954 | echo " mwctl <interface> set csi interval=<interval (us)>" |
| 955 | echo " mwctl <interface> dump csi <packet num> <filename>" |
| 956 | echo " mwctl <interface> set amnt <index>(0x0~0xf) <mac addr>(xx:xx:xx:xx:xx:xx)" |
| 957 | echo " mwctl <interface> dump amnt <index> (0x0~0xf or 0xff)" |
| 958 | echo " mwctl <interface> set ap_rfeatures he_gi=<val>" |
| 959 | echo " mwctl <interface> set ap_rfeatures he_ltf=<val>" |
| 960 | echo " mwctl <interface> set ap_rfeatures trig_type=<enable>,<val> (val: 0-7)" |
| 961 | echo " mwctl <interface> set ap_rfeatures ack_policy=<val> (val: 0-4)" |
| 962 | echo " mwctl <interface> set ap_wireless fixed_mcs=<val>" |
| 963 | echo " mwctl <interface> set ap_wireless ofdma=<val> (0: disable, 1: DL, 2: UL)" |
| 964 | echo " mwctl <interface> set ap_wireless nusers_ofdma=<val>" |
| 965 | echo " mwctl <interface> set ap_wireless ppdu_type=<val> (0: SU, 1: MU, 4: LEGACY)" |
| 966 | echo " mwctl <interface> set ap_wireless add_ba_req_bufsize=<val>" |
| 967 | echo " mwctl <interface> set ap_wireless mimo=<val> (0: DL, 1: UL)" |
| 968 | echo " mwctl <interface> set ap_wireless ampdu=<enable>" |
| 969 | echo " mwctl <interface> set ap_wireless amsdu=<enable>" |
| 970 | echo " mwctl <interface> set ap_wireless cert=<enable>" |
| 971 | echo " mwctl <interface> set hemu onoff=<val> (bitmap- UL MU-MIMO(bit3), DL MU-MIMO(bit2), UL OFDMA(bit1), DL OFDMA(bit0))" |
| 972 | echo " mwctl <interface> dump phy_capa" |
| 973 | } |
| 974 | |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 975 | # main start here |
| 976 | |
developer | f90c9af | 2022-12-28 22:40:23 +0800 | [diff] [blame^] | 977 | if [ -z ${interface} ]; then |
| 978 | dump_usage |
| 979 | exit |
| 980 | elif [[ ${interface} == "ra"* ]]; then |
developer | eebce5c | 2022-08-26 19:05:56 +0800 | [diff] [blame] | 981 | convert_interface $interface |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 982 | fi |
| 983 | |
developer | 679a6aa | 2022-09-07 09:52:41 +0800 | [diff] [blame] | 984 | tmp_work_mode=$(get_config "WORKMODE" ${iwpriv_file}) |
| 985 | |
| 986 | if [ ! -z ${tmp_work_mode} ]; then |
| 987 | work_mode=${tmp_work_mode} |
| 988 | fi |
| 989 | |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 990 | cmd=$(echo ${full_cmd} | sed s/=/' '/g | cut -d " " -f 1) |
| 991 | param=$(echo ${full_cmd} | sed s/=/' '/g | cut -d " " -f 2) |
| 992 | |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 993 | if [ "${cmd_type}" = "set" ]; then |
| 994 | skip=0 |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 995 | case ${cmd} in |
developer | f90c9af | 2022-12-28 22:40:23 +0800 | [diff] [blame^] | 996 | ## In wifi 7 chipset, testmode & vendor command both use mwctl |
| 997 | ## Therefore this wrapper would translate it to either mt76-test or mt76-vendor based on the attribute of the command |
| 998 | ## Translate to mt76-vendor command |
| 999 | "csi"|"amnt"|"ap_rfeatures"|"ap_wireless"|"hemu") |
| 1000 | do_cmd "mt76-vendor $*" |
| 1001 | skip=1 |
| 1002 | ;; |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 1003 | "ATE") |
| 1004 | do_ate_work ${param} |
| 1005 | |
| 1006 | skip=1 |
| 1007 | ;; |
| 1008 | "ATETXCNT"|"ATETXLEN"|"ATETXMCS"|"ATEVHTNSS"|"ATETXLDPC"|"ATETXSTBC"| \ |
| 1009 | "ATEPKTTXTIME"|"ATEIPG"|"ATEDUTYCYCLE"|"ATETXFREQOFFSET") |
| 1010 | cmd_new=$(simple_convert ${cmd}) |
developer | 679a6aa | 2022-09-07 09:52:41 +0800 | [diff] [blame] | 1011 | if [ "${param_new}" = "undefined" ]; then |
| 1012 | echo "unknown cmd: ${cmd}" |
| 1013 | exit |
| 1014 | fi |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 1015 | param_new=${param} |
developer | 1346ce5 | 2022-12-15 21:36:14 +0800 | [diff] [blame] | 1016 | if [ "${cmd}" = "ATETXCNT" ] && [ "${param}" = "0" ]; then |
| 1017 | param_new="10000000" |
| 1018 | fi |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 1019 | ;; |
| 1020 | "ATETXANT"|"ATERXANT") |
| 1021 | cmd_new="tx_antenna" |
| 1022 | param_new=${param} |
| 1023 | ;; |
| 1024 | "ATETXGI") |
developer | 679a6aa | 2022-09-07 09:52:41 +0800 | [diff] [blame] | 1025 | tx_mode=$(convert_tx_mode $(get_config "ATETXMODE" ${iwpriv_file})) |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 1026 | convert_gi ${tx_mode} ${param} |
| 1027 | skip=1 |
| 1028 | ;; |
| 1029 | "ATETXMODE") |
| 1030 | cmd_new="tx_rate_mode" |
| 1031 | param_new=$(convert_tx_mode ${param}) |
developer | 679a6aa | 2022-09-07 09:52:41 +0800 | [diff] [blame] | 1032 | if [ "${param_new}" = "undefined" ]; then |
| 1033 | echo "unknown tx mode" |
| 1034 | echo "0:cck, 1:ofdm, 2:ht, 4:vht, 8:he_su, 9:he_er, 10:he_tb, 11:he_mu" |
| 1035 | exit |
| 1036 | else |
| 1037 | record_config ${cmd} ${param} ${iwpriv_file} |
| 1038 | fi |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 1039 | ;; |
| 1040 | "ATETXPOW0"|"ATETXPOW1"|"ATETXPOW2"|"ATETXPOW3") |
| 1041 | cmd_new="tx_power" |
| 1042 | param_new="${param},0,0,0" |
| 1043 | ;; |
| 1044 | "ATETXBW") |
developer | 679a6aa | 2022-09-07 09:52:41 +0800 | [diff] [blame] | 1045 | record_config ${cmd} ${param} ${iwpriv_file} |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 1046 | skip=1 |
| 1047 | ;; |
| 1048 | "ATECHANNEL") |
| 1049 | convert_channel ${param} |
| 1050 | skip=1 |
| 1051 | ;; |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 1052 | "ATERXSTAT") |
| 1053 | convert_rxstat |
| 1054 | skip=1 |
| 1055 | ;; |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 1056 | "ATECTRLBANDIDX") |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 1057 | change_band_idx ${param} |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 1058 | skip=1 |
| 1059 | ;; |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 1060 | "ATEDA"|"ATESA"|"ATEBSSID") |
| 1061 | set_mac_addr ${cmd} ${param} |
| 1062 | skip=1 |
| 1063 | ;; |
developer | 887da63 | 2022-10-28 09:35:38 +0800 | [diff] [blame] | 1064 | "DfsRxCtrl"|"DfsRxHist") |
| 1065 | convert_dfs ${cmd} ${param} |
| 1066 | skip=1 |
| 1067 | ;; |
developer | 1346ce5 | 2022-12-15 21:36:14 +0800 | [diff] [blame] | 1068 | "ATETxBfInit"|"ATETxBfGdInit"|"ATEIBFPhaseComp"|"ATEEBfProfileConfig"|"ATEIBfProfileConfig"| \ |
| 1069 | "TxBfTxApply"|"ATETxPacketWithBf"|"TxBfProfileData20MAllWrite"|"ATEIBfInstCal"| \ |
| 1070 | "ATEIBfGdCal"|"ATEIBFPhaseE2pUpdate"|"TriggerSounding"|"StopSounding"| \ |
| 1071 | "StaRecBfRead"|"TxBfProfileTagInValid"|"TxBfProfileTagWrite"|"TxBfProfileTagRead"| \ |
| 1072 | "ATEIBFPhaseVerify"|"ATEConTxETxBfGdProc"|"ATEConTxETxBfInitProc") |
developer | f9843e2 | 2022-09-13 10:57:15 +0800 | [diff] [blame] | 1073 | convert_ibf ${cmd} ${param} |
| 1074 | skip=1 |
| 1075 | ;; |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 1076 | "bufferMode") |
| 1077 | if [ "${param}" = "2" ]; then |
developer | 461cb54 | 2022-04-29 18:17:44 +0800 | [diff] [blame] | 1078 | do_cmd "atenl -i ${interface} -c \"eeprom update buffermode\"" |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 1079 | fi |
| 1080 | skip=1 |
| 1081 | ;; |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 1082 | "ResetCounter"|"ATERXSTATRESET") |
| 1083 | skip=1 |
| 1084 | ;; |
developer | 679a6aa | 2022-09-07 09:52:41 +0800 | [diff] [blame] | 1085 | "WORKMODE") |
| 1086 | record_config "WORKMODE" ${param} ${iwpriv_file} |
| 1087 | echo "Entering ${param} mode in iwpriv" |
| 1088 | skip=1 |
| 1089 | ;; |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 1090 | *) |
developer | 9b7cdad | 2022-03-10 14:24:55 +0800 | [diff] [blame] | 1091 | print_debug "Unknown command to set: ${cmd}" |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 1092 | skip=1 |
| 1093 | esac |
| 1094 | |
| 1095 | if [ "${skip}" != "1" ]; then |
| 1096 | do_cmd "mt76-test ${interface} set ${cmd_new}=${param_new}" |
| 1097 | fi |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 1098 | |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 1099 | elif [ "${cmd_type}" = "show" ]; then |
developer | 1346ce5 | 2022-12-15 21:36:14 +0800 | [diff] [blame] | 1100 | if [ "${cmd}" = "wtbl" ]; then |
| 1101 | wlan_idx=/sys/kernel/debug/ieee80211/phy${phy_idx}/mt76/wlan_idx |
| 1102 | wtbl_info=/sys/kernel/debug/ieee80211/phy${phy_idx}/mt76/wtbl_info |
| 1103 | |
| 1104 | do_cmd "echo ${param} > ${wlan_idx}" |
| 1105 | do_cmd "cat ${wtbl_info}" |
| 1106 | else |
| 1107 | do_cmd "mt76-test ${interface} dump" |
| 1108 | do_cmd "mt76-test ${interface} dump stats" |
| 1109 | fi |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 1110 | |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 1111 | elif [ "${cmd_type}" = "e2p" ]; then |
developer | f90c9af | 2022-12-28 22:40:23 +0800 | [diff] [blame^] | 1112 | # support multiple read write |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 1113 | # eeprom offset write |
| 1114 | if [[ ${full_cmd} == *"="* ]]; then |
developer | f90c9af | 2022-12-28 22:40:23 +0800 | [diff] [blame^] | 1115 | IFS=, |
| 1116 | for tuple in $full_cmd |
| 1117 | do |
| 1118 | cmd=$(echo ${tuple} | sed s/=/' '/g | cut -d " " -f 1) |
| 1119 | param=$(echo ${tuple} | sed s/=/' '/g | cut -d " " -f 2) |
| 1120 | offset=$(printf "0x%s" ${cmd}) |
| 1121 | val=$(printf "0x%s" ${param}) |
| 1122 | tmp=$((${val} & 0xff)) |
| 1123 | tmp=$(printf "0x%x" ${tmp}) |
| 1124 | do_cmd "atenl -i ${interface} -c \"eeprom set ${offset}=${tmp}\"" |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 1125 | |
developer | f90c9af | 2022-12-28 22:40:23 +0800 | [diff] [blame^] | 1126 | offset=$((${offset})) |
| 1127 | offset=$(expr ${offset} + "1") |
| 1128 | offset=$(printf "0x%x" ${offset}) |
| 1129 | tmp=$(((${val} >> 8) & 0xff)) |
| 1130 | tmp=$(printf "0x%x" ${tmp}) |
| 1131 | do_cmd "atenl -i ${interface} -c \"eeprom set ${offset}=${tmp}\"" |
| 1132 | done |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 1133 | else |
developer | f90c9af | 2022-12-28 22:40:23 +0800 | [diff] [blame^] | 1134 | IFS=, |
| 1135 | for tuple in $full_cmd |
| 1136 | do |
| 1137 | cmd=$(echo ${tuple} | sed s/=/' '/g | cut -d " " -f 1) |
| 1138 | param=$(echo ${tuple} | sed s/=/' '/g | cut -d " " -f 2) |
| 1139 | offset=$(printf "0x%s" ${cmd}) |
| 1140 | val=$(printf "0x%s" ${param}) |
| 1141 | v1=$(do_cmd "atenl -i ${interface} -c \"eeprom read ${param}\"") |
| 1142 | 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] | 1143 | |
developer | f90c9af | 2022-12-28 22:40:23 +0800 | [diff] [blame^] | 1144 | tmp=$(printf "0x%s" ${param}) |
| 1145 | tmp=$((${tmp})) |
| 1146 | param2=$(expr ${tmp} + "1") |
| 1147 | param2=$(printf "%x" ${param2}) |
| 1148 | v2=$(do_cmd "atenl -i ${interface} -c \"eeprom read ${param2}\"") |
| 1149 | v2=$(echo "${v2}" | grep "val =" | cut -d '(' -f 2 | grep -o -E '[0-9]+') |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 1150 | |
developer | f90c9af | 2022-12-28 22:40:23 +0800 | [diff] [blame^] | 1151 | param=$(printf "0x%s" ${param}) |
| 1152 | param=$(printf "%04x" ${param}) |
| 1153 | param=$(echo $param | tr 'a-z' 'A-Z') |
| 1154 | printf "%s e2p:\n" ${interface_ori} |
| 1155 | printf "[0x%s]:0x%02x%02x\n" ${param} ${v2} ${v1} |
| 1156 | done |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 1157 | fi |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 1158 | |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 1159 | elif [ "${cmd_type}" = "mac" ]; then |
| 1160 | regidx=/sys/kernel/debug/ieee80211/phy${phy_idx}/mt76/regidx |
| 1161 | regval=/sys/kernel/debug/ieee80211/phy${phy_idx}/mt76/regval |
| 1162 | offset=$(printf "0x%s" ${cmd}) |
| 1163 | val=$(printf "0x%s" ${param}) |
| 1164 | |
| 1165 | echo ${offset} > ${regidx} |
| 1166 | # reg write |
| 1167 | if [[ ${full_cmd} == *"="* ]]; then |
| 1168 | echo ${val} > ${regval} |
developer | a626714 | 2022-01-26 20:50:22 +0800 | [diff] [blame] | 1169 | fi |
developer | 10946c3 | 2022-03-04 18:28:43 +0800 | [diff] [blame] | 1170 | |
developer | 461cb54 | 2022-04-29 18:17:44 +0800 | [diff] [blame] | 1171 | res=$(cat ${regval} | cut -d 'x' -f 2) |
| 1172 | printf "%s mac:[%s]:%s\n" ${interface_ori} ${offset} ${res} |
| 1173 | |
developer | f90c9af | 2022-12-28 22:40:23 +0800 | [diff] [blame^] | 1174 | ## dump command is only for vendor commands |
| 1175 | elif [ "${cmd_type}" = "dump" ]; then |
| 1176 | do_cmd "mt76-vendor $*" |
developer | 3abe1ad | 2022-01-24 11:13:32 +0800 | [diff] [blame] | 1177 | else |
| 1178 | echo "Unknown command" |
| 1179 | fi |