Skip to contentSkip to conversation

Add new mac80211 driver mwlwifi.

PATCH Superseded David Lin 2 participants 7 messages Jul 9, 2015 – Oct 5, 2015 Networking drivers (wireless)

v6 of 9 Superseded Latest is v9 →

lore
Share & tools
lore

David Lin

author
#0 lore raw

PATCH v6 1/1 Add new mac80211 driver mwlwifi.

The Linux driver for WRT1900AC. The work was initially developed as part of openwrt effort and maintained on https://github.com/kaloz/mwlwifi.

This is still work in progress, with 8864 chipset more mature and tested, while 8897 for the similar use case is added recently.

---
 MAINTAINERS                             |    6 +
 drivers/net/wireless/Kconfig            |    1 +
 drivers/net/wireless/Makefile           |    2 +
 drivers/net/wireless/mwlwifi/Kconfig    |   23 +
 drivers/net/wireless/mwlwifi/Makefile   |   11 +
 drivers/net/wireless/mwlwifi/dev.h      |  436 ++++++
 drivers/net/wireless/mwlwifi/fwcmd.c    | 2211 +++++++++++++++++++++++++++++++
 drivers/net/wireless/mwlwifi/fwcmd.h    |  175 +++
 drivers/net/wireless/mwlwifi/fwdl.c     |  182 +++
 drivers/net/wireless/mwlwifi/fwdl.h     |   25 +
 drivers/net/wireless/mwlwifi/hostcmd.h  |  753 +++++++++++
 drivers/net/wireless/mwlwifi/isr.c      |  146 ++
 drivers/net/wireless/mwlwifi/isr.h      |   26 +
 drivers/net/wireless/mwlwifi/mac80211.c |  724 ++++++++++
 drivers/net/wireless/mwlwifi/main.c     |  868 ++++++++++++
 drivers/net/wireless/mwlwifi/rx.c       |  502 +++++++
 drivers/net/wireless/mwlwifi/rx.h       |   25 +
 drivers/net/wireless/mwlwifi/sysadpt.h  |   67 +
 drivers/net/wireless/mwlwifi/tx.c       |  845 ++++++++++++
 drivers/net/wireless/mwlwifi/tx.h       |   28 +
 20 files changed, 7056 insertions(+)
 create mode 100644 drivers/net/wireless/mwlwifi/Kconfig
 create mode 100644 drivers/net/wireless/mwlwifi/Makefile
 create mode 100644 drivers/net/wireless/mwlwifi/dev.h
 create mode 100644 drivers/net/wireless/mwlwifi/fwcmd.c
 create mode 100644 drivers/net/wireless/mwlwifi/fwcmd.h
 create mode 100644 drivers/net/wireless/mwlwifi/fwdl.c
 create mode 100644 drivers/net/wireless/mwlwifi/fwdl.h
 create mode 100644 drivers/net/wireless/mwlwifi/hostcmd.h
 create mode 100644 drivers/net/wireless/mwlwifi/isr.c
 create mode 100644 drivers/net/wireless/mwlwifi/isr.h
 create mode 100644 drivers/net/wireless/mwlwifi/mac80211.c
 create mode 100644 drivers/net/wireless/mwlwifi/main.c
 create mode 100644 drivers/net/wireless/mwlwifi/rx.c
 create mode 100644 drivers/net/wireless/mwlwifi/rx.h
 create mode 100644 drivers/net/wireless/mwlwifi/sysadpt.h
 create mode 100644 drivers/net/wireless/mwlwifi/tx.c
 create mode 100644 drivers/net/wireless/mwlwifi/tx.h
MAINTAINERS +6 -0
index 5bb0b9e..bbc549e 100644
@@ -6281,6 +6281,12 @@ L:	[email protected]
 S:	Odd Fixes
 F:	drivers/net/wireless/mwl8k.c
 
+MARVELL MWLWIFI WIRELESS DRIVER
+M:	David Lin <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	drivers/net/wireless/mwlwifi/
+
 MARVELL SOC MMC/SD/SDIO CONTROLLER DRIVER
 M:	Nicolas Pitre <[email protected]>
 S:	Odd Fixes
drivers/net/wireless/Kconfig +1 -0
index a63ab2e..1c60845 100644
@@ -284,5 +284,6 @@ source "drivers/net/wireless/zd1211rw/Kconfig"
 source "drivers/net/wireless/mwifiex/Kconfig"
 source "drivers/net/wireless/cw1200/Kconfig"
 source "drivers/net/wireless/rsi/Kconfig"
+source "drivers/net/wireless/mwlwifi/Kconfig"
 
 endif # WLAN
drivers/net/wireless/Makefile +2 -0
index 6b9e729..1fe0f0d 100644
@@ -62,3 +62,5 @@ obj-$(CONFIG_BRCMSMAC)	+= brcm80211/
 
 obj-$(CONFIG_CW1200)	+= cw1200/
 obj-$(CONFIG_RSI_91X)	+= rsi/
+
+obj-$(CONFIG_MWLWIFI)	+= mwlwifi/
drivers/net/wireless/mwlwifi/Kconfig new file +23 -0
new file mode 100644
index 0000000..392a313
@@ -0,0 +1,23 @@
+config MWLWIFI
+	tristate "Marvell Wireless Avastar 88W8864/88W8897 Driver (mac80211 compatible)"
+	depends on PCI && MAC80211
+	select FW_LOADER
+	---help---
+		Select to build the driver supporting the:
+
+		Marvell Wireless Wi-Fi 88W8864 modules
+		Marvell Wireless Wi-Fi 88W8897 modules
+
+		This driver uses the kernel's mac80211 subsystem.
+
+		If you want to compile the driver as a module (= code which can be
+		inserted in and removed from the running kernel whenever you want),
+		say M here and read <file:Documentation/kbuild/modules.txt>.  The
+		module will be called mwlwifi.
+
+		NOTE: Selecting this driver may cause conflict with MWIFIEX driver
+		that also operates on the same part number 88W8897. Users should
+		select either MWIFIEX or MWLWIFI, not both. MWIFIEX is fullmac,
+		supporting more comprehensive client functions for laptops/embedded
+		devices. MWLWIFI is mac80211-based for full AP/Wireless Bridge.
+
drivers/net/wireless/mwlwifi/Makefile new file +11 -0
new file mode 100644
index 0000000..49bd311
@@ -0,0 +1,11 @@
+obj-$(CONFIG_MWLWIFI)	+= mwlwifi.o
+
+mwlwifi-objs		+= main.o
+mwlwifi-objs		+= mac80211.o
+mwlwifi-objs		+= fwdl.o
+mwlwifi-objs		+= fwcmd.o
+mwlwifi-objs		+= tx.o
+mwlwifi-objs		+= rx.o
+mwlwifi-objs		+= isr.o
+
+ccflags-y += -D__CHECK_ENDIAN__
drivers/net/wireless/mwlwifi/dev.h new file +436 -0

436 lines not on this page · raw message

drivers/net/wireless/mwlwifi/fwcmd.c new file +2211 -0

2,211 lines not on this page · raw message

drivers/net/wireless/mwlwifi/fwcmd.h new file +175 -0

175 lines not on this page · raw message

drivers/net/wireless/mwlwifi/fwdl.c new file +182 -0

121 lines not on this page · raw message

drivers/net/wireless/mwlwifi/fwdl.h new file +25 -0
new file mode 100644
index 0000000..b117142

Lines of this file are not shown. View the raw message.

drivers/net/wireless/mwlwifi/hostcmd.h new file +753 -0

753 lines not on this page · raw message

drivers/net/wireless/mwlwifi/isr.c new file +146 -0

146 lines not on this page · raw message

drivers/net/wireless/mwlwifi/isr.h new file +26 -0
new file mode 100644
index 0000000..2598115

Lines of this file are not shown. View the raw message.

drivers/net/wireless/mwlwifi/mac80211.c new file +724 -0

724 lines not on this page · raw message

drivers/net/wireless/mwlwifi/main.c new file +868 -0

868 lines not on this page · raw message

drivers/net/wireless/mwlwifi/rx.c new file +502 -0

502 lines not on this page · raw message

drivers/net/wireless/mwlwifi/rx.h new file +25 -0
new file mode 100644
index 0000000..d32c558

Lines of this file are not shown. View the raw message.

drivers/net/wireless/mwlwifi/sysadpt.h new file +67 -0

67 lines not on this page · raw message

drivers/net/wireless/mwlwifi/tx.c new file +845 -0

845 lines not on this page · raw message

drivers/net/wireless/mwlwifi/tx.h new file +28 -0
new file mode 100644
index 0000000..175437c

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.9.1

Part of the diff is not shown here. View the raw message.

#1 lore raw
Quoted 7 lines · David Lin

The Linux driver for WRT1900AC. The work was initially developed as part of openwrt effort and maintained on https://github.com/kaloz/mwlwifi.

This is still work in progress, with 8864 chipset more mature and tested, while 8897 for the similar use case is added recently.

[...]

Quoted 136 lines
drivers/net/wireless/mwlwifi/main.c new file +136 -0
+static void mwl_reg_notifier(struct wiphy *wiphy,
+			     struct regulatory_request *request)
+{
+#ifdef CONFIG_OF
+	struct ieee80211_hw *hw;
+	struct mwl_priv *priv;
+	struct property *prop;
+	struct property *fcc_prop = NULL;
+	struct property *etsi_prop = NULL;
+	struct property *specific_prop = NULL;
+	u32 prop_value;
+	int i, j, k;
+
+	hw = (struct ieee80211_hw *)wiphy_priv(wiphy);
+	priv = hw->priv;
+
+	if (priv->pwr_node) {
+		for_each_property_of_node(priv->pwr_node, prop) {
+			if (strcmp(prop->name, "FCC") == 0)
+				fcc_prop = prop;
+			if (strcmp(prop->name, "ETSI") == 0)
+				etsi_prop = prop;
+			if ((prop->name[0] == request->alpha2[0]) &&
+			    (prop->name[1] == request->alpha2[1]))
+				specific_prop = prop;
+		}
+
+		prop = NULL;
+
+		if (specific_prop) {
+			prop = specific_prop;
+		} else {
+			if (request->dfs_region == NL80211_DFS_ETSI)
+				prop = etsi_prop;
+			else
+				prop = fcc_prop;
+		}
+
+		if (prop) {
+			/* Reset the whole table */
+			for (i = 0; i < SYSADPT_MAX_NUM_CHANNELS; i++)
+				memset(&priv->tx_pwr_tbl[i], 0,
+				       sizeof(struct mwl_tx_pwr_tbl));
+
+			/* Load related power table */
+			i = 0;
+			j = 0;
+			while (i < prop->length) {
+				prop_value =
+					be32_to_cpu(*(__be32 *)
+						    (prop->value + i));
+				priv->tx_pwr_tbl[j].channel = prop_value;
+				i += 4;
+				prop_value =
+					be32_to_cpu(*(__be32 *)
+						    (prop->value + i));
+				priv->tx_pwr_tbl[j].setcap = prop_value;
+				i += 4;
+				for (k = 0; k < SYSADPT_TX_POWER_LEVEL_TOTAL;
+				     k++) {
+					prop_value =
+						be32_to_cpu(*(__be32 *)
+							    (prop->value + i));
+					priv->tx_pwr_tbl[j].tx_power[k] =
+						prop_value;
+					i += 4;
+				}
+				prop_value =
+					be32_to_cpu(*(__be32 *)
+						    (prop->value + i));
+				priv->tx_pwr_tbl[j].cdd =
+					(prop_value == 0) ? false : true;
+				i += 4;
+				prop_value =
+					be32_to_cpu(*(__be32 *)
+						    (prop->value + i));
+				priv->tx_pwr_tbl[j].txantenna2 = prop_value;
+				i += 4;
+				j++;
+			}
+
+			/* Dump loaded power tabel */
+			wiphy_info(hw->wiphy, "%s: %s\n", dev_name(&wiphy->dev),
+				   prop->name);
+			for (i = 0; i < SYSADPT_MAX_NUM_CHANNELS; i++) {
+				struct mwl_tx_pwr_tbl *pwr_tbl;
+				char disp_buf[64];
+				char *disp_ptr;
+
+				pwr_tbl = &priv->tx_pwr_tbl[i];
+				if (pwr_tbl->channel == 0)
+					break;
+				wiphy_info(hw->wiphy,
+					   "Channel: %d: 0x%x 0x%x 0x%x\n",
+					   pwr_tbl->channel,
+					   pwr_tbl->setcap,
+					   pwr_tbl->cdd,
+					   pwr_tbl->txantenna2);
+				disp_ptr = disp_buf;
+				for (j = 0; j < SYSADPT_TX_POWER_LEVEL_TOTAL;
+				     j++) {
+					disp_ptr +=
+						sprintf(disp_ptr, "%x ",
+							pwr_tbl->tx_power[j]);
+				}
+				wiphy_info(hw->wiphy, "%s\n", disp_buf);
+			}
+		}
+	}
+#endif
+}
+
+static void mwl_process_of_dts(struct mwl_priv *priv)
+{
+#ifdef CONFIG_OF
+	struct property *prop;
+	u32 prop_value;
+
+	priv->dt_node =
+		of_find_node_by_name(pci_bus_to_OF_node(priv->pdev->bus),
+				     "mwlwifi");
+	if (!priv->dt_node)
+		return;
+
+	/* look for all matching property names */
+	for_each_property_of_node(priv->dt_node, prop) {
+		if (strcmp(prop->name, "marvell,2ghz") == 0)
+			priv->disable_2g = true;
+		if (strcmp(prop->name, "marvell,5ghz") == 0)
+			priv->disable_5g = true;
+		if (strcmp(prop->name, "marvell,chainmask") == 0) {
+			prop_value = be32_to_cpu(*((__be32 *)prop->value));
+			if (prop_value == 2)
+				priv->antenna_tx = ANTENNA_TX_2;
+
+			prop_value = be32_to_cpu(*((__be32 *)

drivers/net/wireless/mwlwifi/main.c line 449

Quoted 10 lines
drivers/net/wireless/mwlwifi/main.c new file +10 -0
+						 (prop->value + 4)));
+			if (prop_value == 2)
+				priv->antenna_rx = ANTENNA_RX_2;
+		}
+	}
+
+	priv->pwr_node = of_find_node_by_name(priv->dt_node,
+					      "marvell,powertable");
+#endif
+}

The device tree bindings need a proper document in Documentation/devicetree/bindings and reviewed by the device tree folks. That might take some time as I suspect having something like regdomain in DT will be problematic, so I recommend to take this out from initial submission and resend later once properly acked by the device tree maintainers.

Signature · 1 line
Kalle Valo
author
#2 lore raw
Quoted 164 lines

Kalle Valo <[email protected]> writes:

Quoted 7 lines · David Lin

The Linux driver for WRT1900AC. The work was initially developed as part of openwrt effort and maintained on https://github.com/kaloz/mwlwifi.

This is still work in progress, with 8864 chipset more mature and tested, while 8897 for the similar use case is added recently.

[...]

Quoted 133 lines
drivers/net/wireless/mwlwifi/main.c new file +133 -0
+static void mwl_reg_notifier(struct wiphy *wiphy,
+			     struct regulatory_request *request) { #ifdef CONFIG_OF
+	struct ieee80211_hw *hw;
+	struct mwl_priv *priv;
+	struct property *prop;
+	struct property *fcc_prop = NULL;
+	struct property *etsi_prop = NULL;
+	struct property *specific_prop = NULL;
+	u32 prop_value;
+	int i, j, k;
+
+	hw = (struct ieee80211_hw *)wiphy_priv(wiphy);
+	priv = hw->priv;
+
+	if (priv->pwr_node) {
+		for_each_property_of_node(priv->pwr_node, prop) {
+			if (strcmp(prop->name, "FCC") == 0)
+				fcc_prop = prop;
+			if (strcmp(prop->name, "ETSI") == 0)
+				etsi_prop = prop;
+			if ((prop->name[0] == request->alpha2[0]) &&
+			    (prop->name[1] == request->alpha2[1]))
+				specific_prop = prop;
+		}
+
+		prop = NULL;
+
+		if (specific_prop) {
+			prop = specific_prop;
+		} else {
+			if (request->dfs_region == NL80211_DFS_ETSI)
+				prop = etsi_prop;
+			else
+				prop = fcc_prop;
+		}
+
+		if (prop) {
+			/* Reset the whole table */
+			for (i = 0; i < SYSADPT_MAX_NUM_CHANNELS; i++)
+				memset(&priv->tx_pwr_tbl[i], 0,
+				       sizeof(struct mwl_tx_pwr_tbl));
+
+			/* Load related power table */
+			i = 0;
+			j = 0;
+			while (i < prop->length) {
+				prop_value =
+					be32_to_cpu(*(__be32 *)
+						    (prop->value + i));
+				priv->tx_pwr_tbl[j].channel = prop_value;
+				i += 4;
+				prop_value =
+					be32_to_cpu(*(__be32 *)
+						    (prop->value + i));
+				priv->tx_pwr_tbl[j].setcap = prop_value;
+				i += 4;
+				for (k = 0; k < SYSADPT_TX_POWER_LEVEL_TOTAL;
+				     k++) {
+					prop_value =
+						be32_to_cpu(*(__be32 *)
+							    (prop->value + i));
+					priv->tx_pwr_tbl[j].tx_power[k] =
+						prop_value;
+					i += 4;
+				}
+				prop_value =
+					be32_to_cpu(*(__be32 *)
+						    (prop->value + i));
+				priv->tx_pwr_tbl[j].cdd =
+					(prop_value == 0) ? false : true;
+				i += 4;
+				prop_value =
+					be32_to_cpu(*(__be32 *)
+						    (prop->value + i));
+				priv->tx_pwr_tbl[j].txantenna2 = prop_value;
+				i += 4;
+				j++;
+			}
+
+			/* Dump loaded power tabel */
+			wiphy_info(hw->wiphy, "%s: %s\n", dev_name(&wiphy->dev),
+				   prop->name);
+			for (i = 0; i < SYSADPT_MAX_NUM_CHANNELS; i++) {
+				struct mwl_tx_pwr_tbl *pwr_tbl;
+				char disp_buf[64];
+				char *disp_ptr;
+
+				pwr_tbl = &priv->tx_pwr_tbl[i];
+				if (pwr_tbl->channel == 0)
+					break;
+				wiphy_info(hw->wiphy,
+					   "Channel: %d: 0x%x 0x%x 0x%x\n",
+					   pwr_tbl->channel,
+					   pwr_tbl->setcap,
+					   pwr_tbl->cdd,
+					   pwr_tbl->txantenna2);
+				disp_ptr = disp_buf;
+				for (j = 0; j < SYSADPT_TX_POWER_LEVEL_TOTAL;
+				     j++) {
+					disp_ptr +=
+						sprintf(disp_ptr, "%x ",
+							pwr_tbl->tx_power[j]);
+				}
+				wiphy_info(hw->wiphy, "%s\n", disp_buf);
+			}
+		}
+	}
+#endif
+}
+
+static void mwl_process_of_dts(struct mwl_priv *priv) { #ifdef
+CONFIG_OF
+	struct property *prop;
+	u32 prop_value;
+
+	priv->dt_node =
+		of_find_node_by_name(pci_bus_to_OF_node(priv->pdev->bus),
+				     "mwlwifi");
+	if (!priv->dt_node)
+		return;
+
+	/* look for all matching property names */
+	for_each_property_of_node(priv->dt_node, prop) {
+		if (strcmp(prop->name, "marvell,2ghz") == 0)
+			priv->disable_2g = true;
+		if (strcmp(prop->name, "marvell,5ghz") == 0)
+			priv->disable_5g = true;
+		if (strcmp(prop->name, "marvell,chainmask") == 0) {
+			prop_value = be32_to_cpu(*((__be32 *)prop->value));
+			if (prop_value == 2)
+				priv->antenna_tx = ANTENNA_TX_2;
+
+			prop_value = be32_to_cpu(*((__be32 *)

drivers/net/wireless/mwlwifi/main.c line 449

Quoted 10 lines
drivers/net/wireless/mwlwifi/main.c new file +10 -0
+						 (prop->value + 4)));
+			if (prop_value == 2)
+				priv->antenna_rx = ANTENNA_RX_2;
+		}
+	}
+
+	priv->pwr_node = of_find_node_by_name(priv->dt_node,
+					      "marvell,powertable");
+#endif
+}

The device tree bindings need a proper document in Documentation/devicetree/bindings and reviewed by the device tree folks. That might take some time as I suspect having something like regdomain in DT will be problematic, so I recommend to take this out from initial submission and resend later once properly acked by the device tree maintainers.

Quoted 2 lines

--
Kalle Valo

Yes. I will remove them for next patch.

Thanks,
David

author
#3 lore raw
In reply to Kalle Valo
Quoted 155 lines

Kalle Valo [mailto:[email protected]] writes:

Quoted 7 lines · David Lin

The Linux driver for WRT1900AC. The work was initially developed as part of openwrt effort and maintained on https://github.com/kaloz/mwlwifi.

This is still work in progress, with 8864 chipset more mature and tested, while 8897 for the similar use case is added recently.

[...]

Quoted 141 lines
drivers/net/wireless/mwlwifi/main.c new file +141 -0
+static void mwl_reg_notifier(struct wiphy *wiphy,
+			     struct regulatory_request *request) { #ifdef CONFIG_OF
+	struct ieee80211_hw *hw;
+	struct mwl_priv *priv;
+	struct property *prop;
+	struct property *fcc_prop = NULL;
+	struct property *etsi_prop = NULL;
+	struct property *specific_prop = NULL;
+	u32 prop_value;
+	int i, j, k;
+
+	hw = (struct ieee80211_hw *)wiphy_priv(wiphy);
+	priv = hw->priv;
+
+	if (priv->pwr_node) {
+		for_each_property_of_node(priv->pwr_node, prop) {
+			if (strcmp(prop->name, "FCC") == 0)
+				fcc_prop = prop;
+			if (strcmp(prop->name, "ETSI") == 0)
+				etsi_prop = prop;
+			if ((prop->name[0] == request->alpha2[0]) &&
+			    (prop->name[1] == request->alpha2[1]))
+				specific_prop = prop;
+		}
+
+		prop = NULL;
+
+		if (specific_prop) {
+			prop = specific_prop;
+		} else {
+			if (request->dfs_region == NL80211_DFS_ETSI)
+				prop = etsi_prop;
+			else
+				prop = fcc_prop;
+		}
+
+		if (prop) {
+			/* Reset the whole table */
+			for (i = 0; i < SYSADPT_MAX_NUM_CHANNELS; i++)
+				memset(&priv->tx_pwr_tbl[i], 0,
+				       sizeof(struct mwl_tx_pwr_tbl));
+
+			/* Load related power table */
+			i = 0;
+			j = 0;
+			while (i < prop->length) {
+				prop_value =
+					be32_to_cpu(*(__be32 *)
+						    (prop->value + i));
+				priv->tx_pwr_tbl[j].channel = prop_value;
+				i += 4;
+				prop_value =
+					be32_to_cpu(*(__be32 *)
+						    (prop->value + i));
+				priv->tx_pwr_tbl[j].setcap = prop_value;
+				i += 4;
+				for (k = 0; k < SYSADPT_TX_POWER_LEVEL_TOTAL;
+				     k++) {
+					prop_value =
+						be32_to_cpu(*(__be32 *)
+							    (prop->value + i));
+					priv->tx_pwr_tbl[j].tx_power[k] =
+						prop_value;
+					i += 4;
+				}
+				prop_value =
+					be32_to_cpu(*(__be32 *)
+						    (prop->value + i));
+				priv->tx_pwr_tbl[j].cdd =
+					(prop_value == 0) ? false : true;
+				i += 4;
+				prop_value =
+					be32_to_cpu(*(__be32 *)
+						    (prop->value + i));
+				priv->tx_pwr_tbl[j].txantenna2 = prop_value;
+				i += 4;
+				j++;
+			}
+
+			/* Dump loaded power tabel */
+			wiphy_info(hw->wiphy, "%s: %s\n", dev_name(&wiphy->dev),
+				   prop->name);
+			for (i = 0; i < SYSADPT_MAX_NUM_CHANNELS; i++) {
+				struct mwl_tx_pwr_tbl *pwr_tbl;
+				char disp_buf[64];
+				char *disp_ptr;
+
+				pwr_tbl = &priv->tx_pwr_tbl[i];
+				if (pwr_tbl->channel == 0)
+					break;
+				wiphy_info(hw->wiphy,
+					   "Channel: %d: 0x%x 0x%x 0x%x\n",
+					   pwr_tbl->channel,
+					   pwr_tbl->setcap,
+					   pwr_tbl->cdd,
+					   pwr_tbl->txantenna2);
+				disp_ptr = disp_buf;
+				for (j = 0; j < SYSADPT_TX_POWER_LEVEL_TOTAL;
+				     j++) {
+					disp_ptr +=
+						sprintf(disp_ptr, "%x ",
+							pwr_tbl->tx_power[j]);
+				}
+				wiphy_info(hw->wiphy, "%s\n", disp_buf);
+			}
+		}
+	}
+#endif
+}
+
+static void mwl_process_of_dts(struct mwl_priv *priv) { #ifdef
+CONFIG_OF
+	struct property *prop;
+	u32 prop_value;
+
+	priv->dt_node =
+		of_find_node_by_name(pci_bus_to_OF_node(priv->pdev->bus),
+				     "mwlwifi");
+	if (!priv->dt_node)
+		return;
+
+	/* look for all matching property names */
+	for_each_property_of_node(priv->dt_node, prop) {
+		if (strcmp(prop->name, "marvell,2ghz") == 0)
+			priv->disable_2g = true;
+		if (strcmp(prop->name, "marvell,5ghz") == 0)
+			priv->disable_5g = true;
+		if (strcmp(prop->name, "marvell,chainmask") == 0) {
+			prop_value = be32_to_cpu(*((__be32 *)prop->value));
+			if (prop_value == 2)
+				priv->antenna_tx = ANTENNA_TX_2;
+
+			prop_value = be32_to_cpu(*((__be32 *)
+						 (prop->value + 4)));
+			if (prop_value == 2)
+				priv->antenna_rx = ANTENNA_RX_2;
+		}
+	}
+
+	priv->pwr_node = of_find_node_by_name(priv->dt_node,
+					      "marvell,powertable");
Quoted 9 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+#endif
+}

The device tree bindings need a proper document in Documentation/devicetree/bindings and reviewed by the device tree folks. That might take some time as I suspect having something like regdomain in DT will be problematic, so I recommend to take this out from initial submission and resend later once properly acked by the device tree maintainers.

The code is used to handle mwlwifi proprietary parameters in DTS file. Basically it won't be conflicted with any existing bindings. Should I still take them out from initial submission?

pcie-controller {
	pcie@1,0 {
		mwlwifi {
			marvell,2ghz = <0>;
			marvell,chainmask = <2 2>;
			marvell,powertable {
				*
				*
				*
			};
		};
	};
};
Quoted 2 lines

--
Kalle Valo

Thanks,
David

#4 lore raw
Quoted 10 lines · David Lin
Quoted 6 lines

The device tree bindings need a proper document in Documentation/devicetree/bindings and reviewed by the device tree folks. That might take some time as I suspect having something like regdomain in DT will be problematic, so I recommend to take this out from initial submission and resend later once properly acked by the device tree maintainers.

The code is used to handle mwlwifi proprietary parameters in DTS file. Basically it won't be conflicted with any existing bindings. Should I still take them out from initial submission?

Yes, please take the device tree code out from the initial submission. I want the device tree maintainers to review and ack that part and that's easiest to do separately.

Signature · 1 line
Kalle Valo
#5 lore raw
In reply to David Lin
Quoted 7 lines · David Lin

The Linux driver for WRT1900AC. The work was initially developed as part of openwrt effort and maintained on https://github.com/kaloz/mwlwifi.

This is still work in progress, with 8864 chipset more mature and tested, while 8897 for the similar use case is added recently.

The commit log is really short. For a new driver you should explain a lot more, for example what works and what doesn't. Also it should contained detailed info about how and why (!) this conflicts with mwifiex and the way that problem was solved.

Also no new BUG_ON() calls in drivers, please:

fwcmd.c:        BUG_ON(tid >= SYSADPT_MAX_TID);
mac80211.c:     BUG_ON(queue > SYSADPT_TX_WMM_QUEUES - 1);
mac80211.c:             BUG_ON(stream->state != AMPDU_STREAM_IN_PROGRESS);
tx.c:   BUG_ON(tid > 7);
tx.c:   BUG_ON(tid >= SYSADPT_MAX_TID);
tx.c:   BUG_ON(!tx_skb);

We should start to get rid of all 200+ calls we already have, wireless drivers should never call BUG_ON(). Instead use descriptive error message (WARN_ON() etc) and bail out nicely with an error. That's much more user friendly than crashing the kernel.

Signature · 1 line
Kalle Valo
author
#6 lore raw
Quoted 27 lines

Kalle Valo [mailto:[email protected]] writes:

Quoted 7 lines · David Lin

The Linux driver for WRT1900AC. The work was initially developed as part of openwrt effort and maintained on https://github.com/kaloz/mwlwifi.

This is still work in progress, with 8864 chipset more mature and tested, while 8897 for the similar use case is added recently.

The commit log is really short. For a new driver you should explain a lot more, for example what works and what doesn't. Also it should contained detailed info about how and why (!) this conflicts with mwifiex and the way that problem was solved.

Also no new BUG_ON() calls in drivers, please:

fwcmd.c:        BUG_ON(tid >= SYSADPT_MAX_TID);
mac80211.c:     BUG_ON(queue > SYSADPT_TX_WMM_QUEUES - 1);
mac80211.c:             BUG_ON(stream->state !=
AMPDU_STREAM_IN_PROGRESS);
tx.c:   BUG_ON(tid > 7);
tx.c:   BUG_ON(tid >= SYSADPT_MAX_TID);
tx.c:   BUG_ON(!tx_skb);
Quoted 7 lines

We should start to get rid of all 200+ calls we already have, wireless drivers should never call BUG_ON(). Instead use descriptive error message (WARN_ON() etc) and bail out nicely with an error. That's much more user friendly than crashing the kernel.

--
Kalle Valo

I will change BUG_ON() to WARN_ON() for next patch.

Thanks,
David