From owner-svn-src-head@freebsd.org Sun Nov 6 19:18:26 2016 Return-Path: <owner-svn-src-head@freebsd.org> Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C00DFC3422A; Sun, 6 Nov 2016 19:18:26 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7F9B4F2C; Sun, 6 Nov 2016 19:18:26 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uA6JIP5U019719; Sun, 6 Nov 2016 19:18:25 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uA6JIP1J019717; Sun, 6 Nov 2016 19:18:25 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <201611061918.uA6JIP1J019717@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd <adrian@FreeBSD.org> Date: Sun, 6 Nov 2016 19:18:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308385 - head/sys/net80211 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current <svn-src-head.freebsd.org> List-Unsubscribe: <https://lists.freebsd.org/mailman/options/svn-src-head>, <mailto:svn-src-head-request@freebsd.org?subject=unsubscribe> List-Archive: <http://lists.freebsd.org/pipermail/svn-src-head/> List-Post: <mailto:svn-src-head@freebsd.org> List-Help: <mailto:svn-src-head-request@freebsd.org?subject=help> List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/svn-src-head>, <mailto:svn-src-head-request@freebsd.org?subject=subscribe> X-List-Received-Date: Sun, 06 Nov 2016 19:18:26 -0000 Author: adrian Date: Sun Nov 6 19:18:25 2016 New Revision: 308385 URL: https://svnweb.freebsd.org/changeset/base/308385 Log: [net80211] extend the net80211 ALQ code to support variable payloads. Also - allow driver specific bits to be added, rather than just net80211. This still isn't as useful as it should be by default; it needs to be a standalone struct/instance so it can be done before net80211 registration occurs, and it can log per-device items. But, it's getting there. Modified: head/sys/net80211/ieee80211_alq.c head/sys/net80211/ieee80211_alq.h Modified: head/sys/net80211/ieee80211_alq.c ============================================================================== --- head/sys/net80211/ieee80211_alq.c Sun Nov 6 19:17:39 2016 (r308384) +++ head/sys/net80211/ieee80211_alq.c Sun Nov 6 19:18:25 2016 (r308385) @@ -79,14 +79,13 @@ ieee80211_alq_setlogging(int enable) ieee80211_alq_logfile, curthread->td_ucred, ALQ_DEFAULT_CMODE, - sizeof (struct ieee80211_alq_rec), - ieee80211_alq_qsize); + ieee80211_alq_qsize, 0); ieee80211_alq_lost = 0; ieee80211_alq_logged = 0; printf("net80211: logging to %s enabled; " "struct size %d bytes\n", ieee80211_alq_logfile, - sizeof(struct ieee80211_alq_rec)); + (int) sizeof(struct ieee80211_alq_rec)); } else { if (ieee80211_alq) alq_close(ieee80211_alq); @@ -113,18 +112,19 @@ sysctl_ieee80211_alq_log(SYSCTL_HANDLER_ SYSCTL_PROC(_net_wlan, OID_AUTO, alq, CTLTYPE_INT|CTLFLAG_RW, 0, 0, sysctl_ieee80211_alq_log, "I", "Enable net80211 alq logging"); SYSCTL_INT(_net_wlan, OID_AUTO, alq_size, CTLFLAG_RW, - &ieee80211_alq_qsize, 0, "In-memory log size (#records)"); + &ieee80211_alq_qsize, 0, "In-memory log size (bytes)"); SYSCTL_INT(_net_wlan, OID_AUTO, alq_lost, CTLFLAG_RW, &ieee80211_alq_lost, 0, "Debugging operations not logged"); SYSCTL_INT(_net_wlan, OID_AUTO, alq_logged, CTLFLAG_RW, &ieee80211_alq_logged, 0, "Debugging operations logged"); static struct ale * -ieee80211_alq_get(void) +ieee80211_alq_get(size_t len) { struct ale *ale; - ale = alq_get(ieee80211_alq, ALQ_NOWAIT); + ale = alq_getn(ieee80211_alq, len + sizeof(struct ieee80211_alq_rec), + ALQ_NOWAIT); if (!ale) ieee80211_alq_lost++; else @@ -132,25 +132,44 @@ ieee80211_alq_get(void) return ale; } -void -ieee80211_alq_log(struct ieee80211vap *vap, uint8_t op, u_char *p, int l) +int +ieee80211_alq_log(struct ieee80211com *ic, struct ieee80211vap *vap, + uint32_t op, uint32_t flags, uint16_t srcid, const uint8_t *src, + size_t len) { struct ale *ale; struct ieee80211_alq_rec *r; + char *dst; + /* Don't log if we're disabled */ if (ieee80211_alq == NULL) - return; + return (0); - ale = ieee80211_alq_get(); + if (len > IEEE80211_ALQ_MAX_PAYLOAD) + return (ENOMEM); + + ale = ieee80211_alq_get(len); if (! ale) - return; + return (ENOMEM); r = (struct ieee80211_alq_rec *) ale->ae_data; - r->r_timestamp = htonl(ticks); - r->r_version = 1; - r->r_wlan = htons(vap->iv_ifp->if_dunit); - r->r_op = op; - r->r_threadid = htonl((uint32_t) curthread->td_tid); - memcpy(&r->r_payload, p, MIN(l, sizeof(r->r_payload))); + dst = ((char *) r) + sizeof(struct ieee80211_alq_rec); + r->r_timestamp = htobe64(ticks); + if (vap != NULL) { + r->r_wlan = htobe16(vap->iv_ifp->if_dunit); + } else { + r->r_wlan = 0xffff; + } + r->r_src = htobe16(srcid); + r->r_flags = htobe32(flags); + r->r_op = htobe32(op); + r->r_len = htobe32(len + sizeof(struct ieee80211_alq_rec)); + r->r_threadid = htobe32((uint32_t) curthread->td_tid); + + if (src != NULL) + memcpy(dst, src, len); + alq_post(ieee80211_alq, ale); + + return (0); } Modified: head/sys/net80211/ieee80211_alq.h ============================================================================== --- head/sys/net80211/ieee80211_alq.h Sun Nov 6 19:17:39 2016 (r308384) +++ head/sys/net80211/ieee80211_alq.h Sun Nov 6 19:18:25 2016 (r308385) @@ -27,7 +27,7 @@ #ifndef __IEEE80211_ALQ_H__ #define __IEEE80211_ALQ_H__ -#define IEEE80211_ALQ_PAYLOAD_SIZE 24 +#define IEEE80211_ALQ_MAX_PAYLOAD 1024 /* * timestamp @@ -36,18 +36,24 @@ * sub-operation * rest of structure - operation specific */ + +#define IEEE80211_ALQ_SRC_NET80211 0x0001 +/* Drivers define their own numbers above 0xff */ + struct ieee80211_alq_rec { - uint32_t r_timestamp; /* XXX may wrap! */ + uint64_t r_timestamp; /* XXX may wrap! */ uint32_t r_threadid; /* current thread id */ uint16_t r_wlan; /* wlan interface number */ - uint8_t r_version; /* version */ - uint8_t r_op; /* top-level operation id */ - u_char r_payload[IEEE80211_ALQ_PAYLOAD_SIZE]; - /* operation-specific payload */ + uint16_t r_src; /* source - driver, net80211 */ + uint32_t r_flags; /* flags */ + uint32_t r_op; /* top-level operation id */ + uint32_t r_len; /* length of hdr + payload */ + /* Operation payload follows here */ }; /* General logging function */ -extern void ieee80211_alq_log(struct ieee80211vap *vap, uint8_t op, - u_char *p, int l); +extern int ieee80211_alq_log(struct ieee80211com *ic, + struct ieee80211vap *vap, uint32_t op, uint32_t flags, + uint16_t srcid, const uint8_t *src, size_t len); #endif /* __IEEE80211_ALQ_H__ */