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