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