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.

MFC after:	2 weeks
This commit is contained in:
Alexander Motin 2019-08-15 14:11:11 +00:00
parent 773a7e2224
commit 6ddecf2b75
2 changed files with 83 additions and 0 deletions

View file

@ -1977,6 +1977,44 @@ atom_perform_link_restart(struct ntb_softc *ntb)
intel_ntb_reg_write(4, ATOM_LTSSMSTATEJMP_OFFSET, status);
}
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)
@ -3087,6 +3125,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),

View file

@ -470,6 +470,43 @@ 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),