[][MAC80211][mt76][Add ZWDFS testmode support]

[Description]
Add ZWDFS testmode support including background chain channel switch
and show IPI histogram command

[Release-log]
N/A

Change-Id: I0acc2c52abd30f77db4a8c22c8516ad69c13fe11
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/6696081
diff --git a/feed/atenl/files/iwpriv.sh b/feed/atenl/files/iwpriv.sh
index 910e314..d42c32b 100755
--- a/feed/atenl/files/iwpriv.sh
+++ b/feed/atenl/files/iwpriv.sh
@@ -20,8 +20,8 @@
             echo "$1"
             ;;
         "DEBUG")
-            eval "$1"
             echo "$1"
+            eval "$1"
             ;;
     esac
 }
@@ -680,6 +680,41 @@
     fi
 }
 
+function convert_dfs {
+    local cmd=$1
+    local param=$2
+
+    case ${cmd} in
+        "DfsRxCtrl")
+            local offchan_ch="$(echo $param | cut -d ':' -f1)"
+            local offchan_bw="$(echo $param | cut -d ':' -f2)"
+
+	    if [ "$offchan_bw" = "0" ]; then
+            offchan_bw="20"
+	    elif [ "$offchan_bw" = "1" ]; then
+            offchan_bw="40"
+	    elif [ "$offchan_bw" = "2" ]; then
+            offchan_bw="80"
+	    fi
+
+	    do_cmd "mt76-test phy${phy_idx} set state=idle"
+	    do_cmd "mt76-test phy${phy_idx} set offchan_ch=${offchan_ch} offchan_bw=${offchan_bw}"
+            ;;
+        "DfsRxHist")
+            local ipi_th="$(echo $param | cut -d ':' -f 1)"
+            local ipi_period="$(echo $param | cut -d ':' -f 2)"
+	    local ipi_antenna="$(echo $param | cut -d ':' -f 3)"
+
+	    if [ -z $ipi_antenna ]; then
+	        do_cmd "mt76-test phy${phy_idx} set ipi_threshold=${ipi_th} ipi_period=${ipi_period}"
+	    else
+		do_cmd "mt76-test phy${phy_idx} set ipi_threshold=${ipi_th} ipi_period=${ipi_period} ipi_antenna_idx=${ipi_antenna}"
+	    fi
+            ;;
+        *)
+    esac
+}
+
 function do_ate_work() {
     local ate_cmd=$1
 
@@ -844,6 +879,10 @@
             set_mac_addr ${cmd} ${param}
             skip=1
             ;;
+        "DfsRxCtrl"|"DfsRxHist")
+            convert_dfs ${cmd} ${param}
+            skip=1
+            ;;
         "ATETxBfInit"|"ATEIBFPhaseComp"|"ATEEBfProfileConfig"|"ATEIBfProfileConfig"| \
         "TxBfTxApply"|"ATETxPacketWithBf"|"TxBfProfileData20MAllWrite"|"ATEIBfInstCal"|\
         "ATEIBfGdCal"|"ATEIBFPhaseE2pUpdate")