Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 6 Mar 2019 08:52:02 +0000 (UTC)
From:      Adrian Chadd <adrian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r344843 - head/sys/contrib/dev/ath/ath_hal/ar9300
Message-ID:  <201903060852.x268q2Iq001613@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: adrian
Date: Wed Mar  6 08:52:02 2019
New Revision: 344843
URL: https://svnweb.freebsd.org/changeset/base/344843

Log:
  [ath_hal_ar9300] Add the missing bits from the previous HAL commit.
  
  Noticed by: 75+ emails telling me I messed up.

Modified:
  head/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_ani.c
  head/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_misc.c

Modified: head/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_ani.c
==============================================================================
--- head/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_ani.c	Wed Mar  6 07:58:19 2019	(r344842)
+++ head/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_ani.c	Wed Mar  6 08:52:02 2019	(r344843)
@@ -462,13 +462,55 @@ ar9300_ani_control(struct ath_hal *ah, HAL_ANI_CMD cmd
     u_int level = param;
     u_int is_on;
 
+    HALDEBUG(ah, HAL_DEBUG_ANI, "%s: cmd=%d, param=%d, chan=%p, funcmask=0x%08x\n",
+      __func__,
+      cmd,
+      param,
+      chan,
+      ahp->ah_ani_function);
+
+
     if (chan == NULL && cmd != HAL_ANI_MODE) {
         HALDEBUG(ah, HAL_DEBUG_UNMASKABLE,
             "%s: ignoring cmd 0x%02x - no channel\n", __func__, cmd);
         return AH_FALSE;
     }
 
-    switch (cmd & ahp->ah_ani_function) {
+    /*
+     * These two control the top-level cck/ofdm immunity levels and will
+     * program the rest of the values.
+     */
+    if (cmd == HAL_ANI_NOISE_IMMUNITY_LEVEL) {
+        if (param > HAL_ANI_OFDM_NUM_LEVEL)
+          return AH_FALSE;
+        ar9300_ani_set_odfm_noise_immunity_level(ah, param);
+        return AH_TRUE;
+    }
+
+    if (cmd == HAL_ANI_CCK_NOISE_IMMUNITY_LEVEL) {
+        if (param > HAL_ANI_CCK_NUM_LEVEL)
+          return AH_FALSE;
+        ar9300_ani_set_cck_noise_immunity_level(ah, param);
+        return AH_TRUE;
+    }
+
+    /*
+     * Check to see if this command is available in the
+     * current operating mode.
+     */
+    if (((1 << cmd) & ahp->ah_ani_function) == 0) {
+        HALDEBUG(ah, HAL_DEBUG_ANI,
+            "%s: early check: invalid cmd 0x%02x (allowed=0x%02x)\n",
+            __func__, cmd, ahp->ah_ani_function);
+        return AH_FALSE;
+    }
+
+    /*
+     * The rest of these program in the requested parameter values
+     * into the PHY.
+     */
+    switch (cmd) {
+
     case HAL_ANI_OFDM_WEAK_SIGNAL_DETECTION: 
         {
             int m1_thresh_low, m2_thresh_low;
@@ -887,13 +929,16 @@ ar9300_ani_reset(struct ath_hal *ah, HAL_BOOL is_scann
     /* only allow a subset of functions in AP mode */
     if (AH_PRIVATE(ah)->ah_opmode == HAL_M_HOSTAP) {
         if (IS_CHAN_2GHZ(ichan)) {
-            ahp->ah_ani_function = (HAL_ANI_SPUR_IMMUNITY_LEVEL |
-                                    HAL_ANI_FIRSTEP_LEVEL |
-                                    HAL_ANI_MRC_CCK);
+            ahp->ah_ani_function = (1 << HAL_ANI_SPUR_IMMUNITY_LEVEL) |
+                                   (1 << HAL_ANI_FIRSTEP_LEVEL) |
+                                   (1 << HAL_ANI_MRC_CCK);
         } else {
             ahp->ah_ani_function = 0;
         }
+    } else {
+      ahp->ah_ani_function = HAL_ANI_ALL;
     }
+
     /* always allow mode (on/off) to be controlled */
     ahp->ah_ani_function |= HAL_ANI_MODE;
 

Modified: head/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_misc.c
==============================================================================
--- head/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_misc.c	Wed Mar  6 07:58:19 2019	(r344842)
+++ head/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_misc.c	Wed Mar  6 08:52:02 2019	(r344843)
@@ -1268,7 +1268,7 @@ ar9300_get_diag_state(struct ath_hal *ah, int request,
         ahp->ext_ani_state.spurImmunityLevel = ani->spur_immunity_level;
         ahp->ext_ani_state.firstepLevel = ani->firstep_level;
         ahp->ext_ani_state.ofdmWeakSigDetectOff = ani->ofdm_weak_sig_detect_off;
-        ahp->ext_ani_state.mrcCckOff = ani->mrc_cck_off;
+        ahp->ext_ani_state.mrcCck = !! ani->mrc_cck_off;
         ahp->ext_ani_state.cckNoiseImmunityLevel = ani->cck_noise_immunity_level;
 
         ahp->ext_ani_state.listenTime = ani->listen_time;
@@ -1287,12 +1287,18 @@ ar9300_get_diag_state(struct ath_hal *ah, int request,
             0 : sizeof(HAL_ANI_STATS);
         return AH_TRUE;
     case HAL_DIAG_ANI_CMD:
+    {
+        HAL_ANI_CMD savefunc = ahp->ah_ani_function;
         if (argsize != 2*sizeof(u_int32_t)) {
             return AH_FALSE;
         }
+        /* temporarly allow all functions so we can override */
+        ahp->ah_ani_function = HAL_ANI_ALL;
         ar9300_ani_control(
             ah, ((const u_int32_t *)args)[0], ((const u_int32_t *)args)[1]);
+        ahp->ah_ani_function = savefunc;
         return AH_TRUE;
+    }
 #if 0
     case HAL_DIAG_TXCONT:
         /*AR9300_CONTTXMODE(ah, (struct ath_desc *)args, argsize );*/



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201903060852.x268q2Iq001613>