svn commit: r353272 - in releng/12.1: share/man/man4 sys/conf sys/dev/mlx5 sys/dev/mlx5/mlx5_core sys/dev/mlx5/mlx5_en sys/dev/mlx5/mlx5_ib sys/modules/mlx5 sys/modules/mlx5en usr.sbin/mlx5tool

Hans Petter Selasky hselasky at FreeBSD.org
Mon Oct 7 13:13:09 UTC 2019


Author: hselasky
Date: Mon Oct  7 13:13:06 2019
New Revision: 353272
URL: https://svnweb.freebsd.org/changeset/base/353272

Log:
  MFS r353184, r353186, r353188, r353190, r353192, r353194, r353196, r353198,
  r353200, r353203, r353205, r353207, r353209, r353211, r353213, r353215,
  r353217, r353219, r353221, r353223, r353225, r353227, r353229, r353231,
  r353233, r353235, r353237, r353239, r353241, r353243, r353245, r353247,
  r353249, r353251, r353253, r353255, r353257, r353259, r353261, r353263,
  r353265 and r353267:
  
  Update mlx5core, mlx5en(4) and mlx5ib(4).
  
  Sponsored by:	Mellanox Technologies
  Approved by:	re (gjb)
  
  MFC r352956:
  Fix reported max SGE calculation in mlx5ib.
  
  Add the 512 bytes limit of RDMA READ and the size of remote address to the max
  SGE calculation.
  
  Linux commit:	288c01b746aa
  
  MFC r352957:
  Update warning and error print formats in mlx5ib.
  
  MFC r352958:
  Make sure the number of IRQ vectors doesn't exceed 256 in mlx5core.
  The "intr" field in "struct mlx5_ifc_eqc_bits" is only 8 bits wide.
  
  MFC r352959:
  Check return value of mlx5_vector2eqn() function in mlx5en.
  
  MFC r352960:
  Fix for missing cleanup code in error case in mlx5en.
  
  MFC r352961:
  Implement macro for asserting priv lock in mlx5en.
  
  MFC r352962:
  Add support for Multi-Physical Function Switch, MPFS, in mlx5en.
  
  MPFS is a logical switch in the Mellanox device which forward packets
  based on a hardware driven L2 address table, to one or more physical-
  or virtual- functions. The physical- or virtual- function is required
  to tell the MPFS by using the MPFS firmware commands, which unicast
  MAC addresses it is requesting from the physical port's traffic.
  Broadcast and multicast traffic however, is copied to all listening
  physical- and virtual- functions and does not need a rule in the MPFS
  switching table.
  
  Linux commit:	eeb66cdb682678bfd1f02a4547e3649b38ffea7e
  
  MFC r352963:
  Cleanup naming of IRQ vectors in mlx5en.
  Remove unused IRQ naming functions and arrays.
  
  MFC r352964:
  Export channel IRQ number as part of the "hw_ctx_debug" sysctl(8) in mlx5en(4).
  
  MFC r352965:
  Correct and update some counter names in mlx5en(4).
  
  MFC r352966:
  Add port module event software counters in mlx5core.
  While at it, fixup PME based on latest PRM defines.
  
  MFC r352967:
  Make the mlx5_vsc_wait_on_flag(9) function global.
  
  MFC r352968:
  Move mlx5_ifc_vsc_space_bits and mlx5_ifc_vsc_addr_bits to mlx5_ifc.h.
  
  MFC r352969:
  Use the MLX5_VSC_DOMAIN_SEMAPHORES constant instead of hand-rolled symbol
  in mlx5core.
  
  MFC r352970:
  Define MLX5_VSC_DOMAIN_SCAN_CRSPACE.
  
  MFC r352971:
  Read rege map from crdump scan space in mlx5core.
  
  MFC r352972:
  Remove no longer needed fwdump register tables from mlx5core.
  
  MFC r352973:
  Add missing blank line at the end of the print in mlx5core.
  
  MFC r352974:
  Add proper print in case of 0x0 health syndrome in mlx5core.
  
  In case of health counter fails to increment it indicates a bad device health.
  In case when the syndrome indicated by firmware is 0x0, this indicates that
  firmware is unable to respond to initialization segment reads.
  Add proper print in this case.
  
  MFC r352975:
  Unify prints in mlx5core.
  
  All prints in mlx5core should use on of the macros:
  mlx5_core_err/dbg/warn
  
  MFC r352976:
  Unify prints in mlx5en(4).
  
  All prints in mlx5en(4) should use on of the macros:
  mlx5_en_err/dbg/warn
  
  MFC r352977:
  Sort the ports registers definitions numerically in mlx5core.
  
  MFC r352978:
  Add definition for the Port Buffer Status Register in mlx5core.
  
  MFC r352979:
  Update definitons for PPTB and PBMC registers layouts in mlx5core.
  
  MFC r352980:
  Add mlx5e_dbg() compatibility macro.
  
  MFC r352981:
  Import Linux code to query/set buffer state in mlx5en(4).
  
  MFC r352982:
  Add support for buffer parameter manipulations in mlx5en(4).
  
  The following sysctls are added:
  dev.mce.N.conf.qos.cable_length
  dev.mce.N.conf.qos.buffers_size
  dev.mce.N.conf.qos.buffers_prio
  
  MFC r352983 and r353001:
  Move EEPROM information query from a sysctl in mlx5en(4) to an ioctl
  in mlx5core. The EEPROM information is not only a property of the
  mlx5en(4) driver.
  
  MFC r352984:
  Add the ability to query the EEPROM information in mlx5tool(8).
  
  MFC r352985:
  Add sysctl(8) to get and set forward error correction, FEC, configuration
  in mlx5en(4).
  
  MFC r352986:
  Return an error from ioctl(MLX5_FW_RESET) if reset was rejected in mlx5core.
  
  MFC r352987:
  Remove mkey_be from channel structure in mlx5en(4).
  Use value from priv structure instead.
  This saves some space in the channel structure.
  
  MFC r352988:
  Remove unused cpu field from channel structure in mlx5en(4).
  
  MFC r352989:
  Seal transmit path with regards to using destroyed mutex in mlx5en(4).
  
  It may happen during link down that the running state may be observed
  non-zero in the transmit routine, right before the running state is
  cleared. This may end up using a destroyed mutex.
  
  Make all channel mutexes and callouts persistant.
  
  Preserve receive and send queue statistics during link toggle.
  
  MFC r352991 and 353000:
  Wait for FW readiness before initializing command interface in mlx5core.
  
  Before attempting to initialize the command interface we must wait till
  the fw_initializing bit is clear.
  
  If we fail to meet this condition the hardware will drop our
  configuration, specifically the descriptors page address.  This scenario
  can happen when the firmware is still executing an FLR flow and did not
  finish yet so the driver needs to wait for that to finish.
  
  Linux commits:
  6c780a0267b8
  b8a92577f4be.
  
  MFC r352992:
  Use size_t for byte_to_write variable when comparing to eeprom_info_out_len
  which is also size_t in mlx5tool(8).
  
  MFC r352993:
  Randomize the delay when waiting for VSC flag in mlx5core.
  
  The PRM suggests random 0 - 10ms to prevent multiple waiters on the same
  interval in order to avoid starvation.
  
  MFC r352994:
  Improve mlx5_fwdump_prep logging in mlx5core.
  
  MFC r352995:
  Only update lossy buffers config when manual PFC configuration was done
  in mlx5en(4).
  
  MFC r352996:
  Add print to show user a reason for rejecting buffer size change in mlx5en(4).
  
  MFC r352997:
  Print numeric error_type and module_status in mlx5core
  in case the strings are not available.
  
  MFC r352998:
  Bump driver version for mlx5core, mlx5en(4) and mlx5ib(4).

Added:
  releng/12.1/sys/dev/mlx5/mlx5_core/mlx5_mpfs.c
     - copied, changed from r353196, stable/12/sys/dev/mlx5/mlx5_core/mlx5_mpfs.c
  releng/12.1/sys/dev/mlx5/mlx5_en/mlx5_en_port_buffer.c
     - copied, changed from r353235, stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_port_buffer.c
  releng/12.1/sys/dev/mlx5/mlx5_en/port_buffer.h
     - copied unchanged from r353235, stable/12/sys/dev/mlx5/mlx5_en/port_buffer.h
  releng/12.1/sys/dev/mlx5/mpfs.h
     - copied unchanged from r353196, stable/12/sys/dev/mlx5/mpfs.h
Deleted:
  releng/12.1/sys/dev/mlx5/mlx5_core/mlx5_fwdump_regmaps.c
Modified:
  releng/12.1/share/man/man4/mlx5io.4
  releng/12.1/sys/conf/files
  releng/12.1/sys/dev/mlx5/device.h
  releng/12.1/sys/dev/mlx5/diagnostics.h
  releng/12.1/sys/dev/mlx5/driver.h
  releng/12.1/sys/dev/mlx5/mlx5_core/mlx5_cmd.c
  releng/12.1/sys/dev/mlx5/mlx5_core/mlx5_core.h
  releng/12.1/sys/dev/mlx5/mlx5_core/mlx5_diagnostics.c
  releng/12.1/sys/dev/mlx5/mlx5_core/mlx5_eq.c
  releng/12.1/sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c
  releng/12.1/sys/dev/mlx5/mlx5_core/mlx5_fw.c
  releng/12.1/sys/dev/mlx5/mlx5_core/mlx5_fwdump.c
  releng/12.1/sys/dev/mlx5/mlx5_core/mlx5_health.c
  releng/12.1/sys/dev/mlx5/mlx5_core/mlx5_main.c
  releng/12.1/sys/dev/mlx5/mlx5_core/mlx5_port.c
  releng/12.1/sys/dev/mlx5/mlx5_core/mlx5_vsc.c
  releng/12.1/sys/dev/mlx5/mlx5_en/en.h
  releng/12.1/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.c
  releng/12.1/sys/dev/mlx5/mlx5_en/mlx5_en_flow_table.c
  releng/12.1/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
  releng/12.1/sys/dev/mlx5/mlx5_en/mlx5_en_rl.c
  releng/12.1/sys/dev/mlx5/mlx5_en/mlx5_en_txrx.c
  releng/12.1/sys/dev/mlx5/mlx5_ib/mlx5_ib.h
  releng/12.1/sys/dev/mlx5/mlx5_ib/mlx5_ib_main.c
  releng/12.1/sys/dev/mlx5/mlx5_ib/mlx5_ib_qp.c
  releng/12.1/sys/dev/mlx5/mlx5_ifc.h
  releng/12.1/sys/dev/mlx5/mlx5io.h
  releng/12.1/sys/dev/mlx5/port.h
  releng/12.1/sys/modules/mlx5/Makefile
  releng/12.1/sys/modules/mlx5en/Makefile
  releng/12.1/usr.sbin/mlx5tool/mlx5tool.8
  releng/12.1/usr.sbin/mlx5tool/mlx5tool.c
Directory Properties:
  releng/12.1/   (props changed)

Modified: releng/12.1/share/man/man4/mlx5io.4
==============================================================================
--- releng/12.1/share/man/man4/mlx5io.4	Mon Oct  7 12:54:28 2019	(r353271)
+++ releng/12.1/share/man/man4/mlx5io.4	Mon Oct  7 13:13:06 2019	(r353272)
@@ -25,18 +25,18 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd May 7, 2019
+.Dd October 2, 2019
 .Dt mlx5io 4
 .Os
 .Sh NAME
 .Nm mlx5io
-.Nd IOCTL interface to manage Connect-X 4/5 Mellanox network adapters
+.Nd IOCTL interface to manage Connect-X 4/5/6 Mellanox network adapters
 .Sh SYNOPSIS
 .In dev/mlx5/mlx5io.h
 .Sh DESCRIPTION
 The
 .Nm
-interface is provided for management of the Connect-X 4 and 5 network adapters
+interface is provided for management of the Connect-X4, 5 and 6 network adapters
 in the aspects not covered by the generic network configuration,
 mostly related to the PCIe attachment and internal card working.
 Interface consists of the commands, which are passed by means of
@@ -147,6 +147,29 @@ Requests PCIe link-level reset on the device.
 The address of the device is specified by the
 .Vt struct mlx5_tool_addr
 structure, which should be passed as an argument.
+.It Dv MLX5_EEPROM_GET
+Fetch EEPROM information.
+The argument to the command should point to the input/output
+.Vt struct mlx5_eeprom_get
+structure where, the
+.Dv devaddr
+field specifies the address of the device.
+.Bd -literal
+struct mlx5_eeprom_get {
+        struct mlx5_tool_addr devaddr;
+        size_t eeprom_info_page_valid;
+        uint32_t *eeprom_info_buf;
+        size_t eeprom_info_out_len;
+};
+.Ed
+.Pp
+On successfull return, the
+.Dv eeprom_info_out_len
+field reports the length of the EEPROM information.
+.Dv eeprom_info_buf
+field contains the actual EEPROM information.
+.Dv eeprom_info_page_valid
+field reports the third page validity.
 .El
 .Sh FILES
 The

Modified: releng/12.1/sys/conf/files
==============================================================================
--- releng/12.1/sys/conf/files	Mon Oct  7 12:54:28 2019	(r353271)
+++ releng/12.1/sys/conf/files	Mon Oct  7 13:13:06 2019	(r353272)
@@ -4800,8 +4800,6 @@ dev/mlx5/mlx5_core/mlx5_fw.c			optional mlx5 pci	\
 	compile-with "${OFED_C}"
 dev/mlx5/mlx5_core/mlx5_fwdump.c		optional mlx5 pci	\
 	compile-with "${OFED_C}"
-dev/mlx5/mlx5_core/mlx5_fwdump_regmaps.c	optional mlx5 pci	\
-	compile-with "${OFED_C}"
 dev/mlx5/mlx5_core/mlx5_health.c		optional mlx5 pci	\
 	compile-with "${OFED_C}"
 dev/mlx5/mlx5_core/mlx5_mad.c			optional mlx5 pci	\
@@ -4810,6 +4808,8 @@ dev/mlx5/mlx5_core/mlx5_main.c			optional mlx5 pci	\
 	compile-with "${OFED_C}"
 dev/mlx5/mlx5_core/mlx5_mcg.c			optional mlx5 pci	\
 	compile-with "${OFED_C}"
+dev/mlx5/mlx5_core/mlx5_mpfs.c			optional mlx5 pci	\
+	compile-with "${OFED_C}"
 dev/mlx5/mlx5_core/mlx5_mr.c			optional mlx5 pci	\
 	compile-with "${OFED_C}"
 dev/mlx5/mlx5_core/mlx5_pagealloc.c		optional mlx5 pci	\
@@ -4852,6 +4852,8 @@ dev/mlx5/mlx5_en/mlx5_en_rx.c			optional mlx5en pci in
 dev/mlx5/mlx5_en/mlx5_en_rl.c			optional mlx5en pci inet inet6	\
 	compile-with "${OFED_C}"
 dev/mlx5/mlx5_en/mlx5_en_txrx.c			optional mlx5en pci inet inet6	\
+	compile-with "${OFED_C}"
+dev/mlx5/mlx5_en/mlx5_en_port_buffer.c		optional mlx5en pci inet inet6	\
 	compile-with "${OFED_C}"
 
 # crypto support

Modified: releng/12.1/sys/dev/mlx5/device.h
==============================================================================
--- releng/12.1/sys/dev/mlx5/device.h	Mon Oct  7 12:54:28 2019	(r353271)
+++ releng/12.1/sys/dev/mlx5/device.h	Mon Oct  7 13:13:06 2019	(r353272)
@@ -32,8 +32,10 @@
 #include <rdma/ib_verbs.h>
 #include <dev/mlx5/mlx5_ifc.h>
 
-#define FW_INIT_TIMEOUT_MILI 2000
-#define FW_INIT_WAIT_MS 2
+#define	FW_INIT_TIMEOUT_MILI		2000
+#define	FW_INIT_WAIT_MS			2
+#define	FW_PRE_INIT_TIMEOUT_MILI	120000
+#define	FW_INIT_WARN_MESSAGE_INTERVAL	20000
 
 #if defined(__LITTLE_ENDIAN)
 #define MLX5_SET_HOST_ENDIANNESS	0
@@ -537,7 +539,7 @@ enum {
 	MLX5_MODULE_STATUS_PLUGGED_ENABLED      = 0x1,
 	MLX5_MODULE_STATUS_UNPLUGGED            = 0x2,
 	MLX5_MODULE_STATUS_ERROR                = 0x3,
-	MLX5_MODULE_STATUS_PLUGGED_DISABLED     = 0x4,
+	MLX5_MODULE_STATUS_NUM			,
 };
 
 enum {
@@ -549,7 +551,7 @@ enum {
 	MLX5_MODULE_EVENT_ERROR_UNSUPPORTED_CABLE                     = 0x5,
 	MLX5_MODULE_EVENT_ERROR_HIGH_TEMPERATURE                      = 0x6,
 	MLX5_MODULE_EVENT_ERROR_CABLE_IS_SHORTED                      = 0x7,
-	MLX5_MODULE_EVENT_ERROR_PCIE_SYSTEM_POWER_SLOT_EXCEEDED       = 0xc,
+	MLX5_MODULE_EVENT_ERROR_NUM		                      ,
 };
 
 struct mlx5_eqe_port_module_event {
@@ -1052,6 +1054,9 @@ enum mlx5_mcam_feature_groups {
 
 #define MLX5_CAP_PCAM_FEATURE(mdev, fld) \
 	MLX5_GET(pcam_reg, (mdev)->caps.pcam, feature_cap_mask.enhanced_features.fld)
+
+#define	MLX5_CAP_PCAM_REG(mdev, reg) \
+	MLX5_GET(pcam_reg, (mdev)->caps.pcam, port_access_reg_cap_mask.regs_5000_to_507f.reg)
 
 #define MLX5_CAP_MCAM_FEATURE(mdev, fld) \
 	MLX5_GET(mcam_reg, (mdev)->caps.mcam, mng_feature_cap_mask.enhanced_features.fld)

Modified: releng/12.1/sys/dev/mlx5/diagnostics.h
==============================================================================
--- releng/12.1/sys/dev/mlx5/diagnostics.h	Mon Oct  7 12:54:28 2019	(r353271)
+++ releng/12.1/sys/dev/mlx5/diagnostics.h	Mon Oct  7 13:13:06 2019	(r353272)
@@ -32,6 +32,8 @@
 #define	MLX5_CORE_DIAGNOSTICS_STRUCT(n, s, t) s,
 #define	MLX5_CORE_DIAGNOSTICS_ENTRY(n, s, t) { #s, (t) },
 
+static MALLOC_DEFINE(M_MLX5_EEPROM, "MLX5EEPROM", "MLX5 EEPROM information");
+
 struct mlx5_core_diagnostics_entry {
 	const char *desc;
 	u16	counter_id;
@@ -127,6 +129,18 @@ union mlx5_core_general_diagnostics {
 extern const struct mlx5_core_diagnostics_entry
 	mlx5_core_general_diagnostics_table[MLX5_CORE_GENERAL_DIAGNOSTICS_NUM];
 
+struct mlx5_eeprom {
+	int	lock_bit;
+	int	i2c_addr;
+	int	page_num;
+	int	device_addr;
+	int	module_num;
+	int	len;
+	int	type;
+	int	page_valid;
+	u32	*data;
+};
+
 /* function prototypes */
 int mlx5_core_set_diagnostics_full(struct mlx5_core_dev *mdev,
 				   u8 enable_pci, u8 enable_general);
@@ -134,5 +148,8 @@ int mlx5_core_get_diagnostics_full(struct mlx5_core_de
 				   union mlx5_core_pci_diagnostics *ppci,
 				   union mlx5_core_general_diagnostics *pgen);
 int mlx5_core_supports_diagnostics(struct mlx5_core_dev *mdev, u16 counter_id);
+int mlx5_read_eeprom(struct mlx5_core_dev *dev, struct mlx5_eeprom *eeprom);
+int mlx5_get_eeprom_info(struct mlx5_core_dev *dev, struct mlx5_eeprom *eeprom);
+int mlx5_get_eeprom(struct mlx5_core_dev *dev, struct mlx5_eeprom *ee);
 
 #endif					/* MLX5_CORE_DIAGNOSTICS_H */

Modified: releng/12.1/sys/dev/mlx5/driver.h
==============================================================================
--- releng/12.1/sys/dev/mlx5/driver.h	Mon Oct  7 12:54:28 2019	(r353271)
+++ releng/12.1/sys/dev/mlx5/driver.h	Mon Oct  7 13:13:06 2019	(r353272)
@@ -84,10 +84,6 @@ enum {
 };
 
 enum {
-	MLX5_MAX_IRQ_NAME	= 32
-};
-
-enum {
 	MLX5_ATOMIC_MODE_OFF		= 16,
 	MLX5_ATOMIC_MODE_NONE		= 0 << MLX5_ATOMIC_MODE_OFF,
 	MLX5_ATOMIC_MODE_IB_COMP	= 1 << MLX5_ATOMIC_MODE_OFF,
@@ -130,24 +126,26 @@ enum {
 	MLX5_REG_QCAM		 = 0x4019,
 	MLX5_REG_DCBX_PARAM	 = 0x4020,
 	MLX5_REG_DCBX_APP	 = 0x4021,
-	MLX5_REG_PCAP		 = 0x5001,
 	MLX5_REG_FPGA_CAP	 = 0x4022,
 	MLX5_REG_FPGA_CTRL	 = 0x4023,
 	MLX5_REG_FPGA_ACCESS_REG = 0x4024,
 	MLX5_REG_FPGA_SHELL_CNTR = 0x4025,
+	MLX5_REG_PCAP		 = 0x5001,
+	MLX5_REG_PMLP		 = 0x5002,
 	MLX5_REG_PMTU		 = 0x5003,
 	MLX5_REG_PTYS		 = 0x5004,
 	MLX5_REG_PAOS		 = 0x5006,
 	MLX5_REG_PFCC		 = 0x5007,
 	MLX5_REG_PPCNT		 = 0x5008,
-	MLX5_REG_PMAOS		 = 0x5012,
 	MLX5_REG_PUDE		 = 0x5009,
 	MLX5_REG_PPTB		 = 0x500B,
 	MLX5_REG_PBMC		 = 0x500C,
+	MLX5_REG_PELC		 = 0x500E,
+	MLX5_REG_PVLC		 = 0x500F,
 	MLX5_REG_PMPE		 = 0x5010,
-	MLX5_REG_PELC		 = 0x500e,
-	MLX5_REG_PVLC		 = 0x500f,
-	MLX5_REG_PMLP		 = 0x5002,
+	MLX5_REG_PMAOS		 = 0x5012,
+	MLX5_REG_PPLM		 = 0x5023,
+	MLX5_REG_PBSR		 = 0x5038,
 	MLX5_REG_PCAM		 = 0x507f,
 	MLX5_REG_NODE_DESC	 = 0x6001,
 	MLX5_REG_HOST_ENDIANNESS = 0x7004,
@@ -556,10 +554,6 @@ struct mlx5_mr_table {
 	struct radix_tree_root	tree;
 };
 
-struct mlx5_irq_info {
-	char name[MLX5_MAX_IRQ_NAME];
-};
-
 #ifdef RATELIMIT
 struct mlx5_rl_entry {
 	u32			rate;
@@ -577,11 +571,15 @@ struct mlx5_rl_table {
 };
 #endif
 
+struct mlx5_pme_stats {
+	u64			status_counters[MLX5_MODULE_STATUS_NUM];
+	u64			error_counters[MLX5_MODULE_EVENT_ERROR_NUM];
+};
+
 struct mlx5_priv {
 	char			name[MLX5_MAX_NAME_LEN];
 	struct mlx5_eq_table	eq_table;
 	struct msix_entry	*msix_arr;
-	struct mlx5_irq_info	*irq_info;
 	struct mlx5_uuar_info	uuari;
 	MLX5_DECLARE_DOORBELL_LOCK(cq_uar_lock);
 	int			disable_irqs;
@@ -633,6 +631,7 @@ struct mlx5_priv {
 #ifdef RATELIMIT
 	struct mlx5_rl_table	rl_table;
 #endif
+	struct mlx5_pme_stats pme_stats;
 };
 
 enum mlx5_device_state {
@@ -701,7 +700,7 @@ struct mlx5_core_dev {
 	struct mlx5_flow_root_namespace *sniffer_rx_root_ns;
 	struct mlx5_flow_root_namespace *sniffer_tx_root_ns;
 	u32 num_q_counter_allocated[MLX5_INTERFACE_NUMBER];
-	const struct mlx5_crspace_regmap *dump_rege;
+	struct mlx5_crspace_regmap *dump_rege;
 	uint32_t *dump_data;
 	unsigned dump_size;
 	bool dump_valid;
@@ -717,6 +716,12 @@ struct mlx5_core_dev {
 		struct mlx5_rsvd_gids	reserved_gids;
 		atomic_t		roce_en;
 	} roce;
+
+	struct {
+		spinlock_t	spinlock;
+#define	MLX5_MPFS_TABLE_MAX 32
+		long		bitmap[BITS_TO_LONGS(MLX5_MPFS_TABLE_MAX)];
+	} mpfs;
 #ifdef CONFIG_MLX5_FPGA
 	struct mlx5_fpga_device	*fpga;
 #endif
@@ -1023,7 +1028,7 @@ struct mlx5_core_srq *mlx5_core_get_srq(struct mlx5_co
 void mlx5_cmd_comp_handler(struct mlx5_core_dev *dev, u64 vector, enum mlx5_cmd_mode mode);
 void mlx5_cq_event(struct mlx5_core_dev *dev, u32 cqn, int event_type);
 int mlx5_create_map_eq(struct mlx5_core_dev *dev, struct mlx5_eq *eq, u8 vecidx,
-		       int nent, u64 mask, const char *name, struct mlx5_uar *uar);
+		       int nent, u64 mask, struct mlx5_uar *uar);
 int mlx5_destroy_unmap_eq(struct mlx5_core_dev *dev, struct mlx5_eq *eq);
 int mlx5_start_eqs(struct mlx5_core_dev *dev);
 int mlx5_stop_eqs(struct mlx5_core_dev *dev);
@@ -1093,6 +1098,7 @@ int mlx5_vsc_find_cap(struct mlx5_core_dev *mdev);
 int mlx5_vsc_lock(struct mlx5_core_dev *mdev);
 void mlx5_vsc_unlock(struct mlx5_core_dev *mdev);
 int mlx5_vsc_set_space(struct mlx5_core_dev *mdev, u16 space);
+int mlx5_vsc_wait_on_flag(struct mlx5_core_dev *mdev, u32 expected);
 int mlx5_vsc_write(struct mlx5_core_dev *mdev, u32 addr, const u32 *data);
 int mlx5_vsc_read(struct mlx5_core_dev *mdev, u32 addr, u32 *data);
 int mlx5_vsc_lock_addr_space(struct mlx5_core_dev *mdev, u32 addr);

Modified: releng/12.1/sys/dev/mlx5/mlx5_core/mlx5_cmd.c
==============================================================================
--- releng/12.1/sys/dev/mlx5/mlx5_core/mlx5_cmd.c	Mon Oct  7 12:54:28 2019	(r353271)
+++ releng/12.1/sys/dev/mlx5/mlx5_core/mlx5_cmd.c	Mon Oct  7 13:13:06 2019	(r353272)
@@ -1489,7 +1489,9 @@ int mlx5_cmd_init(struct mlx5_core_dev *dev)
 	memset(cmd, 0, sizeof(*cmd));
 	cmd_if_rev = cmdif_rev_get(dev);
 	if (cmd_if_rev != CMD_IF_REV) {
-		device_printf((&dev->pdev->dev)->bsddev, "ERR: ""Driver cmdif rev(%d) differs from firmware's(%d)\n", CMD_IF_REV, cmd_if_rev);
+		mlx5_core_err(dev,
+		    "Driver cmdif rev(%d) differs from firmware's(%d)\n",
+		    CMD_IF_REV, cmd_if_rev);
 		return -EINVAL;
 	}
 
@@ -1501,13 +1503,16 @@ int mlx5_cmd_init(struct mlx5_core_dev *dev)
 	cmd->log_sz = cmd_l >> 4 & 0xf;
 	cmd->log_stride = cmd_l & 0xf;
 	if (1 << cmd->log_sz > MLX5_MAX_COMMANDS) {
-		device_printf((&dev->pdev->dev)->bsddev, "ERR: ""firmware reports too many outstanding commands %d\n", 1 << cmd->log_sz);
+		mlx5_core_err(dev,
+		    "firmware reports too many outstanding commands %d\n",
+		    1 << cmd->log_sz);
 		err = -EINVAL;
 		goto err_free_page;
 	}
 
 	if (cmd->log_sz + cmd->log_stride > MLX5_ADAPTER_PAGE_SHIFT) {
-		device_printf((&dev->pdev->dev)->bsddev, "ERR: ""command queue size overflow\n");
+		mlx5_core_err(dev,
+		    "command queue size overflow\n");
 		err = -EINVAL;
 		goto err_free_page;
 	}
@@ -1518,7 +1523,9 @@ int mlx5_cmd_init(struct mlx5_core_dev *dev)
 
 	cmd->cmdif_rev = ioread32be(&dev->iseg->cmdif_rev_fw_sub) >> 16;
 	if (cmd->cmdif_rev > CMD_IF_REV) {
-		device_printf((&dev->pdev->dev)->bsddev, "ERR: ""driver does not support command interface version. driver %d, firmware %d\n", CMD_IF_REV, cmd->cmdif_rev);
+		mlx5_core_err(dev,
+		    "driver does not support command interface version. driver %d, firmware %d\n",
+		    CMD_IF_REV, cmd->cmdif_rev);
 		err = -ENOTSUPP;
 		goto err_free_page;
 	}
@@ -1534,7 +1541,7 @@ int mlx5_cmd_init(struct mlx5_core_dev *dev)
 	cmd_h = (u32)((u64)(cmd->dma) >> 32);
 	cmd_l = (u32)(cmd->dma);
 	if (cmd_l & 0xfff) {
-		device_printf((&dev->pdev->dev)->bsddev, "ERR: ""invalid command queue address\n");
+		mlx5_core_err(dev, "invalid command queue address\n");
 		err = -ENOMEM;
 		goto err_free_page;
 	}
@@ -1551,7 +1558,7 @@ int mlx5_cmd_init(struct mlx5_core_dev *dev)
 
 	err = create_msg_cache(dev);
 	if (err) {
-		device_printf((&dev->pdev->dev)->bsddev, "ERR: ""failed to create command cache\n");
+		mlx5_core_err(dev, "failed to create command cache\n");
 		goto err_free_page;
 	}
 	return 0;

Modified: releng/12.1/sys/dev/mlx5/mlx5_core/mlx5_core.h
==============================================================================
--- releng/12.1/sys/dev/mlx5/mlx5_core/mlx5_core.h	Mon Oct  7 12:54:28 2019	(r353271)
+++ releng/12.1/sys/dev/mlx5/mlx5_core/mlx5_core.h	Mon Oct  7 13:13:06 2019	(r353272)
@@ -36,9 +36,9 @@
 
 #define DRIVER_NAME "mlx5_core"
 #ifndef DRIVER_VERSION
-#define DRIVER_VERSION "3.5.1"
+#define DRIVER_VERSION "3.5.2"
 #endif
-#define DRIVER_RELDATE "April 2019"
+#define DRIVER_RELDATE "September 2019"
 
 extern int mlx5_core_debug_mask;
 
@@ -53,16 +53,21 @@ do {									\
 		mlx5_core_dbg(dev, format, ##__VA_ARGS__);		\
 } while (0)
 
-#define mlx5_core_err(_dev, format, ...)					\
-	device_printf((&(_dev)->pdev->dev)->bsddev, "ERR: ""%s:%d:(pid %d): " format, \
+#define	mlx5_core_err(_dev, format, ...)					\
+	device_printf((_dev)->pdev->dev.bsddev, "ERR: ""%s:%d:(pid %d): " format, \
 		__func__, __LINE__, curthread->td_proc->p_pid, \
 		##__VA_ARGS__)
 
-#define mlx5_core_warn(_dev, format, ...)				\
-	device_printf((&(_dev)->pdev->dev)->bsddev, "WARN: ""%s:%d:(pid %d): " format, \
+#define	mlx5_core_warn(_dev, format, ...)				\
+	device_printf((_dev)->pdev->dev.bsddev, "WARN: ""%s:%d:(pid %d): " format, \
 		__func__, __LINE__, curthread->td_proc->p_pid, \
 		##__VA_ARGS__)
 
+#define	mlx5_core_info(_dev, format, ...)					\
+	device_printf((_dev)->pdev->dev.bsddev, "INFO: ""%s:%d:(pid %d): " format, \
+		__func__, __LINE__, curthread->td_proc->p_pid, \
+		##__VA_ARGS__)
+
 enum {
 	MLX5_CMD_DATA, /* print command payload only */
 	MLX5_CMD_TIME, /* print command execution time */
@@ -102,12 +107,10 @@ int mlx5_firmware_flash(struct mlx5_core_dev *dev, con
 void mlx5e_init(void);
 void mlx5e_cleanup(void);
 
-int mlx5_rename_eq(struct mlx5_core_dev *dev, int eq_ix, char *name);
-
 int mlx5_ctl_init(void);
 void mlx5_ctl_fini(void);
 void mlx5_fwdump_prep(struct mlx5_core_dev *mdev);
-void mlx5_fwdump(struct mlx5_core_dev *mdev);
+int mlx5_fwdump(struct mlx5_core_dev *mdev);
 void mlx5_fwdump_clean(struct mlx5_core_dev *mdev);
 
 struct mlx5_crspace_regmap {

Modified: releng/12.1/sys/dev/mlx5/mlx5_core/mlx5_diagnostics.c
==============================================================================
--- releng/12.1/sys/dev/mlx5/mlx5_core/mlx5_diagnostics.c	Mon Oct  7 12:54:28 2019	(r353271)
+++ releng/12.1/sys/dev/mlx5/mlx5_core/mlx5_diagnostics.c	Mon Oct  7 13:13:06 2019	(r353272)
@@ -26,7 +26,10 @@
  */
 
 #include <dev/mlx5/driver.h>
+#include <dev/mlx5/port.h>
 #include <dev/mlx5/diagnostics.h>
+#include <dev/mlx5/mlx5_core/mlx5_core.h>
+#include <net/sff8472.h>
 
 const struct mlx5_core_diagnostics_entry
 	mlx5_core_pci_diagnostics_table[
@@ -284,3 +287,156 @@ int mlx5_core_supports_diagnostics(struct mlx5_core_de
 	}
 	return 0;			/* not supported counter */
 }
+
+/*
+ * Read the first three bytes of the eeprom in order to get the needed info
+ * for the whole reading.
+ * Byte 0 - Identifier byte
+ * Byte 1 - Revision byte
+ * Byte 2 - Status byte
+ */
+int
+mlx5_get_eeprom_info(struct mlx5_core_dev *dev, struct mlx5_eeprom *eeprom)
+{
+	u32 data = 0;
+	int size_read = 0;
+	int ret;
+
+	ret = mlx5_query_module_num(dev, &eeprom->module_num);
+	if (ret) {
+		mlx5_core_err(dev, "Failed query module error=%d\n", ret);
+		return (-ret);
+	}
+
+	/* Read the first three bytes to get Identifier, Revision and Status */
+	ret = mlx5_query_eeprom(dev, eeprom->i2c_addr, eeprom->page_num,
+	    eeprom->device_addr, MLX5_EEPROM_INFO_BYTES, eeprom->module_num, &data,
+	    &size_read);
+	if (ret) {
+		mlx5_core_err(dev,
+		    "Failed query EEPROM module error=0x%x\n", ret);
+		return (-ret);
+	}
+
+	switch (data & MLX5_EEPROM_IDENTIFIER_BYTE_MASK) {
+	case SFF_8024_ID_QSFP:
+		eeprom->type = MLX5_ETH_MODULE_SFF_8436;
+		eeprom->len = MLX5_ETH_MODULE_SFF_8436_LEN;
+		break;
+	case SFF_8024_ID_QSFPPLUS:
+	case SFF_8024_ID_QSFP28:
+		if ((data & MLX5_EEPROM_IDENTIFIER_BYTE_MASK) == SFF_8024_ID_QSFP28 ||
+		    ((data & MLX5_EEPROM_REVISION_ID_BYTE_MASK) >> 8) >= 0x3) {
+			eeprom->type = MLX5_ETH_MODULE_SFF_8636;
+			eeprom->len = MLX5_ETH_MODULE_SFF_8636_LEN;
+		} else {
+			eeprom->type = MLX5_ETH_MODULE_SFF_8436;
+			eeprom->len = MLX5_ETH_MODULE_SFF_8436_LEN;
+		}
+		if ((data & MLX5_EEPROM_PAGE_3_VALID_BIT_MASK) == 0)
+			eeprom->page_valid = 1;
+		break;
+	case SFF_8024_ID_SFP:
+		eeprom->type = MLX5_ETH_MODULE_SFF_8472;
+		eeprom->len = MLX5_ETH_MODULE_SFF_8472_LEN;
+		break;
+	default:
+		mlx5_core_err(dev, "Not recognized cable type = 0x%x(%s)\n",
+		    data & MLX5_EEPROM_IDENTIFIER_BYTE_MASK,
+		    sff_8024_id[data & MLX5_EEPROM_IDENTIFIER_BYTE_MASK]);
+		return (EINVAL);
+	}
+	return (0);
+}
+
+/* Read both low and high pages of the eeprom */
+int
+mlx5_get_eeprom(struct mlx5_core_dev *dev, struct mlx5_eeprom *ee)
+{
+	int size_read = 0;
+	int ret;
+
+	if (ee->len == 0)
+		return (EINVAL);
+
+	/* Read low page of the eeprom */
+	while (ee->device_addr < ee->len) {
+		ret = mlx5_query_eeprom(dev, ee->i2c_addr, ee->page_num, ee->device_addr,
+		    ee->len - ee->device_addr, ee->module_num,
+		    ee->data + (ee->device_addr / 4), &size_read);
+		if (ret) {
+			mlx5_core_err(dev,
+			    "Failed reading EEPROM, error = 0x%02x\n", ret);
+			return (-ret);
+		}
+		ee->device_addr += size_read;
+	}
+
+	/* Read high page of the eeprom */
+	if (ee->page_valid == 1) {
+		ee->device_addr = MLX5_EEPROM_HIGH_PAGE_OFFSET;
+		ee->page_num = MLX5_EEPROM_HIGH_PAGE;
+		size_read = 0;
+		while (ee->device_addr < MLX5_EEPROM_PAGE_LENGTH) {
+			ret = mlx5_query_eeprom(dev, ee->i2c_addr, ee->page_num,
+			    ee->device_addr, MLX5_EEPROM_PAGE_LENGTH - ee->device_addr,
+			    ee->module_num, ee->data + (ee->len / 4) +
+			    ((ee->device_addr - MLX5_EEPROM_HIGH_PAGE_OFFSET) / 4),
+			    &size_read);
+			if (ret) {
+				mlx5_core_err(dev,
+				    "Failed reading EEPROM, error = 0x%02x\n",
+				    ret);
+				return (-ret);
+			}
+			ee->device_addr += size_read;
+		}
+	}
+	return (0);
+}
+
+/*
+ * Read cable EEPROM module information by first inspecting the first
+ * three bytes to get the initial information for a whole reading.
+ * Information will be printed to dmesg.
+ */
+int
+mlx5_read_eeprom(struct mlx5_core_dev *dev, struct mlx5_eeprom *eeprom)
+{
+	int error;
+
+	eeprom->i2c_addr = MLX5_I2C_ADDR_LOW;
+	eeprom->device_addr = 0;
+	eeprom->page_num = MLX5_EEPROM_LOW_PAGE;
+	eeprom->page_valid = 0;
+
+	/* Read three first bytes to get important info */
+	error = mlx5_get_eeprom_info(dev, eeprom);
+	if (error) {
+		mlx5_core_err(dev,
+		    "Failed reading EEPROM initial information\n");
+		return (error);
+	}
+	/*
+	 * Allocate needed length buffer and additional space for
+	 * page 0x03
+	 */
+	eeprom->data = malloc(eeprom->len + MLX5_EEPROM_PAGE_LENGTH,
+	    M_MLX5_EEPROM, M_WAITOK | M_ZERO);
+
+	/* Read the whole eeprom information */
+	error = mlx5_get_eeprom(dev, eeprom);
+	if (error) {
+		mlx5_core_err(dev, "Failed reading EEPROM\n");
+		error = 0;
+		/*
+		 * Continue printing partial information in case of
+		 * an error
+		 */
+	}
+	free(eeprom->data, M_MLX5_EEPROM);
+
+	return (error);
+}
+
+

Modified: releng/12.1/sys/dev/mlx5/mlx5_core/mlx5_eq.c
==============================================================================
--- releng/12.1/sys/dev/mlx5/mlx5_core/mlx5_eq.c	Mon Oct  7 12:54:28 2019	(r353271)
+++ releng/12.1/sys/dev/mlx5/mlx5_core/mlx5_eq.c	Mon Oct  7 13:13:06 2019	(r353272)
@@ -219,7 +219,7 @@ mlx5_temp_warning_event(struct mlx5_core_dev *dev, str
 {
 
 	mlx5_core_warn(dev,
-	    "High temperature on sensors with bit set %#jx %#jx",
+	    "High temperature on sensors with bit set %#jx %#jx\n",
 	    (uintmax_t)be64_to_cpu(eqe->data.temp_warning.sensor_warning_msb),
 	    (uintmax_t)be64_to_cpu(eqe->data.temp_warning.sensor_warning_lsb));
 }
@@ -415,7 +415,7 @@ static void init_eq_buf(struct mlx5_eq *eq)
 }
 
 int mlx5_create_map_eq(struct mlx5_core_dev *dev, struct mlx5_eq *eq, u8 vecidx,
-		       int nent, u64 mask, const char *name, struct mlx5_uar *uar)
+		       int nent, u64 mask, struct mlx5_uar *uar)
 {
 	u32 out[MLX5_ST_SZ_DW(create_eq_out)] = {0};
 	struct mlx5_priv *priv = &dev->priv;
@@ -463,10 +463,8 @@ int mlx5_create_map_eq(struct mlx5_core_dev *dev, stru
 	eq->irqn = vecidx;
 	eq->dev = dev;
 	eq->doorbell = uar->map + MLX5_EQ_DOORBEL_OFFSET;
-	snprintf(priv->irq_info[vecidx].name, MLX5_MAX_IRQ_NAME, "%s at pci:%s",
-		 name, pci_name(dev->pdev));
 	err = request_irq(priv->msix_arr[vecidx].vector, mlx5_msix_handler, 0,
-			  priv->irq_info[vecidx].name, eq);
+			  "mlx5_core", eq);
 	if (err)
 		goto err_eq;
 #ifdef RSS
@@ -568,7 +566,7 @@ int mlx5_start_eqs(struct mlx5_core_dev *dev)
 
 	err = mlx5_create_map_eq(dev, &table->cmd_eq, MLX5_EQ_VEC_CMD,
 				 MLX5_NUM_CMD_EQE, 1ull << MLX5_EVENT_TYPE_CMD,
-				 "mlx5_cmd_eq", &dev->priv.uuari.uars[0]);
+				 &dev->priv.uuari.uars[0]);
 	if (err) {
 		mlx5_core_warn(dev, "failed to create cmd EQ %d\n", err);
 		return err;
@@ -578,7 +576,7 @@ int mlx5_start_eqs(struct mlx5_core_dev *dev)
 
 	err = mlx5_create_map_eq(dev, &table->async_eq, MLX5_EQ_VEC_ASYNC,
 				 MLX5_NUM_ASYNC_EQE, async_event_mask,
-				 "mlx5_async_eq", &dev->priv.uuari.uars[0]);
+				 &dev->priv.uuari.uars[0]);
 	if (err) {
 		mlx5_core_warn(dev, "failed to create async EQ %d\n", err);
 		goto err1;
@@ -587,7 +585,7 @@ int mlx5_start_eqs(struct mlx5_core_dev *dev)
 	err = mlx5_create_map_eq(dev, &table->pages_eq,
 				 MLX5_EQ_VEC_PAGES,
 				 /* TODO: sriov max_vf + */ 1,
-				 1 << MLX5_EVENT_TYPE_PAGE_REQUEST, "mlx5_pages_eq",
+				 1 << MLX5_EVENT_TYPE_PAGE_REQUEST,
 				 &dev->priv.uuari.uars[0]);
 	if (err) {
 		mlx5_core_warn(dev, "failed to create pages EQ %d\n", err);
@@ -641,9 +639,9 @@ static const char *mlx5_port_module_event_error_type_t
 {
 	switch (error_type) {
 	case MLX5_MODULE_EVENT_ERROR_POWER_BUDGET_EXCEEDED:
-		return "Power Budget Exceeded";
+		return "Power budget exceeded";
 	case MLX5_MODULE_EVENT_ERROR_LONG_RANGE_FOR_NON_MLNX_CABLE_MODULE:
-		return "Long Range for non MLNX cable/module";
+		return "Long Range for non MLNX cable";
 	case MLX5_MODULE_EVENT_ERROR_BUS_STUCK:
 		return "Bus stuck(I2C or data shorted)";
 	case MLX5_MODULE_EVENT_ERROR_NO_EEPROM_RETRY_TIMEOUT:
@@ -651,18 +649,11 @@ static const char *mlx5_port_module_event_error_type_t
 	case MLX5_MODULE_EVENT_ERROR_ENFORCE_PART_NUMBER_LIST:
 		return "Enforce part number list";
 	case MLX5_MODULE_EVENT_ERROR_UNSUPPORTED_CABLE:
-		return "Unsupported Cable";
+		return "Unknown identifier";
 	case MLX5_MODULE_EVENT_ERROR_HIGH_TEMPERATURE:
 		return "High Temperature";
 	case MLX5_MODULE_EVENT_ERROR_CABLE_IS_SHORTED:
-		return "Cable is shorted";
-	case MLX5_MODULE_EVENT_ERROR_PCIE_SYSTEM_POWER_SLOT_EXCEEDED:
-		return "One or more network ports have been powered "
-			"down due to insufficient/unadvertised power on "
-			"the PCIe slot. Please refer to the card's user "
-			"manual for power specifications or contact "
-			"Mellanox support.";
-
+		return "Bad or shorted cable/module";
 	default:
 		return "Unknown error type";
 	}
@@ -682,35 +673,42 @@ static void mlx5_port_module_event(struct mlx5_core_de
 	unsigned int module_status;
 	unsigned int error_type;
 	struct mlx5_eqe_port_module_event *module_event_eqe;
-	struct pci_dev *pdev = dev->pdev;
 
 	module_event_eqe = &eqe->data.port_module_event;
 
 	module_num = (unsigned int)module_event_eqe->module;
 	module_status = (unsigned int)module_event_eqe->module_status &
-			PORT_MODULE_EVENT_MODULE_STATUS_MASK;
+	    PORT_MODULE_EVENT_MODULE_STATUS_MASK;
 	error_type = (unsigned int)module_event_eqe->error_type &
-		     PORT_MODULE_EVENT_ERROR_TYPE_MASK;
+	    PORT_MODULE_EVENT_ERROR_TYPE_MASK;
 
+	if (module_status < MLX5_MODULE_STATUS_NUM)
+		dev->priv.pme_stats.status_counters[module_status]++;
 	switch (module_status) {
 	case MLX5_MODULE_STATUS_PLUGGED_ENABLED:
-		device_printf((&pdev->dev)->bsddev, "INFO: ""Module %u, status: plugged and enabled\n", module_num);
+		mlx5_core_info(dev,
+		    "Module %u, status: plugged and enabled\n",
+		    module_num);
 		break;
 
 	case MLX5_MODULE_STATUS_UNPLUGGED:
-		device_printf((&pdev->dev)->bsddev, "INFO: ""Module %u, status: unplugged\n", module_num);
+		mlx5_core_info(dev,
+		    "Module %u, status: unplugged\n", module_num);
 		break;
 
 	case MLX5_MODULE_STATUS_ERROR:
-		device_printf((&pdev->dev)->bsddev, "INFO: ""Module %u, status: error, %s\n", module_num, mlx5_port_module_event_error_type_to_string(error_type));
+		mlx5_core_err(dev,
+		    "Module %u, status: error, %s (%d)\n",
+		    module_num,
+		    mlx5_port_module_event_error_type_to_string(error_type),
+		    error_type);
+		if (error_type < MLX5_MODULE_EVENT_ERROR_NUM)
+			dev->priv.pme_stats.error_counters[error_type]++;
 		break;
 
-	case MLX5_MODULE_STATUS_PLUGGED_DISABLED:
-		device_printf((&pdev->dev)->bsddev, "INFO: ""Module %u, status: plugged but disabled\n", module_num);
-		break;
-
 	default:
-		device_printf((&pdev->dev)->bsddev, "INFO: ""Module %u, unknown status\n", module_num);
+		mlx5_core_info(dev,
+		    "Module %u, unknown status %d\n", module_num, module_status);
 	}
 	/* store module status */
 	if (module_num < MLX5_MAX_PORTS)

Modified: releng/12.1/sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c
==============================================================================
--- releng/12.1/sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c	Mon Oct  7 12:54:28 2019	(r353271)
+++ releng/12.1/sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c	Mon Oct  7 13:13:06 2019	(r353272)
@@ -139,7 +139,6 @@ static struct mlx5_flow_root_namespace *find_root(stru
 		node = parent;
 
 	if (node->type != FS_TYPE_NAMESPACE) {
-		printf("mlx5_core: WARN: ""mlx5: flow steering node %s is not in tree or garbaged\n", node->name);
 		return NULL;
 	}
 
@@ -477,7 +476,7 @@ static int connect_prev_fts(struct fs_prio *locked_pri
 		err = fs_set_star_rule(dev, iter, next_ft);
 		if (err) {
 			mlx5_core_warn(dev,
-				       "mlx5: flow steering can't connect prev and next\n");
+			    "mlx5: flow steering can't connect prev and next\n");
 			goto unlock;
 		} else {
 			/* Assume ft's prio is locked */
@@ -605,7 +604,9 @@ static void destroy_star_rule(struct mlx5_flow_table *
 
 	root = find_root(&prio->base);
 	if (!root)
-		printf("mlx5_core: ERR: ""mlx5: flow steering failed to find root of priority %s", prio->base.name);
+		mlx5_core_err(dev,
+		    "flow steering failed to find root of priority %s",
+		    prio->base.name);
 
 	/* In order to ensure atomic deletion, first update
 	 * prev ft to point on the next ft.
@@ -765,11 +766,13 @@ static struct mlx5_flow_table *_create_ft_common(struc
 	int log_table_sz;
 	int ft_size;
 	char gen_name[20];
-	struct mlx5_flow_root_namespace *root =
-		find_root(&ns->base);
+	struct mlx5_flow_root_namespace *root = find_root(&ns->base);
+	struct mlx5_core_dev *dev = fs_get_dev(&ns->base);
 
 	if (!root) {
-		printf("mlx5_core: ERR: ""mlx5: flow steering failed to find root of namespace %s", ns->base.name);
+		mlx5_core_err(dev,
+		    "flow steering failed to find root of namespace %s",
+		    ns->base.name);
 		return ERR_PTR(-ENODEV);
 	}
 
@@ -987,12 +990,16 @@ int mlx5_destroy_flow_table(struct mlx5_flow_table *ft
 	struct fs_prio *prio;
 	struct mlx5_flow_root_namespace *root;
 	bool is_shared_prio;
+	struct mlx5_core_dev *dev;
 
 	fs_get_parent(prio, ft);
 	root = find_root(&prio->base);
+	dev = fs_get_dev(&prio->base);
 
 	if (!root) {
-		printf("mlx5_core: ERR: ""mlx5: flow steering failed to find root of priority %s", prio->base.name);
+		mlx5_core_err(dev,
+		    "flow steering failed to find root of priority %s",
+		    prio->base.name);
 		return -ENODEV;
 	}
 

Modified: releng/12.1/sys/dev/mlx5/mlx5_core/mlx5_fw.c
==============================================================================
--- releng/12.1/sys/dev/mlx5/mlx5_core/mlx5_fw.c	Mon Oct  7 12:54:28 2019	(r353271)
+++ releng/12.1/sys/dev/mlx5/mlx5_core/mlx5_fw.c	Mon Oct  7 13:13:06 2019	(r353272)
@@ -324,7 +324,7 @@ int mlx5_cmd_fast_teardown_hca(struct mlx5_core_dev *d
 	} while (!time_after(jiffies, end));
 
 	if (mlx5_get_nic_state(dev) != MLX5_NIC_IFC_DISABLED) {
-		dev_err(&dev->pdev->dev, "NIC IFC still %d after %ums.\n",
+		mlx5_core_err(dev, "NIC IFC still %d after %ums.\n",
 			mlx5_get_nic_state(dev), delay_ms);
 		return -EIO;
 	}

Modified: releng/12.1/sys/dev/mlx5/mlx5_core/mlx5_fwdump.c
==============================================================================
--- releng/12.1/sys/dev/mlx5/mlx5_core/mlx5_fwdump.c	Mon Oct  7 12:54:28 2019	(r353271)
+++ releng/12.1/sys/dev/mlx5/mlx5_core/mlx5_fwdump.c	Mon Oct  7 13:13:06 2019	(r353272)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2018, Mellanox Technologies, Ltd.  All rights reserved.
+ * Copyright (c) 2018, 2019 Mellanox Technologies, Ltd.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -32,13 +32,11 @@ __FBSDID("$FreeBSD$");
 #include <sys/fcntl.h>
 #include <dev/mlx5/driver.h>
 #include <dev/mlx5/device.h>
+#include <dev/mlx5/port.h>
 #include <dev/mlx5/mlx5_core/mlx5_core.h>
 #include <dev/mlx5/mlx5io.h>
+#include <dev/mlx5/diagnostics.h>
 
-extern const struct mlx5_crspace_regmap mlx5_crspace_regmap_mt4117[];
-extern const struct mlx5_crspace_regmap mlx5_crspace_regmap_mt4115[];
-extern const struct mlx5_crspace_regmap mlx5_crspace_regmap_connectx5[];
-
 static MALLOC_DEFINE(M_MLX5_DUMP, "MLX5DUMP", "MLX5 Firmware dump");
 
 static unsigned
@@ -64,52 +62,113 @@ mlx5_fwdump_destroy_dd(struct mlx5_core_dev *mdev)
 void
 mlx5_fwdump_prep(struct mlx5_core_dev *mdev)
 {
-	int error;
+	device_t dev;
+	int error, vsc_addr;
+	unsigned i, sz;
+	u32 addr, in, out, next_addr;
 
 	mdev->dump_data = NULL;
 	error = mlx5_vsc_find_cap(mdev);
 	if (error != 0) {
 		/* Inability to create a firmware dump is not fatal. */
-		device_printf((&mdev->pdev->dev)->bsddev, "WARN: "
-		    "mlx5_fwdump_prep failed %d\n", error);
+		mlx5_core_warn(mdev,
+		    "Failed to find vendor-specific capability, error %d\n",
+		    error);
 		return;
 	}
-	switch (pci_get_device(mdev->pdev->dev.bsddev)) {
-	case 0x1013:
-		mdev->dump_rege = mlx5_crspace_regmap_mt4115;
-		break;
-	case 0x1015:
-		mdev->dump_rege = mlx5_crspace_regmap_mt4117;
-		break;
-	case 0x1017:
-	case 0x1019:
-		mdev->dump_rege = mlx5_crspace_regmap_connectx5;
-		break;
-	default:
-		return; /* silently fail, do not prevent driver attach */
+	error = mlx5_vsc_lock(mdev);
+	if (error != 0)
+		return;
+	error = mlx5_vsc_set_space(mdev, MLX5_VSC_DOMAIN_SCAN_CRSPACE);
+	if (error != 0) {
+		mlx5_core_warn(mdev, "VSC scan space is not supported\n");
+		goto unlock_vsc;
 	}
+	dev = mdev->pdev->dev.bsddev;
+	vsc_addr = mdev->vsc_addr;
+	if (vsc_addr == 0) {
+		mlx5_core_warn(mdev, "Cannot read VSC, no address\n");
+		goto unlock_vsc;
+	}
+
+	in = 0;
+	for (sz = 1, addr = 0;;) {
+		MLX5_VSC_SET(vsc_addr, &in, address, addr);
+		pci_write_config(dev, vsc_addr + MLX5_VSC_ADDR_OFFSET, in, 4);
+		error = mlx5_vsc_wait_on_flag(mdev, 1);
+		if (error != 0) {
+			mlx5_core_warn(mdev,
+		    "Failed waiting for read complete flag, error %d addr %#x\n",
+			    error, addr);
+			goto unlock_vsc;
+		}
+		pci_read_config(dev, vsc_addr + MLX5_VSC_DATA_OFFSET, 4);
+		out = pci_read_config(dev, vsc_addr + MLX5_VSC_ADDR_OFFSET, 4);
+		next_addr = MLX5_VSC_GET(vsc_addr, &out, address);
+		if (next_addr == 0 || next_addr == addr)
+			break;
+		if (next_addr != addr + 4)
+			sz++;
+		addr = next_addr;
+	}
+	mdev->dump_rege = malloc(sz * sizeof(struct mlx5_crspace_regmap),
+	    M_MLX5_DUMP, M_WAITOK | M_ZERO);
+
+	for (i = 0, addr = 0;;) {
+		MPASS(i < sz);
+		mdev->dump_rege[i].cnt++;
+		MLX5_VSC_SET(vsc_addr, &in, address, addr);
+		pci_write_config(dev, vsc_addr + MLX5_VSC_ADDR_OFFSET, in, 4);
+		error = mlx5_vsc_wait_on_flag(mdev, 1);
+		if (error != 0) {
+			mlx5_core_warn(mdev,
+		    "Failed waiting for read complete flag, error %d addr %#x\n",
+			    error, addr);
+			free(mdev->dump_rege, M_MLX5_DUMP);
+			mdev->dump_rege = NULL;
+			goto unlock_vsc;
+		}
+		pci_read_config(dev, vsc_addr + MLX5_VSC_DATA_OFFSET, 4);
+		out = pci_read_config(dev, vsc_addr + MLX5_VSC_ADDR_OFFSET, 4);
+		next_addr = MLX5_VSC_GET(vsc_addr, &out, address);
+		if (next_addr == 0 || next_addr == addr)
+			break;
+		if (next_addr != addr + 4)
+			mdev->dump_rege[++i].addr = next_addr;
+		addr = next_addr;
+	}
+	KASSERT(i + 1 == sz,
+	    ("inconsistent hw crspace reads: sz %u i %u addr %#lx",
+	    sz, i, (unsigned long)addr));
+
 	mdev->dump_size = mlx5_fwdump_getsize(mdev->dump_rege);
 	mdev->dump_data = malloc(mdev->dump_size * sizeof(uint32_t),
 	    M_MLX5_DUMP, M_WAITOK | M_ZERO);
 	mdev->dump_valid = false;
 	mdev->dump_copyout = false;
+
+unlock_vsc:
+	mlx5_vsc_unlock(mdev);
 }
 
-void
+int
 mlx5_fwdump(struct mlx5_core_dev *mdev)
 {
 	const struct mlx5_crspace_regmap *r;
 	uint32_t i, ri;
 	int error;
 
-	dev_info(&mdev->pdev->dev, "Issuing FW dump\n");
+	mlx5_core_info(mdev, "Issuing FW dump\n");
 	mtx_lock(&mdev->dump_lock);
-	if (mdev->dump_data == NULL)
+	if (mdev->dump_data == NULL) {
+		error = EIO;
 		goto failed;
+	}
 	if (mdev->dump_valid) {
 		/* only one dump */
-		dev_warn(&mdev->pdev->dev,
+		mlx5_core_warn(mdev,
 		    "Only one FW dump can be captured aborting FW dump\n");
+		error = EEXIST;
 		goto failed;
 	}
 
@@ -134,6 +193,7 @@ unlock_vsc:
 	mlx5_vsc_unlock(mdev);
 failed:
 	mtx_unlock(&mdev->dump_lock);
+	return (error);
 }
 
 void
@@ -145,6 +205,7 @@ mlx5_fwdump_clean(struct mlx5_core_dev *mdev)
 		msleep(&mdev->dump_copyout, &mdev->dump_lock, 0, "mlx5fwc", 0);
 	mlx5_fwdump_destroy_dd(mdev);
 	mtx_unlock(&mdev->dump_lock);
+	free(mdev->dump_rege, M_MLX5_DUMP);
 }
 
 static int
@@ -254,6 +315,54 @@ mlx5_fw_reset(struct mlx5_core_dev *mdev)
 }
 
 static int
+mlx5_eeprom_copyout(struct mlx5_core_dev *dev, struct mlx5_eeprom_get *eeprom_info)
+{
+	struct mlx5_eeprom eeprom;
+	int error;
+
+	eeprom.i2c_addr = MLX5_I2C_ADDR_LOW;
+	eeprom.device_addr = 0;
+	eeprom.page_num = MLX5_EEPROM_LOW_PAGE;
+	eeprom.page_valid = 0;
+
+	/* Read three first bytes to get important info */
+	error = mlx5_get_eeprom_info(dev, &eeprom);
+	if (error != 0) {
+		mlx5_core_err(dev,
+		    "Failed reading EEPROM initial information\n");
+		return (error);
+	}
+	eeprom_info->eeprom_info_page_valid = eeprom.page_valid;
+	eeprom_info->eeprom_info_out_len = eeprom.len;
+
+	if (eeprom_info->eeprom_info_buf == NULL)
+		return (0);
+	/*
+	 * Allocate needed length buffer and additional space for
+	 * page 0x03
+	 */
+	eeprom.data = malloc(eeprom.len + MLX5_EEPROM_PAGE_LENGTH,
+	    M_MLX5_EEPROM, M_WAITOK | M_ZERO);
+

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***


More information about the svn-src-releng mailing list