linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC net-next 0/4] Marvell Prestera Switchdev initial updates for firmware version 3.0
@ 2021-05-19 14:33 Vadym Kochan
  2021-05-19 14:33 ` [RFC net-next 1/4] net: marvell: prestera: try to load previous fw version Vadym Kochan
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Vadym Kochan @ 2021-05-19 14:33 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski, netdev
  Cc: Vadym Kochan, Taras Chornyi, linux-kernel, Mickey Rachamim, Vadym Kochan

From: Vadym Kochan <vkochan@marvell.com>

This series adds minimal support for firmware version 3.0 which
has such changes like:

    - initial routing support

    - LAG support

    - events interrupt handling changes

Changes just make able to work with new firmware version but
supported features in driver will be added later.

New firmware version was recently merged into linux-firmware tree.

Added ability of loading previous fw major version if the latest one
is missing, also add support for previous FW ABI.

PATCH -> RFC:
    1) Load previous fw version if the latest one is missing (suggested by Andrew Lunn)

    2) Add support for previous FW ABI version (suggested by Andrew Lunn)

Vadym Kochan (4):
  net: marvell: prestera: try to load previous fw version
  net: marvell: prestera: disable events interrupt while handling
  net: marvell: prestera: align flood setting according to latest
    firmware version
  net: marvell: prestera: bump supported firmware version to 3.0

 .../ethernet/marvell/prestera/prestera_hw.c   | 85 +++++++++++++++-
 .../ethernet/marvell/prestera/prestera_hw.h   |  3 +-
 .../ethernet/marvell/prestera/prestera_pci.c  | 96 +++++++++++++++----
 .../marvell/prestera/prestera_switchdev.c     | 17 ++--
 4 files changed, 170 insertions(+), 31 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [RFC net-next 1/4] net: marvell: prestera: try to load previous fw version
  2021-05-19 14:33 [RFC net-next 0/4] Marvell Prestera Switchdev initial updates for firmware version 3.0 Vadym Kochan
@ 2021-05-19 14:33 ` Vadym Kochan
  2021-05-20  1:12   ` Andrew Lunn
  2021-05-19 14:33 ` [RFC net-next 2/4] net: marvell: prestera: disable events interrupt while handling Vadym Kochan
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Vadym Kochan @ 2021-05-19 14:33 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski, netdev
  Cc: Vadym Kochan, Taras Chornyi, linux-kernel, Mickey Rachamim, Vadym Kochan

From: Vadym Kochan <vkochan@marvell.com>

Lets try to load previous fw version in case the latest one is missing on
existing system.

Signed-off-by: Vadym Kochan <vkochan@marvell.com>
---
 .../ethernet/marvell/prestera/prestera_pci.c  | 75 ++++++++++++++-----
 1 file changed, 56 insertions(+), 19 deletions(-)

diff --git a/drivers/net/ethernet/marvell/prestera/prestera_pci.c b/drivers/net/ethernet/marvell/prestera/prestera_pci.c
index 298110119272..d384dcacd579 100644
--- a/drivers/net/ethernet/marvell/prestera/prestera_pci.c
+++ b/drivers/net/ethernet/marvell/prestera/prestera_pci.c
@@ -166,6 +166,8 @@ struct prestera_fw_evtq {
 };
 
 struct prestera_fw {
+	struct prestera_fw_rev rev_supp;
+	const struct firmware *bin;
 	struct workqueue_struct *wq;
 	struct prestera_device dev;
 	u8 __iomem *ldr_regs;
@@ -576,25 +578,24 @@ static void prestera_fw_rev_parse(const struct prestera_fw_header *hdr,
 static int prestera_fw_rev_check(struct prestera_fw *fw)
 {
 	struct prestera_fw_rev *rev = &fw->dev.fw_rev;
-	u16 maj_supp = PRESTERA_SUPP_FW_MAJ_VER;
-	u16 min_supp = PRESTERA_SUPP_FW_MIN_VER;
 
-	if (rev->maj == maj_supp && rev->min >= min_supp)
+	if (rev->maj == fw->rev_supp.maj && rev->min >= fw->rev_supp.min)
 		return 0;
 
 	dev_err(fw->dev.dev, "Driver supports FW version only '%u.%u.x'",
-		PRESTERA_SUPP_FW_MAJ_VER, PRESTERA_SUPP_FW_MIN_VER);
+		fw->rev_supp.maj, fw->rev_supp.min);
 
 	return -EINVAL;
 }
 
-static int prestera_fw_hdr_parse(struct prestera_fw *fw,
-				 const struct firmware *img)
+static int prestera_fw_hdr_parse(struct prestera_fw *fw)
 {
-	struct prestera_fw_header *hdr = (struct prestera_fw_header *)img->data;
 	struct prestera_fw_rev *rev = &fw->dev.fw_rev;
+	struct prestera_fw_header *hdr;
 	u32 magic;
 
+	hdr = (struct prestera_fw_header *)fw->bin->data;
+
 	magic = be32_to_cpu(hdr->magic_number);
 	if (magic != PRESTERA_FW_HDR_MAGIC) {
 		dev_err(fw->dev.dev, "FW img hdr magic is invalid");
@@ -609,11 +610,51 @@ static int prestera_fw_hdr_parse(struct prestera_fw *fw,
 	return prestera_fw_rev_check(fw);
 }
 
+static int prestera_fw_get(struct prestera_fw *fw)
+{
+	int ver_maj = PRESTERA_SUPP_FW_MAJ_VER;
+	int ver_min = PRESTERA_SUPP_FW_MIN_VER;
+	char fw_path[128];
+	int err;
+
+pick_fw_ver:
+	snprintf(fw_path, sizeof(fw_path), PRESTERA_FW_PATH_FMT,
+		 ver_maj, ver_min);
+
+	err = request_firmware_direct(&fw->bin, fw_path, fw->dev.dev);
+	if (err) {
+		if (ver_maj == PRESTERA_SUPP_FW_MAJ_VER) {
+			ver_maj--;
+			goto pick_fw_ver;
+		} else {
+			dev_err(fw->dev.dev, "failed to request firmware file\n");
+			return err;
+		}
+	}
+
+	if (ver_maj < PRESTERA_SUPP_FW_MAJ_VER)
+		dev_warn(fw->dev.dev,
+			 "using older FW version %u.%u than expected %u.%u\n",
+			 ver_maj, ver_min,
+			 PRESTERA_SUPP_FW_MAJ_VER, PRESTERA_SUPP_FW_MIN_VER);
+
+	dev_info(fw->dev.dev, "Loading %s ...", fw_path);
+
+	fw->rev_supp.maj = ver_maj;
+	fw->rev_supp.min = ver_min;
+	fw->rev_supp.sub = 0;
+
+	return 0;
+}
+
+static void prestera_fw_put(struct prestera_fw *fw)
+{
+	release_firmware(fw->bin);
+}
+
 static int prestera_fw_load(struct prestera_fw *fw)
 {
 	size_t hlen = sizeof(struct prestera_fw_header);
-	const struct firmware *f;
-	char fw_path[128];
 	int err;
 
 	err = prestera_ldr_wait_reg32(fw, PRESTERA_LDR_READY_REG,
@@ -632,30 +673,26 @@ static int prestera_fw_load(struct prestera_fw *fw)
 
 	fw->ldr_wr_idx = 0;
 
-	snprintf(fw_path, sizeof(fw_path), PRESTERA_FW_PATH_FMT,
-		 PRESTERA_SUPP_FW_MAJ_VER, PRESTERA_SUPP_FW_MIN_VER);
-
-	err = request_firmware_direct(&f, fw_path, fw->dev.dev);
+	err = prestera_fw_get(fw);
 	if (err) {
 		dev_err(fw->dev.dev, "failed to request firmware file\n");
 		return err;
 	}
 
-	err = prestera_fw_hdr_parse(fw, f);
+	err = prestera_fw_hdr_parse(fw);
 	if (err) {
 		dev_err(fw->dev.dev, "FW image header is invalid\n");
 		goto out_release;
 	}
 
-	prestera_ldr_write(fw, PRESTERA_LDR_IMG_SIZE_REG, f->size - hlen);
+	prestera_ldr_write(fw, PRESTERA_LDR_IMG_SIZE_REG, fw->bin->size - hlen);
 	prestera_ldr_write(fw, PRESTERA_LDR_CTL_REG, PRESTERA_LDR_CTL_DL_START);
 
-	dev_info(fw->dev.dev, "Loading %s ...", fw_path);
-
-	err = prestera_ldr_fw_send(fw, f->data + hlen, f->size - hlen);
+	err = prestera_ldr_fw_send(fw, fw->bin->data + hlen,
+				   fw->bin->size - hlen);
 
 out_release:
-	release_firmware(f);
+	prestera_fw_put(fw);
 	return err;
 }
 
-- 
2.17.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [RFC net-next 2/4] net: marvell: prestera: disable events interrupt while handling
  2021-05-19 14:33 [RFC net-next 0/4] Marvell Prestera Switchdev initial updates for firmware version 3.0 Vadym Kochan
  2021-05-19 14:33 ` [RFC net-next 1/4] net: marvell: prestera: try to load previous fw version Vadym Kochan
@ 2021-05-19 14:33 ` Vadym Kochan
  2021-05-19 14:33 ` [RFC net-next 3/4] net: marvell: prestera: align flood setting according to latest firmware version Vadym Kochan
  2021-05-19 14:33 ` [RFC net-next 4/4] net: marvell: prestera: bump supported firmware version to 3.0 Vadym Kochan
  3 siblings, 0 replies; 7+ messages in thread
From: Vadym Kochan @ 2021-05-19 14:33 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski, netdev
  Cc: Vadym Kochan, Taras Chornyi, linux-kernel, Mickey Rachamim, Vadym Kochan

From: Vadym Kochan <vkochan@marvell.com>

There are change in firmware which requires that receiver will
disable event interrupts before handling them and enable them
after finish with handling. Events still may come into the queue
but without receiver interruption.

Signed-off-by: Vadym Kochan <vkochan@marvell.com>
---
 .../ethernet/marvell/prestera/prestera_pci.c  | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/drivers/net/ethernet/marvell/prestera/prestera_pci.c b/drivers/net/ethernet/marvell/prestera/prestera_pci.c
index d384dcacd579..7ac045e82fab 100644
--- a/drivers/net/ethernet/marvell/prestera/prestera_pci.c
+++ b/drivers/net/ethernet/marvell/prestera/prestera_pci.c
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
 /* Copyright (c) 2019-2020 Marvell International Ltd. All rights reserved */
 
+#include <linux/bitfield.h>
 #include <linux/circ_buf.h>
 #include <linux/device.h>
 #include <linux/firmware.h>
@@ -144,6 +145,11 @@ struct prestera_fw_regs {
 /* PRESTERA_CMD_RCV_CTL_REG flags */
 #define PRESTERA_CMD_F_REPL_SENT	BIT(0)
 
+#define PRESTERA_FW_EVT_CTL_STATUS_MASK	GENMASK(1, 0)
+
+#define PRESTERA_FW_EVT_CTL_STATUS_ON	0
+#define PRESTERA_FW_EVT_CTL_STATUS_OFF	1
+
 #define PRESTERA_EVTQ_REG_OFFSET(q, f)			\
 	(PRESTERA_FW_REG_OFFSET(evtq_list) +		\
 	 (q) * sizeof(struct prestera_fw_evtq_regs) +	\
@@ -262,6 +268,15 @@ static u8 prestera_fw_evtq_pick(struct prestera_fw *fw)
 	return PRESTERA_EVT_QNUM_MAX;
 }
 
+static void prestera_fw_evt_ctl_status_set(struct prestera_fw *fw, u32 val)
+{
+	u32 status = prestera_fw_read(fw, PRESTERA_FW_STATUS_REG);
+
+	u32p_replace_bits(&status, val, PRESTERA_FW_EVT_CTL_STATUS_MASK);
+
+	prestera_fw_write(fw, PRESTERA_FW_STATUS_REG, status);
+}
+
 static void prestera_fw_evt_work_fn(struct work_struct *work)
 {
 	struct prestera_fw *fw;
@@ -271,6 +286,8 @@ static void prestera_fw_evt_work_fn(struct work_struct *work)
 	fw = container_of(work, struct prestera_fw, evt_work);
 	msg = fw->evt_msg;
 
+	prestera_fw_evt_ctl_status_set(fw, PRESTERA_FW_EVT_CTL_STATUS_OFF);
+
 	while ((qid = prestera_fw_evtq_pick(fw)) < PRESTERA_EVT_QNUM_MAX) {
 		u32 idx;
 		u32 len;
@@ -290,6 +307,8 @@ static void prestera_fw_evt_work_fn(struct work_struct *work)
 		if (fw->dev.recv_msg)
 			fw->dev.recv_msg(&fw->dev, msg, len);
 	}
+
+	prestera_fw_evt_ctl_status_set(fw, PRESTERA_FW_EVT_CTL_STATUS_ON);
 }
 
 static int prestera_fw_wait_reg32(struct prestera_fw *fw, u32 reg, u32 cmp,
-- 
2.17.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [RFC net-next 3/4] net: marvell: prestera: align flood setting according to latest firmware version
  2021-05-19 14:33 [RFC net-next 0/4] Marvell Prestera Switchdev initial updates for firmware version 3.0 Vadym Kochan
  2021-05-19 14:33 ` [RFC net-next 1/4] net: marvell: prestera: try to load previous fw version Vadym Kochan
  2021-05-19 14:33 ` [RFC net-next 2/4] net: marvell: prestera: disable events interrupt while handling Vadym Kochan
@ 2021-05-19 14:33 ` Vadym Kochan
  2021-05-19 14:33 ` [RFC net-next 4/4] net: marvell: prestera: bump supported firmware version to 3.0 Vadym Kochan
  3 siblings, 0 replies; 7+ messages in thread
From: Vadym Kochan @ 2021-05-19 14:33 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski, netdev
  Cc: Vadym Kochan, Taras Chornyi, linux-kernel, Mickey Rachamim, Vadym Kochan

From: Vadym Kochan <vkochan@marvell.com>

Latest FW IPC flood message format was changed to configure uc/mc
flooding separately, so change code according to this.

Signed-off-by: Vadym Kochan <vkochan@marvell.com>
---
PATCH -> RFC:
    1) Add support for previous FW ABI version (suggested by Andrew Lunn)

 .../ethernet/marvell/prestera/prestera_hw.c   | 85 ++++++++++++++++++-
 .../ethernet/marvell/prestera/prestera_hw.h   |  3 +-
 .../marvell/prestera/prestera_switchdev.c     | 17 ++--
 3 files changed, 94 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/marvell/prestera/prestera_hw.c b/drivers/net/ethernet/marvell/prestera/prestera_hw.c
index 0424718d5998..96ce73b50fec 100644
--- a/drivers/net/ethernet/marvell/prestera/prestera_hw.c
+++ b/drivers/net/ethernet/marvell/prestera/prestera_hw.c
@@ -2,6 +2,7 @@
 /* Copyright (c) 2019-2020 Marvell International Ltd. All rights reserved */
 
 #include <linux/etherdevice.h>
+#include <linux/if_bridge.h>
 #include <linux/ethtool.h>
 #include <linux/list.h>
 
@@ -85,6 +86,11 @@ enum {
 	PRESTERA_PORT_TP_AUTO,
 };
 
+enum {
+	PRESTERA_PORT_FLOOD_TYPE_UC = 0,
+	PRESTERA_PORT_FLOOD_TYPE_MC = 1,
+};
+
 enum {
 	PRESTERA_PORT_GOOD_OCTETS_RCV_CNT,
 	PRESTERA_PORT_BAD_OCTETS_RCV_CNT,
@@ -188,6 +194,11 @@ struct prestera_msg_port_mdix_param {
 	u8 admin_mode;
 };
 
+struct prestera_msg_port_flood_param {
+	u8 type;
+	u8 enable;
+};
+
 union prestera_msg_port_param {
 	u8  admin_state;
 	u8  oper_state;
@@ -205,6 +216,7 @@ union prestera_msg_port_param {
 	struct prestera_msg_port_mdix_param mdix;
 	struct prestera_msg_port_autoneg_param autoneg;
 	struct prestera_msg_port_cap_param cap;
+	struct prestera_msg_port_flood_param flood_ext;
 };
 
 struct prestera_msg_port_attr_req {
@@ -988,7 +1000,43 @@ int prestera_hw_port_learning_set(struct prestera_port *port, bool enable)
 			    &req.cmd, sizeof(req));
 }
 
-int prestera_hw_port_flood_set(struct prestera_port *port, bool flood)
+static int prestera_hw_port_uc_flood_set(struct prestera_port *port, bool flood)
+{
+	struct prestera_msg_port_attr_req req = {
+		.attr = PRESTERA_CMD_PORT_ATTR_FLOOD,
+		.port = port->hw_id,
+		.dev = port->dev_id,
+		.param = {
+			.flood_ext = {
+				.type = PRESTERA_PORT_FLOOD_TYPE_UC,
+				.enable = flood,
+			}
+		}
+	};
+
+	return prestera_cmd(port->sw, PRESTERA_CMD_TYPE_PORT_ATTR_SET,
+			    &req.cmd, sizeof(req));
+}
+
+static int prestera_hw_port_mc_flood_set(struct prestera_port *port, bool flood)
+{
+	struct prestera_msg_port_attr_req req = {
+		.attr = PRESTERA_CMD_PORT_ATTR_FLOOD,
+		.port = port->hw_id,
+		.dev = port->dev_id,
+		.param = {
+			.flood_ext = {
+				.type = PRESTERA_PORT_FLOOD_TYPE_MC,
+				.enable = flood,
+			}
+		}
+	};
+
+	return prestera_cmd(port->sw, PRESTERA_CMD_TYPE_PORT_ATTR_SET,
+			    &req.cmd, sizeof(req));
+}
+
+static int prestera_hw_port_flood_set_v2(struct prestera_port *port, bool flood)
 {
 	struct prestera_msg_port_attr_req req = {
 		.attr = PRESTERA_CMD_PORT_ATTR_FLOOD,
@@ -1003,6 +1051,41 @@ int prestera_hw_port_flood_set(struct prestera_port *port, bool flood)
 			    &req.cmd, sizeof(req));
 }
 
+int prestera_hw_port_flood_set(struct prestera_port *port, unsigned long mask,
+			       unsigned long val)
+{
+	int err;
+
+	if (port->sw->dev->fw_rev.maj <= 2) {
+		if (!(mask & BR_FLOOD))
+			return 0;
+
+		return prestera_hw_port_flood_set_v2(port, val & BR_FLOOD);
+	}
+
+	if (mask & BR_FLOOD) {
+		err = prestera_hw_port_uc_flood_set(port, val & BR_FLOOD);
+		if (err)
+			goto err_uc_flood;
+	}
+
+	if (mask & BR_MCAST_FLOOD) {
+		err = prestera_hw_port_mc_flood_set(port, val & BR_MCAST_FLOOD);
+		if (err)
+			goto err_mc_flood;
+	}
+
+	return 0;
+
+err_mc_flood:
+	prestera_hw_port_mc_flood_set(port, 0);
+err_uc_flood:
+	if (mask & BR_FLOOD)
+		prestera_hw_port_uc_flood_set(port, 0);
+
+	return err;
+}
+
 int prestera_hw_vlan_create(struct prestera_switch *sw, u16 vid)
 {
 	struct prestera_msg_vlan_req req = {
diff --git a/drivers/net/ethernet/marvell/prestera/prestera_hw.h b/drivers/net/ethernet/marvell/prestera/prestera_hw.h
index b2b5ac95b4e3..e8dd0e2b81d2 100644
--- a/drivers/net/ethernet/marvell/prestera/prestera_hw.h
+++ b/drivers/net/ethernet/marvell/prestera/prestera_hw.h
@@ -138,7 +138,8 @@ int prestera_hw_port_mdix_get(const struct prestera_port *port, u8 *status,
 int prestera_hw_port_mdix_set(const struct prestera_port *port, u8 mode);
 int prestera_hw_port_speed_get(const struct prestera_port *port, u32 *speed);
 int prestera_hw_port_learning_set(struct prestera_port *port, bool enable);
-int prestera_hw_port_flood_set(struct prestera_port *port, bool flood);
+int prestera_hw_port_flood_set(struct prestera_port *port, unsigned long mask,
+			       unsigned long val);
 int prestera_hw_port_accept_frm_type(struct prestera_port *port,
 				     enum prestera_accept_frm_type type);
 /* Vlan API */
diff --git a/drivers/net/ethernet/marvell/prestera/prestera_switchdev.c b/drivers/net/ethernet/marvell/prestera/prestera_switchdev.c
index cb564890a3dc..6442dc411285 100644
--- a/drivers/net/ethernet/marvell/prestera/prestera_switchdev.c
+++ b/drivers/net/ethernet/marvell/prestera/prestera_switchdev.c
@@ -404,7 +404,8 @@ prestera_bridge_1d_port_join(struct prestera_bridge_port *br_port)
 	if (err)
 		return err;
 
-	err = prestera_hw_port_flood_set(port, br_port->flags & BR_FLOOD);
+	err = prestera_hw_port_flood_set(port, BR_FLOOD | BR_MCAST_FLOOD,
+					 br_port->flags);
 	if (err)
 		goto err_port_flood_set;
 
@@ -415,7 +416,6 @@ prestera_bridge_1d_port_join(struct prestera_bridge_port *br_port)
 	return 0;
 
 err_port_learning_set:
-	prestera_hw_port_flood_set(port, false);
 err_port_flood_set:
 	prestera_hw_bridge_port_delete(port, bridge->bridge_id);
 
@@ -528,7 +528,7 @@ static void prestera_port_bridge_leave(struct prestera_port *port,
 		prestera_bridge_1d_port_leave(br_port);
 
 	prestera_hw_port_learning_set(port, false);
-	prestera_hw_port_flood_set(port, false);
+	prestera_hw_port_flood_set(port, BR_FLOOD | BR_MCAST_FLOOD, 0);
 	prestera_port_vid_stp_set(port, PRESTERA_VID_ALL, BR_STATE_FORWARDING);
 	prestera_bridge_port_put(br_port);
 }
@@ -590,11 +590,9 @@ static int prestera_port_attr_br_flags_set(struct prestera_port *port,
 	if (!br_port)
 		return 0;
 
-	if (flags.mask & BR_FLOOD) {
-		err = prestera_hw_port_flood_set(port, flags.val & BR_FLOOD);
-		if (err)
-			return err;
-	}
+	err = prestera_hw_port_flood_set(port, flags.mask, flags.val);
+	if (err)
+		return err;
 
 	if (flags.mask & BR_LEARNING) {
 		err = prestera_hw_port_learning_set(port,
@@ -901,7 +899,8 @@ prestera_port_vlan_bridge_join(struct prestera_port_vlan *port_vlan,
 	if (port_vlan->br_port)
 		return 0;
 
-	err = prestera_hw_port_flood_set(port, br_port->flags & BR_FLOOD);
+	err = prestera_hw_port_flood_set(port, BR_FLOOD | BR_MCAST_FLOOD,
+					 br_port->flags);
 	if (err)
 		return err;
 
-- 
2.17.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [RFC net-next 4/4] net: marvell: prestera: bump supported firmware version to 3.0
  2021-05-19 14:33 [RFC net-next 0/4] Marvell Prestera Switchdev initial updates for firmware version 3.0 Vadym Kochan
                   ` (2 preceding siblings ...)
  2021-05-19 14:33 ` [RFC net-next 3/4] net: marvell: prestera: align flood setting according to latest firmware version Vadym Kochan
@ 2021-05-19 14:33 ` Vadym Kochan
  3 siblings, 0 replies; 7+ messages in thread
From: Vadym Kochan @ 2021-05-19 14:33 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski, netdev
  Cc: Vadym Kochan, Taras Chornyi, linux-kernel, Mickey Rachamim, Vadym Kochan

From: Vadym Kochan <vkochan@marvell.com>

New firmware version has some ABI and feature changes like:

    - LAG support
    - initial L3 support
    - changed events handling logic

Signed-off-by: Vadym Kochan <vkochan@marvell.com>
---
 drivers/net/ethernet/marvell/prestera/prestera_pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/prestera/prestera_pci.c b/drivers/net/ethernet/marvell/prestera/prestera_pci.c
index 7ac045e82fab..e26f1d93606a 100644
--- a/drivers/net/ethernet/marvell/prestera/prestera_pci.c
+++ b/drivers/net/ethernet/marvell/prestera/prestera_pci.c
@@ -14,7 +14,7 @@
 
 #define PRESTERA_MSG_MAX_SIZE 1500
 
-#define PRESTERA_SUPP_FW_MAJ_VER	2
+#define PRESTERA_SUPP_FW_MAJ_VER	3
 #define PRESTERA_SUPP_FW_MIN_VER	0
 
 #define PRESTERA_FW_PATH_FMT	"mrvl/prestera/mvsw_prestera_fw-v%u.%u.img"
-- 
2.17.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC net-next 1/4] net: marvell: prestera: try to load previous fw version
  2021-05-19 14:33 ` [RFC net-next 1/4] net: marvell: prestera: try to load previous fw version Vadym Kochan
@ 2021-05-20  1:12   ` Andrew Lunn
  2021-05-20 10:48     ` Vadym Kochan
  0 siblings, 1 reply; 7+ messages in thread
From: Andrew Lunn @ 2021-05-20  1:12 UTC (permalink / raw)
  To: Vadym Kochan
  Cc: David S. Miller, Jakub Kicinski, netdev, Taras Chornyi,
	linux-kernel, Mickey Rachamim, Vadym Kochan

> +static int prestera_fw_get(struct prestera_fw *fw)
> +{
> +	int ver_maj = PRESTERA_SUPP_FW_MAJ_VER;
> +	int ver_min = PRESTERA_SUPP_FW_MIN_VER;
> +	char fw_path[128];
> +	int err;
> +
> +pick_fw_ver:
> +	snprintf(fw_path, sizeof(fw_path), PRESTERA_FW_PATH_FMT,
> +		 ver_maj, ver_min);
> +
> +	err = request_firmware_direct(&fw->bin, fw_path, fw->dev.dev);
> +	if (err) {
> +		if (ver_maj == PRESTERA_SUPP_FW_MAJ_VER) {
> +			ver_maj--;
> +			goto pick_fw_ver;
> +		} else {
> +			dev_err(fw->dev.dev, "failed to request firmware file\n");
> +			return err;
> +		}
> +	}

So lets say for the sake of the argument, you have version 3.0 and
2.42. It looks like this code will first try to load version 3.0. If
that fails, ver_maj is decremented, so it tries 2.0, which also fails
because it should be looking for 2.42. I don't think this decrement is
a good idea.

Also:

> +			dev_err(fw->dev.dev, "failed to request firmware file\n");

It would be useful to say what version you are actually looking for,
so the user can go find the correct firmware.

   Andrew

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC net-next 1/4] net: marvell: prestera: try to load previous fw version
  2021-05-20  1:12   ` Andrew Lunn
@ 2021-05-20 10:48     ` Vadym Kochan
  0 siblings, 0 replies; 7+ messages in thread
From: Vadym Kochan @ 2021-05-20 10:48 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: David S. Miller, Jakub Kicinski, netdev, Taras Chornyi,
	linux-kernel, Mickey Rachamim, Vadym Kochan

On Thu, May 20, 2021 at 03:12:02AM +0200, Andrew Lunn wrote:
> > +static int prestera_fw_get(struct prestera_fw *fw)
> > +{
> > +	int ver_maj = PRESTERA_SUPP_FW_MAJ_VER;
> > +	int ver_min = PRESTERA_SUPP_FW_MIN_VER;
> > +	char fw_path[128];
> > +	int err;
> > +
> > +pick_fw_ver:
> > +	snprintf(fw_path, sizeof(fw_path), PRESTERA_FW_PATH_FMT,
> > +		 ver_maj, ver_min);
> > +
> > +	err = request_firmware_direct(&fw->bin, fw_path, fw->dev.dev);
> > +	if (err) {
> > +		if (ver_maj == PRESTERA_SUPP_FW_MAJ_VER) {
> > +			ver_maj--;
> > +			goto pick_fw_ver;
> > +		} else {
> > +			dev_err(fw->dev.dev, "failed to request firmware file\n");
> > +			return err;
> > +		}
> > +	}
> 
> So lets say for the sake of the argument, you have version 3.0 and
> 2.42. It looks like this code will first try to load version 3.0. If
> that fails, ver_maj is decremented, so it tries 2.0, which also fails
> because it should be looking for 2.42. I don't think this decrement is
> a good idea.

Ahh, you are correct, I was too focused on a major version. So the only
option which I see is to hard-code also the previous version.

> 
> Also:
> 
> > +			dev_err(fw->dev.dev, "failed to request firmware file\n");
> 
> It would be useful to say what version you are actually looking for,
> so the user can go find the correct firmware.

I agree.

> 
>    Andrew

Thanks,

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-05-20 11:09 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-19 14:33 [RFC net-next 0/4] Marvell Prestera Switchdev initial updates for firmware version 3.0 Vadym Kochan
2021-05-19 14:33 ` [RFC net-next 1/4] net: marvell: prestera: try to load previous fw version Vadym Kochan
2021-05-20  1:12   ` Andrew Lunn
2021-05-20 10:48     ` Vadym Kochan
2021-05-19 14:33 ` [RFC net-next 2/4] net: marvell: prestera: disable events interrupt while handling Vadym Kochan
2021-05-19 14:33 ` [RFC net-next 3/4] net: marvell: prestera: align flood setting according to latest firmware version Vadym Kochan
2021-05-19 14:33 ` [RFC net-next 4/4] net: marvell: prestera: bump supported firmware version to 3.0 Vadym Kochan

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).