From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.linux.dev
Cc: James Prestwood <prestwoj@gmail.com>
Subject: [PATCH 2/7] wiphy: allow for user-defined driver flags
Date: Thu, 15 Jun 2023 12:24:10 -0700 [thread overview]
Message-ID: <20230615192415.1718516-2-prestwoj@gmail.com> (raw)
In-Reply-To: <20230615192415.1718516-1-prestwoj@gmail.com>
The driver_infos list in wiphy.c is hard coded and, naturally,
not configurable from a user perspective. As drivers are updated
or added users may be left with their system being broken until the
driver is added, IWD released, and packaged.
This adds the ability to define driver flags inside main.conf under
the "DriverFlags" group. Keys in this group correspond to values in
enum driver_flag and values are a list of glob matches for specific
drivers:
[DriverFlags]
DefaultInterface=rtl81*,rtl87*,rtl88*,rtw_*,brcmfmac,bcmsdh_sdmmc
ForcePae=buggy_pae_*
---
src/wiphy.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/src/wiphy.c b/src/wiphy.c
index ca8a4958..6f8f6826 100644
--- a/src/wiphy.c
+++ b/src/wiphy.c
@@ -73,6 +73,11 @@ enum driver_flag {
FORCE_PAE = 0x2,
};
+struct driver_flag_name {
+ const char *name;
+ enum driver_flag flag;
+};
+
struct driver_info {
const char *prefix;
unsigned int flags;
@@ -93,6 +98,11 @@ static const struct driver_info driver_infos[] = {
{ "bcmsdh_sdmmc", DEFAULT_IF },
};
+static const struct driver_flag_name driver_flag_names[] = {
+ { "DefaultInterface", DEFAULT_IF },
+ { "ForcePae", FORCE_PAE },
+};
+
struct wiphy {
uint32_t id;
char name[20];
@@ -1868,6 +1878,9 @@ static bool wiphy_get_driver_name(struct wiphy *wiphy)
char driver_path[256];
ssize_t len;
unsigned int i;
+ unsigned int j;
+ const struct l_settings *config = iwd_get_config();
+ char **flag_list;
driver_link = l_strdup_printf("/sys/class/ieee80211/%s/device/driver",
wiphy->name);
@@ -1885,6 +1898,24 @@ static bool wiphy_get_driver_name(struct wiphy *wiphy)
if (!fnmatch(driver_infos[i].prefix, wiphy->driver_str, 0))
wiphy->driver_flags |= driver_infos[i].flags;
+ /* Check for any user-defined driver flags */
+ if (!l_settings_has_group(config, "DriverFlags"))
+ return true;
+
+ for (i = 0; i < L_ARRAY_SIZE(driver_flag_names); i++) {
+ flag_list = l_settings_get_string_list(config, "DriverFlags",
+ driver_flag_names[i].name, ',');
+ if (!flag_list)
+ continue;
+
+ for (j = 0; flag_list[j]; j++)
+ if (!fnmatch(flag_list[j], wiphy->driver_str, 0))
+ wiphy->driver_flags |=
+ driver_flag_names[i].flag;
+
+ l_strv_free(flag_list);
+ }
+
return true;
}
--
2.25.1
next prev parent reply other threads:[~2023-06-15 19:24 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-15 19:24 [PATCH 1/7] wiphy: store driver flags directly in wiphy object James Prestwood
2023-06-15 19:24 ` James Prestwood [this message]
2023-06-18 19:03 ` [PATCH 2/7] wiphy: allow for user-defined driver flags Denis Kenzior
2023-06-15 19:24 ` [PATCH 3/7] doc: document [DriverFlags] group settings James Prestwood
2023-06-15 19:24 ` [PATCH 4/7] wiphy: add [DriverFlags].PowerSaveDisable flag James Prestwood
2023-06-18 19:07 ` Denis Kenzior
2023-06-19 14:49 ` James Prestwood
2023-06-15 19:24 ` [PATCH 5/7] netdev: disable power save if required James Prestwood
2023-06-18 19:11 ` Denis Kenzior
2023-06-19 14:54 ` James Prestwood
2023-06-15 19:24 ` [PATCH 6/7] wiphy: print driver flags on startup James Prestwood
2023-06-15 19:24 ` [PATCH 7/7] doc: Document [DriverFlags].PowerSaveDisable James Prestwood
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230615192415.1718516-2-prestwoj@gmail.com \
--to=prestwoj@gmail.com \
--cc=iwd@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox