Skip to contentSkip to conversation

rsi: add driver and firmware version info

PATCH In review Amitkumar Karwar 2 participants 3 messages Aug 30, 2017 – Sep 21, 2017 Redpine wireless driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rsi: add driver and firmware version info

From: Pavani Muthyala <[email protected]>

We will dump information about driver and firmware versions, firmware file name and operating mode during initialization.

---
 drivers/net/wireless/rsi/rsi_91x_debugfs.c | 20 +++++++-------------
 drivers/net/wireless/rsi/rsi_91x_hal.c     | 13 +++++++++++++
 drivers/net/wireless/rsi/rsi_91x_main.c    | 29 +++++++++++++++++++++++++++++
 drivers/net/wireless/rsi/rsi_hal.h         |  3 +++
 drivers/net/wireless/rsi/rsi_main.h        | 17 +++++++++++++----
 5 files changed, 65 insertions(+), 17 deletions(-)
drivers/net/wireless/rsi/rsi_91x_debugfs.c +7 -13
index e98eb55..a1b5e28 100644
@@ -83,19 +83,13 @@ static int rsi_version_read(struct seq_file *seq, void *data)
 {
 	struct rsi_common *common = seq->private;
 
-	common->driver_ver.major = 0;
-	common->driver_ver.minor = 1;
-	common->driver_ver.release_num = 0;
-	common->driver_ver.patch_num = 0;
-	seq_printf(seq, "Driver : %x.%d.%d.%d\nLMAC   : %d.%d.%d.%d\n",
-		   common->driver_ver.major,
-		   common->driver_ver.minor,
-		   common->driver_ver.release_num,
-		   common->driver_ver.patch_num,
-		   common->fw_ver.major,
-		   common->fw_ver.minor,
-		   common->fw_ver.release_num,
-		   common->fw_ver.patch_num);
+	seq_printf(seq, "Driver : %s\nLMAC   : %d.%d.%d.%d\n",
+		   common->driver_ver,
+		   common->lmac_ver.major,
+		   common->lmac_ver.minor,
+		   common->lmac_ver.release_num,
+		   common->lmac_ver.patch_num);
+
 	return 0;
 }
 
drivers/net/wireless/rsi/rsi_91x_hal.c +13 -0
index 7e8e5d4..71b02ad 100644
@@ -769,6 +769,7 @@ static int auto_fw_upgrade(struct rsi_hw *adapter, u8 *flash_content,
 
 static int rsi_load_firmware(struct rsi_hw *adapter)
 {
+	struct rsi_common *common = adapter->priv;
 	struct rsi_host_intf_ops *hif_ops = adapter->host_intf_ops;
 	const struct firmware *fw_entry = NULL;
 	u32 regout_val = 0, content_size;
@@ -844,6 +845,18 @@ static int rsi_load_firmware(struct rsi_hw *adapter)
 	content_size = fw_entry->size;
 	rsi_dbg(INFO_ZONE, "FW Length = %d bytes\n", content_size);
 
+	/* Get the firmware version */
+	common->lmac_ver.ver.info.fw_ver[0] =
+		flash_content[LMAC_VER_OFFSET] & 0xFF;
+	common->lmac_ver.ver.info.fw_ver[1] =
+		flash_content[LMAC_VER_OFFSET + 1] & 0xFF;
+	common->lmac_ver.major = flash_content[LMAC_VER_OFFSET + 2] & 0xFF;
+	common->lmac_ver.release_num =
+		flash_content[LMAC_VER_OFFSET + 3] & 0xFF;
+	common->lmac_ver.minor = flash_content[LMAC_VER_OFFSET + 4] & 0xFF;
+	common->lmac_ver.patch_num = 0;
+	rsi_print_version(common);
+
 	status = bl_write_header(adapter, flash_content, content_size);
 	if (status) {
 		rsi_dbg(ERR_ZONE,
drivers/net/wireless/rsi/rsi_91x_main.c +29 -0
index b57bfdc..ed988b3 100644
@@ -20,6 +20,7 @@
 #include <linux/firmware.h>
 #include "rsi_mgmt.h"
 #include "rsi_common.h"
+#include "rsi_hal.h"
 
 u32 rsi_zone_enabled = /* INFO_ZONE |
 			INIT_ZONE |
@@ -56,6 +57,34 @@ void rsi_dbg(u32 zone, const char *fmt, ...)
 }
 EXPORT_SYMBOL_GPL(rsi_dbg);
 
+static char *opmode_str(int oper_mode)
+{
+	switch (oper_mode) {
+	case RSI_DEV_OPMODE_WIFI_ALONE:
+		return "Wi-Fi alone";
+	}
+
+	return "Unknown";
+}
+
+void rsi_print_version(struct rsi_common *common)
+{
+	memcpy(common->driver_ver, DRV_VER, ARRAY_SIZE(DRV_VER));
+	common->driver_ver[ARRAY_SIZE(DRV_VER)] = '\0';
+
+	rsi_dbg(ERR_ZONE, "================================================\n");
+	rsi_dbg(ERR_ZONE, "================ RSI Version Info ==============\n");
+	rsi_dbg(ERR_ZONE, "================================================\n");
+	rsi_dbg(ERR_ZONE, "FW Version\t: %d.%d.%d\n",
+		common->lmac_ver.major, common->lmac_ver.minor,
+		common->lmac_ver.release_num);
+	rsi_dbg(ERR_ZONE, "Driver Version\t: %s", common->driver_ver);
+	rsi_dbg(ERR_ZONE, "Operating mode\t: %d [%s]",
+		common->oper_mode, opmode_str(common->oper_mode));
+	rsi_dbg(ERR_ZONE, "Firmware file\t: %s", common->priv->fw_file_name);
+	rsi_dbg(ERR_ZONE, "================================================\n");
+}
+
 /**
  * rsi_prepare_skb() - This function prepares the skb.
  * @common: Pointer to the driver private structure.
drivers/net/wireless/rsi/rsi_hal.h +3 -0
index ad0d653..a09d36b 100644
@@ -101,6 +101,9 @@
 
 #define BBP_INFO_40MHZ 0x6
 
+#define FW_FLASH_OFFSET			0x820
+#define LMAC_VER_OFFSET			(FW_FLASH_OFFSET + 0x200)
+
 struct bl_header {
 	__le32 flags;
 	__le32 image_no;
drivers/net/wireless/rsi/rsi_main.h +13 -4
index 34089ab..53343a3f 100644
@@ -32,6 +32,8 @@ struct rsi_hw;
 
 #include "rsi_ps.h"
 
+#define DRV_VER				"RS911X.NB0.NL.GNU.LNX.1.0"
+
 #define ERR_ZONE                        BIT(0)  /* For Error Msgs             */
 #define INFO_ZONE                       BIT(1)  /* For General Status Msgs    */
 #define INIT_ZONE                       BIT(2)  /* For Driver Init Seq Msgs   */
@@ -113,8 +115,13 @@ extern __printf(2, 3) void rsi_dbg(u32 zone, const char *fmt, ...);
 struct version_info {
 	u16 major;
 	u16 minor;
-	u16 release_num;
-	u16 patch_num;
+	u8 release_num;
+	u8 patch_num;
+	union {
+		struct {
+			u8 fw_ver[8];
+		} info;
+	} ver;
 } __packed;
 
 struct skb_info {
@@ -199,8 +206,8 @@ struct rsi_common {
 	struct vif_priv vif_info[RSI_MAX_VIFS];
 
 	bool mgmt_q_block;
-	struct version_info driver_ver;
-	struct version_info fw_ver;
+	char driver_ver[32];
+	struct version_info lmac_ver;
 
 	struct rsi_thread tx_thread;
 	struct sk_buff_head tx_queue[NUM_EDCA_QUEUES + 2];
@@ -334,6 +341,8 @@ struct rsi_hw {
 	int (*determine_event_timeout)(struct rsi_hw *adapter);
 };
 
+void rsi_print_version(struct rsi_common *common);
+
 struct rsi_host_intf_ops {
 	int (*read_pkt)(struct rsi_hw *adapter, u8 *pkt, u32 len);
 	int (*write_pkt)(struct rsi_hw *adapter, u8 *pkt, u32 len);
Signature · 1 line
2.7.4
#1 lore raw
Quoted 7 lines · Amitkumar Karwar

From: Pavani Muthyala <[email protected]>

We will dump information about driver and firmware versions, firmware file name and operating mode during initialization.

[...]

Quoted 18 lines
drivers/net/wireless/rsi/rsi_91x_main.c +18 -0
+void rsi_print_version(struct rsi_common *common)
+{
+	memcpy(common->driver_ver, DRV_VER, ARRAY_SIZE(DRV_VER));
+	common->driver_ver[ARRAY_SIZE(DRV_VER)] = '\0';
+
+	rsi_dbg(ERR_ZONE, "================================================\n");
+	rsi_dbg(ERR_ZONE, "================ RSI Version Info ==============\n");
+	rsi_dbg(ERR_ZONE, "================================================\n");
+	rsi_dbg(ERR_ZONE, "FW Version\t: %d.%d.%d\n",
+		common->lmac_ver.major, common->lmac_ver.minor,
+		common->lmac_ver.release_num);
+	rsi_dbg(ERR_ZONE, "Driver Version\t: %s", common->driver_ver);
+	rsi_dbg(ERR_ZONE, "Operating mode\t: %d [%s]",
+		common->oper_mode, opmode_str(common->oper_mode));
+	rsi_dbg(ERR_ZONE, "Firmware file\t: %s", common->priv->fw_file_name);
+	rsi_dbg(ERR_ZONE, "================================================\n");
+}
+

[...]

Quoted 1 line

+#define DRV_VER "RS911X.NB0.NL.GNU.LNX.1.0"

The concept of a driver version does not really work with upstream drivers. The history has shown multiple times that the driver version won't be updated for years and thus it won't have any meaning. So better remove driver_ver from the driver entirely.

Signature · 1 line
Kalle Valo
#2 lore raw
Quoted 33 lines · Kalle Valo
Quoted 7 lines · Amitkumar Karwar

From: Pavani Muthyala <[email protected]>

We will dump information about driver and firmware versions, firmware file name and operating mode during initialization.

[...]

Quoted 18 lines
drivers/net/wireless/rsi/rsi_91x_main.c +18 -0
+void rsi_print_version(struct rsi_common *common)
+{
+     memcpy(common->driver_ver, DRV_VER, ARRAY_SIZE(DRV_VER));
+     common->driver_ver[ARRAY_SIZE(DRV_VER)] = '\0';
+
+     rsi_dbg(ERR_ZONE, "================================================\n");
+     rsi_dbg(ERR_ZONE, "================ RSI Version Info ==============\n");
+     rsi_dbg(ERR_ZONE, "================================================\n");
+     rsi_dbg(ERR_ZONE, "FW Version\t: %d.%d.%d\n",
+             common->lmac_ver.major, common->lmac_ver.minor,
+             common->lmac_ver.release_num);
+     rsi_dbg(ERR_ZONE, "Driver Version\t: %s", common->driver_ver);
+     rsi_dbg(ERR_ZONE, "Operating mode\t: %d [%s]",
+             common->oper_mode, opmode_str(common->oper_mode));
+     rsi_dbg(ERR_ZONE, "Firmware file\t: %s", common->priv->fw_file_name);
+     rsi_dbg(ERR_ZONE, "================================================\n");
+}
+

[...]

Quoted 6 lines
Quoted 1 line

+#define DRV_VER "RS911X.NB0.NL.GNU.LNX.1.0"

The concept of a driver version does not really work with upstream drivers. The history has shown multiple times that the driver version won't be updated for years and thus it won't have any meaning. So better remove driver_ver from the driver entirely.

I agree. Driver version has been removed in v2 patch.

Thanks,
Amitkumar Karwar