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