From owner-svn-src-user@FreeBSD.ORG Sun Aug 21 00:48: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 A95BE106564A; Sun, 21 Aug 2011 00:48:03 +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 99C498FC0C; Sun, 21 Aug 2011 00:48:03 +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 p7L0m3jR075429; Sun, 21 Aug 2011 00:48:03 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7L0m3AK075427; Sun, 21 Aug 2011 00:48:03 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108210048.p7L0m3AK075427@svn.freebsd.org> From: Gabor Kovesdan Date: Sun, 21 Aug 2011 00:48:03 +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: r225050 - 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: Sun, 21 Aug 2011 00:48:03 -0000 Author: gabor Date: Sun Aug 21 00:48:03 2011 New Revision: 225050 URL: http://svn.freebsd.org/changeset/base/225050 Log: - Support REG_PEND for fast matching functions Modified: user/gabor/tre-integration/include/fastmatch.h Modified: user/gabor/tre-integration/include/fastmatch.h ============================================================================== --- user/gabor/tre-integration/include/fastmatch.h Sat Aug 20 21:26:35 2011 (r225049) +++ user/gabor/tre-integration/include/fastmatch.h Sun Aug 21 00:48:03 2011 (r225050) @@ -20,6 +20,7 @@ typedef struct { int defBc; hashtable *qsBc_table; int *sbmGs; + const char *re_endp; /* flags */ bool bol; From owner-svn-src-user@FreeBSD.ORG Sun Aug 21 00:51:43 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 360C9106566C; Sun, 21 Aug 2011 00:51:43 +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 244788FC08; Sun, 21 Aug 2011 00:51:43 +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 p7L0phJ5075631; Sun, 21 Aug 2011 00:51:43 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7L0phFm075623; Sun, 21 Aug 2011 00:51:43 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108210051.p7L0phFm075623@svn.freebsd.org> From: Gabor Kovesdan Date: Sun, 21 Aug 2011 00:51:43 +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: r225051 - in user/gabor/tre-integration: contrib/tre/lib include lib/libc/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: Sun, 21 Aug 2011 00:51:43 -0000 Author: gabor Date: Sun Aug 21 00:51:42 2011 New Revision: 225051 URL: http://svn.freebsd.org/changeset/base/225051 Log: - Add the heuristic matching code. Currently * it only supports BRE * the heuristic construction is limited because the fast matching algorithm is also limited and only allows simple heuristic patterns * it has a bug and fills in incorrectly the matching offsets - Even with the above limitations, some searches only require half of the time with BSD grep. Added: user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.c (contents, props changed) user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.h (contents, props changed) Modified: user/gabor/tre-integration/contrib/tre/lib/regcomp.c user/gabor/tre-integration/contrib/tre/lib/regexec.c user/gabor/tre-integration/contrib/tre/lib/tre-compile.c user/gabor/tre-integration/include/regex.h user/gabor/tre-integration/lib/libc/regex/Makefile.inc Modified: user/gabor/tre-integration/contrib/tre/lib/regcomp.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/regcomp.c Sun Aug 21 00:48:03 2011 (r225050) +++ user/gabor/tre-integration/contrib/tre/lib/regcomp.c Sun Aug 21 00:51:42 2011 (r225051) @@ -16,6 +16,7 @@ #include #include "tre-fastmatch.h" +#include "tre-heuristic.h" #include "tre-internal.h" #include "xmalloc.h" @@ -143,7 +144,15 @@ void tre_regfree(regex_t *preg) { if (preg->shortcut != NULL) - tre_free_fast(preg->shortcut); + { + tre_free_fast(preg->shortcut); + xfree(preg->shortcut); + } + if (preg->heur != NULL) + { + tre_free_heur(preg->heur); + xfree(preg->heur); + } tre_free(preg); } Modified: user/gabor/tre-integration/contrib/tre/lib/regexec.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/regexec.c Sun Aug 21 00:48:03 2011 (r225050) +++ user/gabor/tre-integration/contrib/tre/lib/regexec.c Sun Aug 21 00:51:42 2011 (r225051) @@ -46,6 +46,7 @@ char *alloca (); #include #include "tre-fastmatch.h" +#include "tre-heuristic.h" #include "tre-internal.h" #include "xmalloc.h" @@ -151,14 +152,53 @@ tre_have_approx(const regex_t *preg) static int tre_match(const tre_tnfa_t *tnfa, const void *string, size_t len, tre_str_type_t type, size_t nmatch, regmatch_t pmatch[], - int eflags, fastmatch_t *shortcut) + int eflags, fastmatch_t *shortcut, heur_t *heur) { reg_errcode_t status; int *tags = NULL, eo; - /* Check if we can cheat with a faster algorithm */ + /* Check if we can cheat with a faster algorithm. */ if (shortcut != NULL) - return tre_match_fast(shortcut, string, len, type, nmatch, pmatch, eflags); + return tre_match_fast(shortcut, string, len, type, nmatch, + pmatch, eflags); + + /* Check if we have a heuristic to speed up the search. */ + if (heur != NULL) + { + int ret; + size_t st = 0, j; + const char *data_byte = string; + const tre_char_t *data_wide = string; + const void *tmp; + + /* Look for the beginning of possibly matching text. */ + ret = tre_match_fast(heur->start, string, len, type, nmatch, + pmatch, eflags); + if (ret != REG_OK) + return ret; + st = pmatch[0].rm_so; + j = pmatch[0].rm_eo; + string = (type == STR_WIDE) ? (void *)&data_wide[st] : + (void *)&data_byte[st]; + + /* When having a fixed-length pattern there is only one heuristic. */ + if (heur->end == NULL) + return tre_match(tnfa, string, + heur->prefix ? (len - st) : (j - st), + type, nmatch, pmatch, eflags, NULL, NULL); + + tmp = (type == STR_WIDE) ? (void *)&data_wide[j] : + (void *)&data_byte[j]; + + /* Look for the end of possibly matching text. */ + ret = tre_match_fast(heur->end, tmp, len - j, type, nmatch, + pmatch, eflags); + if (ret != REG_OK) + return ret; + + return tre_match(tnfa, string, pmatch[0].rm_eo + j - st, + type, nmatch, pmatch, eflags, NULL, NULL); + } if (tnfa->num_tags > 0 && nmatch > 0) { @@ -227,7 +267,7 @@ tre_match(const tre_tnfa_t *tnfa, const if ((long long)pmatch[0].rm_eo - pmatch[0].rm_so < 0) \ return REG_NOMATCH; \ ret = tre_match(tnfa, &str[offset], slen, type, nmatch, \ - pmatch, eflags, preg->shortcut); \ + pmatch, eflags, preg->shortcut, preg->heur); \ for (unsigned i = 0; (i == 0) || (!(eflags & REG_NOSUB) && \ (i < nmatch)); i++) \ { \ @@ -248,7 +288,7 @@ tre_regnexec(const regex_t *preg, const ADJUST_OFFSETS else return tre_match(tnfa, str, len, type, nmatch, pmatch, eflags, - preg->shortcut); + preg->shortcut, preg->heur); } int @@ -272,7 +312,7 @@ tre_regwnexec(const regex_t *preg, const ADJUST_OFFSETS else return tre_match(tnfa, str, len, STR_WIDE, nmatch, pmatch, eflags, - preg->shortcut); + preg->shortcut, preg->heur); } int @@ -290,7 +330,7 @@ tre_reguexec(const regex_t *preg, const { tre_tnfa_t *tnfa = (void *)preg->TRE_REGEX_T_FIELD; return tre_match(tnfa, str, (unsigned)-1, STR_USER, nmatch, pmatch, eflags, - preg->shortcut); + preg->shortcut, preg->heur); } @@ -314,7 +354,7 @@ tre_match_approx(const tre_tnfa_t *tnfa, if (params.max_cost == 0 && !tnfa->have_approx && !(eflags & REG_APPROX_MATCHER)) return tre_match(tnfa, string, len, type, match->nmatch, match->pmatch, - eflags, NULL); + eflags, NULL, NULL); /* Back references are not supported by the approximate matcher. */ if (tnfa->have_backrefs) Modified: user/gabor/tre-integration/contrib/tre/lib/tre-compile.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-compile.c Sun Aug 21 00:48:03 2011 (r225050) +++ user/gabor/tre-integration/contrib/tre/lib/tre-compile.c Sun Aug 21 00:51:42 2011 (r225051) @@ -22,6 +22,7 @@ #include #include "tre-fastmatch.h" +#include "tre-heuristic.h" #include "tre-internal.h" #include "tre-mem.h" #include "tre-stack.h" @@ -1867,6 +1868,7 @@ tre_compile(regex_t *preg, const tre_cha reg_errcode_t errcode; tre_mem_t mem; fastmatch_t *shortcut; + heur_t *heur; /* Parse context. */ tre_parse_ctx_t parse_ctx; @@ -2179,6 +2181,28 @@ tre_compile(regex_t *preg, const tre_cha xfree(offs); preg->TRE_REGEX_T_FIELD = (void *)tnfa; + + /* + * If we reach here, the regex is parsed and legal. Now we try to construct + * a heuristic to speed up matching. + */ + + heur = xmalloc(sizeof(heur_t)); + if (!heur) + { + errcode = REG_ESPACE; + goto error_exit; + } + + ret = tre_compile_heur(heur, regex, n, cflags); + if (ret != REG_OK) + { + xfree(heur); + preg->heur = NULL; + } + else + preg->heur = heur; + return REG_OK; error_exit: Added: user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.c Sun Aug 21 00:51:42 2011 (r225051) @@ -0,0 +1,271 @@ +/*- + * Copyright (C) 2011 Gabor Kovesdan + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif /* HAVE_CONFIG_H */ +#include +#include +#include +#ifdef TRE_WCHAR +#include +#endif + +#include "tre-fastmatch.h" +#include "tre-heuristic.h" +#include "tre-internal.h" +#include "xmalloc.h" + +/* + * Parses bracket expression seeking to the end of the enclosed text. + * The parameters are the opening (oe) and closing elements (ce). + * Can handle nested bracket expressions. + */ +#define PARSE_UNIT(oe, ce) \ + { \ + int level = 0; \ + \ + while (i < len) \ + { \ + if (regex[i] == TRE_CHAR(oe)) \ + level++; \ + else if (regex[i] == TRE_CHAR(ce)) \ + level--; \ + if (level == 0) \ + break; \ + i++; \ + } \ + } + +/* + * Finishes a segment (fixed-length text fragment). + */ +#define END_SEGMENT \ + do \ + { \ + st = i + 1; \ + escaped = false; \ + goto end_segment; \ + } while (0); + +/* + * Parses a regular expression and constructs a heuristic in heur_t and + * returns REG_OK if successful or the corresponding error code if a + * heuristic cannot be constructed. + */ +int +tre_compile_heur(heur_t *h, const tre_char_t *regex, size_t len, int cflags) +{ + tre_char_t *heur; + int st = 0, pos = 0; + bool escaped = false; + int errcode, ret; + + /* XXX: only basic regexes are supported. */ + if (cflags & REG_EXTENDED) + return REG_BADPAT; + + /* Temporary space, len will be enough. */ + heur = xmalloc(len); + if (!heur) + return REG_ESPACE; + + memset(h, 0, sizeof(*h)); + + while (true) + { + + /* + * Process the pattern char-by-char. + * + * i: position in regex + * st: start offset of current segment (fixed-length fragment) + * to be processed + * pos: current position (and length) in the temporary space where + * we copy the current segment + */ + for (int i = st; i < len; i++) + { + switch (regex[i]) + { + + /* Bracketed expression is substituted with a dot. */ + case TRE_CHAR('['): + PARSE_UNIT('[', ']'); + heur[pos++] = TRE_CHAR('.'); + continue; + + /* + * If a repetition marker, erases the repeting character + * and terminates the segment. + * Otherwise just terminates the segment (XXX). + */ + case TRE_CHAR('{'): + PARSE_UNIT('{', '}'); + if (escaped) + pos--; + END_SEGMENT; + break; + + /* + * Terminates the current segment whether a subexpression + * marker or not. (XXX) + */ + case TRE_CHAR('('): + PARSE_UNIT('(', ')'); + END_SEGMENT; + break; + + /* + * Sets escaped flag. + * Escaped escape terminates current segment. (XXX) + */ + case TRE_CHAR('\\'): + if (escaped) + END_SEGMENT; + escaped = !escaped; + continue; + + /* + * If not the first character, erases the last character + * and terminates the segment. + * Otherwise heuristic construction fails. (XXX) + */ + case TRE_CHAR('*'): + if (i != 0) + { + pos--; + END_SEGMENT; + } + else + goto badpat1; + break; + + /* + * If a backreference (escaped digit), terminates segment. + * Otherwise adds current character to the current segment + * by copying it to the temporary space. + */ + default: + if (escaped && tre_isdigit(regex[i])) + END_SEGMENT; + heur[pos++] = regex[i]; + continue; + } + } + + /* We are done with the pattern if we got here. */ + st = len; + +end_segment: + + /* If it is not initialized yet, then we just got the first segment. */ + if (h->start == NULL) + { + + /* + * An empty or a one-char prefix segment is useless, + * better to just fail. + */ + if (pos <= 1) + { + errcode = REG_BADPAT; + goto badpat1; + } + + h->start = xmalloc(sizeof(fastmatch_t)); + if (!h->start) + { + errcode = REG_ESPACE; + goto space1; + } + + ret = tre_compile_fast(h->start, heur, pos, 0); + if (ret != REG_OK) + { + errcode = REG_BADPAT; + goto badpat2; + } + } + + /* + * If true, this is the last segment. We do not care about the + * middle ones. + */ + else if (st == len) + { + + /* If empty, we only have a prefix heuristic. */ + if (pos == 0) + { + h->prefix = true; + errcode = REG_OK; + goto ok; + } + + h->end = xmalloc(sizeof(fastmatch_t)); + if (!h->end) + { + errcode = REG_ESPACE; + goto space2; + } + + ret = tre_compile_fast(h->end, heur, pos, 0); + if (ret != REG_OK) + { + xfree(h->end); + h->prefix = true; + } + errcode = REG_OK; + goto ok; + } + + /* Just drop middle segments by overwriting the temporary space. */ + pos = 0; + } + +badpat2: +space2: + if (h->start != NULL) + xfree(h->start); +badpat1: +space1: +ok: + xfree(heur); + return errcode; +} + +/* + * Frees a heuristic. + */ +void +tre_free_heur(heur_t *h) +{ + if (h->start != NULL) + xfree(h->start); + if (h->end != NULL) + xfree(h->end); +} Added: user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.h Sun Aug 21 00:51:42 2011 (r225051) @@ -0,0 +1,21 @@ +#ifndef TRE_HEURISTIC_H +#define TRE_HEURISTIC_H 1 + +#include +#include + +#include "tre-fastmatch.h" +#include "tre-internal.h" + +typedef struct { + fastmatch_t *start; + fastmatch_t *end; + bool prefix; +} heur_t; + + +extern int tre_compile_heur(heur_t *h, const tre_char_t *regex, + size_t len, int cflags); +extern void tre_free_heur(heur_t *h); + +#endif /* TRE_HEURISTIC_H */ Modified: user/gabor/tre-integration/include/regex.h ============================================================================== --- user/gabor/tre-integration/include/regex.h Sun Aug 21 00:48:03 2011 (r225050) +++ user/gabor/tre-integration/include/regex.h Sun Aug 21 00:51:42 2011 (r225051) @@ -67,6 +67,7 @@ typedef struct { size_t re_nsub; /* Number of parenthesized subexpressions. */ void *value; /* For internal use only. */ void *shortcut; /* For internal use only. */ + void *heur; /* For internal use only. */ const char *re_endp; } regex_t; Modified: user/gabor/tre-integration/lib/libc/regex/Makefile.inc ============================================================================== --- user/gabor/tre-integration/lib/libc/regex/Makefile.inc Sun Aug 21 00:48:03 2011 (r225050) +++ user/gabor/tre-integration/lib/libc/regex/Makefile.inc Sun Aug 21 00:51:42 2011 (r225051) @@ -6,7 +6,7 @@ CFLAGS+=-DHAVE_CONFIG_H -DTRE_LIBC_BUILD -I${.CURDIR}/../../contrib/tre SRCS+= fastmatch.c hashtable.c regcomp.c regerror.c regexec.c tre-ast.c \ - tre-compile.c tre-fastmatch.c tre-match-approx.c \ + tre-compile.c tre-fastmatch.c tre-heuristic.c tre-match-approx.c \ tre-match-backtrack.c tre-match-parallel.c tre-mem.c tre-parse.c \ tre-stack.c xmalloc.c From owner-svn-src-user@FreeBSD.ORG Sun Aug 21 02:35:11 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 DDE01106564A; Sun, 21 Aug 2011 02:35: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 C40FC8FC0A; Sun, 21 Aug 2011 02:35: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 p7L2ZA2R078702; Sun, 21 Aug 2011 02:35:10 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7L2ZAH4078698; Sun, 21 Aug 2011 02:35:10 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108210235.p7L2ZAH4078698@svn.freebsd.org> From: Adrian Chadd Date: Sun, 21 Aug 2011 02:35: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: r225052 - 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, 21 Aug 2011 02:35:11 -0000 Author: adrian Date: Sun Aug 21 02:35:10 2011 New Revision: 225052 URL: http://svn.freebsd.org/changeset/base/225052 Log: Add some very basic TX aggregation statistics via a sysctl. 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 Sun Aug 21 00:51:42 2011 (r225051) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_sysctl.c Sun Aug 21 02:35:10 2011 (r225052) @@ -299,6 +299,35 @@ ath_sysctl_rfkill(SYSCTL_HANDLER_ARGS) } static int +ath_sysctl_txagg(SYSCTL_HANDLER_ARGS) +{ + struct ath_softc *sc = arg1; + int i, param = 0; + int error; + + error = sysctl_handle_int(oidp, ¶m, 0, req); + if (error || !req->newptr) + return error; + + if (param != 1) + return 0; + + printf("aggr single packet: %d\n", + sc->sc_stats.tx_aggr.aggr_single_pkt); + printf("aggr non-baw packet: %d\n", + sc->sc_stats.tx_aggr.aggr_nonbaw_pkt); + printf("aggr aggregate packet: %d\n", + sc->sc_stats.tx_aggr.aggr_aggr_pkt); + for (i = 0; i < 64; i++) { + printf("%2d: %10d ", i, sc->sc_stats.tx_aggr.aggr_pkts[i]); + if (i % 4 == 3) + printf("\n"); + } + printf("\n"); + return 0; +} + +static int ath_sysctl_rfsilent(SYSCTL_HANDLER_ARGS) { struct ath_softc *sc = arg1; @@ -465,6 +494,11 @@ ath_sysctlattach(struct ath_softc *sc) "rfkill", CTLTYPE_INT | CTLFLAG_RW, sc, 0, ath_sysctl_rfkill, "I", "enable/disable RF kill switch"); } + + SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, + "txagg", CTLTYPE_INT | CTLFLAG_RW, sc, 0, + ath_sysctl_txagg, "I", ""); + if (ath_hal_hasintmit(ah)) { SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "intmit", CTLTYPE_INT | CTLFLAG_RW, sc, 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.c Sun Aug 21 00:51:42 2011 (r225051) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Sun Aug 21 02:35:10 2011 (r225052) @@ -2876,6 +2876,8 @@ 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++; + /* Queue the packet; continue */ goto queuepkt; } @@ -2915,12 +2917,14 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft ath_tx_chaindesclist(sc, bf); ath_hal_clr11n_aggr(sc->sc_ah, bf->bf_desc); ath_tx_set_ratectrl(sc, ni, bf); + sc->sc_stats.tx_aggr.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]++; /* Set rate 1, 2, 3 to 0 for aggregate frames */ bf->bf_state.bfs_rc[1].rix = Modified: user/adrian/if_ath_tx/sys/dev/ath/if_athioctl.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_athioctl.h Sun Aug 21 00:51:42 2011 (r225051) +++ user/adrian/if_ath_tx/sys/dev/ath/if_athioctl.h Sun Aug 21 02:35:10 2011 (r225052) @@ -35,6 +35,13 @@ #ifndef _DEV_ATH_ATHIOCTL_H #define _DEV_ATH_ATHIOCTL_H +struct ath_tx_aggr_stats { + u_int32_t aggr_pkts[64]; + u_int32_t aggr_single_pkt; + u_int32_t aggr_nonbaw_pkt; + u_int32_t aggr_aggr_pkt; +}; + struct ath_stats { u_int32_t ast_watchdog; /* device reset by watchdog */ u_int32_t ast_hardware; /* fatal hardware error interrupts */ @@ -138,6 +145,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; + struct ath_tx_aggr_stats tx_aggr; u_int32_t ast_pad[9]; }; From owner-svn-src-user@FreeBSD.ORG Sun Aug 21 02:40:43 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 49CE1106564A; Sun, 21 Aug 2011 02:40:43 +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 3A0EC8FC12; Sun, 21 Aug 2011 02:40:43 +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 p7L2ehLw078886; Sun, 21 Aug 2011 02:40:43 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7L2ehTb078884; Sun, 21 Aug 2011 02:40:43 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108210240.p7L2ehTb078884@svn.freebsd.org> From: Adrian Chadd Date: Sun, 21 Aug 2011 02:40:43 +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: r225053 - 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, 21 Aug 2011 02:40:43 -0000 Author: adrian Date: Sun Aug 21 02:40:42 2011 New Revision: 225053 URL: http://svn.freebsd.org/changeset/base/225053 Log: Document off-channel TX handling. 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 Sun Aug 21 02:35:10 2011 (r225052) +++ user/adrian/if_ath_tx/sys/dev/ath/README Sun Aug 21 02:40:42 2011 (r225053) @@ -51,6 +51,9 @@ Things to debug! Things that need doing! +* When off-channel, aggregate traffic should stay queued, but raw + frames (eg probes) should be sent? + * Handle channel/mode changes which shouldn't flush packets in the software queue (and the packets in the hardware queue that can be recovered after TX DMA is stopped..) From owner-svn-src-user@FreeBSD.ORG Sun Aug 21 03:12:08 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 845CE106566B; Sun, 21 Aug 2011 03:12:08 +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 5AB198FC0C; Sun, 21 Aug 2011 03:12:08 +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 p7L3C8as080118; Sun, 21 Aug 2011 03:12:08 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7L3C8sL080114; Sun, 21 Aug 2011 03:12:08 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108210312.p7L3C8sL080114@svn.freebsd.org> From: Adrian Chadd Date: Sun, 21 Aug 2011 03:12:08 +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: r225054 - 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, 21 Aug 2011 03:12:08 -0000 Author: adrian Date: Sun Aug 21 03:12:07 2011 New Revision: 225054 URL: http://svn.freebsd.org/changeset/base/225054 Log: * Add some more stats * Add a comment that I need to add some locking 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 Sun Aug 21 02:40:42 2011 (r225053) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_sysctl.c Sun Aug 21 03:12:07 2011 (r225054) @@ -314,6 +314,8 @@ ath_sysctl_txagg(SYSCTL_HANDLER_ARGS) printf("aggr single packet: %d\n", sc->sc_stats.tx_aggr.aggr_single_pkt); + printf("aggr single packet w/ BAW closed: %d\n", + sc->sc_stats.tx_aggr.aggr_baw_closed_single_pkt); printf("aggr non-baw packet: %d\n", sc->sc_stats.tx_aggr.aggr_nonbaw_pkt); printf("aggr aggregate packet: %d\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 Sun Aug 21 02:40:42 2011 (r225053) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Sun Aug 21 03:12:07 2011 (r225054) @@ -2917,7 +2917,10 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft ath_tx_chaindesclist(sc, bf); ath_hal_clr11n_aggr(sc->sc_ah, bf->bf_desc); ath_tx_set_ratectrl(sc, ni, bf); - sc->sc_stats.tx_aggr.aggr_single_pkt++; + if (status == ATH_AGGR_BAW_CLOSED) + sc->sc_stats.tx_aggr.aggr_baw_closed_single_pkt++; + else + sc->sc_stats.tx_aggr.aggr_single_pkt++; } else { DPRINTF(sc, ATH_DEBUG_SW_TX_AGGR, "%s: multi-frame aggregate: %d frames, length %d\n", @@ -3043,6 +3046,11 @@ 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) Modified: user/adrian/if_ath_tx/sys/dev/ath/if_athioctl.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_athioctl.h Sun Aug 21 02:40:42 2011 (r225053) +++ user/adrian/if_ath_tx/sys/dev/ath/if_athioctl.h Sun Aug 21 03:12:07 2011 (r225054) @@ -40,6 +40,7 @@ struct ath_tx_aggr_stats { u_int32_t aggr_single_pkt; u_int32_t aggr_nonbaw_pkt; u_int32_t aggr_aggr_pkt; + u_int32_t aggr_baw_closed_single_pkt; }; struct ath_stats { From owner-svn-src-user@FreeBSD.ORG Sun Aug 21 03:48:08 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 0B3B7106564A; Sun, 21 Aug 2011 03:48:08 +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 D5C3F8FC08; Sun, 21 Aug 2011 03:48: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 p7L3m7GR081189; Sun, 21 Aug 2011 03:48:07 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7L3m7U6081187; Sun, 21 Aug 2011 03:48:07 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108210348.p7L3m7U6081187@svn.freebsd.org> From: Adrian Chadd Date: Sun, 21 Aug 2011 03:48: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: r225055 - 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, 21 Aug 2011 03:48:08 -0000 Author: adrian Date: Sun Aug 21 03:48:07 2011 New Revision: 225055 URL: http://svn.freebsd.org/changeset/base/225055 Log: * Correctly lock stuff during ath_txq_sched() * Add the aggregate packet counter * For now, don't try to queue further work to a TXQ if there's more than two packets queued to it. This is an attempt to give the aggregation code more time to form aggregates. 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 21 03:12:07 2011 (r225054) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Sun Aug 21 03:48:07 2011 (r225055) @@ -2928,6 +2928,7 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft 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++; /* Set rate 1, 2, 3 to 0 for aggregate frames */ bf->bf_state.bfs_rc[1].rix = @@ -2961,6 +2962,10 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft /* Punt to txq */ ATH_TXQ_LOCK(txq); ath_tx_handoff(sc, txq, bf); + if (txq->axq_depth > ATH_AGGR_MIN_QDEPTH) { + ATH_TXQ_UNLOCK(txq); + break; + } ATH_TXQ_UNLOCK(txq); /* @@ -3058,11 +3063,26 @@ ath_txq_sched(struct ath_softc *sc, stru struct ath_tid *atid, *next; /* + * 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 buffersj, not + * XXX normal ones. + */ + ATH_TXQ_LOCK(txq); + if (txq->axq_depth >= ATH_AGGR_MIN_QDEPTH) { + ATH_TXQ_UNLOCK(txq); + return; + } + + /* * For now, let's not worry about QoS, fair-scheduling * 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. @@ -3077,7 +3097,7 @@ ath_txq_sched(struct ath_softc *sc, stru ATH_TXQ_UNLOCK(atid); ATH_TXQ_LOCK(txq); ath_tx_tid_unsched(sc, atid->an, atid->tid); - ATH_TXQ_UNLOCK(txq); + //ATH_TXQ_UNLOCK(txq); continue; } ATH_TXQ_UNLOCK(atid); @@ -3090,8 +3110,13 @@ ath_txq_sched(struct ath_softc *sc, stru ATH_TXQ_LOCK(txq); if (atid->axq_depth == 0) ath_tx_tid_unsched(sc, atid->an, atid->tid); - ATH_TXQ_UNLOCK(txq); + if (txq->axq_depth > ATH_AGGR_MIN_QDEPTH) { + //ATH_TXQ_UNLOCK(txq); + break; + } + //ATH_TXQ_UNLOCK(txq); } + ATH_TXQ_UNLOCK(txq); } /* From owner-svn-src-user@FreeBSD.ORG Sun Aug 21 10:05:40 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 6DCF9106566C; Sun, 21 Aug 2011 10:05:40 +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 545C78FC12; Sun, 21 Aug 2011 10:05:40 +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 p7LA5euc099390; Sun, 21 Aug 2011 10:05:40 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7LA5eXT099385; Sun, 21 Aug 2011 10:05:40 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108211005.p7LA5eXT099385@svn.freebsd.org> From: Adrian Chadd Date: Sun, 21 Aug 2011 10:05:40 +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: r225056 - 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, 21 Aug 2011 10:05:40 -0000 Author: adrian Date: Sun Aug 21 10:05:39 2011 New Revision: 225056 URL: http://svn.freebsd.org/changeset/base/225056 Log: * Fix a duplicate call to the TX scheduling task queue function; this doesn't improve network throughput but it decreases CPU usage. * Add a reference to the softc from the hardware txq; this was intended to be used by a per-txq task scheduler function; I may end up removing this later on. * add a txq field to ath_tx_sched_proc_sched(), but as taskqueue_enable doesn't take an argument, we can't use it just yet. Again, the current way of kicking the TXQ scheduler code may not be the best way to do it - ie, calling taskqueue_enable() on every single TX'ed packet is likely not helping ;-) Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath.c user/adrian/if_ath_tx/sys/dev/ath/if_ath_misc.h 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.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Sun Aug 21 03:48:07 2011 (r225055) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Sun Aug 21 10:05:39 2011 (r225056) @@ -3899,6 +3899,7 @@ ath_txq_init(struct ath_softc *sc, struc txq->axq_depth = 0; txq->axq_intrcnt = 0; txq->axq_link = NULL; + txq->axq_softc = sc; TAILQ_INIT(&txq->axq_q); TAILQ_INIT(&txq->axq_tidq); ATH_TXQ_LOCK_INIT(sc, txq); @@ -4428,7 +4429,7 @@ ath_tx_sched_proc(void *arg, int npendin * Schedule a TXQ scheduling task to occur. */ void -ath_tx_sched_proc_sched(struct ath_softc *sc) +ath_tx_sched_proc_sched(struct ath_softc *sc, struct ath_txq *txq) { taskqueue_enqueue(sc->sc_tq, &sc->sc_txschedtask); } Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_misc.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_misc.h Sun Aug 21 03:48:07 2011 (r225055) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_misc.h Sun Aug 21 10:05:39 2011 (r225056) @@ -59,6 +59,6 @@ extern void ath_tx_default_comp(struct a int fail); extern void ath_tx_freebuf(struct ath_softc *sc, struct ath_buf *bf, int status); -extern void ath_tx_sched_proc_sched(struct ath_softc *sc); +extern void ath_tx_sched_proc_sched(struct ath_softc *sc, struct ath_txq *txq); #endif 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 21 03:48:07 2011 (r225055) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Sun Aug 21 10:05:39 2011 (r225056) @@ -1329,7 +1329,7 @@ ath_tx_start(struct ath_softc *sc, struc ath_tx_swq(sc, ni, txq, bf); /* Schedule a TX scheduler task call to occur */ - ath_tx_sched_proc_sched(sc); + ath_tx_sched_proc_sched(sc, txq); } #else /* @@ -1554,6 +1554,9 @@ ath_tx_raw_start(struct ath_softc *sc, s else { /* Queue to software queue */ ath_tx_swq(sc, ni, sc->sc_ac2q[pri], bf); + + /* Schedule a TX scheduler task call to occur */ + ath_tx_sched_proc_sched(sc, sc->sc_ac2q[pri]); } return 0; @@ -1616,14 +1619,6 @@ ath_raw_xmit(struct ieee80211_node *ni, ifp->if_opackets++; sc->sc_stats.ast_tx_raw++; - /* - * This kicks off a TX packet scheduler task, - * pushing packet scheduling out of this thread - * and into a separate context. This will (hopefully) - * simplify locking/contention in the long run. - */ - ath_tx_sched_proc_sched(sc); - return 0; bad2: ATH_TXBUF_LOCK(sc); @@ -2062,7 +2057,7 @@ ath_tx_tid_resume(struct ath_softc *sc, ath_tx_tid_sched(sc, tid->an, tid->tid); ATH_TXQ_UNLOCK(txq); - ath_tx_sched_proc_sched(sc); + ath_tx_sched_proc_sched(sc, txq); } /* 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 21 03:48:07 2011 (r225055) +++ user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Sun Aug 21 10:05:39 2011 (r225056) @@ -263,6 +263,7 @@ struct ath_descdma { * hardware queue). */ struct ath_txq { + struct ath_softc *axq_softc; /* Needed for scheduling */ u_int axq_qnum; /* hardware q number */ #define ATH_TXQ_SWQ (HAL_NUM_TX_QUEUES+1) /* qnum for s/w only queue */ u_int axq_ac; /* WME AC */ From owner-svn-src-user@FreeBSD.ORG Sun Aug 21 14:43: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 4D175106566B; Sun, 21 Aug 2011 14:43:20 +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 3CC098FC1B; Sun, 21 Aug 2011 14:43: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 p7LEhKDQ007800; Sun, 21 Aug 2011 14:43:20 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7LEhKwW007798; Sun, 21 Aug 2011 14:43:20 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108211443.p7LEhKwW007798@svn.freebsd.org> From: Adrian Chadd Date: Sun, 21 Aug 2011 14:43:20 +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: r225058 - 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, 21 Aug 2011 14:43:20 -0000 Author: adrian Date: Sun Aug 21 14:43:19 2011 New Revision: 225058 URL: http://svn.freebsd.org/changeset/base/225058 Log: add a twiddle to dump the current queue depth. It's not -that- useful with live traffic as the queue depth changes too frequently, so.. Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_sysctl.c 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 Sun Aug 21 10:52:50 2011 (r225057) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_sysctl.c Sun Aug 21 14:43:19 2011 (r225058) @@ -326,6 +326,14 @@ ath_sysctl_txagg(SYSCTL_HANDLER_ARGS) printf("\n"); } printf("\n"); + + for (i = 0; i < HAL_NUM_TX_QUEUES; i++) { + if (ATH_TXQ_SETUP(sc, i)) { + printf("HW TXQ %d: axq_depth=%d\n", + i, sc->sc_txq[i].axq_depth); + } + } + return 0; } From owner-svn-src-user@FreeBSD.ORG Sun Aug 21 14:44:45 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 5B7FF1065676; Sun, 21 Aug 2011 14:44:45 +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 4B2E58FC14; Sun, 21 Aug 2011 14:44: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 p7LEijtS007892; Sun, 21 Aug 2011 14:44:45 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7LEijf4007890; Sun, 21 Aug 2011 14:44:45 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108211444.p7LEijf4007890@svn.freebsd.org> From: Adrian Chadd Date: Sun, 21 Aug 2011 14:44: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: r225059 - 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, 21 Aug 2011 14:44:45 -0000 Author: adrian Date: Sun Aug 21 14:44:44 2011 New Revision: 225059 URL: http://svn.freebsd.org/changeset/base/225059 Log: Clear bf_comp, not all frame setups currently set this to something, so packets were getting the -previous- completion handler. tsk. 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 Sun Aug 21 14:43:19 2011 (r225058) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Sun Aug 21 14:44:44 2011 (r225059) @@ -1878,6 +1878,7 @@ _ath_getbuf_locked(struct ath_softc *sc) "out of xmit buffers" : "xmit buffer busy"); } bf->bf_next = NULL; /* XXX just to be sure */ + bf->bf_comp = NULL; /* XXX again, just to be sure */ return bf; } From owner-svn-src-user@FreeBSD.ORG Sun Aug 21 16:11: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 EFB381065675; Sun, 21 Aug 2011 16:11: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 DE7468FC14; Sun, 21 Aug 2011 16:11: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 p7LGBvpc010536; Sun, 21 Aug 2011 16:11:57 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7LGBvPM010534; Sun, 21 Aug 2011 16:11:57 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108211611.p7LGBvPM010534@svn.freebsd.org> From: Adrian Chadd Date: Sun, 21 Aug 2011 16:11: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: r225060 - 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, 21 Aug 2011 16:11:58 -0000 Author: adrian Date: Sun Aug 21 16:11:57 2011 New Revision: 225060 URL: http://svn.freebsd.org/changeset/base/225060 Log: Always request an interrupt when doing aggregation; let the interrupt coelescence support mitigate interrupt load. 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 21 14:44:44 2011 (r225059) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Sun Aug 21 16:11:57 2011 (r225060) @@ -423,7 +423,7 @@ ath_tx_setds_11n(struct ath_softc *sc, s ath_hal_setupfirsttxdesc(sc->sc_ah, bf_first->bf_desc, bf_first->bf_state.bfs_al, - bf_first->bf_state.bfs_flags, + bf_first->bf_state.bfs_flags | HAL_TXDESC_INTREQ, bf_first->bf_state.bfs_txpower, bf_first->bf_state.bfs_txrate0, bf_first->bf_state.bfs_try0, From owner-svn-src-user@FreeBSD.ORG Sun Aug 21 16:27: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 87C32106566C; Sun, 21 Aug 2011 16:27:59 +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 754438FC0C; Sun, 21 Aug 2011 16:27: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 p7LGRxSh011021; Sun, 21 Aug 2011 16:27:59 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7LGRx2K011017; Sun, 21 Aug 2011 16:27:59 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108211627.p7LGRx2K011017@svn.freebsd.org> From: Adrian Chadd Date: Sun, 21 Aug 2011 16:27: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: r225061 - 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, 21 Aug 2011 16:27:59 -0000 Author: adrian Date: Sun Aug 21 16:27:59 2011 New Revision: 225061 URL: http://svn.freebsd.org/changeset/base/225061 Log: Begin adding some support framework needed to try and get a handle on aggregation throughput. The main problem at the present moment is that - at least for userspace applications (ie iperf) generating traffic - the scheduler is called too often (and likely calling taskqueue_enabled on each queued frame is .. bad, I'll deal with that mistake of mine later) and thus the software queue isn't "large" enough for aggregates to be formed. This is noticable for UDP, where over 80% of the frames are sent as single frames rather than being aggregated, limiting performance on my MIPS boards to < 30mbit. The eventual aim is to only queue enough frames to the hardware TX queue to keep the MAC busy sending said frames, rather than filling its TXQ with as many frames as possible. As long as packets are queued faster than individual frames are scheduled, the software queue will back up and give the aggregation logic something to work with. * Add a couple of schedule calls which kick along the TID scheduling after a completion handler has occured. These aren't strictly needed here (as the call is only needed when frames are added onto the TID queue) but they'll be needed later on when the TID scheduling is delayed to "encourage" aggregates. * Add hwq_depth to the TID state, which tracks how many buffers are queued to the hardware. Aggregate buffers are (for now) counted as a single buffer. Since completion functions can (unfortunately) be called from both the ath task and when flushing/draining a queue (ie, from various other contexts), lock access to it. * modify the aggregate queue function to limit scheduling aggregate frames based on how many hardware-queued frames from this TID are queued. This may flip back to being based on the hardware queue after some more testing. 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 Sun Aug 21 16:11:57 2011 (r225060) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Sun Aug 21 16:27:59 2011 (r225061) @@ -431,8 +431,6 @@ ath_tx_setds_11n(struct ath_softc *sc, s bf_first->bf_state.bfs_ctsrate, bf_first->bf_state.bfs_ctsduration); - - /* * Setup the last descriptor in the list. * bf_prev points to the last; bf is NULL here. @@ -1957,7 +1955,6 @@ ath_tx_swq(struct ath_softc *sc, struct ATH_TXQ_INSERT_TAIL(atid, bf, bf_list); ATH_TXQ_UNLOCK(atid); - /* Mark the given tid as having packets to dequeue */ ATH_TXQ_LOCK(txq); ath_tx_tid_sched(sc, an, tid); ATH_TXQ_UNLOCK(txq); @@ -2001,6 +1998,7 @@ ath_tx_tid_init(struct ath_softc *sc, st atid->baw_head = atid->baw_tail = 0; atid->paused = 0; atid->sched = 0; + atid->hwq_depth = 0; atid->cleanup_inprogress = 0; if (i == IEEE80211_NONQOS_TID) atid->ac = WME_AC_BE; @@ -2180,8 +2178,21 @@ ath_tx_tid_cleanup(struct ath_softc *sc, void ath_tx_normal_comp(struct ath_softc *sc, struct ath_buf *bf, int fail) { - DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: bf=%p: fail=%d\n", __func__, - bf, fail); + struct ieee80211_node *ni = bf->bf_node; + struct ath_node *an = ATH_NODE(ni); + int tid = bf->bf_state.bfs_tid; + struct ath_tid *atid = &an->an_tid[tid]; + + 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); + ath_tx_default_comp(sc, bf, fail); } @@ -2384,8 +2395,13 @@ ath_tx_aggr_retry_unaggr(struct ath_soft } #endif + ATH_TXQ_LOCK(sc->sc_ac2q[atid->ac]); + ath_tx_tid_sched(sc, an, atid->tid); + ATH_TXQ_UNLOCK(sc->sc_ac2q[atid->ac]); + /* Free buffer, bf is free after this call */ ath_tx_default_comp(sc, bf, 0); + return; } @@ -2542,9 +2558,6 @@ ath_tx_comp_aggr_error(struct ath_softc } ATH_TXQ_UNLOCK(tid); - /* - * Kick the queue - */ ATH_TXQ_LOCK(txq); ath_tx_tid_sched(sc, an, tid->tid); ATH_TXQ_UNLOCK(txq); @@ -2611,7 +2624,15 @@ ath_tx_aggr_comp_aggr(struct ath_softc * struct ath_txq *txq = sc->sc_ac2q[atid->ac]; int np = 0; - DPRINTF(sc, ATH_DEBUG_SW_TX_AGGR, "%s: called\n", __func__); + DPRINTF(sc, ATH_DEBUG_SW_TX_AGGR, "%s: called; hwq_depth=%d\n", + __func__, 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); /* * Punt cleanup to the relevant function, not our problem now @@ -2728,10 +2749,6 @@ ath_tx_aggr_comp_aggr(struct ath_softc * } ATH_TXQ_UNLOCK(atid); - /* - * Kick the queue if it needs it - * XXX too aggressive? - */ ATH_TXQ_LOCK(txq); ath_tx_tid_sched(sc, an, atid->tid); ATH_TXQ_UNLOCK(txq); @@ -2758,8 +2775,20 @@ ath_tx_aggr_comp_unaggr(struct ath_softc if (tid == IEEE80211_NONQOS_TID) device_printf(sc->sc_dev, "%s: TID=16!\n", __func__); - DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: bf=%p: tid=%d\n", - __func__, bf, bf->bf_state.bfs_tid); + + 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); + + ATH_TXQ_LOCK(sc->sc_ac2q[atid->ac]); + ath_tx_tid_sched(sc, an, atid->tid); + ATH_TXQ_UNLOCK(sc->sc_ac2q[atid->ac]); /* * If a cleanup is in progress, punt to comp_cleanup; @@ -2957,19 +2986,22 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft /* Punt to txq */ ATH_TXQ_LOCK(txq); ath_tx_handoff(sc, txq, bf); - if (txq->axq_depth > ATH_AGGR_MIN_QDEPTH) { - ATH_TXQ_UNLOCK(txq); + ATH_TXQ_UNLOCK(txq); + + /* Track outstanding buffer count to hardware */ + /* aggregates are "one" buffer */ + ATH_TXQ_LOCK(atid); + atid->hwq_depth++; + if (atid->hwq_depth >= ATH_AGGR_SCHED_LOW) { + ATH_TXQ_UNLOCK(atid); break; } - ATH_TXQ_UNLOCK(txq); + ATH_TXQ_UNLOCK(atid); /* * Break out if ath_tx_form_aggr() indicated * there can't be any further progress (eg BAW is full.) * Checking for an empty txq is done above. - * - * Later on, enforce ATH_AGGR_MIN_QDEPTH to try and - * keep aggregation flowing. */ if (status == ATH_AGGR_BAW_CLOSED) break; @@ -3033,6 +3065,12 @@ ath_tx_tid_hw_queue_norm(struct ath_soft ath_tx_chaindesclist(sc, bf); ath_tx_set_ratectrl(sc, ni, bf); + /* 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); @@ -3061,7 +3099,7 @@ ath_txq_sched(struct ath_softc *sc, stru * 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 buffersj, not + * XXX TODO: only do this based on AMPDU buffers, not * XXX normal ones. */ ATH_TXQ_LOCK(txq); @@ -3105,7 +3143,9 @@ ath_txq_sched(struct ath_softc *sc, stru ATH_TXQ_LOCK(txq); if (atid->axq_depth == 0) ath_tx_tid_unsched(sc, atid->an, atid->tid); - if (txq->axq_depth > ATH_AGGR_MIN_QDEPTH) { + + /* Give the software queue time to aggregate more packets */ + if (txq->axq_depth >= ATH_AGGR_MIN_QDEPTH) { //ATH_TXQ_UNLOCK(txq); break; } 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 21 16:11:57 2011 (r225060) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.h Sun Aug 21 16:27:59 2011 (r225061) @@ -49,6 +49,19 @@ #define ATH_AGGR_MIN_QDEPTH 2 /* + * Watermark for scheduling TIDs in order to maximise aggregation. + * + * If hwq_depth is greater than this, don't schedule the TID + * for packet scheduling - the hardware is already busy servicing + * this TID. + * + * If hwq_depth is less than this, schedule the TID for packet + * scheduling in the completion handler. + */ +#define ATH_AGGR_SCHED_HIGH 4 +#define ATH_AGGR_SCHED_LOW 2 + +/* * return whether a bit at index _n in bitmap _bm is set * _sz is the size of the bitmap */ 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 21 16:11:57 2011 (r225060) +++ user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Sun Aug 21 16:27:59 2011 (r225061) @@ -98,6 +98,7 @@ struct ath_tid { struct ath_node *an; /* pointer to parent */ int tid; /* tid */ int ac; /* which AC gets this trafic */ + int hwq_depth; /* how many buffers are on HW */ /* * Entry on the ath_txq; when there's traffic From owner-svn-src-user@FreeBSD.ORG Sun Aug 21 16:33: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 5B711106566C; Sun, 21 Aug 2011 16:33: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 3FCBC8FC15; Sun, 21 Aug 2011 16:33: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 p7LGXZpY011227; Sun, 21 Aug 2011 16:33:35 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7LGXZtF011225; Sun, 21 Aug 2011 16:33:35 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108211633.p7LGXZtF011225@svn.freebsd.org> From: Adrian Chadd Date: Sun, 21 Aug 2011 16:33: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: r225062 - 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, 21 Aug 2011 16:33:35 -0000 Author: adrian Date: Sun Aug 21 16:33:34 2011 New Revision: 225062 URL: http://svn.freebsd.org/changeset/base/225062 Log: Update my todo/notes list. 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 Sun Aug 21 16:27:59 2011 (r225061) +++ user/adrian/if_ath_tx/sys/dev/ath/README Sun Aug 21 16:33:34 2011 (r225062) @@ -1,4 +1,5 @@ Things to debug! +---------------- * Write something in ath_tx_default_comp() that ensures the buffer is unlinked (ie, not part of an aggregate) @@ -10,22 +11,29 @@ Things to debug! * Am I losing an ath_buf in the hardware TX queue code? Ie, are they not ever queued? + - No * Is it some missing sequence numbers? ie, is addto_baw being called with sequence numbers out of order, or "gaps" in the sequence numbers? - -* Scheduler issues - add some statistics to track how many packets are going - out as aggregates (looks like around 84%) -and- what the distribution of - aggregate packets is like. Abuse a histogram - will only send up to 64 - aggregate packets at once, so track: - - + single packet returned from ath_tx_form_aggr() - + single packet with no BAW returned from ath_tx_form_aggr() - + single packet with non HT rate - + aggregate packets (ie, how many times were aggregates sent) - + aggregate sub-frame count histogram, 2->64 sub-frames - - I can't help but think we're sending very small aggregates. + - Yes, if the frame is queued via ath_tx_swq() but it's never submitted + to the hardware; it never gets added to the BAW. + - The solution here is to modify the whole TX aggr pipeline to allocate + seqno's just as a frame is to be queued to the hardware the first time, + rather than in ath_tx_start(). + +* Although it's a nice idea to run completion handlers in the ath task + context (making scheduling and completion occur in a mutually exclusive + setup within the same taskqueue), the fact that nodes can be flushed, + drained and freed from -outside- that context puts a spanner in the works. + Ideally, the only time completion handlers should be called from outside + that context is when the node is being destroyed. Otherwise, we're going + to have to lock -everything-. + + So, when going over the drain/flush/free code to see what's going on, + please consider making -node free- the only time these completion + functions are called from outside the ath taskqueue task, and ensure + that they don't trample over any state which is going to cause contention + (and thus need to be locked.) * The RX side (AR9160, FreeBSD) seems to lock up from time to time, with stuck beacons and RXORN interrupts (ie, RX FIFO overflows.) Why? @@ -48,7 +56,6 @@ Things to debug! * for interface -cleanup-, ? * drain? - Things that need doing! * When off-channel, aggregate traffic should stay queued, but raw @@ -308,3 +315,18 @@ trap+8a4 (?,?,?,?) ra 80376fec sp c7bf9d MipsUserGenException+10c (?,?,?,40818e20) ra 0 sp c7bf9e80 sz 0 pid 1510 +* Scheduler issues - add some statistics to track how many packets are going + out as aggregates (looks like around 84%) -and- what the distribution of + aggregate packets is like. Abuse a histogram - will only send up to 64 + aggregate packets at once, so track: + + + single packet returned from ath_tx_form_aggr() + + single packet with no BAW returned from ath_tx_form_aggr() + + single packet with non HT rate + + aggregate packets (ie, how many times were aggregates sent) + + aggregate sub-frame count histogram, 2->64 sub-frames + + I can't help but think we're sending very small aggregates. + + - done - sysctl dev.ath.X.txagg=1 + From owner-svn-src-user@FreeBSD.ORG Sun Aug 21 16:38: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 972011065672; Sun, 21 Aug 2011 16:38: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 85C048FC08; Sun, 21 Aug 2011 16:38: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 p7LGcGwY011391; Sun, 21 Aug 2011 16:38:16 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7LGcGF0011389; Sun, 21 Aug 2011 16:38:16 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108211638.p7LGcGF0011389@svn.freebsd.org> From: Adrian Chadd Date: Sun, 21 Aug 2011 16:38: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: r225063 - 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, 21 Aug 2011 16:38:16 -0000 Author: adrian Date: Sun Aug 21 16:38:16 2011 New Revision: 225063 URL: http://svn.freebsd.org/changeset/base/225063 Log: Update 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 Sun Aug 21 16:33:34 2011 (r225062) +++ user/adrian/if_ath_tx/sys/dev/ath/README Sun Aug 21 16:38:16 2011 (r225063) @@ -117,22 +117,17 @@ Things that need doing! * Software retransmit when aggregation is enabled + Whether doing A-MPDU or not + - done + Support rate updates and lookup on a retry; maybe a slower rate is needed? + - not yet done, but would need changes to the way the rate decisions + are made * 20<->2040 mode change? + part of this project or not? + right now packets are simply flushed; why not just re-prod them into the software TXQ ? -* Delimiter calculation? is it right? - port ath_compute_num_delims() - -* rate series packet duration calculation - it needs to be the entire - aggregate length for aggregates, not the individual frame? - (carrier code uses the whole aggregate, what about newma/fusion/ath9k?) - newma does this too (check ath_pkt_duration()) - * nodes w/ a lower BA window size; try to fill it in ath_tx_form_aggr() ? * teach ath_rate about aggregate completion? @@ -330,3 +325,13 @@ pid 1510 - done - sysctl dev.ath.X.txagg=1 +* Delimiter calculation? is it right? + port ath_compute_num_delims() + - done + +* rate series packet duration calculation - it needs to be the entire + aggregate length for aggregates, not the individual frame? + (carrier code uses the whole aggregate, what about newma/fusion/ath9k?) + newma does this too (check ath_pkt_duration()) + - done - it uses the whole aggregate length, incl. delimiters. + From owner-svn-src-user@FreeBSD.ORG Mon Aug 22 04:33: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 8C0101065670; Mon, 22 Aug 2011 04:33: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 630638FC0C; Mon, 22 Aug 2011 04:33: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 p7M4XnGw033544; Mon, 22 Aug 2011 04:33:49 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7M4XneM033541; Mon, 22 Aug 2011 04:33:49 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108220433.p7M4XneM033541@svn.freebsd.org> From: Adrian Chadd Date: Mon, 22 Aug 2011 04:33: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: r225070 - 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, 22 Aug 2011 04:33:49 -0000 Author: adrian Date: Mon Aug 22 04:33:49 2011 New Revision: 225070 URL: http://svn.freebsd.org/changeset/base/225070 Log: Move the TX schedule taskqueue call out of the per-packet path and into ath_start(), and call it just once if any packets were queued. Add it back in the ath_tx_raw_xmit() path, so raw packets still cause the software TX scheduler to be queued to the ath task queue. This improves TCP performance a bit because of reduced CPU use, but UDP still isn't being aggregated. Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath.c user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Mon Aug 22 03:10:29 2011 (r225069) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Mon Aug 22 04:33:49 2011 (r225070) @@ -1908,6 +1908,7 @@ ath_start(struct ifnet *ifp) struct ath_buf *bf; struct mbuf *m, *next; ath_bufhead frags; + int tx = 0; if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0 || sc->sc_invalid) return; @@ -1944,6 +1945,7 @@ ath_start(struct ifnet *ifp) goto bad; } ifp->if_opackets++; + tx = 1; nextfrag: /* * Pass the frame to the h/w for transmission. @@ -1994,6 +1996,13 @@ 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 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 22 03:10:29 2011 (r225069) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Mon Aug 22 04:33:49 2011 (r225070) @@ -1325,9 +1325,6 @@ ath_tx_start(struct ath_softc *sc, struc } else { /* add to software queue */ ath_tx_swq(sc, ni, txq, bf); - - /* Schedule a TX scheduler task call to occur */ - ath_tx_sched_proc_sched(sc, txq); } #else /* @@ -1552,9 +1549,6 @@ ath_tx_raw_start(struct ath_softc *sc, s else { /* Queue to software queue */ ath_tx_swq(sc, ni, sc->sc_ac2q[pri], bf); - - /* Schedule a TX scheduler task call to occur */ - ath_tx_sched_proc_sched(sc, sc->sc_ac2q[pri]); } return 0; @@ -1617,6 +1611,9 @@ 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); From owner-svn-src-user@FreeBSD.ORG Mon Aug 22 05:03: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 05110106564A; Mon, 22 Aug 2011 05:03: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 E9D878FC12; Mon, 22 Aug 2011 05:03:43 +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 p7M53hl4034440; Mon, 22 Aug 2011 05:03:43 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7M53hqG034438; Mon, 22 Aug 2011 05:03:43 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108220503.p7M53hqG034438@svn.freebsd.org> From: Adrian Chadd Date: Mon, 22 Aug 2011 05:03:43 +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: r225071 - 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, 22 Aug 2011 05:03:44 -0000 Author: adrian Date: Mon Aug 22 05:03:43 2011 New Revision: 225071 URL: http://svn.freebsd.org/changeset/base/225071 Log: The completion handler "fail" flag is 0 or 1 - -1 is what was being passed to the net80211 completion routine. 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 Mon Aug 22 04:33:49 2011 (r225070) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Mon Aug 22 05:03:43 2011 (r225071) @@ -2112,7 +2112,7 @@ ath_tx_tid_free_pkts(struct ath_softc *s } ATH_TXQ_REMOVE(atid, bf, bf_list); ATH_TXQ_UNLOCK(atid); - ath_tx_default_comp(sc, bf, -1); + ath_tx_default_comp(sc, bf, 0); } } From owner-svn-src-user@FreeBSD.ORG Mon Aug 22 06:25: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 25F931065673; Mon, 22 Aug 2011 06:25: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 433428FC1F; Mon, 22 Aug 2011 06:25: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 p7M6P2oF037059; Mon, 22 Aug 2011 06:25:02 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7M6P2Mm037053; Mon, 22 Aug 2011 06:25:02 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108220625.p7M6P2Mm037053@svn.freebsd.org> From: Adrian Chadd Date: Mon, 22 Aug 2011 06:25: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: r225072 - in 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: Mon, 22 Aug 2011 06:25:10 -0000 Author: adrian Date: Mon Aug 22 06:25:01 2011 New Revision: 225072 URL: http://svn.freebsd.org/changeset/base/225072 Log: Do some reasonably major surgery to the way TX rates are calculated and completed, as part of providing the rate control code with accurate information about aggregate packet completions. Since the aggregate completion function has no idea how many frames have succeeded or failed until -after- the ath_buf list has been walked, compared against the Blockack bitmap (and buffers have been completed), we need to keep a variety of the state somewhere. So we can't just pass in an ath_buf into the completion code - it has likely already been freed before the rate update call is made. Also, the framelength for an aggregate is the aggregate itself, not the length of the first frame. The specifics: * add a 'ratecode' field to ath_rc_series, storing the ratecode decision; * update ratecode in ath_tx_rate_fill_rcflags(), also taking into account whether the ath_buf has the short preamble bit set; * modify the sample ath_tx_rate_complete() function to take a copy of the ath_rc_series, along with a framelength * if a buffer doesn't have a completion handler, manually call the rate control code * if a buffer -does- have a completion handler, leave calling the rate control code up to that. The things to do: * Actually teach ath_rate_sample about the packet error rate when TX'ing aggregates. That's next. * Becuase the rate lookup is done before the aggregate is formed, we can't query the rate control code with the length of the aggregate. It's a chicken and egg problem - we can't form aggregates until we know what the rate selection is (as that's used to enforce the 4ms frame max duration) and delimiter density. So for now, it'll just use the size of the first frame in the list when making a rate decision, and I'll worry about delaying the rate control lookup later. Modified: user/adrian/if_ath_tx/sys/dev/ath/ath_rate/sample/sample.c user/adrian/if_ath_tx/sys/dev/ath/if_ath.c user/adrian/if_ath_tx/sys/dev/ath/if_ath_misc.h 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_athrate.h 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 Mon Aug 22 05:03:43 2011 (r225071) +++ user/adrian/if_ath_tx/sys/dev/ath/ath_rate/sample/sample.c Mon Aug 22 06:25:01 2011 (r225072) @@ -594,21 +594,20 @@ badrate(struct ifnet *ifp, int series, i void ath_rate_tx_complete(struct ath_softc *sc, struct ath_node *an, - const struct ath_buf *bf) + const struct ath_rc_series *rc, const struct ath_tx_status *ts, + int frame_size, int nframes, int nbad) { struct ifnet *ifp = sc->sc_ifp; struct ieee80211com *ic = ifp->if_l2com; struct sample_node *sn = ATH_NODE_SAMPLE(an); - const struct ath_tx_status *ts = &bf->bf_status.ds_txstat; - const struct ath_desc *ds0 = &bf->bf_desc[0]; - int final_rix, short_tries, long_tries, frame_size; + int final_rix, short_tries, long_tries; const HAL_RATE_TABLE *rt = sc->sc_currates; int mrr; final_rix = rt->rateCodeToIndex[ts->ts_rate]; short_tries = ts->ts_shortretry; long_tries = ts->ts_longretry + 1; - frame_size = ds0->ds_ctl0 & 0x0fff; /* low-order 12 bits of ds_ctl0 */ + if (frame_size == 0) /* NB: should not happen */ frame_size = 1500; @@ -645,18 +644,12 @@ ath_rate_tx_complete(struct ath_softc *s 0, 0, short_tries, long_tries, ts->ts_status); } else { - int hwrates[4], tries[4], rix[4]; int finalTSIdx = ts->ts_finaltsi; int i; /* * Process intermediate rates that failed. */ - ath_hal_gettxcompletionrates(sc->sc_ah, ds0, hwrates, tries); - - for (i = 0; i < 4; i++) { - rix[i] = rt->rateCodeToIndex[hwrates[i]]; - } IEEE80211_NOTE(an->an_node.ni_vap, IEEE80211_MSG_RATECTL, &an->an_node, @@ -665,16 +658,21 @@ ath_rate_tx_complete(struct ath_softc *s bin_to_size(size_to_bin(frame_size)), frame_size, finalTSIdx, - long_tries, + long_tries, ts->ts_status ? "FAIL" : "OK", - dot11rate(rt, rix[0]), dot11rate_label(rt, rix[0]), tries[0], - dot11rate(rt, rix[1]), dot11rate_label(rt, rix[1]), tries[1], - dot11rate(rt, rix[2]), dot11rate_label(rt, rix[2]), tries[2], - dot11rate(rt, rix[3]), dot11rate_label(rt, rix[3]), tries[3]); + dot11rate(rt, rc[0].rix), + dot11rate_label(rt, rc[0].rix), rc[0].tries, + dot11rate(rt, rc[1].rix), + dot11rate_label(rt, rc[1].rix), rc[1].tries, + 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); for (i = 0; i < 4; i++) { - if (tries[i] && !IS_RATE_DEFINED(sn, rix[i])) - badrate(ifp, 0, hwrates[i], tries[i], ts->ts_status); + if (rc[i].tries && !IS_RATE_DEFINED(sn, rc[i].rix)) + badrate(ifp, 0, rc[i].ratecode, rc[i].tries, + ts->ts_status); } /* @@ -684,46 +682,46 @@ ath_rate_tx_complete(struct ath_softc *s * sample higher rates 1 try at a time doing so * may unfairly penalize them. */ - if (tries[0]) { - update_stats(sc, an, frame_size, - rix[0], tries[0], - rix[1], tries[1], - rix[2], tries[2], - rix[3], tries[3], - short_tries, long_tries, - long_tries > tries[0]); - long_tries -= tries[0]; + if (rc[0].tries) { + update_stats(sc, an, frame_size, + rc[0].rix, rc[0].tries, + rc[1].rix, rc[1].tries, + rc[2].rix, rc[2].tries, + rc[3].rix, rc[3].tries, + short_tries, long_tries, + long_tries > rc[0].tries); + long_tries -= rc[0].tries; } - if (tries[1] && finalTSIdx > 0) { - update_stats(sc, an, frame_size, - rix[1], tries[1], - rix[2], tries[2], - rix[3], tries[3], - 0, 0, - short_tries, long_tries, + if (rc[1].tries && finalTSIdx > 0) { + update_stats(sc, an, frame_size, + rc[1].rix, rc[1].tries, + rc[2].rix, rc[2].tries, + rc[3].rix, rc[3].tries, + 0, 0, + short_tries, long_tries, ts->ts_status); - long_tries -= tries[1]; + long_tries -= rc[1].tries; } - if (tries[2] && finalTSIdx > 1) { - update_stats(sc, an, frame_size, - rix[2], tries[2], - rix[3], tries[3], + if (rc[2].tries && finalTSIdx > 1) { + update_stats(sc, an, frame_size, + rc[2].rix, rc[2].tries, + rc[3].rix, rc[3].tries, 0, 0, 0, 0, - short_tries, long_tries, + short_tries, long_tries, ts->ts_status); - long_tries -= tries[2]; + long_tries -= rc[2].tries; } - if (tries[3] && finalTSIdx > 2) { - update_stats(sc, an, frame_size, - rix[3], tries[3], + if (rc[3].tries && finalTSIdx > 2) { + update_stats(sc, an, frame_size, + rc[3].rix, rc[3].tries, 0, 0, 0, 0, 0, 0, - short_tries, long_tries, + short_tries, long_tries, ts->ts_status); } } Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath.c ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Mon Aug 22 05:03:43 2011 (r225071) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Mon Aug 22 06:25:01 2011 (r225072) @@ -4206,6 +4206,29 @@ ath_tx_default_comp(struct ath_softc *sc } /* + * Update rate control with the given completion status. + */ +void +ath_tx_update_ratectrl(struct ath_softc *sc, struct ieee80211_node *ni, + struct ath_rc_series *rc, struct ath_tx_status *ts, int frmlen, + int nframes, int nbad) +{ + struct ath_node *an; + + /* Only for unicast frames */ + if (ni == NULL) + return; + + an = ATH_NODE(ni); + + if ((ts->ts_status & HAL_TXERR_FILT) == 0) { + ATH_NODE_LOCK(an); + ath_rate_tx_complete(sc, an, rc, ts, frmlen, nframes, nbad); + ATH_NODE_UNLOCK(an); + } +} + +/* * Process completed xmit descriptors from the specified queue. * Kick the packet scheduler if needed. This can occur from this * particular task. @@ -4283,21 +4306,31 @@ ath_tx_processq(struct ath_softc *sc, st an = ATH_NODE(ni); /* update statistics */ ath_tx_update_stats(sc, ts, bf); + } - /* - * Hand the descriptor to the rate control algorithm. - */ + + /* + * Call the completion handler. + * The completion handler is responsible for + * calling the rate control code. + * + * Frames with no completion handler get the + * rate control code called here. + */ + if (bf->bf_comp == NULL) { if ((ts->ts_status & HAL_TXERR_FILT) == 0 && (bf->bf_txflags & HAL_TXDESC_NOACK) == 0) { - ATH_NODE_LOCK(an); - ath_rate_tx_complete(sc, an, bf); - ATH_NODE_UNLOCK(an); - } - } - - if (bf->bf_comp == NULL) + /* + * XXX assume this isn't an aggregate + * frame. + */ + ath_tx_update_ratectrl(sc, ni, + bf->bf_state.bfs_rc, ts, + bf->bf_state.bfs_pktlen, 1, + (ts->ts_status == 0 ? 0 : 1)); ath_tx_default_comp(sc, bf, 0); - else + } + } else bf->bf_comp(sc, bf, 0); } #ifdef IEEE80211_SUPPORT_SUPERG Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_misc.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_misc.h Mon Aug 22 05:03:43 2011 (r225071) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_misc.h Mon Aug 22 06:25:01 2011 (r225072) @@ -57,6 +57,10 @@ extern int ath_reset(struct ifnet *); extern void ath_tx_draintxq(struct ath_softc *sc, struct ath_txq *txq); extern void ath_tx_default_comp(struct ath_softc *sc, struct ath_buf *bf, int fail); +extern void ath_tx_update_ratectrl(struct ath_softc *sc, + struct ieee80211_node *ni, struct ath_rc_series *rc, + struct ath_tx_status *ts, int frmlen, int nframes, int nbad); + extern void ath_tx_freebuf(struct ath_softc *sc, struct ath_buf *bf, int status); extern void ath_tx_sched_proc_sched(struct ath_softc *sc, struct ath_txq *txq); 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 22 05:03:43 2011 (r225071) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Mon Aug 22 06:25:01 2011 (r225072) @@ -760,26 +760,17 @@ static void ath_tx_set_ratectrl(struct ath_softc *sc, struct ieee80211_node *ni, struct ath_buf *bf) { - const HAL_RATE_TABLE *rt = sc->sc_currates; struct ath_rc_series *rc = bf->bf_state.bfs_rc; - uint8_t rate[4]; - int i; 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 */ - for (i = 0; i < 4; i++) { - rate[i] = rt->info[rc[i].rix].rateCode; - if (bf->bf_state.bfs_shpream) { - rate[i] |= rt->info[rc[i].rix].shortPreamble; - } - } ath_hal_setupxtxdesc(sc->sc_ah, bf->bf_desc - , rate[1], rc[1].tries - , rate[2], rc[2].tries - , rate[3], rc[3].tries + , rc[1].ratecode, rc[1].tries + , rc[2].ratecode, rc[2].tries + , rc[3].ratecode, rc[3].tries ); } } @@ -1129,6 +1120,7 @@ ath_tx_normal_setup(struct ath_softc *sc */ bf->bf_state.bfs_rc[0].rix = rix; bf->bf_state.bfs_rc[0].tries = try0; + bf->bf_state.bfs_rc[0].ratecode = txrate; /* Store the decided rate index values away */ bf->bf_state.bfs_pktlen = pktlen; @@ -1498,17 +1490,21 @@ ath_tx_raw_start(struct ath_softc *sc, s bf->bf_state.bfs_rc[0].rix = ath_tx_findrix(sc, params->ibp_rate0); bf->bf_state.bfs_rc[0].tries = try0; + bf->bf_state.bfs_rc[0].ratecode = txrate; if (ismrr) { - bf->bf_state.bfs_rc[1].rix = - ath_tx_findrix(sc, params->ibp_rate1); - bf->bf_state.bfs_rc[2].rix = - ath_tx_findrix(sc, params->ibp_rate2); - bf->bf_state.bfs_rc[3].rix = - ath_tx_findrix(sc, params->ibp_rate3); + int rix; + rix = ath_tx_findrix(sc, params->ibp_rate1); + bf->bf_state.bfs_rc[1].rix = rix; bf->bf_state.bfs_rc[1].tries = params->ibp_try1; + + rix = ath_tx_findrix(sc, params->ibp_rate2); + bf->bf_state.bfs_rc[2].rix = rix; bf->bf_state.bfs_rc[2].tries = params->ibp_try2; + + rix = ath_tx_findrix(sc, params->ibp_rate3); + bf->bf_state.bfs_rc[3].rix = rix; bf->bf_state.bfs_rc[3].tries = params->ibp_try3; } /* @@ -2179,6 +2175,7 @@ ath_tx_normal_comp(struct ath_softc *sc, struct ath_node *an = ATH_NODE(ni); 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; DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: bf=%p: fail=%d, hwq_depth now %d\n", __func__, bf, fail, atid->hwq_depth - 1); @@ -2190,6 +2187,15 @@ ath_tx_normal_comp(struct ath_softc *sc, __func__, atid->hwq_depth); ATH_TXQ_UNLOCK(atid); + /* + * punt to rate control if we're not being cleaned up + * during a hw queue drain. + */ + if (fail == 0) + ath_tx_update_ratectrl(sc, ni, bf->bf_state.bfs_rc, + ts, bf->bf_state.bfs_pktlen, + 1, (ts->ts_status == 0) ? 0 : 1); + ath_tx_default_comp(sc, bf, fail); } @@ -2514,6 +2520,14 @@ ath_tx_comp_aggr_error(struct ath_softc TAILQ_INIT(&bf_q); + /* + * Update rate control - all frames have failed. + */ + ath_tx_update_ratectrl(sc, ni, bf_first->bf_state.bfs_rc, + &bf_first->bf_status.ds_txstat, + bf_first->bf_state.bfs_al, + bf_first->bf_state.bfs_nframes, bf_first->bf_state.bfs_nframes); + /* Retry all subframes */ bf = bf_first; while (bf) { @@ -2523,9 +2537,6 @@ ath_tx_comp_aggr_error(struct ath_softc bf = bf_next; } - /* Update rate control module about aggregation */ - /* XXX todo */ - #if 0 /* * send bar if we dropped any frames @@ -2579,7 +2590,7 @@ ath_tx_comp_cleanup_aggr(struct ath_soft atid->incomp--; bf_next = bf->bf_next; bf->bf_next = NULL; /* Remove it from the aggr list */ - ath_tx_default_comp(sc, bf, -1); + ath_tx_default_comp(sc, bf, 1); bf = bf_next; } @@ -2609,7 +2620,7 @@ ath_tx_aggr_comp_aggr(struct ath_softc * struct ath_node *an = ATH_NODE(ni); int tid = bf_first->bf_state.bfs_tid; struct ath_tid *atid = &an->an_tid[tid]; - struct ath_tx_status *ts = &bf_first->bf_status.ds_txstat; + struct ath_tx_status ts; struct ieee80211_tx_ampdu *tap; ath_bufhead bf_q; int seq_st, tx_ok; @@ -2619,7 +2630,10 @@ ath_tx_aggr_comp_aggr(struct ath_softc * int ba_index; int drops = 0; struct ath_txq *txq = sc->sc_ac2q[atid->ac]; - int np = 0; + int nframes = 0, nbad = 0; + int pktlen; + /* XXX there's too much on the stack? */ + struct ath_rc_series rc[4]; DPRINTF(sc, ATH_DEBUG_SW_TX_AGGR, "%s: called; hwq_depth=%d\n", __func__, atid->hwq_depth); @@ -2640,9 +2654,16 @@ ath_tx_aggr_comp_aggr(struct ath_softc * } /* + * Take a copy; this may be needed -after- bf_first + * has been completed and freed. + */ + ts = bf_first->bf_status.ds_txstat; + pktlen = bf_first->bf_state.bfs_al; + + /* * handle errors first */ - if (ts->ts_status & HAL_TXERR_XRETRY) { + if (ts.ts_status & HAL_TXERR_XRETRY) { ath_tx_comp_aggr_error(sc, bf_first, atid); return; } @@ -2654,22 +2675,30 @@ ath_tx_aggr_comp_aggr(struct ath_softc * * extract starting sequence and block-ack bitmap */ /* XXX endian-ness of seq_st, ba? */ - seq_st = ts->ts_seqnum; - hasba = !! (ts->ts_flags & HAL_TX_BA); - tx_ok = (ts->ts_status == 0); + seq_st = ts.ts_seqnum; + hasba = !! (ts.ts_flags & HAL_TX_BA); + tx_ok = (ts.ts_status == 0); isaggr = bf_first->bf_state.bfs_aggr; - ba[0] = ts->ts_ba_low; - ba[1] = ts->ts_ba_high; + ba[0] = ts.ts_ba_low; + ba[1] = ts.ts_ba_high; + + /* + * Copy the TX completion status and the rate control + * series from the first descriptor, as it may be freed + * before the rate control code can get its grubby fingers + * into things. + */ + memcpy(rc, bf_first->bf_state.bfs_rc, sizeof(rc)); DPRINTF(sc, ATH_DEBUG_SW_TX_AGGR, "%s: txa_start=%d, tx_ok=%d, status=%.8x, flags=%.8x, isaggr=%d, seq_st=%d, hasba=%d, ba=%.8x, %.8x\n", - __func__, tap->txa_start, tx_ok, ts->ts_status, ts->ts_flags, + __func__, tap->txa_start, tx_ok, ts.ts_status, ts.ts_flags, isaggr, seq_st, hasba, ba[0], ba[1]); /* Occasionally, the MAC sends a tx status for the wrong TID. */ - if (tid != ts->ts_tid) { + if (tid != ts.ts_tid) { device_printf(sc->sc_dev, "%s: tid %d != hw tid %d\n", - __func__, tid, ts->ts_tid); + __func__, tid, ts.ts_tid); tx_ok = 0; } @@ -2683,7 +2712,7 @@ ath_tx_aggr_comp_aggr(struct ath_softc * bf = bf_first; while (bf) { - np++; + nframes++; ba_index = ATH_BA_INDEX(seq_st, SEQNO(bf->bf_state.bfs_seqno)); bf_next = bf->bf_next; bf->bf_next = NULL; /* Remove it from the aggr list */ @@ -2706,16 +2735,21 @@ ath_tx_aggr_comp_aggr(struct ath_softc * ath_tx_default_comp(sc, bf, 0); } else { drops += ath_tx_retry_subframe(sc, bf, &bf_q); + nbad++; } bf = bf_next; } - if (np != bf_first->bf_state.bfs_nframes) + if (nframes != bf_first->bf_state.bfs_nframes) device_printf(sc->sc_dev, "%s: np=%d; nframes=%d\n", - __func__, np, bf_first->bf_state.bfs_nframes); + __func__, nframes, bf_first->bf_state.bfs_nframes); - /* update rate control module about aggregate status */ - /* XXX TODO */ + /* + * Now we know how many frames were bad, call the rate + * control code. + */ + if (fail == 0) + ath_tx_update_ratectrl(sc, ni, rc, &ts, pktlen, nframes, nbad); #if 0 /* @@ -2783,6 +2817,16 @@ ath_tx_aggr_comp_unaggr(struct ath_softc __func__, atid->hwq_depth); ATH_TXQ_UNLOCK(atid); + /* + * Update rate control status here, before we possibly + * punt to retry or cleanup. + */ + if (fail == 0) + ath_tx_update_ratectrl(sc, ni, bf->bf_state.bfs_rc, + &bf->bf_status.ds_txstat, + bf->bf_state.bfs_pktlen, + 1, (ts->ts_status == 0) ? 0 : 1); + ATH_TXQ_LOCK(sc->sc_ac2q[atid->ac]); ath_tx_tid_sched(sc, an, atid->tid); ATH_TXQ_UNLOCK(sc->sc_ac2q[atid->ac]); @@ -2791,7 +2835,7 @@ ath_tx_aggr_comp_unaggr(struct ath_softc * If a cleanup is in progress, punt to comp_cleanup; * rather than handling it here. It's thus their * responsibility to clean up, call the completion - * function in net80211, update rate control, etc. + * function in net80211, etc. */ if (atid->cleanup_inprogress) { ath_tx_comp_cleanup_unaggr(sc, bf); @@ -2955,6 +2999,11 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft 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; 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 22 05:03:43 2011 (r225071) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx_ht.c Mon Aug 22 06:25:01 2011 (r225072) @@ -234,6 +234,17 @@ ath_tx_rate_fill_rcflags(struct ath_soft rate = rt->info[rc[i].rix].rateCode; + /* + * XXX only do this for legacy rates? + */ + if (bf->bf_state.bfs_shpream) + rate |= rt->info[rc[i].rix].shortPreamble; + + /* + * Save this, used by the TX and completion code + */ + rc[i].ratecode = rate; + if (bf->bf_state.bfs_flags & (HAL_TXDESC_RTSENA | HAL_TXDESC_CTSENA)) rc[i].flags |= ATH_RC_RTSCTS_FLAG; Modified: user/adrian/if_ath_tx/sys/dev/ath/if_athrate.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_athrate.h Mon Aug 22 05:03:43 2011 (r225071) +++ user/adrian/if_ath_tx/sys/dev/ath/if_athrate.h Mon Aug 22 06:25:01 2011 (r225072) @@ -87,6 +87,7 @@ void ath_rate_detach(struct ath_ratectrl struct ath_rc_series { uint8_t rix; /* ratetable index, not rate code */ + uint8_t ratecode; /* hardware rate code */ uint8_t tries; uint8_t flags; uint32_t max4msframelen; @@ -141,8 +142,12 @@ void ath_rate_setupxtxdesc(struct ath_so * supplied transmit descriptor. The routine is invoked both * for packets that were successfully sent and for those that * failed (consult the descriptor for details). + * + * For A-MPDU frames, nframes and nbad indicate how many frames + * were in the aggregate, and how many failed. */ struct ath_buf; void ath_rate_tx_complete(struct ath_softc *, struct ath_node *, - const struct ath_buf *); + const struct ath_rc_series *, const struct ath_tx_status *, + int pktlen, int nframes, int nbad); #endif /* _ATH_RATECTRL_H_ */ From owner-svn-src-user@FreeBSD.ORG Mon Aug 22 06:27:45 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 EE3D51065672; Mon, 22 Aug 2011 06:27:45 +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 DED6A8FC0A; Mon, 22 Aug 2011 06:27: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 p7M6RjqO037165; Mon, 22 Aug 2011 06:27:45 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7M6Rjsu037163; Mon, 22 Aug 2011 06:27:45 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108220627.p7M6Rjsu037163@svn.freebsd.org> From: Adrian Chadd Date: Mon, 22 Aug 2011 06:27: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: r225073 - 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, 22 Aug 2011 06:27:46 -0000 Author: adrian Date: Mon Aug 22 06:27:45 2011 New Revision: 225073 URL: http://svn.freebsd.org/changeset/base/225073 Log: Don't call the rate control update code if the frame didn't require an ACK. Since aggregate frames require an ACK, don't worry about doing the checks there. 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 Mon Aug 22 06:25:01 2011 (r225072) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Mon Aug 22 06:27:45 2011 (r225073) @@ -2189,9 +2189,9 @@ ath_tx_normal_comp(struct ath_softc *sc, /* * punt to rate control if we're not being cleaned up - * during a hw queue drain. + * during a hw queue drain and the frame wanted an ACK. */ - if (fail == 0) + if (fail == 0 && ((bf->bf_txflags & HAL_TXDESC_NOACK) == 0)) ath_tx_update_ratectrl(sc, ni, bf->bf_state.bfs_rc, ts, bf->bf_state.bfs_pktlen, 1, (ts->ts_status == 0) ? 0 : 1); @@ -2821,7 +2821,7 @@ ath_tx_aggr_comp_unaggr(struct ath_softc * Update rate control status here, before we possibly * punt to retry or cleanup. */ - if (fail == 0) + if (fail == 0 && ((bf->bf_txflags & HAL_TXDESC_NOACK) == 0)) ath_tx_update_ratectrl(sc, ni, bf->bf_state.bfs_rc, &bf->bf_status.ds_txstat, bf->bf_state.bfs_pktlen, From owner-svn-src-user@FreeBSD.ORG Mon Aug 22 06:33: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 EAA25106564A; Mon, 22 Aug 2011 06:33:03 +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 DB39F8FC12; Mon, 22 Aug 2011 06:33:03 +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 p7M6X31K037425; Mon, 22 Aug 2011 06:33:03 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7M6X3DS037423; Mon, 22 Aug 2011 06:33:03 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108220633.p7M6X3DS037423@svn.freebsd.org> From: Adrian Chadd Date: Mon, 22 Aug 2011 06:33:03 +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: r225074 - 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, 22 Aug 2011 06:33:04 -0000 Author: adrian Date: Mon Aug 22 06:33:03 2011 New Revision: 225074 URL: http://svn.freebsd.org/changeset/base/225074 Log: Update README. 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 Mon Aug 22 06:27:45 2011 (r225073) +++ user/adrian/if_ath_tx/sys/dev/ath/README Mon Aug 22 06:33:03 2011 (r225074) @@ -57,6 +57,7 @@ Things to debug! * drain? Things that need doing! +----------------------- * When off-channel, aggregate traffic should stay queued, but raw frames (eg probes) should be sent? @@ -175,7 +176,30 @@ Hopefully it's something easy * When a node is flushed (but not being deleted) should the BAW also be updated? I don't think it is right now and this could be incorrect. + +Stuff to do to the rate control code +------------------------------------ + +* Teach ath_rate_sample about the packet error rate when TX'ing aggregates + +* Delay rate control lookup? Until the aggregate is being formed or a non-agg + frame is being TXed? + +* .. then we can re-do rate control lookups for retransmits? That should help + with performance issues when bad MCSes have been chosen + +* Tidy up ath_rate_sample and have it use the flags in the ath_rc_series array, + rather than re-calculating what flags are used (ht20/ht40, shortgi, etc.) + + That way if the rate selection logic decides to use something besides what + the node says it supports (eg sending a HT/20 frame to a HT/40 station, + sending long-gi instead of short-GI) then the correct calculations can be + made. + + The rate selection stuff doesn't do this -now-, but it may be useful later. + Fixed issues: +------------- * Recursive TXQ lock on interface destruction: From owner-svn-src-user@FreeBSD.ORG Mon Aug 22 07:55: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 1A474106564A; Mon, 22 Aug 2011 07:55: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 E54998FC0A; Mon, 22 Aug 2011 07:55: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 p7M7tmk4039857; Mon, 22 Aug 2011 07:55:48 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7M7tmGi039853; Mon, 22 Aug 2011 07:55:48 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108220755.p7M7tmGi039853@svn.freebsd.org> From: Adrian Chadd Date: Mon, 22 Aug 2011 07:55: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: r225075 - 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, 22 Aug 2011 07:55:49 -0000 Author: adrian Date: Mon Aug 22 07:55:48 2011 New Revision: 225075 URL: http://svn.freebsd.org/changeset/base/225075 Log: Add parameters to tweak aggregation thresholds. 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_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 Mon Aug 22 06:33:03 2011 (r225074) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Mon Aug 22 07:55:48 2011 (r225075) @@ -1660,6 +1660,13 @@ ath_init(void *arg) sc->sc_beacons = 0; /* + * Initial aggregation settings. + */ + sc->sc_hwq_limit = ATH_AGGR_MIN_QDEPTH; + sc->sc_tid_hwq_lo = ATH_AGGR_SCHED_LOW; + sc->sc_tid_hwq_hi = ATH_AGGR_SCHED_HIGH; + + /* * Setup the hardware after reset: the key cache * is filled as needed and the receive engine is * set going. Frame transmit is handled entirely 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 Mon Aug 22 06:33:03 2011 (r225074) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_sysctl.c Mon Aug 22 07:55:48 2011 (r225075) @@ -518,6 +518,17 @@ ath_sysctlattach(struct ath_softc *sc) SYSCTL_ADD_UINT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, "monpass", CTLFLAG_RW, &sc->sc_monpass, 0, "mask of error frames to pass when monitoring"); + + SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, + "hwq_limit", CTLFLAG_RW, &sc->sc_hwq_limit, 0, + ""); + SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, + "tid_hwq_lo", CTLFLAG_RW, &sc->sc_tid_hwq_lo, 0, + ""); + SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, + "tid_hwq_hi", CTLFLAG_RW, &sc->sc_tid_hwq_hi, 0, + ""); + #ifdef IEEE80211_SUPPORT_TDMA if (ath_hal_macversion(ah) > 0x78) { sc->sc_tdmadbaprep = 2; 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 22 06:33:03 2011 (r225074) +++ user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Mon Aug 22 07:55:48 2011 (r225075) @@ -483,6 +483,20 @@ struct ath_softc { int sc_txchainmask; /* currently configured TX chainmask */ int sc_rxchainmask; /* currently configured RX chainmask */ + /* + * Aggregation twiddles + * + * hwq_limit: how busy to keep the hardware queue - don't schedule + * further packets to the hardware, regardless of the TID + * tid_hwq_lo: how low the per-TID hwq count has to be before the + * TID will be scheduled again + * tid_hwq_hi: how many frames to queue to the HWQ before the TID + * stops being scheduled. + */ + int sc_hwq_limit; + int sc_tid_hwq_lo; + int sc_tid_hwq_hi; + /* DFS related state */ void *sc_dfs; /* Used by an optional DFS module */ int sc_dodfs; /* Whether to enable DFS rx filter bits */ From owner-svn-src-user@FreeBSD.ORG Mon Aug 22 11:22: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 E14951065672; Mon, 22 Aug 2011 11:22: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 D11BA8FC0C; Mon, 22 Aug 2011 11:22: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 p7MBMDYN048535; Mon, 22 Aug 2011 11:22:13 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7MBMDLg048533; Mon, 22 Aug 2011 11:22:13 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108221122.p7MBMDLg048533@svn.freebsd.org> From: Gabor Kovesdan Date: Mon, 22 Aug 2011 11:22:13 +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: r225077 - 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: Mon, 22 Aug 2011 11:22:14 -0000 Author: gabor Date: Mon Aug 22 11:22:13 2011 New Revision: 225077 URL: http://svn.freebsd.org/changeset/base/225077 Log: - Add a general comment Modified: user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.c Modified: user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.c Mon Aug 22 11:18:47 2011 (r225076) +++ user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.c Mon Aug 22 11:22:13 2011 (r225077) @@ -40,6 +40,21 @@ #include "xmalloc.h" /* + * A full regex implementation requires a finite state automaton + * and using an automaton is always about a trade-off. A DFA is + * fast but complex and requires more memory because of the + * high number of states. NFA is slower but simpler and uses less + * memory. Regular expression matching is an underlying common task + * that is required to be efficient but correctness, clean and + * maintanable code are also requirements. So what we do is using + * an NFA implementation and heuristically locate the possible matches + * with a cheaper algorithm and only apply the heavy one to the + * possibly matching segments. This allows us to benefit from the + * advantages of an NFA implementation reducing the effect of the + * performance impact. + */ + +/* * Parses bracket expression seeking to the end of the enclosed text. * The parameters are the opening (oe) and closing elements (ce). * Can handle nested bracket expressions. From owner-svn-src-user@FreeBSD.ORG Mon Aug 22 16:35:47 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 2F979106567A; Mon, 22 Aug 2011 16:35:47 +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 20AF98FC12; Mon, 22 Aug 2011 16:35:47 +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 p7MGZlVX058798; Mon, 22 Aug 2011 16:35:47 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7MGZk2m058796; Mon, 22 Aug 2011 16:35:46 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108221635.p7MGZk2m058796@svn.freebsd.org> From: Adrian Chadd Date: Mon, 22 Aug 2011 16:35:46 +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: r225078 - 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, 22 Aug 2011 16:35:47 -0000 Author: adrian Date: Mon Aug 22 16:35:46 2011 New Revision: 225078 URL: http://svn.freebsd.org/changeset/base/225078 Log: Fix a NULL de-reference 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 Mon Aug 22 11:22:13 2011 (r225077) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Mon Aug 22 16:35:46 2011 (r225078) @@ -1883,9 +1883,10 @@ _ath_getbuf_locked(struct ath_softc *sc) DPRINTF(sc, ATH_DEBUG_XMIT, "%s: %s\n", __func__, TAILQ_FIRST(&sc->sc_txbuf) == NULL ? "out of xmit buffers" : "xmit buffer busy"); + } else { + bf->bf_next = NULL; /* XXX just to be sure */ + bf->bf_comp = NULL; /* XXX again, just to be sure */ } - bf->bf_next = NULL; /* XXX just to be sure */ - bf->bf_comp = NULL; /* XXX again, just to be sure */ return bf; } From owner-svn-src-user@FreeBSD.ORG Mon Aug 22 20:25: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 81420106564A; Mon, 22 Aug 2011 20:25: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 7140B8FC0A; Mon, 22 Aug 2011 20:25: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 p7MKPtkQ067133; Mon, 22 Aug 2011 20:25:55 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7MKPt57067131; Mon, 22 Aug 2011 20:25:55 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108222025.p7MKPt57067131@svn.freebsd.org> From: Gabor Kovesdan Date: Mon, 22 Aug 2011 20:25: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: r225087 - 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: Mon, 22 Aug 2011 20:25:55 -0000 Author: gabor Date: Mon Aug 22 20:25:55 2011 New Revision: 225087 URL: http://svn.freebsd.org/changeset/base/225087 Log: - Partly fix offset handling Modified: user/gabor/tre-integration/contrib/tre/lib/regexec.c Modified: user/gabor/tre-integration/contrib/tre/lib/regexec.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/regexec.c Mon Aug 22 19:46:25 2011 (r225086) +++ user/gabor/tre-integration/contrib/tre/lib/regexec.c Mon Aug 22 20:25:55 2011 (r225087) @@ -162,42 +162,76 @@ tre_match(const tre_tnfa_t *tnfa, const return tre_match_fast(shortcut, string, len, type, nmatch, pmatch, eflags); +#define FIX_OFFSETS \ + if (ret == REG_NOMATCH) \ + { \ + st += n; \ + continue; \ + } \ + else if ((ret == REG_OK) && !(tnfa->cflags & REG_NOSUB)) \ + for (int i = 0; i < nmatch; i++) \ + { \ + pmatch[i].rm_so += st; \ + pmatch[i].rm_eo += st; \ + } \ + return ret; + +#define SEEK_TO(off) \ + string = (type == STR_WIDE) ? (void *)&data_wide[off] : \ + (void *)&data_byte[off]; + /* Check if we have a heuristic to speed up the search. */ if (heur != NULL) { int ret; - size_t st = 0, j; + size_t st = 0, n; const char *data_byte = string; const tre_char_t *data_wide = string; - const void *tmp; - /* Look for the beginning of possibly matching text. */ - ret = tre_match_fast(heur->start, string, len, type, nmatch, - pmatch, eflags); - if (ret != REG_OK) - return ret; - st = pmatch[0].rm_so; - j = pmatch[0].rm_eo; - string = (type == STR_WIDE) ? (void *)&data_wide[st] : - (void *)&data_byte[st]; - - /* When having a fixed-length pattern there is only one heuristic. */ - if (heur->end == NULL) - return tre_match(tnfa, string, - heur->prefix ? (len - st) : (j - st), - type, nmatch, pmatch, eflags, NULL, NULL); - - tmp = (type == STR_WIDE) ? (void *)&data_wide[j] : - (void *)&data_byte[j]; - - /* Look for the end of possibly matching text. */ - ret = tre_match_fast(heur->end, tmp, len - j, type, nmatch, - pmatch, eflags); - if (ret != REG_OK) - return ret; + while (st < len) + { + SEEK_TO(st); - return tre_match(tnfa, string, pmatch[0].rm_eo + j - st, - type, nmatch, pmatch, eflags, NULL, NULL); + /* Look for the beginning of possibly matching text. */ + ret = tre_match_fast(heur->start, string, len - st, type, nmatch, + pmatch, eflags); + if (ret != REG_OK) + return ret; + st += pmatch[0].rm_so; + n = pmatch[0].rm_eo; + + /* + * When having a fixed-length pattern there is only + * one heuristic. + */ + if (heur->end == NULL) + { + SEEK_TO(st); + + ret = tre_match(tnfa, string, + heur->prefix ? (len - st) : + n, type, nmatch, + pmatch, eflags, NULL, NULL); + + FIX_OFFSETS; + } + + SEEK_TO(st + n); + + /* Look for the end of possibly matching text. */ + ret = tre_match_fast(heur->end, string, len - st - n, type, + nmatch, pmatch, eflags); + + if (ret != REG_OK) + return ret; + + SEEK_TO(st); + + ret = tre_match(tnfa, string, pmatch[0].rm_eo + n, + type, nmatch, pmatch, eflags, NULL, NULL); + + FIX_OFFSETS; + } } if (tnfa->num_tags > 0 && nmatch > 0) From owner-svn-src-user@FreeBSD.ORG Mon Aug 22 23:15:15 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 E7A0A106566B; Mon, 22 Aug 2011 23:15:15 +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 D772A8FC08; Mon, 22 Aug 2011 23:15:15 +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 p7MNFFAP072341; Mon, 22 Aug 2011 23:15:15 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7MNFFNk072339; Mon, 22 Aug 2011 23:15:15 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108222315.p7MNFFNk072339@svn.freebsd.org> From: Gabor Kovesdan Date: Mon, 22 Aug 2011 23:15:15 +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: r225092 - 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: Mon, 22 Aug 2011 23:15:16 -0000 Author: gabor Date: Mon Aug 22 23:15:15 2011 New Revision: 225092 URL: http://svn.freebsd.org/changeset/base/225092 Log: - Fix offsets for heuristics with prefix and end segment Modified: user/gabor/tre-integration/contrib/tre/lib/regexec.c Modified: user/gabor/tre-integration/contrib/tre/lib/regexec.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/regexec.c Mon Aug 22 21:10:50 2011 (r225091) +++ user/gabor/tre-integration/contrib/tre/lib/regexec.c Mon Aug 22 23:15:15 2011 (r225092) @@ -221,13 +221,14 @@ tre_match(const tre_tnfa_t *tnfa, const /* Look for the end of possibly matching text. */ ret = tre_match_fast(heur->end, string, len - st - n, type, nmatch, pmatch, eflags); + n += pmatch[0].rm_eo; if (ret != REG_OK) return ret; SEEK_TO(st); - ret = tre_match(tnfa, string, pmatch[0].rm_eo + n, + ret = tre_match(tnfa, string, n, type, nmatch, pmatch, eflags, NULL, NULL); FIX_OFFSETS; From owner-svn-src-user@FreeBSD.ORG Mon Aug 22 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 EEC4B106564A; Mon, 22 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 DE2CC8FC17; Mon, 22 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 p7MNJKZc072491; Mon, 22 Aug 2011 23:19:20 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7MNJKZ4072487; Mon, 22 Aug 2011 23:19:20 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108222319.p7MNJKZ4072487@svn.freebsd.org> From: Gabor Kovesdan Date: Mon, 22 Aug 2011 23:19:20 +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: r225093 - 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: Mon, 22 Aug 2011 23:19:21 -0000 Author: gabor Date: Mon Aug 22 23:19:20 2011 New Revision: 225093 URL: http://svn.freebsd.org/changeset/base/225093 Log: - Add an internal flag for heuristics: it understands ^$. but handles everything else as literal. This allows using the fast algorithm while treating {}, \, *, etc. as literal. Modified: user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c user/gabor/tre-integration/include/regex.h Modified: user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Mon Aug 22 23:15:15 2011 (r225092) +++ user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Mon Aug 22 23:19:20 2011 (r225093) @@ -428,10 +428,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; Modified: user/gabor/tre-integration/include/regex.h ============================================================================== --- user/gabor/tre-integration/include/regex.h Mon Aug 22 23:15:15 2011 (r225092) +++ user/gabor/tre-integration/include/regex.h Mon Aug 22 23:19:20 2011 (r225093) @@ -110,6 +110,7 @@ typedef enum { #define REG_PEND (REG_UNGREEDY << 1) #define REG_GNU (REG_PEND << 1) #define REG_WORD (REG_GNU << 1) +#define _REG_HEUR (REG_WORD << 1) /* POSIX tre_regexec() flags. */ #define REG_NOTBOL 1 From owner-svn-src-user@FreeBSD.ORG Mon Aug 22 23:20: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 D22BB106566C; Mon, 22 Aug 2011 23:20: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 B755A8FC0C; Mon, 22 Aug 2011 23:20: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 p7MNKDIQ072566; Mon, 22 Aug 2011 23:20:13 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7MNKDNg072564; Mon, 22 Aug 2011 23:20:13 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108222320.p7MNKDNg072564@svn.freebsd.org> From: Gabor Kovesdan Date: Mon, 22 Aug 2011 23:20:13 +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: r225094 - 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: Mon, 22 Aug 2011 23:20:14 -0000 Author: gabor Date: Mon Aug 22 23:20:13 2011 New Revision: 225094 URL: http://svn.freebsd.org/changeset/base/225094 Log: - With the previous change we can allow more accurate heuristics Modified: user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.c Modified: user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.c Mon Aug 22 23:19:20 2011 (r225093) +++ user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.c Mon Aug 22 23:20:13 2011 (r225094) @@ -135,57 +135,63 @@ tre_compile_heur(heur_t *h, const tre_ch /* * If a repetition marker, erases the repeting character - * and terminates the segment. - * Otherwise just terminates the segment (XXX). + * and terminates the segment, otherwise treated as a normal + * character. */ case TRE_CHAR('{'): PARSE_UNIT('{', '}'); if (escaped) - pos--; - END_SEGMENT; + { + pos--; + END_SEGMENT; + } + heur[pos++] = regex[i]; break; /* - * Terminates the current segment whether a subexpression - * marker or not. (XXX) + * Terminates the current segment when escaped, + * otherwise treated as a normal character. */ case TRE_CHAR('('): PARSE_UNIT('(', ')'); - END_SEGMENT; + if (escaped) + END_SEGMENT; + heur[pos++] = regex[i]; break; /* * Sets escaped flag. - * Escaped escape terminates current segment. (XXX) + * Escaped escape is treated as a normal character. + * (This is also the GNU behaviour.) */ case TRE_CHAR('\\'): if (escaped) - END_SEGMENT; + heur[pos++] = regex[i]; escaped = !escaped; continue; /* - * If not the first character, erases the last character - * and terminates the segment. - * Otherwise heuristic construction fails. (XXX) + * If not the first character and not escaped, erases the + * last character and terminates the segment. + * Otherwise treated as a normal character. */ case TRE_CHAR('*'): - if (i != 0) + if ((i != 0) && !escaped) { pos--; END_SEGMENT; } else - goto badpat1; + heur[pos++] = regex[i]; break; /* - * If a backreference (escaped digit), terminates segment. + * If escaped, terminates segment. * Otherwise adds current character to the current segment * by copying it to the temporary space. */ default: - if (escaped && tre_isdigit(regex[i])) + if (escaped) END_SEGMENT; heur[pos++] = regex[i]; continue; @@ -218,7 +224,7 @@ end_segment: goto space1; } - ret = tre_compile_fast(h->start, heur, pos, 0); + ret = tre_compile_fast(h->start, heur, pos, _REG_HEUR); if (ret != REG_OK) { errcode = REG_BADPAT; @@ -248,7 +254,7 @@ end_segment: goto space2; } - ret = tre_compile_fast(h->end, heur, pos, 0); + ret = tre_compile_fast(h->end, heur, pos, _REG_HEUR); if (ret != REG_OK) { xfree(h->end); From owner-svn-src-user@FreeBSD.ORG Tue Aug 23 00:12: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 13E8A1065689; Tue, 23 Aug 2011 00:12: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 DE5448FC19; Tue, 23 Aug 2011 00:12: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 p7N0COHv076424; Tue, 23 Aug 2011 00:12:24 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7N0COaY076422; Tue, 23 Aug 2011 00:12:24 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108230012.p7N0COaY076422@svn.freebsd.org> From: Gabor Kovesdan Date: Tue, 23 Aug 2011 00:12: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: r225098 - 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, 23 Aug 2011 00:12:25 -0000 Author: gabor Date: Tue Aug 23 00:12:24 2011 New Revision: 225098 URL: http://svn.freebsd.org/changeset/base/225098 Log: - [] brackets are parsed differently than other brackets because [ and ] are interpreted differently in some special cases Modified: user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.c Modified: user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.c Mon Aug 22 23:54:12 2011 (r225097) +++ user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.c Tue Aug 23 00:12:24 2011 (r225098) @@ -39,6 +39,13 @@ #include "tre-internal.h" #include "xmalloc.h" +#ifdef TRE_WCHAR +#define tre_strnstr(big, s1, little, s2) \ + memmem(big, s1 * sizeof(tre_char_t), little, s2 * sizeof(tre_char_t)) +#else +#define tre_strnstr(big, s1, little, s2) strnstr(big, little, s1) +#endif + /* * A full regex implementation requires a finite state automaton * and using an automaton is always about a trade-off. A DFA is @@ -75,6 +82,40 @@ } \ } +#define PARSE_BRACKETS \ + { \ + tre_char_t *tmp; \ + \ + i++; \ + if (regex[i] == TRE_CHAR('^')) \ + i++; \ + if (regex[i] == TRE_CHAR(']')) \ + i++; \ + \ + do \ + { \ + tmp = tre_strnstr(®ex[i], len - i, TRE_CHAR("[.].]"), 5); \ + if (tmp) \ + { \ + i += (tmp - regex); \ + regex = tmp; \ + } \ + } while (tmp != NULL); \ + \ + do \ + { \ + tmp = tre_strnstr(®ex[i], len - i, TRE_CHAR("[=]=]"), 5); \ + if (tmp) \ + { \ + i += (tmp - regex); \ + regex = tmp; \ + } \ + } while (tmp != NULL); \ + \ + for (; (i != TRE_CHAR(']')) && (i < len); i++); \ + } + + /* * Finishes a segment (fixed-length text fragment). */ @@ -129,7 +170,7 @@ tre_compile_heur(heur_t *h, const tre_ch /* Bracketed expression is substituted with a dot. */ case TRE_CHAR('['): - PARSE_UNIT('[', ']'); + PARSE_BRACKETS; heur[pos++] = TRE_CHAR('.'); continue; From owner-svn-src-user@FreeBSD.ORG Tue Aug 23 03:44: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 DF7641065673; Tue, 23 Aug 2011 03:44:19 +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 6578D8FC08; Tue, 23 Aug 2011 03:44:18 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by vniz.net (8.14.5/8.14.5) with ESMTP id p7N3iHb1007957; Tue, 23 Aug 2011 07:44:17 +0400 (MSK) (envelope-from ache@vniz.net) Received: (from ache@localhost) by localhost (8.14.5/8.14.5/Submit) id p7N3iHtD007956; Tue, 23 Aug 2011 07:44:17 +0400 (MSK) (envelope-from ache) Date: Tue, 23 Aug 2011 07:44:16 +0400 From: Andrey Chernov To: Gabor Kovesdan Message-ID: <20110823034416.GA7597@vniz.net> Mail-Followup-To: Andrey Chernov , Gabor Kovesdan , src-committers@FreeBSD.ORG, svn-src-user@FreeBSD.ORG References: <201108222319.p7MNJKZ4072487@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201108222319.p7MNJKZ4072487@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: r225093 - 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: Tue, 23 Aug 2011 03:44:20 -0000 On Mon, Aug 22, 2011 at 11:19:20PM +0000, Gabor Kovesdan wrote: > Modified: user/gabor/tre-integration/include/regex.h > ============================================================================== > --- user/gabor/tre-integration/include/regex.h Mon Aug 22 23:15:15 2011 (r225092) > +++ user/gabor/tre-integration/include/regex.h Mon Aug 22 23:19:20 2011 (r225093) > @@ -110,6 +110,7 @@ typedef enum { > #define REG_PEND (REG_UNGREEDY << 1) > #define REG_GNU (REG_PEND << 1) > #define REG_WORD (REG_GNU << 1) > +#define _REG_HEUR (REG_WORD << 1) Not a good place. Next extension flag from TRE author or POSIX will break binary compatibility badly. It will be better to put it to the end of a word instead or don't use this field at all (converting to another internal function argument etc.), which is much safer. -- http://ache.vniz.net/ From owner-svn-src-user@FreeBSD.ORG Tue Aug 23 07:17: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 5543A106564A; Tue, 23 Aug 2011 07:17:38 +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 44DBA8FC12; Tue, 23 Aug 2011 07:17: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 p7N7Hc18089788; Tue, 23 Aug 2011 07:17:38 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7N7Hcn4089783; Tue, 23 Aug 2011 07:17:38 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108230717.p7N7Hcn4089783@svn.freebsd.org> From: Adrian Chadd Date: Tue, 23 Aug 2011 07:17:38 +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: r225101 - 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, 23 Aug 2011 07:17:38 -0000 Author: adrian Date: Tue Aug 23 07:17:37 2011 New Revision: 225101 URL: http://svn.freebsd.org/changeset/base/225101 Log: Sync this code a little more with what's in the Linux/atheros reference drivers. It doesn't yet fix aggregation throughput issues, but it provides some handy statistics for tracking what's going on. * add an ath_txq (hardware) counter tracking how many aggregate frames are pending. * Use this instead of the overall counter (axq_depth) * Add it to the txagg sysctl And another temporary tinker: * Delay scheduling the TID in ath_tx_swq() if the TID has some hardware queued frames. This doesn't seem to (yet) be doing what I would like it to be doing. The MAC is still not being kept totally busy, especially when TX'ing UDP traffic from a local iperf process. I'll add some more statistics and see what's going on. 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_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 Tue Aug 23 07:00:51 2011 (r225100) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Tue Aug 23 07:17:37 2011 (r225101) @@ -2512,7 +2512,9 @@ ath_txqmove(struct ath_txq *dst, struct dst->axq_link = src->axq_link; src->axq_link = NULL; dst->axq_depth += src->axq_depth; + dst->axq_aggr_depth += src->axq_aggr_depth; src->axq_depth = 0; + src->axq_aggr_depth = 0; } /* @@ -3915,6 +3917,7 @@ ath_txq_init(struct ath_softc *sc, struc txq->axq_qnum = qnum; txq->axq_ac = 0; txq->axq_depth = 0; + txq->axq_aggr_depth = 0; txq->axq_intrcnt = 0; txq->axq_link = NULL; txq->axq_softc = sc; @@ -4293,6 +4296,8 @@ ath_tx_processq(struct ath_softc *sc, st if (txq->axq_depth == 0) #endif txq->axq_link = NULL; + if (bf->bf_state.bfs_aggr) + txq->axq_aggr_depth--; ATH_TXQ_UNLOCK(txq); ni = bf->bf_node; @@ -4549,6 +4554,8 @@ ath_tx_draintxq(struct ath_softc *sc, st 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) { 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 23 07:00:51 2011 (r225100) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_sysctl.c Tue Aug 23 07:17:37 2011 (r225101) @@ -329,8 +329,10 @@ ath_sysctl_txagg(SYSCTL_HANDLER_ARGS) for (i = 0; i < HAL_NUM_TX_QUEUES; i++) { if (ATH_TXQ_SETUP(sc, i)) { - printf("HW TXQ %d: axq_depth=%d\n", - i, sc->sc_txq[i].axq_depth); + printf("HW TXQ %d: axq_depth=%d, axq_aggr_depth=%d\n", + i, + sc->sc_txq[i].axq_depth, + sc->sc_txq[i].axq_aggr_depth); } } 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 23 07:00:51 2011 (r225100) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Tue Aug 23 07:17:37 2011 (r225101) @@ -568,6 +568,8 @@ ath_tx_handoff_hw(struct ath_softc *sc, (caddr_t)bf->bf_daddr, bf->bf_desc, txq->axq_depth); } #endif /* IEEE80211_SUPPORT_TDMA */ + if (bf->bf_state.bfs_aggr) + txq->axq_aggr_depth++; txq->axq_link = &bf->bf_lastds->ds_link; ath_hal_txstart(ah, txq->axq_qnum); } @@ -1946,11 +1948,18 @@ ath_tx_swq(struct ath_softc *sc, struct /* 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_tx_tid_sched(sc, an, tid); - ATH_TXQ_UNLOCK(txq); + /* + * Don't queue frames if the TID has a handful + * of hardware queued frames already. + */ + if (atid->hwq_depth < sc->sc_tid_hwq_hi) { + ATH_TXQ_UNLOCK(atid); + ATH_TXQ_LOCK(txq); + ath_tx_tid_sched(sc, an, tid); + ATH_TXQ_UNLOCK(txq); + } else + ATH_TXQ_UNLOCK(atid); } /* @@ -3038,18 +3047,17 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft /* aggregates are "one" buffer */ ATH_TXQ_LOCK(atid); atid->hwq_depth++; - if (atid->hwq_depth >= ATH_AGGR_SCHED_LOW) { - ATH_TXQ_UNLOCK(atid); - break; - } ATH_TXQ_UNLOCK(atid); /* * Break out if ath_tx_form_aggr() indicated * there can't be any further progress (eg BAW is full.) * Checking for an empty txq is done above. + * + * XXX locking on txq here? */ - if (status == ATH_AGGR_BAW_CLOSED) + if (txq->axq_aggr_depth >= sc->sc_hwq_limit || + status == ATH_AGGR_BAW_CLOSED) break; } } @@ -3149,7 +3157,7 @@ ath_txq_sched(struct ath_softc *sc, stru * XXX normal ones. */ ATH_TXQ_LOCK(txq); - if (txq->axq_depth >= ATH_AGGR_MIN_QDEPTH) { + if (txq->axq_aggr_depth >= sc->sc_hwq_limit) { ATH_TXQ_UNLOCK(txq); return; } @@ -3191,7 +3199,7 @@ ath_txq_sched(struct ath_softc *sc, stru ath_tx_tid_unsched(sc, atid->an, atid->tid); /* Give the software queue time to aggregate more packets */ - if (txq->axq_depth >= ATH_AGGR_MIN_QDEPTH) { + if (txq->axq_aggr_depth >= sc->sc_hwq_limit) { //ATH_TXQ_UNLOCK(txq); break; } Modified: user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Tue Aug 23 07:00:51 2011 (r225100) +++ user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Tue Aug 23 07:17:37 2011 (r225101) @@ -271,6 +271,7 @@ struct ath_txq { u_int axq_flags; #define ATH_TXQ_PUTPENDING 0x0001 /* ath_hal_puttxbuf pending */ u_int axq_depth; /* queue depth (stat only) */ + u_int axq_aggr_depth; /* how many aggregates are queued */ u_int axq_intrcnt; /* interrupt count */ u_int32_t *axq_link; /* link ptr in last TX desc */ TAILQ_HEAD(axq_q_s, ath_buf) axq_q; /* transmit queue */ From owner-svn-src-user@FreeBSD.ORG Tue Aug 23 11:53:09 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 732A11065674; Tue, 23 Aug 2011 11:53:09 +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 4A51C8FC14; Tue, 23 Aug 2011 11:53: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 p7NBr9uP001471; Tue, 23 Aug 2011 11:53:09 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7NBr9vh001469; Tue, 23 Aug 2011 11:53:09 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108231153.p7NBr9vh001469@svn.freebsd.org> From: Adrian Chadd Date: Tue, 23 Aug 2011 11:53: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: r225106 - 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, 23 Aug 2011 11:53:09 -0000 Author: adrian Date: Tue Aug 23 11:53:08 2011 New Revision: 225106 URL: http://svn.freebsd.org/changeset/base/225106 Log: Undo some of the stuff I've been tinkering with. TX aggregation seems to be working on faster hardware; it's just running iperf locally on these MIPS boards is causing headaches. * Always schedule the TID in ath_tx_swq() * Only schedule the TID when packets are thrown on the end of that TID software queue. This matches what the linux and reference code driver does. 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 Tue Aug 23 09:42:29 2011 (r225105) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Tue Aug 23 11:53:08 2011 (r225106) @@ -1948,18 +1948,11 @@ ath_tx_swq(struct ath_softc *sc, struct /* 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); - /* - * Don't queue frames if the TID has a handful - * of hardware queued frames already. - */ - if (atid->hwq_depth < sc->sc_tid_hwq_hi) { - ATH_TXQ_UNLOCK(atid); - ATH_TXQ_LOCK(txq); - ath_tx_tid_sched(sc, an, tid); - ATH_TXQ_UNLOCK(txq); - } else - ATH_TXQ_UNLOCK(atid); + ATH_TXQ_LOCK(txq); + ath_tx_tid_sched(sc, an, tid); + ATH_TXQ_UNLOCK(txq); } /* @@ -2407,10 +2400,6 @@ ath_tx_aggr_retry_unaggr(struct ath_soft } #endif - ATH_TXQ_LOCK(sc->sc_ac2q[atid->ac]); - ath_tx_tid_sched(sc, an, atid->tid); - ATH_TXQ_UNLOCK(sc->sc_ac2q[atid->ac]); - /* Free buffer, bf is free after this call */ ath_tx_default_comp(sc, bf, 0); @@ -2836,10 +2825,6 @@ ath_tx_aggr_comp_unaggr(struct ath_softc bf->bf_state.bfs_pktlen, 1, (ts->ts_status == 0) ? 0 : 1); - ATH_TXQ_LOCK(sc->sc_ac2q[atid->ac]); - ath_tx_tid_sched(sc, an, atid->tid); - ATH_TXQ_UNLOCK(sc->sc_ac2q[atid->ac]); - /* * If a cleanup is in progress, punt to comp_cleanup; * rather than handling it here. It's thus their From owner-svn-src-user@FreeBSD.ORG Tue Aug 23 21:10:23 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 C5EBD106572D; Tue, 23 Aug 2011 21:10:23 +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 B4AF58FC0A; Tue, 23 Aug 2011 21:10:23 +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 p7NLAN3x019554; Tue, 23 Aug 2011 21:10:23 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7NLANA4019549; Tue, 23 Aug 2011 21:10:23 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108232110.p7NLANA4019549@svn.freebsd.org> From: Gabor Kovesdan Date: Tue, 23 Aug 2011 21:10: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: r225123 - 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, 23 Aug 2011 21:10:23 -0000 Author: gabor Date: Tue Aug 23 21:10:23 2011 New Revision: 225123 URL: http://svn.freebsd.org/changeset/base/225123 Log: - Add some debug output Modified: user/gabor/tre-integration/contrib/tre/lib/regexec.c user/gabor/tre-integration/contrib/tre/lib/tre-compile.c user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.c Modified: user/gabor/tre-integration/contrib/tre/lib/regexec.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/regexec.c Tue Aug 23 20:25:11 2011 (r225122) +++ user/gabor/tre-integration/contrib/tre/lib/regexec.c Tue Aug 23 21:10:23 2011 (r225123) @@ -159,8 +159,11 @@ tre_match(const tre_tnfa_t *tnfa, const /* Check if we can cheat with a faster algorithm. */ if (shortcut != NULL) - return tre_match_fast(shortcut, string, len, type, nmatch, - pmatch, eflags); + { + DPRINT("tre_match: using tre_match_fast() instead of the full NFA\n"); + return tre_match_fast(shortcut, string, len, type, nmatch, + pmatch, eflags); + } #define FIX_OFFSETS \ if (ret == REG_NOMATCH) \ @@ -188,6 +191,9 @@ tre_match(const tre_tnfa_t *tnfa, const const char *data_byte = string; const tre_char_t *data_wide = string; + DPRINT(("tre_match: using a heuristic [%s/%s] to speed up the " + "search\n", heur->start->pattern, heur->end->pattern)); + while (st < len) { SEEK_TO(st); @@ -208,6 +214,9 @@ tre_match(const tre_tnfa_t *tnfa, const { SEEK_TO(st); + DPRINT(("tre_match: calling NFA with offsets [%u/%u]\n", + st, heur->prefix ? len : n + st)); + ret = tre_match(tnfa, string, heur->prefix ? (len - st) : n, type, nmatch, @@ -228,6 +237,9 @@ tre_match(const tre_tnfa_t *tnfa, const SEEK_TO(st); + DPRINT(("tre_match: calling NFA with offsets [%u/%u]\n", + st, st + n)); + ret = tre_match(tnfa, string, n, type, nmatch, pmatch, eflags, NULL, NULL); Modified: user/gabor/tre-integration/contrib/tre/lib/tre-compile.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-compile.c Tue Aug 23 20:25:11 2011 (r225122) +++ user/gabor/tre-integration/contrib/tre/lib/tre-compile.c Tue Aug 23 21:10:23 2011 (r225123) @@ -1884,12 +1884,14 @@ tre_compile(regex_t *preg, const tre_cha { preg->shortcut = shortcut; preg->re_nsub = 0; + DPRINT("tre_compile: pattern compiled for fast matcher\n"); return REG_OK; } else { xfree(shortcut); preg->shortcut = NULL; + DPRINT("tre_compile: pattern compilation failed for fast matcher\n"); } /* Allocate a stack used throughout the compilation process for various @@ -2186,7 +2188,6 @@ tre_compile(regex_t *preg, const tre_cha * If we reach here, the regex is parsed and legal. Now we try to construct * a heuristic to speed up matching. */ - heur = xmalloc(sizeof(heur_t)); if (!heur) { @@ -2199,9 +2200,14 @@ tre_compile(regex_t *preg, const tre_cha { xfree(heur); preg->heur = NULL; + DPRINT("tre_compile: heuristic compilation failed, NFA will be used " + "entirely\n"); } else - preg->heur = heur; + { + preg->heur = heur; + DPRINT("tre_compile: heuristic compiled to speed up the search\n"); + } return REG_OK; Modified: user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Tue Aug 23 20:25:11 2011 (r225122) +++ user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Tue Aug 23 21:10:23 2011 (r225123) @@ -134,6 +134,9 @@ static int fastcmp(const void *, const v gs = fg->bmGs[mismatch]; \ } \ bc = (r == 0) ? 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) \ @@ -144,6 +147,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; \ @@ -161,6 +167,7 @@ static int fastcmp(const void *, const v u = 0; \ } \ } \ + DPRINT(("tre_fast_match: shifting %d characters\n", shift)); \ j += shift; \ } @@ -190,6 +197,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]) \ @@ -218,6 +227,8 @@ static int fastcmp(const void *, const v { \ int k = fg->wlen - i; \ hashtable_put(fg->qsBc_table, &fg->wpattern[i], &k); \ + 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]) ? \ @@ -375,6 +386,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 @@ -452,6 +467,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 @@ -635,6 +656,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) @@ -688,6 +712,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; } Modified: user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.c Tue Aug 23 20:25:11 2011 (r225122) +++ user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.c Tue Aug 23 21:10:23 2011 (r225123) @@ -255,6 +255,8 @@ end_segment: if (pos <= 1) { errcode = REG_BADPAT; + DPRINT("tre_compile_heur: pattern does not have a " + " fixed-length prefix that is long enough\n"); goto badpat1; } @@ -271,6 +273,8 @@ end_segment: errcode = REG_BADPAT; goto badpat2; } + DPRINT(("tre_compile_heur: fixed-length prefix is %s\n", + h->start->pattern)); } /* @@ -285,6 +289,8 @@ end_segment: { h->prefix = true; errcode = REG_OK; + DPRINT("tre-compile_heur: using only a fixed-length prefix; " + "no fixed-length suffix is available\n"); goto ok; } @@ -302,6 +308,8 @@ end_segment: h->prefix = true; } errcode = REG_OK; + DPRINT(("tre_compile_heur: fixed-length suffix is %s\n", + h->end->pattern)); goto ok; } @@ -315,6 +323,7 @@ space2: xfree(h->start); badpat1: space1: + DPRINT("tre_compile_heur: compiling a heuristic failed\n"); ok: xfree(heur); return errcode; @@ -330,4 +339,6 @@ tre_free_heur(heur_t *h) xfree(h->start); if (h->end != NULL) xfree(h->end); + + DPRINT("tre_free_heur: resources are freed\n"); } From owner-svn-src-user@FreeBSD.ORG Tue Aug 23 23:33:39 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 4EEDC106564A; Tue, 23 Aug 2011 23:33:39 +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 3DDC08FC08; Tue, 23 Aug 2011 23:33:39 +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 p7NNXdGJ024120; Tue, 23 Aug 2011 23:33:39 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7NNXdOh024116; Tue, 23 Aug 2011 23:33:39 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108232333.p7NNXdOh024116@svn.freebsd.org> From: Adrian Chadd Date: Tue, 23 Aug 2011 23:33:39 +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: r225124 - 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, 23 Aug 2011 23:33:39 -0000 Author: adrian Date: Tue Aug 23 23:33:38 2011 New Revision: 225124 URL: http://svn.freebsd.org/changeset/base/225124 Log: Try to make the ATH_BUF_BUSY handling work again. * add bf_last to ath_buf, which points to the last frame in an aggregate, or itself for a single frame * Set ATH_BUF_BUSY in the last frame in an aggregate - that's the ath_buf which the hardware may be currently tinkering with. * Restore the ATH_BUF_BUSY clearing in ath_tx_processq() - clear the ATH_BUF_BUSY flag in the last entry on the free list before adding the next buffer - it's assumed the hardware has finished with that descriptor. This should restore the current behaviour that ATH_BUF_BUSY protects against, but: * retries which use ATH_BUF_BUSY buffers need to result in the ath_buf being cloned, rather than reused. That buffer then needs to be returned to the free list. * This code seems like it'll only work for a single TX queue. As in, if TXQ 0 has been handled and the last buffer is marked BUSY, then TXQ 1 runs - the last buffer on the free list will be marked as non-busy. ath9k and the reference code uses a more complicated "holding descriptor" setup which keeps the descriptor on the TXQ list and frees it when needed. This will be eventually needed! 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_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 Tue Aug 23 21:10:23 2011 (r225123) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Tue Aug 23 23:33:38 2011 (r225124) @@ -1885,6 +1885,7 @@ _ath_getbuf_locked(struct ath_softc *sc) "out of xmit buffers" : "xmit buffer busy"); } else { bf->bf_next = NULL; /* XXX just to be sure */ + bf->bf_last = NULL; /* XXX again, just to be sure */ bf->bf_comp = NULL; /* XXX again, just to be sure */ } return bf; @@ -2433,6 +2434,7 @@ ath_beacon_setup(struct ath_softc *sc, s /* setup descriptors */ ds = bf->bf_desc; + bf->bf_last = bf; flags = HAL_TXDESC_NOACK; if (ic->ic_opmode == IEEE80211_M_IBSS && sc->sc_hasveol) { @@ -4248,7 +4250,7 @@ static int ath_tx_processq(struct ath_softc *sc, struct ath_txq *txq) { struct ath_hal *ah = sc->sc_ah; - struct ath_buf *bf; + struct ath_buf *bf, *last; struct ath_desc *ds, *ds0; struct ath_tx_status *ts; struct ieee80211_node *ni; @@ -4289,8 +4291,12 @@ ath_tx_processq(struct ath_softc *sc, st * More frames follow. Mark the buffer busy * so it's not re-used while the hardware may * still re-read the link field in the descriptor. + * + * Use the last buffer in an aggregate as that + * is where the hardware may be - intermediate + * descriptors won't be "busy". */ - bf->bf_flags |= ATH_BUF_BUSY; + bf->bf_last->bf_flags |= ATH_BUF_BUSY; } else #else if (txq->axq_depth == 0) @@ -4321,6 +4327,20 @@ ath_tx_processq(struct ath_softc *sc, st ath_tx_update_stats(sc, ts, bf); } + /* + * Since the last frame may still be marked + * as ATH_BUF_BUSY, unmark it here before + * finishing the frame processing. + * Since we've completed a frame (aggregate + * or otherwise), the hardware has moved on + * and is no longer referencing the previous + * descriptor. + */ + ATH_TXBUF_LOCK(sc); + last = TAILQ_LAST(&sc->sc_txbuf, ath_bufhead_s); + if (last != NULL) + last->bf_flags &= ~ATH_BUF_BUSY; + ATH_TXBUF_UNLOCK(sc); /* * Call the completion handler. @@ -4574,6 +4594,11 @@ ath_tx_draintxq(struct ath_softc *sc, st * functions, we -must- call it for aggregation * destinations or BAW tracking will get upset. */ + /* + * Clear ATH_BUF_BUSY; the completion handler + * will free the buffer. + */ + bf->bf_flags &= ~ATH_BUF_BUSY; if (bf->bf_comp) bf->bf_comp(sc, bf, 1); else 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 23 21:10:23 2011 (r225123) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Tue Aug 23 23:33:38 2011 (r225124) @@ -444,6 +444,12 @@ ath_tx_setds_11n(struct ath_softc *sc, s */ bf_first->bf_lastds = bf_prev->bf_lastds; + /* + * And bf_last in the first descriptor points to the end of + * the aggregate list. + */ + bf_first->bf_last = bf_prev; + DPRINTF(sc, ATH_DEBUG_SW_TX_AGGR, "%s: end\n", __func__); } @@ -739,6 +745,7 @@ ath_tx_setds(struct ath_softc *sc, struc * This will be overriden when the descriptor chain is written. */ bf->bf_lastds = ds; + bf->bf_last = bf; /* XXX TODO: Setup descriptor chain */ } Modified: user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Tue Aug 23 21:10:23 2011 (r225123) +++ user/adrian/if_ath_tx/sys/dev/ath/if_athvar.h Tue Aug 23 23:33:38 2011 (r225124) @@ -183,6 +183,7 @@ struct ath_buf { struct mbuf *bf_m; /* mbuf for buf */ struct ieee80211_node *bf_node; /* pointer to the node */ struct ath_desc *bf_lastds; /* last descriptor for comp status */ + struct ath_buf *bf_last; /* last buffer in aggregate, or self for non-aggregate */ bus_size_t bf_mapsize; #define ATH_MAX_SCATTER ATH_TXDESC /* max(tx,rx,beacon) desc's */ bus_dma_segment_t bf_segs[ATH_MAX_SCATTER]; From owner-svn-src-user@FreeBSD.ORG Wed Aug 24 03:09: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 9CB54106566B; Wed, 24 Aug 2011 03:09:02 +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 8D5098FC19; Wed, 24 Aug 2011 03:09: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 p7O3927m030672; Wed, 24 Aug 2011 03:09:02 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7O392DO030670; Wed, 24 Aug 2011 03:09:02 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108240309.p7O392DO030670@svn.freebsd.org> From: Adrian Chadd Date: Wed, 24 Aug 2011 03:09: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: r225126 - 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, 24 Aug 2011 03:09:02 -0000 Author: adrian Date: Wed Aug 24 03:09:02 2011 New Revision: 225126 URL: http://svn.freebsd.org/changeset/base/225126 Log: Tidy this up a bit 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 24 00:45:53 2011 (r225125) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Wed Aug 24 03:09:02 2011 (r225126) @@ -1879,15 +1879,19 @@ _ath_getbuf_locked(struct ath_softc *sc) TAILQ_REMOVE(&sc->sc_txbuf, bf, bf_list); else bf = NULL; + if (bf == NULL) { DPRINTF(sc, ATH_DEBUG_XMIT, "%s: %s\n", __func__, TAILQ_FIRST(&sc->sc_txbuf) == NULL ? "out of xmit buffers" : "xmit buffer busy"); - } else { - bf->bf_next = NULL; /* XXX just to be sure */ - bf->bf_last = NULL; /* XXX again, just to be sure */ - bf->bf_comp = NULL; /* XXX again, just to be sure */ + return NULL; } + + /* Valid bf here; clear some basic fields */ + bf->bf_next = NULL; /* XXX just to be sure */ + bf->bf_last = NULL; /* XXX again, just to be sure */ + bf->bf_comp = NULL; /* XXX again, just to be sure */ + return bf; } From owner-svn-src-user@FreeBSD.ORG Wed Aug 24 04:06:21 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 E581D106564A; Wed, 24 Aug 2011 04:06:21 +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 D5A848FC08; Wed, 24 Aug 2011 04:06: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 p7O46Lwf032538; Wed, 24 Aug 2011 04:06:21 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7O46L1s032535; Wed, 24 Aug 2011 04:06:21 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108240406.p7O46L1s032535@svn.freebsd.org> From: Adrian Chadd Date: Wed, 24 Aug 2011 04:06: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: r225127 - 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, 24 Aug 2011 04:06:22 -0000 Author: adrian Date: Wed Aug 24 04:06:21 2011 New Revision: 225127 URL: http://svn.freebsd.org/changeset/base/225127 Log: * Begin fleshing out ath_buf_clone() - a method of cloning buffers for reuse during software retransmit * Break out the buffer reclaimation code into ath_freebuf(), which doesn't recycle the mbuf/node or call the net80211 callback. * Change _ath_getbuf_locked() to use ath_freebuf(). This changes the order of DMA unmap and buffer free, so keep that in mind. The (eventual) aim of ath_freebuf() is to allow a buffer to be cloned, and the original buffer to then be returned. The caller can blank the node/mbuf and call ath_freebuf(). Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath.c user/adrian/if_ath_tx/sys/dev/ath/if_ath_misc.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 24 03:09:02 2011 (r225126) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Wed Aug 24 04:06:21 2011 (r225127) @@ -1895,6 +1895,61 @@ _ath_getbuf_locked(struct ath_softc *sc) return bf; } +/* + * When retrying a software frame, buffers marked ATH_BUF_BUSY + * can't be thrown back on the queue as they could still be + * in use by the hardware. + * + * This duplicates the buffer, or returns NULL. + * + * The descriptor is also copied but the link pointers and + * the DMA segments aren't copied; this frame should thus + * be again passed through the descriptor setup/chain routines + * so the link is correct. + * + * XXX TODO: the source buffer is still valid; so the mbuf + * XXX will be freed when that buffer is freed! The bf callback + * XXX will be called too, etc, etc. + * XXX so the caller must handle this somehow! + */ +struct ath_buf * +ath_buf_clone(struct ath_softc *sc, const struct ath_buf *bf) +{ + struct ath_buf *tbf; + + tbf = ath_getbuf(sc); + if (tbf == NULL) + return NULL; /* XXX failure? Why? */ + + /* Copy basics */ + tbf->bf_next = bf->bf_next; + tbf->bf_nseg = bf->bf_nseg; + tbf->bf_txflags = bf->bf_txflags; + tbf->bf_flags = bf->bf_flags; + tbf->bf_status = bf->bf_status; + tbf->bf_m = bf->bf_m; + tbf->bf_node = bf->bf_node; + /* will be setup by the chain/setup function */ + tbf->bf_lastds = NULL; + /* for now, last == self */ + tbf->bf_last = tbf; + tbf->bf_comp = bf->bf_comp; + + /* NOTE: DMA segments will be setup by the setup/chain functions */ + + /* + * Copy the descriptor contents - just the active + * number of segments. + */ + memcpy(tbf->bf_desc, bf->bf_desc, + bf->bf_nseg * sizeof(struct ath_desc)); + + /* Copy status */ + memcpy(&tbf->bf_state, &bf->bf_state, sizeof(bf->bf_state)); + + return tbf; +} + struct ath_buf * ath_getbuf(struct ath_softc *sc) { @@ -4515,6 +4570,22 @@ ath_tx_sched_proc_sched(struct ath_softc } /* + * Return a buffer to the pool. + * The caller must free the mbuf and recycle the node reference. + */ +void +ath_freebuf(struct ath_softc *sc, struct ath_buf *bf) +{ + bus_dmamap_unload(sc->sc_dmat, bf->bf_dmamap); + + KASSERT((bf->bf_node == NULL), ("%s: bf->bf_node != NULL\n", __func__)); + KASSERT((bf->bf_m == NULL), ("%s: bf->bf_m != NULL\n", __func__)); + ATH_TXBUF_LOCK(sc); + TAILQ_INSERT_TAIL(&sc->sc_txbuf, bf, bf_list); + ATH_TXBUF_UNLOCK(sc); +} + +/* * This is currently used by ath_tx_draintxq() and * ath_tx_tid_free_pkts(). * @@ -4523,31 +4594,30 @@ ath_tx_sched_proc_sched(struct ath_softc void ath_tx_freebuf(struct ath_softc *sc, struct ath_buf *bf, int status) { - struct ieee80211_node *ni; + struct ieee80211_node *ni = bf->bf_node; + struct mbuf *m0 = bf->bf_m; - bus_dmamap_unload(sc->sc_dmat, bf->bf_dmamap); - ni = bf->bf_node; bf->bf_node = NULL; + bf->bf_m = NULL; + + /* Free the buffer, it's not needed any longer */ + ath_freebuf(sc, bf); + if (ni != NULL) { /* * Do any callback and reclaim the node reference. */ - if (bf->bf_m->m_flags & M_TXCB) - ieee80211_process_callback(ni, bf->bf_m, status); + if (m0->m_flags & M_TXCB) + ieee80211_process_callback(ni, m0, status); ieee80211_free_node(ni); } - m_freem(bf->bf_m); - bf->bf_m = NULL; + m_freem(m0); /* - * XXX This is incorrect. Check what the -HEAD code is doing. - * XXX The TDMA code will be broken if this isn't properly repaired. + * XXX the buffer used to be freed -after-, but the DMA map was + * freed where ath_freebuf() now is. I've no idea what this + * will do. */ - bf->bf_flags &= ~ATH_BUF_BUSY; - - ATH_TXBUF_LOCK(sc); - TAILQ_INSERT_TAIL(&sc->sc_txbuf, bf, bf_list); - ATH_TXBUF_UNLOCK(sc); } void Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_misc.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_misc.h Wed Aug 24 03:09:02 2011 (r225126) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_misc.h Wed Aug 24 04:06:21 2011 (r225127) @@ -52,6 +52,9 @@ extern int ath_tx_findrix(const struct a extern struct ath_buf * ath_getbuf(struct ath_softc *sc); extern struct ath_buf * _ath_getbuf_locked(struct ath_softc *sc); +extern struct ath_buf * ath_buf_clone(struct ath_softc *sc, + const struct ath_buf *bf); +extern void ath_freebuf(struct ath_softc *sc, struct ath_buf *bf); extern int ath_reset(struct ifnet *); extern void ath_tx_draintxq(struct ath_softc *sc, struct ath_txq *txq); From owner-svn-src-user@FreeBSD.ORG Wed Aug 24 04:42:32 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 14693106564A; Wed, 24 Aug 2011 04:42:32 +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 04F7F8FC12; Wed, 24 Aug 2011 04:42:32 +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 p7O4gVJq033654; Wed, 24 Aug 2011 04:42:31 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7O4gVJV033652; Wed, 24 Aug 2011 04:42:31 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108240442.p7O4gVJV033652@svn.freebsd.org> From: Adrian Chadd Date: Wed, 24 Aug 2011 04:42: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: r225128 - 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, 24 Aug 2011 04:42:32 -0000 Author: adrian Date: Wed Aug 24 04:42:31 2011 New Revision: 225128 URL: http://svn.freebsd.org/changeset/base/225128 Log: Clear the ATH_BUF_BUSY flag on cloned buffers. 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 24 04:06:21 2011 (r225127) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Wed Aug 24 04:42:31 2011 (r225128) @@ -1925,7 +1925,7 @@ ath_buf_clone(struct ath_softc *sc, cons tbf->bf_next = bf->bf_next; tbf->bf_nseg = bf->bf_nseg; tbf->bf_txflags = bf->bf_txflags; - tbf->bf_flags = bf->bf_flags; + tbf->bf_flags = bf->bf_flags & ~ATH_BUF_BUSY; tbf->bf_status = bf->bf_status; tbf->bf_m = bf->bf_m; tbf->bf_node = bf->bf_node; From owner-svn-src-user@FreeBSD.ORG Wed Aug 24 05:59: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 D75591065670; Wed, 24 Aug 2011 05:59: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 C7D248FC17; Wed, 24 Aug 2011 05:59: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 p7O5xwma035914; Wed, 24 Aug 2011 05:59:58 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7O5xws1035912; Wed, 24 Aug 2011 05:59:58 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108240559.p7O5xws1035912@svn.freebsd.org> From: Adrian Chadd Date: Wed, 24 Aug 2011 05:59:58 +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: r225129 - 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, 24 Aug 2011 05:59:58 -0000 Author: adrian Date: Wed Aug 24 05:59:58 2011 New Revision: 225129 URL: http://svn.freebsd.org/changeset/base/225129 Log: * Setup bf_lastds when fiddling with beacon descriptors * Restore a DMA unmap call I removed earlier 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 24 04:42:31 2011 (r225128) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Wed Aug 24 05:59:58 2011 (r225129) @@ -2494,6 +2494,7 @@ ath_beacon_setup(struct ath_softc *sc, s /* setup descriptors */ ds = bf->bf_desc; bf->bf_last = bf; + bf->bf_lastds = ds; flags = HAL_TXDESC_NOACK; if (ic->ic_opmode == IEEE80211_M_IBSS && sc->sc_hasveol) { @@ -4577,6 +4578,7 @@ void ath_freebuf(struct ath_softc *sc, struct ath_buf *bf) { bus_dmamap_unload(sc->sc_dmat, bf->bf_dmamap); + bus_dmamap_sync(sc->sc_dmat, bf->bf_dmamap, BUS_DMASYNC_POSTWRITE); KASSERT((bf->bf_node == NULL), ("%s: bf->bf_node != NULL\n", __func__)); KASSERT((bf->bf_m == NULL), ("%s: bf->bf_m != NULL\n", __func__)); From owner-svn-src-user@FreeBSD.ORG Wed Aug 24 06:49: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 75D30106564A; Wed, 24 Aug 2011 06:49: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 6614E8FC13; Wed, 24 Aug 2011 06:49: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 p7O6nvak037429; Wed, 24 Aug 2011 06:49:57 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7O6nvPV037427; Wed, 24 Aug 2011 06:49:57 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108240649.p7O6nvPV037427@svn.freebsd.org> From: Adrian Chadd Date: Wed, 24 Aug 2011 06:49: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: r225130 - 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, 24 Aug 2011 06:49:57 -0000 Author: adrian Date: Wed Aug 24 06:49:57 2011 New Revision: 225130 URL: http://svn.freebsd.org/changeset/base/225130 Log: Eliminate a dangling bf_next when creating a cloned buf; new buffers are not part of an aggregate. 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 24 05:59:58 2011 (r225129) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Wed Aug 24 06:49:57 2011 (r225130) @@ -1922,7 +1922,7 @@ ath_buf_clone(struct ath_softc *sc, cons return NULL; /* XXX failure? Why? */ /* Copy basics */ - tbf->bf_next = bf->bf_next; + tbf->bf_next = NULL; tbf->bf_nseg = bf->bf_nseg; tbf->bf_txflags = bf->bf_txflags; tbf->bf_flags = bf->bf_flags & ~ATH_BUF_BUSY; From owner-svn-src-user@FreeBSD.ORG Wed Aug 24 06:57: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 2721D106566B; Wed, 24 Aug 2011 06:57:30 +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 167C58FC08; Wed, 24 Aug 2011 06:57: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 p7O6vTWo037683; Wed, 24 Aug 2011 06:57:29 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7O6vT1T037681; Wed, 24 Aug 2011 06:57:29 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108240657.p7O6vT1T037681@svn.freebsd.org> From: Adrian Chadd Date: Wed, 24 Aug 2011 06:57:29 +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: r225131 - 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, 24 Aug 2011 06:57:30 -0000 Author: adrian Date: Wed Aug 24 06:57:29 2011 New Revision: 225131 URL: http://svn.freebsd.org/changeset/base/225131 Log: Begin fleshing out busy buffer handling in the software retry path. If the buffer is marked ATH_BUF_BUSY, the hardware may still be pointing at the link pointer in that descriptor. So the software retry code can't simply throw the descriptor back into the work list. 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 24 06:49:57 2011 (r225130) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Wed Aug 24 06:57:29 2011 (r225131) @@ -2345,6 +2345,44 @@ ath_tx_set_retry(struct ath_softc *sc, s wh->i_fc[1] |= IEEE80211_FC1_RETRY; } +static struct ath_buf * +ath_tx_retry_clone(struct ath_softc *sc, struct ath_buf *bf) +{ + struct ath_buf *nbf; + int error; + + nbf = ath_buf_clone(sc, bf); + +#if 0 + device_printf(sc->sc_dev, "%s: ATH_BUF_BUSY; cloning\n", + __func__); +#endif + + if (nbf == NULL) { + /* Failed to clone */ + device_printf(sc->sc_dev, + "%s: failed to clone a busy buffer\n", + __func__); + return NULL; + } + + /* Setup the dma for the new buffer */ + error = ath_tx_dmasetup(sc, nbf, nbf->bf_m); + if (error != 0) { + device_printf(sc->sc_dev, + "%s: failed to setup dma for clone\n", + __func__); + ath_freebuf(sc, nbf); + return NULL; + } + + /* Free current buffer; return the older buffer */ + bf->bf_m = NULL; + bf->bf_node = NULL; + ath_freebuf(sc, bf); + return nbf; +} + /* * Handle retrying an unaggregate frame in an aggregate * session. @@ -2366,6 +2404,24 @@ ath_tx_aggr_retry_unaggr(struct ath_soft tap = ath_tx_get_tx_tid(an, tid); + /* + * If the buffer is marked as busy, we can't directly + * reuse it. Instead, try to clone the buffer. + * If the clone is successful, recycle the old buffer. + * If the clone is unsuccessful, set bfs_retries to max + * to force the next bit of code to free the buffer + * for us. + */ + if (bf->bf_flags & ATH_BUF_BUSY) { + struct ath_buf *nbf; + nbf = ath_tx_retry_clone(sc, bf); + if (nbf) + /* bf has been freed at this point */ + bf = nbf; + else + bf->bf_state.bfs_retries = SWMAX_RETRIES + 1; + } + if (bf->bf_state.bfs_retries >= SWMAX_RETRIES) { device_printf(sc->sc_dev, "%s: exceeded retries; seqno %d\n", __func__, SEQNO(bf->bf_state.bfs_seqno)); @@ -2421,28 +2477,6 @@ ath_tx_aggr_retry_unaggr(struct ath_soft ath_tx_set_retry(sc, bf); /* - * XXX Clear the ATH_BUF_BUSY flag. This is likely incorrect - * XXX and must be revisited before this is merged into -HEAD. - * - * This flag is set in ath_tx_processq() if the HW TXQ has - * further frames on it. The hardware may currently be processing - * the link field in the descriptor (because for TDMA, the - * QCU (TX queue DMA engine) can stop until the next TX slot is - * available and a recycled buffer may still contain a descriptor - * which the currently-paused QCU still points to. - * - * Since I'm not worried about TDMA just for now, I'm going to blank - * the flag. - */ - if (bf->bf_flags & ATH_BUF_BUSY) { - bf->bf_flags &= ~ ATH_BUF_BUSY; -#if 0 - DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, - "%s: bf %p: ATH_BUF_BUSY\n", __func__, bf); -#endif - } - - /* * Insert this at the head of the queue, so it's * retried before any current/subsequent frames. */ @@ -2475,6 +2509,24 @@ ath_tx_retry_subframe(struct ath_softc * ath_hal_set11nburstduration(sc->sc_ah, bf->bf_desc, 0); /* ath_hal_set11n_virtualmorefrag(sc->sc_ah, bf->bf_desc, 0); */ + /* + * If the buffer is marked as busy, we can't directly + * reuse it. Instead, try to clone the buffer. + * If the clone is successful, recycle the old buffer. + * If the clone is unsuccessful, set bfs_retries to max + * to force the next bit of code to free the buffer + * for us. + */ + if (bf->bf_flags & ATH_BUF_BUSY) { + struct ath_buf *nbf; + nbf = ath_tx_retry_clone(sc, bf); + if (nbf) + /* bf has been freed at this point */ + bf = nbf; + else + bf->bf_state.bfs_retries = SWMAX_RETRIES + 1; + } + if (bf->bf_state.bfs_retries >= SWMAX_RETRIES) { device_printf(sc->sc_dev, "%s: max retries: seqno %d\n", __func__, SEQNO(bf->bf_state.bfs_seqno)); @@ -2491,14 +2543,6 @@ ath_tx_retry_subframe(struct ath_softc * return 1; } - if (bf->bf_flags & ATH_BUF_BUSY) { - bf->bf_flags &= ~ ATH_BUF_BUSY; -#if 0 - DPRINTF(sc, ATH_DEBUG_SW_TX_CTRL, - "%s: bf %p: ATH_BUF_BUSY\n", __func__, bf); -#endif - } - ath_tx_set_retry(sc, bf); bf->bf_next = NULL; /* Just to make sure */ @@ -2935,8 +2979,6 @@ ath_tx_tid_hw_queue_aggr(struct ath_soft ATH_TXQ_REMOVE(atid, bf, bf_list); ATH_TXQ_UNLOCK(atid); bf->bf_state.bfs_aggr = 0; - /* Ensure the last descriptor link is 0 */ - bf->bf_lastds->ds_link = 0; ath_tx_setds(sc, bf); ath_tx_chaindesclist(sc, bf); ath_hal_clr11n_aggr(sc->sc_ah, bf->bf_desc); @@ -2977,8 +3019,6 @@ 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; - /* Ensure the last descriptor link is 0 */ - bf->bf_lastds->ds_link = 0; ath_tx_setds(sc, bf); ath_tx_chaindesclist(sc, bf); ath_hal_clr11n_aggr(sc->sc_ah, bf->bf_desc); From owner-svn-src-user@FreeBSD.ORG Wed Aug 24 07:00: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 CBF65106566B; Wed, 24 Aug 2011 07:00:00 +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 B6DAC8FC16; Wed, 24 Aug 2011 07:00: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 p7O700xK037783; Wed, 24 Aug 2011 07:00:00 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7O6xxvr037781; Wed, 24 Aug 2011 06:59:59 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108240659.p7O6xxvr037781@svn.freebsd.org> From: Adrian Chadd Date: Wed, 24 Aug 2011 06:59: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: r225132 - 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, 24 Aug 2011 07:00:00 -0000 Author: adrian Date: Wed Aug 24 06:59:59 2011 New Revision: 225132 URL: http://svn.freebsd.org/changeset/base/225132 Log: Add a comment describing what may occur during retries. Another thing to sort out before this is merged into -HEAD. 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 24 06:57:29 2011 (r225131) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Wed Aug 24 06:59:59 2011 (r225132) @@ -1907,10 +1907,13 @@ _ath_getbuf_locked(struct ath_softc *sc) * be again passed through the descriptor setup/chain routines * so the link is correct. * - * XXX TODO: the source buffer is still valid; so the mbuf - * XXX will be freed when that buffer is freed! The bf callback - * XXX will be called too, etc, etc. - * XXX so the caller must handle this somehow! + * The caller must free the buffer using ath_freebuf(). + * + * XXX TODO: this call shouldn't fail as it'll cause packet loss + * XXX in the TX pathway when retries are needed. + * XXX Figure out how to keep some buffers free, or factor the + * XXX number of busy buffers into the xmit path (ath_start()) + * XXX so we don't over-commit. */ struct ath_buf * ath_buf_clone(struct ath_softc *sc, const struct ath_buf *bf) From owner-svn-src-user@FreeBSD.ORG Wed Aug 24 07:28: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 0DC311065673; Wed, 24 Aug 2011 07:28:05 +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 EB97A8FC14; Wed, 24 Aug 2011 07:28: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 p7O7S4L8038665; Wed, 24 Aug 2011 07:28:04 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7O7S4bO038663; Wed, 24 Aug 2011 07:28:04 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108240728.p7O7S4bO038663@svn.freebsd.org> From: Adrian Chadd Date: Wed, 24 Aug 2011 07:28: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: r225133 - 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, 24 Aug 2011 07:28:08 -0000 Author: adrian Date: Wed Aug 24 07:28:04 2011 New Revision: 225133 URL: http://svn.freebsd.org/changeset/base/225133 Log: The descriptor + link is going to be updated anyway; so there's no need to copy the descriptors into the cloned buffer. 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 24 06:59:59 2011 (r225132) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Wed Aug 24 07:28:04 2011 (r225133) @@ -1940,14 +1940,9 @@ ath_buf_clone(struct ath_softc *sc, cons /* NOTE: DMA segments will be setup by the setup/chain functions */ - /* - * Copy the descriptor contents - just the active - * number of segments. - */ - memcpy(tbf->bf_desc, bf->bf_desc, - bf->bf_nseg * sizeof(struct ath_desc)); + /* The caller has to re-init the descriptor + links */ - /* Copy status */ + /* Copy state */ memcpy(&tbf->bf_state, &bf->bf_state, sizeof(bf->bf_state)); return tbf; From owner-svn-src-user@FreeBSD.ORG Wed Aug 24 08:27: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 EF662106566C; Wed, 24 Aug 2011 08:27:00 +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 DFB878FC1B; Wed, 24 Aug 2011 08:27: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 p7O8R0gt040568; Wed, 24 Aug 2011 08:27:00 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7O8R0Uk040566; Wed, 24 Aug 2011 08:27:00 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108240827.p7O8R0Uk040566@svn.freebsd.org> From: Adrian Chadd Date: Wed, 24 Aug 2011 08:27: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: r225136 - 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, 24 Aug 2011 08:27:01 -0000 Author: adrian Date: Wed Aug 24 08:27:00 2011 New Revision: 225136 URL: http://svn.freebsd.org/changeset/base/225136 Log: Add some debugging to spit out the txbuf count and busy txbuf count. Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_sysctl.c 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 24 07:52:55 2011 (r225135) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_sysctl.c Wed Aug 24 08:27:00 2011 (r225136) @@ -302,8 +302,9 @@ static int ath_sysctl_txagg(SYSCTL_HANDLER_ARGS) { struct ath_softc *sc = arg1; - int i, param = 0; + int i, t, param = 0; int error; + struct ath_buf *bf; error = sysctl_handle_int(oidp, ¶m, 0, req); if (error || !req->newptr) @@ -336,6 +337,19 @@ ath_sysctl_txagg(SYSCTL_HANDLER_ARGS) } } + i = t = 0; + ATH_TXBUF_LOCK(sc); + TAILQ_FOREACH(bf, &sc->sc_txbuf, bf_list) { + if (bf->bf_flags & ATH_BUF_BUSY) { + printf("Busy: %d\n", t); + i++; + } + t++; + } + ATH_TXBUF_UNLOCK(sc); + printf("Total TX buffers: %d; Total TX buffers busy: %d\n", + t, i); + return 0; } From owner-svn-src-user@FreeBSD.ORG Wed Aug 24 08:32: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 65FB9106566B; Wed, 24 Aug 2011 08:32: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 3D0068FC23; Wed, 24 Aug 2011 08:32: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 p7O8Wqlh040769; Wed, 24 Aug 2011 08:32:52 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7O8WqUo040767; Wed, 24 Aug 2011 08:32:52 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108240832.p7O8WqUo040767@svn.freebsd.org> From: Adrian Chadd Date: Wed, 24 Aug 2011 08:32: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: r225137 - 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, 24 Aug 2011 08:32:52 -0000 Author: adrian Date: Wed Aug 24 08:32:51 2011 New Revision: 225137 URL: http://svn.freebsd.org/changeset/base/225137 Log: Fix a TX hang that crept in when I flipped in ATH_BUF_BUSY / TX buf cloning. This was due to an ATH_BUF_BUSY buffer ending up at the head of the txbuf list, causing ath_getbuf() to halt TX until the TX queue had caught up. Since the TX queue wasn't -really- full, TX would stay paused. The basic problem: because I just checked the busy flag, the: * buffer would be cloned; the ATH_BUF_BUSY tagged buffer would be freed and tossed onto the end of the list; * if the new cloned buffer (not busy) was already at max retries, the new non-busy buffer would be freed, and added to the end of the list; and thus the busy buffer isn't at the end of the list; * .. and bewm. The flag would never be cleared. Also, whilst I'm at it, add a comment about an error condition if the buffer can't be cloned - i may end up confusing the DMA code a bit. I'll sort that out later. 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 24 08:27:00 2011 (r225136) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Wed Aug 24 08:32:51 2011 (r225137) @@ -2372,6 +2372,7 @@ ath_tx_retry_clone(struct ath_softc *sc, device_printf(sc->sc_dev, "%s: failed to setup dma for clone\n", __func__); + /* XXX this frees the dmasetup that failed above? */ ath_freebuf(sc, nbf); return NULL; } @@ -2412,7 +2413,8 @@ ath_tx_aggr_retry_unaggr(struct ath_soft * to force the next bit of code to free the buffer * for us. */ - if (bf->bf_flags & ATH_BUF_BUSY) { + if ((bf->bf_state.bfs_retries < SWMAX_RETRIES) && + (bf->bf_flags & ATH_BUF_BUSY)) { struct ath_buf *nbf; nbf = ath_tx_retry_clone(sc, bf); if (nbf) @@ -2517,7 +2519,8 @@ ath_tx_retry_subframe(struct ath_softc * * to force the next bit of code to free the buffer * for us. */ - if (bf->bf_flags & ATH_BUF_BUSY) { + if ((bf->bf_state.bfs_retries < SWMAX_RETRIES) && + (bf->bf_flags & ATH_BUF_BUSY)) { struct ath_buf *nbf; nbf = ath_tx_retry_clone(sc, bf); if (nbf) From owner-svn-src-user@FreeBSD.ORG Wed Aug 24 08:38: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 B15581065673; Wed, 24 Aug 2011 08:38: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 A17668FC14; Wed, 24 Aug 2011 08:38: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 p7O8ciWN040981; Wed, 24 Aug 2011 08:38:44 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7O8ciAR040978; Wed, 24 Aug 2011 08:38:44 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108240838.p7O8ciAR040978@svn.freebsd.org> From: Adrian Chadd Date: Wed, 24 Aug 2011 08:38: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: r225138 - 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, 24 Aug 2011 08:38:44 -0000 Author: adrian Date: Wed Aug 24 08:38:44 2011 New Revision: 225138 URL: http://svn.freebsd.org/changeset/base/225138 Log: Create a new debug flag to print out the software retries. Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_debug.h user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Modified: user/adrian/if_ath_tx/sys/dev/ath/if_ath_debug.h ============================================================================== --- user/adrian/if_ath_tx/sys/dev/ath/if_ath_debug.h Wed Aug 24 08:32:51 2011 (r225137) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_debug.h Wed Aug 24 08:38:44 2011 (r225138) @@ -61,6 +61,7 @@ enum { ATH_DEBUG_SW_TX_BAW = 0x08000000, /* BAW handling */ ATH_DEBUG_SW_TX_CTRL = 0x10000000, /* queue control */ ATH_DEBUG_SW_TX_AGGR = 0x20000000, /* aggregate TX */ + ATH_DEBUG_SW_TX_RETRIES = 0x40000000, /* software TX retries */ ATH_DEBUG_FATAL = 0x80000000, /* fatal errors */ ATH_DEBUG_ANY = 0xffffffff }; 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 24 08:32:51 2011 (r225137) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Wed Aug 24 08:38:44 2011 (r225138) @@ -2425,7 +2425,8 @@ ath_tx_aggr_retry_unaggr(struct ath_soft } if (bf->bf_state.bfs_retries >= SWMAX_RETRIES) { - device_printf(sc->sc_dev, "%s: exceeded retries; seqno %d\n", + DPRINTF(sc, ATH_DEBUG_SW_TX_RETRIES, + "%s: exceeded retries; seqno %d\n", __func__, SEQNO(bf->bf_state.bfs_seqno)); sc->sc_stats.ast_tx_swretrymax++; @@ -2531,7 +2532,8 @@ ath_tx_retry_subframe(struct ath_softc * } if (bf->bf_state.bfs_retries >= SWMAX_RETRIES) { - device_printf(sc->sc_dev, "%s: max retries: seqno %d\n", + 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)); From owner-svn-src-user@FreeBSD.ORG Wed Aug 24 18:41: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 13E8E106566B; Wed, 24 Aug 2011 18:41:49 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0200F8FC13; Wed, 24 Aug 2011 18:41: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 p7OIfm2m066095; Wed, 24 Aug 2011 18:41:49 GMT (envelope-from hrs@svn.freebsd.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7OIfm02066093; Wed, 24 Aug 2011 18:41:48 GMT (envelope-from hrs@svn.freebsd.org) Message-Id: <201108241841.p7OIfm02066093@svn.freebsd.org> From: Hiroki Sato Date: Wed, 24 Aug 2011 18:41: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: r225148 - user/hrs/ipv6/usr.sbin/rtadvd 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, 24 Aug 2011 18:41:49 -0000 Author: hrs Date: Wed Aug 24 18:41:48 2011 New Revision: 225148 URL: http://svn.freebsd.org/changeset/base/225148 Log: Refine log messages. Modified: user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.c Modified: user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.c ============================================================================== --- user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.c Wed Aug 24 14:53:49 2011 (r225147) +++ user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.c Wed Aug 24 18:41:48 2011 (r225148) @@ -189,7 +189,7 @@ main(int argc, char *argv[]) dflag++; break; case 'D': - dflag += 2; + dflag += 3; break; case 'f': fflag = 1; @@ -227,10 +227,12 @@ main(int argc, char *argv[]) openlog("rtadvd", logopt, LOG_DAEMON); /* set log level */ - if (dflag > 1) + if (dflag > 2) (void)setlogmask(LOG_UPTO(LOG_DEBUG)); - else if (dflag > 0) + else if (dflag > 1) (void)setlogmask(LOG_UPTO(LOG_INFO)); + else if (dflag > 0) + (void)setlogmask(LOG_UPTO(LOG_NOTICE)); else (void)setlogmask(LOG_UPTO(LOG_ERR)); @@ -251,8 +253,8 @@ main(int argc, char *argv[]) errx(1, "%s already running, pid: %d", getprogname(), otherpid); syslog(LOG_ERR, - "<%s> failed to open the pid log file, run anyway.", - __func__); + "failed to open the pid file %s, run anyway.", + pidfilename); } if (!fflag) daemon(1, 0); @@ -265,7 +267,8 @@ main(int argc, char *argv[]) csock_open(&ctrlsock, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH); if (ctrlsock.si_fd == -1) { - syslog(LOG_ERR, "<%s> cannot open control socket", __func__); + syslog(LOG_ERR, "cannot open control socket: %s", + strerror(errno)); exit(1); } @@ -289,7 +292,8 @@ main(int argc, char *argv[]) error = csock_listen(&ctrlsock); if (error) { - syslog(LOG_ERR, "<%s> listen failed", __func__); + syslog(LOG_ERR, "cannot listen control socket: %s", + strerror(errno)); exit(1); } @@ -332,10 +336,11 @@ main(int argc, char *argv[]) if ((i = poll(set, sizeof(set)/sizeof(set[0]), timeout ? (timeout->tv_sec * 1000 + timeout->tv_usec / 1000) : INFTIM)) < 0) { - /* EINTR would occur upon SIGUSR1 for status dump */ + + /* EINTR would occur if a signal was delivered */ if (errno != EINTR) - syslog(LOG_ERR, "<%s> select: %s", - __func__, strerror(errno)); + syslog(LOG_ERR, "poll() failed: %s", + strerror(errno)); continue; } if (i == 0) /* timeout */ @@ -351,7 +356,9 @@ main(int argc, char *argv[]) fd = csock_accept(&ctrlsock); if (fd == -1) - syslog(LOG_ERR, "<%s> accept", __func__); + syslog(LOG_ERR, + "cannot accept() control socket: %s", + strerror(errno)); else { cm_handler_server(fd); close(fd); @@ -371,14 +378,14 @@ rtadvd_shutdown(void) if (wait_shutdown) { syslog(LOG_INFO, - "waiting expiration of the all RA timers\n"); + "waiting expiration of the all RA timers."); TAILQ_FOREACH(ifi, &ifilist, ifi_next) { if (ifi->ifi_ra_timer != NULL) break; } if (ifi == NULL) { - syslog(LOG_INFO, "gracefully terminated.\n"); + syslog(LOG_NOTICE, "gracefully terminated."); exit(0); } @@ -386,7 +393,7 @@ rtadvd_shutdown(void) return; } - syslog(LOG_DEBUG, "<%s> cease to be an advertising router\n", + syslog(LOG_DEBUG, "<%s> cease to be an advertising router", __func__); wait_shutdown = 1; @@ -431,8 +438,7 @@ rtadvd_shutdown(void) rtadvd_set_timer(&ifi->ifi_ra_timer->rat_tm, ifi->ifi_ra_timer); } - syslog(LOG_INFO, - "<%s> final RA transmission started.\n", __func__); + syslog(LOG_NOTICE, "final RA transmission started."); pidfile_remove(pfh); csock_close(&ctrlsock); @@ -518,20 +524,20 @@ rtmsg_input(struct sockinfo *s) continue; } - syslog(LOG_INFO, "<%s>: if_announcemsg (idx=%d:%d)", + syslog(LOG_DEBUG, "<%s>: if_announcemsg (idx=%d:%d)", __func__, ifan->ifan_index, ifan->ifan_what); switch (ifan->ifan_what) { case IFAN_ARRIVAL: - syslog(LOG_INFO, - "<%s>: interface added (idx=%d)", - __func__, ifan->ifan_index); + syslog(LOG_NOTICE, + "interface added (idx=%d)", + ifan->ifan_index); update_ifinfo(&ifilist, ifan->ifan_index); loadconfig_index(ifan->ifan_index); break; case IFAN_DEPARTURE: - syslog(LOG_INFO, - "<%s>: interface removed (idx=%d)", - __func__, ifan->ifan_index); + syslog(LOG_NOTICE, + "interface removed (idx=%d)", + ifan->ifan_index); rm_ifinfo_index(ifan->ifan_index); /* Clear ifi_ifindex */ @@ -657,16 +663,16 @@ rtmsg_input(struct sockinfo *s) /* check if an interface flag is changed */ if ((oldifflags & IFF_UP) && /* UP to DOWN */ !(ifi->ifi_flags & IFF_UP)) { - syslog(LOG_INFO, - "<%s> interface %s becomes down. stop timer.", - __func__, ifi->ifi_ifname); + syslog(LOG_NOTICE, + "ifi_ifname); rtadvd_remove_timer(ifi->ifi_ra_timer); ifi->ifi_ra_timer = NULL; } else if (!(oldifflags & IFF_UP) && /* DOWN to UP */ (ifi->ifi_flags & IFF_UP)) { - syslog(LOG_INFO, - "<%s> interface %s becomes up. restart timer.", - __func__, ifi->ifi_ifname); + syslog(LOG_NOTICE, + "interface %s becomes up. restart timer.", + ifi->ifi_ifname); ifi->ifi_state = IFI_STATE_TRANSITIVE; ifi->ifi_burstcount = @@ -740,15 +746,11 @@ rtadvd_input(struct sockinfo *s) hlimp = (int *)CMSG_DATA(cm); } if (ifindex == 0) { - syslog(LOG_ERR, - "<%s> failed to get receiving interface", - __func__); + syslog(LOG_ERR, "failed to get receiving interface"); return; } if (hlimp == NULL) { - syslog(LOG_ERR, - "<%s> failed to get receiving hop limit", - __func__); + syslog(LOG_ERR, "failed to get receiving hop limit"); return; } @@ -768,8 +770,7 @@ rtadvd_input(struct sockinfo *s) #ifdef OLDRAWSOCKET if ((size_t)i < sizeof(struct ip6_hdr) + sizeof(struct icmp6_hdr)) { syslog(LOG_ERR, - "<%s> packet size(%d) is too short", - __func__, i); + "packet size(%d) is too short", i); return; } @@ -777,9 +778,7 @@ rtadvd_input(struct sockinfo *s) icp = (struct icmp6_hdr *)(ip + 1); /* XXX: ext. hdr? */ #else if ((size_t)i < sizeof(struct icmp6_hdr)) { - syslog(LOG_ERR, - "<%s> packet size(%zd) is too short", - __func__, i); + syslog(LOG_ERR, "packet size(%zd) is too short", i); return; } @@ -795,9 +794,9 @@ rtadvd_input(struct sockinfo *s) */ if (*hlimp != 255) { syslog(LOG_NOTICE, - "<%s> RS with invalid hop limit(%d) " + "RS with invalid hop limit(%d) " "received from %s on %s", - __func__, *hlimp, + *hlimp, inet_ntop(AF_INET6, &rcvfrom.sin6_addr, ntopbuf, sizeof(ntopbuf)), if_indextoname(pi->ipi6_ifindex, ifnamebuf)); @@ -805,9 +804,9 @@ rtadvd_input(struct sockinfo *s) } if (icp->icmp6_code) { syslog(LOG_NOTICE, - "<%s> RS with invalid ICMP6 code(%d) " + "RS with invalid ICMP6 code(%d) " "received from %s on %s", - __func__, icp->icmp6_code, + icp->icmp6_code, inet_ntop(AF_INET6, &rcvfrom.sin6_addr, ntopbuf, sizeof(ntopbuf)), if_indextoname(pi->ipi6_ifindex, ifnamebuf)); @@ -815,9 +814,8 @@ rtadvd_input(struct sockinfo *s) } if ((size_t)i < sizeof(struct nd_router_solicit)) { syslog(LOG_NOTICE, - "<%s> RS from %s on %s does not have enough " + "RS from %s on %s does not have enough " "length (len = %zd)", - __func__, inet_ntop(AF_INET6, &rcvfrom.sin6_addr, ntopbuf, sizeof(ntopbuf)), if_indextoname(pi->ipi6_ifindex, ifnamebuf), i); @@ -832,18 +830,18 @@ rtadvd_input(struct sockinfo *s) */ if (!IN6_IS_ADDR_LINKLOCAL(&rcvfrom.sin6_addr)) { syslog(LOG_NOTICE, - "<%s> RA witn non-linklocal source address " + "RA witn non-linklocal source address " "received from %s on %s", - __func__, inet_ntop(AF_INET6, &rcvfrom.sin6_addr, + inet_ntop(AF_INET6, &rcvfrom.sin6_addr, ntopbuf, sizeof(ntopbuf)), if_indextoname(pi->ipi6_ifindex, ifnamebuf)); return; } if (*hlimp != 255) { syslog(LOG_NOTICE, - "<%s> RA with invalid hop limit(%d) " + "RA with invalid hop limit(%d) " "received from %s on %s", - __func__, *hlimp, + *hlimp, inet_ntop(AF_INET6, &rcvfrom.sin6_addr, ntopbuf, sizeof(ntopbuf)), if_indextoname(pi->ipi6_ifindex, ifnamebuf)); @@ -851,9 +849,9 @@ rtadvd_input(struct sockinfo *s) } if (icp->icmp6_code) { syslog(LOG_NOTICE, - "<%s> RA with invalid ICMP6 code(%d) " + "RA with invalid ICMP6 code(%d) " "received from %s on %s", - __func__, icp->icmp6_code, + icp->icmp6_code, inet_ntop(AF_INET6, &rcvfrom.sin6_addr, ntopbuf, sizeof(ntopbuf)), if_indextoname(pi->ipi6_ifindex, ifnamebuf)); @@ -861,9 +859,8 @@ rtadvd_input(struct sockinfo *s) } if ((size_t)i < sizeof(struct nd_router_advert)) { syslog(LOG_NOTICE, - "<%s> RA from %s on %s does not have enough " + "RA from %s on %s does not have enough " "length (len = %zd)", - __func__, inet_ntop(AF_INET6, &rcvfrom.sin6_addr, ntopbuf, sizeof(ntopbuf)), if_indextoname(pi->ipi6_ifindex, ifnamebuf), i); @@ -873,9 +870,8 @@ rtadvd_input(struct sockinfo *s) break; case ICMP6_ROUTER_RENUMBERING: if (mcastif == NULL) { - syslog(LOG_ERR, "<%s> received a router renumbering " - "message, but not allowed to be accepted", - __func__); + syslog(LOG_ERR, "received a router renumbering " + "message, but not allowed to be accepted"); break; } rr_input(i, (struct icmp6_router_renum *)icp, pi, &rcvfrom, @@ -888,8 +884,7 @@ rtadvd_input(struct sockinfo *s) * could receive message after opening the socket and * before setting ICMP6 type filter(see sock_open()). */ - syslog(LOG_ERR, "<%s> invalid icmp type(%d)", - __func__, icp->icmp6_type); + syslog(LOG_ERR, "invalid icmp type(%d)", icp->icmp6_type); return; } @@ -1042,7 +1037,7 @@ check_accept_rtadv(int idx) break; } if (ifi == NULL) { - syslog(LOG_ERR, + syslog(LOG_DEBUG, "<%s> if (idx=%d) not found. Why?", __func__, idx); return (0); @@ -1060,9 +1055,7 @@ check_accept_rtadv(int idx) * RA_SEND: ip6.forwarding */ if (update_ifinfo_nd_flags(ifi) != 0) { - syslog(LOG_ERR, - "<%s> nd6 flags failed (idx=%d)", - __func__, idx); + syslog(LOG_ERR, "cannot get nd6 flags (idx=%d)", idx); return (0); } @@ -1120,16 +1113,16 @@ ra_input(int len, struct nd_router_adver } rai = ifi->ifi_rainfo; ifi->ifi_rainput++; - syslog(LOG_DEBUG, "<%s> ifi->ifi_rainput = %" PRIu64 "\n", __func__, + syslog(LOG_DEBUG, "<%s> ifi->ifi_rainput = %" PRIu64, __func__, ifi->ifi_rainput); /* Cur Hop Limit value */ if (nra->nd_ra_curhoplimit && rai->rai_hoplimit && nra->nd_ra_curhoplimit != rai->rai_hoplimit) { - syslog(LOG_INFO, - "<%s> CurHopLimit inconsistent on %s:" + syslog(LOG_NOTICE, + "CurHopLimit inconsistent on %s:" " %d from %s, %d from us", - __func__, ifi->ifi_ifname, nra->nd_ra_curhoplimit, + ifi->ifi_ifname, nra->nd_ra_curhoplimit, inet_ntop(AF_INET6, &from->sin6_addr, ntopbuf, sizeof(ntopbuf)), rai->rai_hoplimit); inconsistent++; @@ -1137,10 +1130,10 @@ ra_input(int len, struct nd_router_adver /* M flag */ if ((nra->nd_ra_flags_reserved & ND_RA_FLAG_MANAGED) != rai->rai_managedflg) { - syslog(LOG_INFO, - "<%s> M flag inconsistent on %s:" + syslog(LOG_NOTICE, + "M flag inconsistent on %s:" " %s from %s, %s from us", - __func__, ifi->ifi_ifname, on_off[!rai->rai_managedflg], + ifi->ifi_ifname, on_off[!rai->rai_managedflg], inet_ntop(AF_INET6, &from->sin6_addr, ntopbuf, sizeof(ntopbuf)), on_off[rai->rai_managedflg]); inconsistent++; @@ -1148,10 +1141,10 @@ ra_input(int len, struct nd_router_adver /* O flag */ if ((nra->nd_ra_flags_reserved & ND_RA_FLAG_OTHER) != rai->rai_otherflg) { - syslog(LOG_INFO, - "<%s> O flag inconsistent on %s:" + syslog(LOG_NOTICE, + "O flag inconsistent on %s:" " %s from %s, %s from us", - __func__, ifi->ifi_ifname, on_off[!rai->rai_otherflg], + ifi->ifi_ifname, on_off[!rai->rai_otherflg], inet_ntop(AF_INET6, &from->sin6_addr, ntopbuf, sizeof(ntopbuf)), on_off[rai->rai_otherflg]); inconsistent++; @@ -1160,10 +1153,10 @@ ra_input(int len, struct nd_router_adver reachabletime = ntohl(nra->nd_ra_reachable); if (reachabletime && rai->rai_reachabletime && reachabletime != rai->rai_reachabletime) { - syslog(LOG_INFO, - "<%s> ReachableTime inconsistent on %s:" + syslog(LOG_NOTICE, + "ReachableTime inconsistent on %s:" " %d from %s, %d from us", - __func__, ifi->ifi_ifname, reachabletime, + ifi->ifi_ifname, reachabletime, inet_ntop(AF_INET6, &from->sin6_addr, ntopbuf, sizeof(ntopbuf)), rai->rai_reachabletime); inconsistent++; @@ -1172,10 +1165,10 @@ ra_input(int len, struct nd_router_adver retranstimer = ntohl(nra->nd_ra_retransmit); if (retranstimer && rai->rai_retranstimer && retranstimer != rai->rai_retranstimer) { - syslog(LOG_INFO, - "<%s> RetranceTimer inconsistent on %s:" + syslog(LOG_NOTICE, + "RetranceTimer inconsistent on %s:" " %d from %s, %d from us", - __func__, ifi->ifi_ifname, retranstimer, + ifi->ifi_ifname, retranstimer, inet_ntop(AF_INET6, &from->sin6_addr, ntopbuf, sizeof(ntopbuf)), rai->rai_retranstimer); inconsistent++; @@ -1184,10 +1177,10 @@ ra_input(int len, struct nd_router_adver if (ndopts.opt_mtu) { mtu = ntohl(ndopts.opt_mtu->nd_opt_mtu_mtu); if (mtu && rai->rai_linkmtu && mtu != rai->rai_linkmtu) { - syslog(LOG_INFO, - "<%s> MTU option value inconsistent on %s:" + syslog(LOG_NOTICE, + "MTU option value inconsistent on %s:" " %d from %s, %d from us", - __func__, ifi->ifi_ifname, mtu, + ifi->ifi_ifname, mtu, inet_ntop(AF_INET6, &from->sin6_addr, ntopbuf, sizeof(ntopbuf)), rai->rai_linkmtu); inconsistent++; @@ -1696,18 +1689,18 @@ ra_output(struct ifinfo *ifi) ifi->ifi_ifname); if (rai->rai_lifetime != 0) { - if (check_accept_rtadv(ifi->ifi_ifindex)) { - syslog(LOG_INFO, - "<%s> non-zero lifetime RA " - "on RA receiving interface %s." - " Ignored.", __func__, ifi->ifi_ifname); - return; - } if (getinet6sysctl(IPV6CTL_FORWARDING) == 0) { - syslog(LOG_INFO, - "<%s> non-zero lifetime RA " + syslog(LOG_ERR, + "non-zero lifetime RA " "but net.inet6.ip6.forwarding=0. " - "Ignored.", __func__); + "Ignored."); + return; + } + if (check_accept_rtadv(ifi->ifi_ifindex)) { + syslog(LOG_ERR, + "non-zero lifetime RA " + "on RA receiving interface %s." + " Ignored.", ifi->ifi_ifname); return; } } From owner-svn-src-user@FreeBSD.ORG Wed Aug 24 18:44: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 ED370106566C; Wed, 24 Aug 2011 18:44:05 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DCB3A8FC08; Wed, 24 Aug 2011 18:44:05 +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 p7OIi55Q066212; Wed, 24 Aug 2011 18:44:05 GMT (envelope-from hrs@svn.freebsd.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7OIi5fX066210; Wed, 24 Aug 2011 18:44:05 GMT (envelope-from hrs@svn.freebsd.org) Message-Id: <201108241844.p7OIi5fX066210@svn.freebsd.org> From: Hiroki Sato Date: Wed, 24 Aug 2011 18:44:05 +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: r225149 - user/hrs/ipv6/usr.sbin/rtadvd 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, 24 Aug 2011 18:44:06 -0000 Author: hrs Date: Wed Aug 24 18:44:05 2011 New Revision: 225149 URL: http://svn.freebsd.org/changeset/base/225149 Log: Fix SIGSEGV when receiving RAs that contain RDNSS and/or DNSSL options. Spotted by: ps Modified: user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.c Modified: user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.c ============================================================================== --- user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.c Wed Aug 24 18:41:48 2011 (r225148) +++ user/hrs/ipv6/usr.sbin/rtadvd/rtadvd.c Wed Aug 24 18:44:05 2011 (r225149) @@ -910,6 +910,7 @@ rs_input(int len, struct nd_router_solic /* ND option check */ memset(&ndopts, 0, sizeof(ndopts)); + TAILQ_INIT(&ndopts.opt_list); if (nd6_options((struct nd_opt_hdr *)(rs + 1), len - sizeof(struct nd_router_solicit), &ndopts, NDOPT_FLAG_SRCLINKADDR)) { @@ -1083,6 +1084,7 @@ ra_input(int len, struct nd_router_adver /* ND option check */ memset(&ndopts, 0, sizeof(ndopts)); + TAILQ_INIT(&ndopts.opt_list); error = nd6_options((struct nd_opt_hdr *)(nra + 1), len - sizeof(struct nd_router_advert), &ndopts, NDOPT_FLAG_SRCLINKADDR | NDOPT_FLAG_PREFIXINFO | NDOPT_FLAG_MTU | From owner-svn-src-user@FreeBSD.ORG Wed Aug 24 19:01: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 3D7FF106564A; Wed, 24 Aug 2011 19:01:38 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2CD0C8FC0C; Wed, 24 Aug 2011 19:01: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 p7OJ1cT5066754; Wed, 24 Aug 2011 19:01:38 GMT (envelope-from hrs@svn.freebsd.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7OJ1cdR066752; Wed, 24 Aug 2011 19:01:38 GMT (envelope-from hrs@svn.freebsd.org) Message-Id: <201108241901.p7OJ1cdR066752@svn.freebsd.org> From: Hiroki Sato Date: Wed, 24 Aug 2011 19:01:38 +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: r225150 - user/hrs/ipv6/usr.sbin/rtsold 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, 24 Aug 2011 19:01:38 -0000 Author: hrs Date: Wed Aug 24 19:01:37 2011 New Revision: 225150 URL: http://svn.freebsd.org/changeset/base/225150 Log: Fix -F flag handling to support receiving RAs even when ip6.forwarding=1. Modified: user/hrs/ipv6/usr.sbin/rtsold/rtsold.c Modified: user/hrs/ipv6/usr.sbin/rtsold/rtsold.c ============================================================================== --- user/hrs/ipv6/usr.sbin/rtsold/rtsold.c Wed Aug 24 18:44:05 2011 (r225149) +++ user/hrs/ipv6/usr.sbin/rtsold/rtsold.c Wed Aug 24 19:01:37 2011 (r225150) @@ -225,6 +225,7 @@ main(int argc, char **argv) srandom((u_long)time(NULL)); #endif +#if (__FreeBSD_version < 900000) if (Fflag) { setinet6sysctl(IPV6CTL_FORWARDING, 0); } else { @@ -232,6 +233,7 @@ main(int argc, char **argv) if (getinet6sysctl(IPV6CTL_FORWARDING)) warnx("kernel is configured as a router, not a host"); } +#endif #ifndef SMALL /* initialization to dump internal status to a file */ @@ -411,6 +413,32 @@ ifconfig(char *ifname) return (-1); } + if (Fflag) { + struct in6_ndireq nd; + int s; + + if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) { + warnmsg(LOG_ERR, __func__, "socket() failed."); + return (-1); + } + memset(&nd, 0, sizeof(nd)); + strlcpy(nd.ifname, ifname, sizeof(nd.ifname)); + if (ioctl(s, SIOCGIFINFO_IN6, (caddr_t)&nd) < 0) { + warnmsg(LOG_ERR, __func__, + "cannot get accept_rtadv flag"); + close(s); + return (-1); + } + nd.ndi.flags |= ND6_IFF_ACCEPT_RTADV; + if (ioctl(s, SIOCSIFINFO_IN6, (caddr_t)&nd) < 0) { + warnmsg(LOG_ERR, __func__, + "cannot set accept_rtadv flag"); + close(s); + return (-1); + } + close(s); + } + if ((ifi = malloc(sizeof(*ifi))) == NULL) { warnmsg(LOG_ERR, __func__, "memory allocation failed"); free(sdl); From owner-svn-src-user@FreeBSD.ORG Wed Aug 24 19:27: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 E49E71065673; Wed, 24 Aug 2011 19:27:49 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C9D698FC08; Wed, 24 Aug 2011 19:27: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 p7OJRnqe067550; Wed, 24 Aug 2011 19:27:49 GMT (envelope-from hrs@svn.freebsd.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7OJRnZt067545; Wed, 24 Aug 2011 19:27:49 GMT (envelope-from hrs@svn.freebsd.org) Message-Id: <201108241927.p7OJRnZt067545@svn.freebsd.org> From: Hiroki Sato Date: Wed, 24 Aug 2011 19:27: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: r225151 - user/hrs/ipv6/sys/netinet6 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, 24 Aug 2011 19:27:50 -0000 Author: hrs Date: Wed Aug 24 19:27:49 2011 New Revision: 225151 URL: http://svn.freebsd.org/changeset/base/225151 Log: Add ip6.rfc6204w3 to support accepting the default router lists from RAs even when ip6.forwarding=1. Obtained from: m0n0wall r475 Modified: user/hrs/ipv6/sys/netinet6/in6.h user/hrs/ipv6/sys/netinet6/in6_proto.c user/hrs/ipv6/sys/netinet6/ip6_var.h user/hrs/ipv6/sys/netinet6/nd6_rtr.c Modified: user/hrs/ipv6/sys/netinet6/in6.h ============================================================================== --- user/hrs/ipv6/sys/netinet6/in6.h Wed Aug 24 19:01:37 2011 (r225150) +++ user/hrs/ipv6/sys/netinet6/in6.h Wed Aug 24 19:27:49 2011 (r225151) @@ -614,7 +614,9 @@ struct ip6_mtuinfo { #define IPV6CTL_NO_RADR 48 /* No defroute from RA */ #define IPV6CTL_NORBIT_RAIF 49 /* Disable R-bit in NA on RA * receiving IF. */ -#define IPV6CTL_MAXID 50 +#define IPV6CTL_RFC6204W3 50 /* Accept defroute even when forwarding + enabled */ +#define IPV6CTL_MAXID 51 #endif /* __BSD_VISIBLE */ /* Modified: user/hrs/ipv6/sys/netinet6/in6_proto.c ============================================================================== --- user/hrs/ipv6/sys/netinet6/in6_proto.c Wed Aug 24 19:01:37 2011 (r225150) +++ user/hrs/ipv6/sys/netinet6/in6_proto.c Wed Aug 24 19:27:49 2011 (r225151) @@ -399,6 +399,7 @@ VNET_DEFINE(int, ip6_defmcasthlim) = IPV VNET_DEFINE(int, ip6_accept_rtadv) = 0; VNET_DEFINE(int, ip6_no_radr) = 0; VNET_DEFINE(int, ip6_norbit_raif) = 0; +VNET_DEFINE(int, ip6_rfc6204w3) = 0; VNET_DEFINE(int, ip6_maxfragpackets); /* initialized in frag6.c:frag6_init() */ VNET_DEFINE(int, ip6_maxfrags); /* initialized in frag6.c:frag6_init() */ VNET_DEFINE(int, ip6_log_interval) = 5; @@ -536,6 +537,10 @@ SYSCTL_VNET_INT(_net_inet6_ip6, IPV6CTL_ &VNET_NAME(ip6_norbit_raif), 0, "Always set 0 to R flag in ICMPv6 NA messages when accepting RA" " on the interface."); +SYSCTL_VNET_INT(_net_inet6_ip6, IPV6CTL_RFC6204W3, rfc6204w3, + CTLFLAG_RW, &VNET_NAME(ip6_rfc6204w3), 0, + "Accept the default router list from ICMPv6 RA messages even " + "when packet forwarding enabled."); SYSCTL_VNET_INT(_net_inet6_ip6, IPV6CTL_KEEPFAITH, keepfaith, CTLFLAG_RW, &VNET_NAME(ip6_keepfaith), 0, ""); SYSCTL_VNET_INT(_net_inet6_ip6, IPV6CTL_LOG_INTERVAL, log_interval, Modified: user/hrs/ipv6/sys/netinet6/ip6_var.h ============================================================================== --- user/hrs/ipv6/sys/netinet6/ip6_var.h Wed Aug 24 19:01:37 2011 (r225150) +++ user/hrs/ipv6/sys/netinet6/ip6_var.h Wed Aug 24 19:27:49 2011 (r225151) @@ -319,6 +319,8 @@ VNET_DECLARE(int, ip6_accept_rtadv); /* VNET_DECLARE(int, ip6_no_radr); /* No defroute from RA */ VNET_DECLARE(int, ip6_norbit_raif); /* Disable R-bit in NA on RA * receiving IF. */ +VNET_DECLARE(int, ip6_rfc6204w3); /* Accept defroute from RA even when + forwarding enabled */ VNET_DECLARE(int, ip6_keepfaith); /* Firewall Aided Internet Translator */ VNET_DECLARE(int, ip6_log_interval); VNET_DECLARE(time_t, ip6_log_time); @@ -332,6 +334,7 @@ VNET_DECLARE(int, ip6_dad_count); /* Dup #define V_ip6_accept_rtadv VNET(ip6_accept_rtadv) #define V_ip6_no_radr VNET(ip6_no_radr) #define V_ip6_norbit_raif VNET(ip6_norbit_raif) +#define V_ip6_rfc6204w3 VNET(ip6_rfc6204w3) #define V_ip6_keepfaith VNET(ip6_keepfaith) #define V_ip6_log_interval VNET(ip6_log_interval) #define V_ip6_log_time VNET(ip6_log_time) Modified: user/hrs/ipv6/sys/netinet6/nd6_rtr.c ============================================================================== --- user/hrs/ipv6/sys/netinet6/nd6_rtr.c Wed Aug 24 19:01:37 2011 (r225150) +++ user/hrs/ipv6/sys/netinet6/nd6_rtr.c Wed Aug 24 19:27:49 2011 (r225151) @@ -269,11 +269,13 @@ nd6_ra_input(struct mbuf *m, int off, in dr0.rtaddr = saddr6; dr0.flags = nd_ra->nd_ra_flags_reserved; /* - * Effectively-disable the route in the RA packet - * when ND6_IFF_NO_RADR on the receiving interface or - * ip6.forwarding=1. + * Effectively-disable routes from RA messages when + * ND6_IFF_NO_RADR enabled on the receiving interface or + * (ip6.forwarding == 1 && ip6.rfc6204w3 != 1). */ - if (ndi->flags & ND6_IFF_NO_RADR || V_ip6_forwarding) + if (ndi->flags & ND6_IFF_NO_RADR) + dr0.rtlifetime = 0; + else if (V_ip6_forwarding && !V_ip6_rfc6204w3) dr0.rtlifetime = 0; else dr0.rtlifetime = ntohs(nd_ra->nd_ra_router_lifetime); From owner-svn-src-user@FreeBSD.ORG Wed Aug 24 23:41: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 8115E106566C; Wed, 24 Aug 2011 23:41:03 +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 398158FC12; Wed, 24 Aug 2011 23:41:03 +0000 (UTC) Received: from server.mypc.hu (localhost [127.0.0.1]) by server.mypc.hu (Postfix) with ESMTP id DBAAC14DC171; Thu, 25 Aug 2011 01:23:02 +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 z6JRI8KLBaOg; Thu, 25 Aug 2011 01:23:00 +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 D98A214D28DF; Thu, 25 Aug 2011 01:22:59 +0200 (CEST) Message-ID: <4E5587CF.2010309@FreeBSD.org> Date: Thu, 25 Aug 2011 01:22:55 +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: Andrey Chernov , src-committers@FreeBSD.ORG, svn-src-user@FreeBSD.ORG References: <201108222319.p7MNJKZ4072487@svn.freebsd.org> <20110823034416.GA7597@vniz.net> In-Reply-To: <20110823034416.GA7597@vniz.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Subject: Re: svn commit: r225093 - 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, 24 Aug 2011 23:41:03 -0000 On 2011.08.23. 5:44, Andrey Chernov wrote: > On Mon, Aug 22, 2011 at 11:19:20PM +0000, Gabor Kovesdan wrote: >> Modified: user/gabor/tre-integration/include/regex.h >> ============================================================================== >> --- user/gabor/tre-integration/include/regex.h Mon Aug 22 23:15:15 2011 (r225092) >> +++ user/gabor/tre-integration/include/regex.h Mon Aug 22 23:19:20 2011 (r225093) >> @@ -110,6 +110,7 @@ typedef enum { >> #define REG_PEND (REG_UNGREEDY<< 1) >> #define REG_GNU (REG_PEND<< 1) >> #define REG_WORD (REG_GNU<< 1) >> +#define _REG_HEUR (REG_WORD<< 1) > Not a good place. Next extension flag from TRE author or POSIX will break > binary compatibility badly. It will be better to put it to the end of a > word instead or don't use this field at all (converting to another > internal function argument etc.), which is much safer. Thanks for reviewing my changes and commenting! This change was a semi-temporary solution. I'm wondering whether I should remove the underscore and consider it a normal knob as it may be useful outside TRE, however I cannot think of any concrete case. What do you exactly mean by end of a word? Still, binary compatibility will break if a new POSIX flag will be introduced because TRE already defines some extra flags. I'm not quite sure which is the best solution. Probably, I'll clean up my patches once I'm done and hopefully the TRE author will be interested in integrating my changes so I'll discuss these with him. Gabor From owner-svn-src-user@FreeBSD.ORG Wed Aug 24 23:49:21 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 B2EA51065674; Wed, 24 Aug 2011 23:49:21 +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 A16DA8FC08; Wed, 24 Aug 2011 23:49: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 p7ONnLf9075626; Wed, 24 Aug 2011 23:49:21 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7ONnLB8075619; Wed, 24 Aug 2011 23:49:21 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108242349.p7ONnLB8075619@svn.freebsd.org> From: Gabor Kovesdan Date: Wed, 24 Aug 2011 23:49: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: r225156 - 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, 24 Aug 2011 23:49:21 -0000 Author: gabor Date: Wed Aug 24 23:49:21 2011 New Revision: 225156 URL: http://svn.freebsd.org/changeset/base/225156 Log: - Clean up the hashtable code Added: user/gabor/tre-integration/contrib/tre/lib/hashtable.h - copied, changed from r224979, user/gabor/tre-integration/include/hashtable.h Deleted: user/gabor/tre-integration/include/hashtable.h Modified: user/gabor/tre-integration/contrib/tre/lib/hashtable.c user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.h user/gabor/tre-integration/include/Makefile user/gabor/tre-integration/include/fastmatch.h Modified: user/gabor/tre-integration/contrib/tre/lib/hashtable.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/hashtable.c Wed Aug 24 22:46:18 2011 (r225155) +++ user/gabor/tre-integration/contrib/tre/lib/hashtable.c Wed Aug 24 23:49:21 2011 (r225156) @@ -25,10 +25,19 @@ */ #include -#include + +#include #include #include +#include "hashtable.h" + +/* + * 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) { @@ -36,13 +45,11 @@ hashtable tbl = malloc(sizeof(hashtable)); if (tbl == NULL) - return (NULL); + goto mem1; tbl->entries = calloc(sizeof(hashtable_entry *), table_size); - if (tbl->entries == NULL) { - free(tbl); - return (NULL); - } + if (tbl->entries == NULL) + goto mem2; tbl->table_size = table_size; tbl->usage = 0; @@ -50,96 +57,151 @@ hashtable 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); + if (tbl->table_size == tbl->usage) { + return (HASH_FULL); + } + + hash = hash32_buf(key, tbl->key_size, hash) % tbl->table_size; - hash = hash32_buf(key, tbl->key_size, hash); - hash %= tbl->table_size; + /* + * 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); + } + } 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); + if (tbl->entries[hash] == NULL) { + errno = ENOMEM; + goto mem1; + } tbl->entries[hash]->key = malloc(tbl->key_size); if (tbl->entries[hash]->key == NULL) { - free(tbl->entries[hash]); - return (-1); + errno = ENOMEM; + goto mem2; } 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); + errno = ENOMEM; + goto mem3; } - memcpy(&tbl->entries[hash]->key, key, tbl->key_size); - memcpy(&tbl->entries[hash]->value, value, tbl->value_size); + memcpy(tbl->entries[hash]->key, key, tbl->key_size); + memcpy(tbl->entries[hash]->value, value, tbl->value_size); tbl->usage++; - return (0); + 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; - 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, + else if (memcmp(key, tbl->entries[hash]->key, tbl->key_size) == 0) - return (tbl->entries[hash]); + return (&tbl->entries[hash]); 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); + 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); + 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); + return (HASH_OK); } +/* + * Frees the resources associated with the hash table tbl. + */ void hashtable_free(hashtable *tbl) { @@ -148,10 +210,9 @@ hashtable_free(hashtable *tbl) 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); -// free(tbl->entries[i]); - } + if ((tbl->entries[i] != NULL)) { + free(tbl->entries[i]->key); + free(tbl->entries[i]->value); + } free(tbl->entries); } Copied and modified: user/gabor/tre-integration/contrib/tre/lib/hashtable.h (from r224979, user/gabor/tre-integration/include/hashtable.h) ============================================================================== --- user/gabor/tre-integration/include/hashtable.h Thu Aug 18 16:57:51 2011 (r224979, copy source) +++ user/gabor/tre-integration/contrib/tre/lib/hashtable.h Wed Aug 24 23:49:21 2011 (r225156) @@ -5,6 +5,12 @@ #include +#define HASH_OK 0 +#define HASH_UPDATED 1 +#define HASH_FAIL 2 +#define HASH_FULL 3 +#define HASH_NOTFOUND 4 + typedef struct { void *key; void *value; Modified: user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Wed Aug 24 22:46:18 2011 (r225155) +++ user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Wed Aug 24 23:49:21 2011 (r225156) @@ -28,7 +28,6 @@ #ifdef HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ -#include #include #include #include @@ -133,7 +132,7 @@ 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)); \ Modified: user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.h ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.h Wed Aug 24 22:46:18 2011 (r225155) +++ user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.h Wed Aug 24 23:49:21 2011 (r225156) @@ -2,7 +2,6 @@ #define TRE_FASTMATCH_H 1 #include -#include #include #include #include Modified: user/gabor/tre-integration/include/Makefile ============================================================================== --- user/gabor/tre-integration/include/Makefile Wed Aug 24 22:46:18 2011 (r225155) +++ user/gabor/tre-integration/include/Makefile Wed Aug 24 23:49:21 2011 (r225156) @@ -11,7 +11,7 @@ INCS= a.out.h ar.h assert.h bitstring.h db.h \ dirent.h dlfcn.h elf.h elf-hints.h err.h fastmatch.h fmtmsg.h fnmatch.h \ fstab.h fts.h ftw.h getopt.h glob.h grp.h gssapi.h \ - hashtable.h ieeefp.h ifaddrs.h \ + ieeefp.h ifaddrs.h \ inttypes.h iso646.h kenv.h langinfo.h libgen.h limits.h link.h \ locale.h malloc.h malloc_np.h memory.h monetary.h mpool.h mqueue.h \ ndbm.h netconfig.h \ Modified: user/gabor/tre-integration/include/fastmatch.h ============================================================================== --- user/gabor/tre-integration/include/fastmatch.h Wed Aug 24 22:46:18 2011 (r225155) +++ user/gabor/tre-integration/include/fastmatch.h Wed Aug 24 23:49:21 2011 (r225156) @@ -3,7 +3,6 @@ #ifndef FASTMATCH_H #define FASTMATCH_H 1 -#include #include #include #include @@ -18,7 +17,7 @@ typedef struct { int *bmGs; char *pattern; int defBc; - hashtable *qsBc_table; + void *qsBc_table; int *sbmGs; const char *re_endp; From owner-svn-src-user@FreeBSD.ORG Thu Aug 25 00:25: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 6FCAF106564A; Thu, 25 Aug 2011 00:25: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 464CE8FC0A; Thu, 25 Aug 2011 00:25: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 p7P0PGKR076801; Thu, 25 Aug 2011 00:25:16 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7P0PGVZ076799; Thu, 25 Aug 2011 00:25:16 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108250025.p7P0PGVZ076799@svn.freebsd.org> From: Gabor Kovesdan Date: Thu, 25 Aug 2011 00:25: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: r225158 - 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, 25 Aug 2011 00:25:16 -0000 Author: gabor Date: Thu Aug 25 00:25:15 2011 New Revision: 225158 URL: http://svn.freebsd.org/changeset/base/225158 Log: - Add proper error checking for hashtable-related errors 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 Thu Aug 25 00:14:30 2011 (r225157) +++ user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Thu Aug 25 00:25:15 2011 (r225158) @@ -46,6 +46,18 @@ static int fastcmp(const void *, const void *, size_t, tre_str_type_t, bool, bool); +#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 * address to startptr. Note: as per IEEE Std 1003.1-2008 @@ -222,17 +234,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); \ } \ } From owner-svn-src-user@FreeBSD.ORG Thu Aug 25 00:55: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 ADF751065672; Thu, 25 Aug 2011 00:55:19 +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 941788FC0C; Thu, 25 Aug 2011 00:55: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 p7P0tJTj077698; Thu, 25 Aug 2011 00:55:19 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7P0tJxG077695; Thu, 25 Aug 2011 00:55:19 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108250055.p7P0tJxG077695@svn.freebsd.org> From: Gabor Kovesdan Date: Thu, 25 Aug 2011 00:55: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: r225159 - 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, 25 Aug 2011 00:55:19 -0000 Author: gabor Date: Thu Aug 25 00:55:19 2011 New Revision: 225159 URL: http://svn.freebsd.org/changeset/base/225159 Log: - Only compile shortcut if length is at least 2 - Still, fix segfault in fast matcher when len == 1 because this code may be used independently through the public interface Modified: user/gabor/tre-integration/contrib/tre/lib/tre-compile.c user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Modified: user/gabor/tre-integration/contrib/tre/lib/tre-compile.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-compile.c Thu Aug 25 00:25:15 2011 (r225158) +++ user/gabor/tre-integration/contrib/tre/lib/tre-compile.c Thu Aug 25 00:55:19 2011 (r225159) @@ -1873,25 +1873,31 @@ tre_compile(regex_t *preg, const tre_cha /* Parse context. */ tre_parse_ctx_t parse_ctx; - /* Check if we can cheat with a fixed string algorithm. */ - shortcut = xmalloc(sizeof(fastmatch_t)); - if (!shortcut) - return REG_ESPACE; - ret = (cflags & REG_LITERAL) - ? tre_compile_literal(shortcut, regex, n, cflags) - : tre_compile_fast(shortcut, regex, n, cflags); - if (ret == REG_OK) - { - preg->shortcut = shortcut; - preg->re_nsub = 0; - DPRINT("tre_compile: pattern compiled for fast matcher\n"); - return REG_OK; - } - else + /* + * Check if we can cheat with a fixed string algorithm + * if the pattern is long enough. + */ + if (n >= 2) { - xfree(shortcut); - preg->shortcut = NULL; - DPRINT("tre_compile: pattern compilation failed for fast matcher\n"); + shortcut = xmalloc(sizeof(fastmatch_t)); + if (!shortcut) + return REG_ESPACE; + ret = (cflags & REG_LITERAL) + ? tre_compile_literal(shortcut, regex, n, cflags) + : tre_compile_fast(shortcut, regex, n, cflags); + if (ret == REG_OK) + { + preg->shortcut = shortcut; + preg->re_nsub = 0; + DPRINT("tre_compile: pattern compiled for fast matcher\n"); + return REG_OK; + } + else + { + xfree(shortcut); + preg->shortcut = NULL; + DPRINT("tre_compile: pattern compilation failed for fast matcher\n"); + } } /* Allocate a stack used throughout the compilation process for various Modified: user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Thu Aug 25 00:25:15 2011 (r225158) +++ user/gabor/tre-integration/contrib/tre/lib/tre-fastmatch.c Thu Aug 25 00:55:19 2011 (r225159) @@ -265,7 +265,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); \ } /* @@ -277,7 +280,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) \ From owner-svn-src-user@FreeBSD.ORG Thu Aug 25 01:00: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 1D135106566C; Thu, 25 Aug 2011 01:00: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 0C9D28FC0C; Thu, 25 Aug 2011 01:00: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 p7P10sLm077906; Thu, 25 Aug 2011 01:00:54 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7P10suW077904; Thu, 25 Aug 2011 01:00:54 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108250100.p7P10suW077904@svn.freebsd.org> From: Gabor Kovesdan Date: Thu, 25 Aug 2011 01:00:54 +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: r225160 - 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, 25 Aug 2011 01:00:55 -0000 Author: gabor Date: Thu Aug 25 01:00:54 2011 New Revision: 225160 URL: http://svn.freebsd.org/changeset/base/225160 Log: - Change to TRE-specific style Modified: user/gabor/tre-integration/contrib/tre/lib/hashtable.c Modified: user/gabor/tre-integration/contrib/tre/lib/hashtable.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/hashtable.c Thu Aug 25 00:55:19 2011 (r225159) +++ user/gabor/tre-integration/contrib/tre/lib/hashtable.c Thu Aug 25 01:00:54 2011 (r225160) @@ -41,28 +41,28 @@ hashtable *hashtable_init(size_t table_size, size_t key_size, size_t value_size) { - hashtable *tbl; + 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; + 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); + return (tbl); mem2: - free(tbl); + free(tbl); mem1: - errno = ENOMEM; - return (NULL); + errno = ENOMEM; + return (NULL); } /* @@ -80,80 +80,81 @@ mem1: int hashtable_put(hashtable *tbl, const void *key, const void *value) { - uint32_t hash = 0; + uint32_t hash = 0; + + if (tbl->table_size == tbl->usage) + return (HASH_FULL); - if (tbl->table_size == tbl->usage) { - return (HASH_FULL); - } - - hash = hash32_buf(key, tbl->key_size, hash) % tbl->table_size; - - /* - * 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); - } - } - - 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) { - 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; - } + hash = hash32_buf(key, tbl->key_size, hash) % tbl->table_size; - memcpy(tbl->entries[hash]->key, key, tbl->key_size); + /* + * 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); - tbl->usage++; + return (HASH_UPDATED); + } + + 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) + { + 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); + return (HASH_OK); mem3: - free(tbl->entries[hash]->key); + free(tbl->entries[hash]->key); mem2: - free(tbl->entries[hash]); + free(tbl->entries[hash]); mem1: - return (HASH_FAIL); + return (HASH_FAIL); } static hashtable_entry **hashtable_lookup(const hashtable *tbl, const void *key) { - uint32_t hash = 0; + uint32_t hash = 0; - hash = hash32_buf(key, tbl->key_size, 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; + } } /* @@ -165,14 +166,14 @@ static hashtable_entry 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 (HASH_NOTFOUND); + entry = hashtable_lookup(tbl, key); + if (entry == NULL) + return (HASH_NOTFOUND); - memcpy(value, (*entry)->value, tbl->value_size); - return (HASH_OK); + memcpy(value, (*entry)->value, tbl->value_size); + return (HASH_OK); } /* @@ -183,20 +184,19 @@ hashtable_get(hashtable *tbl, const void int hashtable_remove(hashtable *tbl, const void *key) { - hashtable_entry **entry; - - entry = hashtable_lookup(tbl, key); - if (entry == NULL) - return (HASH_NOTFOUND); - - free((*entry)->key); - free((*entry)->value); - free(*entry); - *entry = NULL; + hashtable_entry **entry; - tbl->usage--; + entry = hashtable_lookup(tbl, key); + if (entry == NULL) + return (HASH_NOTFOUND); + + free((*entry)->key); + free((*entry)->value); + free(*entry); + *entry = NULL; - return (HASH_OK); + tbl->usage--; + return (HASH_OK); } /* @@ -205,14 +205,15 @@ hashtable_remove(hashtable *tbl, const v 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); + free(tbl->entries); } From owner-svn-src-user@FreeBSD.ORG Thu Aug 25 01:47:08 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 EEA26106566B; Thu, 25 Aug 2011 01:47:08 +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 DECCB8FC08; Thu, 25 Aug 2011 01:47:08 +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 p7P1l8d9079281; Thu, 25 Aug 2011 01:47:08 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7P1l8Fj079279; Thu, 25 Aug 2011 01:47:08 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108250147.p7P1l8Fj079279@svn.freebsd.org> From: Gabor Kovesdan Date: Thu, 25 Aug 2011 01:47:08 +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: r225161 - 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, 25 Aug 2011 01:47:09 -0000 Author: gabor Date: Thu Aug 25 01:47:08 2011 New Revision: 225161 URL: http://svn.freebsd.org/changeset/base/225161 Log: - Eliminate duplicated code snippet - Improve portability by eliminating FreeBSD-related dependencies Modified: user/gabor/tre-integration/contrib/tre/lib/hashtable.c Modified: user/gabor/tre-integration/contrib/tre/lib/hashtable.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/hashtable.c Thu Aug 25 01:00:54 2011 (r225160) +++ user/gabor/tre-integration/contrib/tre/lib/hashtable.c Thu Aug 25 01:47:08 2011 (r225161) @@ -24,14 +24,29 @@ * SUCH DAMAGE. */ -#include - #include #include #include #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) +{ + const unsigned char *p = buf; + + while (len--) + hash = HASHSTEP(hash, *p++); + + 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 @@ -101,9 +116,6 @@ hashtable_put(hashtable *tbl, const void return (HASH_UPDATED); } - 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) { From owner-svn-src-user@FreeBSD.ORG Thu Aug 25 01:47: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 483FF1065672; Thu, 25 Aug 2011 01:47: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 3867D8FC19; Thu, 25 Aug 2011 01:47: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 p7P1lREw079326; Thu, 25 Aug 2011 01:47:27 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7P1lRbt079324; Thu, 25 Aug 2011 01:47:27 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108250147.p7P1lRbt079324@svn.freebsd.org> From: Gabor Kovesdan Date: Thu, 25 Aug 2011 01:47: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: r225162 - 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, 25 Aug 2011 01:47:27 -0000 Author: gabor Date: Thu Aug 25 01:47:26 2011 New Revision: 225162 URL: http://svn.freebsd.org/changeset/base/225162 Log: - Convert to TRE style Modified: user/gabor/tre-integration/contrib/tre/lib/hashtable.h Modified: user/gabor/tre-integration/contrib/tre/lib/hashtable.h ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/hashtable.h Thu Aug 25 01:47:08 2011 (r225161) +++ user/gabor/tre-integration/contrib/tre/lib/hashtable.h Thu Aug 25 01:47:26 2011 (r225162) @@ -5,29 +5,31 @@ #include -#define HASH_OK 0 -#define HASH_UPDATED 1 -#define HASH_FAIL 2 -#define HASH_FULL 3 -#define HASH_NOTFOUND 4 +#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 */ From owner-svn-src-user@FreeBSD.ORG Thu Aug 25 04:18: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 DBDE1106564A; Thu, 25 Aug 2011 04:18:49 +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 5BE438FC0C; Thu, 25 Aug 2011 04:18:48 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by vniz.net (8.14.5/8.14.5) with ESMTP id p7P4IlrM092899; Thu, 25 Aug 2011 08:18:47 +0400 (MSK) (envelope-from ache@vniz.net) Received: (from ache@localhost) by localhost (8.14.5/8.14.5/Submit) id p7P4IlNh092898; Thu, 25 Aug 2011 08:18:47 +0400 (MSK) (envelope-from ache) Date: Thu, 25 Aug 2011 08:18:47 +0400 From: Andrey Chernov To: Gabor Kovesdan Message-ID: <20110825041847.GA92789@vniz.net> Mail-Followup-To: Andrey Chernov , Gabor Kovesdan , src-committers@FreeBSD.ORG, svn-src-user@FreeBSD.ORG References: <201108222319.p7MNJKZ4072487@svn.freebsd.org> <20110823034416.GA7597@vniz.net> <4E5587CF.2010309@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4E5587CF.2010309@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: r225093 - 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: Thu, 25 Aug 2011 04:18:49 -0000 On Thu, Aug 25, 2011 at 01:22:55AM +0200, Gabor Kovesdan wrote: > This change was a semi-temporary solution. I'm wondering whether I > should remove the underscore and consider it a normal knob as it may be > useful outside TRE, however I cannot think of any concrete case. If it will be direct user-visible flag, you'll need to discuss that with TRE author first, but I don't see, why it needs to be normal flag. > What do you exactly mean by end of a word? I mean end of a word bits pool (opposite to start of it where all bit-occuped flags are grouped together). > Still, binary compatibility will > break if a new POSIX flag will be introduced because TRE already defines > some extra flags. POSIX often does not specify exact numeric values of its flags. If TRE author just add new flag, old binary still can run with new lib normally, since this place was not occuped previously. But if you separately use the same bit too, old binary can even run but produce strange results. > I'm not quite sure which is the best solution. If it is supposed to be direct user-visible flag, it should be coordinated with TRE author or moved to the end of bits pool at least to delay conflict as much as possible. If it is pure internal flag, it should not be in that field and in the public header at all. -- http://ache.vniz.net/ From owner-svn-src-user@FreeBSD.ORG Thu Aug 25 07:24: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 46D89106564A; Thu, 25 Aug 2011 07:24: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 36B518FC0C; Thu, 25 Aug 2011 07:24: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 p7P7OoBi089820; Thu, 25 Aug 2011 07:24:50 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7P7OoMI089818; Thu, 25 Aug 2011 07:24:50 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108250724.p7P7OoMI089818@svn.freebsd.org> From: Adrian Chadd Date: Thu, 25 Aug 2011 07:24: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: r225164 - 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, 25 Aug 2011 07:24:50 -0000 Author: adrian Date: Thu Aug 25 07:24:49 2011 New Revision: 225164 URL: http://svn.freebsd.org/changeset/base/225164 Log: * rename the drain routine to ath_tx_tid_drain(), bringing it (mostly) in line with what the reference/atheros driver code does. * add some locking around the sequence number assignment, since although only one location allocates sequence numbers, now we're changing it in >1 location. This is inspired by the linux/atheros reference code, but as mentioned in the comments in this commit, there's a possible race where an interface is flushed whilst active traffic is being queued to it (or being completed.) This may cause some funny shenanigans to occur. This doesn't happen (as often) in the Linux/Reference code because the TID/TXQ locks are being held for much longer. I'll have to fix this for access point mode as otherwise some crazy stuff is likely to occur. 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 Thu Aug 25 04:31:20 2011 (r225163) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Thu Aug 25 07:24:49 2011 (r225164) @@ -1235,8 +1235,8 @@ 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]); + struct ath_node *an = ATH_NODE(ni); + ATH_TXQ_LOCK(&an->an_tid[tid]); /* * Always call; this function will * handle making sure that null data frames @@ -1248,7 +1248,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(&an->an_tid[tid]); } /* @@ -2078,26 +2078,33 @@ ath_tx_tid_txq_unmark(struct ath_softc * /* * Free any packets currently pending in the software TX queue. * - * Since net80211 shouldn't free the node until the last packets - * have been sent, this function should never have to free any - * packets when a node is freed. + * This will be called when a node is being deleted. * * It can also be called on an active node during an interface * reset or state transition. + * + * (From Linux/reference): + * + * TODO: For frame(s) that are in the retry state, we will reuse the + * sequence number(s) without setting the retry bit. The + * alternative is to give up on these and BAR the receiver's window + * forward. */ static void -ath_tx_tid_free_pkts(struct ath_softc *sc, struct ath_node *an, - int tid) +ath_tx_tid_drain(struct ath_softc *sc, struct ath_node *an, struct ath_tid *tid) { - struct ath_tid *atid = &an->an_tid[tid]; struct ath_buf *bf; + struct ieee80211_tx_ampdu *tap; + struct ieee80211_node *ni = &an->an_node; + + tap = ath_tx_get_tx_tid(an, tid->tid); /* Walk the queue, free frames */ for (;;) { - ATH_TXQ_LOCK(atid); - bf = TAILQ_FIRST(&atid->axq_q); + ATH_TXQ_LOCK(tid); + bf = TAILQ_FIRST(&tid->axq_q); if (bf == NULL) { - ATH_TXQ_UNLOCK(atid); + ATH_TXQ_UNLOCK(tid); break; } @@ -2105,20 +2112,63 @@ ath_tx_tid_free_pkts(struct ath_softc *s * If the current TID is running AMPDU, update * the BAW. */ - if (ath_tx_ampdu_running(sc, an, tid) && + if (ath_tx_ampdu_running(sc, an, tid->tid) && bf->bf_state.bfs_dobaw) { - ath_tx_update_baw(sc, an, atid, - SEQNO(bf->bf_state.bfs_seqno)); - bf->bf_state.bfs_dobaw = 0; + /* + * Only remove the frame from the BAW if it's + * been transmitted at least once; this means + * the frame was in the BAW to begin with. + */ + if (bf->bf_state.bfs_retries > 0) { + ath_tx_update_baw(sc, an, tid, + SEQNO(bf->bf_state.bfs_seqno)); + bf->bf_state.bfs_dobaw = 0; + } + /* + * This has become a non-fatal error now + */ 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_REMOVE(atid, bf, bf_list); - ATH_TXQ_UNLOCK(atid); + ATH_TXQ_REMOVE(tid, bf, bf_list); + ATH_TXQ_UNLOCK(tid); ath_tx_default_comp(sc, bf, 0); } + + /* + * Now that it's completed, grab the TID lock and update + * the sequence number and BAW window. + * Because sequence numbers have been assigned to frames + * that haven't been sent yet, it's entirely possible + * we'll be called with some pending frames that have not + * been transmitted. + * + * 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", + __func__, an, tid->tid, tap->txa_start); +#endif + ni->ni_txseqs[tid->tid] = tap->txa_start; + tid->baw_tail = tid->baw_head; + ATH_TXQ_UNLOCK(tid); + } } /* @@ -2144,7 +2194,7 @@ ath_tx_node_flush(struct ath_softc *sc, ATH_TXQ_UNLOCK(txq); /* Free packets */ - ath_tx_tid_free_pkts(sc, an, tid); + ath_tx_tid_drain(sc, an, atid); } } From owner-svn-src-user@FreeBSD.ORG Thu Aug 25 07:28: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 6C894106566B; Thu, 25 Aug 2011 07:28: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 5BCF18FC15; Thu, 25 Aug 2011 07:28: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 p7P7S7In089955; Thu, 25 Aug 2011 07:28:07 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7P7S7iT089953; Thu, 25 Aug 2011 07:28:07 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108250728.p7P7S7iT089953@svn.freebsd.org> From: Adrian Chadd Date: Thu, 25 Aug 2011 07:28: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: r225165 - 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: Thu, 25 Aug 2011 07:28:07 -0000 Author: adrian Date: Thu Aug 25 07:28:07 2011 New Revision: 225165 URL: http://svn.freebsd.org/changeset/base/225165 Log: Begin teaching ath_rate_sample about aggregate packets. I'm hoping to (just) teach ath_rate_sample about the multiple packet attempt/success/failure as if the rate completion routine was called for each packet. (Which seems a bit over the top.) This still doesn't choose/stick to the fastest throughput, primarily because: * there's no probe/sounding frame support yet - ie, if ath_rate_sample decides to sample a higher rate to see if it's better, the aggregate code still aggregates; * .. and the rate API doesn't really get anywhere enough info to make aggregate decisions - primarily because the rate API gets called before any aggregate is formed. So it can't do things like choose a rate based on how long the potential aggregate is (eg, if higher MCS rates work fine for short bursts, but not for longer bursts); and * Rate assignment is only done once, it isn't recalculated in the software retry path. I think that'll be one of my next things to refactor out. 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 Thu Aug 25 07:24:49 2011 (r225164) +++ user/adrian/if_ath_tx/sys/dev/ath/ath_rate/sample/sample.c Thu Aug 25 07:28:07 2011 (r225165) @@ -498,7 +498,8 @@ update_stats(struct ath_softc *sc, struc int rix1, int tries1, int rix2, int tries2, int rix3, int tries3, - int short_tries, int tries, int status) + int short_tries, int tries, int status, + int nframes, int nbad) { struct sample_node *sn = ATH_NODE_SAMPLE(an); struct sample_softc *ssc = ATH_SOFTC_SAMPLE(sc); @@ -540,7 +541,7 @@ update_stats(struct ath_softc *sc, struc /* just average the first few packets */ int avg_tx = sn->stats[size_bin][rix0].average_tx_time; int packets = sn->stats[size_bin][rix0].total_packets; - sn->stats[size_bin][rix0].average_tx_time = (tt+(avg_tx*packets))/(packets+1); + sn->stats[size_bin][rix0].average_tx_time = (tt+(avg_tx*packets))/(packets+nframes); } else { /* use a ewma */ sn->stats[size_bin][rix0].average_tx_time = @@ -550,36 +551,37 @@ update_stats(struct ath_softc *sc, struc if (status != 0) { int y; - sn->stats[size_bin][rix0].successive_failures++; + sn->stats[size_bin][rix0].successive_failures += nbad; for (y = size_bin+1; y < NUM_PACKET_SIZE_BINS; y++) { /* * Also say larger packets failed since we * assume if a small packet fails at a * bit-rate then a larger one will also. */ - sn->stats[y][rix0].successive_failures++; + sn->stats[y][rix0].successive_failures += nbad; sn->stats[y][rix0].last_tx = ticks; sn->stats[y][rix0].tries += tries; - sn->stats[y][rix0].total_packets++; + sn->stats[y][rix0].total_packets += nframes; } } else { - sn->stats[size_bin][rix0].packets_acked++; + sn->stats[size_bin][rix0].packets_acked += nframes; sn->stats[size_bin][rix0].successive_failures = 0; } sn->stats[size_bin][rix0].tries += tries; sn->stats[size_bin][rix0].last_tx = ticks; - sn->stats[size_bin][rix0].total_packets++; + sn->stats[size_bin][rix0].total_packets += nframes; 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)", +"%s: size %d %s sample rate %d tries (%d/%d) tt %d avg_tt (%d/%d) nfrm %d nbad %d", __func__, size, status ? "FAIL" : "OK", rix0, short_tries, tries, tt, sn->stats[size_bin][rix0].average_tx_time, - sn->stats[size_bin][rix0].perfect_tx_time); + sn->stats[size_bin][rix0].perfect_tx_time, + nframes, nbad); sn->sample_tt[size_bin] = tt; sn->current_sample_rix[size_bin] = -1; } @@ -642,7 +644,8 @@ 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, ts->ts_status, + nframes, nbad); } else { int finalTSIdx = ts->ts_finaltsi; int i; @@ -689,7 +692,8 @@ ath_rate_tx_complete(struct ath_softc *s rc[2].rix, rc[2].tries, rc[3].rix, rc[3].tries, short_tries, long_tries, - long_tries > rc[0].tries); + long_tries > rc[0].tries, + nframes, nbad); long_tries -= rc[0].tries; } @@ -700,7 +704,8 @@ ath_rate_tx_complete(struct ath_softc *s rc[3].rix, rc[3].tries, 0, 0, short_tries, long_tries, - ts->ts_status); + ts->ts_status, + nframes, nbad); long_tries -= rc[1].tries; } @@ -711,7 +716,8 @@ ath_rate_tx_complete(struct ath_softc *s 0, 0, 0, 0, short_tries, long_tries, - ts->ts_status); + ts->ts_status, + nframes, nbad); long_tries -= rc[2].tries; } @@ -722,7 +728,8 @@ ath_rate_tx_complete(struct ath_softc *s 0, 0, 0, 0, short_tries, long_tries, - ts->ts_status); + ts->ts_status, + nframes, nbad); } } } From owner-svn-src-user@FreeBSD.ORG Thu Aug 25 09:29: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 D1125106567A; Thu, 25 Aug 2011 09:29: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 C19708FC15; Thu, 25 Aug 2011 09:29: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 p7P9TSkS096109; Thu, 25 Aug 2011 09:29:28 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7P9TSXE096107; Thu, 25 Aug 2011 09:29:28 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108250929.p7P9TSXE096107@svn.freebsd.org> From: Adrian Chadd Date: Thu, 25 Aug 2011 09:29: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: r225170 - 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, 25 Aug 2011 09:29:28 -0000 Author: adrian Date: Thu Aug 25 09:29:28 2011 New Revision: 225170 URL: http://svn.freebsd.org/changeset/base/225170 Log: Fix indenting 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 Thu Aug 25 09:20:13 2011 (r225169) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Thu Aug 25 09:29:28 2011 (r225170) @@ -4419,7 +4419,7 @@ ath_tx_processq(struct ath_softc *sc, st bf->bf_state.bfs_rc, ts, bf->bf_state.bfs_pktlen, 1, (ts->ts_status == 0 ? 0 : 1)); - ath_tx_default_comp(sc, bf, 0); + ath_tx_default_comp(sc, bf, 0); } } else bf->bf_comp(sc, bf, 0); From owner-svn-src-user@FreeBSD.ORG Thu Aug 25 18:03: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 CD1EC106564A; Thu, 25 Aug 2011 18:03:29 +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 BC94B8FC0C; Thu, 25 Aug 2011 18:03:29 +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 p7PI3TYN013839; Thu, 25 Aug 2011 18:03:29 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7PI3TO3013837; Thu, 25 Aug 2011 18:03:29 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108251803.p7PI3TO3013837@svn.freebsd.org> From: Gabor Kovesdan Date: Thu, 25 Aug 2011 18:03:29 +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: r225183 - 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, 25 Aug 2011 18:03:29 -0000 Author: gabor Date: Thu Aug 25 18:03:29 2011 New Revision: 225183 URL: http://svn.freebsd.org/changeset/base/225183 Log: - Add support for REG_EXTENDED - Some accuracy fixes for REG_BASIC Modified: user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.c Modified: user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.c ============================================================================== --- user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.c Thu Aug 25 17:43:06 2011 (r225182) +++ user/gabor/tre-integration/contrib/tre/lib/tre-heuristic.c Thu Aug 25 18:03:29 2011 (r225183) @@ -125,7 +125,15 @@ st = i + 1; \ escaped = false; \ goto end_segment; \ - } while (0); + } while (0) + +#define STORE_CHAR \ + do \ + { \ + escaped = false; \ + heur[pos++] = regex[i]; \ + } while (0) + /* * Parses a regular expression and constructs a heuristic in heur_t and @@ -140,10 +148,6 @@ tre_compile_heur(heur_t *h, const tre_ch bool escaped = false; int errcode, ret; - /* XXX: only basic regexes are supported. */ - if (cflags & REG_EXTENDED) - return REG_BADPAT; - /* Temporary space, len will be enough. */ heur = xmalloc(len); if (!heur) @@ -168,10 +172,17 @@ tre_compile_heur(heur_t *h, const tre_ch switch (regex[i]) { - /* Bracketed expression is substituted with a dot. */ + /* + * Bracketed expression is substituted with a dot or the + * brackets are treated as normal if at least the opening + * bracket is escaped. + */ case TRE_CHAR('['): PARSE_BRACKETS; - heur[pos++] = TRE_CHAR('.'); + if (escaped) + STORE_CHAR; + else + heur[pos++] = TRE_CHAR('.'); continue; /* @@ -180,14 +191,22 @@ tre_compile_heur(heur_t *h, const tre_ch * character. */ case TRE_CHAR('{'): + if (escaped && (i == 1)) + STORE_CHAR; + else if ((i == 0) && !(cflags & REG_EXTENDED)) + STORE_CHAR; + else if ((i == 0) && (cflags & REG_EXTENDED)) + continue; + PARSE_UNIT('{', '}'); - if (escaped) + if (escaped ^ (cflags & REG_EXTENDED)) { pos--; END_SEGMENT; } - heur[pos++] = regex[i]; - break; + else + STORE_CHAR; + continue; /* * Terminates the current segment when escaped, @@ -195,10 +214,11 @@ tre_compile_heur(heur_t *h, const tre_ch */ case TRE_CHAR('('): PARSE_UNIT('(', ')'); - if (escaped) + if (escaped ^ (cflags & REG_EXTENDED)) END_SEGMENT; - heur[pos++] = regex[i]; - break; + else + STORE_CHAR; + continue; /* * Sets escaped flag. @@ -207,24 +227,88 @@ tre_compile_heur(heur_t *h, const tre_ch */ case TRE_CHAR('\\'): if (escaped) - heur[pos++] = regex[i]; - escaped = !escaped; + STORE_CHAR; + else + escaped = !escaped; continue; /* - * If not the first character and not escaped, erases the + * BRE: If not the first character and not escaped, erases the * last character and terminates the segment. * Otherwise treated as a normal character. + * ERE: Skipped if first character (GNU), rest is like in BRE. */ case TRE_CHAR('*'): - if ((i != 0) && !escaped) + if (escaped || (!(cflags & REG_EXTENDED) && (i == 0))) + STORE_CHAR; + else if ((i != 0)) + { + pos--; + END_SEGMENT; + } + continue; + + /* + * In BRE, it is a normal character, behavior is undefined + * when escaped. + * In ERE, it is special unless escaped. Terminate segment + * when not escaped. Last character is not removed because it + * must occur at least once. It is skipped when first + * character (GNU). + */ + case TRE_CHAR('+'): + if ((cflags & REG_EXTENDED) && (i == 0)) + continue; + else if ((cflags & REG_EXTENDED) ^ escaped) + END_SEGMENT; + else + STORE_CHAR; + continue; + + /* + * In BRE, it is a normal character, behavior is undefined + * when escaped. + * In ERE, it is special unless escaped. Terminate segment + * when not escaped. Last character is removed. Skipped when + * first character (GNU). + */ + case TRE_CHAR('?'): + if ((cflags & REG_EXTENDED) && (i == 0)) + continue; + if ((cflags & REG_EXTENDED) ^ escaped) { pos--; END_SEGMENT; } else - heur[pos++] = regex[i]; - break; + STORE_CHAR; + continue; + + /* + * Fail if it is an ERE alternation marker. + */ + case TRE_CHAR('|'): + if ((cflags & REG_EXTENDED) && !escaped) + { + errcode = REG_BADPAT; + goto badpat2; + } + else if (!(cflags & REG_EXTENDED) && escaped) + END_SEGMENT; + else + STORE_CHAR; + continue; + + /* + * Cut the segment at an escaped dot because the fast matcher + * cannot handle it. + */ + case TRE_CHAR('.'): + if (escaped) + END_SEGMENT; + else + STORE_CHAR; + continue; /* * If escaped, terminates segment. @@ -234,7 +318,8 @@ tre_compile_heur(heur_t *h, const tre_ch default: if (escaped) END_SEGMENT; - heur[pos++] = regex[i]; + else + STORE_CHAR; continue; } } From owner-svn-src-user@FreeBSD.ORG Fri Aug 26 08:47: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 5B6D9106566C; Fri, 26 Aug 2011 08:47:00 +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 324F98FC0A; Fri, 26 Aug 2011 08:47: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 p7Q8l05h044417; Fri, 26 Aug 2011 08:47:00 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7Q8l0P9044415; Fri, 26 Aug 2011 08:47:00 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108260847.p7Q8l0P9044415@svn.freebsd.org> From: Adrian Chadd Date: Fri, 26 Aug 2011 08:47: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: r225187 - 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, 26 Aug 2011 08:47:00 -0000 Author: adrian Date: Fri Aug 26 08:46:59 2011 New Revision: 225187 URL: http://svn.freebsd.org/changeset/base/225187 Log: Various fixes to some of the issues I've seen with the hostap operation. * Fix the mcast queue assignment * When completing aggregate frames, bf_first no longer exists, so don't assume you can use it for anything. 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 Fri Aug 26 07:38:40 2011 (r225186) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath_tx.c Fri Aug 26 08:46:59 2011 (r225187) @@ -1289,7 +1289,7 @@ ath_tx_start(struct ath_softc *sc, struc * destination hardware queue. Don't bother software * queuing it, as the TID will now be paused. */ - if (ismcast) { + if (txq == &avp->av_mcastq) { /* Setup the descriptor before handoff */ ath_tx_setds(sc, bf); ath_tx_set_ratectrl(sc, ni, bf); @@ -1377,6 +1377,10 @@ ath_tx_raw_start(struct ath_softc *sc, s /* XXX honor IEEE80211_BPF_DATAPAD */ pktlen = m0->m_pkthdr.len - (hdrlen & 3) + IEEE80211_CRC_LEN; + + DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: ismcast=%d\n", + __func__, ismcast); + /* Handle encryption twiddling if needed */ if (! ath_tx_tag_crypto(sc, ni, m0, params->ibp_flags & IEEE80211_BPF_CRYPTO, 0, @@ -1542,6 +1546,8 @@ ath_tx_raw_start(struct ath_softc *sc, s * into the hardware queue, right after any pending * frames to that node are. */ + DPRINTF(sc, ATH_DEBUG_SW_TX, "%s: dooverride=%d\n", + __func__, do_override); if (do_override) { ath_tx_setds(sc, bf); @@ -2734,7 +2740,7 @@ ath_tx_aggr_comp_aggr(struct ath_softc * int ba_index; int drops = 0; struct ath_txq *txq = sc->sc_ac2q[atid->ac]; - int nframes = 0, nbad = 0; + int nframes = 0, nbad = 0, nf; int pktlen; /* XXX there's too much on the stack? */ struct ath_rc_series rc[4]; @@ -2814,6 +2820,10 @@ ath_tx_aggr_comp_aggr(struct ath_softc * * sent and which weren't. */ bf = bf_first; + nf = bf_first->bf_state.bfs_nframes; + + /* bf_first is going to be invalid once this list is walked */ + bf_first = NULL; while (bf) { nframes++; @@ -2844,9 +2854,10 @@ ath_tx_aggr_comp_aggr(struct ath_softc * bf = bf_next; } - if (nframes != bf_first->bf_state.bfs_nframes) - device_printf(sc->sc_dev, "%s: np=%d; nframes=%d\n", - __func__, nframes, bf_first->bf_state.bfs_nframes); + if (nframes != nf) + device_printf(sc->sc_dev, + "%s: num frames seen=%d; bf nframes=%d\n", + __func__, nframes, nf); /* * Now we know how many frames were bad, call the rate From owner-svn-src-user@FreeBSD.ORG Fri Aug 26 22:33: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 B96BF1065678; Fri, 26 Aug 2011 22:33:41 +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 AA3468FC1F; Fri, 26 Aug 2011 22:33: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 p7QMXfdV073597; Fri, 26 Aug 2011 22:33:41 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7QMXfi4073595; Fri, 26 Aug 2011 22:33:41 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201108262233.p7QMXfi4073595@svn.freebsd.org> From: Doug Barton Date: Fri, 26 Aug 2011 22:33: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: r225204 - 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, 26 Aug 2011 22:33:41 -0000 Author: dougb Date: Fri Aug 26 22:33:41 2011 New Revision: 225204 URL: http://svn.freebsd.org/changeset/base/225204 Log: For --clean-packages if a package is up to date but not installed it should still be deleted if -y is in use. Modified: user/dougb/portmaster/portmaster Modified: user/dougb/portmaster/portmaster ============================================================================== --- user/dougb/portmaster/portmaster Fri Aug 26 21:46:36 2011 (r225203) +++ user/dougb/portmaster/portmaster Fri Aug 26 22:33:41 2011 (r225204) @@ -1332,16 +1332,14 @@ if [ -n "$CLEAN_PACKAGES" ]; then if [ -n "$port_ver" ]; then if [ "${port_ver}.tbz" = "${package##*/}" ]; then echo "===>>> ${package##*/} is up to date" - if [ -z "$PM_YES" ]; then - if [ ! -d "${pdb}/${pkg_dir}" ]; then - echo " ===>>> $pkg_dir is not installed" - echo " ===>>> Path: ${package}" - get_answer_yn y " ===>>> Delete stale package: ${package##*/}" - case "$?" in - 0) echo " ===>>> Deleting $package" - pm_unlink_s $package ;; - esac - fi + if [ ! -d "${pdb}/${pkg_dir}" ]; then + echo " ===>>> $pkg_dir is not installed" + echo " ===>>> Path: ${package}" + get_answer_yn y " ===>>> Delete stale package: ${package##*/}" + case "$?" in + 0) echo " ===>>> Deleting $package" + pm_unlink_s $package ;; + esac fi unset port_ver continue From owner-svn-src-user@FreeBSD.ORG Sat Aug 27 06:30: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 3FE6D106566B; Sat, 27 Aug 2011 06:30:02 +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 2BE918FC08; Sat, 27 Aug 2011 06:30: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 p7R6U2bj087851; Sat, 27 Aug 2011 06:30:02 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7R6U2uG087849; Sat, 27 Aug 2011 06:30:02 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108270630.p7R6U2uG087849@svn.freebsd.org> From: Adrian Chadd Date: Sat, 27 Aug 2011 06:30:01 +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: r225207 - 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: Sat, 27 Aug 2011 06:30:02 -0000 Author: adrian Date: Sat Aug 27 06:30:01 2011 New Revision: 225207 URL: http://svn.freebsd.org/changeset/base/225207 Log: Give in and just zero bf_state when allocating a new buffer. The lingering bits of state that are floating around were causing occasional issues in hostap mode where the buffers allocated for beacon frames would be incorrectly accounted for (eg they'd still have the bfs_aggr flag set.) 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 Aug 26 23:45:27 2011 (r225206) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Sat Aug 27 06:30:01 2011 (r225207) @@ -1891,6 +1891,7 @@ _ath_getbuf_locked(struct ath_softc *sc) bf->bf_next = NULL; /* XXX just to be sure */ bf->bf_last = NULL; /* XXX again, just to be sure */ bf->bf_comp = NULL; /* XXX again, just to be sure */ + bzero(&bf->bf_state, sizeof(bf->bf_state)); return bf; } From owner-svn-src-user@FreeBSD.ORG Sat Aug 27 06:54:08 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 74758106564A; Sat, 27 Aug 2011 06:54:08 +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 645848FC14; Sat, 27 Aug 2011 06:54:08 +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 p7R6s83S088614; Sat, 27 Aug 2011 06:54:08 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7R6s8oe088612; Sat, 27 Aug 2011 06:54:08 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108270654.p7R6s8oe088612@svn.freebsd.org> From: Adrian Chadd Date: Sat, 27 Aug 2011 06:54:08 +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: r225208 - 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: Sat, 27 Aug 2011 06:54:08 -0000 Author: adrian Date: Sat Aug 27 06:54:08 2011 New Revision: 225208 URL: http://svn.freebsd.org/changeset/base/225208 Log: oops, ath_tx_default_comp() wasn't being called when a non-ucast packet TX completed. 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 Sat Aug 27 06:30:01 2011 (r225207) +++ user/adrian/if_ath_tx/sys/dev/ath/if_ath.c Sat Aug 27 06:54:08 2011 (r225208) @@ -4420,8 +4420,8 @@ ath_tx_processq(struct ath_softc *sc, st bf->bf_state.bfs_rc, ts, bf->bf_state.bfs_pktlen, 1, (ts->ts_status == 0 ? 0 : 1)); - ath_tx_default_comp(sc, bf, 0); } + ath_tx_default_comp(sc, bf, 0); } else bf->bf_comp(sc, bf, 0); } From owner-svn-src-user@FreeBSD.ORG Sat Aug 27 15:31: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 C7660106566B; Sat, 27 Aug 2011 15:31:30 +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 AD9BB8FC0A; Sat, 27 Aug 2011 15:31: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 p7RFVUwR011206; Sat, 27 Aug 2011 15:31:30 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7RFVUpr011204; Sat, 27 Aug 2011 15:31:30 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201108271531.p7RFVUpr011204@svn.freebsd.org> From: Adrian Chadd Date: Sat, 27 Aug 2011 15:31: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: r225216 - 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: Sat, 27 Aug 2011 15:31:31 -0000 Author: adrian Date: Sat Aug 27 15:31:30 2011 New Revision: 225216 URL: http://svn.freebsd.org/changeset/base/225216 Log: Add more things to look at 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 Sat Aug 27 15:28:57 2011 (r225215) +++ user/adrian/if_ath_tx/sys/dev/ath/README Sat Aug 27 15:31:30 2011 (r225216) @@ -198,6 +198,69 @@ Stuff to do to the rate control code The rate selection stuff doesn't do this -now-, but it may be useful later. +Problems in net80211 (ie, not necessarily this branch) +------------------------------------------------------ + +ieee80211_node.c:1940 is within: + +static void +ieee80211_timeout_stations(struct ieee80211com *ic) + +This initial lock: IEEE80211_NODE_LOCK(nt); + +lock order reversal: + 1st 0xc08316cc ath0_node_lock (ath0_node_lock) @ /data/freebsd/mips/if_ath_tx/src/sys/net80211/ieee80211_node.c:1940 + 2nd 0xc0830014 ath0_com_lock (ath0_com_lock) @ /data/freebsd/mips/if_ath_tx/src/sys/net80211/ieee80211_power.c:295 +KDB: stack backtrace: +db_trace_thread+30 (?,?,?,?) ra 8038e35c sp c077da90 sz 24 +db_trace_self+1c (?,?,?,?) ra 80074c1c sp c077daa8 sz 24 +80074be8+34 (?,?,?,?) ra 801d1ba4 sp c077dac0 sz 416 +kdb_backtrace+44 (?,?,?,?) ra 801e9660 sp c077dc60 sz 24 +801e962c+34 (?,?,?,?) ra 801ea2a4 sp c077dc78 sz 32 +witness_checkorder+954 (?,?,?,?) ra 8018a740 sp c077dc98 sz 88 +_mtx_lock_flags+c4 (?,?,?,?) ra 802a5a30 sp c077dcf0 sz 48 +802a59a8+88 (?,?,?,?) ra 8029e4a8 sp c077dd20 sz 40 +8029e444+64 (?,?,?,?) ra 8029d4d8 sp c077dd48 sz 32 +ieee80211_node_timeout+1a4 (?,?,?,?) ra 801b0300 sp c077dd68 sz 64 +softclock+298 (?,?,?,?) ra 80172860 sp c077dda8 sz 88 +intr_event_execute_handlers+158 (?,?,?,?) ra 80173868 sp c077de00 sz 40 +8017375c+10c (?,?,?,?) ra 8016fb64 sp c077de28 sz 48 +fork_exit+a8 (?,?,?,?) ra 80386aa0 sp c077de58 sz 40 +fork_trampoline+10 (?,?,?,?) ra 0 sp c077de80 sz 0 + +A kernel panic, when a station is downed; + +wlan0: [8c:7b:9d:d6:65:ba] station with aid 1 leaves +ath0: ath_addba_stop: called +ath0: ath_tx_tid_pause: paused = 1 +ath0: ath_tx_cleanup: TID 0: called +ath0: ath_tx_cleanup: TID 0: cleanup needed: 2 packets +ath0: ath_tx_tid_cleanup: node 0xc08e8000: cleaning up +Trap cause = 2 (TLB miss (load or instr. fetch) - kernel mode) +[ thread pid 0 tid 100024 ] +Stopped at _mtx_lock_flags+0x58: lw v1,16(a0) +db> bt +Tracing pid 0 tid 100024 td 0x80a07600 +db_trace_thread+30 (?,?,?,?) ra 80072dc0 sp c766f7f8 sz 24 +80072cac+114 (8018a6d4,?,ffffffff,?) ra 8007237c sp c766f810 sz 32 +80071ff4+388 (?,?,?,?) ra 80072500 sp c766f830 sz 168 +db_command_loop+70 (?,?,?,?) ra 80074bc4 sp c766f8d8 sz 24 +80074ad0+f4 (?,?,?,?) ra 801d1818 sp c766f8f0 sz 424 +kdb_trap+104 (?,?,?,?) ra 80382910 sp c766fa98 sz 40 +trap+e58 (?,?,?,?) ra 8037a5e0 sp c766fac0 sz 168 +MipsKernGenException+134 (c08ec3e4,0,803e053c,10c9) ra 8018a6d4 sp c766fb68 sz 200 +_mtx_lock_flags+58 (?,?,?,?) ra 80079ea0 sp c766fc30 sz 48 +ath_tx_update_ratectrl+5c (?,?,?,?) ra 80088644 sp c766fc60 sz 56 +ath_tx_aggr_comp+660 (?,?,0,?) ra 8007dcc4 sp c766fc98 sz 232 +8007d7e8+4dc (?,?,?,?) ra 8007e56c sp c766fd80 sz 72 (if_ath.c:4326) - processq? +8007e4e4+88 (?,?,?,?) ra 801dfb24 sp c766fdc8 sz 48 (if_ath.c:4491) - tx tasklet +801dfa3c+e8 (?,?,?,?) ra 801e05ec sp c766fdf8 sz 56 (subr_taskqueue.c:308) +taskqueue_thread_loop+60 (?,?,?,?) ra 8016fb64 sp c766fe30 sz 40 +fork_exit+a8 (?,?,?,?) ra 80386aa0 sp c766fe58 sz 40 +fork_trampoline+10 (?,?,?,?) ra 0 sp c766fe80 sz 0 +pid 0 + + Fixed issues: -------------