Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 15 Feb 2015 21:15:10 +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: r278816 - head/sys/contrib/dev/ath/ath_hal/ar9300
Message-ID:  <201502152115.t1FLFABV060308@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: adrian
Date: Sun Feb 15 21:15:09 2015
New Revision: 278816
URL: https://svnweb.freebsd.org/changeset/base/278816

Log:
  Add initial support to the AR9300 HAL to support FreeBSD's intmit API.
  
  I don't like having it in this function; I may migrate it to ar9300_freebsd.c
  at some point to keep the HAL code pollution down.
  
  This allows ANI to be disabled via a sysctl.
  
  Tested:
  
  * AR9331, STA/TDMA modes

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

Modified: head/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_misc.c
==============================================================================
--- head/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_misc.c	Sun Feb 15 21:11:07 2015	(r278815)
+++ head/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_misc.c	Sun Feb 15 21:15:09 2015	(r278816)
@@ -683,6 +683,7 @@ ar9300_get_capability(struct ath_hal *ah
 {
     struct ath_hal_9300 *ahp = AH9300(ah);
     const HAL_CAPABILITIES *p_cap = &AH_PRIVATE(ah)->ah_caps;
+    struct ar9300_ani_state *ani;
 
     switch (type) {
     case HAL_CAP_CIPHER:            /* cipher handled in hardware */
@@ -911,6 +912,34 @@ ar9300_get_capability(struct ath_hal *ah
             return HAL_ENOTSUPP;
         }
 #endif
+
+    /* FreeBSD ANI */
+    case HAL_CAP_INTMIT:            /* interference mitigation */
+            switch (capability) {
+            case HAL_CAP_INTMIT_PRESENT:            /* hardware capability */
+                    return HAL_OK;
+            case HAL_CAP_INTMIT_ENABLE:
+                    return (ahp->ah_proc_phy_err & HAL_PROCESS_ANI) ?
+                            HAL_OK : HAL_ENXIO;
+            case HAL_CAP_INTMIT_NOISE_IMMUNITY_LEVEL:
+            case HAL_CAP_INTMIT_OFDM_WEAK_SIGNAL_LEVEL:
+//            case HAL_CAP_INTMIT_CCK_WEAK_SIGNAL_THR:
+            case HAL_CAP_INTMIT_FIRSTEP_LEVEL:
+            case HAL_CAP_INTMIT_SPUR_IMMUNITY_LEVEL:
+                    ani = ar9300_ani_get_current_state(ah);
+                    if (ani == AH_NULL)
+                            return HAL_ENXIO;
+                    switch (capability) {
+                    /* XXX AR9300 HAL has OFDM/CCK noise immunity level params? */
+                    case 2: *result = ani->ofdm_noise_immunity_level; break;
+                    case 3: *result = !ani->ofdm_weak_sig_detect_off; break;
+ //                   case 4: *result = ani->cck_weak_sig_threshold; break;
+                    case 5: *result = ani->firstep_level; break;
+                    case 6: *result = ani->spur_immunity_level; break;
+                    }
+                    return HAL_OK;
+            }
+            return HAL_EINVAL;
     default:
         return ath_hal_getcapability(ah, type, capability, result);
     }
@@ -986,6 +1015,27 @@ ar9300_set_capability(struct ath_hal *ah
             return AH_TRUE;
         }
         return AH_FALSE;
+
+    /* FreeBSD interrupt mitigation / ANI */
+    case HAL_CAP_INTMIT: {          /* interference mitigation */
+            /* This maps the public ANI commands to the internal ANI commands */
+            /* Private: HAL_ANI_CMD; Public: HAL_CAP_INTMIT_CMD */
+            static const HAL_ANI_CMD cmds[] = {
+                    HAL_ANI_PRESENT,
+                    HAL_ANI_MODE,
+                    HAL_ANI_NOISE_IMMUNITY_LEVEL,
+                    HAL_ANI_OFDM_WEAK_SIGNAL_DETECTION,
+                    HAL_ANI_CCK_WEAK_SIGNAL_THR,
+                    HAL_ANI_FIRSTEP_LEVEL,
+                    HAL_ANI_SPUR_IMMUNITY_LEVEL,
+            };
+#define N(a)    (sizeof(a) / sizeof(a[0]))
+            return capability < N(cmds) ?
+                    ar9300_ani_control(ah, cmds[capability], setting) :
+                    AH_FALSE;
+#undef N
+    }
+
     case HAL_CAP_RXBUFSIZE:         /* set MAC receive buffer size */
         ahp->rx_buf_size = setting & AR_DATABUF_MASK;
         OS_REG_WRITE(ah, AR_DATABUF, ahp->rx_buf_size);



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