Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 452427b0 authored by Yuval Mintz's avatar Yuval Mintz Committed by David S. Miller
Browse files

bnx2x: previous driver unload revised



The flow in which the bnx2x driver starts after a previous driver
has been terminated in an 'unclean' manner has several bugs and
FW risks, which makes it possible for the driver to fail after
boot-from-SAN or kdump.
This patch contains a revised flow which performs a safer
initialization, solving the possible crash scenarios.
Notice this patch contains lines with over 80 characters, as it
keeps print-strings in a single line.

Signed-off-by: default avatarYuval Mintz <yuvalmin@broadcom.com>
Signed-off-by: default avatarEilon Greenstein <eilong@broadcom.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a2daf263
Loading
Loading
Loading
Loading
+7 −0
Original line number Original line Diff line number Diff line
@@ -1173,6 +1173,13 @@ enum {
};
};




struct bnx2x_prev_path_list {
	u8 bus;
	u8 slot;
	u8 path;
	struct list_head list;
};

struct bnx2x {
struct bnx2x {
	/* Fields used in the tx and intr/napi performance paths
	/* Fields used in the tx and intr/napi performance paths
	 * are grouped together in the beginning of the structure
	 * are grouped together in the beginning of the structure
+24 −16
Original line number Original line Diff line number Diff line
@@ -1721,6 +1721,29 @@ static void bnx2x_squeeze_objects(struct bnx2x *bp)
	} while (0)
	} while (0)
#endif
#endif


bool bnx2x_test_firmware_version(struct bnx2x *bp, bool is_err)
{
	/* build FW version dword */
	u32 my_fw = (BCM_5710_FW_MAJOR_VERSION) +
		    (BCM_5710_FW_MINOR_VERSION << 8) +
		    (BCM_5710_FW_REVISION_VERSION << 16) +
		    (BCM_5710_FW_ENGINEERING_VERSION << 24);

	/* read loaded FW from chip */
	u32 loaded_fw = REG_RD(bp, XSEM_REG_PRAM);

	DP(NETIF_MSG_IFUP, "loaded fw %x, my fw %x\n", loaded_fw, my_fw);

	if (loaded_fw != my_fw) {
		if (is_err)
			BNX2X_ERR("bnx2x with FW %x was already loaded, which mismatches my %x FW. aborting\n",
				  loaded_fw, my_fw);
		return false;
	}

	return true;
}

/* must be called with rtnl_lock */
/* must be called with rtnl_lock */
int bnx2x_nic_load(struct bnx2x *bp, int load_mode)
int bnx2x_nic_load(struct bnx2x *bp, int load_mode)
{
{
@@ -1815,23 +1838,8 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode)
		}
		}
		if (load_code != FW_MSG_CODE_DRV_LOAD_COMMON_CHIP &&
		if (load_code != FW_MSG_CODE_DRV_LOAD_COMMON_CHIP &&
		    load_code != FW_MSG_CODE_DRV_LOAD_COMMON) {
		    load_code != FW_MSG_CODE_DRV_LOAD_COMMON) {
			/* build FW version dword */
			u32 my_fw = (BCM_5710_FW_MAJOR_VERSION) +
					(BCM_5710_FW_MINOR_VERSION << 8) +
					(BCM_5710_FW_REVISION_VERSION << 16) +
					(BCM_5710_FW_ENGINEERING_VERSION << 24);

			/* read loaded FW from chip */
			u32 loaded_fw = REG_RD(bp, XSEM_REG_PRAM);

			DP(BNX2X_MSG_SP, "loaded fw %x, my fw %x",
			   loaded_fw, my_fw);

			/* abort nic load if version mismatch */
			/* abort nic load if version mismatch */
			if (my_fw != loaded_fw) {
			if (!bnx2x_test_firmware_version(bp, true)) {
				BNX2X_ERR("bnx2x with FW %x already loaded, "
					  "which mismatches my %x FW. aborting",
					  loaded_fw, my_fw);
				rc = -EBUSY;
				rc = -EBUSY;
				LOAD_ERROR_EXIT(bp, load_error2);
				LOAD_ERROR_EXIT(bp, load_error2);
			}
			}
+3 −0
Original line number Original line Diff line number Diff line
@@ -431,6 +431,9 @@ void bnx2x_panic_dump(struct bnx2x *bp);


void bnx2x_fw_dump_lvl(struct bnx2x *bp, const char *lvl);
void bnx2x_fw_dump_lvl(struct bnx2x *bp, const char *lvl);


/* validate currect fw is loaded */
bool bnx2x_test_firmware_version(struct bnx2x *bp, bool is_err);

/* dev_close main block */
/* dev_close main block */
int bnx2x_nic_unload(struct bnx2x *bp, int unload_mode);
int bnx2x_nic_unload(struct bnx2x *bp, int unload_mode);


+3 −0
Original line number Original line Diff line number Diff line
@@ -1251,6 +1251,9 @@ struct drv_func_mb {


	#define DRV_MSG_CODE_LINK_STATUS_CHANGED        0x01000000
	#define DRV_MSG_CODE_LINK_STATUS_CHANGED        0x01000000


	#define DRV_MSG_CODE_INITIATE_FLR               0x02000000
	#define REQ_BC_VER_4_INITIATE_FLR               0x00070213

	#define BIOS_MSG_CODE_LIC_CHALLENGE             0xff010000
	#define BIOS_MSG_CODE_LIC_CHALLENGE             0xff010000
	#define BIOS_MSG_CODE_LIC_RESPONSE              0xff020000
	#define BIOS_MSG_CODE_LIC_RESPONSE              0xff020000
	#define BIOS_MSG_CODE_VIRT_MAC_PRIM             0xff030000
	#define BIOS_MSG_CODE_VIRT_MAC_PRIM             0xff030000
+0 −1
Original line number Original line Diff line number Diff line
@@ -35,7 +35,6 @@
#define ETH_MAX_PACKET_SIZE		1500
#define ETH_MAX_PACKET_SIZE		1500
#define ETH_MAX_JUMBO_PACKET_SIZE	9600
#define ETH_MAX_JUMBO_PACKET_SIZE	9600
#define MDIO_ACCESS_TIMEOUT		1000
#define MDIO_ACCESS_TIMEOUT		1000
#define BMAC_CONTROL_RX_ENABLE		2
#define WC_LANE_MAX			4
#define WC_LANE_MAX			4
#define I2C_SWITCH_WIDTH		2
#define I2C_SWITCH_WIDTH		2
#define I2C_BSC0			0
#define I2C_BSC0			0
Loading