Changeset View
Changeset View
Standalone View
Standalone View
head/tools/tools/mwl/mwldebug/mwldebug.c
Show All 27 Lines | |||||
* | * | ||||
* $FreeBSD$ | * $FreeBSD$ | ||||
*/ | */ | ||||
/* | /* | ||||
* mwldebug [-i interface] flags | * mwldebug [-i interface] flags | ||||
* (default interface is mwl0). | * (default interface is mwl0). | ||||
*/ | */ | ||||
#include <sys/types.h> | |||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/file.h> | #include <sys/file.h> | ||||
#include <sys/ioctl.h> | #include <sys/ioctl.h> | ||||
#include <sys/socket.h> | #include <sys/socket.h> | ||||
#include <sys/sysctl.h> | #include <sys/sysctl.h> | ||||
#include <stdlib.h> | |||||
#include <stdio.h> | |||||
#include <ctype.h> | #include <ctype.h> | ||||
#include <err.h> | |||||
#include <getopt.h> | #include <getopt.h> | ||||
#include <stdio.h> | |||||
#include <stdlib.h> | |||||
#include <string.h> | #include <string.h> | ||||
#include <err.h> | |||||
#define N(a) (sizeof(a)/sizeof(a[0])) | |||||
const char *progname; | const char *progname; | ||||
enum { | enum { | ||||
MWL_DEBUG_XMIT = 0x00000001, /* basic xmit operation */ | MWL_DEBUG_XMIT = 0x00000001, /* basic xmit operation */ | ||||
MWL_DEBUG_XMIT_DESC = 0x00000002, /* xmit descriptors */ | MWL_DEBUG_XMIT_DESC = 0x00000002, /* xmit descriptors */ | ||||
MWL_DEBUG_RECV = 0x00000004, /* basic recv operation */ | MWL_DEBUG_RECV = 0x00000004, /* basic recv operation */ | ||||
MWL_DEBUG_RECV_DESC = 0x00000008, /* recv descriptors */ | MWL_DEBUG_RECV_DESC = 0x00000008, /* recv descriptors */ | ||||
MWL_DEBUG_RESET = 0x00000010, /* reset processing */ | MWL_DEBUG_RESET = 0x00000010, /* reset processing */ | ||||
Show All 35 Lines | static struct { | ||||
{ "halhang", 0x04000000 }, /* disable fw hang stuff */ | { "halhang", 0x04000000 }, /* disable fw hang stuff */ | ||||
}; | }; | ||||
static u_int | static u_int | ||||
getflag(const char *name, int len) | getflag(const char *name, int len) | ||||
{ | { | ||||
int i; | int i; | ||||
for (i = 0; i < N(flags); i++) | for (i = 0; i < nitems(flags); i++) | ||||
if (strncasecmp(flags[i].name, name, len) == 0) | if (strncasecmp(flags[i].name, name, len) == 0) | ||||
return flags[i].bit; | return flags[i].bit; | ||||
return 0; | return 0; | ||||
} | } | ||||
#if 0 | #if 0 | ||||
static const char * | static const char * | ||||
getflagname(u_int flag) | getflagname(u_int flag) | ||||
{ | { | ||||
int i; | int i; | ||||
for (i = 0; i < N(flags); i++) | for (i = 0; i < nitems(flags); i++) | ||||
if (flags[i].bit == flag) | if (flags[i].bit == flag) | ||||
return flags[i].name; | return flags[i].name; | ||||
return "???"; | return "???"; | ||||
} | } | ||||
#endif | #endif | ||||
static void | static void | ||||
usage(void) | usage(void) | ||||
{ | { | ||||
int i; | int i; | ||||
fprintf(stderr, "usage: %s [-i device] [flags]\n", progname); | fprintf(stderr, "usage: %s [-i device] [flags]\n", progname); | ||||
fprintf(stderr, "where flags are:\n"); | fprintf(stderr, "where flags are:\n"); | ||||
for (i = 0; i < N(flags); i++) | for (i = 0; i < nitems(flags); i++) | ||||
printf("%s\n", flags[i].name); | printf("%s\n", flags[i].name); | ||||
exit(-1); | exit(-1); | ||||
} | } | ||||
int | int | ||||
main(int argc, char *argv[]) | main(int argc, char *argv[]) | ||||
{ | { | ||||
const char *ifname = "mwl0"; | const char *ifname = "mwl0"; | ||||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | if (debug != ndebug) { | ||||
printf("%s: 0x%x => ", oid, debug); | printf("%s: 0x%x => ", oid, debug); | ||||
if (sysctlbyname(oid, NULL, NULL, &ndebug, sizeof(ndebug)) < 0) | if (sysctlbyname(oid, NULL, NULL, &ndebug, sizeof(ndebug)) < 0) | ||||
err(1, "sysctl-set(%s)", oid); | err(1, "sysctl-set(%s)", oid); | ||||
printf("0x%x", ndebug); | printf("0x%x", ndebug); | ||||
debug = ndebug; | debug = ndebug; | ||||
} else | } else | ||||
printf("%s: 0x%x", oid, debug); | printf("%s: 0x%x", oid, debug); | ||||
sep = "<"; | sep = "<"; | ||||
for (i = 0; i < N(flags); i++) | for (i = 0; i < nitems(flags); i++) | ||||
if (debug & flags[i].bit) { | if (debug & flags[i].bit) { | ||||
printf("%s%s", sep, flags[i].name); | printf("%s%s", sep, flags[i].name); | ||||
sep = ","; | sep = ","; | ||||
} | } | ||||
printf("%s\n", *sep != '<' ? ">" : ""); | printf("%s\n", *sep != '<' ? ">" : ""); | ||||
return 0; | return 0; | ||||
} | } |