Skip to content

Commit cc25177

Browse files
committed
Add 'driver' connector
Add a new one connector that provide access to the HW via driver debugging interface. In fact this is a class of connectors, where only one of them is actually build depending on a target operation system. Such per-OS approach was selected since OSs usually have too different debug interface and keeping them in a signle source file with a lot of ifdefs is senseless. So, one source file per-OS and build only one of them. But each such source file should use common 'con_driver' descriptor to simplify (avoid ifdefs) generic utility code. At the moment only Linux ath9k and ath10k drivers are supported (via their debugfs raw register access interfaces). All other Linux drivers as well as xBSD drivers do not have any suitable direct HW access interface. Accessing hardware via the debugfs is deadly slow, but anyway it faster then rebuild the kernel in case if you have builtin driver debugfs support, but have no '/dev/mem' I/O memory access interface (e.g. on latest OpenWrt builds).
1 parent f5a2b2b commit cc25177

File tree

4 files changed

+385
-3
lines changed

4 files changed

+385
-3
lines changed

Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,22 @@ DEP=$(OBJ:%.o=%.d)
1919

2020
DEFS=
2121

22+
OS?=$(shell uname -s)
2223
HAVE_LIBPCIACCESS=$(shell pkg-config pciaccess && echo y || echo n)
2324

25+
CONFIG_CON_DRIVER?=$(if $(filter Linux,$(OS)),y)
2426
CONFIG_CON_PCI?=$(HAVE_LIBPCIACCESS)
2527
CONFIG_CON_MEM?=y
2628
CONFIG_I_KNOW_WHAT_I_AM_DOING?=n
2729

30+
ifeq ($(CONFIG_CON_DRIVER),y)
31+
ifeq ($(OS),Linux)
32+
DEFS+=-DCONFIG_CON_DRIVER
33+
OBJ+=con_driver_linux.o
34+
else
35+
$(error Driver connector building was requested, but there are no driver access support for OS $(OS))
36+
endif
37+
endif
2838
ifeq ($(CONFIG_CON_PCI),y)
2939
DEFS+=-DCONFIG_CON_PCI
3040
OBJ+=con_pci.o

atheepmgr.c

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -642,10 +642,17 @@ static const struct action {
642642
#define CON_USAGE_PCI ""
643643
#define CON_OPTSTR_PCI ""
644644
#endif
645+
#if defined(CONFIG_CON_DRIVER)
646+
#define CON_USAGE_DRIVER " | -D <dev>"
647+
#define CON_OPTSTR_DRIVER "D:"
648+
#else
649+
#define CON_USAGE_DRIVER ""
650+
#define CON_OPTSTR_DRIVER ""
651+
#endif
645652

646-
#define CON_OPTSTR "F:" CON_OPTSTR_MEM CON_OPTSTR_PCI
647-
#if defined(CONFIG_CON_MEM) || defined(CONFIG_CON_PCI)
648-
#define CON_USAGE "{" CON_USAGE_FILE CON_USAGE_MEM CON_USAGE_PCI "}"
653+
#define CON_OPTSTR "F:" CON_OPTSTR_MEM CON_OPTSTR_PCI CON_OPTSTR_DRIVER
654+
#if defined(CONFIG_CON_MEM) || defined(CONFIG_CON_PCI) || defined(CONFIG_CON_DRIVER)
655+
#define CON_USAGE "{" CON_USAGE_FILE CON_USAGE_MEM CON_USAGE_PCI CON_USAGE_DRIVER "}"
649656
#else
650657
#define CON_USAGE CON_USAGE_FILE
651658
#endif
@@ -778,6 +785,13 @@ static void usage(struct atheepmgr *aem, char *name)
778785
" utility. If <domain> is omitted then domain 0 will be used.\n"
779786
" If <func> is omitted then first available function will be\n"
780787
" used.\n"
788+
#endif
789+
#if defined(CONFIG_CON_DRIVER)
790+
" -D <dev> Use driver debug interface to interact with <dev> card.\n"
791+
#if defined(__linux__)
792+
" <dev> could be specified as a cfg80211 phy (e.g. phy0, phy1)\n"
793+
" or as a network device/interface (e.g. wlan0, wlan1)\n"
794+
#endif
781795
#endif
782796
" -t <eepmap> Override EEPROM map type (see below), this option is required\n"
783797
" for connectors, without PnP (map type autodetection) support.\n"
@@ -903,6 +917,12 @@ int main(int argc, char *argv[])
903917
aem->con = &con_pci;
904918
con_arg = optarg;
905919
break;
920+
#endif
921+
#if defined(CONFIG_CON_DRIVER)
922+
case 'D':
923+
aem->con = &con_driver;
924+
con_arg = optarg;
925+
break;
906926
#endif
907927
case 't':
908928
user_eepmap = eepmap_find_by_name(optarg);

atheepmgr.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ struct atheepmgr {
275275
};
276276

277277
extern const struct connector con_file;
278+
extern const struct connector con_driver;
278279
extern const struct connector con_mem;
279280
extern const struct connector con_pci;
280281
extern const struct connector con_stub;

0 commit comments

Comments
 (0)