The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/net80211/ieee80211_alq.c

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 2011 Adrian Chadd, Xenion Lty Ltd
    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
    9  *    notice, this list of conditions and the following disclaimer.
   10  * 2. Redistributions in binary form must reproduce the above copyright
   11  *    notice, this list of conditions and the following disclaimer in the
   12  *    documentation and/or other materials provided with the distribution.
   13  *
   14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   15  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   16  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   17  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   18  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   19  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   20  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   21  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   23  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   24  */
   25 
   26 #include <sys/cdefs.h>
   27 #ifdef __FreeBSD__
   28 __FBSDID("$FreeBSD: releng/10.0/sys/net80211/ieee80211_alq.c 233255 2012-03-21 03:19:50Z adrian $");
   29 #endif
   30 
   31 /*
   32  * net80211 fast-logging support, primarily for debugging.
   33  *
   34  * This implements a single debugging queue which includes
   35  * per-device enumeration where needed.
   36  */
   37 
   38 #include "opt_wlan.h"
   39 
   40 #include <sys/param.h>
   41 #include <sys/systm.h>
   42 #include <sys/mbuf.h>
   43 #include <sys/malloc.h>
   44 #include <sys/endian.h>
   45 #include <sys/kernel.h>
   46 #include <sys/sysctl.h>
   47 #include <sys/pcpu.h>
   48 #include <sys/proc.h>
   49 #include <sys/ucred.h>
   50 #include <sys/alq.h>
   51 
   52 #include <sys/socket.h>
   53 
   54 #include <net/if.h>
   55 #include <net/if_var.h>
   56 #include <net/if_dl.h>
   57 #include <net/if_clone.h>
   58 #include <net/if_media.h>
   59 #include <net/if_types.h>
   60 
   61 #include <net80211/ieee80211_var.h>
   62 #include <net80211/ieee80211_freebsd.h>
   63 #include <net80211/ieee80211_alq.h>
   64 
   65 static struct alq *ieee80211_alq;
   66 static int ieee80211_alq_lost;
   67 static int ieee80211_alq_logged;
   68 static char ieee80211_alq_logfile[MAXPATHLEN] = "/tmp/net80211.log";
   69 static unsigned int ieee80211_alq_qsize = 64*1024;
   70 
   71 static int
   72 ieee80211_alq_setlogging(int enable)
   73 {
   74         int error;
   75 
   76         if (enable) {
   77                 if (ieee80211_alq)
   78                         alq_close(ieee80211_alq);
   79 
   80                 error = alq_open(&ieee80211_alq,
   81                     ieee80211_alq_logfile,
   82                     curthread->td_ucred,
   83                     ALQ_DEFAULT_CMODE,
   84                     sizeof (struct ieee80211_alq_rec),
   85                     ieee80211_alq_qsize);
   86                 ieee80211_alq_lost = 0;
   87                 ieee80211_alq_logged = 0;
   88                 printf("net80211: logging to %s enabled; "
   89                     "struct size %d bytes\n",
   90                     ieee80211_alq_logfile,
   91                     sizeof(struct ieee80211_alq_rec));
   92         } else {
   93                 if (ieee80211_alq)
   94                         alq_close(ieee80211_alq);
   95                 ieee80211_alq = NULL;
   96                 printf("net80211: logging disabled\n");
   97                 error = 0;
   98         }
   99         return (error);
  100 }
  101 
  102 static int
  103 sysctl_ieee80211_alq_log(SYSCTL_HANDLER_ARGS)
  104 {
  105         int error, enable;
  106 
  107         enable = (ieee80211_alq != NULL);
  108         error = sysctl_handle_int(oidp, &enable, 0, req);
  109         if (error || !req->newptr)
  110                 return (error);
  111         else
  112                 return (ieee80211_alq_setlogging(enable));
  113 }
  114 
  115 SYSCTL_PROC(_net_wlan, OID_AUTO, alq, CTLTYPE_INT|CTLFLAG_RW,
  116         0, 0, sysctl_ieee80211_alq_log, "I", "Enable net80211 alq logging");
  117 SYSCTL_INT(_net_wlan, OID_AUTO, alq_size, CTLFLAG_RW,
  118         &ieee80211_alq_qsize, 0, "In-memory log size (#records)");
  119 SYSCTL_INT(_net_wlan, OID_AUTO, alq_lost, CTLFLAG_RW,
  120         &ieee80211_alq_lost, 0, "Debugging operations not logged");
  121 SYSCTL_INT(_net_wlan, OID_AUTO, alq_logged, CTLFLAG_RW,
  122         &ieee80211_alq_logged, 0, "Debugging operations logged");
  123 
  124 static struct ale *
  125 ieee80211_alq_get(void)
  126 {
  127         struct ale *ale;
  128 
  129         ale = alq_get(ieee80211_alq, ALQ_NOWAIT);
  130         if (!ale)
  131                 ieee80211_alq_lost++;
  132         else
  133                 ieee80211_alq_logged++;
  134         return ale;
  135 }
  136 
  137 void
  138 ieee80211_alq_log(struct ieee80211vap *vap, uint8_t op, u_char *p, int l)
  139 {
  140         struct ale *ale;
  141         struct ieee80211_alq_rec *r;
  142 
  143         if (ieee80211_alq == NULL)
  144                 return;
  145 
  146         ale = ieee80211_alq_get();
  147         if (! ale)
  148                 return;
  149 
  150         r = (struct ieee80211_alq_rec *) ale->ae_data;
  151         r->r_timestamp = htonl(ticks);
  152         r->r_version = 1;
  153         r->r_wlan = htons(vap->iv_ifp->if_dunit);
  154         r->r_op = op;
  155         r->r_threadid = htonl((uint32_t) curthread->td_tid);
  156         memcpy(&r->r_payload, p, MIN(l, sizeof(r->r_payload)));
  157         alq_post(ieee80211_alq, ale);
  158 }

Cache object: 31a2f5430e201a9ef0405844b033dab2


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.