4

In the answer by Chili555 for How do I create a system file /etc/modprobe.d/ath9k.conf? it is shown that you can create a config file for a kernel module . Now the question is how do I verify that the options set in that config file have taken effect after sudo modprobe ath9k ?

Specific option that I am trying to check is ps_enable. However, doing the following

$ modinfo ath9k | grep ps_enable
parm:           ps_enable:Enable WLAN PowerSave (int)

only explains what the parameter is and not its current value.

Sergiy Kolodyazhnyy
  • 105,154
  • 20
  • 279
  • 497

1 Answers1

5

TL;DR: Look in /sys/module/ath9k/parameters/ or do cat "$(readlink -f /sys/class/net/wlp2s0/device/driver/)"/module/parameters/<param_name>

Apparently such information is contained within /sys filesystem. According to Gilles's answer on the relevant post, in order to find the driver in use by interface you would execute

readlink /sys/class/net/wlan0/device/driver

which would provide the relative path as in

../../../../bus/pci/drivers/ath5k

In my case due to systemd and predictive interface naming, the interface is named differently and produces

$  readlink /sys/class/net/wlp2s0/device/driver
../../../../bus/pci/drivers/ath9k

The resulting directory path contains subdirectories module/parameters/ where there will be files for each parameter containing their current value. Thus, if I edit the /etc/modprobe/ath9k.conf file and reinsert the module, the result is as follows:

# After editing the conf file to set parameter to 1
$ sudo sh -c 'modprobe -r ath9k ; sleep 3; modprobe ath9k'
$ sudo cat  /sys/class/net/wlp2s0/device/driver/../../../../bus/pci/drivers/ath9k/module/parameters/ps_enable
1
# after editing the file and setting parameter to 0
$ sudo sh -c 'modprobe -r ath9k ; sleep 3; modprobe ath9k'
$ sudo cat  /sys/class/net/wlp2s0/device/driver/../../../../bus/pci/drivers/ath9k/module/parameters/ps_enable
0

The command can be combined as well.

$ cat  "$(readlink -f /sys/class/net/wlp2s0/device/driver/)"/module/parameters/ps_enable
0

Alternative /sys path would also be /sys/modules and probably more preferable if you already know what driver is used by the interface, so you can skip the readlink part. In my specific case

/sys/module/ath9k/parameters/ps_enable

or

/sys/module/ath9k/drivers/pci\:ath9k/module/parameters/

According to sysfs(5) manual, "This subdirectory contains one subdirectory for each module that is loaded into the kernel."


There's also another way to figure out what driver is in use by the interface (if necessary, although the fact that I'm editing conf file for the module means I already know what module the interface uses; but in case you do need that I'll leave it as an alternative). If you do have desktop environment and dbus running, as well as qdbus or dbus-send installed, such information can be queried via Network Manager's dbus interface ( though it requires figuring out the object path of each individual device, and probably would be better written in Python or C )

$ qdbus --system org.freedesktop.NetworkManager /org/freedesktop/NetworkManager/Devices/14 org.freedesktop.NetworkManager.Device.Driver
ath9k
Sergiy Kolodyazhnyy
  • 105,154
  • 20
  • 279
  • 497