From: Eason Lai <eason.lai@mediatek.com>
To: <nbd@nbd.name>, <lorenzo@kernel.org>
Cc: <linux-wireless@vger.kernel.org>,
<linux-mediatek@lists.infradead.org>, <kun.wu@mediatek.com>,
<deren.wu@mediatek.com>, <sean.wang@mediatek.com>,
<quan.zhou@mediatek.com>, <ryder.lee@mediatek.com>,
<leon.yen@mediatek.com>, <litien.chang@mediatek.com>,
<jb.tsai@mediatek.com>, <michael.shih@mediatek.com>,
<eason.lai@mediatek.com>
Subject: [PATCH v1] wifi: mt76: mt792x: Add MTK OUI support for wpa supplicant
Date: Fri, 30 Oct 2026 11:17:58 +0800 [thread overview]
Message-ID: <20261030031758.3397910-1-eason.lai@mediatek.com> (raw)
From: Michael Shih <michael.shih@mediatek.com>
Implement MediaTek OUI vendor command in the mt76 driver by defining a
wiphy_vendor_command table with a GET_CHIP_INFO sub-command handler.
Signed-off-by: Michael Shih <michael.shih@mediatek.com>
---
drivers/net/wireless/mediatek/mt76/Makefile | 2 +-
drivers/net/wireless/mediatek/mt76/mt792x.h | 1 +
.../net/wireless/mediatek/mt76/mt792x_core.c | 2 +
.../wireless/mediatek/mt76/mt792x_vendor.c | 76 +++++++++++++++++++
.../wireless/mediatek/mt76/mt792x_vendor.h | 36 +++++++++
5 files changed, 116 insertions(+), 1 deletion(-)
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/Makefile b/drivers/net/wireless/mediatek/mt76/Makefile
index cacdd2b13d05..90bf68f25cfd 100644
--- a/drivers/net/wireless/mediatek/mt76/Makefile
+++ b/drivers/net/wireless/mediatek/mt76/Makefile
@@ -38,7 +38,7 @@ mt76x02-usb-y := mt76x02_usb_mcu.o mt76x02_usb_core.o
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_debugfs.o mt792x_dma.o mt792x_vendor.o
mt792x-lib-$(CONFIG_ACPI) += mt792x_acpi_sar.o
mt792x-usb-y := mt792x_usb.o
diff --git a/drivers/net/wireless/mediatek/mt76/mt792x.h b/drivers/net/wireless/mediatek/mt76/mt792x.h
index a7d71e007da0..926e2cadb023 100644
--- a/drivers/net/wireless/mediatek/mt76/mt792x.h
+++ b/drivers/net/wireless/mediatek/mt76/mt792x.h
@@ -538,6 +538,7 @@ 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);
+void mt792x_vendor_register(struct ieee80211_hw *hw);
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 3ce6c6ceac81..eb50548c4d51 100644
--- a/drivers/net/wireless/mediatek/mt76/mt792x_core.c
+++ b/drivers/net/wireless/mediatek/mt76/mt792x_core.c
@@ -854,6 +854,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
reply other threads:[~2026-10-30 3:18 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261030031758.3397910-1-eason.lai@mediatek.com \
--to=eason.lai@mediatek.com \
--cc=deren.wu@mediatek.com \
--cc=jb.tsai@mediatek.com \
--cc=kun.wu@mediatek.com \
--cc=leon.yen@mediatek.com \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-wireless@vger.kernel.org \
--cc=litien.chang@mediatek.com \
--cc=lorenzo@kernel.org \
--cc=michael.shih@mediatek.com \
--cc=nbd@nbd.name \
--cc=quan.zhou@mediatek.com \
--cc=ryder.lee@mediatek.com \
--cc=sean.wang@mediatek.com \
/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