Blame SOURCES/9003-add-pci_get_dsn.patch

2eb987
Index: src/drivers/net/ethernet/intel/ice/ice_backport_compat.h
2eb987
===================================================================
2eb987
--- src.orig/drivers/net/ethernet/intel/ice/ice_backport_compat.h	2020-08-27 19:25:24.269152253 +0200
2eb987
+++ src/drivers/net/ethernet/intel/ice/ice_backport_compat.h	2020-08-27 23:44:51.384511148 +0200
2eb987
@@ -1,5 +1,40 @@
2eb987
 #ifndef ICE_BACKPORT_COMPAT_H
2eb987
 #define ICE_BACKPORT_COMPAT_H
2eb987
 
2eb987
+#include <linux/pci.h>
2eb987
+
2eb987
+/**
2eb987
+ * pci_get_dsn - Read and return the 8-byte Device Serial Number
2eb987
+ * @dev: PCI device to query
2eb987
+ *
2eb987
+ * Looks up the PCI_EXT_CAP_ID_DSN and reads the 8 bytes of the Device Serial
2eb987
+ * Number.
2eb987
+ *
2eb987
+ * Returns the DSN, or zero if the capability does not exist.
2eb987
+ */
2eb987
+static inline u64 pci_get_dsn(struct pci_dev *dev)
2eb987
+{
2eb987
+	u32 dword;
2eb987
+	u64 dsn;
2eb987
+	int pos;
2eb987
+
2eb987
+	pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_DSN);
2eb987
+	if (!pos)
2eb987
+		return 0;
2eb987
+
2eb987
+	/*
2eb987
+	 * The Device Serial Number is two dwords offset 4 bytes from the
2eb987
+	 * capability position. The specification says that the first dword is
2eb987
+	 * the lower half, and the second dword is the upper half.
2eb987
+	 */
2eb987
+	pos += 4;
2eb987
+	pci_read_config_dword(dev, pos, &dword);
2eb987
+	dsn = (u64)dword;
2eb987
+	pci_read_config_dword(dev, pos + 4, &dword);
2eb987
+	dsn |= ((u64)dword) << 32;
2eb987
+
2eb987
+	return dsn;
2eb987
+}
2eb987
+
2eb987
 
2eb987
 #endif /* ICE_BACKPORT_COMPAT_H */
2eb987
Index: src/drivers/net/ethernet/intel/ice/ice_main.c
2eb987
===================================================================
2eb987
--- src.orig/drivers/net/ethernet/intel/ice/ice_main.c	2020-08-27 19:25:24.221152207 +0200
2eb987
+++ src/drivers/net/ethernet/intel/ice/ice_main.c	2020-08-27 23:41:52.364425785 +0200
2eb987
@@ -13,6 +13,8 @@
2eb987
 #include "ice_dcb_nl.h"
2eb987
 #include "ice_devlink.h"
2eb987
 
2eb987
+#include "ice_backport_compat.h"
2eb987
+
2eb987
 #define DRV_VERSION_MAJOR 0
2eb987
 #define DRV_VERSION_MINOR 8
2eb987
 #define DRV_VERSION_BUILD 2
2eb987
Index: src/drivers/net/ethernet/intel/ice/ice_devlink.c
2eb987
===================================================================
2eb987
--- src.orig/drivers/net/ethernet/intel/ice/ice_devlink.c	2020-08-27 19:25:23.959151957 +0200
2eb987
+++ src/drivers/net/ethernet/intel/ice/ice_devlink.c	2020-08-27 19:25:24.319152301 +0200
2eb987
@@ -5,6 +5,8 @@
2eb987
 #include "ice_lib.h"
2eb987
 #include "ice_devlink.h"
2eb987
 
2eb987
+#include "ice_backport_compat.h"
2eb987
+
2eb987
 static int ice_info_get_dsn(struct ice_pf *pf, char *buf, size_t len)
2eb987
 {
2eb987
 	u8 dsn[8];