linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jerome Pouiller <Jerome.Pouiller@silabs.com>
To: "devel@driverdev.osuosl.org" <devel@driverdev.osuosl.org>,
	"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Kalle Valo <kvalo@codeaurora.org>,
	"David S . Miller" <davem@davemloft.net>,
	David Le Goff <David.Legoff@silabs.com>,
	Jerome Pouiller <Jerome.Pouiller@silabs.com>
Subject: [PATCH 10/20] staging: wfx: instantiate mac80211 data
Date: Thu, 19 Sep 2019 10:52:39 +0000	[thread overview]
Message-ID: <20190919105153.15285-11-Jerome.Pouiller@silabs.com> (raw)
In-Reply-To: <20190919105153.15285-1-Jerome.Pouiller@silabs.com>

From: Jérôme Pouiller <jerome.pouiller@silabs.com>

Allocate a struct ieee80211_hw but do not yet register it.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
---
 drivers/staging/wfx/Makefile |  1 +
 drivers/staging/wfx/debug.c  | 12 ++++++++++
 drivers/staging/wfx/debug.h  | 15 ++++++++++++
 drivers/staging/wfx/main.c   | 41 ++++++++++++++++++++++++++++++--
 drivers/staging/wfx/sta.c    | 46 ++++++++++++++++++++++++++++++++++++
 drivers/staging/wfx/sta.h    | 24 +++++++++++++++++++
 drivers/staging/wfx/wfx.h    |  8 +++++++
 7 files changed, 145 insertions(+), 2 deletions(-)
 create mode 100644 drivers/staging/wfx/debug.h
 create mode 100644 drivers/staging/wfx/sta.c
 create mode 100644 drivers/staging/wfx/sta.h

diff --git a/drivers/staging/wfx/Makefile b/drivers/staging/wfx/Makefile
index 35670b86c64f..2896a2127c88 100644
--- a/drivers/staging/wfx/Makefile
+++ b/drivers/staging/wfx/Makefile
@@ -9,6 +9,7 @@ wfx-y := \
 	fwio.o \
 	hif_rx.o \
 	main.o \
+	sta.o \
 	debug.o
 wfx-$(CONFIG_SPI) += bus_spi.o
 wfx-$(subst m,y,$(CONFIG_MMC)) += bus_sdio.o
diff --git a/drivers/staging/wfx/debug.c b/drivers/staging/wfx/debug.c
index bf44c944640d..f28c94d8de89 100644
--- a/drivers/staging/wfx/debug.c
+++ b/drivers/staging/wfx/debug.c
@@ -5,6 +5,18 @@
  * Copyright (c) 2017-2019, Silicon Laboratories, Inc.
  * Copyright (c) 2010, ST-Ericsson
  */
+#include <linux/debugfs.h>
+
+#include "wfx.h"
 
 #define CREATE_TRACE_POINTS
 #include "traces.h"
+
+int wfx_debug_init(struct wfx_dev *wdev)
+{
+	struct dentry *d;
+
+	d = debugfs_create_dir("wfx", wdev->hw->wiphy->debugfsdir);
+
+	return 0;
+}
diff --git a/drivers/staging/wfx/debug.h b/drivers/staging/wfx/debug.h
new file mode 100644
index 000000000000..8bfba1a9fa20
--- /dev/null
+++ b/drivers/staging/wfx/debug.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Debugfs interface.
+ *
+ * Copyright (c) 2017-2019, Silicon Laboratories, Inc.
+ * Copyright (c) 2011, ST-Ericsson
+ */
+#ifndef WFX_DEBUG_H
+#define WFX_DEBUG_H
+
+struct wfx_dev;
+
+int wfx_debug_init(struct wfx_dev *wdev);
+
+#endif /* WFX_DEBUG_H */
diff --git a/drivers/staging/wfx/main.c b/drivers/staging/wfx/main.c
index 5e7e7225f068..ca0ca873bd7d 100644
--- a/drivers/staging/wfx/main.c
+++ b/drivers/staging/wfx/main.c
@@ -25,6 +25,9 @@
 #include "hwio.h"
 #include "bus.h"
 #include "bh.h"
+#include "sta.h"
+#include "debug.h"
+#include "hif_api_cmd.h"
 #include "wfx_version.h"
 
 MODULE_DESCRIPTION("Silicon Labs 802.11 Wireless LAN driver for WFx");
@@ -36,6 +39,13 @@ static int gpio_wakeup = -2;
 module_param(gpio_wakeup, int, 0644);
 MODULE_PARM_DESC(gpio_wakeup, "gpio number for wakeup. -1 for none.");
 
+static const struct ieee80211_ops wfx_ops = {
+	.start			= wfx_start,
+	.stop			= wfx_stop,
+	.add_interface		= wfx_add_interface,
+	.remove_interface	= wfx_remove_interface,
+};
+
 bool wfx_api_older_than(struct wfx_dev *wdev, int major, int minor)
 {
 	if (wdev->hw_caps.api_version_major < major)
@@ -79,11 +89,26 @@ struct wfx_dev *wfx_init_common(struct device *dev,
 				const struct hwbus_ops *hwbus_ops,
 				void *hwbus_priv)
 {
+	struct ieee80211_hw *hw;
 	struct wfx_dev *wdev;
 
-	wdev = devm_kmalloc(dev, sizeof(*wdev), GFP_KERNEL);
-	if (!wdev)
+	hw = ieee80211_alloc_hw(sizeof(struct wfx_dev), &wfx_ops);
+	if (!hw)
 		return NULL;
+
+	SET_IEEE80211_DEV(hw, dev);
+
+	hw->vif_data_size = sizeof(struct wfx_vif);
+	hw->sta_data_size = sizeof(struct wfx_sta_priv);
+	hw->queues = 4;
+	hw->max_rates = 8;
+	hw->max_rate_tries = 15;
+	hw->extra_tx_headroom = sizeof(struct hif_sl_msg_hdr) + sizeof(struct hif_msg)
+				+ sizeof(struct hif_req_tx)
+				+ 4 /* alignment */ + 8 /* TKIP IV */;
+
+	wdev = hw->priv;
+	wdev->hw = hw;
 	wdev->dev = dev;
 	wdev->hwbus_ops = hwbus_ops;
 	wdev->hwbus_priv = hwbus_priv;
@@ -96,6 +121,7 @@ struct wfx_dev *wfx_init_common(struct device *dev,
 
 void wfx_free_common(struct wfx_dev *wdev)
 {
+	ieee80211_free_hw(wdev->hw);
 }
 
 int wfx_probe(struct wfx_dev *wdev)
@@ -127,6 +153,11 @@ int wfx_probe(struct wfx_dev *wdev)
 		 wdev->hw_caps.firmware_build, wdev->hw_caps.firmware_label,
 		 wdev->hw_caps.api_version_major, wdev->hw_caps.api_version_minor,
 		 wdev->keyset, *((u32 *) &wdev->hw_caps.capabilities));
+	snprintf(wdev->hw->wiphy->fw_version, sizeof(wdev->hw->wiphy->fw_version),
+		 "%d.%d.%d",
+		 wdev->hw_caps.firmware_major,
+		 wdev->hw_caps.firmware_minor,
+		 wdev->hw_caps.firmware_build);
 
 	if (wfx_api_older_than(wdev, 1, 0)) {
 		dev_err(wdev->dev, "unsupported firmware API version (expect 1 while firmware returns %d)\n",
@@ -150,8 +181,14 @@ int wfx_probe(struct wfx_dev *wdev)
 		dev_info(wdev->dev, "MAC address %d: %pM\n", i, wdev->addresses[i].addr);
 	}
 
+	err = wfx_debug_init(wdev);
+	if (err)
+		goto err2;
+
 	return 0;
 
+err2:
+	ieee80211_free_hw(wdev->hw);
 err1:
 	wfx_bh_unregister(wdev);
 	return err;
diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c
new file mode 100644
index 000000000000..fe3ff6536a87
--- /dev/null
+++ b/drivers/staging/wfx/sta.c
@@ -0,0 +1,46 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Implementation of mac80211 API.
+ *
+ * Copyright (c) 2017-2019, Silicon Laboratories, Inc.
+ * Copyright (c) 2010, ST-Ericsson
+ */
+#include <net/mac80211.h>
+
+#include "sta.h"
+#include "wfx.h"
+
+int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
+{
+	int i;
+	struct wfx_dev *wdev = hw->priv;
+	struct wfx_vif *wvif = (struct wfx_vif *) vif->drv_priv;
+
+	for (i = 0; i < ARRAY_SIZE(wdev->vif); i++) {
+		if (!wdev->vif[i]) {
+			wdev->vif[i] = vif;
+			wvif->id = i;
+			break;
+		}
+	}
+	if (i == ARRAY_SIZE(wdev->vif))
+		return -EOPNOTSUPP;
+	wvif->vif = vif;
+	wvif->wdev = wdev;
+
+	return 0;
+}
+
+void wfx_remove_interface(struct ieee80211_hw *hw,
+			  struct ieee80211_vif *vif)
+{
+}
+
+int wfx_start(struct ieee80211_hw *hw)
+{
+	return 0;
+}
+
+void wfx_stop(struct ieee80211_hw *hw)
+{
+}
diff --git a/drivers/staging/wfx/sta.h b/drivers/staging/wfx/sta.h
new file mode 100644
index 000000000000..f17b4d1511d7
--- /dev/null
+++ b/drivers/staging/wfx/sta.h
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Implementation of mac80211 API.
+ *
+ * Copyright (c) 2017-2019, Silicon Laboratories, Inc.
+ * Copyright (c) 2010, ST-Ericsson
+ */
+#ifndef WFX_STA_H
+#define WFX_STA_H
+
+#include <net/mac80211.h>
+
+struct wfx_sta_priv {
+	int link_id;
+	int vif_id;
+};
+
+// mac80211 interface
+int wfx_start(struct ieee80211_hw *hw);
+void wfx_stop(struct ieee80211_hw *hw);
+int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
+void wfx_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif);
+
+#endif /* WFX_STA_H */
diff --git a/drivers/staging/wfx/wfx.h b/drivers/staging/wfx/wfx.h
index f5f9a337d828..a7e571e0da30 100644
--- a/drivers/staging/wfx/wfx.h
+++ b/drivers/staging/wfx/wfx.h
@@ -22,6 +22,8 @@ struct hwbus_ops;
 struct wfx_dev {
 	struct wfx_platform_data pdata;
 	struct device		*dev;
+	struct ieee80211_hw	*hw;
+	struct ieee80211_vif	*vif[2];
 	struct mac_address	addresses[2];
 	const struct hwbus_ops	*hwbus_ops;
 	void			*hwbus_priv;
@@ -32,4 +34,10 @@ struct wfx_dev {
 	struct wfx_hif		hif;
 };
 
+struct wfx_vif {
+	struct wfx_dev		*wdev;
+	struct ieee80211_vif	*vif;
+	int			id;
+};
+
 #endif /* WFX_H */
-- 
2.20.1

  parent reply	other threads:[~2019-09-19 10:52 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-19 10:52 [PATCH 00/20] Add support for Silicon Labs WiFi chip WF200 and further Jerome Pouiller
2019-09-19 10:52 ` [PATCH 01/20] staging: wfx: add infrastructure for new driver Jerome Pouiller
2019-09-19 10:52 ` [PATCH 02/20] staging: wfx: add support for I/O access Jerome Pouiller
2019-09-19 16:34   ` Andrew Lunn
2019-09-19 16:40     ` Greg Kroah-Hartman
2019-10-02 16:29     ` Jerome Pouiller
2019-10-02 16:42       ` Greg Kroah-Hartman
2019-10-02 16:51         ` Jerome Pouiller
2019-09-19 10:52 ` [PATCH 03/20] staging: wfx: add I/O API Jerome Pouiller
2019-09-19 10:52 ` [PATCH 04/20] staging: wfx: add tracepoints for I/O access Jerome Pouiller
2019-09-19 10:52 ` [PATCH 05/20] staging: wfx: load firmware Jerome Pouiller
2019-09-19 10:52 ` [PATCH 06/20] staging: wfx: import HIF API headers Jerome Pouiller
2019-09-19 10:52 ` [PATCH 07/20] staging: wfx: add IRQ handling Jerome Pouiller
2019-09-19 10:52 ` [PATCH 08/20] staging: wfx: add tracepoints for HIF Jerome Pouiller
2019-09-19 10:52 ` [PATCH 09/20] staging: wfx: add support for start-up indication Jerome Pouiller
2019-09-19 10:52 ` Jerome Pouiller [this message]
2019-09-19 10:52 ` [PATCH 11/20] staging: wfx: allow to send commands to chip Jerome Pouiller
2019-09-19 10:52 ` [PATCH 12/20] staging: wfx: add HIF commands helpers Jerome Pouiller
2019-09-19 10:52 ` [PATCH 13/20] staging: wfx: introduce "secure link" Jerome Pouiller
2019-09-19 10:52 ` [PATCH 14/20] staging: wfx: setup initial chip configuration Jerome Pouiller
2019-09-19 10:52 ` [PATCH 16/20] staging: wfx: allow to send 802.11 frames Jerome Pouiller
2019-09-19 10:52 ` [PATCH 15/20] staging: wfx: add debug files and trace debug events Jerome Pouiller
2019-09-19 10:52 ` [PATCH 17/20] staging: wfx: allow to receive 802.11 frames Jerome Pouiller
2019-09-19 10:52 ` [PATCH 18/20] staging: wfx: allow to scan networks Jerome Pouiller
2019-09-19 10:52 ` [PATCH 19/20] staging: wfx: implement 802.11 key handling Jerome Pouiller
2019-09-19 10:52 ` [PATCH 20/20] staging: wfx: implement the rest of mac80211 API Jerome Pouiller
2019-09-19 11:25 ` [PATCH 00/20] Add support for Silicon Labs WiFi chip WF200 and further Greg Kroah-Hartman
2019-09-19 11:39   ` Arend Van Spriel

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=20190919105153.15285-11-Jerome.Pouiller@silabs.com \
    --to=jerome.pouiller@silabs.com \
    --cc=David.Legoff@silabs.com \
    --cc=davem@davemloft.net \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kvalo@codeaurora.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).