if_ath_alq.c (243158) | if_ath_alq.c (246648) |
---|---|
1/*- 2 * Copyright (c) 2012 Adrian Chadd 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 12 unchanged lines hidden (view full) --- 21 * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, 22 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 27 * THE POSSIBILITY OF SUCH DAMAGES. 28 * | 1/*- 2 * Copyright (c) 2012 Adrian Chadd 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 12 unchanged lines hidden (view full) --- 21 * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, 22 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 27 * THE POSSIBILITY OF SUCH DAMAGES. 28 * |
29 * $FreeBSD: head/sys/dev/ath/if_ath_alq.c 243158 2012-11-16 19:39:29Z adrian $ | 29 * $FreeBSD: head/sys/dev/ath/if_ath_alq.c 246648 2013-02-11 02:48:49Z adrian $ |
30 */ 31#include "opt_ah.h" 32#include "opt_ath.h" 33 34#include <sys/param.h> 35#include <sys/systm.h> 36#include <sys/kernel.h> 37#include <sys/module.h> 38#include <sys/sysctl.h> 39#include <sys/bus.h> 40#include <sys/malloc.h> 41#include <sys/proc.h> 42#include <sys/pcpu.h> 43#include <sys/lock.h> 44#include <sys/mutex.h> 45#include <sys/alq.h> 46#include <sys/endian.h> | 30 */ 31#include "opt_ah.h" 32#include "opt_ath.h" 33 34#include <sys/param.h> 35#include <sys/systm.h> 36#include <sys/kernel.h> 37#include <sys/module.h> 38#include <sys/sysctl.h> 39#include <sys/bus.h> 40#include <sys/malloc.h> 41#include <sys/proc.h> 42#include <sys/pcpu.h> 43#include <sys/lock.h> 44#include <sys/mutex.h> 45#include <sys/alq.h> 46#include <sys/endian.h> |
47#include <sys/time.h> |
|
47 48#include <dev/ath/if_ath_alq.h> 49 50#ifdef ATH_DEBUG_ALQ 51static struct ale * 52if_ath_alq_get(struct if_ath_alq *alq, int len) 53{ 54 struct ale *ale; --- 93 unchanged lines hidden (view full) --- 148 * "len" is the size of the buf payload in bytes. 149 */ 150void 151if_ath_alq_post(struct if_ath_alq *alq, uint16_t op, uint16_t len, 152 const char *buf) 153{ 154 struct if_ath_alq_hdr *ap; 155 struct ale *ale; | 48 49#include <dev/ath/if_ath_alq.h> 50 51#ifdef ATH_DEBUG_ALQ 52static struct ale * 53if_ath_alq_get(struct if_ath_alq *alq, int len) 54{ 55 struct ale *ale; --- 93 unchanged lines hidden (view full) --- 149 * "len" is the size of the buf payload in bytes. 150 */ 151void 152if_ath_alq_post(struct if_ath_alq *alq, uint16_t op, uint16_t len, 153 const char *buf) 154{ 155 struct if_ath_alq_hdr *ap; 156 struct ale *ale; |
157 struct timeval tv; |
|
156 157 if (! if_ath_alq_checkdebug(alq, op)) 158 return; 159 | 158 159 if (! if_ath_alq_checkdebug(alq, op)) 160 return; 161 |
162 microtime(&tv); 163 |
|
160 /* 161 * Enforce some semblence of sanity on 'len'. 162 * Although strictly speaking, any length is possible - 163 * just be conservative so things don't get out of hand. 164 */ 165 if (len > ATH_ALQ_PAYLOAD_LEN) 166 len = ATH_ALQ_PAYLOAD_LEN; 167 168 ale = if_ath_alq_get(alq, len + sizeof(struct if_ath_alq_hdr)); 169 170 if (ale == NULL) 171 return; 172 173 ap = (struct if_ath_alq_hdr *) ale->ae_data; 174 ap->threadid = htobe64((uint64_t) curthread->td_tid); | 164 /* 165 * Enforce some semblence of sanity on 'len'. 166 * Although strictly speaking, any length is possible - 167 * just be conservative so things don't get out of hand. 168 */ 169 if (len > ATH_ALQ_PAYLOAD_LEN) 170 len = ATH_ALQ_PAYLOAD_LEN; 171 172 ale = if_ath_alq_get(alq, len + sizeof(struct if_ath_alq_hdr)); 173 174 if (ale == NULL) 175 return; 176 177 ap = (struct if_ath_alq_hdr *) ale->ae_data; 178 ap->threadid = htobe64((uint64_t) curthread->td_tid); |
175 ap->tstamp = htobe32((uint32_t) ticks); | 179 ap->tstamp_sec = htobe32((uint32_t) tv.tv_sec); 180 ap->tstamp_usec = htobe32((uint32_t) tv.tv_usec); |
176 ap->op = htobe16(op); 177 ap->len = htobe16(len); 178 179 /* 180 * Copy the payload _after_ the header field. 181 */ 182 memcpy(((char *) ap) + sizeof(struct if_ath_alq_hdr), 183 buf, 184 len); 185 186 alq_post(alq->sc_alq_alq, ale); 187} 188#endif /* ATH_DEBUG */ | 181 ap->op = htobe16(op); 182 ap->len = htobe16(len); 183 184 /* 185 * Copy the payload _after_ the header field. 186 */ 187 memcpy(((char *) ap) + sizeof(struct if_ath_alq_hdr), 188 buf, 189 len); 190 191 alq_post(alq->sc_alq_alq, ale); 192} 193#endif /* ATH_DEBUG */ |