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