aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/ntb/ntb.c
diff options
context:
space:
mode:
authorAlexander Motin <mav@FreeBSD.org>2017-09-02 11:56:16 +0000
committerAlexander Motin <mav@FreeBSD.org>2017-09-02 11:56:16 +0000
commitb7dd3fbedee199e37d7f8011f9e405716aa7781c (patch)
treecc9ef783f0de0795b45bc2e35d081e0fe961ae84 /sys/dev/ntb/ntb.c
parenta905e3962c8d061d3c03c622196db00db3bf7716 (diff)
downloadsrc-b7dd3fbedee199e37d7f8011f9e405716aa7781c.tar.gz
src-b7dd3fbedee199e37d7f8011f9e405716aa7781c.zip
Make NTB drivers report more info via NewBus methods.
MFC after: 12 days
Notes
Notes: svn path=/head/; revision=323126
Diffstat (limited to 'sys/dev/ntb/ntb.c')
-rw-r--r--sys/dev/ntb/ntb.c47
1 files changed, 45 insertions, 2 deletions
diff --git a/sys/dev/ntb/ntb.c b/sys/dev/ntb/ntb.c
index fd6e1028891a..63417ab249df 100644
--- a/sys/dev/ntb/ntb.c
+++ b/sys/dev/ntb/ntb.c
@@ -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)
{