svn commit: r351538 - stable/12/sys/dev/ntb/ntb_hw

Alexander Motin mav at FreeBSD.org
Tue Aug 27 04:15:22 UTC 2019


Author: mav
Date: Tue Aug 27 04:15:21 2019
New Revision: 351538
URL: https://svnweb.freebsd.org/changeset/base/351538

Log:
  MFC r351072: Implement new methods for Intel and PLX NTB.
  
  This restores parity with AMD NTB driver.  Though without any drivers
  supporting more then one peer and respective KPI modification to pass
  peer index to most of the calls this addition is pretty useless now.

Modified:
  stable/12/sys/dev/ntb/ntb_hw/ntb_hw_intel.c
  stable/12/sys/dev/ntb/ntb_hw/ntb_hw_plx.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/ntb/ntb_hw/ntb_hw_intel.c
==============================================================================
--- stable/12/sys/dev/ntb/ntb_hw/ntb_hw_intel.c	Tue Aug 27 04:14:38 2019	(r351537)
+++ stable/12/sys/dev/ntb/ntb_hw/ntb_hw_intel.c	Tue Aug 27 04:15:21 2019	(r351538)
@@ -1977,6 +1977,44 @@ atom_perform_link_restart(struct ntb_softc *ntb)
 }
 
 static int
+intel_ntb_port_number(device_t dev)
+{
+	struct ntb_softc *ntb = device_get_softc(dev);
+
+	return (ntb->dev_type == NTB_DEV_USD ? 0 : 1);
+}
+
+static int
+intel_ntb_peer_port_count(device_t dev)
+{
+
+	return (1);
+}
+
+static int
+intel_ntb_peer_port_number(device_t dev, int pidx)
+{
+	struct ntb_softc *ntb = device_get_softc(dev);
+
+	if (pidx != 0)
+		return (-EINVAL);
+
+	return (ntb->dev_type == NTB_DEV_USD ? 1 : 0);
+}
+
+static int
+intel_ntb_peer_port_idx(device_t dev, int port)
+{
+	int peer_port;
+
+	peer_port = intel_ntb_peer_port_number(dev, 0);
+	if (peer_port == -EINVAL || port != peer_port)
+		return (-EINVAL);
+
+	return (0);
+}
+
+static int
 intel_ntb_link_enable(device_t dev, enum ntb_speed speed __unused,
     enum ntb_width width __unused)
 {
@@ -3086,6 +3124,10 @@ static device_method_t ntb_intel_methods[] = {
 	DEVMETHOD(bus_child_location_str, ntb_child_location_str),
 	DEVMETHOD(bus_print_child,	ntb_print_child),
 	/* NTB interface */
+	DEVMETHOD(ntb_port_number,	intel_ntb_port_number),
+	DEVMETHOD(ntb_peer_port_count,	intel_ntb_peer_port_count),
+	DEVMETHOD(ntb_peer_port_number,	intel_ntb_peer_port_number),
+	DEVMETHOD(ntb_peer_port_idx, 	intel_ntb_peer_port_idx),
 	DEVMETHOD(ntb_link_is_up,	intel_ntb_link_is_up),
 	DEVMETHOD(ntb_link_enable,	intel_ntb_link_enable),
 	DEVMETHOD(ntb_link_disable,	intel_ntb_link_disable),

Modified: stable/12/sys/dev/ntb/ntb_hw/ntb_hw_plx.c
==============================================================================
--- stable/12/sys/dev/ntb/ntb_hw/ntb_hw_plx.c	Tue Aug 27 04:14:38 2019	(r351537)
+++ stable/12/sys/dev/ntb/ntb_hw/ntb_hw_plx.c	Tue Aug 27 04:15:21 2019	(r351538)
@@ -470,7 +470,44 @@ ntb_plx_detach(device_t dev)
 	return (0);
 }
 
+static int
+ntb_plx_port_number(device_t dev)
+{
+	struct ntb_plx_softc *sc = device_get_softc(dev);
 
+	return (sc->link ? 1 : 0);
+}
+
+static int
+ntb_plx_peer_port_count(device_t dev)
+{
+
+	return (1);
+}
+
+static int
+ntb_plx_peer_port_number(device_t dev, int pidx)
+{
+	struct ntb_plx_softc *sc = device_get_softc(dev);
+
+	if (pidx != 0)
+		return (-EINVAL);
+
+	return (sc->link ? 0 : 1);
+}
+
+static int
+ntb_plx_peer_port_idx(device_t dev, int port)
+{
+	int peer_port;
+
+	peer_port = ntb_plx_peer_port_number(dev, 0);
+	if (peer_port == -EINVAL || port != peer_port)
+		return (-EINVAL);
+
+	return (0);
+}
+
 static bool
 ntb_plx_link_is_up(device_t dev, enum ntb_speed *speed, enum ntb_width *width)
 {
@@ -974,6 +1011,10 @@ static device_method_t ntb_plx_methods[] = {
 	DEVMETHOD(bus_child_location_str, ntb_child_location_str),
 	DEVMETHOD(bus_print_child,	ntb_print_child),
 	/* NTB interface */
+	DEVMETHOD(ntb_port_number,	ntb_plx_port_number),
+	DEVMETHOD(ntb_peer_port_count,	ntb_plx_peer_port_count),
+	DEVMETHOD(ntb_peer_port_number,	ntb_plx_peer_port_number),
+	DEVMETHOD(ntb_peer_port_idx, 	ntb_plx_peer_port_idx),
 	DEVMETHOD(ntb_link_is_up,	ntb_plx_link_is_up),
 	DEVMETHOD(ntb_link_enable,	ntb_plx_link_enable),
 	DEVMETHOD(ntb_link_disable,	ntb_plx_link_disable),


More information about the svn-src-all mailing list