Author: adrian
Date: Sun Apr  2 20:59:12 2017
New Revision: 316429
URL: https://svnweb.freebsd.org/changeset/base/316429

Log:
  [net80211] refactor the A-MPDU RX window code
  
  The RX window update code is effectively the same in both locations.
  
  Reviewed by:  avos
  Differential Revision:        https://reviews.freebsd.org/D10208

Modified:
  head/sys/net80211/ieee80211_ht.c

Modified: head/sys/net80211/ieee80211_ht.c
==============================================================================
--- head/sys/net80211/ieee80211_ht.c    Sun Apr  2 20:57:59 2017        
(r316428)
+++ head/sys/net80211/ieee80211_ht.c    Sun Apr  2 20:59:12 2017        
(r316429)
@@ -644,6 +644,40 @@ ampdu_dispatch(struct ieee80211_node *ni
        (void) ieee80211_input(ni, m, 0, 0);
 }
 
+static void
+ampdu_rx_moveup(struct ieee80211_rx_ampdu *rap, struct ieee80211_node *ni,
+    int i, int winstart)
+{
+       struct ieee80211vap *vap = ni->ni_vap;
+
+       if (rap->rxa_qframes != 0) {
+               int n = rap->rxa_qframes, j;
+
+               if (winstart != -1) {
+                       /*
+                        * NB: in window-sliding mode, loop assumes i > 0
+                        * and/or rxa_m[0] is NULL
+                        */
+                       KASSERT(rap->rxa_m[0] == NULL,
+                           ("%s: BA window slot 0 occupied", __func__));
+               }
+               for (j = i+1; j < rap->rxa_wnd; j++) {
+                       if (rap->rxa_m[j] != NULL) {
+                               rap->rxa_m[j-i] = rap->rxa_m[j];
+                               rap->rxa_m[j] = NULL;
+                               if (--n == 0)
+                                       break;
+                       }
+               }
+               KASSERT(n == 0, ("%s: lost %d frames, qframes %d off %d "
+                   "BA win <%d:%d> winstart %d",
+                   __func__, n, rap->rxa_qframes, i, rap->rxa_start,
+                   IEEE80211_SEQ_ADD(rap->rxa_start, rap->rxa_wnd-1),
+                   winstart));
+               vap->iv_stats.is_ampdu_rx_copy += rap->rxa_qframes;
+       }
+}
+
 /*
  * Dispatch as many frames as possible from the re-order queue.
  * Frames will always be "at the front"; we process all frames
@@ -674,19 +708,8 @@ ampdu_rx_dispatch(struct ieee80211_rx_am
         * If frames remain, copy the mbuf pointers down so
         * they correspond to the offsets in the new window.
         */
-       if (rap->rxa_qframes != 0) {
-               int n = rap->rxa_qframes, j;
-               for (j = i+1; j < rap->rxa_wnd; j++) {
-                       if (rap->rxa_m[j] != NULL) {
-                               rap->rxa_m[j-i] = rap->rxa_m[j];
-                               rap->rxa_m[j] = NULL;
-                               if (--n == 0)
-                                       break;
-                       }
-               }
-               KASSERT(n == 0, ("lost %d frames", n));
-               vap->iv_stats.is_ampdu_rx_copy += rap->rxa_qframes;
-       }
+       ampdu_rx_moveup(rap, ni, i, -1);
+
        /*
         * Adjust the start of the BA window to
         * reflect the frames just dispatched.
@@ -761,27 +784,8 @@ ampdu_rx_flush_upto(struct ieee80211_nod
         * If frames remain, copy the mbuf pointers down so
         * they correspond to the offsets in the new window.
         */
-       if (rap->rxa_qframes != 0) {
-               int n = rap->rxa_qframes, j;
+       ampdu_rx_moveup(rap, ni, i, winstart);
 
-               /* NB: this loop assumes i > 0 and/or rxa_m[0] is NULL */
-               KASSERT(rap->rxa_m[0] == NULL,
-                   ("%s: BA window slot 0 occupied", __func__));
-               for (j = i+1; j < rap->rxa_wnd; j++) {
-                       if (rap->rxa_m[j] != NULL) {
-                               rap->rxa_m[j-i] = rap->rxa_m[j];
-                               rap->rxa_m[j] = NULL;
-                               if (--n == 0)
-                                       break;
-                       }
-               }
-               KASSERT(n == 0, ("%s: lost %d frames, qframes %d off %d "
-                   "BA win <%d:%d> winstart %d",
-                   __func__, n, rap->rxa_qframes, i, rap->rxa_start,
-                   IEEE80211_SEQ_ADD(rap->rxa_start, rap->rxa_wnd-1),
-                   winstart));
-               vap->iv_stats.is_ampdu_rx_copy += rap->rxa_qframes;
-       }
        /*
         * Move the start of the BA window; we use the
         * sequence number of the last MSDU that was
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to