From owner-svn-src-head@freebsd.org Sat Sep 2 11:56:18 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 10378E0F201; Sat, 2 Sep 2017 11:56:18 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E0B3E83AE1; Sat, 2 Sep 2017 11:56:17 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v82BuH8k074496; Sat, 2 Sep 2017 11:56:17 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v82BuGO0074491; Sat, 2 Sep 2017 11:56:16 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201709021156.v82BuGO0074491@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Sat, 2 Sep 2017 11:56:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r323126 - in head/sys/dev/ntb: . ntb_hw X-SVN-Group: head X-SVN-Commit-Author: mav X-SVN-Commit-Paths: in head/sys/dev/ntb: . ntb_hw X-SVN-Commit-Revision: 323126 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Sep 2017 11:56:18 -0000 Author: mav Date: Sat Sep 2 11:56:16 2017 New Revision: 323126 URL: https://svnweb.freebsd.org/changeset/base/323126 Log: Make NTB drivers report more info via NewBus methods. MFC after: 12 days Modified: head/sys/dev/ntb/ntb.c head/sys/dev/ntb/ntb.h head/sys/dev/ntb/ntb_hw/ntb_hw_intel.c head/sys/dev/ntb/ntb_hw/ntb_hw_plx.c head/sys/dev/ntb/ntb_transport.c Modified: head/sys/dev/ntb/ntb.c ============================================================================== --- head/sys/dev/ntb/ntb.c Sat Sep 2 07:04:06 2017 (r323125) +++ head/sys/dev/ntb/ntb.c Sat Sep 2 11:56:16 2017 (r323126) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2016 Alexander Motin + * Copyright (c) 2016-2017 Alexander Motin * 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 sy 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); @@ -160,6 +164,45 @@ ntb_unregister_device(device_t dev) free(nc, M_DEVBUF); } 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 Modified: head/sys/dev/ntb/ntb.h ============================================================================== --- head/sys/dev/ntb/ntb.h Sat Sep 2 07:04:06 2017 (r323125) +++ head/sys/dev/ntb/ntb.h Sat Sep 2 11:56:16 2017 (r323126) @@ -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 Modified: head/sys/dev/ntb/ntb_hw/ntb_hw_intel.c ============================================================================== --- head/sys/dev/ntb/ntb_hw/ntb_hw_intel.c Sat Sep 2 07:04:06 2017 (r323125) +++ head/sys/dev/ntb/ntb_hw/ntb_hw_intel.c Sat Sep 2 11:56:16 2017 (r323126) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2016 Alexander Motin + * Copyright (c) 2016-2017 Alexander Motin * 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), Modified: head/sys/dev/ntb/ntb_hw/ntb_hw_plx.c ============================================================================== --- head/sys/dev/ntb/ntb_hw/ntb_hw_plx.c Sat Sep 2 07:04:06 2017 (r323125) +++ head/sys/dev/ntb/ntb_hw/ntb_hw_plx.c Sat Sep 2 11:56:16 2017 (r323126) @@ -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), Modified: head/sys/dev/ntb/ntb_transport.c ============================================================================== --- head/sys/dev/ntb/ntb_transport.c Sat Sep 2 07:04:06 2017 (r323125) +++ head/sys/dev/ntb/ntb_transport.c Sat Sep 2 11:56:16 2017 (r323126) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2016 Alexander Motin + * Copyright (c) 2016-2017 Alexander Motin * 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 };