[PATCH v3] wifi: mt76: mt7928: Add MTK OUI support for nl80211 (ALOS support for wpa_supplicant to get MTK OUI)
Michael Shih
michael.shih at mediatek.com
Tue Nov 17 17:17:58 PST 2026
Customer request MTK to support OUI for wpa supplicant.
Signed-off-by: Michael Shih <michael.shih at mediatek.com>
---
v2: Added "CONFIG_MT792x_VENDOR_CMD" for Kconfig build flag
v3: Fix commit message.
---
drivers/net/wireless/mediatek/mt76/Kconfig | 12 +++
drivers/net/wireless/mediatek/mt76/Makefile | 1 +
drivers/net/wireless/mediatek/mt76/mt792x.h | 5 ++
.../net/wireless/mediatek/mt76/mt792x_core.c | 2 +
.../wireless/mediatek/mt76/mt792x_vendor.c | 76 +++++++++++++++++++
.../wireless/mediatek/mt76/mt792x_vendor.h | 36 +++++++++
6 files changed, 132 insertions(+)
create mode 100644 drivers/net/wireless/mediatek/mt76/mt792x_vendor.c
create mode 100644 drivers/net/wireless/mediatek/mt76/mt792x_vendor.h
diff --git a/drivers/net/wireless/mediatek/mt76/Kconfig b/drivers/net/wireless/mediatek/mt76/Kconfig
index a4ece38f938d..24faee348d8d 100644
--- a/drivers/net/wireless/mediatek/mt76/Kconfig
+++ b/drivers/net/wireless/mediatek/mt76/Kconfig
@@ -33,6 +33,18 @@ config MT792x_LIB
tristate
select MT76_CONNAC_LIB
+config MT792x_VENDOR_CMD
+ bool "MediaTek MT792x nl80211 vendor command support"
+ depends on MT792x_LIB
+ default y
+ help
+ Advertise the MediaTek OUI (0x000CE7) nl80211 vendor command
+ interface, allowing user space (e.g. wpa_supplicant) to query
+ chip information. This is a read-only query interface and has no
+ effect unless a matching vendor command is issued from user space.
+
+ Say N to disable the interface entirely.
+
config MT792x_USB
tristate
select MT76_USB
diff --git a/drivers/net/wireless/mediatek/mt76/Makefile b/drivers/net/wireless/mediatek/mt76/Makefile
index cacdd2b13d05..e7e75ab66fdd 100644
--- a/drivers/net/wireless/mediatek/mt76/Makefile
+++ b/drivers/net/wireless/mediatek/mt76/Makefile
@@ -40,6 +40,7 @@ mt76-connac-lib-y := mt76_connac_mcu.o mt76_connac_mac.o mt76_connac3_mac.o
mt792x-lib-y := mt792x_core.o mt792x_mac.o mt792x_trace.o \
mt792x_debugfs.o mt792x_dma.o
mt792x-lib-$(CONFIG_ACPI) += mt792x_acpi_sar.o
+mt792x-lib-$(CONFIG_MT792x_VENDOR_CMD) += mt792x_vendor.o
mt792x-usb-y := mt792x_usb.o
obj-$(CONFIG_MT76x0_COMMON) += mt76x0/
diff --git a/drivers/net/wireless/mediatek/mt76/mt792x.h b/drivers/net/wireless/mediatek/mt76/mt792x.h
index 4753ec20fe0c..d0b985d7951c 100644
--- a/drivers/net/wireless/mediatek/mt76/mt792x.h
+++ b/drivers/net/wireless/mediatek/mt76/mt792x.h
@@ -558,6 +558,11 @@ int mt792x_pm_stats(struct seq_file *s, void *data);
int mt792x_pm_idle_timeout_set(void *data, u64 val);
int mt792x_pm_idle_timeout_get(void *data, u64 *val);
int mt792x_init_wiphy(struct ieee80211_hw *hw);
+#if IS_ENABLED(CONFIG_MT792x_VENDOR_CMD)
+void mt792x_vendor_register(struct ieee80211_hw *hw);
+#else
+static inline void mt792x_vendor_register(struct ieee80211_hw *hw) {}
+#endif
struct ieee80211_ops *
mt792x_get_mac80211_ops(struct device *dev,
const struct ieee80211_ops *mac80211_ops,
diff --git a/drivers/net/wireless/mediatek/mt76/mt792x_core.c b/drivers/net/wireless/mediatek/mt76/mt792x_core.c
index 1965e9de7099..b6183b2f5db0 100644
--- a/drivers/net/wireless/mediatek/mt76/mt792x_core.c
+++ b/drivers/net/wireless/mediatek/mt76/mt792x_core.c
@@ -876,6 +876,8 @@ int mt792x_init_wiphy(struct ieee80211_hw *hw)
hw->max_tx_fragments = 4;
+ mt792x_vendor_register(hw);
+
return 0;
}
EXPORT_SYMBOL_GPL(mt792x_init_wiphy);
diff --git a/drivers/net/wireless/mediatek/mt76/mt792x_vendor.c b/drivers/net/wireless/mediatek/mt76/mt792x_vendor.c
new file mode 100644
index 000000000000..d1f1560d8641
--- /dev/null
+++ b/drivers/net/wireless/mediatek/mt76/mt792x_vendor.c
@@ -0,0 +1,76 @@
+// SPDX-License-Identifier: ISC
+/* Copyright (C) 2026 MediaTek Inc. */
+
+#include <linux/module.h>
+#include <net/netlink.h>
+#include <net/cfg80211.h>
+
+#include "mt792x.h"
+#include "mt792x_vendor.h"
+
+static const struct nla_policy
+mtk_vendor_chip_info_policy[MTK_VENDOR_ATTR_CHIP_INFO_MAX + 1] = {
+ [MTK_VENDOR_ATTR_CHIP_INFO_ID] = { .type = NLA_U32 },
+ [MTK_VENDOR_ATTR_CHIP_INFO_OUI] = { .type = NLA_U32 },
+};
+
+static int
+mt792x_vendor_get_chip_info(struct wiphy *wiphy, struct wireless_dev *wdev,
+ const void *data, int data_len)
+{
+ struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
+ struct mt792x_phy *phy = mt792x_hw_phy(hw);
+ struct sk_buff *skb;
+
+ /* reply payload: two u32 attributes */
+ skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy,
+ 2 * (nla_total_size(sizeof(u32))));
+ if (!skb)
+ return -ENOMEM;
+
+ if (nla_put_u32(skb, MTK_VENDOR_ATTR_CHIP_INFO_ID,
+ phy->dev->mt76.rev) ||
+ nla_put_u32(skb, MTK_VENDOR_ATTR_CHIP_INFO_OUI,
+ MTK_NL80211_VENDOR_ID)) {
+ kfree_skb(skb);
+ return -ENOBUFS;
+ }
+
+ return cfg80211_vendor_cmd_reply(skb);
+}
+
+static const struct wiphy_vendor_command mt792x_vendor_commands[] = {
+ {
+ .info = {
+ .vendor_id = MTK_NL80211_VENDOR_ID,
+ .subcmd = MTK_NL80211_VENDOR_SUBCMD_GET_CHIP_INFO,
+ },
+ .flags = WIPHY_VENDOR_CMD_NEED_WDEV |
+ WIPHY_VENDOR_CMD_NEED_NETDEV,
+ .doit = mt792x_vendor_get_chip_info,
+ .policy = mtk_vendor_chip_info_policy,
+ .maxattr = MTK_VENDOR_ATTR_CHIP_INFO_MAX,
+ },
+};
+
+static const struct nl80211_vendor_cmd_info mt792x_vendor_events[] = {
+ [MTK_NL80211_VENDOR_EVENT_CHIP_INFO] = {
+ .vendor_id = MTK_NL80211_VENDOR_ID,
+ .subcmd = MTK_NL80211_VENDOR_SUBCMD_GET_CHIP_INFO,
+ },
+};
+
+void mt792x_vendor_register(struct ieee80211_hw *hw)
+{
+ struct wiphy *wiphy = hw->wiphy;
+
+ wiphy->vendor_commands = mt792x_vendor_commands;
+ wiphy->n_vendor_commands = ARRAY_SIZE(mt792x_vendor_commands);
+ wiphy->vendor_events = mt792x_vendor_events;
+ wiphy->n_vendor_events = ARRAY_SIZE(mt792x_vendor_events);
+
+ dev_info(wiphy->dev.parent,
+ "mt792x: registered %u vendor cmd(s), OUI=0x%06x\n",
+ wiphy->n_vendor_commands, MTK_NL80211_VENDOR_ID);
+}
+EXPORT_SYMBOL_GPL(mt792x_vendor_register);
diff --git a/drivers/net/wireless/mediatek/mt76/mt792x_vendor.h b/drivers/net/wireless/mediatek/mt76/mt792x_vendor.h
new file mode 100644
index 000000000000..ab728cfd0912
--- /dev/null
+++ b/drivers/net/wireless/mediatek/mt76/mt792x_vendor.h
@@ -0,0 +1,36 @@
+/* SPDX-License-Identifier: ISC */
+/* Copyright (C) 2026 MediaTek Inc. */
+
+#ifndef __MT792X_VENDOR_H
+#define __MT792X_VENDOR_H
+
+/* MediaTek nl80211 vendor OUI (24-bit OUI placed in the low 24 bits).
+ * This is the value advertised to user space (e.g. wpa_supplicant's
+ * wiphy_info_handler) via NL80211_ATTR_VENDOR_DATA in the GET_WIPHY reply.
+ */
+#define MTK_NL80211_VENDOR_ID 0x000ce7
+
+/* vendor sub-commands (defined by the vendor) */
+enum mtk_nl80211_vendor_subcmds {
+ MTK_NL80211_VENDOR_SUBCMD_UNSPEC = 0,
+ MTK_NL80211_VENDOR_SUBCMD_GET_CHIP_INFO = 1,
+};
+
+/* vendor event indexes (used by cfg80211_vendor_event*) */
+enum mtk_nl80211_vendor_events {
+ MTK_NL80211_VENDOR_EVENT_CHIP_INFO = 0,
+};
+
+/* attributes carried in the GET_CHIP_INFO vendor command reply */
+enum mtk_vendor_attr_chip_info {
+ MTK_VENDOR_ATTR_CHIP_INFO_INVALID = 0,
+ MTK_VENDOR_ATTR_CHIP_INFO_ID = 1,
+ MTK_VENDOR_ATTR_CHIP_INFO_OUI = 2,
+
+ /* keep last */
+ __MTK_VENDOR_ATTR_CHIP_INFO_MAX,
+ MTK_VENDOR_ATTR_CHIP_INFO_MAX =
+ __MTK_VENDOR_ATTR_CHIP_INFO_MAX - 1,
+};
+
+#endif /* __MT792X_VENDOR_H */
--
2.45.2
More information about the Linux-mediatek
mailing list