Make NTB drivers report more info via NewBus methods.
MFC after: 12 days
This commit is contained in:
parent
a905e3962c
commit
b7dd3fbede
@ -1,5 +1,5 @@
|
||||
/*-
|
||||
* Copyright (c) 2016 Alexander Motin <mav@FreeBSD.org>
|
||||
* Copyright (c) 2016-2017 Alexander Motin <mav@FreeBSD.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -43,13 +43,15 @@ SYSCTL_NODE(_hw, OID_AUTO, ntb, CTLFLAG_RW, 0, "NTB sysctls");
|
||||
|
||||
struct ntb_child {
|
||||
device_t dev;
|
||||
int function;
|
||||
int enabled;
|
||||
int mwoff;
|
||||
int mwcnt;
|
||||
int spadoff;
|
||||
int spadcnt;
|
||||
int dboff;
|
||||
int dbmask;
|
||||
int dbcnt;
|
||||
uint64_t dbmask;
|
||||
void *ctx;
|
||||
const struct ntb_ctx_ops *ctx_ops;
|
||||
struct rmlock ctx_lock;
|
||||
@ -98,11 +100,13 @@ ntb_register_device(device_t dev)
|
||||
}
|
||||
|
||||
nc = malloc(sizeof(*nc), M_DEVBUF, M_WAITOK | M_ZERO);
|
||||
nc->function = i;
|
||||
nc->mwoff = mwu;
|
||||
nc->mwcnt = mw;
|
||||
nc->spadoff = spadu;
|
||||
nc->spadcnt = spad;
|
||||
nc->dboff = dbu;
|
||||
nc->dbcnt = db;
|
||||
nc->dbmask = (db == 0) ? 0 : (0xffffffffffffffff >> (64 - db));
|
||||
rm_init(&nc->ctx_lock, "ntb ctx");
|
||||
nc->dev = device_add_child(dev, name, -1);
|
||||
@ -162,6 +166,45 @@ ntb_unregister_device(device_t dev)
|
||||
return (error);
|
||||
}
|
||||
|
||||
int
|
||||
ntb_child_location_str(device_t dev, device_t child, char *buf,
|
||||
size_t buflen)
|
||||
{
|
||||
struct ntb_child *nc = device_get_ivars(child);
|
||||
|
||||
snprintf(buf, buflen, "function=%d", nc->function);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
ntb_print_child(device_t dev, device_t child)
|
||||
{
|
||||
struct ntb_child *nc = device_get_ivars(child);
|
||||
int retval;
|
||||
|
||||
retval = bus_print_child_header(dev, child);
|
||||
if (nc->mwcnt > 0) {
|
||||
printf(" mw %d", nc->mwoff);
|
||||
if (nc->mwcnt > 1)
|
||||
printf("-%d", nc->mwoff + nc->mwcnt - 1);
|
||||
}
|
||||
if (nc->spadcnt > 0) {
|
||||
printf(" spad %d", nc->spadoff);
|
||||
if (nc->spadcnt > 1)
|
||||
printf("-%d", nc->spadoff + nc->spadcnt - 1);
|
||||
}
|
||||
if (nc->dbcnt > 0) {
|
||||
printf(" db %d", nc->dboff);
|
||||
if (nc->dbcnt > 1)
|
||||
printf("-%d", nc->dboff + nc->dbcnt - 1);
|
||||
}
|
||||
retval += printf(" at function %d", nc->function);
|
||||
retval += bus_print_child_domain(dev, child);
|
||||
retval += bus_print_child_footer(dev, child);
|
||||
|
||||
return (retval);
|
||||
}
|
||||
|
||||
void
|
||||
ntb_link_event(device_t dev)
|
||||
{
|
||||
|
@ -36,6 +36,9 @@ SYSCTL_DECL(_hw_ntb);
|
||||
|
||||
int ntb_register_device(device_t ntb);
|
||||
int ntb_unregister_device(device_t ntb);
|
||||
int ntb_child_location_str(device_t dev, device_t child, char *buf,
|
||||
size_t buflen);
|
||||
int ntb_print_child(device_t dev, device_t child);
|
||||
|
||||
/*
|
||||
* ntb_link_event() - notify driver context of a change in link status
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*-
|
||||
* Copyright (c) 2016 Alexander Motin <mav@FreeBSD.org>
|
||||
* Copyright (c) 2016-2017 Alexander Motin <mav@FreeBSD.org>
|
||||
* Copyright (C) 2013 Intel Corporation
|
||||
* Copyright (C) 2015 EMC Corporation
|
||||
* All rights reserved.
|
||||
@ -3085,6 +3085,9 @@ static device_method_t ntb_intel_methods[] = {
|
||||
DEVMETHOD(device_probe, intel_ntb_probe),
|
||||
DEVMETHOD(device_attach, intel_ntb_attach),
|
||||
DEVMETHOD(device_detach, intel_ntb_detach),
|
||||
/* Bus interface */
|
||||
DEVMETHOD(bus_child_location_str, ntb_child_location_str),
|
||||
DEVMETHOD(bus_print_child, ntb_print_child),
|
||||
/* NTB interface */
|
||||
DEVMETHOD(ntb_link_is_up, intel_ntb_link_is_up),
|
||||
DEVMETHOD(ntb_link_enable, intel_ntb_link_enable),
|
||||
|
@ -914,6 +914,9 @@ static device_method_t ntb_plx_methods[] = {
|
||||
DEVMETHOD(device_probe, ntb_plx_probe),
|
||||
DEVMETHOD(device_attach, ntb_plx_attach),
|
||||
DEVMETHOD(device_detach, ntb_plx_detach),
|
||||
/* Bus interface */
|
||||
DEVMETHOD(bus_child_location_str, ntb_child_location_str),
|
||||
DEVMETHOD(bus_print_child, ntb_print_child),
|
||||
/* NTB interface */
|
||||
DEVMETHOD(ntb_link_is_up, ntb_plx_link_is_up),
|
||||
DEVMETHOD(ntb_link_enable, ntb_plx_link_enable),
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*-
|
||||
* Copyright (c) 2016 Alexander Motin <mav@FreeBSD.org>
|
||||
* Copyright (c) 2016-2017 Alexander Motin <mav@FreeBSD.org>
|
||||
* Copyright (C) 2013 Intel Corporation
|
||||
* Copyright (C) 2015 EMC Corporation
|
||||
* All rights reserved.
|
||||
@ -188,6 +188,7 @@ struct ntb_transport_mw {
|
||||
|
||||
struct ntb_transport_child {
|
||||
device_t dev;
|
||||
int consumer;
|
||||
int qpoff;
|
||||
int qpcnt;
|
||||
struct ntb_transport_child *next;
|
||||
@ -343,9 +344,6 @@ ntb_transport_attach(device_t dev)
|
||||
KASSERT(db_bitmap == (1 << db_count) - 1,
|
||||
("Doorbells are not sequential (%jx).\n", db_bitmap));
|
||||
|
||||
device_printf(dev, "%d memory windows, %d scratchpads, "
|
||||
"%d doorbells\n", nt->mw_count, spad_count, db_count);
|
||||
|
||||
if (nt->mw_count == 0) {
|
||||
device_printf(dev, "At least 1 memory window required.\n");
|
||||
return (ENXIO);
|
||||
@ -409,6 +407,7 @@ ntb_transport_attach(device_t dev)
|
||||
}
|
||||
|
||||
nc = malloc(sizeof(*nc), M_DEVBUF, M_WAITOK | M_ZERO);
|
||||
nc->consumer = i;
|
||||
nc->qpoff = qpu;
|
||||
nc->qpcnt = qp;
|
||||
nc->dev = device_add_child(dev, name, -1);
|
||||
@ -496,6 +495,35 @@ ntb_transport_detach(device_t dev)
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
ntb_transport_print_child(device_t dev, device_t child)
|
||||
{
|
||||
struct ntb_transport_child *nc = device_get_ivars(child);
|
||||
int retval;
|
||||
|
||||
retval = bus_print_child_header(dev, child);
|
||||
if (nc->qpcnt > 0) {
|
||||
printf(" queue %d", nc->qpoff);
|
||||
if (nc->qpcnt > 1)
|
||||
printf("-%d", nc->qpoff + nc->qpcnt - 1);
|
||||
}
|
||||
retval += printf(" at consumer %d", nc->consumer);
|
||||
retval += bus_print_child_domain(dev, child);
|
||||
retval += bus_print_child_footer(dev, child);
|
||||
|
||||
return (retval);
|
||||
}
|
||||
|
||||
static int
|
||||
ntb_transport_child_location_str(device_t dev, device_t child, char *buf,
|
||||
size_t buflen)
|
||||
{
|
||||
struct ntb_transport_child *nc = device_get_ivars(child);
|
||||
|
||||
snprintf(buf, buflen, "consumer=%d", nc->consumer);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
ntb_transport_queue_count(device_t dev)
|
||||
{
|
||||
@ -1552,6 +1580,9 @@ static device_method_t ntb_transport_methods[] = {
|
||||
DEVMETHOD(device_probe, ntb_transport_probe),
|
||||
DEVMETHOD(device_attach, ntb_transport_attach),
|
||||
DEVMETHOD(device_detach, ntb_transport_detach),
|
||||
/* Bus interface */
|
||||
DEVMETHOD(bus_child_location_str, ntb_transport_child_location_str),
|
||||
DEVMETHOD(bus_print_child, ntb_transport_print_child),
|
||||
DEVMETHOD_END
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user