Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 18 May 2020 09:34:41 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r361200 - stable/11/sys/compat/linuxkpi/common/include/linux
Message-ID:  <202005180934.04I9YfgG071209@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Mon May 18 09:34:41 2020
New Revision: 361200
URL: https://svnweb.freebsd.org/changeset/base/361200

Log:
  MFC r360532:
  Implement more PCI-express bandwidth functions in the LinuxKPI.
  
  Submitted by:	ashafer_badland.io (Austin Shafer)
  Sponsored by:	Mellanox Technologies

Modified:
  stable/11/sys/compat/linuxkpi/common/include/linux/pci.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/compat/linuxkpi/common/include/linux/pci.h
==============================================================================
--- stable/11/sys/compat/linuxkpi/common/include/linux/pci.h	Mon May 18 09:32:56 2020	(r361199)
+++ stable/11/sys/compat/linuxkpi/common/include/linux/pci.h	Mon May 18 09:34:41 2020	(r361200)
@@ -970,4 +970,45 @@ pcie_get_width_cap(struct pci_dev *dev)
 	return (PCIE_LNK_WIDTH_UNKNOWN);
 }
 
+static inline int
+pcie_get_mps(struct pci_dev *dev)
+{
+	return (pci_get_max_payload(dev->dev.bsddev));
+}
+
+static inline uint32_t
+PCIE_SPEED2MBS_ENC(enum pci_bus_speed spd)
+{
+
+	switch(spd) {
+	case PCIE_SPEED_16_0GT:
+		return (16000 * 128 / 130);
+	case PCIE_SPEED_8_0GT:
+		return (8000 * 128 / 130);
+	case PCIE_SPEED_5_0GT:
+		return (5000 * 8 / 10);
+	case PCIE_SPEED_2_5GT:
+		return (2500 * 8 / 10);
+	default:
+		return (0);
+	}
+}
+
+static inline uint32_t
+pcie_bandwidth_available(struct pci_dev *pdev,
+    struct pci_dev **limiting,
+    enum pci_bus_speed *speed,
+    enum pcie_link_width *width)
+{
+	enum pci_bus_speed nspeed = pcie_get_speed_cap(pdev);
+	enum pcie_link_width nwidth = pcie_get_width_cap(pdev);
+
+	if (speed)
+		*speed = nspeed;
+	if (width)
+		*width = nwidth;
+
+	return (nwidth * PCIE_SPEED2MBS_ENC(nspeed));
+}
+
 #endif	/* _LINUX_PCI_H_ */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202005180934.04I9YfgG071209>