From owner-svn-src-user@FreeBSD.ORG Sun Aug 28 03:05:16 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A3C4C1065670; Sun, 28 Aug 2011 03:05:16 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 929F58FC0A; Sun, 28 Aug 2011 03:05:16 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7S35G9J031681; Sun, 28 Aug 2011 03:05:16 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7S35G5Q031676; Sun, 28 Aug 2011 03:05:16 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108280305.p7S35G5Q031676@svn.freebsd.org> From: Adrian Chadd Date: Sun, 28 Aug 2011 03:05:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225224 - user/adrian/if_ath_tx/sys/dev/ath X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Aug 2011 03:05:16 -0000 Author: adrian Date: Sun Aug 28 03:05:16 2011 New Revision: 225224 URL: http://svn.freebsd.org/changeset/base/225224 Log: Migrate back to the locking structure the atheros reference driver and linux ath9k uses - hide the per-TID state behind the associated hardware TXQ. This is less fine grained than what I was doing before, but it results in: * The code being cleaner (ie, there's not a mess of locks everywhere); * The code being closer to what the reference/linux drivers do, making it easier to port code over; * A bunch of state changes become much more predictable - eg, the BAW window updates occur in one bunch rather than interleaved with other packet TX. This isn't yet complete, as there are a few things to fix: * recursive mutexes during ht node cleanup * remove the current txq drain which uses ieee80211_iterate_nodes() which grabs the IEEE80211_NODE_LOCK() and replace it with a similar setup to what Linux/Reference driver does. * Figure out how to properly halt the software TXQ (via ath_raw_xmit() and via ath_start()) during the reset process so frames aren't queued to the software queue whilst things are drained. * Investigate whether a STA which is going away can have traffic queued to its ieee80211_node, which is in the process of being freed or has already been freed. Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath.c user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Sun Aug 28 00:14:40 2011 (r225223) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Sun Aug 28 03:05:16 2011 (r225224) @@ -4322,12 +4322,11 @@ ath_tx_processq(struct ath_softc *sc, st (caddr_t)(uintptr_t) ath_hal_gettxbuf(sc->sc_ah, txq->axq_qnum), txq->axq_link); nacked = 0; + ATH_TXQ_LOCK(txq); for (;;) { txq->axq_intrcnt = 0; /* reset periodic desc intr count */ - ATH_TXQ_LOCK(txq); bf = TAILQ_FIRST(&txq->axq_q); if (bf == NULL) { - ATH_TXQ_UNLOCK(txq); break; } ds0 = &bf->bf_desc[0]; @@ -4340,7 +4339,6 @@ ath_tx_processq(struct ath_softc *sc, st status == HAL_OK); #endif if (status == HAL_EINPROGRESS) { - ATH_TXQ_UNLOCK(txq); break; } ATH_TXQ_REMOVE(txq, bf, bf_list); @@ -4363,7 +4361,6 @@ ath_tx_processq(struct ath_softc *sc, st txq->axq_link = NULL; if (bf->bf_state.bfs_aggr) txq->axq_aggr_depth--; - ATH_TXQ_UNLOCK(txq); ni = bf->bf_node; /* @@ -4435,6 +4432,7 @@ ath_tx_processq(struct ath_softc *sc, st /* Kick the TXQ scheduler */ ath_txq_sched(sc, txq); + ATH_TXQ_UNLOCK(txq); return nacked; } @@ -4555,7 +4553,9 @@ ath_tx_sched_proc(void *arg, int npendin for (i = 0; i < HAL_NUM_TX_QUEUES; i++) { txq = &sc->sc_txq[i]; if (ATH_TXQ_SETUP(sc, i)) { + ATH_TXQ_LOCK(txq); ath_txq_sched(sc, txq); + ATH_TXQ_UNLOCK(txq); } } } @@ -4640,18 +4640,16 @@ ath_tx_draintxq(struct ath_softc *sc, st bf->bf_flags &= ~ATH_BUF_BUSY; ATH_TXBUF_UNLOCK(sc); + ATH_TXQ_LOCK(txq); for (ix = 0;; ix++) { - ATH_TXQ_LOCK(txq); bf = TAILQ_FIRST(&txq->axq_q); if (bf == NULL) { txq->axq_link = NULL; - ATH_TXQ_UNLOCK(txq); break; } ATH_TXQ_REMOVE(txq, bf, bf_list); if (bf->bf_state.bfs_aggr) txq->axq_aggr_depth--; - ATH_TXQ_UNLOCK(txq); #ifdef ATH_DEBUG if (sc->sc_debug & ATH_DEBUG_RESET) { struct ieee80211com *ic = sc->sc_ifp->if_l2com; @@ -4679,6 +4677,7 @@ ath_tx_draintxq(struct ath_softc *sc, st else ath_tx_default_comp(sc, bf, 1); } + ATH_TXQ_UNLOCK(txq); } static void Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Sun Aug 28 00:14:40 2011 (r225223) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Sun Aug 28 03:05:16 2011 (r225224) @@ -1235,8 +1235,7 @@ ath_tx_start(struct ath_softc *sc, struc /* Don't do it whilst pending; the net80211 layer still assigns them */ /* XXX do we need locking here? */ if (is_ampdu_tx) { - struct ath_node *an = ATH_NODE(ni); - ATH_TXQ_LOCK(&an->an_tid[tid]); + ATH_TXQ_LOCK(txq); /* * Always call; this function will * handle making sure that null data frames @@ -1248,7 +1247,7 @@ ath_tx_start(struct ath_softc *sc, struc subtype != IEEE80211_FC0_SUBTYPE_QOS_NULL) { bf->bf_state.bfs_dobaw = 1; } - ATH_TXQ_UNLOCK(&an->an_tid[tid]); + ATH_TXQ_UNLOCK(txq); } /* @@ -1743,8 +1742,9 @@ ath_tx_addto_baw(struct ath_softc *sc, s { int index, cindex; struct ieee80211_tx_ampdu *tap; + struct ath_txq *txq = sc->sc_ac2q[tid->ac]; - ATH_TXQ_LOCK_ASSERT(tid); + ATH_TXQ_LOCK_ASSERT(txq); if (bf->bf_state.bfs_isretried) return; @@ -1792,8 +1792,9 @@ ath_tx_update_baw(struct ath_softc *sc, { int index, cindex; struct ieee80211_tx_ampdu *tap; + struct ath_txq *txq = sc->sc_ac2q[tid->ac]; - ATH_TXQ_LOCK_ASSERT(tid); + ATH_TXQ_LOCK_ASSERT(txq); tap = ath_tx_get_tx_tid(an, tid->tid); index = ATH_BA_INDEX(tap->txa_start, seqno); @@ -1959,11 +1960,8 @@ ath_tx_swq(struct ath_softc *sc, struct bf->bf_state.bfs_addedbaw = 0; /* Queue frame to the tail of the software queue */ - ATH_TXQ_LOCK(atid); - ATH_TXQ_INSERT_TAIL(atid, bf, bf_list); - ATH_TXQ_UNLOCK(atid); - ATH_TXQ_LOCK(txq); + ATH_TXQ_INSERT_TAIL(atid, bf, bf_list); ath_tx_tid_sched(sc, an, tid); ATH_TXQ_UNLOCK(txq); } @@ -2012,9 +2010,6 @@ ath_tx_tid_init(struct ath_softc *sc, st atid->ac = WME_AC_BE; else atid->ac = TID_TO_WME_AC(i); - snprintf(atid->axq_name, 48, "%p %s %d", - an, device_get_nameunit(sc->sc_dev), i); - mtx_init(&atid->axq_lock, atid->axq_name, NULL, MTX_DEF); } } @@ -2028,11 +2023,11 @@ ath_tx_tid_init(struct ath_softc *sc, st static void ath_tx_tid_pause(struct ath_softc *sc, struct ath_tid *tid) { - ATH_TXQ_LOCK(tid); + ATH_TXQ_LOCK(sc->sc_ac2q[tid->ac]); tid->paused++; DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: paused = %d\n", __func__, tid->paused); - ATH_TXQ_UNLOCK(tid); + ATH_TXQ_UNLOCK(sc->sc_ac2q[tid->ac]); } /* @@ -2046,7 +2041,7 @@ ath_tx_tid_resume(struct ath_softc *sc, { struct ath_txq *txq = sc->sc_ac2q[tid->ac]; - ATH_TXQ_LOCK(tid); + ATH_TXQ_LOCK(txq); tid->paused--; @@ -2054,12 +2049,10 @@ ath_tx_tid_resume(struct ath_softc *sc, __func__, tid->paused); if (tid->paused || tid->axq_depth == 0) { - ATH_TXQ_UNLOCK(tid); + ATH_TXQ_UNLOCK(txq); return; } - ATH_TXQ_UNLOCK(tid); - ATH_TXQ_LOCK(txq); ath_tx_tid_sched(sc, tid->an, tid->tid); ATH_TXQ_UNLOCK(txq); @@ -2105,12 +2098,12 @@ ath_tx_tid_drain(struct ath_softc *sc, s tap = ath_tx_get_tx_tid(an, tid->tid); + ATH_TXQ_LOCK_ASSERT(sc->sc_ac2q[tid->ac]); + /* Walk the queue, free frames */ for (;;) { - ATH_TXQ_LOCK(tid); bf = TAILQ_FIRST(&tid->axq_q); if (bf == NULL) { - ATH_TXQ_UNLOCK(tid); break; } @@ -2139,7 +2132,6 @@ ath_tx_tid_drain(struct ath_softc *sc, s __func__, SEQNO(bf->bf_state.bfs_seqno)); } ATH_TXQ_REMOVE(tid, bf, bf_list); - ATH_TXQ_UNLOCK(tid); ath_tx_default_comp(sc, bf, 0); } @@ -2154,18 +2146,10 @@ ath_tx_tid_drain(struct ath_softc *sc, s * The cleaner solution is to do the sequence number allocation * when the packet is first transmitted - and thus the "retries" * check above would be enough to update the BAW/seqno. - * - * XXX There may exist a situation where active traffic on a node - * XXX is occuring in another thread whilst an interface is being - * XXX reset. In this instance, traffic is going to be added (eg to the - * XXX tail of the queue, or head if it's a retry) whilst this routine - * XXX attempts to drain. This is going to make things be very out - * XXX of whack. */ /* But don't do it for non-QoS TIDs */ if (tap) { - ATH_TXQ_LOCK(tid); #if 0 DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: node %p: TID %d: sliding BAW left edge to %d\n", @@ -2173,14 +2157,12 @@ ath_tx_tid_drain(struct ath_softc *sc, s #endif ni->ni_txseqs[tid->tid] = tap->txa_start; tid->baw_tail = tid->baw_head; - ATH_TXQ_UNLOCK(tid); } } /* * Flush all software queued packets for the given node. * - * Work around recursive TXQ locking. * This occurs when a completion handler frees the last buffer * for a node, and the node is thus freed. This causes the node * to be cleaned up, which ends up calling ath_tx_node_flush. @@ -2197,10 +2179,10 @@ ath_tx_node_flush(struct ath_softc *sc, /* Remove this tid from the list of active tids */ ATH_TXQ_LOCK(txq); ath_tx_tid_unsched(sc, an, tid); - ATH_TXQ_UNLOCK(txq); /* Free packets */ ath_tx_tid_drain(sc, an, atid); + ATH_TXQ_UNLOCK(txq); } } @@ -2226,7 +2208,6 @@ ath_tx_tid_cleanup(struct ath_softc *sc, atid = &an->an_tid[tid]; /* Mark hw-queued packets as having no parent now */ ath_tx_tid_txq_unmark(sc, an, tid); - mtx_destroy(&atid->axq_lock); } } @@ -2242,15 +2223,15 @@ ath_tx_normal_comp(struct ath_softc *sc, struct ath_tid *atid = &an->an_tid[tid]; struct ath_tx_status *ts = &bf->bf_status.ds_txstat; + ATH_TXQ_LOCK_ASSERT(sc->sc_ac2q[atid->ac]); + DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: bf=%p: fail=%d, hwq_depth now %d\n", __func__, bf, fail, atid->hwq_depth - 1); - ATH_TXQ_LOCK(atid); atid->hwq_depth--; if (atid->hwq_depth < 0) device_printf(sc->sc_dev, "%s: hwq_depth < 0: %d\n", __func__, atid->hwq_depth); - ATH_TXQ_UNLOCK(atid); /* * punt to rate control if we're not being cleaned up @@ -2276,6 +2257,8 @@ ath_tx_comp_cleanup_unaggr(struct ath_so int tid = bf->bf_state.bfs_tid; struct ath_tid *atid = &an->an_tid[tid]; + ATH_TXQ_LOCK_ASSERT(sc->sc_ac2q[atid->ac]); + DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: TID %d: incomp=%d\n", __func__, tid, atid->incomp); @@ -2313,13 +2296,14 @@ ath_tx_cleanup(struct ath_softc *sc, str DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: TID %d: called\n", __func__, tid); + ATH_TXQ_LOCK_ASSERT(sc->sc_ac2q[atid->ac]); + /* * Update the frames in the software TX queue: * * + Discard retry frames in the queue * + Fix the completion function to be non-aggregate */ - ATH_TXQ_LOCK(atid); bf = TAILQ_FIRST(&atid->axq_q); while (bf) { if (bf->bf_state.bfs_isretried) { @@ -2347,7 +2331,6 @@ ath_tx_cleanup(struct ath_softc *sc, str bf->bf_comp = ath_tx_normal_comp; bf = TAILQ_NEXT(bf, bf_list); } - ATH_TXQ_UNLOCK(atid); /* The caller is required to pause the TID */ #if 0 @@ -2363,7 +2346,6 @@ ath_tx_cleanup(struct ath_softc *sc, str */ tap = ath_tx_get_tx_tid(an, tid); /* Need the lock - fiddling with BAW */ - ATH_TXQ_LOCK(atid); while (atid->baw_head != atid->baw_tail) { if (atid->tx_buf[atid->baw_head]) { atid->incomp++; @@ -2373,7 +2355,6 @@ ath_tx_cleanup(struct ath_softc *sc, str INCR(atid->baw_head, ATH_TID_MAX_BUFS); INCR(tap->txa_start, IEEE80211_SEQ_RANGE); } - ATH_TXQ_UNLOCK(atid); /* * If cleanup is required, defer TID scheduling @@ -2488,10 +2469,8 @@ ath_tx_aggr_retry_unaggr(struct ath_soft /* Update BAW anyway */ if (bf->bf_state.bfs_dobaw) { - ATH_TXQ_LOCK(atid); ath_tx_update_baw(sc, an, atid, SEQNO(bf->bf_state.bfs_seqno)); - ATH_TXQ_UNLOCK(atid); if (! bf->bf_state.bfs_addedbaw) device_printf(sc->sc_dev, "%s: wasn't added: seqno %d\n", @@ -2539,13 +2518,8 @@ ath_tx_aggr_retry_unaggr(struct ath_soft * Insert this at the head of the queue, so it's * retried before any current/subsequent frames. */ - ATH_TXQ_LOCK(atid); ATH_TXQ_INSERT_HEAD(atid, bf, bf_list); - ATH_TXQ_UNLOCK(atid); - - ATH_TXQ_LOCK(bf->bf_state.bfs_txq); ath_tx_tid_sched(sc, an, atid->tid); - ATH_TXQ_UNLOCK(bf->bf_state.bfs_txq); } /* @@ -2564,6 +2538,8 @@ ath_tx_retry_subframe(struct ath_softc * int tid = bf->bf_state.bfs_tid; struct ath_tid *atid = &an->an_tid[tid]; + ATH_TXQ_LOCK_ASSERT(sc->sc_ac2q[atid->ac]); + ath_hal_clr11n_aggr(sc->sc_ah, bf->bf_desc); ath_hal_set11nburstduration(sc->sc_ah, bf->bf_desc, 0); /* ath_hal_set11n_virtualmorefrag(sc->sc_ah, bf->bf_desc, 0); */ @@ -2591,14 +2567,12 @@ ath_tx_retry_subframe(struct ath_softc * DPRINTF(sc, ATH_DEBUG_SW_TX_RETRIES, "%s: max retries: seqno %d\n", __func__, SEQNO(bf->bf_state.bfs_seqno)); - ATH_TXQ_LOCK(atid); ath_tx_update_baw(sc, an, atid, SEQNO(bf->bf_state.bfs_seqno)); if (! bf->bf_state.bfs_addedbaw) device_printf(sc->sc_dev, "%s: wasn't added: seqno %d\n", __func__, SEQNO(bf->bf_state.bfs_seqno)); bf->bf_state.bfs_dobaw = 0; - ATH_TXQ_UNLOCK(atid); /* XXX subframe completion status? is that valid here? */ ath_tx_default_comp(sc, bf, 0); return 1; @@ -2626,6 +2600,8 @@ ath_tx_comp_aggr_error(struct ath_softc struct ieee80211_tx_ampdu *tap; struct ath_txq *txq = sc->sc_ac2q[tid->ac]; + ATH_TXQ_LOCK_ASSERT(txq); + tap = ath_tx_get_tx_tid(an, tid->tid); TAILQ_INIT(&bf_q); @@ -2669,16 +2645,12 @@ ath_tx_comp_aggr_error(struct ath_softc #endif /* Prepend all frames to the beginning of the queue */ - ATH_TXQ_LOCK(tid); while ((bf = TAILQ_LAST(&bf_q, ath_bufhead_s)) != NULL) { TAILQ_REMOVE(&bf_q, bf, bf_list); ATH_TXQ_INSERT_HEAD(tid, bf, bf_list); } - ATH_TXQ_UNLOCK(tid); - ATH_TXQ_LOCK(txq); ath_tx_tid_sched(sc, an, tid->tid); - ATH_TXQ_UNLOCK(txq); } /* @@ -2748,12 +2720,12 @@ ath_tx_aggr_comp_aggr(struct ath_softc * DPRINTF(sc, ATH_DEBUG_SW_TX_AGGR, "%s: called; hwq_depth=%d\n", __func__, atid->hwq_depth); - ATH_TXQ_LOCK(atid); + ATH_TXQ_LOCK_ASSERT(txq); + atid->hwq_depth--; if (atid->hwq_depth < 0) device_printf(sc->sc_dev, "%s: hwq_depth < 0: %d\n", __func__, atid->hwq_depth); - ATH_TXQ_UNLOCK(atid); /* * Punt cleanup to the relevant function, not our problem now @@ -2837,10 +2809,8 @@ ath_tx_aggr_comp_aggr(struct ath_softc * ATH_BA_ISSET(ba, ba_index)); if (tx_ok && ATH_BA_ISSET(ba, ba_index)) { - ATH_TXQ_LOCK(atid); ath_tx_update_baw(sc, an, atid, SEQNO(bf->bf_state.bfs_seqno)); - ATH_TXQ_UNLOCK(atid); bf->bf_state.bfs_dobaw = 0; if (! bf->bf_state.bfs_addedbaw) device_printf(sc->sc_dev, @@ -2888,16 +2858,12 @@ ath_tx_aggr_comp_aggr(struct ath_softc * #endif /* Prepend all frames to the beginning of the queue */ - ATH_TXQ_LOCK(atid); while ((bf = TAILQ_LAST(&bf_q, ath_bufhead_s)) != NULL) { TAILQ_REMOVE(&bf_q, bf, bf_list); ATH_TXQ_INSERT_HEAD(atid, bf, bf_list); } - ATH_TXQ_UNLOCK(atid); - ATH_TXQ_LOCK(txq); ath_tx_tid_sched(sc, an, atid->tid); - ATH_TXQ_UNLOCK(txq); DPRINTF(sc, ATH_DEBUG_SW_TX_AGGR, "%s: finished; txa_start now %d\n", __func__, tap->txa_start); @@ -2918,6 +2884,9 @@ ath_tx_aggr_comp_unaggr(struct ath_softc int tid = bf->bf_state.bfs_tid; struct ath_tid *atid = &an->an_tid[tid]; struct ath_tx_status *ts = &bf->bf_status.ds_txstat; + struct ath_txq *txq = sc->sc_ac2q[atid->ac]; + + ATH_TXQ_LOCK_ASSERT(txq); if (tid == IEEE80211_NONQOS_TID) device_printf(sc->sc_dev, "%s: TID=16!\n", __func__); @@ -2925,12 +2894,10 @@ ath_tx_aggr_comp_unaggr(struct ath_softc DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: bf=%p: tid=%d, hwq_depth=%d\n", __func__, bf, bf->bf_state.bfs_tid, atid->hwq_depth); - ATH_TXQ_LOCK(atid); atid->hwq_depth--; if (atid->hwq_depth < 0) device_printf(sc->sc_dev, "%s: hwq_depth < 0: %d\n", __func__, atid->hwq_depth); - ATH_TXQ_UNLOCK(atid); /* * Update rate control status here, before we possibly @@ -2966,14 +2933,12 @@ ath_tx_aggr_comp_unaggr(struct ath_softc DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: TID=%d, seqno %d\n", __func__, tid, SEQNO(bf->bf_state.bfs_seqno)); if (bf->bf_state.bfs_dobaw) { - ATH_TXQ_LOCK(atid); ath_tx_update_baw(sc, an, atid, SEQNO(bf->bf_state.bfs_seqno)); bf->bf_state.bfs_dobaw = 0; if (! bf->bf_state.bfs_addedbaw) device_printf(sc->sc_dev, "%s: wasn't added: seqno %d\n", __func__, SEQNO(bf->bf_state.bfs_seqno)); - ATH_TXQ_UNLOCK(atid); } ath_tx_default_comp(sc, bf, fail); @@ -2998,14 +2963,15 @@ void ath_tx_tid_hw_queue_aggr(struct ath_softc *sc, struct ath_node *an, int tid) { struct ath_buf *bf; - struct ath_txq *txq; struct ath_tid *atid = &an->an_tid[tid]; + struct ath_txq *txq = sc->sc_ac2q[atid->ac]; struct ieee80211_tx_ampdu *tap; struct ieee80211_node *ni = &an->an_node; ATH_AGGR_STATUS status; ath_bufhead bf_q; DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: tid=%d\n", __func__, tid); + ATH_TXQ_LOCK_ASSERT(txq); tap = ath_tx_get_tx_tid(an, tid); @@ -3016,8 +2982,6 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft for (;;) { status = ATH_AGGR_DONE; - ATH_TXQ_LOCK(atid); - /* * If the upper layer has paused the TID, don't * queue any further packets. @@ -3031,7 +2995,6 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft bf = TAILQ_FIRST(&atid->axq_q); if (bf == NULL) { - ATH_TXQ_UNLOCK(atid); break; } @@ -3043,7 +3006,6 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft DPRINTF(sc, ATH_DEBUG_SW_TX_AGGR, "%s: non-baw packet\n", __func__); ATH_TXQ_REMOVE(atid, bf, bf_list); - ATH_TXQ_UNLOCK(atid); bf->bf_state.bfs_aggr = 0; ath_tx_setds(sc, bf); ath_tx_chaindesclist(sc, bf); @@ -3055,7 +3017,6 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft /* Queue the packet; continue */ goto queuepkt; } - ATH_TXQ_UNLOCK(atid); /* Don't lock the TID - ath_tx_form_aggr will lock as needed */ TAILQ_INIT(&bf_q); @@ -3128,7 +3089,7 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft ath_tx_set_ratectrl(sc, ni, bf); } queuepkt: - txq = bf->bf_state.bfs_txq; + //txq = bf->bf_state.bfs_txq; /* Set completion handler, multi-frame aggregate or not */ bf->bf_comp = ath_tx_aggr_comp; @@ -3137,15 +3098,11 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft device_printf(sc->sc_dev, "%s: TID=16?\n", __func__); /* Punt to txq */ - ATH_TXQ_LOCK(txq); ath_tx_handoff(sc, txq, bf); - ATH_TXQ_UNLOCK(txq); /* Track outstanding buffer count to hardware */ /* aggregates are "one" buffer */ - ATH_TXQ_LOCK(atid); atid->hwq_depth++; - ATH_TXQ_UNLOCK(atid); /* * Break out if ath_tx_form_aggr() indicated @@ -3167,13 +3124,15 @@ void ath_tx_tid_hw_queue_norm(struct ath_softc *sc, struct ath_node *an, int tid) { struct ath_buf *bf; - struct ath_txq *txq; struct ath_tid *atid = &an->an_tid[tid]; + struct ath_txq *txq = sc->sc_ac2q[atid->ac]; struct ieee80211_node *ni = &an->an_node; DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: node %p: TID %d: called\n", __func__, an, tid); + ATH_TXQ_LOCK_ASSERT(txq); + /* Check - is AMPDU pending or running? then print out something */ if (ath_tx_ampdu_pending(sc, an, tid)) device_printf(sc->sc_dev, "%s: tid=%d, ampdu pending?\n", @@ -3183,7 +3142,6 @@ ath_tx_tid_hw_queue_norm(struct ath_soft __func__, tid); for (;;) { - ATH_TXQ_LOCK(atid); /* * If the upper layers have paused the TID, don't @@ -3194,14 +3152,12 @@ ath_tx_tid_hw_queue_norm(struct ath_soft bf = TAILQ_FIRST(&atid->axq_q); if (bf == NULL) { - ATH_TXQ_UNLOCK(atid); break; } ATH_TXQ_REMOVE(atid, bf, bf_list); - ATH_TXQ_UNLOCK(atid); - txq = bf->bf_state.bfs_txq; + KASSERT(txq == bf->bf_state.bfs_txq, ("txqs not equal!\n")); /* Sanity check! */ if (tid != bf->bf_state.bfs_tid) { @@ -3219,14 +3175,10 @@ ath_tx_tid_hw_queue_norm(struct ath_soft /* Track outstanding buffer count to hardware */ /* aggregates are "one" buffer */ - ATH_TXQ_LOCK(atid); atid->hwq_depth++; - ATH_TXQ_UNLOCK(atid); /* Punt to hardware or software txq */ - ATH_TXQ_LOCK(txq); ath_tx_handoff(sc, txq, bf); - ATH_TXQ_UNLOCK(txq); } } @@ -3236,27 +3188,20 @@ ath_tx_tid_hw_queue_norm(struct ath_soft * This function walks the list of TIDs (ie, ath_node TIDs * with queued traffic) and attempts to schedule traffic * from them. - * - * XXX I haven't locked this code yet, but I need to! - * XXX walking the tidq requires the TXQ lock, checking - * XXX for how busy the queues are require the relevant - * XXX lock! */ void ath_txq_sched(struct ath_softc *sc, struct ath_txq *txq) { struct ath_tid *atid, *next; + ATH_TXQ_LOCK_ASSERT(txq); + /* * Don't schedule if the hardware queue is busy. * This (hopefully) gives some more time to aggregate * some packets in the aggregation queue. - * XXX TODO: only do this based on AMPDU buffers, not - * XXX normal ones. */ - ATH_TXQ_LOCK(txq); if (txq->axq_aggr_depth >= sc->sc_hwq_limit) { - ATH_TXQ_UNLOCK(txq); return; } @@ -3265,9 +3210,7 @@ ath_txq_sched(struct ath_softc *sc, stru * or the like. That's a later problem. Just throw * packets at the hardware. */ - /* XXX txq is already locked */ TAILQ_FOREACH_SAFE(atid, &txq->axq_tidq, axq_qelem, next) { - ATH_TXQ_UNLOCK(txq); /* * Suspend paused queues here; they'll be resumed * once the addba completes or times out. @@ -3277,33 +3220,24 @@ ath_txq_sched(struct ath_softc *sc, stru */ DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: tid=%d, paused=%d\n", __func__, atid->tid, atid->paused); - ATH_TXQ_LOCK(atid); if (atid->paused) { - ATH_TXQ_UNLOCK(atid); - ATH_TXQ_LOCK(txq); ath_tx_tid_unsched(sc, atid->an, atid->tid); - //ATH_TXQ_UNLOCK(txq); continue; } - ATH_TXQ_UNLOCK(atid); if (ath_tx_ampdu_running(sc, atid->an, atid->tid)) ath_tx_tid_hw_queue_aggr(sc, atid->an, atid->tid); else ath_tx_tid_hw_queue_norm(sc, atid->an, atid->tid); /* Empty? Remove */ - ATH_TXQ_LOCK(txq); if (atid->axq_depth == 0) ath_tx_tid_unsched(sc, atid->an, atid->tid); /* Give the software queue time to aggregate more packets */ if (txq->axq_aggr_depth >= sc->sc_hwq_limit) { - //ATH_TXQ_UNLOCK(txq); break; } - //ATH_TXQ_UNLOCK(txq); } - ATH_TXQ_UNLOCK(txq); } /* @@ -3500,12 +3434,14 @@ ath_addba_stop(struct ieee80211_node *ni /* There's no need to hold the TXQ lock here */ sc->sc_addba_stop(ni, tap); - ath_tx_cleanup(sc, an, tid); + ATH_TXQ_LOCK(sc->sc_ac2q[atid->ac]); /* * ath_tx_cleanup will resume the TID if possible, otherwise * it'll set the cleanup flag, and it'll be unpaused once * things have been cleaned up. */ + ath_tx_cleanup(sc, an, tid); + ATH_TXQ_UNLOCK(sc->sc_ac2q[atid->ac]); } /* Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c Sun Aug 28 00:14:40 2011 (r225223) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c Sun Aug 28 03:05:16 2011 (r225224) @@ -655,6 +655,8 @@ ath_tx_form_aggr(struct ath_softc *sc, s int prev_frames = 0; /* XXX for AR5416 burst, not done here */ int prev_al = 0; /* XXX also for AR5416 burst */ + ATH_TXQ_LOCK_ASSERT(sc->sc_ac2q[tid->ac]); + tap = ath_tx_get_tx_tid(an, tid->tid); if (tap == NULL) { status = ATH_AGGR_ERROR; @@ -664,12 +666,10 @@ ath_tx_form_aggr(struct ath_softc *sc, s h_baw = tap->txa_wnd / 2; for (;;) { - ATH_TXQ_LOCK(tid); bf = TAILQ_FIRST(&tid->axq_q); if (bf_first == NULL) bf_first = bf; if (bf == NULL) { - ATH_TXQ_UNLOCK(tid); status = ATH_AGGR_DONE; break; } else { @@ -697,7 +697,6 @@ ath_tx_form_aggr(struct ath_softc *sc, s * TX the frame individually. */ if (! bf->bf_state.bfs_dobaw) { - ATH_TXQ_UNLOCK(tid); status = ATH_AGGR_NONAGGR; break; } @@ -715,7 +714,6 @@ ath_tx_form_aggr(struct ath_softc *sc, s */ if (! BAW_WITHIN(tap->txa_start, tap->txa_wnd, SEQNO(bf->bf_state.bfs_seqno))) { - ATH_TXQ_UNLOCK(tid); status = ATH_AGGR_BAW_CLOSED; break; } @@ -734,7 +732,6 @@ ath_tx_form_aggr(struct ath_softc *sc, s al_delta = ATH_AGGR_DELIM_SZ + bf->bf_state.bfs_pktlen; if (nframes && (aggr_limit < (al + bpad + al_delta + prev_al))) { - ATH_TXQ_UNLOCK(tid); status = ATH_AGGR_LIMITED; break; } @@ -744,7 +741,6 @@ ath_tx_form_aggr(struct ath_softc *sc, s */ if ((nframes + prev_frames) >= MIN((h_baw), IEEE80211_AMPDU_SUBFRAME_DEFAULT)) { - ATH_TXQ_UNLOCK(tid); status = ATH_AGGR_LIMITED; break; } @@ -757,7 +753,6 @@ ath_tx_form_aggr(struct ath_softc *sc, s /* The TID lock is required for the BAW update */ ath_tx_addto_baw(sc, an, tid, bf); bf->bf_state.bfs_addedbaw = 1; - ATH_TXQ_UNLOCK(tid); /* * Add the now owned buffer (which isn't Modified: user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Sun Aug 28 00:14:40 2011 (r225223) +++ user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Sun Aug 28 03:05:16 2011 (r225224) @@ -92,7 +92,6 @@ struct ath_buf; */ struct ath_tid { TAILQ_HEAD(,ath_buf) axq_q; /* pending buffers */ - struct mtx axq_lock; /* lock on q and link */ u_int axq_depth; /* SW queue depth */ char axq_name[48]; /* lock name */ struct ath_node *an; /* pointer to parent */ From owner-svn-src-user@FreeBSD.ORG Sun Aug 28 04:17:57 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 373A21065670; Sun, 28 Aug 2011 04:17:57 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0DB748FC0A; Sun, 28 Aug 2011 04:17:57 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7S4HuHW034044; Sun, 28 Aug 2011 04:17:56 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7S4Hu0O034042; Sun, 28 Aug 2011 04:17:56 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108280417.p7S4Hu0O034042@svn.freebsd.org> From: Adrian Chadd Date: Sun, 28 Aug 2011 04:17:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225225 - user/adrian/if_ath_tx/sys/dev/ath X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Aug 2011 04:17:57 -0000 Author: adrian Date: Sun Aug 28 04:17:56 2011 New Revision: 225225 URL: http://svn.freebsd.org/changeset/base/225225 Log: Fix locking (again). Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Sun Aug 28 03:05:16 2011 (r225224) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Sun Aug 28 04:17:56 2011 (r225225) @@ -2041,7 +2041,7 @@ ath_tx_tid_resume(struct ath_softc *sc, { struct ath_txq *txq = sc->sc_ac2q[tid->ac]; - ATH_TXQ_LOCK(txq); + ATH_TXQ_LOCK_ASSERT(txq); tid->paused--; @@ -2049,24 +2049,13 @@ ath_tx_tid_resume(struct ath_softc *sc, __func__, tid->paused); if (tid->paused || tid->axq_depth == 0) { - ATH_TXQ_UNLOCK(txq); return; } ath_tx_tid_sched(sc, tid->an, tid->tid); - ATH_TXQ_UNLOCK(txq); - ath_tx_sched_proc_sched(sc, txq); } -/* - * Mark packets currently in the hardware TXQ from this TID - * as now having no parent software TXQ. - * - * XXX not yet needed; there shouldn't be any packets left - * XXX for this node in any of the hardware queues; the node - * XXX isn't freed until the last TX packet has been sent. - */ static void ath_tx_tid_txq_unmark(struct ath_softc *sc, struct ath_node *an, int tid) @@ -2166,6 +2155,10 @@ ath_tx_tid_drain(struct ath_softc *sc, s * This occurs when a completion handler frees the last buffer * for a node, and the node is thus freed. This causes the node * to be cleaned up, which ends up calling ath_tx_node_flush. + * + * XXX Because the TXQ may be locked right now (when it's called + * XXX from a completion handler which frees the last node) + * XXX do a dirty recursive hack avoidance. */ void ath_tx_node_flush(struct ath_softc *sc, struct ath_node *an) @@ -2175,14 +2168,20 @@ ath_tx_node_flush(struct ath_softc *sc, for (tid = 0; tid < IEEE80211_TID_SIZE; tid++) { struct ath_tid *atid = &an->an_tid[tid]; struct ath_txq *txq = sc->sc_ac2q[atid->ac]; + int islocked = 0; /* Remove this tid from the list of active tids */ - ATH_TXQ_LOCK(txq); + /* XXX eww, this needs to be fixed */ + if (ATH_TXQ_IS_LOCKED(txq)) + islocked = 1; + else + ATH_TXQ_LOCK(txq); ath_tx_tid_unsched(sc, an, tid); /* Free packets */ ath_tx_tid_drain(sc, an, atid); - ATH_TXQ_UNLOCK(txq); + if (! islocked) + ATH_TXQ_UNLOCK(txq); } } @@ -3403,14 +3402,15 @@ ath_addba_response(struct ieee80211_node */ r = sc->sc_addba_response(ni, tap, status, code, batimeout); + ATH_TXQ_LOCK(sc->sc_ac2q[atid->ac]); /* * XXX dirty! * Slide the BAW left edge to wherever net80211 left it for us. * Read above for more information. */ tap->txa_start = ni->ni_txseqs[tid]; - ath_tx_tid_resume(sc, atid); + ATH_TXQ_UNLOCK(sc->sc_ac2q[atid->ac]); return r; } From owner-svn-src-user@FreeBSD.ORG Sun Aug 28 05:27:35 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 49343106564A; Sun, 28 Aug 2011 05:27:35 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 389B58FC0A; Sun, 28 Aug 2011 05:27:35 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7S5RZpv036032; Sun, 28 Aug 2011 05:27:35 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7S5RZZM036028; Sun, 28 Aug 2011 05:27:35 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108280527.p7S5RZZM036028@svn.freebsd.org> From: Adrian Chadd Date: Sun, 28 Aug 2011 05:27:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225226 - user/adrian/if_ath_tx/sys/dev/ath X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Aug 2011 05:27:35 -0000 Author: adrian Date: Sun Aug 28 05:27:34 2011 New Revision: 225226 URL: http://svn.freebsd.org/changeset/base/225226 Log: Shift over to using the software txq drain code from the reference driver. This avoids calling ieee80211_iterate_nodes() to flush the nodes for a given softc. Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath.c user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.h Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Sun Aug 28 04:17:56 2011 (r225225) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Sun Aug 28 05:27:34 2011 (r225226) @@ -202,7 +202,6 @@ static void ath_setcurmode(struct ath_so static void ath_announce(struct ath_softc *); static void ath_dfs_tasklet(void *, int); -static void ath_sc_flushtxq(struct ath_softc *sc); #ifdef IEEE80211_SUPPORT_TDMA static void ath_tdma_settimers(struct ath_softc *sc, u_int32_t nexttbtt, @@ -1148,7 +1147,6 @@ ath_vap_delete(struct ieee80211vap *vap) ath_hal_intrset(ah, 0); /* disable interrupts */ ath_draintxq(sc); /* stop hw xmit side */ /* XXX Do all frames from all vaps/nodes need draining here? */ - ath_sc_flushtxq(sc); /* drain sw xmit side */ ath_stoprecv(sc); /* stop recv side */ } @@ -1172,8 +1170,6 @@ ath_vap_delete(struct ieee80211vap *vap) */ ath_draintxq(sc); - /* XXX Do all frames from all vaps/nodes need draining here? */ - ath_sc_flushtxq(sc); ATH_LOCK(sc); /* @@ -1756,11 +1752,6 @@ ath_stop_locked(struct ifnet *ifp) ath_hal_intrset(ah, 0); } ath_draintxq(sc); - /* - * XXX Draining these packets may create a hole in the - * XXX BAW. - */ - ath_sc_flushtxq(sc); /* drain sw xmit side */ if (!sc->sc_invalid) { ath_stoprecv(sc); ath_hal_phydisable(ah); @@ -1799,19 +1790,6 @@ ath_reset(struct ifnet *ifp) ath_hal_intrset(ah, 0); /* disable interrupts */ ath_draintxq(sc); /* stop xmit side */ - /* - * XXX as long as ath_reset() isn't called during a state - * transition (eg channel change, mode change, etc) - * then there's no need to flush the software TXQ. - * Doing this here messes with the BAW tracking, as - * there may be aggregate packets in the software TXQ - * which haven't been queued to the hardware, and thus - * the BAW hasn't been set. Freeing those packets will - * create a "hole" in the BAW. - */ -#if 0 - ath_sc_flushtxq(sc); /* drain sw xmit side */ -#endif ath_stoprecv(sc); /* stop recv side */ ath_settkipmic(sc); /* configure TKIP MIC handling */ /* NB: indicate channel change so we do a full reset */ @@ -4677,6 +4655,12 @@ ath_tx_draintxq(struct ath_softc *sc, st else ath_tx_default_comp(sc, bf, 1); } + + /* + * Drain software queued frames which are on + * active TIDs. + */ + ath_tx_txq_drain(sc, txq); ATH_TXQ_UNLOCK(txq); } @@ -4849,18 +4833,6 @@ ath_chan_set(struct ath_softc *sc, struc */ ath_hal_intrset(ah, 0); /* disable interrupts */ ath_draintxq(sc); /* clear pending tx frames */ - /* - * XXX This may create holes in the BAW, since some - * XXX aggregate packets may have not yet been scheduled - * XXX to the hardware, and thus ath_tx_addto_baw() has - * XXX never been called. - * - * But we can't _not_ call this here, because the current - * TX code doesn't handle the potential rate/flags change - * (eg a 40->20mhz change, or HT->non-HT change, or 11a<->g - * change, etc.) - */ - ath_sc_flushtxq(sc); /* drain sw xmit side */ ath_stoprecv(sc); /* turn off frame recv */ if (!ath_hal_reset(ah, sc->sc_opmode, chan, AH_TRUE, &status)) { if_printf(ifp, "%s: unable to reset " @@ -6184,40 +6156,5 @@ ath_dfs_tasklet(void *p, int npending) } } -/* - * Flush all software queued packets for the given VAP. - * - * The ieee80211 common lock should be held. - */ -static void -ath_vap_flush_node(void *arg, struct ieee80211_node *ni) -{ - struct ath_softc *sc = (struct ath_softc *) arg; - - ath_tx_node_flush(sc, ATH_NODE(ni)); -} - -/* - * Flush all software queued packets for the given sc. - * - * The ieee80211 common lock should be held. - */ -static void -ath_sc_flushtxq(struct ath_softc *sc) -{ - struct ieee80211com *ic = sc->sc_ifp->if_l2com; - -#if 0 - //IEEE80211_LOCK_ASSERT(ic); - /* Debug if we don't own the lock! */ - if (! mtx_owned(IEEE80211_LOCK_OBJ(ic))) { - device_printf(sc->sc_dev, "%s: comlock not owned?\n", - __func__); - } -#endif - - ieee80211_iterate_nodes(&ic->ic_sta, ath_vap_flush_node, sc); -} - MODULE_VERSION(if_ath, 1); MODULE_DEPEND(if_ath, wlan, 1, 1, 1); /* 802.11 media layer */ Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Sun Aug 28 04:17:56 2011 (r225225) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Sun Aug 28 05:27:34 2011 (r225226) @@ -2186,6 +2186,28 @@ ath_tx_node_flush(struct ath_softc *sc, } /* + * Drain all the software TXQs currently with traffic queued. + */ +void +ath_tx_txq_drain(struct ath_softc *sc, struct ath_txq *txq) +{ + struct ath_tid *tid; + + ATH_TXQ_LOCK_ASSERT(txq); + + /* + * Iterate over all active tids for the given txq, + * flushing and unsched'ing them + */ + while (! TAILQ_EMPTY(&txq->axq_tidq)) { + tid = TAILQ_FIRST(&txq->axq_tidq); + ath_tx_tid_drain(sc, tid->an, tid); + ath_tx_tid_unsched(sc, tid->an, tid->tid); + } + +} + +/* * Free the per-TID node state. * * This frees any packets currently in the software queue and frees Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.h Sun Aug 28 04:17:56 2011 (r225225) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.h Sun Aug 28 05:27:34 2011 (r225226) @@ -81,6 +81,7 @@ extern void ath_freetx(struct mbuf *m); extern void ath_tx_node_flush(struct ath_softc *sc, struct ath_node *an); +extern void ath_tx_txq_drain(struct ath_softc *sc, struct ath_txq *txq); extern void ath_txfrag_cleanup(struct ath_softc *sc, ath_bufhead *frags, struct ieee80211_node *ni); extern int ath_txfrag_setup(struct ath_softc *sc, ath_bufhead *frags, From owner-svn-src-user@FreeBSD.ORG Sun Aug 28 13:24:48 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 98163106564A; Sun, 28 Aug 2011 13:24:48 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6F1A28FC12; Sun, 28 Aug 2011 13:24:48 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7SDOm2b053620; Sun, 28 Aug 2011 13:24:48 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7SDOmEH053617; Sun, 28 Aug 2011 13:24:48 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108281324.p7SDOmEH053617@svn.freebsd.org> From: Adrian Chadd Date: Sun, 28 Aug 2011 13:24:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225230 - user/adrian/if_ath_tx/sys/dev/ath X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Aug 2011 13:24:48 -0000 Author: adrian Date: Sun Aug 28 13:24:48 2011 New Revision: 225230 URL: http://svn.freebsd.org/changeset/base/225230 Log: Push the cleanup stuff into ic_node_cleanup rather than destroy, which ends up having some recursive badness happening leading to panics. Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath.c user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Sun Aug 28 11:49:53 2011 (r225229) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Sun Aug 28 13:24:48 2011 (r225230) @@ -158,6 +158,7 @@ static int ath_desc_alloc(struct ath_sof static void ath_desc_free(struct ath_softc *); static struct ieee80211_node *ath_node_alloc(struct ieee80211vap *, const uint8_t [IEEE80211_ADDR_LEN]); +static void ath_node_cleanup(struct ieee80211_node *); static void ath_node_free(struct ieee80211_node *); static void ath_node_getsignal(const struct ieee80211_node *, int8_t *, int8_t *); @@ -725,6 +726,8 @@ ath_attach(u_int16_t devid, struct ath_s ic->ic_node_alloc = ath_node_alloc; sc->sc_node_free = ic->ic_node_free; ic->ic_node_free = ath_node_free; + sc->sc_node_cleanup = ic->ic_node_cleanup; + ic->ic_node_cleanup = ath_node_cleanup; ic->ic_node_getsignal = ath_node_getsignal; ic->ic_scan_start = ath_scan_start; ic->ic_scan_end = ath_scan_end; @@ -3310,17 +3313,24 @@ ath_node_alloc(struct ieee80211vap *vap, } static void -ath_node_free(struct ieee80211_node *ni) +ath_node_cleanup(struct ieee80211_node *ni) { struct ieee80211com *ic = ni->ni_ic; struct ath_softc *sc = ic->ic_ifp->if_softc; - DPRINTF(sc, ATH_DEBUG_NODE, "%s: ni %p\n", __func__, ni); - /* Cleanup ath_tid, free unused bufs, unlink bufs in TXQ */ ath_tx_tid_cleanup(sc, ATH_NODE(ni)); - ath_rate_node_cleanup(sc, ATH_NODE(ni)); + sc->sc_node_cleanup(ni); +} + +static void +ath_node_free(struct ieee80211_node *ni) +{ + struct ieee80211com *ic = ni->ni_ic; + struct ath_softc *sc = ic->ic_ifp->if_softc; + + DPRINTF(sc, ATH_DEBUG_NODE, "%s: ni %p\n", __func__, ni); mtx_destroy(&ATH_NODE(ni)->an_mtx); sc->sc_node_free(ni); } Modified: user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Sun Aug 28 11:49:53 2011 (r225229) +++ user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Sun Aug 28 13:24:48 2011 (r225230) @@ -340,6 +340,7 @@ struct ath_softc { u_int8_t sc_nbssid0; /* # vap's using base mac */ uint32_t sc_bssidmask; /* bssid mask */ + void (*sc_node_cleanup)(struct ieee80211_node *); void (*sc_node_free)(struct ieee80211_node *); device_t sc_dev; HAL_BUS_TAG sc_st; /* bus space tag */ From owner-svn-src-user@FreeBSD.ORG Sun Aug 28 14:54:26 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6F0D7106564A; Sun, 28 Aug 2011 14:54:26 +0000 (UTC) (envelope-from attilio@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 459DB8FC12; Sun, 28 Aug 2011 14:54:26 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7SEsQme056273; Sun, 28 Aug 2011 14:54:26 GMT (envelope-from attilio@svn.freebsd.org) Received: (from attilio@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7SEsQ7f056272; Sun, 28 Aug 2011 14:54:26 GMT (envelope-from attilio@svn.freebsd.org) Message-Id: <201108281454.p7SEsQ7f056272@svn.freebsd.org> From: Attilio Rao Date: Sun, 28 Aug 2011 14:54:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225231 - user/attilio X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Aug 2011 14:54:26 -0000 Author: attilio Date: Sun Aug 28 14:54:25 2011 New Revision: 225231 URL: http://svn.freebsd.org/changeset/base/225231 Log: Create my own home sub-dir. Added: user/attilio/ From owner-svn-src-user@FreeBSD.ORG Sun Aug 28 14:55:10 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 92C42106566B; Sun, 28 Aug 2011 14:55:10 +0000 (UTC) (envelope-from attilio@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 60E838FC0A; Sun, 28 Aug 2011 14:55:10 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7SEtA2K056340; Sun, 28 Aug 2011 14:55:10 GMT (envelope-from attilio@svn.freebsd.org) Received: (from attilio@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7SEtAEC056339; Sun, 28 Aug 2011 14:55:10 GMT (envelope-from attilio@svn.freebsd.org) Message-Id: <201108281455.p7SEtAEC056339@svn.freebsd.org> From: Attilio Rao Date: Sun, 28 Aug 2011 14:55:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225232 - user/attilio/vmcontention X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Aug 2011 14:55:10 -0000 Author: attilio Date: Sun Aug 28 14:55:09 2011 New Revision: 225232 URL: http://svn.freebsd.org/changeset/base/225232 Log: Create a branch for handling works related to VM lock contention reduction. Added: - copied from r225231, head/ Directory Properties: user/attilio/vmcontention/ (props changed) From owner-svn-src-user@FreeBSD.ORG Sun Aug 28 16:11:24 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A2323106564A; Sun, 28 Aug 2011 16:11:24 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 87A748FC0A; Sun, 28 Aug 2011 16:11:24 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7SGBOGN058535; Sun, 28 Aug 2011 16:11:24 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7SGBOdx058533; Sun, 28 Aug 2011 16:11:24 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108281611.p7SGBOdx058533@svn.freebsd.org> From: Adrian Chadd Date: Sun, 28 Aug 2011 16:11:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225233 - user/adrian/if_ath_tx/sys/dev/ath/ath_rate/sample X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Aug 2011 16:11:24 -0000 Author: adrian Date: Sun Aug 28 16:11:24 2011 New Revision: 225233 URL: http://svn.freebsd.org/changeset/base/225233 Log: Change ath_rate_sample debugging/stats output to use more friendly rate messages. Modified: user/adrian/if_ath_tx/sys/dev/ath/ath_rate/sample/sample.c Modified: user/adrian/if_ath_tx/sys/dev/ath/ath_rate/sample/sample.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/ath_rate/sample/sample.c Sun Aug 28 14:55:09 2011 (r225232) +++ user/adrian/if_ath_tx/sys/dev/ath/ath_rate/sample/sample.c Sun Aug 28 16:11:24 2011 (r225233) @@ -147,6 +147,8 @@ ath_rate_node_cleanup(struct ath_softc * static int dot11rate(const HAL_RATE_TABLE *rt, int rix) { + if (rix < 0) + return -1; return rt->info[rix].phy == IEEE80211_T_HT ? rt->info[rix].dot11Rate : (rt->info[rix].dot11Rate & IEEE80211_RATE_VAL) / 2; } @@ -154,6 +156,8 @@ dot11rate(const HAL_RATE_TABLE *rt, int static const char * dot11rate_label(const HAL_RATE_TABLE *rt, int rix) { + if (rix < 0) + return ""; return rt->info[rix].phy == IEEE80211_T_HT ? "MCS" : "Mb "; } @@ -359,9 +363,12 @@ ath_rate_findrate(struct ath_softc *sc, if (sn->sample_tt[size_bin] < average_tx_time * (sn->packets_since_sample[size_bin]*ssc->sample_rate/100)) { rix = pick_sample_rate(ssc, an, rt, size_bin); IEEE80211_NOTE(an->an_node.ni_vap, IEEE80211_MSG_RATECTL, - &an->an_node, "size %u sample rate %d current rate %d", - bin_to_size(size_bin), RATE(rix), - RATE(sn->current_rix[size_bin])); + &an->an_node, "size %u sample rate %d %s current rate %d %s", + bin_to_size(size_bin), + dot11rate(rt, rix), + dot11rate_label(rt, rix), + dot11rate(rt, sn->current_rix[size_bin]), + dot11rate_label(rt, sn->current_rix[size_bin])); if (rix != sn->current_rix[size_bin]) { sn->current_sample_rix[size_bin] = rix; } else { @@ -503,6 +510,7 @@ update_stats(struct ath_softc *sc, struc { struct sample_node *sn = ATH_NODE_SAMPLE(an); struct sample_softc *ssc = ATH_SOFTC_SAMPLE(sc); + const HAL_RATE_TABLE *rt = sc->sc_currates; const int size_bin = size_to_bin(frame_size); const int size = bin_to_size(size_bin); int tt, tries_so_far; @@ -574,11 +582,13 @@ update_stats(struct ath_softc *sc, struc if (rix0 == sn->current_sample_rix[size_bin]) { IEEE80211_NOTE(an->an_node.ni_vap, IEEE80211_MSG_RATECTL, &an->an_node, -"%s: size %d %s sample rate %d tries (%d/%d) tt %d avg_tt (%d/%d) nfrm %d nbad %d", +"%s: size %d %s sample rate %d %s tries (%d/%d) tt %d avg_tt (%d/%d) nfrm %d nbad %d", __func__, size, status ? "FAIL" : "OK", - rix0, short_tries, tries, tt, + dot11rate(rt, rix0), + dot11rate_label(rt, rix0), + short_tries, tries, tt, sn->stats[size_bin][rix0].average_tx_time, sn->stats[size_bin][rix0].perfect_tx_time, nframes, nbad); @@ -889,18 +899,24 @@ sample_stats(void *arg, struct ieee80211 uint32_t mask; int rix, y; - printf("\n[%s] refcnt %d static_rix %d ratemask 0x%x\n", + printf("\n[%s] refcnt %d static_rix (%d %s) ratemask 0x%x\n", ether_sprintf(ni->ni_macaddr), ieee80211_node_refcnt(ni), - sn->static_rix, sn->ratemask); + dot11rate(rt, sn->static_rix), + dot11rate_label(rt, sn->static_rix), + sn->ratemask); for (y = 0; y < NUM_PACKET_SIZE_BINS; y++) { printf("[%4u] cur rix %d (%d %s) since switch: packets %d ticks %u\n", bin_to_size(y), sn->current_rix[y], dot11rate(rt, sn->current_rix[y]), dot11rate_label(rt, sn->current_rix[y]), sn->packets_since_switch[y], sn->ticks_since_switch[y]); - printf("[%4u] last sample %d cur sample %d packets sent %d\n", - bin_to_size(y), sn->last_sample_rix[y], - sn->current_sample_rix[y], sn->packets_sent[y]); + printf("[%4u] last sample (%d %s) cur sample (%d %s) packets sent %d\n", + bin_to_size(y), + dot11rate(rt, sn->last_sample_rix[y]), + dot11rate_label(rt, sn->last_sample_rix[y]), + dot11rate(rt, sn->current_sample_rix[y]), + dot11rate_label(rt, sn->current_sample_rix[y]), + sn->packets_sent[y]); printf("[%4u] packets since sample %d sample tt %u\n", bin_to_size(y), sn->packets_since_sample[y], sn->sample_tt[y]); From owner-svn-src-user@FreeBSD.ORG Mon Aug 29 05:57:53 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5BEB4106566C; Mon, 29 Aug 2011 05:57:53 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4C4448FC1A; Mon, 29 Aug 2011 05:57:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7T5vrrr082849; Mon, 29 Aug 2011 05:57:53 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7T5vrUZ082847; Mon, 29 Aug 2011 05:57:53 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108290557.p7T5vrUZ082847@svn.freebsd.org> From: Adrian Chadd Date: Mon, 29 Aug 2011 05:57:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225240 - user/adrian/if_ath_tx/sys/modules/ath X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Aug 2011 05:57:53 -0000 Author: adrian Date: Mon Aug 29 05:57:52 2011 New Revision: 225240 URL: http://svn.freebsd.org/changeset/base/225240 Log: Flip on most of the ath/net80211 options by default Modified: user/adrian/if_ath_tx/sys/modules/ath/Makefile Modified: user/adrian/if_ath_tx/sys/modules/ath/Makefile ============================================================================== --- user/adrian/if_ath_tx/sys/modules/ath/Makefile Sun Aug 28 23:56:53 2011 (r225239) +++ user/adrian/if_ath_tx/sys/modules/ath/Makefile Mon Aug 29 05:57:52 2011 (r225240) @@ -144,9 +144,14 @@ opt_ah.h: echo '#define AH_SUPPORT_AR5416 1' > $@ echo '#define AH_AR5416_INTERRUPT_MITIGATION 1' >> $@ echo '#define AH_DEBUG 1' >> $@ - echo '#define ATH_DEBUG 1' >> $@ + +opt_ath.h: + echo '#define ATH_DEBUG 1' > $@ echo '#define ATH_DIAGAPI 1' >> $@ echo '#define ATH_ENABLE_11N 1' >> $@ - echo '#define IEEE80211_DEBUG 1' >> $@ + +opt_wlan.h: + echo '#define IEEE80211_DEBUG 1' > $@ + echo '#define IEEE80211_SUPPORT_TDMA 1'>> $@ .include From owner-svn-src-user@FreeBSD.ORG Mon Aug 29 05:59:49 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DCF561065670; Mon, 29 Aug 2011 05:59:49 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CD8C98FC0A; Mon, 29 Aug 2011 05:59:49 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7T5xnq2082937; Mon, 29 Aug 2011 05:59:49 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7T5xnhP082935; Mon, 29 Aug 2011 05:59:49 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108290559.p7T5xnhP082935@svn.freebsd.org> From: Adrian Chadd Date: Mon, 29 Aug 2011 05:59:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225241 - user/adrian/if_ath_tx/sys/modules/ath X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Aug 2011 05:59:49 -0000 Author: adrian Date: Mon Aug 29 05:59:49 2011 New Revision: 225241 URL: http://svn.freebsd.org/changeset/base/225241 Log: Bring the net80211 build options in line with the rest of the module defaults. Modified: user/adrian/if_ath_tx/sys/modules/ath/Makefile Modified: user/adrian/if_ath_tx/sys/modules/ath/Makefile ============================================================================== --- user/adrian/if_ath_tx/sys/modules/ath/Makefile Mon Aug 29 05:57:52 2011 (r225240) +++ user/adrian/if_ath_tx/sys/modules/ath/Makefile Mon Aug 29 05:59:49 2011 (r225241) @@ -152,6 +152,7 @@ opt_ath.h: opt_wlan.h: echo '#define IEEE80211_DEBUG 1' > $@ - echo '#define IEEE80211_SUPPORT_TDMA 1'>> $@ + echo '#define IEEE80211_AMPDU_AGE 1'>> $@ + echo '#define IEEE80211_SUPPORT_MESH 1'>> $@ .include From owner-svn-src-user@FreeBSD.ORG Mon Aug 29 06:01:35 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BA45A1065673; Mon, 29 Aug 2011 06:01:35 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AAB768FC15; Mon, 29 Aug 2011 06:01:35 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7T61ZRe083050; Mon, 29 Aug 2011 06:01:35 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7T61ZE7083048; Mon, 29 Aug 2011 06:01:35 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108290601.p7T61ZE7083048@svn.freebsd.org> From: Adrian Chadd Date: Mon, 29 Aug 2011 06:01:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225242 - user/adrian/if_ath_tx/sys/modules/ath X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Aug 2011 06:01:35 -0000 Author: adrian Date: Mon Aug 29 06:01:35 2011 New Revision: 225242 URL: http://svn.freebsd.org/changeset/base/225242 Log: .. and make this line up with what sys/modules/wlan/ does. Modified: user/adrian/if_ath_tx/sys/modules/ath/Makefile Modified: user/adrian/if_ath_tx/sys/modules/ath/Makefile ============================================================================== --- user/adrian/if_ath_tx/sys/modules/ath/Makefile Mon Aug 29 05:59:49 2011 (r225241) +++ user/adrian/if_ath_tx/sys/modules/ath/Makefile Mon Aug 29 06:01:35 2011 (r225242) @@ -140,19 +140,21 @@ SRCS+= dfs_null.c CFLAGS+= -I. -I${.CURDIR}/../../dev/ath -I${.CURDIR}/../../dev/ath/ath_hal +.if !defined(KERNBUILDDIR) opt_ah.h: - echo '#define AH_SUPPORT_AR5416 1' > $@ - echo '#define AH_AR5416_INTERRUPT_MITIGATION 1' >> $@ - echo '#define AH_DEBUG 1' >> $@ + echo '#define AH_SUPPORT_AR5416 1' > ${.TARGET} + echo '#define AH_AR5416_INTERRUPT_MITIGATION 1' >> ${.TARGET} + echo '#define AH_DEBUG 1' >> ${.TARGET} opt_ath.h: - echo '#define ATH_DEBUG 1' > $@ - echo '#define ATH_DIAGAPI 1' >> $@ - echo '#define ATH_ENABLE_11N 1' >> $@ + echo '#define ATH_DEBUG 1' > ${.TARGET} + echo '#define ATH_DIAGAPI 1' >> ${.TARGET} + echo '#define ATH_ENABLE_11N 1' >> ${.TARGET} opt_wlan.h: - echo '#define IEEE80211_DEBUG 1' > $@ - echo '#define IEEE80211_AMPDU_AGE 1'>> $@ - echo '#define IEEE80211_SUPPORT_MESH 1'>> $@ + echo '#define IEEE80211_DEBUG 1' > ${.TARGET} + echo '#define IEEE80211_AMPDU_AGE 1'>> ${.TARGET} + echo '#define IEEE80211_SUPPORT_MESH 1'>> ${.TARGET} +.endif .include From owner-svn-src-user@FreeBSD.ORG Mon Aug 29 10:15:16 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 681D4106566B; Mon, 29 Aug 2011 10:15:16 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 57AC68FC0C; Mon, 29 Aug 2011 10:15:16 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7TAFGWa090592; Mon, 29 Aug 2011 10:15:16 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7TAFGgM090589; Mon, 29 Aug 2011 10:15:16 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108291015.p7TAFGgM090589@svn.freebsd.org> From: Adrian Chadd Date: Mon, 29 Aug 2011 10:15:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225243 - user/adrian/if_ath_tx/sys/dev/ath X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Aug 2011 10:15:16 -0000 Author: adrian Date: Mon Aug 29 10:15:15 2011 New Revision: 225243 URL: http://svn.freebsd.org/changeset/base/225243 Log: Begin refactoring out the rts/cts rate/duration code, in preparation for supporting delayed rate lookups. The intention is to support doing a rate lookup just before the packet is queued to the hardware (if required), so software retransmits do not simply use the old rate. This isn't yet very well tested, either on legacy or current NICs. Some further work is needed to enable 11n protection, as well as signaling whether a rate lookup is required or not (as there may be static information passed in to ath_tx_raw_xmit().) Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Mon Aug 29 06:01:35 2011 (r225242) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Mon Aug 29 10:15:15 2011 (r225243) @@ -650,7 +650,7 @@ ath_tx_tag_crypto(struct ath_softc *sc, static uint8_t ath_tx_get_rtscts_rate(struct ath_hal *ah, const HAL_RATE_TABLE *rt, - int rix, int cix, int shortPreamble) + int cix, int shortPreamble) { uint8_t ctsrate; @@ -670,7 +670,6 @@ ath_tx_get_rtscts_rate(struct ath_hal *a return ctsrate; } - /* * Calculate the RTS/CTS duration for legacy frames. */ @@ -716,6 +715,80 @@ ath_tx_calc_ctsduration(struct ath_hal * return ctsduration; } +/* + * Update the given ath_buf with updated rts/cts setup and duration + * values. + * + * To support rate lookups for each software retry, the rts/cts rate + * and cts duration must be re-calculated. + * + * This function assumes the RTS/CTS flags have been set as needed; + * mrr has been disabled; and the rate control lookup has been done. + * + * XXX TODO: MRR need only be disabled for the pre-11n NICs. + * XXX The 11n NICs support per-rate RTS/CTS configuration. + */ +static void +ath_tx_set_rtscts(struct ath_softc *sc, struct ath_buf *bf) +{ + uint16_t ctsduration = 0; + uint8_t ctsrate = 0; + uint8_t rix = bf->bf_state.bfs_rc[0].rix; + uint8_t cix = 0; + const HAL_RATE_TABLE *rt = sc->sc_currates; + + /* + * No RTS/CTS enabled? Don't bother. + */ + if ((bf->bf_state.bfs_flags & + (HAL_TXDESC_RTSENA | HAL_TXDESC_CTSENA)) == 0) { + /* XXX is this really needed? */ + bf->bf_state.bfs_ctsrate = 0; + bf->bf_state.bfs_ctsduration = 0; + return; + } + + /* + * If protection is enabled, use the protection rix control + * rate. Otherwise use the rate0 control rate. + */ + if (bf->bf_state.bfs_doprot) + rix = sc->sc_protrix; + else + rix = bf->bf_state.bfs_rc[0].rix; + + /* + * If the raw path has hard-coded ctsrate0 to something, + * use it. + */ + if (bf->bf_state.bfs_ctsrate0 != 0) + cix = ath_tx_findrix(sc, bf->bf_state.bfs_ctsrate0); + else + /* Control rate from above */ + cix = rt->info[rix].controlRate; + + /* Calculate the rtscts rate for the given cix */ + ctsrate = ath_tx_get_rtscts_rate(sc->sc_ah, rt, cix, + bf->bf_state.bfs_shpream); + + /* The 11n chipsets do ctsduration calculations for you */ + if (! ath_tx_is_11n(sc)) + ctsduration = ath_tx_calc_ctsduration(sc->sc_ah, rix, cix, + bf->bf_state.bfs_shpream, bf->bf_state.bfs_pktlen, + rt, bf->bf_state.bfs_flags); + + /* Squirrel away in ath_buf */ + bf->bf_state.bfs_ctsrate = ctsrate; + bf->bf_state.bfs_ctsduration = ctsduration; + + /* + * Must disable multi-rate retry when using RTS/CTS. + * XXX TODO: only for pre-11n NICs. + */ + bf->bf_state.bfs_ismrr = 0; + bf->bf_state.bfs_try0 = + bf->bf_state.bfs_rc[0].tries = ATH_TXMGTTRY; /* XXX ew */ +} /* * Setup the descriptor chain for a normal or fast-frame @@ -771,11 +844,21 @@ ath_tx_set_ratectrl(struct ath_softc *sc { struct ath_rc_series *rc = bf->bf_state.bfs_rc; + /* If mrr is disabled, blank tries 1, 2, 3 */ + if (! bf->bf_state.bfs_ismrr) + rc[1].tries = rc[2].tries = rc[3].tries = 0; + + /* + * Always call - that way a retried descriptor will + * have the MRR fields overwritten. + * + * XXX TODO: see if this is really needed - setting up + * the first descriptor should set the MRR fields to 0 + * for us anyway. + */ if (ath_tx_is_11n(sc)) { - /* Always setup rate series */ ath_buf_set_rate(sc, ni, bf); - } else if (bf->bf_state.bfs_ismrr) { - /* Only call for legacy NICs if MRR */ + } else { ath_hal_setupxtxdesc(sc->sc_ah, bf->bf_desc , rc[1].ratecode, rc[1].tries , rc[2].ratecode, rc[2].tries @@ -796,12 +879,11 @@ ath_tx_normal_setup(struct ath_softc *sc const struct chanAccParams *cap = &ic->ic_wme.wme_chanParams; int error, iswep, ismcast, isfrag, ismrr; int keyix, hdrlen, pktlen, try0; - u_int8_t rix, txrate, ctsrate; - u_int8_t cix = 0xff; /* NB: silence compiler */ + u_int8_t rix, txrate; struct ath_desc *ds; struct ath_txq *txq; struct ieee80211_frame *wh; - u_int subtype, flags, ctsduration; + u_int subtype, flags; HAL_PKT_TYPE atype; const HAL_RATE_TABLE *rt; HAL_BOOL shortPreamble; @@ -955,7 +1037,6 @@ ath_tx_normal_setup(struct ath_softc *sc } else if (pktlen > vap->iv_rtsthreshold && (ni->ni_ath_flags & IEEE80211_NODE_FF) == 0) { flags |= HAL_TXDESC_RTSENA; /* RTS based on frame length */ - cix = rt->info[rix].controlRate; sc->sc_stats.ast_tx_rts++; } if (flags & HAL_TXDESC_NOACK) /* NB: avoid double counting */ @@ -978,22 +1059,20 @@ ath_tx_normal_setup(struct ath_softc *sc if ((ic->ic_flags & IEEE80211_F_USEPROT) && rt->info[rix].phy == IEEE80211_T_OFDM && (flags & HAL_TXDESC_NOACK) == 0) { + bf->bf_state.bfs_doprot = 1; /* XXX fragments must use CCK rates w/ protection */ - if (ic->ic_protmode == IEEE80211_PROT_RTSCTS) + if (ic->ic_protmode == IEEE80211_PROT_RTSCTS) { flags |= HAL_TXDESC_RTSENA; - else if (ic->ic_protmode == IEEE80211_PROT_CTSONLY) + } else if (ic->ic_protmode == IEEE80211_PROT_CTSONLY) { flags |= HAL_TXDESC_CTSENA; - if (isfrag) { - /* - * For frags it would be desirable to use the - * highest CCK rate for RTS/CTS. But stations - * farther away may detect it at a lower CCK rate - * so use the configured protection rate instead - * (for now). - */ - cix = rt->info[sc->sc_protrix].controlRate; - } else - cix = rt->info[sc->sc_protrix].controlRate; + } + /* + * For frags it would be desirable to use the + * highest CCK rate for RTS/CTS. But stations + * farther away may detect it at a lower CCK rate + * so use the configured protection rate instead + * (for now). + */ sc->sc_stats.ast_tx_protect++; } @@ -1051,25 +1130,6 @@ ath_tx_normal_setup(struct ath_softc *sc } /* - * Calculate RTS/CTS rate and duration if needed. - */ - ctsduration = 0; - if (flags & (HAL_TXDESC_RTSENA|HAL_TXDESC_CTSENA)) { - ctsrate = ath_tx_get_rtscts_rate(ah, rt, rix, cix, shortPreamble); - - /* The 11n chipsets do ctsduration calculations for you */ - if (! ath_tx_is_11n(sc)) - ctsduration = ath_tx_calc_ctsduration(ah, rix, cix, shortPreamble, - pktlen, rt, flags); - /* - * Must disable multi-rate retry when using RTS/CTS. - */ - ismrr = 0; - try0 = ATH_TXMGTTRY; /* XXX */ - } else - ctsrate = 0; - - /* * Determine if a tx interrupt should be generated for * this descriptor. We take a tx interrupt to reap * descriptors when the h/w hits an EOL condition or @@ -1145,8 +1205,9 @@ ath_tx_normal_setup(struct ath_softc *sc bf->bf_state.bfs_shpream = shortPreamble; /* XXX this should be done in ath_tx_setrate() */ - bf->bf_state.bfs_ctsrate = ctsrate; - bf->bf_state.bfs_ctsduration = ctsduration; + bf->bf_state.bfs_ctsrate0 = 0; /* ie, no hard-coded ctsrate */ + bf->bf_state.bfs_ctsrate = 0; /* calculated later */ + bf->bf_state.bfs_ctsduration = 0; bf->bf_state.bfs_ismrr = ismrr; /* @@ -1290,6 +1351,7 @@ ath_tx_start(struct ath_softc *sc, struc */ if (txq == &avp->av_mcastq) { /* Setup the descriptor before handoff */ + ath_tx_set_rtscts(sc, bf); ath_tx_setds(sc, bf); ath_tx_set_ratectrl(sc, ni, bf); ath_tx_chaindesclist(sc, bf); @@ -1315,6 +1377,7 @@ ath_tx_start(struct ath_softc *sc, struc "%s: BAR: TX'ing direct\n", __func__); /* Setup the descriptor before handoff */ + ath_tx_set_rtscts(sc, bf); ath_tx_setds(sc, bf); ath_tx_set_ratectrl(sc, ni, bf); ath_tx_chaindesclist(sc, bf); @@ -1333,6 +1396,7 @@ ath_tx_start(struct ath_softc *sc, struc */ /* Setup the descriptor before handoff */ + ath_tx_set_rtscts(sc, bf); ath_tx_setds(sc, bf); ath_tx_set_ratectrl(sc, ni, bf); ath_tx_chaindesclist(sc, bf); @@ -1356,9 +1420,9 @@ ath_tx_raw_start(struct ath_softc *sc, s struct ieee80211vap *vap = ni->ni_vap; int error, ismcast, ismrr; int keyix, hdrlen, pktlen, try0, txantenna; - u_int8_t rix, cix, txrate, ctsrate; + u_int8_t rix, txrate; struct ieee80211_frame *wh; - u_int flags, ctsduration; + u_int flags; HAL_PKT_TYPE atype; const HAL_RATE_TABLE *rt; struct ath_desc *ds; @@ -1405,8 +1469,11 @@ ath_tx_raw_start(struct ath_softc *sc, s flags |= HAL_TXDESC_INTREQ; /* force interrupt */ if (params->ibp_flags & IEEE80211_BPF_RTS) flags |= HAL_TXDESC_RTSENA; - else if (params->ibp_flags & IEEE80211_BPF_CTS) + else if (params->ibp_flags & IEEE80211_BPF_CTS) { + /* XXX assume 11g/11n protection? */ + bf->bf_state.bfs_doprot = 1; flags |= HAL_TXDESC_CTSENA; + } /* XXX leave ismcast to injector? */ if ((params->ibp_flags & IEEE80211_BPF_NOACK) || ismcast) flags |= HAL_TXDESC_NOACK; @@ -1424,21 +1491,12 @@ ath_tx_raw_start(struct ath_softc *sc, s if (txantenna == 0) /* XXX? */ txantenna = sc->sc_txantenna; - ctsduration = 0; - if (flags & (HAL_TXDESC_RTSENA|HAL_TXDESC_CTSENA)) { - cix = ath_tx_findrix(sc, params->ibp_ctsrate); - ctsrate = ath_tx_get_rtscts_rate(ah, rt, rix, cix, params->ibp_flags & IEEE80211_BPF_SHORTPRE); - /* The 11n chipsets do ctsduration calculations for you */ - if (! ath_tx_is_11n(sc)) - ctsduration = ath_tx_calc_ctsduration(ah, rix, cix, - params->ibp_flags & IEEE80211_BPF_SHORTPRE, pktlen, - rt, flags); - /* - * Must disable multi-rate retry when using RTS/CTS. - */ - ismrr = 0; /* XXX */ - } else - ctsrate = 0; + /* + * Since ctsrate is fixed, store it away for later + * use when the descriptor fields are being set. + */ + if (flags & (HAL_TXDESC_RTSENA|HAL_TXDESC_CTSENA)) + bf->bf_state.bfs_ctsrate0 = params->ibp_ctsrate; pri = params->ibp_pri & 3; /* Override pri if the frame isn't a QoS one */ @@ -1492,8 +1550,8 @@ ath_tx_raw_start(struct ath_softc *sc, s !! (params->ibp_flags & IEEE80211_BPF_SHORTPRE); /* XXX this should be done in ath_tx_setrate() */ - bf->bf_state.bfs_ctsrate = ctsrate; - bf->bf_state.bfs_ctsduration = ctsduration; + bf->bf_state.bfs_ctsrate = 0; + bf->bf_state.bfs_ctsduration = 0; bf->bf_state.bfs_ismrr = ismrr; /* Blank the legacy rate array */ @@ -1549,6 +1607,7 @@ ath_tx_raw_start(struct ath_softc *sc, s __func__, do_override); if (do_override) { + ath_tx_set_rtscts(sc, bf); ath_tx_setds(sc, bf); ath_tx_set_ratectrl(sc, ni, bf); ath_tx_chaindesclist(sc, bf); @@ -3028,6 +3087,7 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft __func__); ATH_TXQ_REMOVE(atid, bf, bf_list); bf->bf_state.bfs_aggr = 0; + ath_tx_set_rtscts(sc, bf); ath_tx_setds(sc, bf); ath_tx_chaindesclist(sc, bf); ath_hal_clr11n_aggr(sc->sc_ah, bf->bf_desc); @@ -3067,6 +3127,7 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft DPRINTF(sc, ATH_DEBUG_SW_TX_AGGR, "%s: single-frame aggregate\n", __func__); bf->bf_state.bfs_aggr = 0; + ath_tx_set_rtscts(sc, bf); ath_tx_setds(sc, bf); ath_tx_chaindesclist(sc, bf); ath_hal_clr11n_aggr(sc->sc_ah, bf->bf_desc); @@ -3190,6 +3251,7 @@ ath_tx_tid_hw_queue_norm(struct ath_soft bf->bf_comp = ath_tx_normal_comp; /* Program descriptors + rate control */ + ath_tx_set_rtscts(sc, bf); ath_tx_setds(sc, bf); ath_tx_chaindesclist(sc, bf); ath_tx_set_ratectrl(sc, ni, bf); Modified: user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Mon Aug 29 06:01:35 2011 (r225242) +++ user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Mon Aug 29 10:15:15 2011 (r225243) @@ -213,6 +213,7 @@ struct ath_buf { int bfs_shpream:1; /* use short preamble */ int bfs_istxfrag:1; /* is fragmented */ int bfs_ismrr:1; /* do multi-rate TX retry */ + int bfs_doprot:1; /* do RTS/CTS based protection */ int bfs_nfl; /* next fragment length */ /* @@ -226,6 +227,7 @@ struct ath_buf { int bfs_flags; /* HAL descriptor flags */ int bfs_txrate0; /* first TX rate */ int bfs_try0; /* first try count */ + uint8_t bfs_ctsrate0; /* Non-zero - use this as ctsrate */ int bfs_keyix; /* crypto key index */ int bfs_txpower; /* tx power */ int bfs_txantenna; /* TX antenna config */ From owner-svn-src-user@FreeBSD.ORG Mon Aug 29 13:01:24 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 28F78106564A; Mon, 29 Aug 2011 13:01:24 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 191428FC15; Mon, 29 Aug 2011 13:01:24 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7TD1N7g097724; Mon, 29 Aug 2011 13:01:23 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7TD1NG3097720; Mon, 29 Aug 2011 13:01:23 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108291301.p7TD1NG3097720@svn.freebsd.org> From: Adrian Chadd Date: Mon, 29 Aug 2011 13:01:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225245 - in user/adrian/if_ath_tx/sys: conf net80211 X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Aug 2011 13:01:24 -0000 Author: adrian Date: Mon Aug 29 13:01:23 2011 New Revision: 225245 URL: http://svn.freebsd.org/changeset/base/225245 Log: Make net80211 aggressive more configurable. Modified: user/adrian/if_ath_tx/sys/conf/options user/adrian/if_ath_tx/sys/net80211/ieee80211_output.c user/adrian/if_ath_tx/sys/net80211/ieee80211_proto.c Modified: user/adrian/if_ath_tx/sys/conf/options ============================================================================== --- user/adrian/if_ath_tx/sys/conf/options Mon Aug 29 10:29:05 2011 (r225244) +++ user/adrian/if_ath_tx/sys/conf/options Mon Aug 29 13:01:23 2011 (r225245) @@ -841,6 +841,7 @@ IEEE80211_SUPPORT_MESH opt_wlan.h IEEE80211_SUPPORT_SUPERG opt_wlan.h IEEE80211_SUPPORT_TDMA opt_wlan.h IEEE80211_ALQ opt_wlan.h +IEEE80211_SUPPORT_AGGRMODE opt_wlan.h # 802.11 TDMA support TDMA_SLOTLEN_DEFAULT opt_tdma.h Modified: user/adrian/if_ath_tx/sys/net80211/ieee80211_output.c ============================================================================== --- user/adrian/if_ath_tx/sys/net80211/ieee80211_output.c Mon Aug 29 10:29:05 2011 (r225244) +++ user/adrian/if_ath_tx/sys/net80211/ieee80211_output.c Mon Aug 29 13:01:23 2011 (r225245) @@ -2830,6 +2830,7 @@ ieee80211_beacon_update(struct ieee80211 if (vap->iv_flags & IEEE80211_F_WME) { struct ieee80211_wme_state *wme = &ic->ic_wme; +#ifdef IEEE80211_SUPPORT_AGGRMODE /* * Check for agressive mode change. When there is * significant high priority traffic in the BSS @@ -2862,6 +2863,8 @@ ieee80211_beacon_update(struct ieee80211 wme->wme_hipri_traffic = wme->wme_hipri_switch_hysteresis; } +#endif /* IEEE80211_SUPPORT_AGGRMODE */ + if (isset(bo->bo_flags, IEEE80211_BEACON_WME)) { (void) ieee80211_add_wme_param(bo->bo_wme, wme); clrbit(bo->bo_flags, IEEE80211_BEACON_WME); Modified: user/adrian/if_ath_tx/sys/net80211/ieee80211_proto.c ============================================================================== --- user/adrian/if_ath_tx/sys/net80211/ieee80211_proto.c Mon Aug 29 10:29:05 2011 (r225244) +++ user/adrian/if_ath_tx/sys/net80211/ieee80211_proto.c Mon Aug 29 13:01:23 2011 (r225245) @@ -974,6 +974,7 @@ ieee80211_wme_initparams(struct ieee8021 void ieee80211_wme_updateparams_locked(struct ieee80211vap *vap) { +#ifdef IEEE80211_SUPPORT_AGGRMODE static const paramType aggrParam[IEEE80211_MODE_MAX] = { [IEEE80211_MODE_AUTO] = { 2, 4, 10, 64, 0 }, [IEEE80211_MODE_11A] = { 2, 4, 10, 64, 0 }, @@ -988,10 +989,14 @@ ieee80211_wme_updateparams_locked(struct [IEEE80211_MODE_11NA] = { 2, 4, 10, 64, 0 }, /* XXXcheck*/ [IEEE80211_MODE_11NG] = { 2, 4, 10, 64, 0 }, /* XXXcheck*/ }; + struct wmeParams *bssp; + +#endif /* IEEE80211_SUPPORT_AGGRMODE */ + struct ieee80211com *ic = vap->iv_ic; struct ieee80211_wme_state *wme = &ic->ic_wme; const struct wmeParams *wmep; - struct wmeParams *chanp, *bssp; + struct wmeParams *chanp; enum ieee80211_phymode mode; int i; @@ -1026,6 +1031,7 @@ ieee80211_wme_updateparams_locked(struct else mode = IEEE80211_MODE_AUTO; +#ifdef IEEE80211_SUPPORT_AGGRMODE /* * This implements agressive mode as found in certain * vendors' AP's. When there is significant high @@ -1081,6 +1087,8 @@ ieee80211_wme_updateparams_locked(struct "update %s (chan+bss) logcwmin %u\n", ieee80211_wme_acnames[WME_AC_BE], chanp->wmep_logcwmin); } +#endif /* IEEE80211_SUPPORT_AGGRMODE */ + if (vap->iv_opmode == IEEE80211_M_HOSTAP) { /* XXX ibss? */ /* * Arrange for a beacon update and bump the parameter From owner-svn-src-user@FreeBSD.ORG Mon Aug 29 15:51:13 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1F6411065678; Mon, 29 Aug 2011 15:51:13 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0FB9C8FC19; Mon, 29 Aug 2011 15:51:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7TFpCvQ002976; Mon, 29 Aug 2011 15:51:12 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7TFpCxM002972; Mon, 29 Aug 2011 15:51:12 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108291551.p7TFpCxM002972@svn.freebsd.org> From: Gabor Kovesdan Date: Mon, 29 Aug 2011 15:51:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225246 - user/gabor/grep/trunk X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Aug 2011 15:51:13 -0000 Author: gabor Date: Mon Aug 29 15:51:12 2011 New Revision: 225246 URL: http://svn.freebsd.org/changeset/base/225246 Log: - Add support for bz[ef]?grep Submitted by: dim Modified: user/gabor/grep/trunk/Makefile user/gabor/grep/trunk/grep.1 user/gabor/grep/trunk/grep.c Modified: user/gabor/grep/trunk/Makefile ============================================================================== --- user/gabor/grep/trunk/Makefile Mon Aug 29 13:01:23 2011 (r225245) +++ user/gabor/grep/trunk/Makefile Mon Aug 29 15:51:12 2011 (r225246) @@ -25,13 +25,19 @@ LINKS= ${BINDIR}/grep ${BINDIR}/egrep \ ${BINDIR}/grep ${BINDIR}/fgrep \ ${BINDIR}/grep ${BINDIR}/zgrep \ ${BINDIR}/grep ${BINDIR}/zegrep \ - ${BINDIR}/grep ${BINDIR}/zfgrep + ${BINDIR}/grep ${BINDIR}/zfgrep \ + ${BINDIR}/grep ${BINDIR}/bzgrep \ + ${BINDIR}/grep ${BINDIR}/bzegrep \ + ${BINDIR}/grep ${BINDIR}/bzfgrep MLINKS= grep.1 egrep.1 \ grep.1 fgrep.1 \ grep.1 zgrep.1 \ grep.1 zegrep.1 \ - grep.1 zfgrep.1 + grep.1 zfgrep.1 \ + grep.1 bzgrep.1 \ + grep.1 bzegrep.1 \ + grep.1 bzfgrep.1 .endif LDADD= -lz -lbz2 Modified: user/gabor/grep/trunk/grep.1 ============================================================================== --- user/gabor/grep/trunk/grep.1 Mon Aug 29 13:01:23 2011 (r225245) +++ user/gabor/grep/trunk/grep.1 Mon Aug 29 15:51:12 2011 (r225246) @@ -35,7 +35,8 @@ .Os .Sh NAME .Nm grep , egrep , fgrep , -.Nm zgrep , zegrep , zfgrep +.Nm zgrep , zegrep , zfgrep , +.Nm bzgrep , bzegrep , bzfgrep .Nd file pattern searcher .Sh SYNOPSIS .Nm grep @@ -103,6 +104,19 @@ or .Xr gzip 1 compression utilities. .Pp +.Nm bzgrep , +.Nm bzegrep , +and +.Nm bzfgrep +act like +.Nm grep , +.Nm egrep , +and +.Nm fgrep , +respectively, but accept input files compressed with the +.Xr bzip2 1 +compression utility. +.Pp The following options are available: .Bl -tag -width indent .It Fl A Ar num , Fl Fl after-context Ns = Ns Ar num @@ -457,6 +471,7 @@ looking for either 19, 20, or 25. .Xr ed 1 , .Xr ex 1 , .Xr gzip 1 , +.Xr bzip2 1 , .Xr sed 1 , .Xr re_format 7 .Sh STANDARDS Modified: user/gabor/grep/trunk/grep.c ============================================================================== --- user/gabor/grep/trunk/grep.c Mon Aug 29 13:01:23 2011 (r225245) +++ user/gabor/grep/trunk/grep.c Mon Aug 29 15:51:12 2011 (r225246) @@ -313,7 +313,7 @@ int main(int argc, char *argv[]) { char **aargv, **eargv, *eopts; - char *ep; + char *pn, *ep; unsigned long long l; unsigned int aargc, eargc, i; int c, lastc, needpattern, newarg, prevoptind; @@ -327,30 +327,21 @@ main(int argc, char *argv[]) /* Check what is the program name of the binary. In this way we can have all the funcionalities in one binary without the need of scripting and using ugly hacks. */ - switch (__progname[0]) { + pn = __progname; + if (pn[0] == 'b' && pn[1] == 'z') { + filebehave = FILE_BZIP; + pn += 2; + } else if (pn[0] == 'z') { + filebehave = FILE_GZIP; + pn += 1; + } + switch (pn[0]) { case 'e': grepbehave = GREP_EXTENDED; break; case 'f': grepbehave = GREP_FIXED; break; - case 'g': - grepbehave = GREP_BASIC; - break; - case 'z': - filebehave = FILE_GZIP; - switch(__progname[1]) { - case 'e': - grepbehave = GREP_EXTENDED; - break; - case 'f': - grepbehave = GREP_FIXED; - break; - case 'g': - grepbehave = GREP_BASIC; - break; - } - break; } lastc = '\0'; From owner-svn-src-user@FreeBSD.ORG Mon Aug 29 19:11:46 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EDEC71065672; Mon, 29 Aug 2011 19:11:45 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DEB0B8FC08; Mon, 29 Aug 2011 19:11:45 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7TJBjs3009013; Mon, 29 Aug 2011 19:11:45 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7TJBjpx009011; Mon, 29 Aug 2011 19:11:45 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108291911.p7TJBjpx009011@svn.freebsd.org> From: Gabor Kovesdan Date: Mon, 29 Aug 2011 19:11:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225248 - user/gabor/grep/trunk X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Aug 2011 19:11:46 -0000 Author: gabor Date: Mon Aug 29 19:11:45 2011 New Revision: 225248 URL: http://svn.freebsd.org/changeset/base/225248 Log: - Merge a static function into the caller since it is not called form elsewhere Modified: user/gabor/grep/trunk/file.c Modified: user/gabor/grep/trunk/file.c ============================================================================== --- user/gabor/grep/trunk/file.c Mon Aug 29 16:24:58 2011 (r225247) +++ user/gabor/grep/trunk/file.c Mon Aug 29 19:11:45 2011 (r225248) @@ -186,56 +186,49 @@ error: return (NULL); } -static inline struct file * -grep_file_init(struct file *f) +/* + * Opens a file for processing. + */ +struct file * +grep_open(const char *path) { + struct file *f; + + f = grep_malloc(sizeof *f); + memset(f, 0, sizeof *f); + if (path == NULL) { + /* Processing stdin implies --line-buffered. */ + lbflag = true; + f->fd = STDIN_FILENO; + } else if ((f->fd = open(path, O_RDONLY)) == -1) + goto error1; if (filebehave == FILE_GZIP && (gzbufdesc = gzdopen(f->fd, "r")) == NULL) - goto error; + goto error2; if (filebehave == FILE_BZIP && (bzbufdesc = BZ2_bzdopen(f->fd, "r")) == NULL) - goto error; + goto error2; /* Fill read buffer, also catches errors early */ if (grep_refill(f) != 0) - goto error; + goto error2; /* Check for binary stuff, if necessary */ if (binbehave != BINFILE_TEXT && memchr(bufpos, '\0', bufrem) != NULL) - f->binary = true; + f->binary = true; return (f); -error: + +error2: close(f->fd); +error1: free(f); return (NULL); } /* - * Opens a file for processing. - */ -struct file * -grep_open(const char *path) -{ - struct file *f; - - f = grep_malloc(sizeof *f); - memset(f, 0, sizeof *f); - if (path == NULL) { - /* Processing stdin implies --line-buffered. */ - lbflag = true; - f->fd = STDIN_FILENO; - } else if ((f->fd = open(path, O_RDONLY)) == -1) { - free(f); - return (NULL); - } - - return (grep_file_init(f)); -} - -/* * Closes a file. */ void From owner-svn-src-user@FreeBSD.ORG Mon Aug 29 20:36:22 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 01DAB10656B8; Mon, 29 Aug 2011 20:36:22 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E63848FC12; Mon, 29 Aug 2011 20:36:21 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7TKaLmk011692; Mon, 29 Aug 2011 20:36:21 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7TKaLgL011686; Mon, 29 Aug 2011 20:36:21 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108292036.p7TKaLgL011686@svn.freebsd.org> From: Gabor Kovesdan Date: Mon, 29 Aug 2011 20:36:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225251 - user/gabor/grep/trunk X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Aug 2011 20:36:22 -0000 Author: gabor Date: Mon Aug 29 20:36:21 2011 New Revision: 225251 URL: http://svn.freebsd.org/changeset/base/225251 Log: - Add support for xz[ef]?grep (1) and lz[ef]?grep. The former handles xz(1) compressed files and the latter lzma(1) compressed files. The -X and -M command-line options can also be used respectively. Suggested by: naddy (1) Modified: user/gabor/grep/trunk/Makefile user/gabor/grep/trunk/file.c user/gabor/grep/trunk/grep.1 user/gabor/grep/trunk/grep.c user/gabor/grep/trunk/grep.h Modified: user/gabor/grep/trunk/Makefile ============================================================================== --- user/gabor/grep/trunk/Makefile Mon Aug 29 20:00:57 2011 (r225250) +++ user/gabor/grep/trunk/Makefile Mon Aug 29 20:36:21 2011 (r225251) @@ -28,7 +28,13 @@ LINKS= ${BINDIR}/grep ${BINDIR}/egrep \ ${BINDIR}/grep ${BINDIR}/zfgrep \ ${BINDIR}/grep ${BINDIR}/bzgrep \ ${BINDIR}/grep ${BINDIR}/bzegrep \ - ${BINDIR}/grep ${BINDIR}/bzfgrep + ${BINDIR}/grep ${BINDIR}/bzfgrep \ + ${BINDIR}/grep ${BINDIR}/xzgrep \ + ${BINDIR}/grep ${BINDIR}/xzefgrep \ + ${BINDIR}/grep ${BINDIR}/xzfgrep \ + ${BINDIR}/grep ${BINDIR}/lzgrep \ + ${BINDIR}/grep ${BINDIR}/lzegrep \ + ${BINDIR}/grep ${BINDIR}/lzfgrep MLINKS= grep.1 egrep.1 \ grep.1 fgrep.1 \ @@ -37,11 +43,17 @@ MLINKS= grep.1 egrep.1 \ grep.1 zfgrep.1 \ grep.1 bzgrep.1 \ grep.1 bzegrep.1 \ - grep.1 bzfgrep.1 + grep.1 bzfgrep.1 \ + grep.1 xzgrep.1 \ + grep.1 xzegrep.1 \ + grep.1 xzfgrep.1 \ + grep.1 lzgrep.1 \ + grep.1 lzegrep.1 \ + grep.1 lzfgrep.1 .endif -LDADD= -lz -lbz2 -DPADD= ${LIBZ} ${LIBBZ2} +LDADD= -lz -lbz2 -llzma +DPADD= ${LIBZ} ${LIBBZ2} ${LIBLZMA} .if !defined(WITHOUT_GNU_COMPAT) CFLAGS+= -I/usr/include/gnu Modified: user/gabor/grep/trunk/file.c ============================================================================== --- user/gabor/grep/trunk/file.c Mon Aug 29 20:00:57 2011 (r225250) +++ user/gabor/grep/trunk/file.c Mon Aug 29 20:36:21 2011 (r225251) @@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -56,6 +57,7 @@ __FBSDID("$FreeBSD$"); static gzFile gzbufdesc; static BZFILE* bzbufdesc; +static lzma_stream lstrm = LZMA_STREAM_INIT; static unsigned char buffer[MAXBUFSIZ]; static unsigned char *bufpos; @@ -101,6 +103,35 @@ grep_refill(struct file *f) /* Make sure we exit with an error */ nr = -1; } + } else if ((filebehave == FILE_XZ) || (filebehave == FILE_LZMA)) { + lzma_action action = LZMA_RUN; + uint8_t in_buf[MAXBUFSIZ]; + lzma_ret ret; + + ret = (filebehave == FILE_XZ) ? + lzma_stream_decoder(&lstrm, UINT64_MAX, + LZMA_CONCATENATED) : + lzma_alone_decoder(&lstrm, UINT64_MAX); + + if (ret != LZMA_OK) + return (-1); + + lstrm.next_out = buffer; + lstrm.avail_out = MAXBUFSIZ; + lstrm.next_in = in_buf; + lstrm.avail_in = read(f->fd, in_buf, MAXBUFSIZ); + + if (lstrm.avail_in < 0) + return (-1); + else if (lstrm.avail_in == 0) + action = LZMA_FINISH; + + ret = lzma_code(&lstrm, action); + + if (ret != LZMA_OK && ret != LZMA_STREAM_END) + return (-1); + bufrem = MAXBUFSIZ - lstrm.avail_out; + return (0); } else nr = read(f->fd, buffer, MAXBUFSIZ); Modified: user/gabor/grep/trunk/grep.1 ============================================================================== --- user/gabor/grep/trunk/grep.1 Mon Aug 29 20:00:57 2011 (r225250) +++ user/gabor/grep/trunk/grep.1 Mon Aug 29 20:36:21 2011 (r225251) @@ -30,13 +30,15 @@ .\" .\" @(#)grep.1 8.3 (Berkeley) 4/18/94 .\" -.Dd July 28, 2010 +.Dd August 29, 2011 .Dt GREP 1 .Os .Sh NAME .Nm grep , egrep , fgrep , .Nm zgrep , zegrep , zfgrep , .Nm bzgrep , bzegrep , bzfgrep +.Nm xzgrep , xzegrep , xzfgrep +.Nm lzgrep , lzegrep , lzfgrep .Nd file pattern searcher .Sh SYNOPSIS .Nm grep @@ -117,6 +119,32 @@ respectively, but accept input files com .Xr bzip2 1 compression utility. .Pp +.Nm xzgrep , +.Nm xzegrep , +and +.Nm xzfgrep +act like +.Nm grep , +.Nm egrep , +and +.Nm fgrep , +respectively, but accept input files compressed with the +.Xr xz 1 +compression utility. +.Pp +.Nm lzgrep , +.Nm lzegrep , +and +.Nm lzfgrep +act like +.Nm grep , +.Nm egrep , +and +.Nm fgrep , +respectively, but accept input files compressed with the +.Xr lzma 1 +compression utility. +.Pp The following options are available: .Bl -tag -width indent .It Fl A Ar num , Fl Fl after-context Ns = Ns Ar num Modified: user/gabor/grep/trunk/grep.c ============================================================================== --- user/gabor/grep/trunk/grep.c Mon Aug 29 20:00:57 2011 (r225250) +++ user/gabor/grep/trunk/grep.c Mon Aug 29 20:36:21 2011 (r225251) @@ -165,7 +165,7 @@ usage(void) exit(2); } -static const char *optstr = "0123456789A:B:C:D:EFGHIJLOPSRUVZabcd:e:f:hilm:nopqrsuvwxy"; +static const char *optstr = "0123456789A:B:C:D:EFGHIJMLOPSRUVZabcd:e:f:hilm:nopqrsuvwxXy"; struct option long_options[] = { @@ -201,6 +201,7 @@ struct option long_options[] = {"files-with-matches", no_argument, NULL, 'l'}, {"files-without-match", no_argument, NULL, 'L'}, {"max-count", required_argument, NULL, 'm'}, + {"lzma", no_argument, NULL, 'M'}, {"line-number", no_argument, NULL, 'n'}, {"only-matching", no_argument, NULL, 'o'}, {"quiet", no_argument, NULL, 'q'}, @@ -213,6 +214,7 @@ struct option long_options[] = {"version", no_argument, NULL, 'V'}, {"word-regexp", no_argument, NULL, 'w'}, {"line-regexp", no_argument, NULL, 'x'}, + {"xz", no_argument, NULL, 'X'}, {"decompress", no_argument, NULL, 'Z'}, {NULL, no_argument, NULL, 0} }; @@ -331,6 +333,12 @@ main(int argc, char *argv[]) if (pn[0] == 'b' && pn[1] == 'z') { filebehave = FILE_BZIP; pn += 2; + } else if (pn[0] == 'x' && pn[1] == 'z') { + filebehave = FILE_XZ; + pn += 2; + } else if (pn[0] == 'l' && pn[1] == 'z') { + filebehave = FILE_LZMA; + pn += 2; } else if (pn[0] == 'z') { filebehave = FILE_GZIP; pn += 1; @@ -505,6 +513,9 @@ main(int argc, char *argv[]) err(2, NULL); } break; + case 'M': + filebehave = FILE_LZMA; + break; case 'n': nflag = true; break; @@ -553,6 +564,9 @@ main(int argc, char *argv[]) xflag = true; cflags &= ~REG_NOSUB; break; + case 'X': + filebehave = FILE_XZ; + break; case 'Z': filebehave = FILE_GZIP; break; Modified: user/gabor/grep/trunk/grep.h ============================================================================== --- user/gabor/grep/trunk/grep.h Mon Aug 29 20:00:57 2011 (r225250) +++ user/gabor/grep/trunk/grep.h Mon Aug 29 20:36:21 2011 (r225251) @@ -62,6 +62,8 @@ extern const char *errstr[]; #define FILE_STDIO 0 #define FILE_GZIP 1 #define FILE_BZIP 2 +#define FILE_XZ 3 +#define FILE_LZMA 4 #define DIR_READ 0 #define DIR_SKIP 1 From owner-svn-src-user@FreeBSD.ORG Mon Aug 29 22:55:38 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 294D0106566B; Mon, 29 Aug 2011 22:55:38 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 00C838FC12; Mon, 29 Aug 2011 22:55:38 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7TMtbA9018011; Mon, 29 Aug 2011 22:55:37 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7TMtbES018006; Mon, 29 Aug 2011 22:55:37 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108292255.p7TMtbES018006@svn.freebsd.org> From: Gabor Kovesdan Date: Mon, 29 Aug 2011 22:55:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225252 - in user/gabor/grep/trunk: . regex X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Aug 2011 22:55:38 -0000 Author: gabor Date: Mon Aug 29 22:55:37 2011 New Revision: 225252 URL: http://svn.freebsd.org/changeset/base/225252 Log: - Fix some warnings - Unfortunately, the code is only WARNS=2 clean at the moment because of the backported regex code Modified: user/gabor/grep/trunk/Makefile user/gabor/grep/trunk/file.c user/gabor/grep/trunk/regex/fastmatch.c user/gabor/grep/trunk/regex/glue.h Modified: user/gabor/grep/trunk/Makefile ============================================================================== --- user/gabor/grep/trunk/Makefile Mon Aug 29 20:36:21 2011 (r225251) +++ user/gabor/grep/trunk/Makefile Mon Aug 29 22:55:37 2011 (r225252) @@ -15,6 +15,8 @@ bsdgrep.1: grep.1 .endif SRCS= file.c grep.c queue.c util.c +WARNS=2 + # Extra files ported backported form some regex improvements .PATH: ${.CURDIR}/regex SRCS+= fastmatch.c hashtable.c tre-fastmatch.c xmalloc.c Modified: user/gabor/grep/trunk/file.c ============================================================================== --- user/gabor/grep/trunk/file.c Mon Aug 29 20:36:21 2011 (r225251) +++ user/gabor/grep/trunk/file.c Mon Aug 29 22:55:37 2011 (r225252) @@ -119,13 +119,14 @@ grep_refill(struct file *f) lstrm.next_out = buffer; lstrm.avail_out = MAXBUFSIZ; lstrm.next_in = in_buf; - lstrm.avail_in = read(f->fd, in_buf, MAXBUFSIZ); + nr = read(f->fd, in_buf, MAXBUFSIZ); - if (lstrm.avail_in < 0) + if (nr < 0) return (-1); - else if (lstrm.avail_in == 0) + else if (nr == 0) action = LZMA_FINISH; + lstrm.avail_in = nr; ret = lzma_code(&lstrm, action); if (ret != LZMA_OK && ret != LZMA_STREAM_END) Modified: user/gabor/grep/trunk/regex/fastmatch.c ============================================================================== --- user/gabor/grep/trunk/regex/fastmatch.c Mon Aug 29 20:36:21 2011 (r225251) +++ user/gabor/grep/trunk/regex/fastmatch.c Mon Aug 29 22:55:37 2011 (r225252) @@ -170,7 +170,7 @@ tre_fastfree(fastmatch_t *preg) size_t offset = pmatch[0].rm_so; \ int ret; \ \ - if ((len != (unsigned)-1) && (pmatch[0].rm_eo > len)) \ + if ((len != (unsigned)-1) && (pmatch[0].rm_eo > (off_t)len)) \ return REG_NOMATCH; \ if ((long long)pmatch[0].rm_eo - pmatch[0].rm_so < 0) \ return REG_NOMATCH; \ Modified: user/gabor/grep/trunk/regex/glue.h ============================================================================== --- user/gabor/grep/trunk/regex/glue.h Mon Aug 29 20:36:21 2011 (r225251) +++ user/gabor/grep/trunk/regex/glue.h Mon Aug 29 22:55:37 2011 (r225252) @@ -3,6 +3,8 @@ #ifndef GLUE_H #define GLUE_H +#include +#undef RE_DUP_MAX #include #define TRE_WCHAR 1 From owner-svn-src-user@FreeBSD.ORG Mon Aug 29 23:16:49 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9851D106564A; Mon, 29 Aug 2011 23:16:49 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from server.mypc.hu (server.mypc.hu [87.229.73.95]) by mx1.freebsd.org (Postfix) with ESMTP id 4F1878FC14; Mon, 29 Aug 2011 23:16:49 +0000 (UTC) Received: from server.mypc.hu (localhost [127.0.0.1]) by server.mypc.hu (Postfix) with ESMTP id 7DBA514E5E6A; Tue, 30 Aug 2011 01:16:48 +0200 (CEST) X-Virus-Scanned: amavisd-new at server.mypc.hu Received: from server.mypc.hu ([127.0.0.1]) by server.mypc.hu (server.mypc.hu [127.0.0.1]) (amavisd-new, port 10024) with LMTP id qbkYUp1-BFdh; Tue, 30 Aug 2011 01:16:45 +0200 (CEST) Received: from [192.168.1.106] (catv-80-98-232-12.catv.broadband.hu [80.98.232.12]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by server.mypc.hu (Postfix) with ESMTPSA id 6A60114E5E3D; Tue, 30 Aug 2011 01:16:45 +0200 (CEST) Message-ID: <4E5C1DD7.70200@FreeBSD.org> Date: Tue, 30 Aug 2011 01:16:39 +0200 From: Gabor Kovesdan User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:8.0a1) Gecko/20110816 Thunderbird/8.0a1 MIME-Version: 1.0 To: Ben Kaduk References: <201108292036.p7TKaLgL011686@svn.freebsd.org> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: Re: svn commit: r225251 - user/gabor/grep/trunk X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Aug 2011 23:16:49 -0000 On 2011.08.30. 0:59, Ben Kaduk wrote: > On 8/29/11, Gabor Kovesdan wrote: >> Author: gabor >> Date: Mon Aug 29 20:36:21 2011 >> New Revision: 225251 >> URL: http://svn.freebsd.org/changeset/base/225251 >> >> Log: >> - Add support for xz[ef]?grep (1) and lz[ef]?grep. The former handles >> xz(1) >> compressed files and the latter lzma(1) compressed files. The -X and -M >> command-line options can also be used respectively. >> > Is there a reason to not make just a single zgrep(1) binary that can > tell what compression algorithm is in use and choose it as > appropriate? It seems like that would be more convenient from a > user's perspective. 1, From xz(1) code it seems that there is no clean way of auto-detection between xz/lzma. I do not know about the rest because I haven't checked it. It may requie some preprocessing, which makes the code more complex or we could use libarchive but probably it has some overhead and performance is crucial in grep so I want to keep I/O as simple as possible. 2, bzgrep imho is kind of a de facto standard because of GNU despite not being part of POSIX so I prefer not to drop it. Similarly, xzgrep is part of XZ utils. In the case of lzgrep, yes, that's my invention to follow the convention. Gabor From owner-svn-src-user@FreeBSD.ORG Mon Aug 29 23:22:03 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 27964106566B; Mon, 29 Aug 2011 23:22:03 +0000 (UTC) (envelope-from minimarmot@gmail.com) Received: from mail-gy0-f182.google.com (mail-gy0-f182.google.com [209.85.160.182]) by mx1.freebsd.org (Postfix) with ESMTP id CE29B8FC0A; Mon, 29 Aug 2011 23:22:02 +0000 (UTC) Received: by gyd10 with SMTP id 10so6284059gyd.13 for ; Mon, 29 Aug 2011 16:22:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=2RDMj/dWDx9dxeipu/shEWIrQHqSEfEbS1gXKOTdx94=; b=dmLpCxbneXlZzNC0k83DFjS4V4WfddNnxV8rSPpv/gwR/835P+R4tsUCBBmfHdEDN2 lZfkTIgZacvfGGZyEXuXaoVtNS/zfSELF4/piIMlf0J8Rph3YSiObNwWx6e29LFnIPR6 vBsjPs2CoP6tSbLsrs0gzkFyyjNt6S3tVMOvo= MIME-Version: 1.0 Received: by 10.236.116.194 with SMTP id g42mr29286810yhh.0.1314658752678; Mon, 29 Aug 2011 15:59:12 -0700 (PDT) Received: by 10.236.103.5 with HTTP; Mon, 29 Aug 2011 15:59:12 -0700 (PDT) In-Reply-To: <201108292036.p7TKaLgL011686@svn.freebsd.org> References: <201108292036.p7TKaLgL011686@svn.freebsd.org> Date: Mon, 29 Aug 2011 18:59:12 -0400 Message-ID: From: Ben Kaduk To: Gabor Kovesdan Content-Type: text/plain; charset=ISO-8859-1 Cc: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: Re: svn commit: r225251 - user/gabor/grep/trunk X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Aug 2011 23:22:03 -0000 On 8/29/11, Gabor Kovesdan wrote: > Author: gabor > Date: Mon Aug 29 20:36:21 2011 > New Revision: 225251 > URL: http://svn.freebsd.org/changeset/base/225251 > > Log: > - Add support for xz[ef]?grep (1) and lz[ef]?grep. The former handles > xz(1) > compressed files and the latter lzma(1) compressed files. The -X and -M > command-line options can also be used respectively. > Is there a reason to not make just a single zgrep(1) binary that can tell what compression algorithm is in use and choose it as appropriate? It seems like that would be more convenient from a user's perspective. -Ben Kaduk From owner-svn-src-user@FreeBSD.ORG Tue Aug 30 01:22:27 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6CCB31065670; Tue, 30 Aug 2011 01:22:27 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5D4AF8FC13; Tue, 30 Aug 2011 01:22:27 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7U1MRLA026548; Tue, 30 Aug 2011 01:22:27 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7U1MRsI026546; Tue, 30 Aug 2011 01:22:27 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108300122.p7U1MRsI026546@svn.freebsd.org> From: Adrian Chadd Date: Tue, 30 Aug 2011 01:22:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225253 - user/adrian/if_ath_tx/sys/dev/ath X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Aug 2011 01:22:27 -0000 Author: adrian Date: Tue Aug 30 01:22:27 2011 New Revision: 225253 URL: http://svn.freebsd.org/changeset/base/225253 Log: * Add an RTS/CTS handling comment when forming aggregates; * Re-enable a comment - I think there are issues forming large aggregates Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c Mon Aug 29 22:55:37 2011 (r225252) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c Tue Aug 30 01:22:27 2011 (r225253) @@ -291,11 +291,9 @@ ath_tx_rate_fill_rcflags(struct ath_soft ath_max_4ms_framelen[j][HT_RC_2_MCS(rate)]; } else rc[i].max4msframelen = 0; -#if 0 DPRINTF(sc, ATH_DEBUG_SW_TX_AGGR, "%s: i=%d, rate=0x%x, flags=0x%x, max4ms=%d\n", __func__, i, rate, rc[i].flags, rc[i].max4msframelen); -#endif } } @@ -755,6 +753,11 @@ ath_tx_form_aggr(struct ath_softc *sc, s bf->bf_state.bfs_addedbaw = 1; /* + * XXX TODO: If any frame in the aggregate requires RTS/CTS, + * set the first frame. + */ + + /* * Add the now owned buffer (which isn't * on the software TXQ any longer) to our * aggregate frame list. From owner-svn-src-user@FreeBSD.ORG Tue Aug 30 02:10:33 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3B985106566B; Tue, 30 Aug 2011 02:10:33 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 123998FC17; Tue, 30 Aug 2011 02:10:33 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7U2AWkK028019; Tue, 30 Aug 2011 02:10:32 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7U2AWpc028017; Tue, 30 Aug 2011 02:10:32 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108300210.p7U2AWpc028017@svn.freebsd.org> From: Adrian Chadd Date: Tue, 30 Aug 2011 02:10:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225255 - user/adrian/if_ath_tx/sys/dev/ath/ath_rate/sample X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Aug 2011 02:10:33 -0000 Author: adrian Date: Tue Aug 30 02:10:32 2011 New Revision: 225255 URL: http://svn.freebsd.org/changeset/base/225255 Log: Add nframes/nbad to the debugging output Modified: user/adrian/if_ath_tx/sys/dev/ath/ath_rate/sample/sample.c Modified: user/adrian/if_ath_tx/sys/dev/ath/ath_rate/sample/sample.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/ath_rate/sample/sample.c Tue Aug 30 01:25:12 2011 (r225254) +++ user/adrian/if_ath_tx/sys/dev/ath/ath_rate/sample/sample.c Tue Aug 30 02:10:32 2011 (r225255) @@ -643,12 +643,13 @@ ath_rate_tx_complete(struct ath_softc *s * Only one rate was used; optimize work. */ IEEE80211_NOTE(an->an_node.ni_vap, IEEE80211_MSG_RATECTL, - &an->an_node, "%s: size %d (%d bytes) %s rate/try %d %s/%d/%d", + &an->an_node, "%s: size %d (%d bytes) %s rate/try %d %s/%d/%d nframes/nbad [%d/%d]", __func__, bin_to_size(size_to_bin(frame_size)), frame_size, ts->ts_status ? "FAIL" : "OK", - dot11rate(rt, final_rix), dot11rate_label(rt, final_rix), short_tries, long_tries); + dot11rate(rt, final_rix), dot11rate_label(rt, final_rix), + short_tries, long_tries, nframes, nbad); update_stats(sc, an, frame_size, final_rix, long_tries, 0, 0, @@ -666,7 +667,7 @@ ath_rate_tx_complete(struct ath_softc *s IEEE80211_NOTE(an->an_node.ni_vap, IEEE80211_MSG_RATECTL, &an->an_node, -"%s: size %d (%d bytes) finaltsidx %d tries %d %s rate/try [%d %s/%d %d %s/%d %d %s/%d %d %s/%d]", +"%s: size %d (%d bytes) finaltsidx %d tries %d %s rate/try [%d %s/%d %d %s/%d %d %s/%d %d %s/%d] nframes/nbad [%d/%d]", __func__, bin_to_size(size_to_bin(frame_size)), frame_size, @@ -680,7 +681,8 @@ ath_rate_tx_complete(struct ath_softc *s dot11rate(rt, rc[2].rix), dot11rate_label(rt, rc[2].rix), rc[2].tries, dot11rate(rt, rc[3].rix), - dot11rate_label(rt, rc[3].rix), rc[3].tries); + dot11rate_label(rt, rc[3].rix), rc[3].tries, + nframes, nbad); for (i = 0; i < 4; i++) { if (rc[i].tries && !IS_RATE_DEFINED(sn, rc[i].rix)) From owner-svn-src-user@FreeBSD.ORG Tue Aug 30 04:23:34 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 54C1B106564A; Tue, 30 Aug 2011 04:23:33 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3F1AA8FC19; Tue, 30 Aug 2011 04:23:33 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7U4NXmv032209; Tue, 30 Aug 2011 04:23:33 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7U4NXNA032207; Tue, 30 Aug 2011 04:23:33 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108300423.p7U4NXNA032207@svn.freebsd.org> From: Adrian Chadd Date: Tue, 30 Aug 2011 04:23:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225256 - user/adrian/if_ath_tx/tools/tools/ath/athstats X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Aug 2011 04:23:34 -0000 Author: adrian Date: Tue Aug 30 04:23:32 2011 New Revision: 225256 URL: http://svn.freebsd.org/changeset/base/225256 Log: Add in the new fields Modified: user/adrian/if_ath_tx/tools/tools/ath/athstats/athstats.c Modified: user/adrian/if_ath_tx/tools/tools/ath/athstats/athstats.c ============================================================================== --- user/adrian/if_ath_tx/tools/tools/ath/athstats/athstats.c Tue Aug 30 02:10:32 2011 (r225255) +++ user/adrian/if_ath_tx/tools/tools/ath/athstats/athstats.c Tue Aug 30 04:23:32 2011 (r225256) @@ -49,18 +49,10 @@ #include #include -/* Use the system net80211 headers, rather than the kernel tree */ -/* - * XXX this means that if you build a separate net80211 stack - * XXX with your kernel and don't install the new/changed headers, - * XXX this tool may break. - * XXX -adrian - */ -#include -#include - #include "ah.h" #include "ah_desc.h" +#include "net80211/ieee80211_ioctl.h" +#include "net80211/ieee80211_radiotap.h" #include "if_athioctl.h" #include "athstats.h" @@ -256,8 +248,44 @@ static const struct fmt athstats[] = { { 5, "txrawfail", "txrawfail", "raw tx failed 'cuz interface/hw down" }, #define S_RX_TOOBIG AFTER(S_TX_RAW_FAIL) { 5, "rx2big", "rx2big", "rx failed 'cuz frame too large" }, +#define S_RX_AGG AFTER(S_RX_TOOBIG) + { 5, "rxagg", "rxagg", "A-MPDU sub-frames received" }, +#define S_RX_HALFGI AFTER(S_RX_AGG) + { 5, "rxhalfgi", "rxhgi", "Half-GI frames received" }, +#define S_RX_2040 AFTER(S_RX_HALFGI) + { 6, "rx2040", "rx2040", "40MHz frames received" }, +#define S_RX_PRE_CRC_ERR AFTER(S_RX_2040) + { 5, "rxprecrcerr", "rxprecrcerr", "CRC errors for non-last A-MPDU subframes" }, +#define S_RX_POST_CRC_ERR AFTER(S_RX_PRE_CRC_ERR) + { 5, "rxpostcrcerr", "rxpostcrcerr", "CRC errors for last subframe in an A-MPDU" }, +#define S_RX_DECRYPT_BUSY_ERR AFTER(S_RX_POST_CRC_ERR) + { 4, "rxdescbusy", "rxdescbusy", "Decryption engine busy" }, +#define S_RX_HI_CHAIN AFTER(S_RX_DECRYPT_BUSY_ERR) + { 4, "rxhi", "rxhi", "Frames received with RX chain in high power mode" }, +#define S_TX_HTPROTECT AFTER(S_RX_HI_CHAIN) + { 4, "txhtprot", "txhtprot", "Frames transmitted with HT Protection" }, +#define S_RX_QEND AFTER(S_TX_HTPROTECT) + { 4, "rxquend", "rxquend", "Hit end of RX descriptor queue" }, +#define S_TX_TIMEOUT AFTER(S_RX_QEND) + { 4, "txtimeout", "txtimeout", "TX Timeout" }, +#define S_TX_CSTIMEOUT AFTER(S_TX_TIMEOUT) + { 4, "csttimeout", "csttimeout", "Carrier Sense Timeout" }, +#define S_TX_XTXOP_ERR AFTER(S_TX_CSTIMEOUT) + { 4, "xtxoperr", "xtxoperr", "TXOP exceed" }, +#define S_TX_TIMEREXPIRED_ERR AFTER(S_TX_XTXOP_ERR) + { 4, "texperr", "texperr", "TX Timer expired" }, +#define S_TX_DESCCFG_ERR AFTER(S_TX_TIMEREXPIRED_ERR) + { 4, "desccfgerr", "desccfgerr", "TX descriptor error" }, +#define S_TX_SWRETRIES AFTER(S_TX_DESCCFG_ERR) + { 4, "txswretry", "txswretry", "Number of frames retransmitted in software" }, +#define S_TX_SWRETRIES_MAX AFTER(S_TX_SWRETRIES) + { 4, "txswmax", "txswmax", "Number of frames exceeding software retry" }, +#define S_TX_DATA_UNDERRUN AFTER(S_TX_SWRETRIES_MAX) + { 4, "txdataunderrun", "txdataunderrun", "A-MPDU TX FIFO data underrun" }, +#define S_TX_DELIM_UNDERRUN AFTER(S_TX_DATA_UNDERRUN) + { 4, "txdelimunderrun", "txdelimunderrun", "A-MPDU TX Delimiter underrun" }, #ifndef __linux__ -#define S_CABQ_XMIT AFTER(S_RX_TOOBIG) +#define S_CABQ_XMIT AFTER(S_TX_DELIM_UNDERRUN) { 5, "cabxmit", "cabxmit", "cabq frames transmitted" }, #define S_CABQ_BUSY AFTER(S_CABQ_XMIT) { 5, "cabqbusy", "cabqbusy", "cabq xmit overflowed beacon interval" }, @@ -269,7 +297,7 @@ static const struct fmt athstats[] = { { 5, "rxbusdma", "rxbusdma", "rx setup failed for dma resrcs" }, #define S_FF_TXOK AFTER(S_RX_BUSDMA) #else -#define S_FF_TXOK AFTER(S_RX_PHY_UNDERRUN) +#define S_FF_TXOK AFTER(S_TX_DELIM_UNDERRUN) #endif { 5, "fftxok", "fftxok", "fast frames xmit successfully" }, #define S_FF_TXERR AFTER(S_FF_TXOK) @@ -384,12 +412,16 @@ static const struct fmt athstats[] = { { 4, "asignal", "asig", "signal of last ack (dBm)" }, #define S_RX_SIGNAL AFTER(S_TX_SIGNAL) { 4, "signal", "sig", "avg recv signal (dBm)" }, + }; #define S_PHY_MIN S_RX_PHY_UNDERRUN #define S_PHY_MAX S_RX_PHY_CCK_RESTART #define S_LAST S_ANT_TX0 #define S_MAX S_ANT_RX7+1 +/* + * XXX fold this into the external HAL definitions! -adrian + */ struct _athstats { struct ath_stats ath; #ifdef ATH_SUPPORT_ANI @@ -723,6 +755,24 @@ ath_get_curstat(struct statfoo *sf, int snprintf(b, bs, "%d", wf->cur.ath.ast_rx_rssi + wf->cur.ath.ast_rx_noise); return 1; + case S_RX_AGG: STAT(rx_agg); + case S_RX_HALFGI: STAT(rx_halfgi); + case S_RX_2040: STAT(rx_2040); + case S_RX_PRE_CRC_ERR: STAT(rx_pre_crc_err); + case S_RX_POST_CRC_ERR: STAT(rx_post_crc_err); + case S_RX_DECRYPT_BUSY_ERR: STAT(rx_decrypt_busy_err); + case S_RX_HI_CHAIN: STAT(rx_hi_rx_chain); + case S_TX_HTPROTECT: STAT(tx_htprotect); + case S_RX_QEND: STAT(rx_hitqueueend); + case S_TX_TIMEOUT: STAT(tx_timeout); + case S_TX_CSTIMEOUT: STAT(tx_cst); + case S_TX_XTXOP_ERR: STAT(tx_xtxop); + case S_TX_TIMEREXPIRED_ERR: STAT(tx_timerexpired); + case S_TX_DESCCFG_ERR: STAT(tx_desccfgerr); + case S_TX_SWRETRIES: STAT(tx_swretries); + case S_TX_SWRETRIES_MAX: STAT(tx_swretrymax); + case S_TX_DATA_UNDERRUN: STAT(tx_data_underrun); + case S_TX_DELIM_UNDERRUN: STAT(tx_delim_underrun); } b[0] = '\0'; return 0; @@ -943,7 +993,26 @@ ath_get_totstat(struct statfoo *sf, int snprintf(b, bs, "%d", wf->total.ath.ast_rx_rssi + wf->total.ath.ast_rx_noise); return 1; + case S_RX_AGG: STAT(rx_agg); + case S_RX_HALFGI: STAT(rx_halfgi); + case S_RX_2040: STAT(rx_2040); + case S_RX_PRE_CRC_ERR: STAT(rx_pre_crc_err); + case S_RX_POST_CRC_ERR: STAT(rx_post_crc_err); + case S_RX_DECRYPT_BUSY_ERR: STAT(rx_decrypt_busy_err); + case S_RX_HI_CHAIN: STAT(rx_hi_rx_chain); + case S_TX_HTPROTECT: STAT(tx_htprotect); + case S_RX_QEND: STAT(rx_hitqueueend); + case S_TX_TIMEOUT: STAT(tx_timeout); + case S_TX_CSTIMEOUT: STAT(tx_cst); + case S_TX_XTXOP_ERR: STAT(tx_xtxop); + case S_TX_TIMEREXPIRED_ERR: STAT(tx_timerexpired); + case S_TX_DESCCFG_ERR: STAT(tx_desccfgerr); + case S_TX_SWRETRIES: STAT(tx_swretries); + case S_TX_SWRETRIES_MAX: STAT(tx_swretrymax); + case S_TX_DATA_UNDERRUN: STAT(tx_data_underrun); + case S_TX_DELIM_UNDERRUN: STAT(tx_delim_underrun); } + b[0] = '\0'; return 0; #undef RXANT From owner-svn-src-user@FreeBSD.ORG Tue Aug 30 04:30:41 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CB754106566B; Tue, 30 Aug 2011 04:30:41 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A23968FC15; Tue, 30 Aug 2011 04:30:41 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7U4UfRB032500; Tue, 30 Aug 2011 04:30:41 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7U4Ufwa032498; Tue, 30 Aug 2011 04:30:41 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108300430.p7U4Ufwa032498@svn.freebsd.org> From: Adrian Chadd Date: Tue, 30 Aug 2011 04:30:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225257 - user/adrian/if_ath_tx/tools/tools/ath/athstats X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Aug 2011 04:30:41 -0000 Author: adrian Date: Tue Aug 30 04:30:41 2011 New Revision: 225257 URL: http://svn.freebsd.org/changeset/base/225257 Log: Add in another new field Modified: user/adrian/if_ath_tx/tools/tools/ath/athstats/athstats.c Modified: user/adrian/if_ath_tx/tools/tools/ath/athstats/athstats.c ============================================================================== --- user/adrian/if_ath_tx/tools/tools/ath/athstats/athstats.c Tue Aug 30 04:23:32 2011 (r225256) +++ user/adrian/if_ath_tx/tools/tools/ath/athstats/athstats.c Tue Aug 30 04:30:41 2011 (r225257) @@ -284,8 +284,10 @@ static const struct fmt athstats[] = { { 4, "txdataunderrun", "txdataunderrun", "A-MPDU TX FIFO data underrun" }, #define S_TX_DELIM_UNDERRUN AFTER(S_TX_DATA_UNDERRUN) { 4, "txdelimunderrun", "txdelimunderrun", "A-MPDU TX Delimiter underrun" }, +#define S_TX_AGGR_FAIL AFTER(S_TX_DELIM_UNDERRUN) + { 4, "txaggrfail", "txaggrfail", "A-MPDU TX attempt failed" }, #ifndef __linux__ -#define S_CABQ_XMIT AFTER(S_TX_DELIM_UNDERRUN) +#define S_CABQ_XMIT AFTER(S_TX_AGGR_FAIL) { 5, "cabxmit", "cabxmit", "cabq frames transmitted" }, #define S_CABQ_BUSY AFTER(S_CABQ_XMIT) { 5, "cabqbusy", "cabqbusy", "cabq xmit overflowed beacon interval" }, @@ -297,7 +299,7 @@ static const struct fmt athstats[] = { { 5, "rxbusdma", "rxbusdma", "rx setup failed for dma resrcs" }, #define S_FF_TXOK AFTER(S_RX_BUSDMA) #else -#define S_FF_TXOK AFTER(S_TX_DELIM_UNDERRUN) +#define S_FF_TXOK AFTER(S_TX_AGGR_FAIL) #endif { 5, "fftxok", "fftxok", "fast frames xmit successfully" }, #define S_FF_TXERR AFTER(S_FF_TXOK) @@ -773,6 +775,7 @@ ath_get_curstat(struct statfoo *sf, int case S_TX_SWRETRIES_MAX: STAT(tx_swretrymax); case S_TX_DATA_UNDERRUN: STAT(tx_data_underrun); case S_TX_DELIM_UNDERRUN: STAT(tx_delim_underrun); + case S_TX_AGGR_FAIL: STAT(tx_aggrfail); } b[0] = '\0'; return 0; @@ -1011,6 +1014,7 @@ ath_get_totstat(struct statfoo *sf, int case S_TX_SWRETRIES_MAX: STAT(tx_swretrymax); case S_TX_DATA_UNDERRUN: STAT(tx_data_underrun); case S_TX_DELIM_UNDERRUN: STAT(tx_delim_underrun); + case S_TX_AGGR_FAIL: STAT(tx_aggrfail); } b[0] = '\0'; From owner-svn-src-user@FreeBSD.ORG Tue Aug 30 04:32:16 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8F1BB106566C; Tue, 30 Aug 2011 04:32:16 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 65ACF8FC0A; Tue, 30 Aug 2011 04:32:16 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7U4WGY1032586; Tue, 30 Aug 2011 04:32:16 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7U4WGbm032582; Tue, 30 Aug 2011 04:32:16 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108300432.p7U4WGbm032582@svn.freebsd.org> From: Adrian Chadd Date: Tue, 30 Aug 2011 04:32:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225258 - user/adrian/if_ath_tx/sys/dev/ath X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Aug 2011 04:32:16 -0000 Author: adrian Date: Tue Aug 30 04:32:16 2011 New Revision: 225258 URL: http://svn.freebsd.org/changeset/base/225258 Log: * correctly bump the max sw retry counter on failed aggregate frames * add a new field which increments when an whole aggregate frame fails to TX Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_sysctl.c user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c user/adrian/if_ath_tx/sys/dev/ath/if_athioctl.h Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_sysctl.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_sysctl.c Tue Aug 30 04:30:41 2011 (r225257) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_sysctl.c Tue Aug 30 04:32:16 2011 (r225258) @@ -809,6 +809,9 @@ ath_sysctl_stats_attach(struct ath_softc &sc->sc_stats.ast_tx_data_underrun, 0, ""); SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_delim_underrun", CTLFLAG_RD, &sc->sc_stats.ast_tx_delim_underrun, 0, ""); + SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_aggrfail", CTLFLAG_RD, + &sc->sc_stats.ast_tx_aggrfail, 0, + "Number of aggregate TX failures (whole frame)"); /* Attach the RX phy error array */ ath_sysctl_stats_attach_rxphyerr(sc, child); Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Tue Aug 30 04:30:41 2011 (r225257) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Tue Aug 30 04:32:16 2011 (r225258) @@ -2644,6 +2644,7 @@ ath_tx_retry_subframe(struct ath_softc * } if (bf->bf_state.bfs_retries >= SWMAX_RETRIES) { + sc->sc_stats.ast_tx_swretrymax++; DPRINTF(sc, ATH_DEBUG_SW_TX_RETRIES, "%s: max retries: seqno %d\n", __func__, SEQNO(bf->bf_state.bfs_seqno)); @@ -2685,6 +2686,7 @@ ath_tx_comp_aggr_error(struct ath_softc tap = ath_tx_get_tx_tid(an, tid->tid); TAILQ_INIT(&bf_q); + sc->sc_stats.ast_tx_aggrfail++; /* * Update rate control - all frames have failed. Modified: user/adrian/if_ath_tx/sys/dev/ath/if_athioctl.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_athioctl.h Tue Aug 30 04:30:41 2011 (r225257) +++ user/adrian/if_ath_tx/sys/dev/ath/if_athioctl.h Tue Aug 30 04:32:16 2011 (r225258) @@ -146,6 +146,7 @@ struct ath_stats { u_int32_t ast_tx_swretrymax; /* software TX retry max limit reach */ u_int32_t ast_tx_data_underrun; u_int32_t ast_tx_delim_underrun; + u_int32_t ast_tx_aggrfail; /* aggregate TX failed in its entirety */ struct ath_tx_aggr_stats tx_aggr; u_int32_t ast_pad[9]; }; From owner-svn-src-user@FreeBSD.ORG Tue Aug 30 13:59:35 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F3DEA106566B; Tue, 30 Aug 2011 13:59:34 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D98128FC0A; Tue, 30 Aug 2011 13:59:34 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7UDxYL0053976; Tue, 30 Aug 2011 13:59:34 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7UDxYOf053974; Tue, 30 Aug 2011 13:59:34 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108301359.p7UDxYOf053974@svn.freebsd.org> From: Adrian Chadd Date: Tue, 30 Aug 2011 13:59:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225262 - user/adrian/if_ath_tx/sys/dev/ath/ath_rate/sample X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Aug 2011 13:59:35 -0000 Author: adrian Date: Tue Aug 30 13:59:34 2011 New Revision: 225262 URL: http://svn.freebsd.org/changeset/base/225262 Log: Although there may be bad frames, the status will still be OK unless they're all bad. Thus, override the status if any of the frames are bad. Modified: user/adrian/if_ath_tx/sys/dev/ath/ath_rate/sample/sample.c Modified: user/adrian/if_ath_tx/sys/dev/ath/ath_rate/sample/sample.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/ath_rate/sample/sample.c Tue Aug 30 11:50:28 2011 (r225261) +++ user/adrian/if_ath_tx/sys/dev/ath/ath_rate/sample/sample.c Tue Aug 30 13:59:34 2011 (r225262) @@ -614,6 +614,7 @@ ath_rate_tx_complete(struct ath_softc *s struct sample_node *sn = ATH_NODE_SAMPLE(an); int final_rix, short_tries, long_tries; const HAL_RATE_TABLE *rt = sc->sc_currates; + int status = ts->ts_status; int mrr; final_rix = rt->rateCodeToIndex[ts->ts_rate]; @@ -623,20 +624,24 @@ ath_rate_tx_complete(struct ath_softc *s if (frame_size == 0) /* NB: should not happen */ frame_size = 1500; + /* If nbad > 1, override status to FAIL */ + if (nbad > 0) + status = 1; + if (sn->ratemask == 0) { IEEE80211_NOTE(an->an_node.ni_vap, IEEE80211_MSG_RATECTL, &an->an_node, "%s: size %d %s rate/try %d/%d no rates yet", __func__, bin_to_size(size_to_bin(frame_size)), - ts->ts_status ? "FAIL" : "OK", + status ? "FAIL" : "OK", short_tries, long_tries); return; } mrr = sc->sc_mrretry && !(ic->ic_flags & IEEE80211_F_USEPROT); if (!mrr || ts->ts_finaltsi == 0) { if (!IS_RATE_DEFINED(sn, final_rix)) { - badrate(ifp, 0, ts->ts_rate, long_tries, ts->ts_status); + badrate(ifp, 0, ts->ts_rate, long_tries, status); return; } /* @@ -647,7 +652,7 @@ ath_rate_tx_complete(struct ath_softc *s __func__, bin_to_size(size_to_bin(frame_size)), frame_size, - ts->ts_status ? "FAIL" : "OK", + status ? "FAIL" : "OK", dot11rate(rt, final_rix), dot11rate_label(rt, final_rix), short_tries, long_tries, nframes, nbad); update_stats(sc, an, frame_size, @@ -655,7 +660,7 @@ ath_rate_tx_complete(struct ath_softc *s 0, 0, 0, 0, 0, 0, - short_tries, long_tries, ts->ts_status, + short_tries, long_tries, status, nframes, nbad); } else { int finalTSIdx = ts->ts_finaltsi; @@ -673,7 +678,7 @@ ath_rate_tx_complete(struct ath_softc *s frame_size, finalTSIdx, long_tries, - ts->ts_status ? "FAIL" : "OK", + status ? "FAIL" : "OK", dot11rate(rt, rc[0].rix), dot11rate_label(rt, rc[0].rix), rc[0].tries, dot11rate(rt, rc[1].rix), @@ -687,7 +692,7 @@ ath_rate_tx_complete(struct ath_softc *s for (i = 0; i < 4; i++) { if (rc[i].tries && !IS_RATE_DEFINED(sn, rc[i].rix)) badrate(ifp, 0, rc[i].ratecode, rc[i].tries, - ts->ts_status); + status); } /* @@ -716,7 +721,7 @@ ath_rate_tx_complete(struct ath_softc *s rc[3].rix, rc[3].tries, 0, 0, short_tries, long_tries, - ts->ts_status, + status, nframes, nbad); long_tries -= rc[1].tries; } @@ -728,7 +733,7 @@ ath_rate_tx_complete(struct ath_softc *s 0, 0, 0, 0, short_tries, long_tries, - ts->ts_status, + status, nframes, nbad); long_tries -= rc[2].tries; } @@ -740,7 +745,7 @@ ath_rate_tx_complete(struct ath_softc *s 0, 0, 0, 0, short_tries, long_tries, - ts->ts_status, + status, nframes, nbad); } } From owner-svn-src-user@FreeBSD.ORG Tue Aug 30 16:20:16 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 971A8106564A; Tue, 30 Aug 2011 16:20:16 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 872DF8FC15; Tue, 30 Aug 2011 16:20:16 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7UGKGlP058264; Tue, 30 Aug 2011 16:20:16 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7UGKGWm058262; Tue, 30 Aug 2011 16:20:16 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108301620.p7UGKGWm058262@svn.freebsd.org> From: Gabor Kovesdan Date: Tue, 30 Aug 2011 16:20:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225263 - user/gabor/grep/trunk/regex X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Aug 2011 16:20:16 -0000 Author: gabor Date: Tue Aug 30 16:20:16 2011 New Revision: 225263 URL: http://svn.freebsd.org/changeset/base/225263 Log: - Revert a minor change that broke the code Modified: user/gabor/grep/trunk/regex/fastmatch.c Modified: user/gabor/grep/trunk/regex/fastmatch.c ============================================================================== --- user/gabor/grep/trunk/regex/fastmatch.c Tue Aug 30 13:59:34 2011 (r225262) +++ user/gabor/grep/trunk/regex/fastmatch.c Tue Aug 30 16:20:16 2011 (r225263) @@ -170,7 +170,7 @@ tre_fastfree(fastmatch_t *preg) size_t offset = pmatch[0].rm_so; \ int ret; \ \ - if ((len != (unsigned)-1) && (pmatch[0].rm_eo > (off_t)len)) \ + if ((len != (unsigned)-1) && (pmatch[0].rm_eo > len)) \ return REG_NOMATCH; \ if ((long long)pmatch[0].rm_eo - pmatch[0].rm_so < 0) \ return REG_NOMATCH; \ From owner-svn-src-user@FreeBSD.ORG Tue Aug 30 16:23:57 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CB30A106567A; Tue, 30 Aug 2011 16:23:57 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B0EB18FC2B; Tue, 30 Aug 2011 16:23:57 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7UGNv49058413; Tue, 30 Aug 2011 16:23:57 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7UGNvwq058409; Tue, 30 Aug 2011 16:23:57 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108301623.p7UGNvwq058409@svn.freebsd.org> From: Gabor Kovesdan Date: Tue, 30 Aug 2011 16:23:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225264 - user/gabor/grep/trunk X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Aug 2011 16:23:58 -0000 Author: gabor Date: Tue Aug 30 16:23:57 2011 New Revision: 225264 URL: http://svn.freebsd.org/changeset/base/225264 Log: - Add back mmap support. It must be more efficient than read(2) if properly implemented. The prefetching problem has to be solved for mmap(2). Suggested by: alc Modified: user/gabor/grep/trunk/file.c user/gabor/grep/trunk/grep.c user/gabor/grep/trunk/grep.h Modified: user/gabor/grep/trunk/file.c ============================================================================== --- user/gabor/grep/trunk/file.c Tue Aug 30 16:20:16 2011 (r225263) +++ user/gabor/grep/trunk/file.c Tue Aug 30 16:23:57 2011 (r225264) @@ -34,8 +34,9 @@ __FBSDID("$FreeBSD$"); #include -#include +#include #include +#include #include #include @@ -59,9 +60,10 @@ static gzFile gzbufdesc; static BZFILE* bzbufdesc; static lzma_stream lstrm = LZMA_STREAM_INIT; -static unsigned char buffer[MAXBUFSIZ]; +static unsigned char *buffer; static unsigned char *bufpos; static size_t bufrem; +static size_t fsiz; static unsigned char *lnbuf; static size_t lnbuflen; @@ -72,6 +74,9 @@ grep_refill(struct file *f) ssize_t nr; int bzerr; + if (filebehave == FILE_MMAP) + return (0); + bufpos = buffer; bufrem = 0; @@ -235,6 +240,33 @@ grep_open(const char *path) } else if ((f->fd = open(path, O_RDONLY)) == -1) goto error1; + if (filebehave == FILE_MMAP) { + struct stat st; + + if ((fstat(f->fd, &st) == -1) || (st.st_size > OFF_MAX) || + (!S_ISREG(st.st_mode))) + filebehave = FILE_STDIO; + else { + int flags = MAP_PRIVATE | MAP_NOCORE | MAP_NOSYNC; +#ifdef MAP_PREFAULT_READ + flags |= MAP_PREFAULT_READ; +#endif + fsiz = st.st_size; + buffer = mmap(NULL, fsiz, PROT_READ, flags, + f->fd, (off_t)0); + if (buffer == MAP_FAILED) + filebehave = FILE_STDIO; + else { + bufrem = st.st_size; + bufpos = buffer; + madvise(buffer, st.st_size, MADV_SEQUENTIAL); + } + } + } + + if ((buffer == NULL) || (buffer == MAP_FAILED)) + buffer = grep_malloc(MAXBUFSIZ); + if (filebehave == FILE_GZIP && (gzbufdesc = gzdopen(f->fd, "r")) == NULL) goto error2; @@ -244,7 +276,7 @@ grep_open(const char *path) goto error2; /* Fill read buffer, also catches errors early */ - if (grep_refill(f) != 0) + if (bufrem == 0 && grep_refill(f) != 0) goto error2; /* Check for binary stuff, if necessary */ @@ -270,6 +302,10 @@ grep_close(struct file *f) close(f->fd); /* Reset read buffer and line buffer */ + if (filebehave == FILE_MMAP) { + munmap(buffer, fsiz); + buffer = NULL; + } bufpos = buffer; bufrem = 0; Modified: user/gabor/grep/trunk/grep.c ============================================================================== --- user/gabor/grep/trunk/grep.c Tue Aug 30 16:20:16 2011 (r225263) +++ user/gabor/grep/trunk/grep.c Tue Aug 30 16:23:57 2011 (r225264) @@ -548,7 +548,7 @@ main(int argc, char *argv[]) break; case 'u': case MMAP_OPT: - /* noop, compatibility */ + filebehave = FILE_MMAP; break; case 'V': printf(getstr(9), __progname, VERSION); Modified: user/gabor/grep/trunk/grep.h ============================================================================== --- user/gabor/grep/trunk/grep.h Tue Aug 30 16:20:16 2011 (r225263) +++ user/gabor/grep/trunk/grep.h Tue Aug 30 16:23:57 2011 (r225264) @@ -60,10 +60,11 @@ extern const char *errstr[]; #define BINFILE_TEXT 2 #define FILE_STDIO 0 -#define FILE_GZIP 1 -#define FILE_BZIP 2 -#define FILE_XZ 3 -#define FILE_LZMA 4 +#define FILE_MMAP 1 +#define FILE_GZIP 2 +#define FILE_BZIP 3 +#define FILE_XZ 4 +#define FILE_LZMA 5 #define DIR_READ 0 #define DIR_SKIP 1 From owner-svn-src-user@FreeBSD.ORG Tue Aug 30 16:33:59 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C4550106566C; Tue, 30 Aug 2011 16:33:59 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B40E18FC13; Tue, 30 Aug 2011 16:33:59 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7UGXxGi058737; Tue, 30 Aug 2011 16:33:59 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7UGXxQ4058735; Tue, 30 Aug 2011 16:33:59 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108301633.p7UGXxQ4058735@svn.freebsd.org> From: Gabor Kovesdan Date: Tue, 30 Aug 2011 16:33:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225265 - user/gabor/tre-integration/contrib/tre/lib X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Aug 2011 16:33:59 -0000 Author: gabor Date: Tue Aug 30 16:33:59 2011 New Revision: 225265 URL: http://svn.freebsd.org/changeset/base/225265 Log: - Add missing #include Modified: user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Modified: user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Tue Aug 30 16:23:57 2011 (r225264) +++ user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Tue Aug 30 16:33:59 2011 (r225265) @@ -28,6 +28,7 @@ #ifdef HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ +#include #include #include #include From owner-svn-src-user@FreeBSD.ORG Tue Aug 30 16:40:18 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1F55B106566B; Tue, 30 Aug 2011 16:40:18 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0E1188FC26; Tue, 30 Aug 2011 16:40:18 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7UGeIGc058946; Tue, 30 Aug 2011 16:40:18 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7UGeIGk058943; Tue, 30 Aug 2011 16:40:18 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108301640.p7UGeIGk058943@svn.freebsd.org> From: Gabor Kovesdan Date: Tue, 30 Aug 2011 16:40:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225266 - user/gabor/grep/trunk/regex X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Aug 2011 16:40:18 -0000 Author: gabor Date: Tue Aug 30 16:40:17 2011 New Revision: 225266 URL: http://svn.freebsd.org/changeset/base/225266 Log: - Merge from TRE code Modified: user/gabor/grep/trunk/regex/glue.h user/gabor/grep/trunk/regex/hashtable.c user/gabor/grep/trunk/regex/hashtable.h user/gabor/grep/trunk/regex/tre-fastmatch.c Modified: user/gabor/grep/trunk/regex/glue.h ============================================================================== --- user/gabor/grep/trunk/regex/glue.h Tue Aug 30 16:33:59 2011 (r225265) +++ user/gabor/grep/trunk/regex/glue.h Tue Aug 30 16:40:17 2011 (r225266) @@ -10,6 +10,8 @@ #define TRE_WCHAR 1 #define TRE_MULTIBYTE 1 +#define TRE_CHAR(n) L##n + #define tre_char_t wchar_t #define tre_mbrtowc(pwc, s, n, ps) (mbrtowc((pwc), (s), (n), (ps))) #define tre_strlen wcslen @@ -19,6 +21,7 @@ #define REG_LITERAL 0020 #define REG_WORD 0100 #define REG_GNU 0400 +#define _REG_HEUR 1000 #define REG_OK 0 Modified: user/gabor/grep/trunk/regex/hashtable.c ============================================================================== --- user/gabor/grep/trunk/regex/hashtable.c Tue Aug 30 16:33:59 2011 (r225265) +++ user/gabor/grep/trunk/regex/hashtable.c Tue Aug 30 16:40:17 2011 (r225266) @@ -1,5 +1,3 @@ -/* $FreeBSD$ */ - /*- * Copyright (C) 2011 Gabor Kovesdan * All rights reserved. @@ -26,134 +24,208 @@ * SUCH DAMAGE. */ -#include -#include +#include #include #include -hashtable -*hashtable_init(size_t table_size, size_t key_size, size_t value_size) +#include "hashtable.h" + + +/* + * Return a 32-bit hash of the given buffer. The init + * value should be 0, or the previous hash value to extend + * the previous hash. + */ +static uint32_t +hash32_buf(const void *buf, size_t len, uint32_t hash) { - hashtable *tbl; + const unsigned char *p = buf; - tbl = malloc(sizeof(hashtable)); - if (tbl == NULL) - return (NULL); - - tbl->entries = calloc(sizeof(hashtable_entry *), table_size); - if (tbl->entries == NULL) { - free(tbl); - return (NULL); - } - - tbl->table_size = table_size; - tbl->usage = 0; - tbl->key_size = key_size; - tbl->value_size = value_size; + while (len--) + hash = HASHSTEP(hash, *p++); - return (tbl); + return hash; } +/* + * Initializes a hash table that can hold table_size number of entries, + * each of which has a key of key_size bytes and a value of value_size + * bytes. On successful allocation returns a pointer to the hash table. + * Otherwise, returns NULL and sets errno to indicate the error. + */ +hashtable +*hashtable_init(size_t table_size, size_t key_size, size_t value_size) +{ + hashtable *tbl; + + tbl = malloc(sizeof(hashtable)); + if (tbl == NULL) + goto mem1; + + tbl->entries = calloc(sizeof(hashtable_entry *), table_size); + if (tbl->entries == NULL) + goto mem2; + + tbl->table_size = table_size; + tbl->usage = 0; + tbl->key_size = key_size; + tbl->value_size = value_size; + + return (tbl); + +mem2: + free(tbl); +mem1: + errno = ENOMEM; + return (NULL); +} + +/* + * Places the key-value pair to the hashtable tbl. + * Returns: + * HASH_OK: if the key was not present in the hash table yet + * but the kay-value pair has been successfully added. + * HASH_UPDATED: if the value for the key has been updated with the + * new value. + * HASH_FULL: if the hash table is full and the entry could not + * be added. + * HASH_FAIL: if an error has occurred and errno has been set to + * indicate the error. + */ int hashtable_put(hashtable *tbl, const void *key, const void *value) { - uint32_t hash = 0; - - if (tbl->table_size == tbl->usage) - return (-1); + uint32_t hash = 0; - hash = hash32_buf(key, tbl->key_size, hash); - hash %= tbl->table_size; + if (tbl->table_size == tbl->usage) + return (HASH_FULL); - while (tbl->entries[hash] != NULL) - hash = (hash >= tbl->table_size) ? 0 : hash + 1; - - tbl->entries[hash] = malloc(sizeof(hashtable_entry)); - if (tbl->entries[hash] == NULL) - return (-1); - - tbl->entries[hash]->key = malloc(tbl->key_size); - if (tbl->entries[hash]->key == NULL) { - free(tbl->entries[hash]); - return (-1); - } - - tbl->entries[hash]->value = malloc(tbl->value_size); - if (tbl->entries[hash]->value == NULL) { - free(tbl->entries[hash]->key); - free(tbl->entries[hash]); - return (-1); - } - - memcpy(&tbl->entries[hash]->key, key, tbl->key_size); - memcpy(&tbl->entries[hash]->value, value, tbl->value_size); - tbl->usage++; + hash = hash32_buf(key, tbl->key_size, hash) % tbl->table_size; - return (0); + /* + * On hash collision entries are inserted at the next free space, + * so we have to increase the index until we either find an entry + * with the same key (and update it) or we find a free space. + */ + for(;;) + if (tbl->entries[hash] == NULL) + break; + else if (memcmp(tbl->entries[hash]->key, key, tbl->key_size) == 0) + { + memcpy(tbl->entries[hash]->value, value, tbl->value_size); + return (HASH_UPDATED); + } + + tbl->entries[hash] = malloc(sizeof(hashtable_entry)); + if (tbl->entries[hash] == NULL) + { + errno = ENOMEM; + goto mem1; + } + + tbl->entries[hash]->key = malloc(tbl->key_size); + if (tbl->entries[hash]->key == NULL) + { + errno = ENOMEM; + goto mem2; + } + + tbl->entries[hash]->value = malloc(tbl->value_size); + if (tbl->entries[hash]->value == NULL) + { + errno = ENOMEM; + goto mem3; + } + + memcpy(tbl->entries[hash]->key, key, tbl->key_size); + memcpy(tbl->entries[hash]->value, value, tbl->value_size); + tbl->usage++; + + return (HASH_OK); + +mem3: + free(tbl->entries[hash]->key); +mem2: + free(tbl->entries[hash]); +mem1: + return (HASH_FAIL); } static hashtable_entry -*hashtable_lookup(const hashtable *tbl, const void *key) +**hashtable_lookup(const hashtable *tbl, const void *key) { - uint32_t hash = 0; + uint32_t hash = 0; - hash = hash32_buf(key, tbl->key_size, hash); - hash %= tbl->table_size; + hash = hash32_buf(key, tbl->key_size, hash) % tbl->table_size; - for (;;) { - if (tbl->entries[hash] == NULL) - return (NULL); - else if (memcmp(key, &tbl->entries[hash]->key, - tbl->key_size) == 0) - return (tbl->entries[hash]); + for (;;) + { + if (tbl->entries[hash] == NULL) + return (NULL); + else if (memcmp(key, tbl->entries[hash]->key, tbl->key_size) == 0) + return (&tbl->entries[hash]); - hash = (hash == tbl->table_size) ? 0 : hash + 1; - } + hash = (hash == tbl->table_size) ? 0 : hash + 1; + } } +/* + * Retrieves the value for key from the hash table tbl and places + * it to the space indicated by the value argument. + * Returns HASH_OK if the value has been found and retrieved or + * HASH_NOTFOUND otherwise. + */ int hashtable_get(hashtable *tbl, const void *key, void *value) { - hashtable_entry *entry; + hashtable_entry **entry; - entry = hashtable_lookup(tbl, key); - if (entry == NULL) - return (-1); + entry = hashtable_lookup(tbl, key); + if (entry == NULL) + return (HASH_NOTFOUND); - memcpy(value, &entry->value, tbl->value_size); - return (0); + memcpy(value, (*entry)->value, tbl->value_size); + return (HASH_OK); } +/* + * Removes the entry with the specifified key from the hash table + * tbl. Returns HASH_OK if the entry has been found and removed + * or HASH_NOTFOUND otherwise. + */ int hashtable_remove(hashtable *tbl, const void *key) { - hashtable_entry *entry; + hashtable_entry **entry; - entry = hashtable_lookup(tbl, key); - if (entry == NULL) - return (-1); + entry = hashtable_lookup(tbl, key); + if (entry == NULL) + return (HASH_NOTFOUND); -// free(entry->key); -// free(entry->value); - free(entry); + free((*entry)->key); + free((*entry)->value); + free(*entry); + *entry = NULL; - tbl->usage--; - - return (0); + tbl->usage--; + return (HASH_OK); } +/* + * Frees the resources associated with the hash table tbl. + */ void hashtable_free(hashtable *tbl) { + if (tbl == NULL) + return; - if (tbl == NULL) - return; + for (unsigned int i = 0; i < tbl->table_size; i++) + if ((tbl->entries[i] != NULL)) + { + free(tbl->entries[i]->key); + free(tbl->entries[i]->value); + } - for (unsigned int i = 0; i < tbl->table_size; i++) - if (tbl->entries[i] != NULL) { -// free(tbl->entries[i]->key); -// free(tbl->entries[i]->value); -// free(tbl->entries[i]); - } - free(tbl->entries); + free(tbl->entries); } Modified: user/gabor/grep/trunk/regex/hashtable.h ============================================================================== --- user/gabor/grep/trunk/regex/hashtable.h Tue Aug 30 16:33:59 2011 (r225265) +++ user/gabor/grep/trunk/regex/hashtable.h Tue Aug 30 16:40:17 2011 (r225266) @@ -5,23 +5,31 @@ #include +#define HASH_OK 0 +#define HASH_UPDATED 1 +#define HASH_FAIL 2 +#define HASH_FULL 3 +#define HASH_NOTFOUND 4 + +#define HASHSTEP(x,c) (((x << 5) + x) + (c)) + typedef struct { - void *key; - void *value; + void *key; + void *value; } hashtable_entry; typedef struct { - size_t key_size; - size_t table_size; - size_t usage; - size_t value_size; - hashtable_entry **entries; + size_t key_size; + size_t table_size; + size_t usage; + size_t value_size; + hashtable_entry **entries; } hashtable; -void hashtable_free(hashtable *); -int hashtable_get(hashtable *, const void *, void *); -hashtable *hashtable_init(size_t, size_t, size_t); -int hashtable_put(hashtable *, const void *, const void *); -int hashtable_remove(hashtable *, const void *); +void hashtable_free(hashtable *); +int hashtable_get(hashtable *, const void *, void *); +hashtable *hashtable_init(size_t, size_t, size_t); +int hashtable_put(hashtable *, const void *, const void *); +int hashtable_remove(hashtable *, const void *); #endif /* HASHTABLE.H */ Modified: user/gabor/grep/trunk/regex/tre-fastmatch.c ============================================================================== --- user/gabor/grep/trunk/regex/tre-fastmatch.c Tue Aug 30 16:33:59 2011 (r225265) +++ user/gabor/grep/trunk/regex/tre-fastmatch.c Tue Aug 30 16:40:17 2011 (r225266) @@ -1,5 +1,3 @@ -/* $FreeBSD$ */ - /*- * Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav * Copyright (C) 2008-2011 Gabor Kovesdan @@ -30,7 +28,6 @@ #include "glue.h" #include -#include #include #include #include @@ -48,14 +45,17 @@ static int fastcmp(const void *, const void *, size_t, tre_str_type_t, bool, bool); -/* - * We will work with wide characters if they are supported - */ -#ifdef TRE_WCHAR -#define TRE_CHAR(n) L##n -#else -#define TRE_CHAR(n) n -#endif +#define FAIL_COMP(errcode) \ + { \ + if (fg->pattern) \ + xfree(fg->pattern); \ + if (fg->wpattern) \ + xfree(fg->wpattern); \ + if (fg->qsBc_table) \ + hashtable_free(fg->qsBc_table); \ + fg = NULL; \ + return errcode; \ + } /* * Skips n characters in the input string and assigns the start @@ -143,7 +143,10 @@ static int fastcmp(const void *, const v &((tre_char_t *)startptr)[mismatch + 1], &bc); \ gs = fg->bmGs[mismatch]; \ } \ - bc = (r == 0) ? bc : fg->defBc; \ + bc = (r == HASH_OK) ? bc : fg->defBc; \ + DPRINT(("tre_fast_match: mismatch on character %lc," \ + "BC %d, GS %d\n", \ + ((tre_char_t *)startptr)[mismatch + 1], bc, gs)); \ break; \ default: \ if (!fg->hasdot) \ @@ -154,6 +157,9 @@ static int fastcmp(const void *, const v gs = fg->sbmGs[mismatch]; \ } \ bc = fg->qsBc[((unsigned char *)startptr)[mismatch + 1]]; \ + DPRINT(("tre_fast_match: mismatch on character %c," \ + "BC %d, GS %d\n", \ + ((unsigned char *)startptr)[mismatch + 1], bc, gs)); \ } \ if (fg->hasdot) \ shift = bc; \ @@ -171,6 +177,7 @@ static int fastcmp(const void *, const v u = 0; \ } \ } \ + DPRINT(("tre_fast_match: shifting %d characters\n", shift)); \ j += shift; \ } @@ -200,6 +207,8 @@ static int fastcmp(const void *, const v for (int i = fg->hasdot + 1; i < fg->len; i++) \ { \ fg->qsBc[(unsigned)fg->pattern[i]] = fg->len - i; \ + DPRINT(("BC shift for char %c is %d\n", fg->pattern[i], \ + fg->len - i)); \ if (fg->icase) \ { \ char c = islower(fg->pattern[i]) ? toupper(fg->pattern[i]) \ @@ -224,15 +233,25 @@ static int fastcmp(const void *, const v /* Preprocess pattern. */ \ fg->qsBc_table = hashtable_init(fg->wlen * 4, sizeof(tre_char_t), \ sizeof(int)); \ + if (!fg->qsBc_table) \ + FAIL_COMP(REG_ESPACE); \ for (unsigned int i = fg->hasdot + 1; i < fg->wlen; i++) \ { \ int k = fg->wlen - i; \ - hashtable_put(fg->qsBc_table, &fg->wpattern[i], &k); \ + int r; \ + \ + r = hashtable_put(fg->qsBc_table, &fg->wpattern[i], &k); \ + if ((r == HASH_FAIL) || (r == HASH_FULL)) \ + FAIL_COMP(REG_ESPACE); \ + DPRINT(("BC shift for wide char %lc is %d\n", fg->wpattern[i], \ + fg->wlen - i)); \ if (fg->icase) \ { \ tre_char_t wc = iswlower(fg->wpattern[i]) ? \ towupper(fg->wpattern[i]) : towlower(fg->wpattern[i]); \ - hashtable_put(fg->qsBc_table, &wc, &k); \ + r = hashtable_put(fg->qsBc_table, &wc, &k); \ + if ((r == HASH_FAIL) || (r == HASH_FULL)) \ + FAIL_COMP(REG_ESPACE); \ } \ } @@ -245,7 +264,10 @@ static int fastcmp(const void *, const v fg->sbmGs = xmalloc(fg->len * sizeof(int)); \ if (!fg->sbmGs) \ return REG_ESPACE; \ - _FILL_BMGS(fg->sbmGs, fg->pattern, fg->len, false); \ + if (fg->len == 1) \ + fg->sbmGs[0] = 1; \ + else \ + _FILL_BMGS(fg->sbmGs, fg->pattern, fg->len, false); \ } /* @@ -257,7 +279,10 @@ static int fastcmp(const void *, const v fg->bmGs = xmalloc(fg->wlen * sizeof(int)); \ if (!fg->bmGs) \ return REG_ESPACE; \ - _FILL_BMGS(fg->bmGs, fg->wpattern, fg->wlen, true); \ + if (fg->wlen == 1) \ + fg->bmGs[0] = 1; \ + else \ + _FILL_BMGS(fg->bmGs, fg->wpattern, fg->wlen, true); \ } #define _FILL_BMGS(arr, pat, plen, wide) \ @@ -385,6 +410,10 @@ tre_compile_literal(fastmatch_t *fg, con SAVE_PATTERN(fg->pattern, fg->len); #endif + DPRINT(("tre_compile_literal: pattern: %s, icase: %c, word: %c, " + "newline %c\n", fg->pattern, fg->icase ? 'y' : 'n', + fg->word ? 'y' : 'n', fg->newline ? 'y' : 'n')); + FILL_QSBC; FILL_BMGS; #ifdef TRE_WCHAR @@ -438,10 +467,11 @@ tre_compile_fast(fastmatch_t *fg, const for (unsigned int i = 0; i < n; i++) { /* Can still cheat? */ - if ((tre_isalnum(pat[i])) || tre_isspace(pat[i]) || + if (!(cflags & _REG_HEUR) && + ((tre_isalnum(pat[i])) || tre_isspace(pat[i]) || (pat[i] == TRE_CHAR('_')) || (pat[i] == TRE_CHAR(',')) || (pat[i] == TRE_CHAR('=')) || (pat[i] == TRE_CHAR('-')) || - (pat[i] == TRE_CHAR(':')) || (pat[i] == TRE_CHAR('/'))) + (pat[i] == TRE_CHAR(':')) || (pat[i] == TRE_CHAR('/')))) continue; else if (pat[i] == TRE_CHAR('.')) fg->hasdot = i; @@ -461,6 +491,12 @@ tre_compile_fast(fastmatch_t *fg, const SAVE_PATTERN(fg->pattern, fg->len); #endif + DPRINT(("tre_compile_fast: pattern: %s, bol %c, eol %c, " + "icase: %c, word: %c, newline %c\n", fg->pattern, + fg->bol ? 'y' : 'n', fg->eol ? 'y' : 'n', + fg->icase ? 'y' : 'n', fg->word ? 'y' : 'n', + fg->newline ? 'y' : 'n')); + FILL_QSBC; FILL_BMGS; #ifdef TRE_WCHAR @@ -644,6 +680,9 @@ void tre_free_fast(fastmatch_t *fg) { + DPRINT(("tre_fast_free: freeing structures for pattern %s\n", + fg->pattern)); + #ifdef TRE_WCHAR hashtable_free(fg->qsBc_table); if (!fg->hasdot) @@ -697,6 +736,7 @@ fastcmp(const void *pat, const void *dat : (pat_byte[i] == str_byte[i])) continue; } + DPRINT(("fastcmp: mismatch at position %d\n", i)); ret = -(i + 1); break; } From owner-svn-src-user@FreeBSD.ORG Tue Aug 30 23:16:55 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 58AF91065676; Tue, 30 Aug 2011 23:16:55 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 499918FC19; Tue, 30 Aug 2011 23:16:55 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7UNGtA5070970; Tue, 30 Aug 2011 23:16:55 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7UNGt3N070965; Tue, 30 Aug 2011 23:16:55 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108302316.p7UNGt3N070965@svn.freebsd.org> From: Gabor Kovesdan Date: Tue, 30 Aug 2011 23:16:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225273 - user/gabor/grep/trunk/regex X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Aug 2011 23:16:55 -0000 Author: gabor Date: Tue Aug 30 23:16:54 2011 New Revision: 225273 URL: http://svn.freebsd.org/changeset/base/225273 Log: - Fix a bug in the hashtable code that caused an infinite loop - While here, add some debug output that helped debugging Modified: user/gabor/grep/trunk/regex/fastmatch.c user/gabor/grep/trunk/regex/glue.h user/gabor/grep/trunk/regex/hashtable.c user/gabor/grep/trunk/regex/tre-fastmatch.c Modified: user/gabor/grep/trunk/regex/fastmatch.c ============================================================================== --- user/gabor/grep/trunk/regex/fastmatch.c Tue Aug 30 20:54:55 2011 (r225272) +++ user/gabor/grep/trunk/regex/fastmatch.c Tue Aug 30 23:16:54 2011 (r225273) @@ -28,6 +28,7 @@ #include "glue.h" +#include #include #include #include Modified: user/gabor/grep/trunk/regex/glue.h ============================================================================== --- user/gabor/grep/trunk/regex/glue.h Tue Aug 30 20:54:55 2011 (r225272) +++ user/gabor/grep/trunk/regex/glue.h Tue Aug 30 23:16:54 2011 (r225273) @@ -6,6 +6,7 @@ #include #undef RE_DUP_MAX #include +#include #define TRE_WCHAR 1 #define TRE_MULTIBYTE 1 @@ -27,7 +28,12 @@ #define TRE_MB_CUR_MAX MB_CUR_MAX -#define DPRINT(msg) +#ifndef _GREP_DEBUG +#define DPRINT(msg) +#else +#define DPRINT(msg) do {printf msg; fflush(stdout);} while(/*CONSTCOND*/0) +#endif + #define MIN(a,b) ((a > b) ? (b) : (a)) #define MAX(a,b) ((a > b) ? (a) : (b)) Modified: user/gabor/grep/trunk/regex/hashtable.c ============================================================================== --- user/gabor/grep/trunk/regex/hashtable.c Tue Aug 30 20:54:55 2011 (r225272) +++ user/gabor/grep/trunk/regex/hashtable.c Tue Aug 30 23:16:54 2011 (r225273) @@ -24,6 +24,8 @@ * SUCH DAMAGE. */ +#include "glue.h" + #include #include #include @@ -58,6 +60,10 @@ hashtable { hashtable *tbl; + DPRINT(("hashtable_init: table_size %lu, key_size %lu, value_size %lu\n", + (unsigned long)table_size, (unsigned long)key_size, + (unsigned long)value_size)); + tbl = malloc(sizeof(hashtable)); if (tbl == NULL) goto mem1; @@ -76,6 +82,7 @@ hashtable mem2: free(tbl); mem1: + DPRINT(("hashtable_init: allocation failed\n")); errno = ENOMEM; return (NULL); } @@ -98,9 +105,13 @@ hashtable_put(hashtable *tbl, const void uint32_t hash = 0; if (tbl->table_size == tbl->usage) - return (HASH_FULL); + { + DPRINT(("hashtable_put: hashtable is full\n")); + return (HASH_FULL); + } hash = hash32_buf(key, tbl->key_size, hash) % tbl->table_size; + DPRINT(("hashtable_put: calculated hash %lu\n", hash)); /* * On hash collision entries are inserted at the next free space, @@ -108,13 +119,21 @@ hashtable_put(hashtable *tbl, const void * with the same key (and update it) or we find a free space. */ for(;;) - if (tbl->entries[hash] == NULL) - break; - else if (memcmp(tbl->entries[hash]->key, key, tbl->key_size) == 0) - { - memcpy(tbl->entries[hash]->value, value, tbl->value_size); - return (HASH_UPDATED); - } + { + if (tbl->entries[hash] == NULL) + break; + else if (memcmp(tbl->entries[hash]->key, key, tbl->key_size) == 0) + { + memcpy(tbl->entries[hash]->value, value, tbl->value_size); + DPRINT(("hashtable_put: effective location is %lu, " + "entry updated\n", hash)); + return (HASH_UPDATED); + } + if (++hash == tbl->table_size) + hash = 0; + } + + DPRINT(("hashtable_put: effective location is %lu\n", hash)); tbl->entries[hash] = malloc(sizeof(hashtable_entry)); if (tbl->entries[hash] == NULL) @@ -141,6 +160,8 @@ hashtable_put(hashtable *tbl, const void memcpy(tbl->entries[hash]->value, value, tbl->value_size); tbl->usage++; + DPRINT(("hashtable_put: entry successfully inserted\n")); + return (HASH_OK); mem3: @@ -148,6 +169,7 @@ mem3: mem2: free(tbl->entries[hash]); mem1: + DPRINT(("hashtable_put: insertion failed\n")); return (HASH_FAIL); } @@ -163,9 +185,13 @@ static hashtable_entry if (tbl->entries[hash] == NULL) return (NULL); else if (memcmp(key, tbl->entries[hash]->key, tbl->key_size) == 0) - return (&tbl->entries[hash]); + { + DPRINT(("hashtable_lookup: entry found at location %lu\n", hash)); + return (&tbl->entries[hash]); + } - hash = (hash == tbl->table_size) ? 0 : hash + 1; + if (++hash == tbl->table_size) + hash = 0; } } @@ -182,9 +208,13 @@ hashtable_get(hashtable *tbl, const void entry = hashtable_lookup(tbl, key); if (entry == NULL) - return (HASH_NOTFOUND); + { + DPRINT(("hashtable_get: entry is not available in the hashtable\n")); + return (HASH_NOTFOUND); + } memcpy(value, (*entry)->value, tbl->value_size); + DPRINT(("hashtable_get: entry successfully copied into output buffer\n")); return (HASH_OK); } @@ -200,7 +230,10 @@ hashtable_remove(hashtable *tbl, const v entry = hashtable_lookup(tbl, key); if (entry == NULL) - return (HASH_NOTFOUND); + { + DPRINT(("hashtable_remove: entry is not available in the hashtable\n")); + return (HASH_NOTFOUND); + } free((*entry)->key); free((*entry)->value); @@ -208,6 +241,7 @@ hashtable_remove(hashtable *tbl, const v *entry = NULL; tbl->usage--; + DPRINT(("hashtable_remove: entry successfully removed\n")); return (HASH_OK); } @@ -228,4 +262,5 @@ hashtable_free(hashtable *tbl) } free(tbl->entries); + DPRINT(("hashtable_free: resources are successfully freed\n")); } Modified: user/gabor/grep/trunk/regex/tre-fastmatch.c ============================================================================== --- user/gabor/grep/trunk/regex/tre-fastmatch.c Tue Aug 30 20:54:55 2011 (r225272) +++ user/gabor/grep/trunk/regex/tre-fastmatch.c Tue Aug 30 23:16:54 2011 (r225273) @@ -144,7 +144,7 @@ static int fastcmp(const void *, const v gs = fg->bmGs[mismatch]; \ } \ bc = (r == HASH_OK) ? bc : fg->defBc; \ - DPRINT(("tre_fast_match: mismatch on character %lc," \ + DPRINT(("tre_fast_match: mismatch on character %lc, " \ "BC %d, GS %d\n", \ ((tre_char_t *)startptr)[mismatch + 1], bc, gs)); \ break; \ @@ -157,7 +157,7 @@ static int fastcmp(const void *, const v gs = fg->sbmGs[mismatch]; \ } \ bc = fg->qsBc[((unsigned char *)startptr)[mismatch + 1]]; \ - DPRINT(("tre_fast_match: mismatch on character %c," \ + DPRINT(("tre_fast_match: mismatch on character %c, " \ "BC %d, GS %d\n", \ ((unsigned char *)startptr)[mismatch + 1], bc, gs)); \ } \ @@ -214,6 +214,7 @@ static int fastcmp(const void *, const v char c = islower(fg->pattern[i]) ? toupper(fg->pattern[i]) \ : tolower(fg->pattern[i]); \ fg->qsBc[(unsigned)c] = fg->len - i; \ + DPRINT(("BC shift for char %c is %d\n", c, fg->len - i)); \ } \ } @@ -231,7 +232,7 @@ static int fastcmp(const void *, const v fg->defBc = fg->wlen - fg->hasdot; \ \ /* Preprocess pattern. */ \ - fg->qsBc_table = hashtable_init(fg->wlen * 4, sizeof(tre_char_t), \ + fg->qsBc_table = hashtable_init(fg->wlen * 8, sizeof(tre_char_t), \ sizeof(int)); \ if (!fg->qsBc_table) \ FAIL_COMP(REG_ESPACE); \ @@ -252,6 +253,8 @@ static int fastcmp(const void *, const v r = hashtable_put(fg->qsBc_table, &wc, &k); \ if ((r == HASH_FAIL) || (r == HASH_FULL)) \ FAIL_COMP(REG_ESPACE); \ + DPRINT(("BC shift for wide char %lc is %d\n", wc, \ + fg->wlen - i)); \ } \ } From owner-svn-src-user@FreeBSD.ORG Tue Aug 30 23:55:46 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0429E106566B; Tue, 30 Aug 2011 23:55:46 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E9C778FC0A; Tue, 30 Aug 2011 23:55:45 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7UNtjK5072131; Tue, 30 Aug 2011 23:55:45 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7UNtjZP072129; Tue, 30 Aug 2011 23:55:45 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108302355.p7UNtjZP072129@svn.freebsd.org> From: Gabor Kovesdan Date: Tue, 30 Aug 2011 23:55:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225274 - user/gabor/grep/trunk X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Aug 2011 23:55:46 -0000 Author: gabor Date: Tue Aug 30 23:55:45 2011 New Revision: 225274 URL: http://svn.freebsd.org/changeset/base/225274 Log: - Avoid segfault wheen pattern file is not a regular file Modified: user/gabor/grep/trunk/grep.c Modified: user/gabor/grep/trunk/grep.c ============================================================================== --- user/gabor/grep/trunk/grep.c Tue Aug 30 23:16:54 2011 (r225273) +++ user/gabor/grep/trunk/grep.c Tue Aug 30 23:55:45 2011 (r225274) @@ -289,10 +289,13 @@ add_dpattern(const char *pat, int mode) static void read_patterns(const char *fn) { + struct stat st; FILE *f; char *line; size_t len; + if ((stat(fn, &st) == -1) || !(S_ISREG(st.st_mode))) + return; if ((f = fopen(fn, "r")) == NULL) err(2, "%s", fn); while ((line = fgetln(f, &len)) != NULL) @@ -637,6 +640,10 @@ main(int argc, char *argv[]) aargc -= optind; aargv += optind; + /* Empty pattern file matches nothing */ + if (!needpattern && (patterns == 0)) + exit(1); + /* Fail if we don't have any pattern */ if (aargc == 0 && needpattern) usage(); From owner-svn-src-user@FreeBSD.ORG Wed Aug 31 02:47:19 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 27D711065676; Wed, 31 Aug 2011 02:47:19 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1701C8FC15; Wed, 31 Aug 2011 02:47:19 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7V2lICg077419; Wed, 31 Aug 2011 02:47:18 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7V2lIXI077417; Wed, 31 Aug 2011 02:47:18 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108310247.p7V2lIXI077417@svn.freebsd.org> From: Adrian Chadd Date: Wed, 31 Aug 2011 02:47:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225277 - user/adrian/if_ath_tx/sys/dev/ath X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Aug 2011 02:47:19 -0000 Author: adrian Date: Wed Aug 31 02:47:18 2011 New Revision: 225277 URL: http://svn.freebsd.org/changeset/base/225277 Log: Remove this ; bf_state is now blanked for us in _ath_getbuf_locked(). Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Wed Aug 31 01:18:23 2011 (r225276) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Wed Aug 31 02:47:18 2011 (r225277) @@ -2003,21 +2003,6 @@ ath_tx_swq(struct ath_softc *sc, struct bf->bf_state.bfs_txq = txq; bf->bf_state.bfs_pri = pri; - /* - * blank out fields which will be overridden if needed - * Don't touch bfs_dobaw - that's already been set by - * ath_tx_start(). - */ - bf->bf_state.bfs_aggr = 0; - bf->bf_state.bfs_aggrburst = 0; - bf->bf_next = NULL; - bf->bf_state.bfs_retries = 0; - bf->bf_state.bfs_isretried = 0; - bf->bf_state.bfs_ndelim = 0; - bf->bf_state.bfs_nframes = 0; - bf->bf_state.bfs_al = 0; - bf->bf_state.bfs_addedbaw = 0; - /* Queue frame to the tail of the software queue */ ATH_TXQ_LOCK(txq); ATH_TXQ_INSERT_TAIL(atid, bf, bf_list); From owner-svn-src-user@FreeBSD.ORG Wed Aug 31 03:04:57 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2A36F106566B; Wed, 31 Aug 2011 03:04:57 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0E6788FC08; Wed, 31 Aug 2011 03:04:57 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7V34uAV078103; Wed, 31 Aug 2011 03:04:56 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7V34uV3078101; Wed, 31 Aug 2011 03:04:56 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108310304.p7V34uV3078101@svn.freebsd.org> From: Adrian Chadd Date: Wed, 31 Aug 2011 03:04:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225278 - user/adrian/if_ath_tx/sys/dev/ath X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Aug 2011 03:04:57 -0000 Author: adrian Date: Wed Aug 31 03:04:56 2011 New Revision: 225278 URL: http://svn.freebsd.org/changeset/base/225278 Log: Break out the common code which sends a non-aggregate packet to the hardware into a new function, ath_tx_xmit_normal(). Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Wed Aug 31 02:47:18 2011 (r225277) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Wed Aug 31 03:04:56 2011 (r225278) @@ -867,6 +867,29 @@ ath_tx_set_ratectrl(struct ath_softc *sc } } +/* + * Transmit the given frame to the hardware. + * + * The frame must already be setup; rate control must already have + * been done. + */ +static void +ath_tx_xmit_normal(struct ath_softc *sc, struct ath_txq *txq, + struct ath_buf *bf) +{ + /* Setup the descriptor before handoff */ + ath_tx_set_rtscts(sc, bf); + ath_tx_setds(sc, bf); + ath_tx_set_ratectrl(sc, bf->bf_node, bf); + ath_tx_chaindesclist(sc, bf); + + ATH_TXQ_LOCK(txq); + ath_tx_handoff(sc, txq, bf); + ATH_TXQ_UNLOCK(txq); +} + + + static int ath_tx_normal_setup(struct ath_softc *sc, struct ieee80211_node *ni, struct ath_buf *bf, struct mbuf *m0) @@ -1350,15 +1373,7 @@ ath_tx_start(struct ath_softc *sc, struc * queuing it, as the TID will now be paused. */ if (txq == &avp->av_mcastq) { - /* Setup the descriptor before handoff */ - ath_tx_set_rtscts(sc, bf); - ath_tx_setds(sc, bf); - ath_tx_set_ratectrl(sc, ni, bf); - ath_tx_chaindesclist(sc, bf); - - ATH_TXQ_LOCK(txq); - ath_tx_handoff(sc, txq, bf); - ATH_TXQ_UNLOCK(txq); + ath_tx_xmit_normal(sc, txq, bf); } else if (type == IEEE80211_FC0_TYPE_CTL && subtype == IEEE80211_FC0_SUBTYPE_BAR) { /* @@ -1375,16 +1390,7 @@ ath_tx_start(struct ath_softc *sc, struc */ DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: BAR: TX'ing direct\n", __func__); - - /* Setup the descriptor before handoff */ - ath_tx_set_rtscts(sc, bf); - ath_tx_setds(sc, bf); - ath_tx_set_ratectrl(sc, ni, bf); - ath_tx_chaindesclist(sc, bf); - - ATH_TXQ_LOCK(txq); - ath_tx_handoff(sc, txq, bf); - ATH_TXQ_UNLOCK(txq); + ath_tx_xmit_normal(sc, txq, bf); } else { /* add to software queue */ ath_tx_swq(sc, ni, txq, bf); @@ -1394,16 +1400,7 @@ ath_tx_start(struct ath_softc *sc, struc * For now, since there's no software queue, * direct-dispatch to the hardware. */ - - /* Setup the descriptor before handoff */ - ath_tx_set_rtscts(sc, bf); - ath_tx_setds(sc, bf); - ath_tx_set_ratectrl(sc, ni, bf); - ath_tx_chaindesclist(sc, bf); - - ATH_TXQ_LOCK(txq); - ath_tx_handoff(sc, txq, bf); - ATH_TXQ_UNLOCK(txq); + ath_tx_xmit_normal(sc, txq, bf); #endif return 0; @@ -1606,15 +1603,8 @@ ath_tx_raw_start(struct ath_softc *sc, s DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: dooverride=%d\n", __func__, do_override); - if (do_override) { - ath_tx_set_rtscts(sc, bf); - ath_tx_setds(sc, bf); - ath_tx_set_ratectrl(sc, ni, bf); - ath_tx_chaindesclist(sc, bf); - ATH_TXQ_LOCK(sc->sc_ac2q[pri]); - ath_tx_handoff(sc, sc->sc_ac2q[pri], bf); - ATH_TXQ_UNLOCK(sc->sc_ac2q[pri]); - } + if (do_override) + ath_tx_xmit_normal(sc, sc->sc_ac2q[pri], bf); else { /* Queue to software queue */ ath_tx_swq(sc, ni, sc->sc_ac2q[pri], bf); From owner-svn-src-user@FreeBSD.ORG Wed Aug 31 04:57:12 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 850A3106566B; Wed, 31 Aug 2011 04:57:12 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7333A8FC13; Wed, 31 Aug 2011 04:57:12 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7V4vCVf081632; Wed, 31 Aug 2011 04:57:12 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7V4vCiq081626; Wed, 31 Aug 2011 04:57:12 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108310457.p7V4vCiq081626@svn.freebsd.org> From: Adrian Chadd Date: Wed, 31 Aug 2011 04:57:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225279 - user/adrian/if_ath_tx/sys/dev/ath X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Aug 2011 04:57:12 -0000 Author: adrian Date: Wed Aug 31 04:57:11 2011 New Revision: 225279 URL: http://svn.freebsd.org/changeset/base/225279 Log: As much as I dislike it, migrate the driver back to doing direct dispatch to hardware. This matches what the Linux/atheros reference code does. If the hardware txq isn't busy, start filling it with non-aggregate frames. If it's sufficiently busy, start aggregating frames in the background. The aim is to massage this code back to match the structure of the reference code in order to make porting/debugging easier. I may move it back to task-based TX at a later stage, but only once the rest of the TX path has been fully debugged. This drops the CPU use a little but there's still a problem breaking > 100mbit on the MIPS dev boards I'm using. (The same dev board can do 250mbit RX on the same NIC, so it's not necessarily unable to do it.) Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath.c user/adrian/if_ath_tx/sys/dev/ath/if_ath_sysctl.c user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c user/adrian/if_ath_tx/sys/dev/ath/if_athioctl.h user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Wed Aug 31 03:04:56 2011 (r225278) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Wed Aug 31 04:57:11 2011 (r225279) @@ -176,7 +176,6 @@ static void ath_tx_cleanup(struct ath_so static void ath_tx_proc_q0(void *, int); static void ath_tx_proc_q0123(void *, int); static void ath_tx_proc(void *, int); -static void ath_tx_sched_proc(void *, int); static int ath_chan_set(struct ath_softc *, struct ieee80211_channel *); static void ath_draintxq(struct ath_softc *); static void ath_stoprecv(struct ath_softc *); @@ -399,7 +398,6 @@ ath_attach(u_int16_t devid, struct ath_s TASK_INIT(&sc->sc_rxtask, 0, ath_rx_proc, sc); TASK_INIT(&sc->sc_bmisstask, 0, ath_bmiss_proc, sc); TASK_INIT(&sc->sc_bstucktask,0, ath_bstuck_proc, sc); - TASK_INIT(&sc->sc_txschedtask, 0, ath_tx_sched_proc, sc); /* * Allocate hardware transmit queues: one queue for @@ -2044,13 +2042,6 @@ ath_start(struct ifnet *ifp) sc->sc_wd_timer = 5; } - - /* - * Schedule the software TX process to occur - * if we transmitted at least one packet. - */ - if (tx) - ath_tx_sched_proc_sched(sc, NULL); } static int @@ -4523,41 +4514,6 @@ ath_tx_proc(void *arg, int npending) } /* - * TX scheduling - * - * This calls the per-TXQ TX queue packet scheduling code. - * - * Note: there's no need to handle the mcastq; it doesn't have - * a software TID queue attached (as it's a software queue in - * itself.) - */ -static void -ath_tx_sched_proc(void *arg, int npending) -{ - struct ath_softc *sc = arg; - struct ath_txq *txq; - int i; - - for (i = 0; i < HAL_NUM_TX_QUEUES; i++) { - txq = &sc->sc_txq[i]; - if (ATH_TXQ_SETUP(sc, i)) { - ATH_TXQ_LOCK(txq); - ath_txq_sched(sc, txq); - ATH_TXQ_UNLOCK(txq); - } - } -} - -/* - * Schedule a TXQ scheduling task to occur. - */ -void -ath_tx_sched_proc_sched(struct ath_softc *sc, struct ath_txq *txq) -{ - taskqueue_enqueue(sc->sc_tq, &sc->sc_txschedtask); -} - -/* * Return a buffer to the pool. * The caller must free the mbuf and recycle the node reference. */ Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_sysctl.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_sysctl.c Wed Aug 31 03:04:56 2011 (r225278) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_sysctl.c Wed Aug 31 04:57:11 2011 (r225279) @@ -321,6 +321,8 @@ ath_sysctl_txagg(SYSCTL_HANDLER_ARGS) sc->sc_stats.tx_aggr.aggr_nonbaw_pkt); printf("aggr aggregate packet: %d\n", sc->sc_stats.tx_aggr.aggr_aggr_pkt); + printf("aggr single packet low hwq: %d\n", + sc->sc_stats.tx_aggr.aggr_low_hwq_single_pkt); for (i = 0; i < 64; i++) { printf("%2d: %10d ", i, sc->sc_stats.tx_aggr.aggr_pkts[i]); if (i % 4 == 3) Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Wed Aug 31 03:04:56 2011 (r225278) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Wed Aug 31 04:57:11 2011 (r225279) @@ -872,20 +872,27 @@ ath_tx_set_ratectrl(struct ath_softc *sc * * The frame must already be setup; rate control must already have * been done. + * + * XXX since the TXQ lock is being held here (and I dislike holding + * it for this long when not doing software aggregation), later on + * break this function into "setup_normal" and "xmit_normal". The + * lock only needs to be held for the ath_tx_handoff call. */ static void ath_tx_xmit_normal(struct ath_softc *sc, struct ath_txq *txq, struct ath_buf *bf) { + + ATH_TXQ_LOCK_ASSERT(txq); + /* Setup the descriptor before handoff */ ath_tx_set_rtscts(sc, bf); ath_tx_setds(sc, bf); ath_tx_set_ratectrl(sc, bf->bf_node, bf); ath_tx_chaindesclist(sc, bf); - ATH_TXQ_LOCK(txq); + /* Hand off to hardware */ ath_tx_handoff(sc, txq, bf); - ATH_TXQ_UNLOCK(txq); } @@ -1371,26 +1378,24 @@ ath_tx_start(struct ath_softc *sc, struc * If it's a BAR frame, do a direct dispatch to the * destination hardware queue. Don't bother software * queuing it, as the TID will now be paused. + * Sending a BAR frame can occur from the net80211 txa timer + * (ie, retries) or from the ath txtask (completion call.) + * It queues directly to hardware because the TID is paused + * at this point (and won't be unpaused until the BAR has + * either been TXed successfully or max retries has been + * reached.) */ if (txq == &avp->av_mcastq) { + ATH_TXQ_LOCK(txq); ath_tx_xmit_normal(sc, txq, bf); + ATH_TXQ_UNLOCK(txq); } else if (type == IEEE80211_FC0_TYPE_CTL && subtype == IEEE80211_FC0_SUBTYPE_BAR) { - /* - * XXX The following is dirty but needed for now. - * - * Sending a BAR frame can occur from the net80211 txa timer - * (ie, retries) or from the ath txtask (completion call.) - * It queues directly to hardware because the TID is paused - * at this point (and won't be unpaused until the BAR has - * either been TXed successfully or max retries has been - * reached.) - * - * TODO: sending a BAR should be done at the management rate! - */ DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, "%s: BAR: TX'ing direct\n", __func__); + ATH_TXQ_LOCK(txq); ath_tx_xmit_normal(sc, txq, bf); + ATH_TXQ_UNLOCK(txq); } else { /* add to software queue */ ath_tx_swq(sc, ni, txq, bf); @@ -1400,7 +1405,9 @@ ath_tx_start(struct ath_softc *sc, struc * For now, since there's no software queue, * direct-dispatch to the hardware. */ + ATH_TXQ_LOCK(txq); ath_tx_xmit_normal(sc, txq, bf); + ATH_TXQ_UNLOCK(txq); #endif return 0; @@ -1603,9 +1610,11 @@ ath_tx_raw_start(struct ath_softc *sc, s DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: dooverride=%d\n", __func__, do_override); - if (do_override) + if (do_override) { + ATH_TXQ_LOCK(sc->sc_ac2q[pri]); ath_tx_xmit_normal(sc, sc->sc_ac2q[pri], bf); - else { + ATH_TXQ_UNLOCK(sc->sc_ac2q[pri]); + } else { /* Queue to software queue */ ath_tx_swq(sc, ni, sc->sc_ac2q[pri], bf); } @@ -1670,9 +1679,6 @@ ath_raw_xmit(struct ieee80211_node *ni, ifp->if_opackets++; sc->sc_stats.ast_tx_raw++; - /* Schedule a TX scheduler task call to occur */ - ath_tx_sched_proc_sched(sc, NULL); - return 0; bad2: ATH_TXBUF_LOCK(sc); @@ -1965,9 +1971,63 @@ ath_tx_tid_seqno_assign(struct ath_softc } /* - * Queue the given packet on the relevant software queue. - * - * This however doesn't queue the packet to the hardware! + * Attempt to direct dispatch an aggregate frame to hardware. + * If the frame is out of BAW, queue. + * Otherwise, schedule it as a single frame. + */ +static void +ath_tx_xmit_aggr(struct ath_softc *sc, struct ath_node *an, struct ath_buf *bf) +{ + struct ath_tid *tid = &an->an_tid[bf->bf_state.bfs_tid]; + struct ath_txq *txq = bf->bf_state.bfs_txq; + struct ieee80211_tx_ampdu *tap; + + ATH_TXQ_LOCK_ASSERT(txq); + + tap = ath_tx_get_tx_tid(an, tid->tid); + + /* paused? queue */ + if (tid->paused) { + ATH_TXQ_INSERT_TAIL(tid, bf, bf_list); + return; + } + + /* outside baw? queue */ + if (bf->bf_state.bfs_dobaw && + (! BAW_WITHIN(tap->txa_start, tap->txa_wnd, + SEQNO(bf->bf_state.bfs_seqno)))) { + ATH_TXQ_INSERT_TAIL(tid, bf, bf_list); + return; + } + + /* Direct dispatch to hardware */ + ath_tx_set_rtscts(sc, bf); + ath_tx_setds(sc, bf); + ath_tx_set_ratectrl(sc, bf->bf_node, bf); + ath_tx_chaindesclist(sc, bf); + + /* Statistics */ + sc->sc_stats.tx_aggr.aggr_low_hwq_single_pkt++; + + /* Track per-TID hardware queue depth correctly */ + tid->hwq_depth++; + + /* Add to BAW */ + ath_tx_addto_baw(sc, an, tid, bf); + bf->bf_state.bfs_addedbaw = 1; + + /* Set completion handler, multi-frame aggregate or not */ + bf->bf_comp = ath_tx_aggr_comp; + + /* Hand off to hardware */ + ath_tx_handoff(sc, txq, bf); +} + +/* + * Attempt to send the packet. + * If the queue isn't busy, direct-dispatch. + * If the queue is busy enough, queue the given packet on the + * relevant software queue. */ void ath_tx_swq(struct ath_softc *sc, struct ieee80211_node *ni, struct ath_txq *txq, @@ -1993,10 +2053,31 @@ ath_tx_swq(struct ath_softc *sc, struct bf->bf_state.bfs_txq = txq; bf->bf_state.bfs_pri = pri; - /* Queue frame to the tail of the software queue */ + /* + * If the hardware queue isn't busy, queue it directly. + * If the hardware queue is busy, queue it. + * If the TID is paused or the traffic it outside BAW, software + * queue it. + */ ATH_TXQ_LOCK(txq); - ATH_TXQ_INSERT_TAIL(atid, bf, bf_list); - ath_tx_tid_sched(sc, an, tid); + if (atid->paused) { + /* TID is paused, queue */ + ATH_TXQ_INSERT_TAIL(atid, bf, bf_list); + } else if (ath_tx_ampdu_pending(sc, an, tid)) { + /* AMPDU pending; queue */ + ATH_TXQ_INSERT_TAIL(atid, bf, bf_list); + } else if (txq->axq_depth < sc->sc_hwq_limit && + ath_tx_ampdu_running(sc, an, tid)) { + /* AMPDU running, attempt direct dispatch */ + ath_tx_xmit_aggr(sc, an, bf); + } else if (txq->axq_depth < sc->sc_hwq_limit) { + /* AMPDU not running, attempt direct dispatch */ + ath_tx_xmit_normal(sc, txq, bf); + } else { + /* Busy; queue */ + ATH_TXQ_INSERT_TAIL(atid, bf, bf_list); + ath_tx_tid_sched(sc, an, tid); + } ATH_TXQ_UNLOCK(txq); } @@ -2087,7 +2168,6 @@ ath_tx_tid_resume(struct ath_softc *sc, } ath_tx_tid_sched(sc, tid->an, tid->tid); - ath_tx_sched_proc_sched(sc, txq); } static void Modified: user/adrian/if_ath_tx/sys/dev/ath/if_athioctl.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_athioctl.h Wed Aug 31 03:04:56 2011 (r225278) +++ user/adrian/if_ath_tx/sys/dev/ath/if_athioctl.h Wed Aug 31 04:57:11 2011 (r225279) @@ -41,6 +41,7 @@ struct ath_tx_aggr_stats { u_int32_t aggr_nonbaw_pkt; u_int32_t aggr_aggr_pkt; u_int32_t aggr_baw_closed_single_pkt; + u_int32_t aggr_low_hwq_single_pkt; }; struct ath_stats { Modified: user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Wed Aug 31 03:04:56 2011 (r225278) +++ user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Wed Aug 31 04:57:11 2011 (r225279) @@ -445,7 +445,6 @@ struct ath_softc { struct ath_txq sc_txq[HAL_NUM_TX_QUEUES]; struct ath_txq *sc_ac2q[5]; /* WME AC -> h/w q map */ struct task sc_txtask; /* tx int processing */ - struct task sc_txschedtask; /* tx processing task */ int sc_wd_timer; /* count down for wd timer */ struct callout sc_wd_ch; /* tx watchdog timer */ struct ath_tx_radiotap_header sc_tx_th; From owner-svn-src-user@FreeBSD.ORG Wed Aug 31 05:19:31 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D43F21065670; Wed, 31 Aug 2011 05:19:31 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C3E1C8FC13; Wed, 31 Aug 2011 05:19:31 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7V5JV5U082335; Wed, 31 Aug 2011 05:19:31 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7V5JVJf082333; Wed, 31 Aug 2011 05:19:31 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108310519.p7V5JVJf082333@svn.freebsd.org> From: Adrian Chadd Date: Wed, 31 Aug 2011 05:19:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225280 - user/adrian/if_ath_tx/sys/dev/ath X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Aug 2011 05:19:31 -0000 Author: adrian Date: Wed Aug 31 05:19:31 2011 New Revision: 225280 URL: http://svn.freebsd.org/changeset/base/225280 Log: Don't clear the MRR fields for aggregate frames. This allows for faster recovery if higher MCS rates begin to fail, as lower MCS rates are now tried. There are still issues forming large aggregates because of the logic involved in selecting the largest aggregate frame size (which is based on the lowest 4ms frame length value in the rate series), but that's a later issue to solve. Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Wed Aug 31 04:57:11 2011 (r225279) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Wed Aug 31 05:19:31 2011 (r225280) @@ -3202,19 +3202,6 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft sc->sc_stats.tx_aggr.aggr_pkts[bf->bf_state.bfs_nframes]++; sc->sc_stats.tx_aggr.aggr_aggr_pkt++; - /* Set rate 1, 2, 3 to 0 for aggregate frames */ - bf->bf_state.bfs_rc[1].rix = - bf->bf_state.bfs_rc[2].rix = - bf->bf_state.bfs_rc[3].rix = 0; - - bf->bf_state.bfs_rc[1].ratecode = - bf->bf_state.bfs_rc[2].ratecode = - bf->bf_state.bfs_rc[3].ratecode = 0; - - bf->bf_state.bfs_rc[1].tries = - bf->bf_state.bfs_rc[2].tries = - bf->bf_state.bfs_rc[3].tries = 0; - /* * Setup the relevant descriptor fields * for aggregation. The first descriptor From owner-svn-src-user@FreeBSD.ORG Wed Aug 31 06:35:50 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C7DA1106566B; Wed, 31 Aug 2011 06:35:50 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B631A8FC0C; Wed, 31 Aug 2011 06:35:50 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7V6Zot3086557; Wed, 31 Aug 2011 06:35:50 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7V6ZoL2086554; Wed, 31 Aug 2011 06:35:50 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108310635.p7V6ZoL2086554@svn.freebsd.org> From: Adrian Chadd Date: Wed, 31 Aug 2011 06:35:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225281 - user/adrian/if_ath_tx/sys/dev/ath X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Aug 2011 06:35:50 -0000 Author: adrian Date: Wed Aug 31 06:35:50 2011 New Revision: 225281 URL: http://svn.freebsd.org/changeset/base/225281 Log: Code tidyups: * make the code compile without witness/invariants - the lock checks turn into null operations and thus some txq variables were never being used, generating a compiler error. * Don't pointlessly keep recalculating pointer values by passing in an integer TID value when a pointer itself will do the job fine. Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.h Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Wed Aug 31 05:19:31 2011 (r225280) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Wed Aug 31 06:35:50 2011 (r225281) @@ -1797,9 +1797,8 @@ ath_tx_addto_baw(struct ath_softc *sc, s { int index, cindex; struct ieee80211_tx_ampdu *tap; - struct ath_txq *txq = sc->sc_ac2q[tid->ac]; - ATH_TXQ_LOCK_ASSERT(txq); + ATH_TXQ_LOCK_ASSERT(sc->sc_ac2q[tid->ac]); if (bf->bf_state.bfs_isretried) return; @@ -1847,9 +1846,8 @@ ath_tx_update_baw(struct ath_softc *sc, { int index, cindex; struct ieee80211_tx_ampdu *tap; - struct ath_txq *txq = sc->sc_ac2q[tid->ac]; - ATH_TXQ_LOCK_ASSERT(txq); + ATH_TXQ_LOCK_ASSERT(sc->sc_ac2q[tid->ac]); tap = ath_tx_get_tx_tid(an, tid->tid); index = ATH_BA_INDEX(tap->txa_start, seqno); @@ -1878,22 +1876,22 @@ ath_tx_update_baw(struct ath_softc *sc, * The TXQ lock must be held. */ static void -ath_tx_tid_sched(struct ath_softc *sc, struct ath_node *an, int tid) +ath_tx_tid_sched(struct ath_softc *sc, struct ath_node *an, + struct ath_tid *tid) { - struct ath_tid *atid = &an->an_tid[tid]; - struct ath_txq *txq = sc->sc_ac2q[atid->ac]; + struct ath_txq *txq = sc->sc_ac2q[tid->ac]; ATH_TXQ_LOCK_ASSERT(txq); - if (atid->paused) + if (tid->paused) return; /* paused, can't schedule yet */ - if (atid->sched) + if (tid->sched) return; /* already scheduled */ - atid->sched = 1; + tid->sched = 1; - TAILQ_INSERT_TAIL(&txq->axq_tidq, atid, axq_qelem); + TAILQ_INSERT_TAIL(&txq->axq_tidq, tid, axq_qelem); } /* @@ -1903,18 +1901,18 @@ ath_tx_tid_sched(struct ath_softc *sc, s * The TXQ lock must be held. */ static void -ath_tx_tid_unsched(struct ath_softc *sc, struct ath_node *an, int tid) +ath_tx_tid_unsched(struct ath_softc *sc, struct ath_node *an, + struct ath_tid *tid) { - struct ath_tid *atid = &an->an_tid[tid]; - struct ath_txq *txq = sc->sc_ac2q[atid->ac]; + struct ath_txq *txq = sc->sc_ac2q[tid->ac]; ATH_TXQ_LOCK_ASSERT(txq); - if (atid->sched == 0) + if (tid->sched == 0) return; - atid->sched = 0; - TAILQ_REMOVE(&txq->axq_tidq, atid, axq_qelem); + tid->sched = 0; + TAILQ_REMOVE(&txq->axq_tidq, tid, axq_qelem); } /* @@ -2076,7 +2074,7 @@ ath_tx_swq(struct ath_softc *sc, struct } else { /* Busy; queue */ ATH_TXQ_INSERT_TAIL(atid, bf, bf_list); - ath_tx_tid_sched(sc, an, tid); + ath_tx_tid_sched(sc, an, atid); } ATH_TXQ_UNLOCK(txq); } @@ -2154,9 +2152,7 @@ ath_tx_tid_pause(struct ath_softc *sc, s static void ath_tx_tid_resume(struct ath_softc *sc, struct ath_tid *tid) { - struct ath_txq *txq = sc->sc_ac2q[tid->ac]; - - ATH_TXQ_LOCK_ASSERT(txq); + ATH_TXQ_LOCK_ASSERT(sc->sc_ac2q[tid->ac]); tid->paused--; @@ -2167,7 +2163,7 @@ ath_tx_tid_resume(struct ath_softc *sc, return; } - ath_tx_tid_sched(sc, tid->an, tid->tid); + ath_tx_tid_sched(sc, tid->an, tid); } static void @@ -2290,7 +2286,7 @@ ath_tx_node_flush(struct ath_softc *sc, islocked = 1; else ATH_TXQ_LOCK(txq); - ath_tx_tid_unsched(sc, an, tid); + ath_tx_tid_unsched(sc, an, atid); /* Free packets */ ath_tx_tid_drain(sc, an, atid); @@ -2316,7 +2312,7 @@ ath_tx_txq_drain(struct ath_softc *sc, s while (! TAILQ_EMPTY(&txq->axq_tidq)) { tid = TAILQ_FIRST(&txq->axq_tidq); ath_tx_tid_drain(sc, tid->an, tid); - ath_tx_tid_unsched(sc, tid->an, tid->tid); + ath_tx_tid_unsched(sc, tid->an, tid); } } @@ -2654,7 +2650,7 @@ ath_tx_aggr_retry_unaggr(struct ath_soft * retried before any current/subsequent frames. */ ATH_TXQ_INSERT_HEAD(atid, bf, bf_list); - ath_tx_tid_sched(sc, an, atid->tid); + ath_tx_tid_sched(sc, an, atid); } /* @@ -2734,9 +2730,8 @@ ath_tx_comp_aggr_error(struct ath_softc ath_bufhead bf_q; int drops = 0; struct ieee80211_tx_ampdu *tap; - struct ath_txq *txq = sc->sc_ac2q[tid->ac]; - ATH_TXQ_LOCK_ASSERT(txq); + ATH_TXQ_LOCK_ASSERT(sc->sc_ac2q[tid->ac]); tap = ath_tx_get_tx_tid(an, tid->tid); @@ -2787,7 +2782,7 @@ ath_tx_comp_aggr_error(struct ath_softc ATH_TXQ_INSERT_HEAD(tid, bf, bf_list); } - ath_tx_tid_sched(sc, an, tid->tid); + ath_tx_tid_sched(sc, an, tid); } /* @@ -2848,7 +2843,6 @@ ath_tx_aggr_comp_aggr(struct ath_softc * struct ath_buf *bf, *bf_next; int ba_index; int drops = 0; - struct ath_txq *txq = sc->sc_ac2q[atid->ac]; int nframes = 0, nbad = 0, nf; int pktlen; /* XXX there's too much on the stack? */ @@ -2857,7 +2851,7 @@ ath_tx_aggr_comp_aggr(struct ath_softc * DPRINTF(sc, ATH_DEBUG_SW_TX_AGGR, "%s: called; hwq_depth=%d\n", __func__, atid->hwq_depth); - ATH_TXQ_LOCK_ASSERT(txq); + ATH_TXQ_LOCK_ASSERT(sc->sc_ac2q[atid->ac]); atid->hwq_depth--; if (atid->hwq_depth < 0) @@ -3000,7 +2994,7 @@ ath_tx_aggr_comp_aggr(struct ath_softc * ATH_TXQ_INSERT_HEAD(atid, bf, bf_list); } - ath_tx_tid_sched(sc, an, atid->tid); + ath_tx_tid_sched(sc, an, atid); DPRINTF(sc, ATH_DEBUG_SW_TX_AGGR, "%s: finished; txa_start now %d\n", __func__, tap->txa_start); @@ -3021,9 +3015,8 @@ ath_tx_aggr_comp_unaggr(struct ath_softc int tid = bf->bf_state.bfs_tid; struct ath_tid *atid = &an->an_tid[tid]; struct ath_tx_status *ts = &bf->bf_status.ds_txstat; - struct ath_txq *txq = sc->sc_ac2q[atid->ac]; - ATH_TXQ_LOCK_ASSERT(txq); + ATH_TXQ_LOCK_ASSERT(sc->sc_ac2q[atid-ac]); if (tid == IEEE80211_NONQOS_TID) device_printf(sc->sc_dev, "%s: TID=16!\n", __func__); @@ -3097,22 +3090,22 @@ ath_tx_aggr_comp(struct ath_softc *sc, s * This is the aggregate version. */ void -ath_tx_tid_hw_queue_aggr(struct ath_softc *sc, struct ath_node *an, int tid) +ath_tx_tid_hw_queue_aggr(struct ath_softc *sc, struct ath_node *an, + struct ath_tid *tid) { struct ath_buf *bf; - struct ath_tid *atid = &an->an_tid[tid]; - struct ath_txq *txq = sc->sc_ac2q[atid->ac]; + struct ath_txq *txq = sc->sc_ac2q[tid->ac]; struct ieee80211_tx_ampdu *tap; struct ieee80211_node *ni = &an->an_node; ATH_AGGR_STATUS status; ath_bufhead bf_q; - DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: tid=%d\n", __func__, tid); + DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: tid=%d\n", __func__, tid->tid); ATH_TXQ_LOCK_ASSERT(txq); - tap = ath_tx_get_tx_tid(an, tid); + tap = ath_tx_get_tx_tid(an, tid->tid); - if (tid == IEEE80211_NONQOS_TID) + if (tid->tid == IEEE80211_NONQOS_TID) device_printf(sc->sc_dev, "%s: called for TID=NONQOS_TID?\n", __func__); @@ -3127,10 +3120,10 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft * of packet loss; but as its serialised with this code, * it won't "appear" half way through queuing packets. */ - if (atid->paused) + if (tid->paused) break; - bf = TAILQ_FIRST(&atid->axq_q); + bf = TAILQ_FIRST(&tid->axq_q); if (bf == NULL) { break; } @@ -3142,7 +3135,7 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft if (! bf->bf_state.bfs_dobaw) { DPRINTF(sc, ATH_DEBUG_SW_TX_AGGR, "%s: non-baw packet\n", __func__); - ATH_TXQ_REMOVE(atid, bf, bf_list); + ATH_TXQ_REMOVE(tid, bf, bf_list); bf->bf_state.bfs_aggr = 0; ath_tx_set_rtscts(sc, bf); ath_tx_setds(sc, bf); @@ -3158,7 +3151,7 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft /* Don't lock the TID - ath_tx_form_aggr will lock as needed */ TAILQ_INIT(&bf_q); - status = ath_tx_form_aggr(sc, an, atid, &bf_q); + status = ath_tx_form_aggr(sc, an, tid, &bf_q); DPRINTF(sc, ATH_DEBUG_SW_TX_AGGR, "%s: ath_tx_form_aggr() status=%d\n", __func__, status); @@ -3228,7 +3221,7 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft /* Track outstanding buffer count to hardware */ /* aggregates are "one" buffer */ - atid->hwq_depth++; + tid->hwq_depth++; /* * Break out if ath_tx_form_aggr() indicated @@ -3247,25 +3240,25 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft * Schedule some packets from the given node/TID to the hardware. */ void -ath_tx_tid_hw_queue_norm(struct ath_softc *sc, struct ath_node *an, int tid) +ath_tx_tid_hw_queue_norm(struct ath_softc *sc, struct ath_node *an, + struct ath_tid *tid) { struct ath_buf *bf; - struct ath_tid *atid = &an->an_tid[tid]; - struct ath_txq *txq = sc->sc_ac2q[atid->ac]; + struct ath_txq *txq = sc->sc_ac2q[tid->ac]; struct ieee80211_node *ni = &an->an_node; DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: node %p: TID %d: called\n", - __func__, an, tid); + __func__, an, tid->tid); ATH_TXQ_LOCK_ASSERT(txq); /* Check - is AMPDU pending or running? then print out something */ - if (ath_tx_ampdu_pending(sc, an, tid)) + if (ath_tx_ampdu_pending(sc, an, tid->tid)) device_printf(sc->sc_dev, "%s: tid=%d, ampdu pending?\n", - __func__, tid); - if (ath_tx_ampdu_running(sc, an, tid)) + __func__, tid->tid); + if (ath_tx_ampdu_running(sc, an, tid->tid)) device_printf(sc->sc_dev, "%s: tid=%d, ampdu running?\n", - __func__, tid); + __func__, tid->tid); for (;;) { @@ -3273,23 +3266,23 @@ ath_tx_tid_hw_queue_norm(struct ath_soft * If the upper layers have paused the TID, don't * queue any further packets. */ - if (atid->paused) + if (tid->paused) break; - bf = TAILQ_FIRST(&atid->axq_q); + bf = TAILQ_FIRST(&tid->axq_q); if (bf == NULL) { break; } - ATH_TXQ_REMOVE(atid, bf, bf_list); + ATH_TXQ_REMOVE(tid, bf, bf_list); KASSERT(txq == bf->bf_state.bfs_txq, ("txqs not equal!\n")); /* Sanity check! */ - if (tid != bf->bf_state.bfs_tid) { + if (tid->tid != bf->bf_state.bfs_tid) { device_printf(sc->sc_dev, "%s: bfs_tid %d !=" " tid %d\n", - __func__, bf->bf_state.bfs_tid, tid); + __func__, bf->bf_state.bfs_tid, tid->tid); } /* Normal completion handler */ bf->bf_comp = ath_tx_normal_comp; @@ -3302,7 +3295,7 @@ ath_tx_tid_hw_queue_norm(struct ath_soft /* Track outstanding buffer count to hardware */ /* aggregates are "one" buffer */ - atid->hwq_depth++; + tid->hwq_depth++; /* Punt to hardware or software txq */ ath_tx_handoff(sc, txq, bf); @@ -3319,7 +3312,7 @@ ath_tx_tid_hw_queue_norm(struct ath_soft void ath_txq_sched(struct ath_softc *sc, struct ath_txq *txq) { - struct ath_tid *atid, *next; + struct ath_tid *tid, *next; ATH_TXQ_LOCK_ASSERT(txq); @@ -3337,7 +3330,7 @@ ath_txq_sched(struct ath_softc *sc, stru * or the like. That's a later problem. Just throw * packets at the hardware. */ - TAILQ_FOREACH_SAFE(atid, &txq->axq_tidq, axq_qelem, next) { + TAILQ_FOREACH_SAFE(tid, &txq->axq_tidq, axq_qelem, next) { /* * Suspend paused queues here; they'll be resumed * once the addba completes or times out. @@ -3346,19 +3339,19 @@ ath_txq_sched(struct ath_softc *sc, stru * the TID lock before checking. */ DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: tid=%d, paused=%d\n", - __func__, atid->tid, atid->paused); - if (atid->paused) { - ath_tx_tid_unsched(sc, atid->an, atid->tid); + __func__, tid->tid, tid->paused); + if (tid->paused) { + ath_tx_tid_unsched(sc, tid->an, tid); continue; } - if (ath_tx_ampdu_running(sc, atid->an, atid->tid)) - ath_tx_tid_hw_queue_aggr(sc, atid->an, atid->tid); + if (ath_tx_ampdu_running(sc, tid->an, tid->tid)) + ath_tx_tid_hw_queue_aggr(sc, tid->an, tid); else - ath_tx_tid_hw_queue_norm(sc, atid->an, atid->tid); + ath_tx_tid_hw_queue_norm(sc, tid->an, tid); /* Empty? Remove */ - if (atid->axq_depth == 0) - ath_tx_tid_unsched(sc, atid->an, atid->tid); + if (tid->axq_depth == 0) + ath_tx_tid_unsched(sc, tid->an, tid); /* Give the software queue time to aggregate more packets */ if (txq->axq_aggr_depth >= sc->sc_hwq_limit) { Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.h Wed Aug 31 05:19:31 2011 (r225280) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.h Wed Aug 31 06:35:50 2011 (r225281) @@ -97,9 +97,9 @@ extern void ath_tx_swq(struct ath_softc extern void ath_tx_tid_init(struct ath_softc *sc, struct ath_node *an); extern void ath_tx_tid_cleanup(struct ath_softc *sc, struct ath_node *an); extern void ath_tx_tid_hw_queue_aggr(struct ath_softc *sc, struct ath_node *an, - int tid); + struct ath_tid *tid); extern void ath_tx_tid_hw_queue_norm(struct ath_softc *sc, struct ath_node *an, - int tid); + struct ath_tid *tid); extern void ath_txq_sched(struct ath_softc *sc, struct ath_txq *txq); extern void ath_tx_normal_comp(struct ath_softc *sc, struct ath_buf *bf, int fail); From owner-svn-src-user@FreeBSD.ORG Wed Aug 31 07:20:44 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4CBA3106567B; Wed, 31 Aug 2011 07:20:44 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3C1EB8FC1C; Wed, 31 Aug 2011 07:20:44 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7V7KiTq087987; Wed, 31 Aug 2011 07:20:44 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7V7KiDG087985; Wed, 31 Aug 2011 07:20:44 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108310720.p7V7KiDG087985@svn.freebsd.org> From: Adrian Chadd Date: Wed, 31 Aug 2011 07:20:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225284 - user/adrian/if_ath_tx/sys/dev/ath/ath_rate/sample X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Aug 2011 07:20:44 -0000 Author: adrian Date: Wed Aug 31 07:20:43 2011 New Revision: 225284 URL: http://svn.freebsd.org/changeset/base/225284 Log: Fix up the rate control logic a little more to correctly tracking failed aggregate packet counts. This still isn't entirely correct but it's better than before. Modified: user/adrian/if_ath_tx/sys/dev/ath/ath_rate/sample/sample.c Modified: user/adrian/if_ath_tx/sys/dev/ath/ath_rate/sample/sample.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/ath_rate/sample/sample.c Wed Aug 31 06:48:00 2011 (r225283) +++ user/adrian/if_ath_tx/sys/dev/ath/ath_rate/sample/sample.c Wed Aug 31 07:20:43 2011 (r225284) @@ -557,7 +557,7 @@ update_stats(struct ath_softc *sc, struc (tt * (100 - ssc->smoothing_rate))) / 100; } - if (status != 0) { + if (nframes == nbad) { int y; sn->stats[size_bin][rix0].successive_failures += nbad; for (y = size_bin+1; y < NUM_PACKET_SIZE_BINS; y++) { @@ -572,7 +572,7 @@ update_stats(struct ath_softc *sc, struc sn->stats[y][rix0].total_packets += nframes; } } else { - sn->stats[size_bin][rix0].packets_acked += nframes; + sn->stats[size_bin][rix0].packets_acked += (nframes - nbad); sn->stats[size_bin][rix0].successive_failures = 0; } sn->stats[size_bin][rix0].tries += tries; @@ -624,10 +624,6 @@ ath_rate_tx_complete(struct ath_softc *s if (frame_size == 0) /* NB: should not happen */ frame_size = 1500; - /* If nbad > 1, override status to FAIL */ - if (nbad > 0) - status = 1; - if (sn->ratemask == 0) { IEEE80211_NOTE(an->an_node.ni_vap, IEEE80211_MSG_RATECTL, &an->an_node, From owner-svn-src-user@FreeBSD.ORG Wed Aug 31 09:15:52 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 74222106566C; Wed, 31 Aug 2011 09:15:52 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 64B718FC28; Wed, 31 Aug 2011 09:15:52 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7V9FqMl091612; Wed, 31 Aug 2011 09:15:52 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7V9Fqex091610; Wed, 31 Aug 2011 09:15:52 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108310915.p7V9Fqex091610@svn.freebsd.org> From: Adrian Chadd Date: Wed, 31 Aug 2011 09:15:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225289 - user/adrian/if_ath_tx/sys/dev/ath X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Aug 2011 09:15:52 -0000 Author: adrian Date: Wed Aug 31 09:15:52 2011 New Revision: 225289 URL: http://svn.freebsd.org/changeset/base/225289 Log: * Add a missing sched call * fix a typo Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Wed Aug 31 09:14:56 2011 (r225288) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Wed Aug 31 09:15:52 2011 (r225289) @@ -1995,6 +1995,7 @@ ath_tx_xmit_aggr(struct ath_softc *sc, s (! BAW_WITHIN(tap->txa_start, tap->txa_wnd, SEQNO(bf->bf_state.bfs_seqno)))) { ATH_TXQ_INSERT_TAIL(tid, bf, bf_list); + ath_tx_tid_sched(sc, an, tid); return; } @@ -3016,7 +3017,7 @@ ath_tx_aggr_comp_unaggr(struct ath_softc struct ath_tid *atid = &an->an_tid[tid]; struct ath_tx_status *ts = &bf->bf_status.ds_txstat; - ATH_TXQ_LOCK_ASSERT(sc->sc_ac2q[atid-ac]); + ATH_TXQ_LOCK_ASSERT(sc->sc_ac2q[atid->ac]); if (tid == IEEE80211_NONQOS_TID) device_printf(sc->sc_dev, "%s: TID=16!\n", __func__); From owner-svn-src-user@FreeBSD.ORG Wed Aug 31 09:31:50 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F01991065672; Wed, 31 Aug 2011 09:31:50 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C71838FC18; Wed, 31 Aug 2011 09:31:50 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7V9Vo9Z092151; Wed, 31 Aug 2011 09:31:50 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7V9VoDR092147; Wed, 31 Aug 2011 09:31:50 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108310931.p7V9VoDR092147@svn.freebsd.org> From: Adrian Chadd Date: Wed, 31 Aug 2011 09:31:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225291 - user/adrian/if_ath_tx/sys/dev/ath X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Aug 2011 09:31:51 -0000 Author: adrian Date: Wed Aug 31 09:31:50 2011 New Revision: 225291 URL: http://svn.freebsd.org/changeset/base/225291 Log: Add another statistic - track how many times the scheduler is called whilst the hardware queue is too deep. Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_sysctl.c user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c user/adrian/if_ath_tx/sys/dev/ath/if_athioctl.h Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_sysctl.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_sysctl.c Wed Aug 31 09:29:46 2011 (r225290) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_sysctl.c Wed Aug 31 09:31:50 2011 (r225291) @@ -323,6 +323,8 @@ ath_sysctl_txagg(SYSCTL_HANDLER_ARGS) sc->sc_stats.tx_aggr.aggr_aggr_pkt); printf("aggr single packet low hwq: %d\n", sc->sc_stats.tx_aggr.aggr_low_hwq_single_pkt); + printf("aggr sched, no work: %d\n", + sc->sc_stats.tx_aggr.aggr_sched_nopkt); for (i = 0; i < 64; i++) { printf("%2d: %10d ", i, sc->sc_stats.tx_aggr.aggr_pkts[i]); if (i % 4 == 3) Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Wed Aug 31 09:29:46 2011 (r225290) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Wed Aug 31 09:31:50 2011 (r225291) @@ -3323,6 +3323,7 @@ ath_txq_sched(struct ath_softc *sc, stru * some packets in the aggregation queue. */ if (txq->axq_aggr_depth >= sc->sc_hwq_limit) { + sc->sc_stats.tx_aggr.aggr_sched_nopkt++; return; } @@ -3335,9 +3336,6 @@ ath_txq_sched(struct ath_softc *sc, stru /* * Suspend paused queues here; they'll be resumed * once the addba completes or times out. - * - * Since this touches tid->paused, it should lock - * the TID lock before checking. */ DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: tid=%d, paused=%d\n", __func__, tid->tid, tid->paused); Modified: user/adrian/if_ath_tx/sys/dev/ath/if_athioctl.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_athioctl.h Wed Aug 31 09:29:46 2011 (r225290) +++ user/adrian/if_ath_tx/sys/dev/ath/if_athioctl.h Wed Aug 31 09:31:50 2011 (r225291) @@ -42,6 +42,7 @@ struct ath_tx_aggr_stats { u_int32_t aggr_aggr_pkt; u_int32_t aggr_baw_closed_single_pkt; u_int32_t aggr_low_hwq_single_pkt; + u_int32_t aggr_sched_nopkt; }; struct ath_stats { From owner-svn-src-user@FreeBSD.ORG Wed Aug 31 13:37:29 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id ECF50106564A; Wed, 31 Aug 2011 13:37:28 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D2A998FC15; Wed, 31 Aug 2011 13:37:28 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7VDbSCg002716; Wed, 31 Aug 2011 13:37:28 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7VDbSAT002712; Wed, 31 Aug 2011 13:37:28 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108311337.p7VDbSAT002712@svn.freebsd.org> From: Adrian Chadd Date: Wed, 31 Aug 2011 13:37:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225294 - user/adrian/if_ath_tx/sys/dev/ath X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Aug 2011 13:37:29 -0000 Author: adrian Date: Wed Aug 31 13:37:28 2011 New Revision: 225294 URL: http://svn.freebsd.org/changeset/base/225294 Log: Add an ADDBA response timeout method which will unpause the TID. I've noticed that there's occasionally TX hangs (which I'll figure out soon enough) that cause net80211 to keep trying to queue ADDBA requests. This tid->paused kept being incremented and even if the addba response finally occured (or the interface was reset), tid->paused wouldn't be reset to 0. The commit to link this into if_ath.c will follow. To think about: if the interface is reset, tid->paused won't be zeroed out. The net80211 addba timeout callback will still occur, so we can't just zero it out as said callback would decrement it to < 0. Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.h user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Wed Aug 31 10:42:42 2011 (r225293) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Wed Aug 31 13:37:28 2011 (r225294) @@ -3596,6 +3596,34 @@ ath_bar_response(struct ieee80211_node * * XXX to a non-aggregate session. So we must unpause the * XXX TID here or it'll never be done. */ - if (status == 0 || attempts == 50) + if (status == 0 || attempts == 50) { + ATH_TXQ_LOCK(sc->sc_ac2q[atid->ac]); ath_tx_tid_resume(sc, atid); + ATH_TXQ_UNLOCK(sc->sc_ac2q[atid->ac]); + } +} + +/* + * This is called whenever the pending ADDBA request times out. + * Unpause and reschedule the TID. + */ +void +ath_addba_response_timeout(struct ieee80211_node *ni, + struct ieee80211_tx_ampdu *tap) +{ + struct ath_softc *sc = ni->ni_ic->ic_ifp->if_softc; + int tid = WME_AC_TO_TID(tap->txa_ac); + struct ath_node *an = ATH_NODE(ni); + struct ath_tid *atid = &an->an_tid[tid]; + + DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, + "%s: called; resuming\n", __func__); + + /* Note: This updates the aggregate state to (again) pending */ + sc->sc_addba_response_timeout(ni, tap); + + /* Unpause the TID; which reschedules it */ + ATH_TXQ_LOCK(sc->sc_ac2q[atid->ac]); + ath_tx_tid_resume(sc, atid); + ATH_TXQ_UNLOCK(sc->sc_ac2q[atid->ac]); } Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.h Wed Aug 31 10:42:42 2011 (r225293) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.h Wed Aug 31 13:37:28 2011 (r225294) @@ -121,5 +121,7 @@ extern void ath_addba_stop(struct ieee80 struct ieee80211_tx_ampdu *tap); extern void ath_bar_response(struct ieee80211_node *ni, struct ieee80211_tx_ampdu *tap, int status); +extern void ath_addba_response_timeout(struct ieee80211_node *ni, + struct ieee80211_tx_ampdu *tap); #endif Modified: user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Wed Aug 31 10:42:42 2011 (r225293) +++ user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Wed Aug 31 13:37:28 2011 (r225294) @@ -512,6 +512,9 @@ struct ath_softc { struct ieee80211_tx_ampdu *, int, int, int); void (*sc_addba_stop)(struct ieee80211_node *, struct ieee80211_tx_ampdu *); + void (*sc_addba_response_timeout) + (struct ieee80211_node *, + struct ieee80211_tx_ampdu *); void (*sc_bar_response)(struct ieee80211_node *ni, struct ieee80211_tx_ampdu *tap, int status); From owner-svn-src-user@FreeBSD.ORG Wed Aug 31 13:39:10 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0C785106564A; Wed, 31 Aug 2011 13:39:10 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F0D9A8FC08; Wed, 31 Aug 2011 13:39:09 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7VDd92Q002804; Wed, 31 Aug 2011 13:39:09 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7VDd9IW002802; Wed, 31 Aug 2011 13:39:09 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108311339.p7VDd9IW002802@svn.freebsd.org> From: Adrian Chadd Date: Wed, 31 Aug 2011 13:39:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225295 - user/adrian/if_ath_tx/sys/dev/ath X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Aug 2011 13:39:10 -0000 Author: adrian Date: Wed Aug 31 13:39:09 2011 New Revision: 225295 URL: http://svn.freebsd.org/changeset/base/225295 Log: Link in the new addba_response_timeout method. Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Wed Aug 31 13:37:28 2011 (r225294) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Wed Aug 31 13:39:09 2011 (r225295) @@ -736,9 +736,11 @@ ath_attach(u_int16_t devid, struct ath_s sc->sc_addba_response = ic->ic_addba_response; sc->sc_addba_stop = ic->ic_addba_stop; sc->sc_bar_response = ic->ic_bar_response; + sc->sc_addba_response_timeout = ic->ic_addba_response_timeout; ic->ic_addba_request = ath_addba_request; ic->ic_addba_response = ath_addba_response; + ic->ic_addba_response_timeout = ath_addba_response_timeout; ic->ic_addba_stop = ath_addba_stop; ic->ic_bar_response = ath_bar_response; From owner-svn-src-user@FreeBSD.ORG Wed Aug 31 23:04:25 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 20245106564A; Wed, 31 Aug 2011 23:04:25 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0FEBD8FC0C; Wed, 31 Aug 2011 23:04:25 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7VN4O4n020959; Wed, 31 Aug 2011 23:04:24 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7VN4Osm020957; Wed, 31 Aug 2011 23:04:24 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108312304.p7VN4Osm020957@svn.freebsd.org> From: Gabor Kovesdan Date: Wed, 31 Aug 2011 23:04:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225298 - user/gabor/grep/trunk X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Aug 2011 23:04:25 -0000 Author: gabor Date: Wed Aug 31 23:04:24 2011 New Revision: 225298 URL: http://svn.freebsd.org/changeset/base/225298 Log: - Use fstat() after opening the file, which is safer - Only disallow directories for pattern file Suggested by: jh Modified: user/gabor/grep/trunk/grep.c Modified: user/gabor/grep/trunk/grep.c ============================================================================== --- user/gabor/grep/trunk/grep.c Wed Aug 31 16:54:05 2011 (r225297) +++ user/gabor/grep/trunk/grep.c Wed Aug 31 23:04:24 2011 (r225298) @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -293,13 +294,18 @@ read_patterns(const char *fn) FILE *f; char *line; size_t len; + int fd; - if ((stat(fn, &st) == -1) || !(S_ISREG(st.st_mode))) + if ((fd = open(fn, O_RDONLY)) == -1) return; - if ((f = fopen(fn, "r")) == NULL) + if ((fstat(fd, &st) == -1) || (S_ISDIR(st.st_mode))) { + close(fd); + return; + } + if ((f = fdopen(fd, "r")) == NULL) err(2, "%s", fn); - while ((line = fgetln(f, &len)) != NULL) - add_pattern(line, *line == '\n' ? 0 : len); + while ((line = fgetln(f, &len)) != NULL) + add_pattern(line, line[0] == '\n' ? 0 : len); if (ferror(f)) err(2, "%s", fn); fclose(f); From owner-svn-src-user@FreeBSD.ORG Wed Aug 31 23:14:38 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1E4891065670; Wed, 31 Aug 2011 23:14:38 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0DA4F8FC0A; Wed, 31 Aug 2011 23:14:38 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7VNEbha021293; Wed, 31 Aug 2011 23:14:37 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7VNEbKb021290; Wed, 31 Aug 2011 23:14:37 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108312314.p7VNEbKb021290@svn.freebsd.org> From: Gabor Kovesdan Date: Wed, 31 Aug 2011 23:14:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225299 - user/gabor/tre-integration/contrib/tre/lib X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Aug 2011 23:14:38 -0000 Author: gabor Date: Wed Aug 31 23:14:37 2011 New Revision: 225299 URL: http://svn.freebsd.org/changeset/base/225299 Log: - Fix REG_PEND length calculation Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c user/gabor/tre-integration/contrib/tre/lib/regcomp.c Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Wed Aug 31 23:04:24 2011 (r225298) +++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Wed Aug 31 23:14:37 2011 (r225299) @@ -125,10 +125,11 @@ tre_fixcomp(fastmatch_t *preg, const cha if (cflags & REG_PEND) { - len = (preg->re_endp >= regex) - ? preg->re_endp - regex - : 0; - return tre_fixncomp(preg, regex, len ? strlen(regex) : 0, cflags); + if (preg->re_endp >= regex) + len = preg->re_endp - regex + else + len = preg ? strlen(regex) : 0; + return tre_fixncomp(preg, regex, len, cflags); } else return tre_fixncomp(preg, regex, regex ? strlen(regex) : 0, cflags); Modified: user/gabor/tre-integration/contrib/tre/lib/regcomp.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/regcomp.c Wed Aug 31 23:04:24 2011 (r225298) +++ user/gabor/tre-integration/contrib/tre/lib/regcomp.c Wed Aug 31 23:14:37 2011 (r225299) @@ -116,10 +116,12 @@ tre_regcomp(regex_t *preg, const char *r if (cflags & REG_PEND) { - len = (preg->re_endp >= regex) - ? preg->re_endp - regex - : 0; - return tre_regncomp(preg, regex, len ? strlen(regex) : 0, cflags); + if (preg->re_endp >= regex) + len = preg->re_endp - regex + else + len = regex ? strlen(regex) : 0; + ) + return tre_regncomp(preg, regex, len, cflags); } else return tre_regncomp(preg, regex, regex ? strlen(regex) : 0, cflags); From owner-svn-src-user@FreeBSD.ORG Wed Aug 31 23:19:20 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1A667106564A; Wed, 31 Aug 2011 23:19:20 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 09EE88FC0A; Wed, 31 Aug 2011 23:19:20 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7VNJJ6Y021476; Wed, 31 Aug 2011 23:19:19 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7VNJJDk021474; Wed, 31 Aug 2011 23:19:19 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108312319.p7VNJJDk021474@svn.freebsd.org> From: Gabor Kovesdan Date: Wed, 31 Aug 2011 23:19:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225300 - user/gabor/tre-integration/contrib/tre/lib X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Aug 2011 23:19:20 -0000 Author: gabor Date: Wed Aug 31 23:19:19 2011 New Revision: 225300 URL: http://svn.freebsd.org/changeset/base/225300 Log: - Add support for 0-length pattern (matches everyting) Modified: user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Modified: user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Wed Aug 31 23:14:37 2011 (r225299) +++ user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Wed Aug 31 23:19:19 2011 (r225300) @@ -385,12 +385,15 @@ static int fastcmp(const void *, const v fg->word = (cflags & REG_WORD); \ fg->newline = (cflags & REG_NEWLINE); \ \ + if (n == 0) \ + { \ + fg->matchall = true; \ + return REG_OK; \ + } + \ /* Cannot handle REG_ICASE with MB string */ \ if (fg->icase && (TRE_MB_CUR_MAX > 1)) \ return REG_BADPAT; \ - \ - /* Calculate length if unspecified */ \ - n = (n == 0) ? tre_strlen(pat) : n; /* * Returns: REG_OK on success, error code otherwise @@ -597,6 +600,13 @@ tre_match_fast(const fastmatch_t *fg, co break; } + if (fg->matchall) + { + pmatch[0].rm_so = 0; + pmatch[0].rm_eo = len; + return REG_OK; + } + /* No point in going farther if we do not have enough data. */ switch (type) { From owner-svn-src-user@FreeBSD.ORG Wed Aug 31 23:20:00 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BC3981065672; Wed, 31 Aug 2011 23:20:00 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A90EE8FC12; Wed, 31 Aug 2011 23:20:00 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7VNK0Et021533; Wed, 31 Aug 2011 23:20:00 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7VNK0aB021531; Wed, 31 Aug 2011 23:20:00 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108312320.p7VNK0aB021531@svn.freebsd.org> From: Gabor Kovesdan Date: Wed, 31 Aug 2011 23:20:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225301 - user/gabor/tre-integration/include X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Aug 2011 23:20:00 -0000 Author: gabor Date: Wed Aug 31 23:20:00 2011 New Revision: 225301 URL: http://svn.freebsd.org/changeset/base/225301 Log: - Add support for 0-length pattern (matches everyting) (Forgot this file in last commit) Modified: user/gabor/tre-integration/include/fastmatch.h Modified: user/gabor/tre-integration/include/fastmatch.h ============================================================================== --- user/gabor/tre-integration/include/fastmatch.h Wed Aug 31 23:19:19 2011 (r225300) +++ user/gabor/tre-integration/include/fastmatch.h Wed Aug 31 23:20:00 2011 (r225301) @@ -27,6 +27,7 @@ typedef struct { bool word; bool icase; bool newline; + bool matchall; } fastmatch_t; extern int From owner-svn-src-user@FreeBSD.ORG Wed Aug 31 23:25:07 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1435B1065675; Wed, 31 Aug 2011 23:25:07 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D07328FC22; Wed, 31 Aug 2011 23:25:06 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7VNP63f021733; Wed, 31 Aug 2011 23:25:06 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7VNP69M021730; Wed, 31 Aug 2011 23:25:06 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108312325.p7VNP69M021730@svn.freebsd.org> From: Gabor Kovesdan Date: Wed, 31 Aug 2011 23:25:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225302 - in user/gabor/tre-integration: contrib/tre/lib include X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Aug 2011 23:25:07 -0000 Author: gabor Date: Wed Aug 31 23:25:06 2011 New Revision: 225302 URL: http://svn.freebsd.org/changeset/base/225302 Log: - Actually leave pmatch untouched if REG_NOSUB is passed to regcomp() Modified: user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c user/gabor/tre-integration/include/fastmatch.h Modified: user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Wed Aug 31 23:20:00 2011 (r225301) +++ user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Wed Aug 31 23:25:06 2011 (r225302) @@ -384,6 +384,7 @@ static int fastcmp(const void *, const v fg->icase = (cflags & REG_ICASE); \ fg->word = (cflags & REG_WORD); \ fg->newline = (cflags & REG_NEWLINE); \ + fg->nosub = (cflags & REG_NOSUB); \ \ if (n == 0) \ { \ @@ -602,8 +603,11 @@ tre_match_fast(const fastmatch_t *fg, co if (fg->matchall) { - pmatch[0].rm_so = 0; - pmatch[0].rm_eo = len; + if (!fg->nosub) + { + pmatch[0].rm_so = 0; + pmatch[0].rm_eo = len; + } return REG_OK; } @@ -651,8 +655,11 @@ tre_match_fast(const fastmatch_t *fg, co { if (fg->word && !IS_ON_WORD_BOUNDARY) return ret; - pmatch[0].rm_so = j; - pmatch[0].rm_eo = j + (type == STR_WIDE ? fg->wlen : fg->len); + if (!fg->nosub) + { + pmatch[0].rm_so = j; + pmatch[0].rm_eo = j + (type == STR_WIDE ? fg->wlen : fg->len); + } return REG_OK; } } @@ -672,8 +679,11 @@ tre_match_fast(const fastmatch_t *fg, co CHECK_BOL_ANCHOR; if (fg->eol) CHECK_EOL_ANCHOR; - pmatch[0].rm_so = j; - pmatch[0].rm_eo = j + ((type == STR_WIDE) ? fg->wlen : fg->len); + if (!fg->nosub) + { + pmatch[0].rm_so = j; + pmatch[0].rm_eo = j + ((type == STR_WIDE) ? fg->wlen : fg->len); + } return REG_OK; } else if (mismatch > 0) Modified: user/gabor/tre-integration/include/fastmatch.h ============================================================================== --- user/gabor/tre-integration/include/fastmatch.h Wed Aug 31 23:20:00 2011 (r225301) +++ user/gabor/tre-integration/include/fastmatch.h Wed Aug 31 23:25:06 2011 (r225302) @@ -27,6 +27,7 @@ typedef struct { bool word; bool icase; bool newline; + bool nosub; bool matchall; } fastmatch_t; From owner-svn-src-user@FreeBSD.ORG Thu Sep 1 06:12:17 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 57F411065674; Thu, 1 Sep 2011 06:12:17 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 484B78FC0A; Thu, 1 Sep 2011 06:12:17 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p816CHbj034485; Thu, 1 Sep 2011 06:12:17 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p816CHvK034483; Thu, 1 Sep 2011 06:12:17 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201109010612.p816CHvK034483@svn.freebsd.org> From: Adrian Chadd Date: Thu, 1 Sep 2011 06:12:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225308 - user/adrian/if_ath_tx/sys/dev/ath X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Sep 2011 06:12:17 -0000 Author: adrian Date: Thu Sep 1 06:12:16 2011 New Revision: 225308 URL: http://svn.freebsd.org/changeset/base/225308 Log: Another bug! Modified: user/adrian/if_ath_tx/sys/dev/ath/README Modified: user/adrian/if_ath_tx/sys/dev/ath/README ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/README Thu Sep 1 06:11:16 2011 (r225307) +++ user/adrian/if_ath_tx/sys/dev/ath/README Thu Sep 1 06:12:16 2011 (r225308) @@ -1,6 +1,10 @@ Things to debug! ---------------- +< adrian> oh that's a fun bug. if I trigger A-MPDU using an aggregate UDP TX, I'm out of buffers +< adrian> (as they're all locked up in pending queues) +< adrian> so I can't send the ADDBA. :P + * Write something in ath_tx_default_comp() that ensures the buffer is unlinked (ie, not part of an aggregate) - Done From owner-svn-src-user@FreeBSD.ORG Thu Sep 1 13:36:30 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3ED14106564A; Thu, 1 Sep 2011 13:36:30 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2EAE18FC14; Thu, 1 Sep 2011 13:36:30 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p81DaUQO053459; Thu, 1 Sep 2011 13:36:30 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p81DaU45053456; Thu, 1 Sep 2011 13:36:30 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201109011336.p81DaU45053456@svn.freebsd.org> From: Gabor Kovesdan Date: Thu, 1 Sep 2011 13:36:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225309 - user/gabor/tre-integration/contrib/tre/lib X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Sep 2011 13:36:30 -0000 Author: gabor Date: Thu Sep 1 13:36:29 2011 New Revision: 225309 URL: http://svn.freebsd.org/changeset/base/225309 Log: - Merge improvements from BSD grep: * More verbose debug output * Fixes for hashtable.c to avoid infinite loop * Allocate more space for hash table to avoid hash collision and be more efficient Modified: user/gabor/tre-integration/contrib/tre/lib/hashtable.c user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Modified: user/gabor/tre-integration/contrib/tre/lib/hashtable.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/hashtable.c Thu Sep 1 06:12:16 2011 (r225308) +++ user/gabor/tre-integration/contrib/tre/lib/hashtable.c Thu Sep 1 13:36:29 2011 (r225309) @@ -29,6 +29,7 @@ #include #include "hashtable.h" +#include "tre-internal.h" /* @@ -58,6 +59,10 @@ hashtable { hashtable *tbl; + DPRINT(("hashtable_init: table_size %lu, key_size %lu, value_size %lu\n", + (unsigned long)table_size, (unsigned long)key_size, + (unsigned long)value_size)); + tbl = malloc(sizeof(hashtable)); if (tbl == NULL) goto mem1; @@ -76,6 +81,7 @@ hashtable mem2: free(tbl); mem1: + DPRINT(("hashtable_init: allocation failed\n")); errno = ENOMEM; return (NULL); } @@ -98,9 +104,13 @@ hashtable_put(hashtable *tbl, const void uint32_t hash = 0; if (tbl->table_size == tbl->usage) - return (HASH_FULL); + { + DPRINT(("hashtable_put: hashtable is full\n")); + return (HASH_FULL); + } hash = hash32_buf(key, tbl->key_size, hash) % tbl->table_size; + DPRINT(("hashtable_put: calculated hash %lu\n", hash)); /* * On hash collision entries are inserted at the next free space, @@ -108,13 +118,21 @@ hashtable_put(hashtable *tbl, const void * with the same key (and update it) or we find a free space. */ for(;;) - if (tbl->entries[hash] == NULL) - break; - else if (memcmp(tbl->entries[hash]->key, key, tbl->key_size) == 0) - { - memcpy(tbl->entries[hash]->value, value, tbl->value_size); - return (HASH_UPDATED); - } + { + if (tbl->entries[hash] == NULL) + break; + else if (memcmp(tbl->entries[hash]->key, key, tbl->key_size) == 0) + { + memcpy(tbl->entries[hash]->value, value, tbl->value_size); + DPRINT(("hashtable_put: effective location is %lu, " + "entry updated\n", hash)); + return (HASH_UPDATED); + } + if (++hash == tbl->table_size) + hash = 0; + } + + DPRINT(("hashtable_put: effective location is %lu\n", hash)); tbl->entries[hash] = malloc(sizeof(hashtable_entry)); if (tbl->entries[hash] == NULL) @@ -141,6 +159,8 @@ hashtable_put(hashtable *tbl, const void memcpy(tbl->entries[hash]->value, value, tbl->value_size); tbl->usage++; + DPRINT(("hashtable_put: entry successfully inserted\n")); + return (HASH_OK); mem3: @@ -148,6 +168,7 @@ mem3: mem2: free(tbl->entries[hash]); mem1: + DPRINT(("hashtable_put: insertion failed\n")); return (HASH_FAIL); } @@ -163,9 +184,13 @@ static hashtable_entry if (tbl->entries[hash] == NULL) return (NULL); else if (memcmp(key, tbl->entries[hash]->key, tbl->key_size) == 0) - return (&tbl->entries[hash]); + { + DPRINT(("hashtable_lookup: entry found at location %lu\n", hash)); + return (&tbl->entries[hash]); + } - hash = (hash == tbl->table_size) ? 0 : hash + 1; + if (++hash == tbl->table_size) + hash = 0; } } @@ -182,9 +207,13 @@ hashtable_get(hashtable *tbl, const void entry = hashtable_lookup(tbl, key); if (entry == NULL) - return (HASH_NOTFOUND); + { + DPRINT(("hashtable_get: entry is not available in the hashtable\n")); + return (HASH_NOTFOUND); + } memcpy(value, (*entry)->value, tbl->value_size); + DPRINT(("hashtable_get: entry successfully copied into output buffer\n")); return (HASH_OK); } @@ -200,7 +229,10 @@ hashtable_remove(hashtable *tbl, const v entry = hashtable_lookup(tbl, key); if (entry == NULL) - return (HASH_NOTFOUND); + { + DPRINT(("hashtable_remove: entry is not available in the hashtable\n")); + return (HASH_NOTFOUND); + } free((*entry)->key); free((*entry)->value); @@ -208,6 +240,7 @@ hashtable_remove(hashtable *tbl, const v *entry = NULL; tbl->usage--; + DPRINT(("hashtable_remove: entry successfully removed\n")); return (HASH_OK); } @@ -228,4 +261,5 @@ hashtable_free(hashtable *tbl) } free(tbl->entries); + DPRINT(("hashtable_free: resources are successfully freed\n")); } Modified: user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Thu Sep 1 06:12:16 2011 (r225308) +++ user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Thu Sep 1 13:36:29 2011 (r225309) @@ -146,7 +146,7 @@ static int fastcmp(const void *, const v gs = fg->bmGs[mismatch]; \ } \ bc = (r == HASH_OK) ? bc : fg->defBc; \ - DPRINT(("tre_fast_match: mismatch on character %lc," \ + DPRINT(("tre_fast_match: mismatch on character %lc, " \ "BC %d, GS %d\n", \ ((tre_char_t *)startptr)[mismatch + 1], bc, gs)); \ break; \ @@ -159,7 +159,7 @@ static int fastcmp(const void *, const v gs = fg->sbmGs[mismatch]; \ } \ bc = fg->qsBc[((unsigned char *)startptr)[mismatch + 1]]; \ - DPRINT(("tre_fast_match: mismatch on character %c," \ + DPRINT(("tre_fast_match: mismatch on character %c, " \ "BC %d, GS %d\n", \ ((unsigned char *)startptr)[mismatch + 1], bc, gs)); \ } \ @@ -216,6 +216,7 @@ static int fastcmp(const void *, const v char c = islower(fg->pattern[i]) ? toupper(fg->pattern[i]) \ : tolower(fg->pattern[i]); \ fg->qsBc[(unsigned)c] = fg->len - i; \ + DPRINT(("BC shift for char %c is %d\n", c, fg->len - i)); \ } \ } @@ -233,8 +234,8 @@ static int fastcmp(const void *, const v fg->defBc = fg->wlen - fg->hasdot; \ \ /* Preprocess pattern. */ \ - fg->qsBc_table = hashtable_init(fg->wlen * 4, sizeof(tre_char_t), \ - sizeof(int)); \ + fg->qsBc_table = hashtable_init(fg->wlen * (fg->icase ? 8 : 4), \ + sizeof(tre_char_t), sizeof(int)); \ if (!fg->qsBc_table) \ FAIL_COMP(REG_ESPACE); \ for (unsigned int i = fg->hasdot + 1; i < fg->wlen; i++) \ @@ -254,6 +255,8 @@ static int fastcmp(const void *, const v r = hashtable_put(fg->qsBc_table, &wc, &k); \ if ((r == HASH_FAIL) || (r == HASH_FULL)) \ FAIL_COMP(REG_ESPACE); \ + DPRINT(("BC shift for wide char %lc is %d\n", wc, \ + fg->wlen - i)); \ } \ } From owner-svn-src-user@FreeBSD.ORG Thu Sep 1 13:40:41 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E14511065680; Thu, 1 Sep 2011 13:40:41 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C59138FC16; Thu, 1 Sep 2011 13:40:41 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p81Def7b053619; Thu, 1 Sep 2011 13:40:41 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p81DefWk053617; Thu, 1 Sep 2011 13:40:41 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201109011340.p81DefWk053617@svn.freebsd.org> From: Gabor Kovesdan Date: Thu, 1 Sep 2011 13:40:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225310 - user/gabor/grep/trunk X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Sep 2011 13:40:42 -0000 Author: gabor Date: Thu Sep 1 13:40:41 2011 New Revision: 225310 URL: http://svn.freebsd.org/changeset/base/225310 Log: - Restore proper err() call on non-existent file and use more concise code Submitted by: jh Modified: user/gabor/grep/trunk/grep.c Modified: user/gabor/grep/trunk/grep.c ============================================================================== --- user/gabor/grep/trunk/grep.c Thu Sep 1 13:36:29 2011 (r225309) +++ user/gabor/grep/trunk/grep.c Thu Sep 1 13:40:41 2011 (r225310) @@ -296,14 +296,12 @@ read_patterns(const char *fn) size_t len; int fd; - if ((fd = open(fn, O_RDONLY)) == -1) - return; - if ((fstat(fd, &st) == -1) || (S_ISDIR(st.st_mode))) { + if ((f = fopen(fn, "r")) == NULL) + err(2, "%s", fn); + if ((fstat(fileno(f), &st) == -1) || (S_ISDIR(st.st_mode))) { close(fd); return; } - if ((f = fdopen(fd, "r")) == NULL) - err(2, "%s", fn); while ((line = fgetln(f, &len)) != NULL) add_pattern(line, line[0] == '\n' ? 0 : len); if (ferror(f)) From owner-svn-src-user@FreeBSD.ORG Thu Sep 1 13:51:27 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5ADDE106564A; Thu, 1 Sep 2011 13:51:27 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4B3F18FC0A; Thu, 1 Sep 2011 13:51:27 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p81DpR6w053983; Thu, 1 Sep 2011 13:51:27 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p81DpRv1053980; Thu, 1 Sep 2011 13:51:27 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201109011351.p81DpRv1053980@svn.freebsd.org> From: Gabor Kovesdan Date: Thu, 1 Sep 2011 13:51:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225311 - user/gabor/grep/trunk/regex X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Sep 2011 13:51:27 -0000 Author: gabor Date: Thu Sep 1 13:51:26 2011 New Revision: 225311 URL: http://svn.freebsd.org/changeset/base/225311 Log: - Merge improvements from TRE: * Support for 0-length pattern (matches everything) * Do not modify pmatch when pattern is compiled with REG_NOSUB Modified: user/gabor/grep/trunk/regex/fastmatch.h user/gabor/grep/trunk/regex/tre-fastmatch.c Modified: user/gabor/grep/trunk/regex/fastmatch.h ============================================================================== --- user/gabor/grep/trunk/regex/fastmatch.h Thu Sep 1 13:40:41 2011 (r225310) +++ user/gabor/grep/trunk/regex/fastmatch.h Thu Sep 1 13:51:26 2011 (r225311) @@ -3,7 +3,6 @@ #ifndef FASTMATCH_H #define FASTMATCH_H 1 -#include #include #include #include @@ -18,8 +17,9 @@ typedef struct { int *bmGs; char *pattern; int defBc; - hashtable *qsBc_table; + void *qsBc_table; int *sbmGs; + const char *re_endp; /* flags */ bool bol; @@ -27,6 +27,8 @@ typedef struct { bool word; bool icase; bool newline; + bool nosub; + bool matchall; } fastmatch_t; extern int Modified: user/gabor/grep/trunk/regex/tre-fastmatch.c ============================================================================== --- user/gabor/grep/trunk/regex/tre-fastmatch.c Thu Sep 1 13:40:41 2011 (r225310) +++ user/gabor/grep/trunk/regex/tre-fastmatch.c Thu Sep 1 13:51:26 2011 (r225311) @@ -232,8 +232,8 @@ static int fastcmp(const void *, const v fg->defBc = fg->wlen - fg->hasdot; \ \ /* Preprocess pattern. */ \ - fg->qsBc_table = hashtable_init(fg->wlen * 8, sizeof(tre_char_t), \ - sizeof(int)); \ + fg->qsBc_table = hashtable_init(fg->wlen * (fg->icase ? 8 : 4), \ + sizeof(tre_char_t), sizeof(int)); \ if (!fg->qsBc_table) \ FAIL_COMP(REG_ESPACE); \ for (unsigned int i = fg->hasdot + 1; i < fg->wlen; i++) \ @@ -385,13 +385,17 @@ static int fastcmp(const void *, const v fg->icase = (cflags & REG_ICASE); \ fg->word = (cflags & REG_WORD); \ fg->newline = (cflags & REG_NEWLINE); \ + fg->nosub = (cflags & REG_NOSUB); \ + \ + if (n == 0) \ + { \ + fg->matchall = true; \ + return REG_OK; \ + } \ \ /* Cannot handle REG_ICASE with MB string */ \ if (fg->icase && (TRE_MB_CUR_MAX > 1)) \ return REG_BADPAT; \ - \ - /* Calculate length if unspecified */ \ - n = (n == 0) ? tre_strlen(pat) : n; /* * Returns: REG_OK on success, error code otherwise @@ -598,6 +602,16 @@ tre_match_fast(const fastmatch_t *fg, co break; } + if (fg->matchall) + { + if (!fg->nosub) + { + pmatch[0].rm_so = 0; + pmatch[0].rm_eo = len; + } + return REG_OK; + } + /* No point in going farther if we do not have enough data. */ switch (type) { @@ -642,8 +656,11 @@ tre_match_fast(const fastmatch_t *fg, co { if (fg->word && !IS_ON_WORD_BOUNDARY) return ret; - pmatch[0].rm_so = j; - pmatch[0].rm_eo = j + (type == STR_WIDE ? fg->wlen : fg->len); + if (!fg->nosub) + { + pmatch[0].rm_so = j; + pmatch[0].rm_eo = j + (type == STR_WIDE ? fg->wlen : fg->len); + } return REG_OK; } } @@ -663,8 +680,11 @@ tre_match_fast(const fastmatch_t *fg, co CHECK_BOL_ANCHOR; if (fg->eol) CHECK_EOL_ANCHOR; - pmatch[0].rm_so = j; - pmatch[0].rm_eo = j + ((type == STR_WIDE) ? fg->wlen : fg->len); + if (!fg->nosub) + { + pmatch[0].rm_so = j; + pmatch[0].rm_eo = j + ((type == STR_WIDE) ? fg->wlen : fg->len); + } return REG_OK; } else if (mismatch > 0) From owner-svn-src-user@FreeBSD.ORG Thu Sep 1 16:41:06 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F2E251065670; Thu, 1 Sep 2011 16:41:06 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E3B588FC1A; Thu, 1 Sep 2011 16:41:06 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p81Gf60P059212; Thu, 1 Sep 2011 16:41:06 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p81Gf6x7059210; Thu, 1 Sep 2011 16:41:06 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201109011641.p81Gf6x7059210@svn.freebsd.org> From: Gabor Kovesdan Date: Thu, 1 Sep 2011 16:41:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225313 - user/gabor/grep/trunk X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Sep 2011 16:41:07 -0000 Author: gabor Date: Thu Sep 1 16:41:06 2011 New Revision: 225313 URL: http://svn.freebsd.org/changeset/base/225313 Log: - Whitespace nit Modified: user/gabor/grep/trunk/Makefile Modified: user/gabor/grep/trunk/Makefile ============================================================================== --- user/gabor/grep/trunk/Makefile Thu Sep 1 15:53:59 2011 (r225312) +++ user/gabor/grep/trunk/Makefile Thu Sep 1 16:41:06 2011 (r225313) @@ -20,7 +20,7 @@ WARNS=2 # Extra files ported backported form some regex improvements .PATH: ${.CURDIR}/regex SRCS+= fastmatch.c hashtable.c tre-fastmatch.c xmalloc.c -CFLAGS+=-I${.CURDIR}/regex +CFLAGS+=-I${.CURDIR}/regex .if ${MK_BSD_GREP} == "yes" LINKS= ${BINDIR}/grep ${BINDIR}/egrep \ From owner-svn-src-user@FreeBSD.ORG Thu Sep 1 16:47:50 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5CB20106566B; Thu, 1 Sep 2011 16:47:50 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4C7878FC0A; Thu, 1 Sep 2011 16:47:50 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p81GlokG059519; Thu, 1 Sep 2011 16:47:50 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p81GloFp059514; Thu, 1 Sep 2011 16:47:50 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201109011647.p81GloFp059514@svn.freebsd.org> From: Gabor Kovesdan Date: Thu, 1 Sep 2011 16:47:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225315 - in user/gabor/grep/trunk: . regex X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Sep 2011 16:47:50 -0000 Author: gabor Date: Thu Sep 1 16:47:49 2011 New Revision: 225315 URL: http://svn.freebsd.org/changeset/base/225315 Log: - Rely on the matcher when having a match-all empty pattern Modified: user/gabor/grep/trunk/grep.c user/gabor/grep/trunk/regex/fastmatch.c user/gabor/grep/trunk/regex/tre-fastmatch.c user/gabor/grep/trunk/util.c Modified: user/gabor/grep/trunk/grep.c ============================================================================== --- user/gabor/grep/trunk/grep.c Thu Sep 1 16:43:23 2011 (r225314) +++ user/gabor/grep/trunk/grep.c Thu Sep 1 16:47:49 2011 (r225315) @@ -227,9 +227,20 @@ static void add_pattern(char *pat, size_t len) { + /* Do not add further pattern is we already match everything */ + if (matchall) + return; + /* Check if we can do a shortcut */ - if (len == 0 || matchall) { + if (len == 0) { matchall = true; + for (int i = 0; i < patterns; i++) { + free(pattern[i].pat); + } + pattern = grep_realloc(pattern, sizeof(struct pat)); + pattern[0].pat = NULL; + pattern[0].len = 0; + patterns = 1; return; } /* Increase size if necessary */ Modified: user/gabor/grep/trunk/regex/fastmatch.c ============================================================================== --- user/gabor/grep/trunk/regex/fastmatch.c Thu Sep 1 16:43:23 2011 (r225314) +++ user/gabor/grep/trunk/regex/fastmatch.c Thu Sep 1 16:47:49 2011 (r225315) @@ -38,67 +38,72 @@ /* XXX: avoid duplication */ #define CONV_PAT \ - int ret; \ - tre_char_t *wregex; \ - size_t wlen; \ - \ - wregex = xmalloc(sizeof(tre_char_t) * (n + 1)); \ - if (wregex == NULL) \ - return REG_ESPACE; \ - \ - if (TRE_MB_CUR_MAX == 1) \ - { \ - unsigned int i; \ - const unsigned char *str = (const unsigned char *)regex; \ - tre_char_t *wstr = wregex; \ - \ - for (i = 0; i < n; i++) \ - *(wstr++) = *(str++); \ - wlen = n; \ - } \ - else \ - { \ - int consumed; \ - tre_char_t *wcptr = wregex; \ - mbstate_t state; \ - memset(&state, '\0', sizeof(state)); \ - while (n > 0) \ - { \ - consumed = tre_mbrtowc(wcptr, regex, n, &state); \ + { \ + wregex = xmalloc(sizeof(tre_char_t) * (n + 1)); \ + if (wregex == NULL) \ + return REG_ESPACE; \ \ - switch (consumed) \ - { \ - case 0: \ - if (*regex == '\0') \ - consumed = 1; \ - else \ - { \ - xfree(wregex); \ - return REG_BADPAT; \ - } \ - break; \ - case -1: \ - DPRINT(("mbrtowc: error %d: %s.\n", errno, \ - strerror(errno))); \ - xfree(wregex); \ - return REG_BADPAT; \ - case -2: \ - consumed = n; \ - break; \ - } \ - regex += consumed; \ - n -= consumed; \ - wcptr++; \ - } \ - wlen = wcptr - wregex; \ - } \ + if (TRE_MB_CUR_MAX == 1) \ + { \ + unsigned int i; \ + const unsigned char *str = (const unsigned char *)regex; \ + tre_char_t *wstr = wregex; \ + \ + for (i = 0; i < n; i++) \ + *(wstr++) = *(str++); \ + wlen = n; \ + } \ + else \ + { \ + int consumed; \ + tre_char_t *wcptr = wregex; \ + mbstate_t state; \ + memset(&state, '\0', sizeof(state)); \ + while (n > 0) \ + { \ + consumed = tre_mbrtowc(wcptr, regex, n, &state); \ + \ + switch (consumed) \ + { \ + case 0: \ + if (*regex == '\0') \ + consumed = 1; \ + else \ + { \ + xfree(wregex); \ + return REG_BADPAT; \ + } \ + break; \ + case -1: \ + DPRINT(("mbrtowc: error %d: %s.\n", errno, \ + strerror(errno))); \ + xfree(wregex); \ + return REG_BADPAT; \ + case -2: \ + consumed = n; \ + break; \ + } \ + regex += consumed; \ + n -= consumed; \ + wcptr++; \ + } \ + wlen = wcptr - wregex; \ + } \ \ - wregex[wlen] = L'\0'; + wregex[wlen] = L'\0'; \ + } int tre_fixncomp(fastmatch_t *preg, const char *regex, size_t n, int cflags) { - CONV_PAT; + int ret; + tre_char_t *wregex; + size_t wlen; + + if (n != 0) + CONV_PAT + else + return tre_compile_literal(preg, NULL, 0, cflags); ret = tre_compile_literal(preg, wregex, wlen, cflags); xfree(wregex); @@ -109,7 +114,14 @@ tre_fixncomp(fastmatch_t *preg, const ch int tre_fastncomp(fastmatch_t *preg, const char *regex, size_t n, int cflags) { - CONV_PAT; + int ret; + tre_char_t *wregex; + size_t wlen; + + if (n != 0) + CONV_PAT + else + return tre_compile_literal(preg, NULL, 0, cflags); ret = (cflags & REG_LITERAL) ? tre_compile_literal(preg, wregex, wlen, cflags) : Modified: user/gabor/grep/trunk/regex/tre-fastmatch.c ============================================================================== --- user/gabor/grep/trunk/regex/tre-fastmatch.c Thu Sep 1 16:43:23 2011 (r225314) +++ user/gabor/grep/trunk/regex/tre-fastmatch.c Thu Sep 1 16:47:49 2011 (r225315) @@ -390,6 +390,8 @@ static int fastcmp(const void *, const v if (n == 0) \ { \ fg->matchall = true; \ + fg->pattern = ""; \ + fg->wpattern = TRE_CHAR(""); \ return REG_OK; \ } \ \ Modified: user/gabor/grep/trunk/util.c ============================================================================== --- user/gabor/grep/trunk/util.c Thu Sep 1 16:43:23 2011 (r225314) +++ user/gabor/grep/trunk/util.c Thu Sep 1 16:47:49 2011 (r225315) @@ -281,74 +281,72 @@ procline(struct str *l, int nottext) unsigned int i; int c = 0, m = 0, r = 0; - if (!matchall) { - /* Loop to process the whole line */ - while (st <= l->len) { - pmatch.rm_so = st; - pmatch.rm_eo = l->len; - - /* Loop to compare with all the patterns */ - for (i = 0; i < patterns; i++) { - if (fg_pattern[i].pattern) - r = fastexec(&fg_pattern[i], - l->dat, 1, &pmatch, eflags); - else - r = regexec(&r_pattern[i], l->dat, 1, - &pmatch, eflags); - r = (r == 0) ? 0 : REG_NOMATCH; - st = (cflags & REG_NOSUB) - ? (size_t)l->len - : (size_t)pmatch.rm_eo; - if (r == REG_NOMATCH) - continue; - /* Check for full match */ - if (r == 0 && xflag) - if (pmatch.rm_so != 0 || - (size_t)pmatch.rm_eo != l->len) - r = REG_NOMATCH; - /* Check for whole word match */ - if (r == 0 && (wflag || fg_pattern[i].word)) { - wint_t wbegin, wend; - - wbegin = wend = L' '; - if (pmatch.rm_so != 0 && - sscanf(&l->dat[pmatch.rm_so - 1], - "%lc", &wbegin) != 1) - r = REG_NOMATCH; - else if ((size_t)pmatch.rm_eo != - l->len && - sscanf(&l->dat[pmatch.rm_eo], - "%lc", &wend) != 1) - r = REG_NOMATCH; - else if (iswword(wbegin) || - iswword(wend)) - r = REG_NOMATCH; - } - if (r == 0) { - if (m == 0) - c++; - if (m < MAX_LINE_MATCHES) - matches[m++] = pmatch; - /* matches - skip further patterns */ - if ((color == NULL && !oflag) || - qflag || lflag) - break; - } + /* Loop to process the whole line */ + while (st <= l->len) { + pmatch.rm_so = st; + pmatch.rm_eo = l->len; + + /* Loop to compare with all the patterns */ + for (i = 0; i < patterns; i++) { + if (fg_pattern[i].pattern) + r = fastexec(&fg_pattern[i], + l->dat, 1, &pmatch, eflags); + else + r = regexec(&r_pattern[i], l->dat, 1, + &pmatch, eflags); + r = (r == 0) ? 0 : REG_NOMATCH; + st = (cflags & REG_NOSUB) + ? (size_t)l->len + : (size_t)pmatch.rm_eo; + if (r == REG_NOMATCH) + continue; + /* Check for full match */ + if (r == 0 && xflag) + if (pmatch.rm_so != 0 || + (size_t)pmatch.rm_eo != l->len) + r = REG_NOMATCH; + /* Check for whole word match */ + if (r == 0 && (wflag || fg_pattern[i].word)) { + wint_t wbegin, wend; + + wbegin = wend = L' '; + if (pmatch.rm_so != 0 && + sscanf(&l->dat[pmatch.rm_so - 1], + "%lc", &wbegin) != 1) + r = REG_NOMATCH; + else if ((size_t)pmatch.rm_eo != + l->len && + sscanf(&l->dat[pmatch.rm_eo], + "%lc", &wend) != 1) + r = REG_NOMATCH; + else if (iswword(wbegin) || + iswword(wend)) + r = REG_NOMATCH; } - - if (vflag) { - c = !c; - break; + if (r == 0) { + if (m == 0) + c++; + if (m < MAX_LINE_MATCHES) + matches[m++] = pmatch; + /* matches - skip further patterns */ + if ((color == NULL && !oflag) || + qflag || lflag) + break; } - /* One pass if we are not recording matches */ - if ((color == NULL && !oflag) || qflag || lflag) - break; + } - if (st == (size_t)pmatch.rm_so) - break; /* No matches */ + if (vflag) { + c = !c; + break; } - } else - c = !vflag; + + /* One pass if we are not recording matches */ + if ((color == NULL && !oflag) || qflag || lflag) + break; + + if (st == (size_t)pmatch.rm_so) + break; /* No matches */ + } if (c && binbehave == BINFILE_BIN && nottext) return (c); /* Binary file */ From owner-svn-src-user@FreeBSD.ORG Fri Sep 2 01:55:02 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DD1041065672; Fri, 2 Sep 2011 01:55:02 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C2B168FC18; Fri, 2 Sep 2011 01:55:02 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p821t2SC076707; Fri, 2 Sep 2011 01:55:02 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p821t2Gh076705; Fri, 2 Sep 2011 01:55:02 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201109020155.p821t2Gh076705@svn.freebsd.org> From: Gabor Kovesdan Date: Fri, 2 Sep 2011 01:55:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225318 - user/gabor/grep/trunk/regex X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Sep 2011 01:55:03 -0000 Author: gabor Date: Fri Sep 2 01:55:02 2011 New Revision: 225318 URL: http://svn.freebsd.org/changeset/base/225318 Log: - Add a finer-grained parser to allow a wider range of patterns to be matched with the fast algorithm Modified: user/gabor/grep/trunk/regex/glue.h user/gabor/grep/trunk/regex/tre-fastmatch.c Modified: user/gabor/grep/trunk/regex/glue.h ============================================================================== --- user/gabor/grep/trunk/regex/glue.h Thu Sep 1 21:42:54 2011 (r225317) +++ user/gabor/grep/trunk/regex/glue.h Fri Sep 2 01:55:02 2011 (r225318) @@ -22,7 +22,7 @@ #define REG_LITERAL 0020 #define REG_WORD 0100 #define REG_GNU 0400 -#define _REG_HEUR 1000 +#define _REG_HEUR 01000 #define REG_OK 0 Modified: user/gabor/grep/trunk/regex/tre-fastmatch.c ============================================================================== --- user/gabor/grep/trunk/regex/tre-fastmatch.c Thu Sep 1 21:42:54 2011 (r225317) +++ user/gabor/grep/trunk/regex/tre-fastmatch.c Fri Sep 2 01:55:02 2011 (r225318) @@ -368,13 +368,18 @@ static int fastcmp(const void *, const v * Copies the pattern pat having lenght n to p and stores * the size in l. */ -#define SAVE_PATTERN(p, l) \ - l = (n == 0) ? tre_strlen(pat) : n; \ - p = xmalloc((l + 1) * sizeof(tre_char_t)); \ - if (p == NULL) \ - return REG_ESPACE; \ - memcpy(p, pat, l * sizeof(tre_char_t)); \ - p[l] = TRE_CHAR('\0'); +#define SAVE_PATTERN(src, srclen, dst, dstlen) \ + dstlen = srclen; \ + if (dstlen == 0) \ + dst = TRE_CHAR(""); \ + else \ + { \ + dst = xmalloc((dstlen + 1) * sizeof(tre_char_t)); \ + if (dst == NULL) \ + return REG_ESPACE; \ + memcpy(dst, src, dstlen * sizeof(tre_char_t)); \ + dst[dstlen] = TRE_CHAR('\0'); \ + } /* * Initializes pattern compiling. @@ -413,10 +418,10 @@ tre_compile_literal(fastmatch_t *fg, con return REG_BADPAT; #ifdef TRE_WCHAR - SAVE_PATTERN(fg->wpattern, fg->wlen); + SAVE_PATTERN(pat, n, fg->wpattern, fg->wlen); STORE_MBS_PAT; #else - SAVE_PATTERN(fg->pattern, fg->len); + SAVE_PATTERN(pat, n, fg->pattern, fg->len); #endif DPRINT(("tre_compile_literal: pattern: %s, icase: %c, word: %c, " @@ -440,14 +445,11 @@ int tre_compile_fast(fastmatch_t *fg, const tre_char_t *pat, size_t n, int cflags) { - INIT_COMP; + tre_char_t *tmp; + size_t pos = 0; + bool escaped = false; - /* Remove end-of-line character ('$'). */ - if ((n > 0) && (pat[n - 1] == TRE_CHAR('$'))) - { - fg->eol = true; - n--; - } + INIT_COMP; /* Remove beginning-of-line character ('^'). */ if (pat[0] == TRE_CHAR('^')) @@ -472,34 +474,138 @@ tre_compile_fast(fastmatch_t *fg, const if (fg->word && (TRE_MB_CUR_MAX > 1)) return REG_BADPAT; - /* Look for ways to cheat...er...avoid the full regex engine. */ - for (unsigned int i = 0; i < n; i++) + tmp = xmalloc((n + 1) * sizeof(tre_char_t)); + if (tmp == NULL) + return REG_ESPACE; + +#define STORE_CHAR \ + do \ + { \ + tmp[pos++] = pat[i]; \ + escaped = false; \ + continue; \ + } while (0) + + /* + * Used for heuristic, only beginning ^, trailing $ and . are treated + * as special. + */ + if (cflags & _REG_HEUR) { - /* Can still cheat? */ - if (!(cflags & _REG_HEUR) && - ((tre_isalnum(pat[i])) || tre_isspace(pat[i]) || - (pat[i] == TRE_CHAR('_')) || (pat[i] == TRE_CHAR(',')) || - (pat[i] == TRE_CHAR('=')) || (pat[i] == TRE_CHAR('-')) || - (pat[i] == TRE_CHAR(':')) || (pat[i] == TRE_CHAR('/')))) + for (int i = 0; i < n; i++) + switch (pat[i]) + { + case TRE_CHAR('.'): + fg->hasdot = true; + STORE_CHAR; + break; + case TRE_CHAR('$'): + if (i == n - 1) + fg->eol = true; + else + STORE_CHAR; + break; + default: + STORE_CHAR; + } + } + else + for (int i = 0; i < n; i++) + { + switch (pat[i]) + { + case TRE_CHAR('\\'): + if (escaped) + STORE_CHAR; + else + escaped = true; + break; + case TRE_CHAR('['): + if (escaped) + STORE_CHAR; + else + goto badpat; + break; + case TRE_CHAR('*'): + if (escaped || (!(cflags & REG_EXTENDED) && (i == 0))) + STORE_CHAR; + else + goto badpat; + break; + case TRE_CHAR('+'): + case TRE_CHAR('?'): + if ((cflags & REG_EXTENDED) && (i == 0)) + continue; + else if ((cflags & REG_EXTENDED) ^ !escaped) + STORE_CHAR; + else + goto badpat; + case TRE_CHAR('.'): + if (escaped) + goto badpat; + else + { + fg->hasdot = true; + STORE_CHAR; + } + break; + case TRE_CHAR('^'): + STORE_CHAR; + break; + case TRE_CHAR('$'): + if (!escaped && (i == n - 1)) + fg->eol = true; + else + STORE_CHAR; + break; + case TRE_CHAR('('): + if ((cflags & REG_EXTENDED) ^ escaped) + goto badpat; + else + STORE_CHAR; + break; + case TRE_CHAR('{'): + if (escaped && (i == 0)) + STORE_CHAR; + else if (!(cflags & REG_EXTENDED) && (i == 0)) + STORE_CHAR; + else if ((cflags & REG_EXTENDED) && (i == 0)) + continue; + else + goto badpat; + break; + case TRE_CHAR('|'): + if ((cflags & REG_EXTENDED) ^ (!escaped)) + goto badpat; + else + STORE_CHAR; + break; + default: + if (escaped) + goto badpat; + else + STORE_CHAR; + } continue; - else if (pat[i] == TRE_CHAR('.')) - fg->hasdot = i; - else +badpat: + xfree(tmp); return REG_BADPAT; - } + } /* - * pat has been adjusted earlier to not include '^', '$' or - * the word match character classes at the beginning and ending - * of the string respectively. + * The pattern has been processed and copied to tmp as a literal string + * with escapes, anchors (^$) and the word boundary match character + * classes stripped out. */ #ifdef TRE_WCHAR - SAVE_PATTERN(fg->wpattern, fg->wlen); + SAVE_PATTERN(tmp, pos, fg->wpattern, fg->wlen); STORE_MBS_PAT; #else - SAVE_PATTERN(fg->pattern, fg->len); + SAVE_PATTERN(tmp, pos, fg->pattern, fg->len); #endif + xfree(tmp); + DPRINT(("tre_compile_fast: pattern: %s, bol %c, eol %c, " "icase: %c, word: %c, newline %c\n", fg->pattern, fg->bol ? 'y' : 'n', fg->eol ? 'y' : 'n', From owner-svn-src-user@FreeBSD.ORG Fri Sep 2 07:19:28 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0A9761065674; Fri, 2 Sep 2011 07:19:28 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EE3718FC12; Fri, 2 Sep 2011 07:19:27 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p827JRes086542; Fri, 2 Sep 2011 07:19:27 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p827JRpj086540; Fri, 2 Sep 2011 07:19:27 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201109020719.p827JRpj086540@svn.freebsd.org> From: Doug Barton Date: Fri, 2 Sep 2011 07:19:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225319 - user/dougb/portmaster X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Sep 2011 07:19:28 -0000 Author: dougb Date: Fri Sep 2 07:19:27 2011 New Revision: 225319 URL: http://svn.freebsd.org/changeset/base/225319 Log: Add support for multiple -r options on the same command line. Take the opportunity to make names of -r related internal variables shorter, consistent, and prefixed with PM_. Modified: user/dougb/portmaster/portmaster Modified: user/dougb/portmaster/portmaster ============================================================================== --- user/dougb/portmaster/portmaster Fri Sep 2 01:55:02 2011 (r225318) +++ user/dougb/portmaster/portmaster Fri Sep 2 07:19:27 2011 (r225319) @@ -125,7 +125,7 @@ parent_exit () { [ -n "$FETCH_ONLY" -a -z "$FETCH_ONLY_DONE" ] && kill_bad_children if [ -z "$1" ]; then - if [ -n "$UPDATE_REQ_BYS" -o -n "$PM_FORCE" ]; then + if [ -n "$PM_URB" -o -n "$PM_FORCE" ]; then files=`find $pdb -type f -name PM_UPGRADE_DONE_FLAG` if [ -n "$files" ]; then pm_sv Deleting \'install complete\' flags @@ -264,11 +264,11 @@ safe_exit () { echo "INTERACTIVE_YES='$INTERACTIVE_YES'" >> $IPC_SAVE echo "INTERACTIVE_NO='$INTERACTIVE_NO'" >> $IPC_SAVE fi - [ -n "$URB_YES" ] && echo "URB_DONE_LIST='$URB_DONE_LIST'" >> $IPC_SAVE + [ -n "$PM_URB" -o -n "$PM_URB_UP" ] && echo "PM_URB_DONE='$PM_URB_DONE'" >> $IPC_SAVE fi exit ${1:-0} -} +} # safe_exit() pm_cd () { builtin cd $1 2>/dev/null || return 1; } pm_cd_pd () { [ -n "$PM_INDEX_ONLY" ] && return 2; @@ -276,7 +276,7 @@ pm_cd_pd () { [ -n "$PM_INDEX_ONLY" ] & fail "Cannot cd to port directory: $pd/$1"; } pm_kill () { /bin/kill $* >/dev/null 2>/dev/null; } pm_make () { ( unset -v CUR_DEPS INSTALLED_LIST PM_DEPTH build_l; - unset -v MASTER_RB_LIST; + unset -v PM_URB_LIST; /usr/bin/nice /usr/bin/make $PM_MAKE_ARGS $*; ); } pm_make_b () { /usr/bin/make $PM_MAKE_ARGS BEFOREPORTMK=bpm $*; } pm_mktemp () { /usr/bin/mktemp -t f-${PM_PARENT_PID}-$1 || @@ -288,7 +288,7 @@ pm_unlink () { [ -e "$1" ] && /bin/unlin pm_find_s () { $PM_SU_CMD /usr/bin/find $*; } pm_install_s () { $PM_SU_CMD /usr/bin/install -p -o root -g wheel -m 644 $1 $2; } pm_make_s () { ( unset -v CUR_DEPS INSTALLED_LIST PM_DEPTH build_l; - unset -v MASTER_RB_LIST; + unset -v PM_URB_LIST; $PM_SU_CMD /usr/bin/nice /usr/bin/make $PM_MAKE_ARGS $*; ); } pm_mkdir_s () { $PM_SU_CMD /bin/mkdir -p $1; } pm_pkg_delete_s () { $PM_SU_CMD /usr/sbin/pkg_delete $*; } @@ -372,6 +372,7 @@ usage () { echo '' echo "${0##*/} [Common flags] -o " echo "${0##*/} [Common flags] [-R] -r " + echo ' (-r can be specified multiple times)' echo '' echo "${0##*/} -l" echo "${0##*/} [--index-only [-t]] -L" @@ -663,7 +664,7 @@ while getopts 'BCDFGHKLPRabde:fghilm:nop n) NO_ACTION=nopt; ARGS="-n $ARGS" ;; o) REPLACE_ORIGIN=oopt ;; p) fail 'The -p option has been deprecated' ;; - r) UPDATE_REQ_BYS=ropt + r) PM_URB=ropt if [ -d "$pdb/$OPTARG" ]; then glob_dirs=$OPTARG else @@ -673,8 +674,9 @@ while getopts 'BCDFGHKLPRabde:fghilm:nop 2) fail 'The argument to -r must match only one port' ;; esac fi - PM_RBP=${glob_dirs##*/} ; unset glob_dirs - portdir=`origin_from_pdb $PM_RBP` ;; + PM_URB_IPORTS="${PM_URB_IPORTS}${glob_dirs##*/} " + PM_URB_ORIGINS="${PM_URB_ORIGINS}`origin_from_pdb ${glob_dirs##*/}` " + unset glob_dirs ;; s) CLEAN_STALE=sopt ;; t) PM_THOROUGH=topt; ARGS="-t $ARGS" ;; u) fail 'The -u option has been deprecated' ;; @@ -730,7 +732,7 @@ fi if [ -n "$LIST" -o -n "$LIST_PLUS" ]; then if [ -n "$FETCH_ONLY" -o -n "$RESTART" -o -n "$UPDATE_ALL" -o \ -n "$EXPUNGE" -o -n "$PM_FORCE" -o -n "$NO_ACTION" -o \ - -n "$REPLACE_ORIGIN" -o -n "$UPDATE_REQ_BYS" -o -n "$CLEAN_STALE" ]; then + -n "$REPLACE_ORIGIN" -o -n "$PM_URB" -o -n "$CLEAN_STALE" ]; then fail 'The -[lL] options are not compatible with -FRaefnors' fi [ $# -gt 0 ] && fail 'The -[lL] options are not compatible with updates or installs' @@ -745,6 +747,9 @@ unset -f packages_init cross_idx test_co # Update based on options chosen above if [ "$$" -eq "$PM_PARENT_PID" ]; then + # Continue error checking in parent only + [ -n "$PM_URB" -a -n "$1" ] && fail 'The -r option is not compatible with other updates' + if [ -n "$PM_PACKAGES" -o -n "$PM_PACKAGES_BUILD" ]; then [ `/sbin/sysctl -n kern.osreldate 2>/dev/null` -lt 600400 ] && fail Package installation support requires FreeBSD 6.4 or newer @@ -1517,9 +1522,8 @@ check_state () { check_force_multi () { if [ -n "$PM_FORCE" ]; then check_restart_and_udf $1 || return 1 - elif [ -n "$URB_YES" ]; then - case "$MASTER_RB_LIST" in - *" $1 "*) check_restart_and_udf $1 || return 1 ;; + elif [ -n "$PM_URB_UP" ]; then + case " $PM_URB_LIST " in *" $1 "*) check_restart_and_udf $1 || return 1 ;; esac elif [ -n "$PM_MULTI_PORTS" ]; then case "$PM_MULTI_PORTS" in @@ -1631,9 +1635,6 @@ check_for_updates () { return 0 elif [ -n "$PM_UPDATE_IF_NEWER" ]; then return 1 - elif [ "$PM_RBP" = "$iport" ]; then - PM_RBP_NEEDS_UPGRADE=pm_rbp_needs_upgrade - return 0 fi # No need for check_exclude here because it is already @@ -2097,7 +2098,7 @@ fi already_done () { [ -n "$PM_VERBOSE" ] || return 0 - echo "===>>> The update for $1 is already done" + echo "===>>> The update for $1 is already done" ; echo '' } check_restart_and_udf () { @@ -2108,7 +2109,7 @@ check_restart_and_udf () { if [ ! -e "$pdb/${1}/PM_UPGRADE_DONE_FLAG" ]; then return 1 else - already_done $1 ; echo '' + already_done $1 fi } @@ -2273,7 +2274,7 @@ update_port () { term_printf " (${num_of_deps})" echo "===>>> Returning to update check of installed ports" echo '' - elif [ -n "$UPDATE_REQ_BYS" ]; then + elif [ -n "$PM_URB" ]; then return 0 elif [ -n "$PM_FIRST_PASS" -a -z "$PM_PACKAGES" ]; then echo "===>>> Continuing initial dependency check for $portdir" @@ -2282,7 +2283,7 @@ update_port () { echo "===>>> Returning to dependency check for $portdir" fi return 0 -} +} # update_port() uniquify_list () { local ul_item ul_temp_list @@ -2423,7 +2424,7 @@ dependency_check () { [ -n "$PM_FIRST_PASS" ] && case "$PM_NEEDS_UPDATE" in *\ $origin\ *) continue ;; esac - [ -z "$URB_YES" ] && + [ -z "$PM_URB_UP" ] && case "$CUR_DEPS" in *:${origin}:*) continue ;; esac if [ -z "$PM_INDEX_ONLY" ]; then @@ -2462,17 +2463,17 @@ dependency_check () { CUR_DEPS="${CUR_DEPS}${iport}:${origin}:" fi continue - elif [ -n "$URB_YES" -a -n "$iport" ]; then - case "$URB_DONE_LIST" in + elif [ -n "$PM_URB_UP" -a -n "$iport" ]; then + case "$PM_URB_DONE" in *:${iport}:*) already_done $iport ; continue ;; esac - case "$MASTER_RB_LIST" in *" $iport "*) + case " $PM_URB_LIST " in *" $iport "*) check_interactive $iport || continue if ! check_restart_and_udf $iport; then update_port $iport else CUR_DEPS="${CUR_DEPS}${iport}:${origin}:" - URB_DONE_LIST="${URB_DONE_LIST}${upg_port}:" + PM_URB_DONE="${PM_URB_DONE}${upg_port}:" fi continue ;; esac @@ -2507,36 +2508,12 @@ dependency_check () { fi ;; esac fi -} - -create_master_rb_list () { - # Global: MASTER_RB_LIST - local req_by - - for req_by in `grep -l DEPORIGIN:$portdir$ $pdb/*/+CONTENTS`; do - req_by="${req_by%/+CONTENTS}" - req_by="${req_by##*/}" - MASTER_RB_LIST="${MASTER_RB_LIST}${req_by} " - done - - [ -n "$MASTER_RB_LIST" ] && export MASTER_RB_LIST=" $MASTER_RB_LIST" -} +} # dependency_check() post_first_pass () { local action - if [ -n "$UPDATE_REQ_BYS" -a -n "$RESTART" ]; then - if [ -n "$PM_RBP_NEEDS_UPGRADE" ]; then - echo "===>>> $PM_RBP and/or dependencies are out of date, forcing rebuild" - else - echo "===>>> $PM_RBP is up to date, skipping rebuild due to -R flag" - PM_REQ_BY_SKIP_PARENT=pm_req_by_skip_parent - build_l="${build_l#*\\n}" - fi - echo '' - fi - - if [ $num_of_deps -gt 0 ]; then + if [ ${num_of_deps:-0} -gt 0 ]; then term_printf " (${num_of_deps})" if [ -z "$PM_NO_CONFIRM" ]; then @@ -2614,6 +2591,62 @@ init_term_printf () { term_printf } +if [ -n "$PM_URB" ]; then + [ -n "$RESTART" ] && PM_UPDATE_IF_NEWER=pm_update_if_newer_urb + +urb_update () { + # Global: PM_URB_UP + local verb origin req_by + + verb=checking ; [ -n "$1" ] && verb=updating + + export PM_URB_UP=pm_urb_up + echo '' + echo "===>>> Begin $verb ports that depend on $PM_URB_IPORTS" + echo '' + + for origin in $PM_URB_ORIGINS; do + for req_by in `grep -l DEPORIGIN:${origin}$ $pdb/*/+CONTENTS`; do + req_by="${req_by%/+CONTENTS}" + req_by="${req_by##*/}" + PM_URB_LIST="${PM_URB_LIST} ${req_by}" + done + done + + if [ -n "$PM_URB_LIST" ]; then + PM_URB_LIST="`uniquify_list $PM_URB_LIST`" + export PM_URB_LIST + else + echo "===>>> No ports depend on $PM_URB_IPORTS" ; echo '' + fi + + for req_by in $PM_URB_LIST; do + # Probably not needed, but JIC + [ -d "$pdb/$req_by" ] || continue + + pm_v "===>>> $req_by depends on $PM_URB_IPORTS" + + case "$PM_URB_DONE" in + *:${req_by}:*) already_done $req_by ; continue ;; esac + + check_exclude $req_by || continue + check_interactive $req_by || continue + + # Shortcut, since check_for will force it + if [ -z "$RESTART" -a -z "$PM_FORCE" ]; then + update_port $req_by + else + check_for_updates $req_by || fail 'Update failed' + fi + echo -e "\n===>>> Returning to check of ports depending on $PM_URB_IPORTS" + done + echo '' + echo "===>>> Done $verb ports that depend on $PM_URB_IPORTS" + echo '' + unset PM_URB_UP PM_URB_LIST PM_URB_DONE +} +fi + multiport () { # Global PM_MULTI_PORTS=':' ; export PM_MULTI_PORTS @@ -2656,14 +2689,16 @@ multiport () { *) iport=$port ;; esac - if [ -n "$iport" ]; then - if check_for_updates multi $iport; then - if [ -n "$PM_VERBOSE" ]; then - echo '' - echo "===>>> $port is up to date, skipping" - fi - continue + if [ -n "$iport" ] && check_for_updates multi $iport; then + if [ -n "$PM_URB" -a -n "$RESTART" ]; then + echo '' + echo "===>>> $iport is up to date, skipping rebuild due to -R flag" + udl_prime="${udl_prime}${iport}:" + elif [ -n "$PM_VERBOSE" ]; then + echo '' + echo "===>>> $port is up to date, skipping" fi + continue fi fi @@ -2673,50 +2708,62 @@ multiport () { done unset PM_UPDATE_IF_NEWER - echo '' if [ -z "$worklist" ]; then - echo "===>>> All listed ports are up to date, exiting" ; echo '' - safe_exit - fi - echo "===>>> Working on multiple ports:" - echo -e $portlist - - if [ -n "$PM_FIRST_PASS" ]; then - if [ -n "$PM_BUILD_ONLY_LIST" ]; then - PM_BUILD_ONLY_LIST=pmp_doing_build_deps - for port in $worklist; do - case "$port" in - */*) run_dl_g="$run_dl_g ${pd}/${port} " ;; - *) run_dl_g="$run_dl_g ${pd}/`origin_from_pdb $port` " ;; - esac - done + if [ -z "$PM_URB" ]; then + echo '' + echo "===>>> All listed ports are up to date, exiting" ; echo '' + safe_exit fi + else + echo '' + echo "===>>> Working on:" + echo -e $portlist + fi - numports=0 + # First Pass + if [ -n "$PM_BUILD_ONLY_LIST" ]; then + PM_BUILD_ONLY_LIST=pmp_doing_build_deps for port in $worklist; do case "$port" in - */*) origin=$port ;; - *) origin=`origin_from_pdb $port` ;; + */*) run_dl_g="$run_dl_g ${pd}/${port} " ;; + *) run_dl_g="$run_dl_g ${pd}/`origin_from_pdb $port` " ;; esac + done + fi - case "$PM_NEEDS_UPDATE" in *\ $origin\ *) continue ;; esac + [ -n "$PM_URB" ] && export PM_URB - numports=$(( $numports + 1 )) - init_term_printf "$port ${numports}/${numports}" - ($0 $ARGS $port) || fail "Update for $port failed" - . $IPC_SAVE - - case "$PM_NEEDS_UPDATE" in - *\ $origin\ *) continue ;; - # Handle +IGNOREME in child - *) numports=$(( $numports - 1 )) ;; - esac - done + numports=0 + for port in $worklist; do + case "$port" in + */*) origin=$port ;; + *) origin=`origin_from_pdb $port` ;; + esac - check_fetch_only - post_first_pass multiple ports + case "$PM_NEEDS_UPDATE" in *\ $origin\ *) continue ;; esac + + numports=$(( $numports + 1 )) + init_term_printf "$port ${numports}/${numports}" + ($0 $ARGS $port) || fail "Update for $port failed" + . $IPC_SAVE + + case "$PM_NEEDS_UPDATE" in + *\ $origin\ *) continue ;; # Handle +IGNOREME in child + *) numports=$(( $numports - 1 )) ;; + esac + done + + if [ -n "$PM_URB" ]; then + unset PM_URB ; PM_URB=pm_urb_post_first_pass + PM_URB_DONE=":${udl_prime}" ; export PM_URB_DONE + urb_update fi + check_fetch_only + post_first_pass multiple ports + + [ -n "$PM_URB" ] && export PM_URB + export PM_BUILDING=pmbuildingmultiport num=0 for port in $worklist; do @@ -2741,6 +2788,13 @@ multiport () { ($0 $ARGS $port) || fail "Update for $port failed" . $IPC_SAVE done + + if [ -n "$PM_URB" ]; then + unset PM_URB ; PM_URB=pm_urb_post_build + PM_URB_DONE=":${udl_prime}" ; export PM_URB_DONE + urb_update urb_update_after_build + fi + safe_exit } @@ -2754,45 +2808,6 @@ make_config () { pm_make_s $config_type } -urb_final () { - # Global: URB_YES - local req_by - - export URB_YES=urb_yes_final - echo "===>>> Updating ports that depend on $new_port" - echo '' - create_master_rb_list - for req_by in $MASTER_RB_LIST; do - # Probably not needed, but JIC - [ -d "$pdb/$req_by" ] || continue - - case "$URB_DONE_LIST" in - *:${req_by}:*) already_done $req_by ; continue ;; - esac - - # Check here since if "no" it will not prompt - check_interactive $req_by || continue - - pm_v "===>>> $new_port is required by $req_by" - check_exclude $req_by || continue - - # Shortcut, since check_for will force it - if [ -z "$RESTART" -a -z "$PM_FORCE" ]; then - update_port $req_by - else - check_for_updates $req_by || fail 'Update failed' - fi - echo "===>>> Returning to check of ports depending on $upg_port" - done - echo '' - echo "===>>> Done updating ports that depend on $new_port" - echo '' - - check_fetch_only Package - - safe_exit -} - #=============== End functions for main =============== # INIT Parent @@ -2827,8 +2842,7 @@ if [ "$$" -eq "$PM_PARENT_PID" -a -z "$S export INTERACTIVE_YES INTERACTIVE_NO fi - [ -n "$UPDATE_REQ_BYS" ] && export URB_DONE_LIST=':' - if [ -n "$UPDATE_REQ_BYS" -o -n "$PM_FORCE" ]; then + if [ -n "$PM_URB" -o -n "$PM_FORCE" ]; then if [ -z "$RESTART" ]; then files=`find $pdb -type f -name PM_UPGRADE_DONE_FLAG` if [ -n "$files" ]; then @@ -2878,6 +2892,7 @@ if [ "$$" -eq "$PM_PARENT_PID" -a -z "$S [ -z "$DONT_SCRUB_DISTFILES" -a -z "$FETCH_ONLY" -a -z "$PM_PACKAGES" ] && export DI_FILES=`pm_mktemp DI-FILES` + [ -n "$PM_URB" ] && multiport $PM_URB_IPORTS [ $# -gt 1 -a -z "$REPLACE_ORIGIN" ] && multiport "$@" fi @@ -3090,7 +3105,7 @@ if [ -e "$pdb/$upg_port/+IGNOREME" ]; th safe_exit fi ;; esac - elif [ -n "$URB_YES" ]; then + elif [ -n "$PM_URB_UP" ]; then echo '' echo "===>>> $upg_port has an +IGNOREME file, ignoring" echo '' @@ -3139,8 +3154,6 @@ if [ -n "$PM_FIRST_PASS" -a -z "$FETCH_O if [ -n "$upg_port" ]; then update_build_l $upg_port - [ -n "$UPDATE_REQ_BYS" -a -n "$RESTART" -a "$$" -eq "$PM_PARENT_PID" ] && - check_for_updates $upg_port else update_build_l $portdir fi @@ -3223,8 +3236,8 @@ if [ -n "$PM_FIRST_PASS" ]; then dependency_check "$dep_check_type" - [ -n "$UPDATE_REQ_BYS" -o -n "$URB_YES" ] && - URB_DONE_LIST="${URB_DONE_LIST}${upg_port}:" + [ -n "$PM_URB" -o -n "$PM_URB_UP" ] && + PM_URB_DONE="${PM_URB_DONE}${upg_port}:" if [ ! "$$" -eq "$PM_PARENT_PID" ]; then # Save state for the parent process to read back in @@ -3241,40 +3254,6 @@ if [ -n "$PM_FIRST_PASS" ]; then fi safe_exit - elif [ -n "$UPDATE_REQ_BYS" ]; then - [ -z "$NO_DEP_UPDATES" ] && PM_RBP_NEEDS_UPGRADE=pm_rbp_needs_upgrade - export URB_YES=urb_yes - echo '' - echo "===>>> Checking ports that depend on $upg_port" - echo '' - create_master_rb_list - [ -n "$MASTER_RB_LIST" ] || { - echo "===>>> No ports depend on $upg_port" ; echo ''; } - for req_by in $MASTER_RB_LIST; do - # Probably not needed, but JIC - [ -d "$pdb/$req_by" ] || continue - - case "$URB_DONE_LIST" in - *:${req_by}:*) already_done $req_by - continue ;; esac - - pm_v "===>>> $upg_port is required by $req_by" - - check_exclude $req_by || continue - check_interactive $req_by || continue - - # Shortcut, since check_for will force it - if [ -z "$RESTART" -a -z "$PM_FORCE" ]; then - update_port $req_by - else - check_for_updates $req_by || fail 'Update failed' - fi - echo "===>>> Returning to check of ports depending on $upg_port" - done - echo '' - echo "===>>> Done checking ports that depend on $upg_port" - echo '' - unset URB_YES MASTER_RB_LIST ; URB_DONE_LIST=':' fi check_fetch_only @@ -3330,8 +3309,6 @@ if [ -z "$new_port" ]; then fi fi -[ -n "$PM_REQ_BY_SKIP_PARENT" ] && urb_final - if [ -n "$PM_PACKAGES" -o "$PM_PACKAGES_BUILD" = doing_build_only_dep ]; then case `pm_make_b -V PT_NO_INSTALL_PACKAGE` in '') pm_package_time=yes ;; @@ -3666,13 +3643,7 @@ if [ -z "$PM_THOROUGH" -a -z "$NO_DEP_UP fi if [ -n "$FETCH_ONLY" ]; then # Only reached here if using packages - if [ -n "$UPDATE_REQ_BYS" ]; then - if [ -s "$pdb/$new_port/+REQUIRED_BY" ]; then - urb_final - else - safe_exit - fi - elif [ "$$" -eq "$PM_PARENT_PID" ]; then + if [ "$$" -eq "$PM_PARENT_PID" ]; then check_fetch_only Package else safe_exit @@ -3858,7 +3829,7 @@ else ilist="Installation of $portdir ($new_port)" fi -if [ "$$" -ne "$PM_PARENT_PID" -o -n "$UPDATE_REQ_BYS" ]; then +if [ "$$" -ne "$PM_PARENT_PID" -o -n "$PM_URB" ]; then echo "===>>> $ilist succeeded" ; echo '' fi @@ -3868,8 +3839,8 @@ CUR_DEPS="${CUR_DEPS}${new_port}:${portd [ -n "$HIDE_BUILD" -a -n "$port_log" ] && pm_unlink $port_log -[ -n "$URB_YES" -o -n "$UPDATE_REQ_BYS" ] && URB_DONE_LIST="${URB_DONE_LIST}${new_port}:" -[ -n "$URB_YES" -o -n "$UPDATE_REQ_BYS" -o -n "$PM_FORCE" ] && +[ -n "$PM_URB" -o -n "$PM_URB_UP" ] && PM_URB_DONE="${PM_URB_DONE}${new_port}:" +[ -n "$PM_URB" -o -n "$PM_URB_UP" -o -n "$PM_FORCE" ] && $PM_SU_CMD touch $pdb/$new_port/PM_UPGRADE_DONE_FLAG if [ -z "$DONT_SCRUB_DISTFILES" ]; then @@ -3880,8 +3851,6 @@ if [ -z "$DONT_SCRUB_DISTFILES" ]; then fi fi -[ -n "$UPDATE_REQ_BYS" ] && [ -s "$pdb/$new_port/+REQUIRED_BY" ] && urb_final - safe_exit #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From owner-svn-src-user@FreeBSD.ORG Fri Sep 2 07:39:05 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0C4F2106564A; Fri, 2 Sep 2011 07:39:05 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F02A38FC1A; Fri, 2 Sep 2011 07:39:04 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p827d4OA087198; Fri, 2 Sep 2011 07:39:04 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p827d4uJ087196; Fri, 2 Sep 2011 07:39:04 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201109020739.p827d4uJ087196@svn.freebsd.org> From: Doug Barton Date: Fri, 2 Sep 2011 07:39:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225321 - user/dougb/portmaster/files X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Sep 2011 07:39:05 -0000 Author: dougb Date: Fri Sep 2 07:39:04 2011 New Revision: 225321 URL: http://svn.freebsd.org/changeset/base/225321 Log: Document that -r can be specified more than once. Modified: user/dougb/portmaster/files/portmaster.8 Modified: user/dougb/portmaster/files/portmaster.8 ============================================================================== --- user/dougb/portmaster/files/portmaster.8 Fri Sep 2 07:37:55 2011 (r225320) +++ user/dougb/portmaster/files/portmaster.8 Fri Sep 2 07:39:04 2011 (r225321) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 1, 2011 +.Dd September 1, 2011 .Dt PORTMASTER 8 .Os .Sh NAME @@ -82,6 +82,7 @@ and/or multiple globs from /var/db/pkg .Op Common Flags .Op Fl R .Fl r Ar name/glob of port in /var/db/pkg +(can be specified more than once) .Nm .Fl l .Nm @@ -466,6 +467,9 @@ but the newly installed port is now foop .Nm .Fl R Fl r Ar fooport-1.24 and it should pick up where you left off. +The +.Fl r +option can be specified more than once. .It Fl R used with the .Fl r From owner-svn-src-user@FreeBSD.ORG Fri Sep 2 07:53:26 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D587D1065670; Fri, 2 Sep 2011 07:53:26 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C50DF8FC15; Fri, 2 Sep 2011 07:53:26 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p827rQNl087814; Fri, 2 Sep 2011 07:53:26 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p827rQsp087812; Fri, 2 Sep 2011 07:53:26 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201109020753.p827rQsp087812@svn.freebsd.org> From: Adrian Chadd Date: Fri, 2 Sep 2011 07:53:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225322 - user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416 X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Sep 2011 07:53:26 -0000 Author: adrian Date: Fri Sep 2 07:53:26 2011 New Revision: 225322 URL: http://svn.freebsd.org/changeset/base/225322 Log: Fix an issue with Addac setup on the AR5416. This needs to be merged into -HEAD when it opens up. Modified: user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416/ar5416.ini Modified: user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416/ar5416.ini ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416/ar5416.ini Fri Sep 2 07:39:04 2011 (r225321) +++ user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416/ar5416.ini Fri Sep 2 07:53:26 2011 (r225322) @@ -687,7 +687,7 @@ static const uint32_t ar5416Addac[][2] = {0x0000989c, 0x00000000 }, {0x0000989c, 0x00000000 }, {0x0000989c, 0x00000000 }, - {0x000098cc, 0x00000000 }, + {0x000098c4, 0x00000000 }, }; /* hand-crafted from code that does explicit register writes */ From owner-svn-src-user@FreeBSD.ORG Fri Sep 2 08:00:58 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 23640106566C; Fri, 2 Sep 2011 08:00:58 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 12DF88FC0C; Fri, 2 Sep 2011 08:00:58 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p8280veZ088093; Fri, 2 Sep 2011 08:00:57 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p8280vte088091; Fri, 2 Sep 2011 08:00:57 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201109020800.p8280vte088091@svn.freebsd.org> From: Adrian Chadd Date: Fri, 2 Sep 2011 08:00:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225323 - user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416 X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Sep 2011 08:00:58 -0000 Author: adrian Date: Fri Sep 2 08:00:57 2011 New Revision: 225323 URL: http://svn.freebsd.org/changeset/base/225323 Log: Another thing to merge into -HEAD : fix ADC calibration. Merlin NICs which are doing fast clock in 5ghz mode (ie 44/88mhz instead of 40/80mhz) don't require the dual ADC calibration in HT20 mode. This should be merged into -HEAD. Modified: user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c Modified: user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c Fri Sep 2 07:53:26 2011 (r225322) +++ user/adrian/if_ath_tx/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c Fri Sep 2 08:00:57 2011 (r225323) @@ -72,16 +72,17 @@ ar5416IsCalSupp(struct ath_hal *ah, cons return !IEEE80211_IS_CHAN_B(chan); case ADC_GAIN_CAL: case ADC_DC_CAL: - /* Run ADC Gain Cal for either 5ghz any or 2ghz HT40 */ /* - * Merlin (AR9280) doesn't ever complete ADC calibrations - * in 5ghz non-HT40 mode (ie, HT20, 11a). For now, disable - * it for Merlin only until further information is - * available. + * Run ADC Gain Cal for either 5ghz any or 2ghz HT40. + * + * Don't run ADC calibrations for 5ghz fast clock mode + * in HT20 - only one ADC is used. */ - if (! AR_SREV_MERLIN(ah)) - if (IEEE80211_IS_CHAN_5GHZ(chan)) - return AH_TRUE; + if (IEEE80211_IS_CHAN_HT20(chan) && + (IS_5GHZ_FAST_CLOCK_EN(ah, chan))) + return AH_FALSE; + if (IEEE80211_IS_CHAN_5GHZ(chan)) + return AH_TRUE; if (IEEE80211_IS_CHAN_HT40(chan)) return AH_TRUE; return AH_FALSE; From owner-svn-src-user@FreeBSD.ORG Fri Sep 2 08:13:07 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AC2931065673; Fri, 2 Sep 2011 08:13:07 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9BD028FC17; Fri, 2 Sep 2011 08:13:07 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p828D77l088541; Fri, 2 Sep 2011 08:13:07 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p828D74f088539; Fri, 2 Sep 2011 08:13:07 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201109020813.p828D74f088539@svn.freebsd.org> From: Adrian Chadd Date: Fri, 2 Sep 2011 08:13:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225324 - user/adrian/if_ath_tx/sys/dev/ath X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Sep 2011 08:13:07 -0000 Author: adrian Date: Fri Sep 2 08:13:07 2011 New Revision: 225324 URL: http://svn.freebsd.org/changeset/base/225324 Log: If the RX link pointer is NULL, RX DMA has been halted. This means the first buffer re-added to the list should be given to the hardware. This doesn't restart DMA by itself; I'l follow up with some tinkering to try and re-enable it without having to forcibly stop and restart the PCU. Whilst here, add a comment to point out another thing I need to tinker with. Obtained from: Linux, Atheros Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Fri Sep 2 08:00:57 2011 (r225323) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Fri Sep 2 08:13:07 2011 (r225324) @@ -3418,7 +3418,9 @@ ath_rxbuf_init(struct ath_softc *sc, str , 0 ); - if (sc->sc_rxlink != NULL) + if (sc->sc_rxlink == NULL) + ath_hal_putrxbuf(sc->sc_ah, bf->bf_daddr); + else *sc->sc_rxlink = bf->bf_daddr; sc->sc_rxlink = &ds->ds_link; return 0; @@ -3931,6 +3933,11 @@ rx_next: */ if (sc->sc_kickpcu) { sc->sc_kickpcu = 0; + /* + * XXX this causes a 3ms delay; and shuts down a lof + * XXX is it really needed? Or is it just enough to + * XXX kick the PCU again to continue RXing? + */ ath_stoprecv(sc); sc->sc_imask |= (HAL_INT_RXEOL | HAL_INT_RXORN); if (ath_startrecv(sc) != 0) { From owner-svn-src-user@FreeBSD.ORG Fri Sep 2 08:15:48 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id ED78B106564A; Fri, 2 Sep 2011 08:15:48 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C36A98FC0A; Fri, 2 Sep 2011 08:15:48 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p828FmGD088661; Fri, 2 Sep 2011 08:15:48 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p828Fmxm088657; Fri, 2 Sep 2011 08:15:48 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201109020815.p828Fmxm088657@svn.freebsd.org> From: Adrian Chadd Date: Fri, 2 Sep 2011 08:15:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225325 - user/adrian/if_ath_tx/sys/dev/ath X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Sep 2011 08:15:49 -0000 Author: adrian Date: Fri Sep 2 08:15:48 2011 New Revision: 225325 URL: http://svn.freebsd.org/changeset/base/225325 Log: Add TX/RX interrupt counts. Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath.c user/adrian/if_ath_tx/sys/dev/ath/if_ath_sysctl.c user/adrian/if_ath_tx/sys/dev/ath/if_athioctl.h Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Fri Sep 2 08:13:07 2011 (r225324) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Fri Sep 2 08:15:48 2011 (r225325) @@ -1459,10 +1459,14 @@ ath_intr(void *arg) /* bump tx trigger level */ ath_hal_updatetxtriglevel(ah, AH_TRUE); } - if (status & HAL_INT_RX) + if (status & HAL_INT_RX) { + sc->sc_stats.ast_rx_intr++; taskqueue_enqueue(sc->sc_tq, &sc->sc_rxtask); - if (status & HAL_INT_TX) + } + if (status & HAL_INT_TX) { + sc->sc_stats.ast_tx_intr++; taskqueue_enqueue(sc->sc_tq, &sc->sc_txtask); + } if (status & HAL_INT_BMISS) { sc->sc_stats.ast_bmiss++; taskqueue_enqueue(sc->sc_tq, &sc->sc_bmisstask); Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_sysctl.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_sysctl.c Fri Sep 2 08:13:07 2011 (r225324) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_sysctl.c Fri Sep 2 08:15:48 2011 (r225325) @@ -817,6 +817,11 @@ ath_sysctl_stats_attach(struct ath_softc &sc->sc_stats.ast_tx_aggrfail, 0, "Number of aggregate TX failures (whole frame)"); + SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_rx_intr", CTLFLAG_RD, + &sc->sc_stats.ast_rx_intr, 0, "RX interrupts"); + SYSCTL_ADD_UINT(ctx, child, OID_AUTO, "ast_tx_intr", CTLFLAG_RD, + &sc->sc_stats.ast_tx_intr, 0, "TX interrupts"); + /* Attach the RX phy error array */ ath_sysctl_stats_attach_rxphyerr(sc, child); } Modified: user/adrian/if_ath_tx/sys/dev/ath/if_athioctl.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_athioctl.h Fri Sep 2 08:13:07 2011 (r225324) +++ user/adrian/if_ath_tx/sys/dev/ath/if_athioctl.h Fri Sep 2 08:15:48 2011 (r225325) @@ -150,7 +150,9 @@ struct ath_stats { u_int32_t ast_tx_delim_underrun; u_int32_t ast_tx_aggrfail; /* aggregate TX failed in its entirety */ struct ath_tx_aggr_stats tx_aggr; - u_int32_t ast_pad[9]; + u_int32_t ast_tx_intr; + u_int32_t ast_rx_intr; + u_int32_t ast_pad[7]; }; #define SIOCGATHSTATS _IOWR('i', 137, struct ifreq) From owner-svn-src-user@FreeBSD.ORG Fri Sep 2 08:34:31 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E01CD106566B; Fri, 2 Sep 2011 08:34:31 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CF61C8FC17; Fri, 2 Sep 2011 08:34:31 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p828YVvK089266; Fri, 2 Sep 2011 08:34:31 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p828YV26089261; Fri, 2 Sep 2011 08:34:31 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201109020834.p828YV26089261@svn.freebsd.org> From: Adrian Chadd Date: Fri, 2 Sep 2011 08:34:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225327 - user/adrian/if_ath_tx/sys/dev/ath X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Sep 2011 08:34:32 -0000 Author: adrian Date: Fri Sep 2 08:34:31 2011 New Revision: 225327 URL: http://svn.freebsd.org/changeset/base/225327 Log: Migrate the aggregate stats out of sc_stats. Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_sysctl.c user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c user/adrian/if_ath_tx/sys/dev/ath/if_athioctl.h user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_sysctl.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_sysctl.c Fri Sep 2 08:19:19 2011 (r225326) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_sysctl.c Fri Sep 2 08:34:31 2011 (r225327) @@ -314,19 +314,19 @@ ath_sysctl_txagg(SYSCTL_HANDLER_ARGS) return 0; printf("aggr single packet: %d\n", - sc->sc_stats.tx_aggr.aggr_single_pkt); + sc->sc_aggr_stats.aggr_single_pkt); printf("aggr single packet w/ BAW closed: %d\n", - sc->sc_stats.tx_aggr.aggr_baw_closed_single_pkt); + sc->sc_aggr_stats.aggr_baw_closed_single_pkt); printf("aggr non-baw packet: %d\n", - sc->sc_stats.tx_aggr.aggr_nonbaw_pkt); + sc->sc_aggr_stats.aggr_nonbaw_pkt); printf("aggr aggregate packet: %d\n", - sc->sc_stats.tx_aggr.aggr_aggr_pkt); + sc->sc_aggr_stats.aggr_aggr_pkt); printf("aggr single packet low hwq: %d\n", - sc->sc_stats.tx_aggr.aggr_low_hwq_single_pkt); + sc->sc_aggr_stats.aggr_low_hwq_single_pkt); printf("aggr sched, no work: %d\n", - sc->sc_stats.tx_aggr.aggr_sched_nopkt); + sc->sc_aggr_stats.aggr_sched_nopkt); for (i = 0; i < 64; i++) { - printf("%2d: %10d ", i, sc->sc_stats.tx_aggr.aggr_pkts[i]); + printf("%2d: %10d ", i, sc->sc_aggr_stats.aggr_pkts[i]); if (i % 4 == 3) printf("\n"); } Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Fri Sep 2 08:19:19 2011 (r225326) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Fri Sep 2 08:34:31 2011 (r225327) @@ -2006,7 +2006,7 @@ ath_tx_xmit_aggr(struct ath_softc *sc, s ath_tx_chaindesclist(sc, bf); /* Statistics */ - sc->sc_stats.tx_aggr.aggr_low_hwq_single_pkt++; + sc->sc_aggr_stats.aggr_low_hwq_single_pkt++; /* Track per-TID hardware queue depth correctly */ tid->hwq_depth++; @@ -3144,7 +3144,7 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft ath_hal_clr11n_aggr(sc->sc_ah, bf->bf_desc); ath_tx_set_ratectrl(sc, ni, bf); - sc->sc_stats.tx_aggr.aggr_nonbaw_pkt++; + sc->sc_aggr_stats.aggr_nonbaw_pkt++; /* Queue the packet; continue */ goto queuepkt; @@ -3184,17 +3184,17 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft ath_hal_clr11n_aggr(sc->sc_ah, bf->bf_desc); ath_tx_set_ratectrl(sc, ni, bf); if (status == ATH_AGGR_BAW_CLOSED) - sc->sc_stats.tx_aggr.aggr_baw_closed_single_pkt++; + sc->sc_aggr_stats.aggr_baw_closed_single_pkt++; else - sc->sc_stats.tx_aggr.aggr_single_pkt++; + sc->sc_aggr_stats.aggr_single_pkt++; } else { DPRINTF(sc, ATH_DEBUG_SW_TX_AGGR, "%s: multi-frame aggregate: %d frames, length %d\n", __func__, bf->bf_state.bfs_nframes, bf->bf_state.bfs_al); bf->bf_state.bfs_aggr = 1; - sc->sc_stats.tx_aggr.aggr_pkts[bf->bf_state.bfs_nframes]++; - sc->sc_stats.tx_aggr.aggr_aggr_pkt++; + sc->sc_aggr_stats.aggr_pkts[bf->bf_state.bfs_nframes]++; + sc->sc_aggr_stats.aggr_aggr_pkt++; /* * Setup the relevant descriptor fields @@ -3323,7 +3323,7 @@ ath_txq_sched(struct ath_softc *sc, stru * some packets in the aggregation queue. */ if (txq->axq_aggr_depth >= sc->sc_hwq_limit) { - sc->sc_stats.tx_aggr.aggr_sched_nopkt++; + sc->sc_aggr_stats.aggr_sched_nopkt++; return; } Modified: user/adrian/if_ath_tx/sys/dev/ath/if_athioctl.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_athioctl.h Fri Sep 2 08:19:19 2011 (r225326) +++ user/adrian/if_ath_tx/sys/dev/ath/if_athioctl.h Fri Sep 2 08:34:31 2011 (r225327) @@ -149,7 +149,6 @@ struct ath_stats { u_int32_t ast_tx_data_underrun; u_int32_t ast_tx_delim_underrun; u_int32_t ast_tx_aggrfail; /* aggregate TX failed in its entirety */ - struct ath_tx_aggr_stats tx_aggr; u_int32_t ast_tx_intr; u_int32_t ast_rx_intr; u_int32_t ast_pad[7]; Modified: user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Fri Sep 2 08:19:19 2011 (r225326) +++ user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Fri Sep 2 08:34:31 2011 (r225327) @@ -334,6 +334,7 @@ struct ath_tx99; struct ath_softc { struct ifnet *sc_ifp; /* interface common */ struct ath_stats sc_stats; /* interface statistics */ + struct ath_tx_aggr_stats sc_aggr_stats; int sc_debug; int sc_nvaps; /* # vaps */ int sc_nstavaps; /* # station vaps */ From owner-svn-src-user@FreeBSD.ORG Fri Sep 2 09:55:35 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 74385106564A; Fri, 2 Sep 2011 09:55:35 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 646B48FC17; Fri, 2 Sep 2011 09:55:35 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p829tZZn091615; Fri, 2 Sep 2011 09:55:35 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p829tZtl091613; Fri, 2 Sep 2011 09:55:35 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201109020955.p829tZtl091613@svn.freebsd.org> From: Adrian Chadd Date: Fri, 2 Sep 2011 09:55:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225328 - user/adrian/if_ath_tx/sys/dev/ath X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Sep 2011 09:55:35 -0000 Author: adrian Date: Fri Sep 2 09:55:35 2011 New Revision: 225328 URL: http://svn.freebsd.org/changeset/base/225328 Log: Revert this for now; there's other stuff I have to fold into re-start RX before I do this. Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Fri Sep 2 08:34:31 2011 (r225327) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Fri Sep 2 09:55:35 2011 (r225328) @@ -3422,9 +3422,7 @@ ath_rxbuf_init(struct ath_softc *sc, str , 0 ); - if (sc->sc_rxlink == NULL) - ath_hal_putrxbuf(sc->sc_ah, bf->bf_daddr); - else + if (sc->sc_rxlink != NULL) *sc->sc_rxlink = bf->bf_daddr; sc->sc_rxlink = &ds->ds_link; return 0; From owner-svn-src-user@FreeBSD.ORG Fri Sep 2 16:46:42 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DA780106564A; Fri, 2 Sep 2011 16:46:42 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CA9308FC1A; Fri, 2 Sep 2011 16:46:42 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p82Gkg5u007455; Fri, 2 Sep 2011 16:46:42 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p82GkgP4007453; Fri, 2 Sep 2011 16:46:42 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201109021646.p82GkgP4007453@svn.freebsd.org> From: Gabor Kovesdan Date: Fri, 2 Sep 2011 16:46:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225335 - user/gabor/grep/trunk X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Sep 2011 16:46:42 -0000 Author: gabor Date: Fri Sep 2 16:46:42 2011 New Revision: 225335 URL: http://svn.freebsd.org/changeset/base/225335 Log: - Add proper error handling for grep -F Modified: user/gabor/grep/trunk/grep.c Modified: user/gabor/grep/trunk/grep.c ============================================================================== --- user/gabor/grep/trunk/grep.c Fri Sep 2 16:40:18 2011 (r225334) +++ user/gabor/grep/trunk/grep.c Fri Sep 2 16:46:42 2011 (r225335) @@ -687,9 +687,15 @@ main(int argc, char *argv[]) /* Check if cheating is allowed (always is for fgrep). */ if (grepbehave == GREP_FIXED) { - for (i = 0; i < patterns; ++i) - fixncomp(&fg_pattern[i], pattern[i].pat, + for (i = 0; i < patterns; ++i) { + c = fixncomp(&fg_pattern[i], pattern[i].pat, pattern[i].len, cflags); + if (c != 0) { + regerror(c, &r_pattern[i], re_error, + RE_ERROR_BUF); + errx(2, "%s", re_error); + } + } } else { for (i = 0; i < patterns; ++i) { if (fastncomp(&fg_pattern[i], pattern[i].pat, From owner-svn-src-user@FreeBSD.ORG Fri Sep 2 16:50:24 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 89C8D1065672; Fri, 2 Sep 2011 16:50:24 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 793668FC0A; Fri, 2 Sep 2011 16:50:24 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p82GoOpT007600; Fri, 2 Sep 2011 16:50:24 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p82GoOtJ007597; Fri, 2 Sep 2011 16:50:24 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201109021650.p82GoOtJ007597@svn.freebsd.org> From: Gabor Kovesdan Date: Fri, 2 Sep 2011 16:50:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225336 - user/gabor/grep/trunk/regex X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Sep 2011 16:50:24 -0000 Author: gabor Date: Fri Sep 2 16:50:24 2011 New Revision: 225336 URL: http://svn.freebsd.org/changeset/base/225336 Log: - Be more verbose with debug information - Fix a bug in dot handling - Do not cast to unsigned char because it can cause a segfault - Add an include to glue.h for consistency Modified: user/gabor/grep/trunk/regex/glue.h user/gabor/grep/trunk/regex/tre-fastmatch.c Modified: user/gabor/grep/trunk/regex/glue.h ============================================================================== --- user/gabor/grep/trunk/regex/glue.h Fri Sep 2 16:46:42 2011 (r225335) +++ user/gabor/grep/trunk/regex/glue.h Fri Sep 2 16:50:24 2011 (r225336) @@ -7,6 +7,7 @@ #undef RE_DUP_MAX #include #include +#include #define TRE_WCHAR 1 #define TRE_MULTIBYTE 1 Modified: user/gabor/grep/trunk/regex/tre-fastmatch.c ============================================================================== --- user/gabor/grep/trunk/regex/tre-fastmatch.c Fri Sep 2 16:46:42 2011 (r225335) +++ user/gabor/grep/trunk/regex/tre-fastmatch.c Fri Sep 2 16:50:24 2011 (r225336) @@ -206,14 +206,14 @@ static int fastcmp(const void *, const v fg->qsBc[i] = fg->len - fg->hasdot; \ for (int i = fg->hasdot + 1; i < fg->len; i++) \ { \ - fg->qsBc[(unsigned)fg->pattern[i]] = fg->len - i; \ + fg->qsBc[fg->pattern[i]] = fg->len - i; \ DPRINT(("BC shift for char %c is %d\n", fg->pattern[i], \ fg->len - i)); \ if (fg->icase) \ { \ char c = islower(fg->pattern[i]) ? toupper(fg->pattern[i]) \ : tolower(fg->pattern[i]); \ - fg->qsBc[(unsigned)c] = fg->len - i; \ + fg->qsBc[c] = fg->len - i; \ DPRINT(("BC shift for char %c is %d\n", c, fg->len - i)); \ } \ } @@ -397,12 +397,16 @@ static int fastcmp(const void *, const v fg->matchall = true; \ fg->pattern = ""; \ fg->wpattern = TRE_CHAR(""); \ + DPRINT(("Matching every input\n")); \ return REG_OK; \ } \ \ /* Cannot handle REG_ICASE with MB string */ \ if (fg->icase && (TRE_MB_CUR_MAX > 1)) \ - return REG_BADPAT; \ + { \ + DPRINT(("Cannot use fast matcher for MBS with REG_ICASE\n")); \ + return REG_BADPAT; \ + } /* * Returns: REG_OK on success, error code otherwise @@ -424,8 +428,8 @@ tre_compile_literal(fastmatch_t *fg, con SAVE_PATTERN(pat, n, fg->pattern, fg->len); #endif - DPRINT(("tre_compile_literal: pattern: %s, icase: %c, word: %c, " - "newline %c\n", fg->pattern, fg->icase ? 'y' : 'n', + DPRINT(("tre_compile_literal: pattern: %s, len %u, icase: %c, word: %c, " + "newline %c\n", fg->pattern, fg->len, fg->icase ? 'y' : 'n', fg->word ? 'y' : 'n', fg->newline ? 'y' : 'n')); FILL_QSBC; @@ -496,7 +500,7 @@ tre_compile_fast(fastmatch_t *fg, const switch (pat[i]) { case TRE_CHAR('.'): - fg->hasdot = true; + fg->hasdot = i; STORE_CHAR; break; case TRE_CHAR('$'): @@ -606,8 +610,8 @@ badpat: xfree(tmp); - DPRINT(("tre_compile_fast: pattern: %s, bol %c, eol %c, " - "icase: %c, word: %c, newline %c\n", fg->pattern, + DPRINT(("tre_compile_fast: pattern: %s, len %u, bol %c, eol %c, " + "icase: %c, word: %c, newline %c\n", fg->pattern, fg->len, fg->bol ? 'y' : 'n', fg->eol ? 'y' : 'n', fg->icase ? 'y' : 'n', fg->word ? 'y' : 'n', fg->newline ? 'y' : 'n')); From owner-svn-src-user@FreeBSD.ORG Fri Sep 2 17:53:38 2011 Return-Path: Delivered-To: svn-src-user@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9271C106564A; Fri, 2 Sep 2011 17:53:38 +0000 (UTC) (envelope-from ache@vniz.net) Received: from vniz.net (vniz.net [194.87.13.69]) by mx1.freebsd.org (Postfix) with ESMTP id 14DA48FC19; Fri, 2 Sep 2011 17:53:37 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by vniz.net (8.14.5/8.14.5) with ESMTP id p82HravN028058; Fri, 2 Sep 2011 21:53:36 +0400 (MSK) (envelope-from ache@vniz.net) Received: (from ache@localhost) by localhost (8.14.5/8.14.5/Submit) id p82HranI028057; Fri, 2 Sep 2011 21:53:36 +0400 (MSK) (envelope-from ache) Date: Fri, 2 Sep 2011 21:53:35 +0400 From: Andrey Chernov To: Gabor Kovesdan Message-ID: <20110902175335.GA27989@vniz.net> Mail-Followup-To: Andrey Chernov , Gabor Kovesdan , src-committers@FreeBSD.ORG, svn-src-user@FreeBSD.ORG References: <201109021650.p82GoOtJ007597@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201109021650.p82GoOtJ007597@svn.freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: src-committers@FreeBSD.ORG, svn-src-user@FreeBSD.ORG Subject: Re: svn commit: r225336 - user/gabor/grep/trunk/regex X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Sep 2011 17:53:38 -0000 On Fri, Sep 02, 2011 at 04:50:24PM +0000, Gabor Kovesdan wrote: > - Do not cast to unsigned char because it can cause a segfault > - fg->qsBc[(unsigned)fg->pattern[i]] = fg->len - i; \ > + fg->qsBc[fg->pattern[i]] = fg->len - i; \ > - fg->qsBc[(unsigned)c] = fg->len - i; \ > + fg->qsBc[c] = fg->len - i; \ I see there was cast to (unsigned) not to (unsigned char). They works in very different ways. To be safe: never cast char to (unsigned), only to (unsigned char). If 8bit is set in the character, i.e. it is negative, cast to (unsigned) provides very big values because it promotes to (int) first and then makes (unsigned) from that (int). -- http://ache.vniz.net/ From owner-svn-src-user@FreeBSD.ORG Fri Sep 2 18:18:24 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9F03A1065672; Fri, 2 Sep 2011 18:18:24 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8DBD28FC08; Fri, 2 Sep 2011 18:18:24 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p82IIOlv010726; Fri, 2 Sep 2011 18:18:24 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p82IIO73010722; Fri, 2 Sep 2011 18:18:24 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201109021818.p82IIO73010722@svn.freebsd.org> From: Gabor Kovesdan Date: Fri, 2 Sep 2011 18:18:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225347 - user/gabor/tre-integration/contrib/tre/lib X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Sep 2011 18:18:24 -0000 Author: gabor Date: Fri Sep 2 18:18:24 2011 New Revision: 225347 URL: http://svn.freebsd.org/changeset/base/225347 Log: - Merge some improvements and fixes from grep - Fix a cast [1] Submitted by: ache [1] Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c user/gabor/tre-integration/contrib/tre/lib/regcomp.c user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Modified: user/gabor/tre-integration/contrib/tre/lib/fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Fri Sep 2 18:13:46 2011 (r225346) +++ user/gabor/tre-integration/contrib/tre/lib/fastmatch.c Fri Sep 2 18:18:24 2011 (r225347) @@ -1,3 +1,5 @@ +/* $FreeBSD$ */ + /*- * Copyright (C) 2011 Gabor Kovesdan * All rights reserved. @@ -27,7 +29,9 @@ #ifdef HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ +#include #include +#include #include #include "tre-fastmatch.h" @@ -36,67 +40,72 @@ /* XXX: avoid duplication */ #define CONV_PAT \ - int ret; \ - tre_char_t *wregex; \ - size_t wlen; \ - \ - wregex = xmalloc(sizeof(tre_char_t) * (n + 1)); \ - if (wregex == NULL) \ - return REG_ESPACE; \ - \ - if (TRE_MB_CUR_MAX == 1) \ - { \ - unsigned int i; \ - const unsigned char *str = (const unsigned char *)regex; \ - tre_char_t *wstr = wregex; \ - \ - for (i = 0; i < n; i++) \ - *(wstr++) = *(str++); \ - wlen = n; \ - } \ - else \ - { \ - int consumed; \ - tre_char_t *wcptr = wregex; \ - mbstate_t state; \ - memset(&state, '\0', sizeof(state)); \ - while (n > 0) \ - { \ - consumed = tre_mbrtowc(wcptr, regex, n, &state); \ + { \ + wregex = xmalloc(sizeof(tre_char_t) * (n + 1)); \ + if (wregex == NULL) \ + return REG_ESPACE; \ \ - switch (consumed) \ - { \ - case 0: \ - if (*regex == '\0') \ - consumed = 1; \ - else \ - { \ - xfree(wregex); \ - return REG_BADPAT; \ - } \ - break; \ - case -1: \ - DPRINT(("mbrtowc: error %d: %s.\n", errno, \ - strerror(errno))); \ - xfree(wregex); \ - return REG_BADPAT; \ - case -2: \ - consumed = n; \ - break; \ - } \ - regex += consumed; \ - n -= consumed; \ - wcptr++; \ - } \ - wlen = wcptr - wregex; \ - } \ + if (TRE_MB_CUR_MAX == 1) \ + { \ + unsigned int i; \ + const unsigned char *str = (const unsigned char *)regex; \ + tre_char_t *wstr = wregex; \ + \ + for (i = 0; i < n; i++) \ + *(wstr++) = *(str++); \ + wlen = n; \ + } \ + else \ + { \ + int consumed; \ + tre_char_t *wcptr = wregex; \ + mbstate_t state; \ + memset(&state, '\0', sizeof(state)); \ + while (n > 0) \ + { \ + consumed = tre_mbrtowc(wcptr, regex, n, &state); \ + \ + switch (consumed) \ + { \ + case 0: \ + if (*regex == '\0') \ + consumed = 1; \ + else \ + { \ + xfree(wregex); \ + return REG_BADPAT; \ + } \ + break; \ + case -1: \ + DPRINT(("mbrtowc: error %d: %s.\n", errno, \ + strerror(errno))); \ + xfree(wregex); \ + return REG_BADPAT; \ + case -2: \ + consumed = n; \ + break; \ + } \ + regex += consumed; \ + n -= consumed; \ + wcptr++; \ + } \ + wlen = wcptr - wregex; \ + } \ \ - wregex[wlen] = L'\0'; + wregex[wlen] = L'\0'; \ + } int tre_fixncomp(fastmatch_t *preg, const char *regex, size_t n, int cflags) { - CONV_PAT; + int ret; + tre_char_t *wregex; + size_t wlen; + + if (n != 0) + CONV_PAT + else + return tre_compile_literal(preg, NULL, 0, cflags); ret = tre_compile_literal(preg, wregex, wlen, cflags); xfree(wregex); @@ -107,7 +116,14 @@ tre_fixncomp(fastmatch_t *preg, const ch int tre_fastncomp(fastmatch_t *preg, const char *regex, size_t n, int cflags) { - CONV_PAT; + int ret; + tre_char_t *wregex; + size_t wlen; + + if (n != 0) + CONV_PAT + else + return tre_compile_literal(preg, NULL, 0, cflags); ret = (cflags & REG_LITERAL) ? tre_compile_literal(preg, wregex, wlen, cflags) : @@ -121,34 +137,13 @@ tre_fastncomp(fastmatch_t *preg, const c int tre_fixcomp(fastmatch_t *preg, const char *regex, int cflags) { - size_t len; - - if (cflags & REG_PEND) - { - if (preg->re_endp >= regex) - len = preg->re_endp - regex - else - len = preg ? strlen(regex) : 0; - return tre_fixncomp(preg, regex, len, cflags); - } - else - return tre_fixncomp(preg, regex, regex ? strlen(regex) : 0, cflags); + return tre_fixncomp(preg, regex, regex ? strlen(regex) : 0, cflags); } int tre_fastcomp(fastmatch_t *preg, const char *regex, int cflags) { - size_t len; - - if (cflags & REG_PEND) - { - len = (preg->re_endp >= regex) - ? preg->re_endp - regex - : 0; - return tre_fastncomp(preg, regex, len ? strlen(regex) : 0, cflags); - } - else - return tre_fastncomp(preg, regex, regex ? strlen(regex) : 0, cflags); + return tre_fastncomp(preg, regex, regex ? strlen(regex) : 0, cflags); } int Modified: user/gabor/tre-integration/contrib/tre/lib/regcomp.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/regcomp.c Fri Sep 2 18:13:46 2011 (r225346) +++ user/gabor/tre-integration/contrib/tre/lib/regcomp.c Fri Sep 2 18:18:24 2011 (r225347) @@ -117,11 +117,10 @@ tre_regcomp(regex_t *preg, const char *r if (cflags & REG_PEND) { if (preg->re_endp >= regex) - len = preg->re_endp - regex + len = preg->re_endp - regex; else len = regex ? strlen(regex) : 0; - ) - return tre_regncomp(preg, regex, len, cflags); + return tre_regncomp(preg, regex, len, cflags); } else return tre_regncomp(preg, regex, regex ? strlen(regex) : 0, cflags); Modified: user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Fri Sep 2 18:13:46 2011 (r225346) +++ user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Fri Sep 2 18:18:24 2011 (r225347) @@ -208,14 +208,14 @@ static int fastcmp(const void *, const v fg->qsBc[i] = fg->len - fg->hasdot; \ for (int i = fg->hasdot + 1; i < fg->len; i++) \ { \ - fg->qsBc[(unsigned)fg->pattern[i]] = fg->len - i; \ + fg->qsBc[(unsigned char)fg->pattern[i]] = fg->len - i; \ DPRINT(("BC shift for char %c is %d\n", fg->pattern[i], \ fg->len - i)); \ if (fg->icase) \ { \ char c = islower(fg->pattern[i]) ? toupper(fg->pattern[i]) \ : tolower(fg->pattern[i]); \ - fg->qsBc[(unsigned)c] = fg->len - i; \ + fg->qsBc[(unsigned char)c] = fg->len - i; \ DPRINT(("BC shift for char %c is %d\n", c, fg->len - i)); \ } \ } @@ -370,13 +370,18 @@ static int fastcmp(const void *, const v * Copies the pattern pat having lenght n to p and stores * the size in l. */ -#define SAVE_PATTERN(p, l) \ - l = (n == 0) ? tre_strlen(pat) : n; \ - p = xmalloc((l + 1) * sizeof(tre_char_t)); \ - if (p == NULL) \ - return REG_ESPACE; \ - memcpy(p, pat, l * sizeof(tre_char_t)); \ - p[l] = TRE_CHAR('\0'); +#define SAVE_PATTERN(src, srclen, dst, dstlen) \ + dstlen = srclen; \ + if (dstlen == 0) \ + dst = TRE_CHAR(""); \ + else \ + { \ + dst = xmalloc((dstlen + 1) * sizeof(tre_char_t)); \ + if (dst == NULL) \ + return REG_ESPACE; \ + memcpy(dst, src, dstlen * sizeof(tre_char_t)); \ + dst[dstlen] = TRE_CHAR('\0'); \ + } /* * Initializes pattern compiling. @@ -392,12 +397,18 @@ static int fastcmp(const void *, const v if (n == 0) \ { \ fg->matchall = true; \ + fg->pattern = ""; \ + fg->wpattern = TRE_CHAR(""); \ + DPRINT(("Matching every input\n")); \ return REG_OK; \ - } + } \ \ /* Cannot handle REG_ICASE with MB string */ \ if (fg->icase && (TRE_MB_CUR_MAX > 1)) \ - return REG_BADPAT; \ + { \ + DPRINT(("Cannot use fast matcher for MBS with REG_ICASE\n")); \ + return REG_BADPAT; \ + } /* * Returns: REG_OK on success, error code otherwise @@ -413,14 +424,14 @@ tre_compile_literal(fastmatch_t *fg, con return REG_BADPAT; #ifdef TRE_WCHAR - SAVE_PATTERN(fg->wpattern, fg->wlen); + SAVE_PATTERN(pat, n, fg->wpattern, fg->wlen); STORE_MBS_PAT; #else - SAVE_PATTERN(fg->pattern, fg->len); + SAVE_PATTERN(pat, n, fg->pattern, fg->len); #endif - DPRINT(("tre_compile_literal: pattern: %s, icase: %c, word: %c, " - "newline %c\n", fg->pattern, fg->icase ? 'y' : 'n', + DPRINT(("tre_compile_literal: pattern: %s, len %u, icase: %c, word: %c, " + "newline %c\n", fg->pattern, fg->len, fg->icase ? 'y' : 'n', fg->word ? 'y' : 'n', fg->newline ? 'y' : 'n')); FILL_QSBC; @@ -440,14 +451,11 @@ int tre_compile_fast(fastmatch_t *fg, const tre_char_t *pat, size_t n, int cflags) { - INIT_COMP; + tre_char_t *tmp; + size_t pos = 0; + bool escaped = false; - /* Remove end-of-line character ('$'). */ - if ((n > 0) && (pat[n - 1] == TRE_CHAR('$'))) - { - fg->eol = true; - n--; - } + INIT_COMP; /* Remove beginning-of-line character ('^'). */ if (pat[0] == TRE_CHAR('^')) @@ -472,36 +480,140 @@ tre_compile_fast(fastmatch_t *fg, const if (fg->word && (TRE_MB_CUR_MAX > 1)) return REG_BADPAT; - /* Look for ways to cheat...er...avoid the full regex engine. */ - for (unsigned int i = 0; i < n; i++) + tmp = xmalloc((n + 1) * sizeof(tre_char_t)); + if (tmp == NULL) + return REG_ESPACE; + +#define STORE_CHAR \ + do \ + { \ + tmp[pos++] = pat[i]; \ + escaped = false; \ + continue; \ + } while (0) + + /* + * Used for heuristic, only beginning ^, trailing $ and . are treated + * as special. + */ + if (cflags & _REG_HEUR) { - /* Can still cheat? */ - if (!(cflags & _REG_HEUR) && - ((tre_isalnum(pat[i])) || tre_isspace(pat[i]) || - (pat[i] == TRE_CHAR('_')) || (pat[i] == TRE_CHAR(',')) || - (pat[i] == TRE_CHAR('=')) || (pat[i] == TRE_CHAR('-')) || - (pat[i] == TRE_CHAR(':')) || (pat[i] == TRE_CHAR('/')))) + for (int i = 0; i < n; i++) + switch (pat[i]) + { + case TRE_CHAR('.'): + fg->hasdot = i; + STORE_CHAR; + break; + case TRE_CHAR('$'): + if (i == n - 1) + fg->eol = true; + else + STORE_CHAR; + break; + default: + STORE_CHAR; + } + } + else + for (int i = 0; i < n; i++) + { + switch (pat[i]) + { + case TRE_CHAR('\\'): + if (escaped) + STORE_CHAR; + else + escaped = true; + break; + case TRE_CHAR('['): + if (escaped) + STORE_CHAR; + else + goto badpat; + break; + case TRE_CHAR('*'): + if (escaped || (!(cflags & REG_EXTENDED) && (i == 0))) + STORE_CHAR; + else + goto badpat; + break; + case TRE_CHAR('+'): + case TRE_CHAR('?'): + if ((cflags & REG_EXTENDED) && (i == 0)) + continue; + else if ((cflags & REG_EXTENDED) ^ !escaped) + STORE_CHAR; + else + goto badpat; + case TRE_CHAR('.'): + if (escaped) + goto badpat; + else + { + fg->hasdot = true; + STORE_CHAR; + } + break; + case TRE_CHAR('^'): + STORE_CHAR; + break; + case TRE_CHAR('$'): + if (!escaped && (i == n - 1)) + fg->eol = true; + else + STORE_CHAR; + break; + case TRE_CHAR('('): + if ((cflags & REG_EXTENDED) ^ escaped) + goto badpat; + else + STORE_CHAR; + break; + case TRE_CHAR('{'): + if (escaped && (i == 0)) + STORE_CHAR; + else if (!(cflags & REG_EXTENDED) && (i == 0)) + STORE_CHAR; + else if ((cflags & REG_EXTENDED) && (i == 0)) + continue; + else + goto badpat; + break; + case TRE_CHAR('|'): + if ((cflags & REG_EXTENDED) ^ (!escaped)) + goto badpat; + else + STORE_CHAR; + break; + default: + if (escaped) + goto badpat; + else + STORE_CHAR; + } continue; - else if (pat[i] == TRE_CHAR('.')) - fg->hasdot = i; - else +badpat: + xfree(tmp); return REG_BADPAT; - } + } /* - * pat has been adjusted earlier to not include '^', '$' or - * the word match character classes at the beginning and ending - * of the string respectively. + * The pattern has been processed and copied to tmp as a literal string + * with escapes, anchors (^$) and the word boundary match character + * classes stripped out. */ #ifdef TRE_WCHAR - SAVE_PATTERN(fg->wpattern, fg->wlen); + SAVE_PATTERN(tmp, pos, fg->wpattern, fg->wlen); STORE_MBS_PAT; #else - SAVE_PATTERN(fg->pattern, fg->len); + SAVE_PATTERN(tmp, pos, fg->pattern, fg->len); #endif - DPRINT(("tre_compile_fast: pattern: %s, bol %c, eol %c, " - "icase: %c, word: %c, newline %c\n", fg->pattern, + xfree(tmp); + + DPRINT(("tre_compile_fast: pattern: %s, len %u, bol %c, eol %c, " + "icase: %c, word: %c, newline %c\n", fg->pattern, fg->len, fg->bol ? 'y' : 'n', fg->eol ? 'y' : 'n', fg->icase ? 'y' : 'n', fg->word ? 'y' : 'n', fg->newline ? 'y' : 'n')); @@ -593,7 +705,7 @@ tre_match_fast(const fastmatch_t *fg, co const tre_char_t *str_wide = data; /* Calculate length if unspecified. */ - if (len == (unsigned)-1) + if (len == (size_t)-1) switch (type) { case STR_WIDE: From owner-svn-src-user@FreeBSD.ORG Fri Sep 2 18:48:44 2011 Return-Path: Delivered-To: svn-src-user@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D4B851065672; Fri, 2 Sep 2011 18:48:44 +0000 (UTC) (envelope-from ache@vniz.net) Received: from vniz.net (vniz.net [194.87.13.69]) by mx1.freebsd.org (Postfix) with ESMTP id 549F48FC08; Fri, 2 Sep 2011 18:48:43 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by vniz.net (8.14.5/8.14.5) with ESMTP id p82ImgOi028472; Fri, 2 Sep 2011 22:48:42 +0400 (MSK) (envelope-from ache@vniz.net) Received: (from ache@localhost) by localhost (8.14.5/8.14.5/Submit) id p82Img5m028471; Fri, 2 Sep 2011 22:48:42 +0400 (MSK) (envelope-from ache) Date: Fri, 2 Sep 2011 22:48:42 +0400 From: Andrey Chernov To: Gabor Kovesdan Message-ID: <20110902184842.GA28351@vniz.net> Mail-Followup-To: Andrey Chernov , Gabor Kovesdan , src-committers@FreeBSD.ORG, svn-src-user@FreeBSD.ORG References: <201109021818.p82IIO73010722@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201109021818.p82IIO73010722@svn.freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: src-committers@FreeBSD.ORG, svn-src-user@FreeBSD.ORG Subject: Re: svn commit: r225347 - user/gabor/tre-integration/contrib/tre/lib X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Sep 2011 18:48:44 -0000 On Fri, Sep 02, 2011 at 06:18:24PM +0000, Gabor Kovesdan wrote: > { \ > char c = islower(fg->pattern[i]) ? toupper(fg->pattern[i]) \ > : tolower(fg->pattern[i]); \ > - fg->qsBc[(unsigned)c] = fg->len - i; \ > + fg->qsBc[(unsigned char)c] = fg->len - i; \ It looks like there should be char c = islower((unsigned char)fg->pattern[i]) ? \ toupper((unsigned char)fg->pattern[i]) : \ tolower((unsigned char)fg->pattern[i]); \ I don't see whole code, it depends on what type fg->pattern[i] have. Due to their bad design ctype macros can't be called directly on signed (i.e. default) char type, unless its value is known to be 7bit. BTW, I don't understand the intention of that expression. You turn lower to upper and upper to lower. Ignore case mode converts all to single case instead. -- http://ache.vniz.net/ From owner-svn-src-user@FreeBSD.ORG Fri Sep 2 20:34:22 2011 Return-Path: Delivered-To: svn-src-user@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0038F1065672; Fri, 2 Sep 2011 20:34:21 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from server.mypc.hu (server.mypc.hu [87.229.73.95]) by mx1.freebsd.org (Postfix) with ESMTP id AA25F8FC28; Fri, 2 Sep 2011 20:34:21 +0000 (UTC) Received: from server.mypc.hu (localhost [127.0.0.1]) by server.mypc.hu (Postfix) with ESMTP id 14B6414E5EEC; Fri, 2 Sep 2011 22:34:19 +0200 (CEST) X-Virus-Scanned: amavisd-new at server.mypc.hu Received: from server.mypc.hu ([127.0.0.1]) by server.mypc.hu (server.mypc.hu [127.0.0.1]) (amavisd-new, port 10024) with LMTP id rdaPy8s6qPtA; Fri, 2 Sep 2011 22:34:16 +0200 (CEST) Received: from [192.168.1.106] (catv-80-98-232-12.catv.broadband.hu [80.98.232.12]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by server.mypc.hu (Postfix) with ESMTPSA id C707E14DB679; Fri, 2 Sep 2011 22:34:16 +0200 (CEST) Message-ID: <4E613DC4.9010809@FreeBSD.org> Date: Fri, 02 Sep 2011 22:34:12 +0200 From: Gabor Kovesdan User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:9.0a1) Gecko/20110822 Thunderbird/9.0a1 MIME-Version: 1.0 To: Andrey Chernov , src-committers@FreeBSD.ORG, svn-src-user@FreeBSD.ORG References: <201109021818.p82IIO73010722@svn.freebsd.org> <20110902184842.GA28351@vniz.net> In-Reply-To: <20110902184842.GA28351@vniz.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Subject: Re: svn commit: r225347 - user/gabor/tre-integration/contrib/tre/lib X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Sep 2011 20:34:22 -0000 On 2011.09.02. 20:48, Andrey Chernov wrote: > On Fri, Sep 02, 2011 at 06:18:24PM +0000, Gabor Kovesdan wrote: >> { \ >> char c = islower(fg->pattern[i]) ? toupper(fg->pattern[i]) \ >> : tolower(fg->pattern[i]); \ >> - fg->qsBc[(unsigned)c] = fg->len - i; \ >> + fg->qsBc[(unsigned char)c] = fg->len - i; \ > > It looks like there should be > > char c = islower((unsigned char)fg->pattern[i]) ? \ > toupper((unsigned char)fg->pattern[i]) : \ > tolower((unsigned char)fg->pattern[i]); \ > > I don't see whole code, it depends on what type fg->pattern[i] have. It's a char. > > Due to their bad design ctype macros can't be called directly on signed > (i.e. default) char type, unless its value is known to be 7bit. Yes, thanks, a cast is missing here, too. > BTW, I don't understand the intention of that expression. > You turn lower to upper and upper to lower. Ignore case mode converts all > to single case instead. It's about the quick search algorithm. Instead of converting _everything_ to single case I store shift values for both cases in the pattern compilation phase, which is executed only once and then the match phase, which may be executed several times, needs to perform much less operations and only convert a few characters. Gabor From owner-svn-src-user@FreeBSD.ORG Fri Sep 2 23:51:55 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F06E51065674; Fri, 2 Sep 2011 23:51:55 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E000B8FC1A; Fri, 2 Sep 2011 23:51:55 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p82Npt27020917; Fri, 2 Sep 2011 23:51:55 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p82Npt2P020915; Fri, 2 Sep 2011 23:51:55 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201109022351.p82Npt2P020915@svn.freebsd.org> From: Gabor Kovesdan Date: Fri, 2 Sep 2011 23:51:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225355 - user/gabor/tre-integration/contrib/tre/lib X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Sep 2011 23:51:56 -0000 Author: gabor Date: Fri Sep 2 23:51:55 2011 New Revision: 225355 URL: http://svn.freebsd.org/changeset/base/225355 Log: - Fix two more casts Submitted by: ache Modified: user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Modified: user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Fri Sep 2 20:35:22 2011 (r225354) +++ user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Fri Sep 2 23:51:55 2011 (r225355) @@ -213,8 +213,9 @@ static int fastcmp(const void *, const v fg->len - i)); \ if (fg->icase) \ { \ - char c = islower(fg->pattern[i]) ? toupper(fg->pattern[i]) \ - : tolower(fg->pattern[i]); \ + char c = islower((unsigned char)fg->pattern[i]) ? \ + toupper((unsigned char)fg->pattern[i]) : \ + tolower((unsigned char)fg->pattern[i]); \ fg->qsBc[(unsigned char)c] = fg->len - i; \ DPRINT(("BC shift for char %c is %d\n", c, fg->len - i)); \ } \ From owner-svn-src-user@FreeBSD.ORG Sat Sep 3 00:47:28 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B1D951065672; Sat, 3 Sep 2011 00:47:28 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 96C7A8FC15; Sat, 3 Sep 2011 00:47:28 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p830lSZA022639; Sat, 3 Sep 2011 00:47:28 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p830lSxw022637; Sat, 3 Sep 2011 00:47:28 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201109030047.p830lSxw022637@svn.freebsd.org> From: Gabor Kovesdan Date: Sat, 3 Sep 2011 00:47:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225357 - user/gabor/tre-integration/contrib/tre/lib X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Sep 2011 00:47:28 -0000 Author: gabor Date: Sat Sep 3 00:47:28 2011 New Revision: 225357 URL: http://svn.freebsd.org/changeset/base/225357 Log: - Add support for escaped dot Modified: user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Modified: user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Sat Sep 3 00:28:53 2011 (r225356) +++ user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Sat Sep 3 00:47:28 2011 (r225357) @@ -44,7 +44,7 @@ #include "tre-internal.h" #include "xmalloc.h" -static int fastcmp(const void *, const void *, size_t, +static int fastcmp(const void *, const bool *, const void *, size_t, tre_str_type_t, bool, bool); #define FAIL_COMP(errcode) \ @@ -104,11 +104,13 @@ static int fastcmp(const void *, const v switch (type) \ { \ case STR_WIDE: \ - mismatch = fastcmp(fg->wpattern, startptr, fg->wlen, type, \ + mismatch = fastcmp(fg->wpattern, fg->wescmap, startptr, \ + fg->wlen, type, \ fg->icase, fg->newline); \ break; \ default: \ - mismatch = fastcmp(fg->pattern, startptr, fg->len, type, \ + mismatch = fastcmp(fg->pattern, fg->escmap, startptr, \ + fg->len, type, \ fg->icase, fg->newline); \ } \ @@ -455,6 +457,7 @@ tre_compile_fast(fastmatch_t *fg, const tre_char_t *tmp; size_t pos = 0; bool escaped = false; + bool *_escmap = NULL; INIT_COMP; @@ -549,10 +552,20 @@ tre_compile_fast(fastmatch_t *fg, const goto badpat; case TRE_CHAR('.'): if (escaped) - goto badpat; + { + if (!_escmap) + _escmap = xmalloc(n * sizeof(bool)); + if (!_escmap) + { + xfree(tmp); + return REG_ESPACE; + } + _escmap[i] = true; + STORE_CHAR; + } else { - fg->hasdot = true; + fg->hasdot = i; STORE_CHAR; } break; @@ -606,9 +619,33 @@ badpat: */ #ifdef TRE_WCHAR SAVE_PATTERN(tmp, pos, fg->wpattern, fg->wlen); + fg->wescmap = _escmap; STORE_MBS_PAT; + if (fg->wescmap != NULL) + { + bool escaped = false; + + fg->escmap = xmalloc(fg->len * sizeof(bool)); + if (!fg->escmap) + { + tre_free_fast(fg); + return REG_ESPACE; + } + + for (int i = 0; i < fg->len; i++) + if (fg->pattern[i] == '\\') + escaped = ! escaped; + else if (fg->pattern[i] == '.' && escaped) + { + fg->escmap[i] = true; + escaped = false; + } + else + escaped = false; + } #else SAVE_PATTERN(tmp, pos, fg->pattern, fg->len); + fg->escmap = _escmap; #endif xfree(tmp); @@ -825,10 +862,14 @@ tre_free_fast(fastmatch_t *fg) hashtable_free(fg->qsBc_table); if (!fg->hasdot) xfree(fg->bmGs); + if (fg->wescmap) + xfree(fg->wescmap); xfree(fg->wpattern); #endif if (!fg->hasdot) xfree(fg->sbmGs); + if (fg->escmap) + xfree(fg->escmap); xfree(fg->pattern); } @@ -838,7 +879,7 @@ tre_free_fast(fastmatch_t *fg) * REG_OK on success */ static inline int -fastcmp(const void *pat, const void *data, size_t len, +fastcmp(const void *pat, const bool *escmap, const void *data, size_t len, tre_str_type_t type, bool icase, bool newline) { const char *str_byte = data; @@ -854,7 +895,7 @@ fastcmp(const void *pat, const void *dat case STR_WIDE: /* Check dot */ - if (pat_wide[i] == TRE_CHAR('.') && + if (pat_wide[i] == TRE_CHAR('.') && (!escmap || !escmap[i]) && (!newline || (str_wide[i] != TRE_CHAR('\n')))) continue; @@ -865,7 +906,7 @@ fastcmp(const void *pat, const void *dat break; default: /* Check dot */ - if (pat_byte[i] == '.' && + if (pat_byte[i] == '.' && (!escmap || !escmap[i]) && (!newline || (str_byte[i] != '\n'))) continue; From owner-svn-src-user@FreeBSD.ORG Sat Sep 3 08:03:25 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BF78E1065674; Sat, 3 Sep 2011 08:03:25 +0000 (UTC) (envelope-from jchandra@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AED1F8FC14; Sat, 3 Sep 2011 08:03:25 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p8383Peb036056; Sat, 3 Sep 2011 08:03:25 GMT (envelope-from jchandra@svn.freebsd.org) Received: (from jchandra@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p8383Pbr036048; Sat, 3 Sep 2011 08:03:25 GMT (envelope-from jchandra@svn.freebsd.org) Message-Id: <201109030803.p8383Pbr036048@svn.freebsd.org> From: "Jayachandran C." Date: Sat, 3 Sep 2011 08:03:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225363 - in user/jchandra/mips-xlp-support/sys/mips: conf nlm nlm/hal X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Sep 2011 08:03:25 -0000 Author: jchandra Date: Sat Sep 3 08:03:25 2011 New Revision: 225363 URL: http://svn.freebsd.org/changeset/base/225363 Log: HAL updates Update hardware access register defs and functions to be more in sync with other platforms Deleted: user/jchandra/mips-xlp-support/sys/mips/nlm/hal/cop0.h Modified: user/jchandra/mips-xlp-support/sys/mips/conf/XLP64 user/jchandra/mips-xlp-support/sys/mips/nlm/cms.c user/jchandra/mips-xlp-support/sys/mips/nlm/hal/bridge.h user/jchandra/mips-xlp-support/sys/mips/nlm/hal/cop2.h user/jchandra/mips-xlp-support/sys/mips/nlm/hal/cpucontrol.h user/jchandra/mips-xlp-support/sys/mips/nlm/hal/fmn.c user/jchandra/mips-xlp-support/sys/mips/nlm/hal/fmn.h user/jchandra/mips-xlp-support/sys/mips/nlm/hal/iomap.h user/jchandra/mips-xlp-support/sys/mips/nlm/hal/mips-extns.h user/jchandra/mips-xlp-support/sys/mips/nlm/hal/mmio.h user/jchandra/mips-xlp-support/sys/mips/nlm/hal/mmu.h user/jchandra/mips-xlp-support/sys/mips/nlm/hal/pcibus.h user/jchandra/mips-xlp-support/sys/mips/nlm/hal/pic.h user/jchandra/mips-xlp-support/sys/mips/nlm/hal/sys.h user/jchandra/mips-xlp-support/sys/mips/nlm/hal/uart.h user/jchandra/mips-xlp-support/sys/mips/nlm/hal/usb.h user/jchandra/mips-xlp-support/sys/mips/nlm/intr_machdep.c user/jchandra/mips-xlp-support/sys/mips/nlm/mpreset.S user/jchandra/mips-xlp-support/sys/mips/nlm/uart_bus_xlp_iodi.c user/jchandra/mips-xlp-support/sys/mips/nlm/uart_cpu_xlp.c user/jchandra/mips-xlp-support/sys/mips/nlm/uart_pci_xlp.c user/jchandra/mips-xlp-support/sys/mips/nlm/usb_init.c user/jchandra/mips-xlp-support/sys/mips/nlm/xlp.h user/jchandra/mips-xlp-support/sys/mips/nlm/xlp_machdep.c user/jchandra/mips-xlp-support/sys/mips/nlm/xlp_pci.c Modified: user/jchandra/mips-xlp-support/sys/mips/conf/XLP64 ============================================================================== --- user/jchandra/mips-xlp-support/sys/mips/conf/XLP64 Sat Sep 3 07:15:14 2011 (r225362) +++ user/jchandra/mips-xlp-support/sys/mips/conf/XLP64 Sat Sep 3 08:03:25 2011 (r225363) @@ -77,7 +77,6 @@ options ALT_BREAK_TO_DEBUGGER #options KTR # ktr(4) and ktrdump(8) support #options KTR_COMPILE=(KTR_LOCK|KTR_PROC|KTR_INTR|KTR_CALLOUT|KTR_UMA|KTR_SYSC) #options KTR_ENTRIES=131072 -#options LOCK_DEBUG #options LOCK_PROFILING @@ -100,6 +99,6 @@ device msk device da device scbus -device usb -device ehci -device umass +#device usb +#device ehci +#device umass Modified: user/jchandra/mips-xlp-support/sys/mips/nlm/cms.c ============================================================================== --- user/jchandra/mips-xlp-support/sys/mips/nlm/cms.c Sat Sep 3 07:15:14 2011 (r225362) +++ user/jchandra/mips-xlp-support/sys/mips/nlm/cms.c Sat Sep 3 08:03:25 2011 (r225363) @@ -58,7 +58,7 @@ __FBSDID("$FreeBSD: head/sys/mips/rmi/fm #include #include #include -#include +#include #include #include #include @@ -108,7 +108,7 @@ xlp_msgring_config(void) int i; /* TODO: Add other nodes */ - xlp_cms_base = nlm_regbase_cms(0); + xlp_cms_base = nlm_get_cms_regbase(0); mtx_init(&msgmap_lock, "msgring", NULL, MTX_SPIN); if (xlp_threads_per_core < xlp_msg_threads_per_core) @@ -210,7 +210,7 @@ xlp_msgring_cpu_init(uint32_t cpuid) { int queue,i; - queue = XLP_CMS_CPU_PUSHQ(0, ((cpuid >> 2) & 0x7), (cpuid & 0x3), 0); + queue = CMS_CPU_PUSHQ(0, ((cpuid >> 2) & 0x7), (cpuid & 0x3), 0); /* temp allocate 4 segments to each output queue */ nlm_cms_alloc_onchip_q(xlp_cms_base, queue, 4); /* Enable high watermark and non empty interrupt */ Modified: user/jchandra/mips-xlp-support/sys/mips/nlm/hal/bridge.h ============================================================================== --- user/jchandra/mips-xlp-support/sys/mips/nlm/hal/bridge.h Sat Sep 3 07:15:14 2011 (r225362) +++ user/jchandra/mips-xlp-support/sys/mips/nlm/hal/bridge.h Sat Sep 3 08:03:25 2011 (r225363) @@ -27,8 +27,8 @@ * * NETLOGIC_BSD */ -#ifndef __NLM_BRIDGE_H__ -#define __NLM_BRIDGE_H__ +#ifndef __NLM_HAL_BRIDGE_H__ +#define __NLM_HAL_BRIDGE_H__ /** * @file_name mio.h @@ -36,141 +36,147 @@ * @brief Basic definitions of XLP memory and io subsystem */ -/* BRIDGE specific registers */ -#define XLP_BRIDGE_MODE_REG 0x40 -#define XLP_BRIDGE_PCI_CFG_BASE_REG 0x41 -#define XLP_BRIDGE_PCI_CFG_LIMIT_REG 0x42 -#define XLP_BRIDGE_PCIE_CFG_BASE_REG 0x43 -#define XLP_BRIDGE_PCIE_CFG_LIMIT_REG 0x44 -#define XLP_BRIDGE_BUSNUM_BAR0_REG 0x45 -#define XLP_BRIDGE_BUSNUM_BAR1_REG 0x46 -#define XLP_BRIDGE_BUSNUM_BAR2_REG 0x47 -#define XLP_BRIDGE_BUSNUM_BAR3_REG 0x48 -#define XLP_BRIDGE_BUSNUM_BAR4_REG 0x49 -#define XLP_BRIDGE_BUSNUM_BAR5_REG 0x4a -#define XLP_BRIDGE_BUSNUM_BAR6_REG 0x4b -#define XLP_BRIDGE_FLASH_BAR0_REG 0x4c -#define XLP_BRIDGE_FLASH_BAR1_REG 0x4d -#define XLP_BRIDGE_FLASH_BAR2_REG 0x4e -#define XLP_BRIDGE_FLASH_BAR3_REG 0x4f -#define XLP_BRIDGE_FLASH_LIMIT0_REG 0x50 -#define XLP_BRIDGE_FLASH_LIMIT1_REG 0x51 -#define XLP_BRIDGE_FLASH_LIMIT2_REG 0x52 -#define XLP_BRIDGE_FLASH_LIMIT3_REG 0x53 - -#define XLP_BRIDGE_DRAM_BAR_REG(i) (0x54 + (i)) -#define XLP_BRIDGE_DRAM_BAR0_REG 0x54 -#define XLP_BRIDGE_DRAM_BAR1_REG 0x55 -#define XLP_BRIDGE_DRAM_BAR2_REG 0x56 -#define XLP_BRIDGE_DRAM_BAR3_REG 0x57 -#define XLP_BRIDGE_DRAM_BAR4_REG 0x58 -#define XLP_BRIDGE_DRAM_BAR5_REG 0x59 -#define XLP_BRIDGE_DRAM_BAR6_REG 0x5a -#define XLP_BRIDGE_DRAM_BAR7_REG 0x5b - -#define XLP_BRIDGE_DRAM_LIMIT_REG(i) (0x5c + (i)) -#define XLP_BRIDGE_DRAM_LIMIT0_REG 0x5c -#define XLP_BRIDGE_DRAM_LIMIT1_REG 0x5d -#define XLP_BRIDGE_DRAM_LIMIT2_REG 0x5e -#define XLP_BRIDGE_DRAM_LIMIT3_REG 0x5f -#define XLP_BRIDGE_DRAM_LIMIT4_REG 0x60 -#define XLP_BRIDGE_DRAM_LIMIT5_REG 0x61 -#define XLP_BRIDGE_DRAM_LIMIT6_REG 0x62 -#define XLP_BRIDGE_DRAM_LIMIT7_REG 0x63 - -#define XLP_BRIDGE_DRAM_NODE_TRANSLN0_REG 0x64 -#define XLP_BRIDGE_DRAM_NODE_TRANSLN1_REG 0x65 -#define XLP_BRIDGE_DRAM_NODE_TRANSLN2_REG 0x66 -#define XLP_BRIDGE_DRAM_NODE_TRANSLN3_REG 0x67 -#define XLP_BRIDGE_DRAM_NODE_TRANSLN4_REG 0x68 -#define XLP_BRIDGE_DRAM_NODE_TRANSLN5_REG 0x69 -#define XLP_BRIDGE_DRAM_NODE_TRANSLN6_REG 0x6a -#define XLP_BRIDGE_DRAM_NODE_TRANSLN7_REG 0x6b -#define XLP_BRIDGE_DRAM_CHNL_TRANSLN0_REG 0x6c -#define XLP_BRIDGE_DRAM_CHNL_TRANSLN1_REG 0x6d -#define XLP_BRIDGE_DRAM_CHNL_TRANSLN2_REG 0x6e -#define XLP_BRIDGE_DRAM_CHNL_TRANSLN3_REG 0x6f -#define XLP_BRIDGE_DRAM_CHNL_TRANSLN4_REG 0x70 -#define XLP_BRIDGE_DRAM_CHNL_TRANSLN5_REG 0x71 -#define XLP_BRIDGE_DRAM_CHNL_TRANSLN6_REG 0x72 -#define XLP_BRIDGE_DRAM_CHNL_TRANSLN7_REG 0x73 -#define XLP_BRIDGE_PCIEMEM_BASE0_REG 0x74 -#define XLP_BRIDGE_PCIEMEM_BASE1_REG 0x75 -#define XLP_BRIDGE_PCIEMEM_BASE2_REG 0x76 -#define XLP_BRIDGE_PCIEMEM_BASE3_REG 0x77 -#define XLP_BRIDGE_PCIEMEM_LIMIT0_REG 0x78 -#define XLP_BRIDGE_PCIEMEM_LIMIT1_REG 0x79 -#define XLP_BRIDGE_PCIEMEM_LIMIT2_REG 0x7a -#define XLP_BRIDGE_PCIEMEM_LIMIT3_REG 0x7b -#define XLP_BRIDGE_PCIEIO_BASE0_REG 0x7c -#define XLP_BRIDGE_PCIEIO_BASE1_REG 0x7d -#define XLP_BRIDGE_PCIEIO_BASE2_REG 0x7e -#define XLP_BRIDGE_PCIEIO_BASE3_REG 0x7f -#define XLP_BRIDGE_PCIEIO_LIMIT0_REG 0x80 -#define XLP_BRIDGE_PCIEIO_LIMIT1_REG 0x81 -#define XLP_BRIDGE_PCIEIO_LIMIT2_REG 0x82 -#define XLP_BRIDGE_PCIEIO_LIMIT3_REG 0x83 -#define XLP_BRIDGE_PCIEMEM_BASE4_REG 0x84 -#define XLP_BRIDGE_PCIEMEM_BASE5_REG 0x85 -#define XLP_BRIDGE_PCIEMEM_BASE6_REG 0x86 -#define XLP_BRIDGE_PCIEMEM_LIMIT4_REG 0x87 -#define XLP_BRIDGE_PCIEMEM_LIMIT5_REG 0x88 -#define XLP_BRIDGE_PCIEMEM_LIMIT6_REG 0x89 -#define XLP_BRIDGE_PCIEIO_BASE4_REG 0x8a -#define XLP_BRIDGE_PCIEIO_BASE5_REG 0x8b -#define XLP_BRIDGE_PCIEIO_BASE6_REG 0x8c -#define XLP_BRIDGE_PCIEIO_LIMIT4_REG 0x8d -#define XLP_BRIDGE_PCIEIO_LIMIT5_REG 0x8e -#define XLP_BRIDGE_PCIEIO_LIMIT6_REG 0x8f -#define XLP_BRIDGE_NBU_EVENT_CNT_CTL_REG 0x90 -#define XLP_BRIDGE_EVNTCTR1_LOW_REG 0x91 -#define XLP_BRIDGE_EVNTCTR1_HI_REG 0x92 -#define XLP_BRIDGE_EVNT_CNT_CTL2_REG 0x93 -#define XLP_BRIDGE_EVNTCTR2_LOW_REG 0x94 -#define XLP_BRIDGE_EVNTCTR2_HI_REG 0x95 -#define XLP_BRIDGE_TRACEBUF_MATCH_REG0 0x96 -#define XLP_BRIDGE_TRACEBUF_MATCH_REG1 0x97 -#define XLP_BRIDGE_TRACEBUF_MATCH_LOW_REG 0x98 -#define XLP_BRIDGE_TRACEBUF_MATCH_HI_REG 0x99 -#define XLP_BRIDGE_TRACEBUF_CTRL_REG 0x9a -#define XLP_BRIDGE_TRACEBUF_INIT_REG 0x9b -#define XLP_BRIDGE_TRACEBUF_ACCESS_REG 0x9c -#define XLP_BRIDGE_TRACEBUF_READ_DATA_REG0 0x9d -#define XLP_BRIDGE_TRACEBUF_READ_DATA_REG1 0x9d -#define XLP_BRIDGE_TRACEBUF_READ_DATA_REG2 0x9f -#define XLP_BRIDGE_TRACEBUF_READ_DATA_REG3 0xa0 -#define XLP_BRIDGE_TRACEBUF_STATUS_REG 0xa1 -#define XLP_BRIDGE_ADDRESS_ERROR0_REG 0xa2 -#define XLP_BRIDGE_ADDRESS_ERROR1_REG 0xa3 -#define XLP_BRIDGE_ADDRESS_ERROR2_REG 0xa4 -#define XLP_BRIDGE_TAG_ECC_ADDR_ERROR0_REG 0xa5 -#define XLP_BRIDGE_TAG_ECC_ADDR_ERROR1_REG 0xa6 -#define XLP_BRIDGE_TAG_ECC_ADDR_ERROR2_REG 0xa7 -#define XLP_BRIDGE_LINE_FLUSH_REG0 0xa8 -#define XLP_BRIDGE_LINE_FLUSH_REG1 0xa9 -#define XLP_BRIDGE_NODE_ID_REG 0xaa -#define XLP_BRIDGE_ERROR_INTERRUPT_EN_REG 0xab -#define XLP_BRIDGE_PCIE0_WEIGHT_REG 0x300 -#define XLP_BRIDGE_PCIE1_WEIGHT_REG 0x301 -#define XLP_BRIDGE_PCIE2_WEIGHT_REG 0x302 -#define XLP_BRIDGE_PCIE3_WEIGHT_REG 0x303 -#define XLP_BRIDGE_USB_WEIGHT_REG 0x304 -#define XLP_BRIDGE_NET_WEIGHT_REG 0x305 -#define XLP_BRIDGE_POE_WEIGHT_REG 0x306 -#define XLP_BRIDGE_CMS_WEIGHT_REG 0x307 -#define XLP_BRIDGE_DMAENG_WEIGHT_REG 0x308 -#define XLP_BRIDGE_SEC_WEIGHT_REG 0x309 -#define XLP_BRIDGE_COMP_WEIGHT_REG 0x30a -#define XLP_BRIDGE_GIO_WEIGHT_REG 0x30b -#define XLP_BRIDGE_FLASH_WEIGHT_REG 0x30c +/* + * BRIDGE specific registers + * + * These registers start after the PCIe header, which has 0x40 + * standard entries + */ +#define BRIDGE_MODE 0x00 +#define BRIDGE_PCI_CFG_BASE 0x01 +#define BRIDGE_PCI_CFG_LIMIT 0x02 +#define BRIDGE_PCIE_CFG_BASE 0x03 +#define BRIDGE_PCIE_CFG_LIMIT 0x04 +#define BRIDGE_BUSNUM_BAR0 0x05 +#define BRIDGE_BUSNUM_BAR1 0x06 +#define BRIDGE_BUSNUM_BAR2 0x07 +#define BRIDGE_BUSNUM_BAR3 0x08 +#define BRIDGE_BUSNUM_BAR4 0x09 +#define BRIDGE_BUSNUM_BAR5 0x0a +#define BRIDGE_BUSNUM_BAR6 0x0b +#define BRIDGE_FLASH_BAR0 0x0c +#define BRIDGE_FLASH_BAR1 0x0d +#define BRIDGE_FLASH_BAR2 0x0e +#define BRIDGE_FLASH_BAR3 0x0f +#define BRIDGE_FLASH_LIMIT0 0x10 +#define BRIDGE_FLASH_LIMIT1 0x11 +#define BRIDGE_FLASH_LIMIT2 0x12 +#define BRIDGE_FLASH_LIMIT3 0x13 + +#define BRIDGE_DRAM_BAR(i) (0x14 + (i)) +#define BRIDGE_DRAM_BAR0 0x14 +#define BRIDGE_DRAM_BAR1 0x15 +#define BRIDGE_DRAM_BAR2 0x16 +#define BRIDGE_DRAM_BAR3 0x17 +#define BRIDGE_DRAM_BAR4 0x18 +#define BRIDGE_DRAM_BAR5 0x19 +#define BRIDGE_DRAM_BAR6 0x1a +#define BRIDGE_DRAM_BAR7 0x1b + +#define BRIDGE_DRAM_LIMIT(i) (0x1c + (i)) +#define BRIDGE_DRAM_LIMIT0 0x1c +#define BRIDGE_DRAM_LIMIT1 0x1d +#define BRIDGE_DRAM_LIMIT2 0x1e +#define BRIDGE_DRAM_LIMIT3 0x1f +#define BRIDGE_DRAM_LIMIT4 0x20 +#define BRIDGE_DRAM_LIMIT5 0x21 +#define BRIDGE_DRAM_LIMIT6 0x22 +#define BRIDGE_DRAM_LIMIT7 0x23 + +#define BRIDGE_DRAM_NODE_TRANSLN0 0x24 +#define BRIDGE_DRAM_NODE_TRANSLN1 0x25 +#define BRIDGE_DRAM_NODE_TRANSLN2 0x26 +#define BRIDGE_DRAM_NODE_TRANSLN3 0x27 +#define BRIDGE_DRAM_NODE_TRANSLN4 0x28 +#define BRIDGE_DRAM_NODE_TRANSLN5 0x29 +#define BRIDGE_DRAM_NODE_TRANSLN6 0x2a +#define BRIDGE_DRAM_NODE_TRANSLN7 0x2b +#define BRIDGE_DRAM_CHNL_TRANSLN0 0x2c +#define BRIDGE_DRAM_CHNL_TRANSLN1 0x2d +#define BRIDGE_DRAM_CHNL_TRANSLN2 0x2e +#define BRIDGE_DRAM_CHNL_TRANSLN3 0x2f +#define BRIDGE_DRAM_CHNL_TRANSLN4 0x30 +#define BRIDGE_DRAM_CHNL_TRANSLN5 0x31 +#define BRIDGE_DRAM_CHNL_TRANSLN6 0x32 +#define BRIDGE_DRAM_CHNL_TRANSLN7 0x33 +#define BRIDGE_PCIEMEM_BASE0 0x34 +#define BRIDGE_PCIEMEM_BASE1 0x35 +#define BRIDGE_PCIEMEM_BASE2 0x36 +#define BRIDGE_PCIEMEM_BASE3 0x37 +#define BRIDGE_PCIEMEM_LIMIT0 0x38 +#define BRIDGE_PCIEMEM_LIMIT1 0x39 +#define BRIDGE_PCIEMEM_LIMIT2 0x3a +#define BRIDGE_PCIEMEM_LIMIT3 0x3b +#define BRIDGE_PCIEIO_BASE0 0x3c +#define BRIDGE_PCIEIO_BASE1 0x3d +#define BRIDGE_PCIEIO_BASE2 0x3e +#define BRIDGE_PCIEIO_BASE3 0x3f +#define BRIDGE_PCIEIO_LIMIT0 0x40 +#define BRIDGE_PCIEIO_LIMIT1 0x41 +#define BRIDGE_PCIEIO_LIMIT2 0x42 +#define BRIDGE_PCIEIO_LIMIT3 0x43 +#define BRIDGE_PCIEMEM_BASE4 0x44 +#define BRIDGE_PCIEMEM_BASE5 0x45 +#define BRIDGE_PCIEMEM_BASE6 0x46 +#define BRIDGE_PCIEMEM_LIMIT4 0x47 +#define BRIDGE_PCIEMEM_LIMIT5 0x48 +#define BRIDGE_PCIEMEM_LIMIT6 0x49 +#define BRIDGE_PCIEIO_BASE4 0x4a +#define BRIDGE_PCIEIO_BASE5 0x4b +#define BRIDGE_PCIEIO_BASE6 0x4c +#define BRIDGE_PCIEIO_LIMIT4 0x4d +#define BRIDGE_PCIEIO_LIMIT5 0x4e +#define BRIDGE_PCIEIO_LIMIT6 0x4f +#define BRIDGE_NBU_EVENT_CNT_CTL 0x50 +#define BRIDGE_EVNTCTR1_LOW 0x51 +#define BRIDGE_EVNTCTR1_HI 0x52 +#define BRIDGE_EVNT_CNT_CTL2 0x53 +#define BRIDGE_EVNTCTR2_LOW 0x54 +#define BRIDGE_EVNTCTR2_HI 0x55 +#define BRIDGE_TRACEBUF_MATCH0 0x56 +#define BRIDGE_TRACEBUF_MATCH1 0x57 +#define BRIDGE_TRACEBUF_MATCH_LOW 0x58 +#define BRIDGE_TRACEBUF_MATCH_HI 0x59 +#define BRIDGE_TRACEBUF_CTRL 0x5a +#define BRIDGE_TRACEBUF_INIT 0x5b +#define BRIDGE_TRACEBUF_ACCESS 0x5c +#define BRIDGE_TRACEBUF_READ_DATA0 0x5d +#define BRIDGE_TRACEBUF_READ_DATA1 0x5d +#define BRIDGE_TRACEBUF_READ_DATA2 0x5f +#define BRIDGE_TRACEBUF_READ_DATA3 0x60 +#define BRIDGE_TRACEBUF_STATUS 0x61 +#define BRIDGE_ADDRESS_ERROR0 0x62 +#define BRIDGE_ADDRESS_ERROR1 0x63 +#define BRIDGE_ADDRESS_ERROR2 0x64 +#define BRIDGE_TAG_ECC_ADDR_ERROR0 0x65 +#define BRIDGE_TAG_ECC_ADDR_ERROR1 0x66 +#define BRIDGE_TAG_ECC_ADDR_ERROR2 0x67 +#define BRIDGE_LINE_FLUSH0 0x68 +#define BRIDGE_LINE_FLUSH1 0x69 +#define BRIDGE_NODE_ID 0x6a +#define BRIDGE_ERROR_INTERRUPT_EN 0x6b +#define BRIDGE_PCIE0_WEIGHT 0x2c0 +#define BRIDGE_PCIE1_WEIGHT 0x2c1 +#define BRIDGE_PCIE2_WEIGHT 0x2c2 +#define BRIDGE_PCIE3_WEIGHT 0x2c3 +#define BRIDGE_USB_WEIGHT 0x2c4 +#define BRIDGE_NET_WEIGHT 0x2c5 +#define BRIDGE_POE_WEIGHT 0x2c6 +#define BRIDGE_CMS_WEIGHT 0x2c7 +#define BRIDGE_DMAENG_WEIGHT 0x2c8 +#define BRIDGE_SEC_WEIGHT 0x2c9 +#define BRIDGE_COMP_WEIGHT 0x2ca +#define BRIDGE_GIO_WEIGHT 0x2cb +#define BRIDGE_FLASH_WEIGHT 0x2cc #if !defined(LOCORE) && !defined(__ASSEMBLY__) -#define nlm_rdreg_bridge(b, r) nlm_read_reg_kseg(b, r) -#define nlm_wreg_bridge(b, r, v) nlm_write_reg_kseg(b, r, v) -#define nlm_pcibase_bridge(node) nlm_pcicfg_base(XLP_IO_BRIDGE_OFFSET(node)) -#define nlm_regbase_bridge(node) nlm_pcibase_bridge(node) +#define nlm_read_bridge_reg(b, r) nlm_read_reg(b, r) +#define nlm_write_bridge_reg(b, r, v) nlm_write_reg(b, r, v) +#define nlm_get_bridge_pcibase(node) \ + nlm_pcicfg_base(XLP_IO_BRIDGE_OFFSET(node)) +#define nlm_get_bridge_regbase(node) \ + (nlm_get_bridge_pcibase(node) + XLP_IO_PCI_HDRSZ) #endif - #endif Modified: user/jchandra/mips-xlp-support/sys/mips/nlm/hal/cop2.h ============================================================================== --- user/jchandra/mips-xlp-support/sys/mips/nlm/hal/cop2.h Sat Sep 3 07:15:14 2011 (r225362) +++ user/jchandra/mips-xlp-support/sys/mips/nlm/hal/cop2.h Sat Sep 3 08:03:25 2011 (r225363) @@ -27,24 +27,24 @@ * * NETLOGIC_BSD */ -#ifndef __NLM_COP2_H__ -#define __NLM_COP2_H__ +#ifndef __NLM_HAL_COP2_H__ +#define __NLM_HAL_COP2_H__ -#define XLP_COP2_TX_BUF_REG 0 -#define XLP_COP2_RX_BUF_REG 1 -#define XLP_COP2_TXMSGSTATUS_REG 2 -#define XLP_COP2_RXMSGSTATUS_REG 3 -#define XLP_COP2_MSGSTATUS1_REG 4 -#define XLP_COP2_MSGCONFIG_REG 5 -#define XLP_COP2_MSGCONFIG1_REG 6 - -#define CROSSTHR_POPQ_EN 0x01 -#define VC0_POPQ_EN 0x02 -#define VC1_POPQ_EN 0x04 -#define VC2_POPQ_EN 0x08 -#define VC3_POPQ_EN 0x10 -#define ALL_VC_POPQ_EN 0x1E -#define ALL_VC_CT_POPQ_EN 0x1F +#define COP2_TX_BUF 0 +#define COP2_RX_BUF 1 +#define COP2_TXMSGSTATUS 2 +#define COP2_RXMSGSTATUS 3 +#define COP2_MSGSTATUS1 4 +#define COP2_MSGCONFIG 5 +#define COP2_MSGCONFIG1 6 + +#define CROSSTHR_POPQ_EN 0x01 +#define VC0_POPQ_EN 0x02 +#define VC1_POPQ_EN 0x04 +#define VC2_POPQ_EN 0x08 +#define VC3_POPQ_EN 0x10 +#define ALL_VC_POPQ_EN 0x1E +#define ALL_VC_CT_POPQ_EN 0x1F struct nlm_fmn_msg { uint64_t msg[4]; @@ -61,8 +61,7 @@ static inline uint32_t nlm_read_c2_##nam "mfc2 %0, $%1, %2\n" \ ".set pop\n" \ : "=r" (__rv) \ - : "i" (reg), "i" (sel) \ - ); \ + : "i" (reg), "i" (sel)); \ return __rv; \ } \ \ @@ -74,8 +73,7 @@ static inline void nlm_write_c2_##name(u ".set mips64\n" \ "mtc2 %0, $%1, %2\n" \ ".set pop\n" \ - :: "r" (val), "i" (reg), "i" (sel) \ - ); \ + : : "r" (val), "i" (reg), "i" (sel)); \ } struct __hack #if (__mips == 64) @@ -90,7 +88,7 @@ static inline uint64_t nlm_read_c2_##nam "dmfc2 %0, $%1, %2\n" \ ".set pop\n" \ : "=r" (__rv) \ - : "i" (reg), "i" (sel) ); \ + : "i" (reg), "i" (sel)); \ return __rv; \ } \ \ @@ -102,7 +100,7 @@ static inline void nlm_write_c2_##name(u ".set mips64\n" \ "dmtc2 %0, $%1, %2\n" \ ".set pop\n" \ - :: "r" (val), "i" (reg), "i" (sel) ); \ + : : "r" (val), "i" (reg), "i" (sel)); \ } struct __hack #else @@ -121,15 +119,15 @@ static inline uint64_t nlm_read_c2_##nam ".set pop\n" \ : "=r"(__high), "=r"(__low) \ : "i"(reg), "i"(sel) \ - : "$8" ); \ + : "$8"); \ \ - return (((uint64_t)__high << 32) | __low); \ + return ((uint64_t)__high << 32) | __low; \ } \ \ static inline void nlm_write_c2_##name(uint64_t val) \ { \ - uint32_t __high = val >> 32; \ - uint32_t __low = val & 0xffffffff; \ + uint32_t __high = val >> 32; \ + uint32_t __low = val & 0xffffffff; \ __asm__ __volatile__ ( \ ".set push\n" \ ".set noreorder\n" \ @@ -140,113 +138,117 @@ static inline void nlm_write_c2_##name(u "or $8, $8, $9\n" \ "dmtc2 $8, $%2, %3\n" \ ".set pop\n" \ - :: "r"(__high), "r"(__low), "i"(reg), "i"(sel) \ - :"$8", "$9"); \ + : : "r"(__high), "r"(__low), "i"(reg), "i"(sel) \ + : "$8", "$9"); \ } struct __hack #endif -NLM_DEFINE_COP2_ACCESSORS64(txbuf0, XLP_COP2_TX_BUF_REG, 0); -NLM_DEFINE_COP2_ACCESSORS64(txbuf1, XLP_COP2_TX_BUF_REG, 1); -NLM_DEFINE_COP2_ACCESSORS64(txbuf2, XLP_COP2_TX_BUF_REG, 2); -NLM_DEFINE_COP2_ACCESSORS64(txbuf3, XLP_COP2_TX_BUF_REG, 3); - -NLM_DEFINE_COP2_ACCESSORS64(rxbuf0, XLP_COP2_RX_BUF_REG, 0); -NLM_DEFINE_COP2_ACCESSORS64(rxbuf1, XLP_COP2_RX_BUF_REG, 1); -NLM_DEFINE_COP2_ACCESSORS64(rxbuf2, XLP_COP2_RX_BUF_REG, 2); -NLM_DEFINE_COP2_ACCESSORS64(rxbuf3, XLP_COP2_RX_BUF_REG, 3); - -NLM_DEFINE_COP2_ACCESSORS32(txmsgstatus, XLP_COP2_TXMSGSTATUS_REG, 0); -NLM_DEFINE_COP2_ACCESSORS32(rxmsgstatus, XLP_COP2_RXMSGSTATUS_REG, 0); -NLM_DEFINE_COP2_ACCESSORS32(msgstatus1, XLP_COP2_MSGSTATUS1_REG, 0); -NLM_DEFINE_COP2_ACCESSORS32(msgconfig, XLP_COP2_MSGCONFIG_REG, 0); -NLM_DEFINE_COP2_ACCESSORS32(msgconfig1, XLP_COP2_MSGCONFIG1_REG, 0); +NLM_DEFINE_COP2_ACCESSORS64(txbuf0, COP2_TX_BUF, 0); +NLM_DEFINE_COP2_ACCESSORS64(txbuf1, COP2_TX_BUF, 1); +NLM_DEFINE_COP2_ACCESSORS64(txbuf2, COP2_TX_BUF, 2); +NLM_DEFINE_COP2_ACCESSORS64(txbuf3, COP2_TX_BUF, 3); + +NLM_DEFINE_COP2_ACCESSORS64(rxbuf0, COP2_RX_BUF, 0); +NLM_DEFINE_COP2_ACCESSORS64(rxbuf1, COP2_RX_BUF, 1); +NLM_DEFINE_COP2_ACCESSORS64(rxbuf2, COP2_RX_BUF, 2); +NLM_DEFINE_COP2_ACCESSORS64(rxbuf3, COP2_RX_BUF, 3); + +NLM_DEFINE_COP2_ACCESSORS32(txmsgstatus, COP2_TXMSGSTATUS, 0); +NLM_DEFINE_COP2_ACCESSORS32(rxmsgstatus, COP2_RXMSGSTATUS, 0); +NLM_DEFINE_COP2_ACCESSORS32(msgstatus1, COP2_MSGSTATUS1, 0); +NLM_DEFINE_COP2_ACCESSORS32(msgconfig, COP2_MSGCONFIG, 0); +NLM_DEFINE_COP2_ACCESSORS32(msgconfig1, COP2_MSGCONFIG1, 0); /* successful completion returns 1, else 0 */ -static __inline__ int nlm_msgsend(int val) +static inline int +nlm_msgsend(int val) { int result; __asm__ volatile ( - ".set push \n" - ".set noreorder \n" - ".set mips64 \n" - "move $8, %1 \n" - "sync \n" - "/* msgsnds $9, $8 */ \n" - ".word 0x4a084801 \n" - "move %0, $9 \n" - ".set pop \n" + ".set push\n" + ".set noreorder\n" + ".set mips64\n" + "move $8, %1\n" + "sync\n" + "/* msgsnds $9, $8 */\n" + ".word 0x4a084801\n" + "move %0, $9\n" + ".set pop\n" : "=r" (result) : "r" (val) - : "$8", "$9" - ); + : "$8", "$9"); return result; } -static __inline__ int nlm_msgld(int vc) +static inline int +nlm_msgld(int vc) { int val; __asm__ volatile ( - ".set push \n" - ".set noreorder \n" - ".set mips64 \n" - "move $8, %1 \n" - "/* msgld $9, $8 */ \n" - ".word 0x4a084802 \n" - "move %0, $9 \n" - ".set pop \n" + ".set push\n" + ".set noreorder\n" + ".set mips64\n" + "move $8, %1\n" + "/* msgld $9, $8 */\n" + ".word 0x4a084802\n" + "move %0, $9\n" + ".set pop\n" : "=r" (val) : "r" (vc) - : "$8", "$9" - ); + : "$8", "$9"); return val; } -static __inline__ void nlm_msgwait(int vc) +static inline void +nlm_msgwait(int vc) { __asm__ volatile ( - ".set push \n" - ".set noreorder \n" - ".set mips64 \n" - "move $8, %0 \n" - "/* msgwait $8 */ \n" - ".word 0x4a080003 \n" - ".set pop \n" - :: "r" (vc) - : "$8" - ); + ".set push\n" + ".set noreorder\n" + ".set mips64\n" + "move $8, %0\n" + "/* msgwait $8 */\n" + ".word 0x4a080003\n" + ".set pop\n" + : : "r" (vc) + : "$8"); } /* TODO this is not needed in n32 and n64 */ -static __inline uint32_t +static inline uint32_t nlm_fmn_saveflags(void) { uint32_t sr = mips_rd_status(); mips_wr_status((sr & ~MIPS_SR_INT_IE) | MIPS_SR_COP_2_BIT); - return (sr); + return sr; } -static __inline void +static inline void nlm_fmn_restoreflags(uint32_t sr) { mips_wr_status(sr); } -static __inline__ int nlm_fmn_msgsend(int dstid, int size, int swcode, - struct nlm_fmn_msg *m) +static inline int +nlm_fmn_msgsend(int dstid, int size, int swcode, struct nlm_fmn_msg *m) { uint32_t flags, status; int rv; size -= 1; flags = nlm_fmn_saveflags(); - switch(size) { - case 3: nlm_write_c2_txbuf3(m->msg[3]); - case 2: nlm_write_c2_txbuf2(m->msg[2]); - case 1: nlm_write_c2_txbuf1(m->msg[1]); - case 0: nlm_write_c2_txbuf0(m->msg[0]); + switch (size) { + case 3: + nlm_write_c2_txbuf3(m->msg[3]); + case 2: + nlm_write_c2_txbuf2(m->msg[2]); + case 1: + nlm_write_c2_txbuf1(m->msg[1]); + case 0: + nlm_write_c2_txbuf0(m->msg[0]); } dstid |= ((swcode << 24) | (size << 16)); @@ -256,11 +258,11 @@ static __inline__ int nlm_fmn_msgsend(in rv = nlm_read_c2_txmsgstatus(); nlm_fmn_restoreflags(flags); - return (rv); + return rv; } -static __inline__ int nlm_fmn_msgrcv(int vc, int *srcid, int *size, int *code, - struct nlm_fmn_msg *m) +static inline int +nlm_fmn_msgrcv(int vc, int *srcid, int *size, int *code, struct nlm_fmn_msg *m) { uint32_t status; uint32_t msg_status, flags; @@ -275,11 +277,15 @@ static __inline__ int nlm_fmn_msgrcv(int *code = (msg_status >> 18) & 0xff; *srcid = (msg_status >> 4) & 0xfff; tmp_sz = *size - 1; - switch(tmp_sz) { - case 3: m->msg[3] = nlm_read_c2_rxbuf3(); - case 2: m->msg[2] = nlm_read_c2_rxbuf2(); - case 1: m->msg[1] = nlm_read_c2_rxbuf1(); - case 0: m->msg[0] = nlm_read_c2_rxbuf0(); + switch (tmp_sz) { + case 3: + m->msg[3] = nlm_read_c2_rxbuf3(); + case 2: + m->msg[2] = nlm_read_c2_rxbuf2(); + case 1: + m->msg[1] = nlm_read_c2_rxbuf1(); + case 0: + m->msg[0] = nlm_read_c2_rxbuf0(); } } nlm_fmn_restoreflags(flags); @@ -287,26 +293,8 @@ static __inline__ int nlm_fmn_msgrcv(int return rv; } -/** - * nlm_fmn_cpu_init() initializes the per-h/w thread cop2 w.r.t the following - * configuration parameters. It needs to be individually setup on each - * hardware thread. - * - * int_vec - interrupt vector getting placed into msgconfig reg - * ctpe - cross thread message pop enable. When set to 1, the thread (h/w cpu) - * associated where this cop2 register is setup, can pop messages - * intended for any other thread in the same core. - * v0pe - VC0 pop message request mode enable. When set to 1, the thread - * can send pop requests to vc0. - * v1pe - VC1 pop message request mode enable. When set to 1, the thread - * can send pop requests to vc1. - * v2pe - VC2 pop message request mode enable. When set to 1, the thread - * can send pop requests to vc2. - * v3pe - VC3 pop message request mode enable. When set to 1, the thread - * can send pop requests to vc3. - */ -static __inline__ void nlm_fmn_cpu_init(int int_vec, int ctpe, int v0pe, - int v1pe, int v2pe, int v3pe) +static inline void +nlm_fmn_cpu_init(int int_vec, int ctpe, int v0pe, int v1pe, int v2pe, int v3pe) { uint32_t val = nlm_read_c2_msgconfig(); Modified: user/jchandra/mips-xlp-support/sys/mips/nlm/hal/cpucontrol.h ============================================================================== --- user/jchandra/mips-xlp-support/sys/mips/nlm/hal/cpucontrol.h Sat Sep 3 07:15:14 2011 (r225362) +++ user/jchandra/mips-xlp-support/sys/mips/nlm/hal/cpucontrol.h Sat Sep 3 08:03:25 2011 (r225363) @@ -27,43 +27,164 @@ * * NETLOGIC_BSD */ -#ifndef __NLM_CPUCONTROL_H__ -#define __NLM_CPUCONTROL_H__ +#ifndef __NLM_HAL_CPUCONTROL_H__ +#define __NLM_HAL_CPUCONTROL_H__ -#define XLP_CPU_BLOCKID_IFU 0 -#define XLP_CPU_BLOCKID_ICU 1 - -#define XLP_CPU_BLOCKID_IEU 2 -#define XLP_CPU_BLOCKID_LSU 3 -#define XLP_LSU_DEFEATURE 0x304 -#define XLP_LSU_CERRLOG_REGID 0x09 - -#define XLP_CPU_BLOCKID_MMU 4 -#define XLP_CPU_BLOCKID_PRF 5 - -#define XLP_CPU_BLOCKID_SCH 7 -#define XLP_SCHED_DEFEATURE 0x700 - -#define XLP_CPU_BLOCKID_SCU 8 -#define XLP_CPU_BLOCKID_FPU 9 - -#define XLP_CPU_BLOCKID_MAP 10 +#define CPU_BLOCKID_IFU 0 +#define CPU_BLOCKID_ICU 1 +#define CPU_BLOCKID_IEU 2 +#define CPU_BLOCKID_LSU 3 +#define CPU_BLOCKID_MMU 4 +#define CPU_BLOCKID_PRF 5 +#define CPU_BLOCKID_SCH 7 +#define CPU_BLOCKID_SCU 8 +#define CPU_BLOCKID_FPU 9 +#define CPU_BLOCKID_MAP 10 + +#define LSU_DEFEATURE 0x304 +#define LSU_CERRLOG_REGID 0x09 +#define SCHED_DEFEATURE 0x700 /* Offsets of interest from the 'MAP' Block */ -#define XLP_BLKID_MAP_THREADMODE 0x00 -#define XLP_BLKID_MAP_EXT_EBASE_ENABLE 0x04 -#define XLP_BLKID_MAP_CCDI_CONFIG 0x08 -#define XLP_BLKID_MAP_THRD0_CCDI_STATUS 0x0c -#define XLP_BLKID_MAP_THRD1_CCDI_STATUS 0x10 -#define XLP_BLKID_MAP_THRD2_CCDI_STATUS 0x14 -#define XLP_BLKID_MAP_THRD3_CCDI_STATUS 0x18 -#define XLP_BLKID_MAP_THRD0_DEBUG_MODE 0x1c -#define XLP_BLKID_MAP_THRD1_DEBUG_MODE 0x20 -#define XLP_BLKID_MAP_THRD2_DEBUG_MODE 0x24 -#define XLP_BLKID_MAP_THRD3_DEBUG_MODE 0x28 -#define XLP_BLKID_MAP_MISC_STATE 0x60 -#define XLP_BLKID_MAP_DEBUG_READ_CTL 0x64 -#define XLP_BLKID_MAP_DEBUG_READ_REG0 0x68 -#define XLP_BLKID_MAP_DEBUG_READ_REG1 0x6c +#define MAP_THREADMODE 0x00 +#define MAP_EXT_EBASE_ENABLE 0x04 +#define MAP_CCDI_CONFIG 0x08 +#define MAP_THRD0_CCDI_STATUS 0x0c +#define MAP_THRD1_CCDI_STATUS 0x10 +#define MAP_THRD2_CCDI_STATUS 0x14 +#define MAP_THRD3_CCDI_STATUS 0x18 +#define MAP_THRD0_DEBUG_MODE 0x1c +#define MAP_THRD1_DEBUG_MODE 0x20 +#define MAP_THRD2_DEBUG_MODE 0x24 +#define MAP_THRD3_DEBUG_MODE 0x28 +#define MAP_MISC_STATE 0x60 +#define MAP_DEBUG_READ_CTL 0x64 +#define MAP_DEBUG_READ_REG0 0x68 +#define MAP_DEBUG_READ_REG1 0x6c + +#define MMU_SETUP 0x400 +#define MMU_LFSRSEED 0x401 +#define MMU_HPW_NUM_PAGE_LVL 0x410 +#define MMU_PGWKR_PGDBASE 0x411 +#define MMU_PGWKR_PGDSHFT 0x412 +#define MMU_PGWKR_PGDMASK 0x413 +#define MMU_PGWKR_PUDSHFT 0x414 +#define MMU_PGWKR_PUDMASK 0x415 +#define MMU_PGWKR_PMDSHFT 0x416 +#define MMU_PGWKR_PMDMASK 0x417 +#define MMU_PGWKR_PTESHFT 0x418 +#define MMU_PGWKR_PTEMASK 0x419 + + +#if !defined(LOCORE) && !defined(__ASSEMBLY__) +#if defined(__mips_n64) || defined(__mips_n32) +static __inline uint64_t +nlm_mfcr(uint32_t reg) +{ + uint64_t res; + + __asm__ __volatile__( + ".set push\n\t" + ".set noreorder\n\t" + "move $9, %1\n\t" + ".word 0x71280018\n\t" /* mfcr $8, $9 */ + "move %0, $8\n\t" + ".set pop\n" + : "=r" (res) : "r"(reg) + : "$8", "$9" + ); + return (res); +} + +static __inline void +nlm_mtcr(uint32_t reg, uint64_t value) +{ + __asm__ __volatile__( + ".set push\n\t" + ".set noreorder\n\t" + "move $8, %0\n" + "move $9, %1\n" + ".word 0x71280019\n" /* mtcr $8, $9 */ + ".set pop\n" + : + : "r" (value), "r" (reg) + : "$8", "$9" + ); +} + +#else /* !(defined(__mips_n64) || defined(__mips_n32)) */ + +static __inline__ uint64_t +nlm_mfcr(uint32_t reg) +{ + uint32_t hi, lo; + + __asm__ __volatile__ ( + ".set push\n" + ".set mips64\n" + "move $8, %2\n" + ".word 0x71090018\n" + "nop \n" + "dsra32 %0, $9, 0\n" + "sll %1, $9, 0\n" + ".set pop\n" + : "=r"(hi), "=r"(lo) + : "r"(reg) : "$8", "$9"); + + return (((uint64_t)hi) << 32) | lo; +} + +static __inline__ void +nlm_mtcr(uint32_t reg, uint64_t val) +{ + uint32_t hi, lo; + + hi = val >> 32; + lo = val & 0xffffffff; + + __asm__ __volatile__ ( + ".set push\n" + ".set mips64\n" + "move $9, %0\n" + "dsll32 $9, %1, 0\n" + "dsll32 $8, %0, 0\n" + "dsrl32 $9, $9, 0\n" + "or $9, $9, $8\n" + "move $8, %2\n" + ".word 0x71090019\n" + "nop \n" + ".set pop\n" + ::"r"(hi), "r"(lo), "r"(reg) + : "$8", "$9"); +} +#endif /* (defined(__mips_n64) || defined(__mips_n32)) */ + +/* hashindex_en = 1 to enable hash mode, hashindex_en=0 to disable + * global_mode = 1 to enable global mode, global_mode=0 to disable + * clk_gating = 0 to enable clock gating, clk_gating=1 to disable + */ +static __inline__ void nlm_mmu_setup(int hashindex_en, int global_mode, + int clk_gating) +{ + uint32_t mmusetup = 0; + + mmusetup |= (hashindex_en << 13); + mmusetup |= (clk_gating << 3); + mmusetup |= (global_mode << 0); + nlm_mtcr(MMU_SETUP, mmusetup); +} + +static __inline__ void nlm_mmu_lfsr_seed (int thr0_seed, int thr1_seed, + int thr2_seed, int thr3_seed) +{ + uint32_t seed = nlm_mfcr(MMU_LFSRSEED); + + seed |= ((thr3_seed & 0x7f) << 23); + seed |= ((thr2_seed & 0x7f) << 16); + seed |= ((thr1_seed & 0x7f) << 7); + seed |= ((thr0_seed & 0x7f) << 0); + nlm_mtcr(MMU_LFSRSEED, seed); +} +#endif /* __ASSEMBLY__ */ #endif /* __NLM_CPUCONTROL_H__ */ Modified: user/jchandra/mips-xlp-support/sys/mips/nlm/hal/fmn.c ============================================================================== --- user/jchandra/mips-xlp-support/sys/mips/nlm/hal/fmn.c Sat Sep 3 07:15:14 2011 (r225362) +++ user/jchandra/mips-xlp-support/sys/mips/nlm/hal/fmn.c Sat Sep 3 08:03:25 2011 (r225363) @@ -31,10 +31,10 @@ #include #include #include +#include #include #include -uint32_t bad_xlp_num_nodes = 4; /* XLP can take upto 16K of FMN messages per hardware queue, as spill. * But, configuring all 16K causes the total spill memory to required * to blow upto 192MB for single chip configuration, and 768MB in four @@ -64,27 +64,7 @@ uint64_t nlm_cms_spill_total_messages = * For all 4 nodes, there are 18*4 = 72 FMN stations */ uint32_t nlm_cms_total_stations = 18 * 4 /*xlp_num_nodes*/; -uint32_t cms_onchip_seg_availability[XLP_CMS_ON_CHIP_PER_QUEUE_SPACE]; - -int nlm_cms_verify_credit_config (int spill_en, int tot_credit) -{ - /* Note: In XLP there seem to be no mechanism to read back - * the credit count that has been programmed into a sid / did pair; - * since we have only one register 0x2000 to read. - * Hence it looks like all credit mgmt/verification needs to - * be done by software. Software could keep track of total credits - * getting programmed and verify it from this function. - */ - - if (spill_en) { - /* TODO */ - } - - if (tot_credit > (XLP_CMS_ON_CHIP_MESG_SPACE*bad_xlp_num_nodes)) - return 1; /* credits overflowed - should not happen */ - - return 0; -} +uint32_t cms_onchip_seg_availability[CMS_ON_CHIP_PER_QUEUE_SPACE]; /** * Takes inputs as node, queue_size and maximum number of queues. @@ -159,7 +139,7 @@ void nlm_cms_setup_credits(uint64_t base uint32_t val; val = ((credit << 24) | (destid << 12) | (srcid << 0)); - nlm_wreg_cms(base, XLP_CMS_OUTPUTQ_CREDIT_CFG_REG, val); + nlm_write_cms_reg(base, CMS_OUTPUTQ_CREDIT_CFG, val); } @@ -178,93 +158,93 @@ int nlm_cms_config_onchip_queue (uint64_ #if 0 /* configure credits for src cpu0, on this queue */ - nlm_cms_setup_credits(base, qid, XLP_CMS_CPU0_SRC_STID, - XLP_CMS_DEFAULT_CREDIT(nlm_cms_total_stations, + nlm_cms_setup_credits(base, qid, CMS_CPU0_SRC_STID, + CMS_DEFAULT_CREDIT(nlm_cms_total_stations, nlm_cms_spill_total_messages)); /* configure credits for src cpu1, on this queue */ - nlm_cms_setup_credits(base, qid, XLP_CMS_CPU1_SRC_STID, - XLP_CMS_DEFAULT_CREDIT(nlm_cms_total_stations, + nlm_cms_setup_credits(base, qid, CMS_CPU1_SRC_STID, + CMS_DEFAULT_CREDIT(nlm_cms_total_stations, nlm_cms_spill_total_messages)); /* configure credits for src cpu2, on this queue */ - nlm_cms_setup_credits(base, qid, XLP_CMS_CPU2_SRC_STID, - XLP_CMS_DEFAULT_CREDIT(nlm_cms_total_stations, + nlm_cms_setup_credits(base, qid, CMS_CPU2_SRC_STID, + CMS_DEFAULT_CREDIT(nlm_cms_total_stations, nlm_cms_spill_total_messages)); /* configure credits for src cpu3, on this queue */ - nlm_cms_setup_credits(base, qid, XLP_CMS_CPU3_SRC_STID, - XLP_CMS_DEFAULT_CREDIT(nlm_cms_total_stations, + nlm_cms_setup_credits(base, qid, CMS_CPU3_SRC_STID, + CMS_DEFAULT_CREDIT(nlm_cms_total_stations, nlm_cms_spill_total_messages)); /* configure credits for src cpu4, on this queue */ - nlm_cms_setup_credits(base, qid, XLP_CMS_CPU4_SRC_STID, - XLP_CMS_DEFAULT_CREDIT(nlm_cms_total_stations, + nlm_cms_setup_credits(base, qid, CMS_CPU4_SRC_STID, + CMS_DEFAULT_CREDIT(nlm_cms_total_stations, nlm_cms_spill_total_messages)); /* configure credits for src cpu5, on this queue */ - nlm_cms_setup_credits(base, qid, XLP_CMS_CPU5_SRC_STID, - XLP_CMS_DEFAULT_CREDIT(nlm_cms_total_stations, + nlm_cms_setup_credits(base, qid, CMS_CPU5_SRC_STID, + CMS_DEFAULT_CREDIT(nlm_cms_total_stations, nlm_cms_spill_total_messages)); /* configure credits for src cpu6, on this queue */ - nlm_cms_setup_credits(base, qid, XLP_CMS_CPU6_SRC_STID, - XLP_CMS_DEFAULT_CREDIT(nlm_cms_total_stations, + nlm_cms_setup_credits(base, qid, CMS_CPU6_SRC_STID, + CMS_DEFAULT_CREDIT(nlm_cms_total_stations, nlm_cms_spill_total_messages)); /* configure credits for src cpu7, on this queue */ - nlm_cms_setup_credits(base, qid, XLP_CMS_CPU7_SRC_STID, - XLP_CMS_DEFAULT_CREDIT(nlm_cms_total_stations, + nlm_cms_setup_credits(base, qid, CMS_CPU7_SRC_STID, + CMS_DEFAULT_CREDIT(nlm_cms_total_stations, nlm_cms_spill_total_messages)); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Sat Sep 3 15:34:18 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EFFF1106566C; Sat, 3 Sep 2011 15:34:18 +0000 (UTC) (envelope-from jchandra@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DE3F38FC12; Sat, 3 Sep 2011 15:34:18 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p83FYIdr051966; Sat, 3 Sep 2011 15:34:18 GMT (envelope-from jchandra@svn.freebsd.org) Received: (from jchandra@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p83FYIP7051951; Sat, 3 Sep 2011 15:34:18 GMT (envelope-from jchandra@svn.freebsd.org) Message-Id: <201109031534.p83FYIP7051951@svn.freebsd.org> From: "Jayachandran C." Date: Sat, 3 Sep 2011 15:34:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225368 - in user/jchandra/mips-xlp-support/sys/mips/nlm: . hal X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Sep 2011 15:34:19 -0000 Author: jchandra Date: Sat Sep 3 15:34:18 2011 New Revision: 225368 URL: http://svn.freebsd.org/changeset/base/225368 Log: HAL updates mmio.h renamed to haldefs.h - contains more than mmio now use cpufunc.h functions for status register changes Added: user/jchandra/mips-xlp-support/sys/mips/nlm/hal/haldefs.h - copied, changed from r225363, user/jchandra/mips-xlp-support/sys/mips/nlm/hal/mmio.h Deleted: user/jchandra/mips-xlp-support/sys/mips/nlm/hal/mmio.h Modified: user/jchandra/mips-xlp-support/sys/mips/nlm/board.c user/jchandra/mips-xlp-support/sys/mips/nlm/cms.c user/jchandra/mips-xlp-support/sys/mips/nlm/hal/cop2.h user/jchandra/mips-xlp-support/sys/mips/nlm/hal/fmn.c user/jchandra/mips-xlp-support/sys/mips/nlm/hal/pic.h user/jchandra/mips-xlp-support/sys/mips/nlm/intern_dev.c user/jchandra/mips-xlp-support/sys/mips/nlm/intr_machdep.c user/jchandra/mips-xlp-support/sys/mips/nlm/uart_bus_xlp_iodi.c user/jchandra/mips-xlp-support/sys/mips/nlm/uart_cpu_xlp.c user/jchandra/mips-xlp-support/sys/mips/nlm/uart_pci_xlp.c user/jchandra/mips-xlp-support/sys/mips/nlm/usb_init.c user/jchandra/mips-xlp-support/sys/mips/nlm/xlp_machdep.c user/jchandra/mips-xlp-support/sys/mips/nlm/xlp_pci.c Modified: user/jchandra/mips-xlp-support/sys/mips/nlm/board.c ============================================================================== --- user/jchandra/mips-xlp-support/sys/mips/nlm/board.c Sat Sep 3 12:59:05 2011 (r225367) +++ user/jchandra/mips-xlp-support/sys/mips/nlm/board.c Sat Sep 3 15:34:18 2011 (r225368) @@ -35,7 +35,7 @@ #include #include -#include +#include #include #include #include Modified: user/jchandra/mips-xlp-support/sys/mips/nlm/cms.c ============================================================================== --- user/jchandra/mips-xlp-support/sys/mips/nlm/cms.c Sat Sep 3 12:59:05 2011 (r225367) +++ user/jchandra/mips-xlp-support/sys/mips/nlm/cms.c Sat Sep 3 15:34:18 2011 (r225368) @@ -56,9 +56,8 @@ __FBSDID("$FreeBSD: head/sys/mips/rmi/fm #include #include -#include +#include #include -#include #include #include #include @@ -247,9 +246,9 @@ xlp_handle_msg_vc(int vc, int max_msgs) uint32_t mflags, status; for (i = 0; i < max_msgs; i++) { - mflags = nlm_fmn_saveflags(); + mflags = nlm_save_flags_cop2(); status = nlm_fmn_msgrcv(vc, &srcid, &size, &code, &msg); - nlm_fmn_restoreflags(mflags); + nlm_restore_flags(mflags); if (status != 0) /* If there is no msg or error */ break; if (srcid < 0 && srcid >= 1024) { @@ -320,9 +319,9 @@ msgring_process(void * arg) if (hwtid != nlm_cpuid()) printf("Misscheduled hwtid %d != cpuid %d\n", hwtid, nlm_cpuid()); - mflags = nlm_fmn_saveflags(); + mflags = nlm_save_flags_cop2(); nlm_fmn_cpu_init(IRQ_MSGRING, 0, 0, 0, 0, 0); - nlm_fmn_restoreflags(mflags); + nlm_restore_flags(mflags); /* start processing messages */ for( ; ; ) { Modified: user/jchandra/mips-xlp-support/sys/mips/nlm/hal/cop2.h ============================================================================== --- user/jchandra/mips-xlp-support/sys/mips/nlm/hal/cop2.h Sat Sep 3 12:59:05 2011 (r225367) +++ user/jchandra/mips-xlp-support/sys/mips/nlm/hal/cop2.h Sat Sep 3 15:34:18 2011 (r225368) @@ -215,23 +215,6 @@ nlm_msgwait(int vc) : "$8"); } -/* TODO this is not needed in n32 and n64 */ -static inline uint32_t -nlm_fmn_saveflags(void) -{ - uint32_t sr = mips_rd_status(); - - mips_wr_status((sr & ~MIPS_SR_INT_IE) | MIPS_SR_COP_2_BIT); - return sr; -} - -static inline void -nlm_fmn_restoreflags(uint32_t sr) -{ - - mips_wr_status(sr); -} - static inline int nlm_fmn_msgsend(int dstid, int size, int swcode, struct nlm_fmn_msg *m) { @@ -239,7 +222,7 @@ nlm_fmn_msgsend(int dstid, int size, int int rv; size -= 1; - flags = nlm_fmn_saveflags(); + flags = nlm_save_flags_cop2(); switch (size) { case 3: nlm_write_c2_txbuf3(m->msg[3]); @@ -256,7 +239,7 @@ nlm_fmn_msgsend(int dstid, int size, int rv = !status; if (rv != 0) rv = nlm_read_c2_txmsgstatus(); - nlm_fmn_restoreflags(flags); + nlm_restore_flags(flags); return rv; } @@ -268,7 +251,7 @@ nlm_fmn_msgrcv(int vc, int *srcid, int * uint32_t msg_status, flags; int tmp_sz, rv; - flags = nlm_fmn_saveflags(); + flags = nlm_save_flags_cop2(); status = nlm_msgld(vc); /* will return 0, if error */ rv = !status; if (rv == 0) { @@ -288,7 +271,7 @@ nlm_fmn_msgrcv(int vc, int *srcid, int * m->msg[0] = nlm_read_c2_rxbuf0(); } } - nlm_fmn_restoreflags(flags); + nlm_restore_flags(flags); return rv; } Modified: user/jchandra/mips-xlp-support/sys/mips/nlm/hal/fmn.c ============================================================================== --- user/jchandra/mips-xlp-support/sys/mips/nlm/hal/fmn.c Sat Sep 3 12:59:05 2011 (r225367) +++ user/jchandra/mips-xlp-support/sys/mips/nlm/hal/fmn.c Sat Sep 3 15:34:18 2011 (r225368) @@ -28,12 +28,13 @@ * NETLOGIC_BSD */ #include +#include + +#include #include -#include +#include #include -#include #include -#include /* XLP can take upto 16K of FMN messages per hardware queue, as spill. * But, configuring all 16K causes the total spill memory to required Copied and modified: user/jchandra/mips-xlp-support/sys/mips/nlm/hal/haldefs.h (from r225363, user/jchandra/mips-xlp-support/sys/mips/nlm/hal/mmio.h) ============================================================================== --- user/jchandra/mips-xlp-support/sys/mips/nlm/hal/mmio.h Sat Sep 3 08:03:25 2011 (r225363, copy source) +++ user/jchandra/mips-xlp-support/sys/mips/nlm/hal/haldefs.h Sat Sep 3 15:34:18 2011 (r225368) @@ -35,7 +35,7 @@ * and will provide a way to read 32/64 bit memory mapped registers in * all ABIs */ -#if !defined(__mips_n32) && !defined(__mips_n64) + /* * For o32 compilation, we have to disable interrupts and enable KX bit to * access 64 bit addresses or data. @@ -44,27 +44,26 @@ * registers in interrupt handling. So if we get hit by an interrupt while * using the upper 32 bits of a register, we lose. */ -static inline uint32_t nlm_enable_kx(void) +static inline uint32_t nlm_save_flags_kx(void) { - uint32_t sr; + uint32_t sr = mips_rd_status(); - __asm__ __volatile__( - "mfc0 %0, $12\n\t" /* read status reg */ - "move $8, %0\n\t" - "ori $8, $8, 0x81\n\t" /* set KX, and IE */ - "xori $8, $8, 0x1\n\t" /* flip IE */ - "mtc0 $8, $12\n\t" /* update status reg */ - : "=r"(sr) - : : "$8"); + mips_wr_status((sr & ~MIPS_SR_INT_IE) | MIPS_SR_KX); + return (sr); +} - return sr; +static inline uint32_t nlm_save_flags_cop2(void) +{ + uint32_t sr = mips_rd_status(); + + mips_wr_status((sr & ~MIPS_SR_INT_IE) | MIPS_SR_COP_2_BIT); + return (sr); } -static inline void nlm_restore_kx(uint32_t sr) +static inline void nlm_restore_flags(uint32_t sr) { - __asm__ __volatile__("mtc0 %0, $12" : : "r"(sr)); + mips_wr_status(sr); } -#endif static inline uint32_t nlm_load_word(uint64_t addr) @@ -106,7 +105,7 @@ nlm_load_dword(uint64_t addr) volatile uint64_t *p = (volatile uint64_t *)(long)addr; uint32_t valhi, vallo, sr; - sr = nlm_enable_kx(); + sr = nlm_save_flags_kx(); __asm__ __volatile__( ".set push\n\t" ".set mips64\n\t" @@ -117,7 +116,7 @@ nlm_load_dword(uint64_t addr) : "=r"(valhi), "=r"(vallo) : "r"(p) : "$8"); - nlm_restore_kx(sr); + nlm_restore_flags(sr); return ((uint64_t)valhi << 32) | vallo; } @@ -131,7 +130,7 @@ nlm_store_dword(uint64_t addr, uint64_t valhi = val >> 32; vallo = val & 0xffffffff; - sr = nlm_enable_kx(); + sr = nlm_save_flags_kx(); __asm__ __volatile__( ".set push\n\t" ".set mips64\n\t" @@ -143,7 +142,7 @@ nlm_store_dword(uint64_t addr, uint64_t ".set pop\n" : : "r"(p), "r"(valhi), "r"(vallo) : "$8", "$9", "memory"); - nlm_restore_kx(sr); + nlm_restore_flags(sr); } #endif @@ -246,7 +245,7 @@ nlm_load_word_daddr(uint64_t addr) addrhi = addr >> 32; addrlo = addr & 0xffffffff; - sr = nlm_enable_kx(); + sr = nlm_save_flags_kx(); __asm__ __volatile__( ".set push\n\t" ".set mips64\n\t" @@ -259,7 +258,7 @@ nlm_load_word_daddr(uint64_t addr) : "=r"(val) : "r"(addrhi), "r"(addrlo) : "$8", "$9"); - nlm_restore_kx(sr); + nlm_restore_flags(sr); return val; @@ -273,7 +272,7 @@ nlm_store_word_daddr(uint64_t addr, uint addrhi = addr >> 32; addrlo = addr & 0xffffffff; - sr = nlm_enable_kx(); + sr = nlm_save_flags_kx(); __asm__ __volatile__( ".set push\n\t" ".set mips64\n\t" @@ -285,7 +284,7 @@ nlm_store_word_daddr(uint64_t addr, uint ".set pop\n" : : "r"(val), "r"(addrhi), "r"(addrlo) : "$8", "$9", "memory"); - nlm_restore_kx(sr); + nlm_restore_flags(sr); } static inline uint64_t @@ -297,7 +296,7 @@ nlm_load_dword_daddr(uint64_t addr) addrh = addr >> 32; addrl = addr & 0xffffffff; - sr = nlm_enable_kx(); + sr = nlm_save_flags_kx(); __asm__ __volatile__( ".set push\n\t" ".set mips64\n\t" @@ -312,7 +311,7 @@ nlm_load_dword_daddr(uint64_t addr) : "=r"(valh), "=r"(vall) : "r"(addrh), "r"(addrl) : "$8", "$9"); - nlm_restore_kx(sr); + nlm_restore_flags(sr); return ((uint64_t)valh << 32) | vall; } @@ -328,7 +327,7 @@ nlm_store_dword_daddr(uint64_t addr, uin valh = val >> 32; vall = val & 0xffffffff; - sr = nlm_enable_kx(); + sr = nlm_save_flags_kx(); __asm__ __volatile__( ".set push\n\t" ".set mips64\n\t" @@ -344,7 +343,7 @@ nlm_store_dword_daddr(uint64_t addr, uin ".set pop\n" : : "r"(valh), "r"(vall), "r"(addrh), "r"(addrl) : "$8", "$9", "memory"); - nlm_restore_kx(sr); + nlm_restore_flags(sr); } #endif /* __mips_n64 */ Modified: user/jchandra/mips-xlp-support/sys/mips/nlm/hal/pic.h ============================================================================== --- user/jchandra/mips-xlp-support/sys/mips/nlm/hal/pic.h Sat Sep 3 12:59:05 2011 (r225367) +++ user/jchandra/mips-xlp-support/sys/mips/nlm/hal/pic.h Sat Sep 3 15:34:18 2011 (r225368) @@ -38,17 +38,17 @@ #define PIC_CTRL_ICI 19 /* ICI interrupt timeout enable */ #define PIC_CTRL_ITE 18 /* interrupt timeout enable */ #define PIC_CTRL_STE 10 /* system timer interrupt enable */ -#define PIC_CTRL_WWR1 8 /* watchdog timer 1 wraparound count for reset */ -#define PIC_CTRL_WWR0 6 /* watchdog timer 0 wraparound count for reset */ -#define PIC_CTRL_WWN1 4 /* watchdog timer 1 wraparound count for NMI */ -#define PIC_CTRL_WWN0 2 /* watchdog timer 0 wraparound count for NMI */ +#define PIC_CTRL_WWR1 8 /* watchdog 1 wraparound count for reset */ +#define PIC_CTRL_WWR0 6 /* watchdog 0 wraparound count for reset */ +#define PIC_CTRL_WWN1 4 /* watchdog 1 wraparound count for NMI */ +#define PIC_CTRL_WWN0 2 /* watchdog 0 wraparound count for NMI */ #define PIC_CTRL_WTE 0 /* watchdog timer enable */ /* PIC Status register defines */ -#define PIC_ICI_STATUS 33 /* ICI interrupt timeout interrupt status */ -#define PIC_ITE_STATUS 32 /* interrupt timeout interrupt status */ +#define PIC_ICI_STATUS 33 /* ICI interrupt timeout status */ +#define PIC_ITE_STATUS 32 /* interrupt timeout status */ #define PIC_STS_STATUS 4 /* System timer interrupt status */ -#define PIC_WNS_STATUS 2 /* NMI interrupt status for watchdog timers */ +#define PIC_WNS_STATUS 2 /* NMI status for watchdog timers */ #define PIC_WIS_STATUS 0 /* Interrupt status for watchdog timers */ /* PIC IPI control register offsets */ @@ -341,8 +341,8 @@ static inline void nlm_pic_write_irt_direct(uint64_t base, int irt_num, int en, int nmi, int sch, int vec, int cpu) { - nlm_pic_write_irt(base, irt_num, en, nmi, sch, vec, 1, - (cpu >> 4), /* thread group */ + nlm_pic_write_irt(base, irt_num, en, nmi, sch, vec, 1, + (cpu >> 4), /* thread group */ 1 << (cpu & 0xf)); /* thread mask */ } @@ -358,7 +358,7 @@ nlm_pic_write_timer(uint64_t base, int t nlm_write_pic_reg(base, PIC_TIMER_COUNT(timer), value); } -static __inline__ void +static inline void nlm_pic_set_timer(uint64_t base, int timer, uint64_t value, int irq, int cpu) { uint64_t pic_ctrl = nlm_read_pic_reg(base, PIC_CTRL); @@ -366,7 +366,7 @@ nlm_pic_set_timer(uint64_t base, int tim en = (irq > 0); nlm_write_pic_reg(base, PIC_TIMER_MAXVAL(timer), value); - nlm_pic_write_irt_direct(base, PIC_IRT_TIMER_INDEX(timer), + nlm_pic_write_irt_direct(base, PIC_IRT_TIMER_INDEX(timer), en, 0, 0, irq, cpu); /* enable the timer */ Modified: user/jchandra/mips-xlp-support/sys/mips/nlm/intern_dev.c ============================================================================== --- user/jchandra/mips-xlp-support/sys/mips/nlm/intern_dev.c Sat Sep 3 12:59:05 2011 (r225367) +++ user/jchandra/mips-xlp-support/sys/mips/nlm/intern_dev.c Sat Sep 3 15:34:18 2011 (r225368) @@ -45,7 +45,7 @@ __FBSDID("$FreeBSD$"); #include -#include +#include #include static int nlm_soc_pci_probe(device_t dev); Modified: user/jchandra/mips-xlp-support/sys/mips/nlm/intr_machdep.c ============================================================================== --- user/jchandra/mips-xlp-support/sys/mips/nlm/intr_machdep.c Sat Sep 3 12:59:05 2011 (r225367) +++ user/jchandra/mips-xlp-support/sys/mips/nlm/intr_machdep.c Sat Sep 3 15:34:18 2011 (r225368) @@ -46,9 +46,8 @@ __FBSDID("$FreeBSD: head/sys/mips/rmi/in #include #include -#include +#include #include -#include #include #include #include Modified: user/jchandra/mips-xlp-support/sys/mips/nlm/uart_bus_xlp_iodi.c ============================================================================== --- user/jchandra/mips-xlp-support/sys/mips/nlm/uart_bus_xlp_iodi.c Sat Sep 3 12:59:05 2011 (r225367) +++ user/jchandra/mips-xlp-support/sys/mips/nlm/uart_bus_xlp_iodi.c Sat Sep 3 15:34:18 2011 (r225368) @@ -42,7 +42,7 @@ __FBSDID("$FreeBSD: head/sys/mips/rmi/ua #include #include -#include +#include #include #include Modified: user/jchandra/mips-xlp-support/sys/mips/nlm/uart_cpu_xlp.c ============================================================================== --- user/jchandra/mips-xlp-support/sys/mips/nlm/uart_cpu_xlp.c Sat Sep 3 12:59:05 2011 (r225367) +++ user/jchandra/mips-xlp-support/sys/mips/nlm/uart_cpu_xlp.c Sat Sep 3 15:34:18 2011 (r225368) @@ -53,7 +53,7 @@ __FBSDID("$FreeBSD: head/sys/mips/rmi/ua #include #include -#include +#include #include #include Modified: user/jchandra/mips-xlp-support/sys/mips/nlm/uart_pci_xlp.c ============================================================================== --- user/jchandra/mips-xlp-support/sys/mips/nlm/uart_pci_xlp.c Sat Sep 3 12:59:05 2011 (r225367) +++ user/jchandra/mips-xlp-support/sys/mips/nlm/uart_pci_xlp.c Sat Sep 3 15:34:18 2011 (r225368) @@ -42,7 +42,7 @@ __FBSDID("$FreeBSD$"); #include -#include +#include #include #include Modified: user/jchandra/mips-xlp-support/sys/mips/nlm/usb_init.c ============================================================================== --- user/jchandra/mips-xlp-support/sys/mips/nlm/usb_init.c Sat Sep 3 12:59:05 2011 (r225367) +++ user/jchandra/mips-xlp-support/sys/mips/nlm/usb_init.c Sat Sep 3 15:34:18 2011 (r225368) @@ -34,7 +34,7 @@ __FBSDID("$FreeBSD: head/sys/mips/rmi/fm #include #include -#include +#include #include #include #include Modified: user/jchandra/mips-xlp-support/sys/mips/nlm/xlp_machdep.c ============================================================================== --- user/jchandra/mips-xlp-support/sys/mips/nlm/xlp_machdep.c Sat Sep 3 12:59:05 2011 (r225367) +++ user/jchandra/mips-xlp-support/sys/mips/nlm/xlp_machdep.c Sat Sep 3 15:34:18 2011 (r225368) @@ -71,9 +71,8 @@ __FBSDID("$FreeBSD: head/sys/mips/rmi/xl #include #include -#include +#include #include -#include #include #include #include Modified: user/jchandra/mips-xlp-support/sys/mips/nlm/xlp_pci.c ============================================================================== --- user/jchandra/mips-xlp-support/sys/mips/nlm/xlp_pci.c Sat Sep 3 12:59:05 2011 (r225367) +++ user/jchandra/mips-xlp-support/sys/mips/nlm/xlp_pci.c Sat Sep 3 15:34:18 2011 (r225368) @@ -56,12 +56,11 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include #include #include #include #include -#include #include #include #include