svn commit: r303517 - in user/alc/PQ_LAUNDRY: include/xlocale lib/libc/locale share/man/man4 sys/dev/ntb sys/dev/ntb/if_ntb sys/dev/ntb/ntb_hw sys/dev/pci sys/kern sys/ofed/drivers/infiniband/ulp/s...
Mark Johnston
markj at FreeBSD.org
Fri Jul 29 21:07:20 UTC 2016
Author: markj
Date: Fri Jul 29 21:07:17 2016
New Revision: 303517
URL: https://svnweb.freebsd.org/changeset/base/303517
Log:
MFH r303516
Deleted:
user/alc/PQ_LAUNDRY/sys/ofed/drivers/infiniband/ulp/sdp/Kconfig
user/alc/PQ_LAUNDRY/sys/ofed/drivers/infiniband/ulp/sdp/Makefile
Modified:
user/alc/PQ_LAUNDRY/include/xlocale/_locale.h
user/alc/PQ_LAUNDRY/lib/libc/locale/freelocale.3
user/alc/PQ_LAUNDRY/lib/libc/locale/xlocale.c
user/alc/PQ_LAUNDRY/share/man/man4/if_ntb.4
user/alc/PQ_LAUNDRY/share/man/man4/ntb_transport.4
user/alc/PQ_LAUNDRY/sys/dev/ntb/if_ntb/if_ntb.c
user/alc/PQ_LAUNDRY/sys/dev/ntb/ntb_hw/ntb_hw.c
user/alc/PQ_LAUNDRY/sys/dev/ntb/ntb_transport.c
user/alc/PQ_LAUNDRY/sys/dev/ntb/ntb_transport.h
user/alc/PQ_LAUNDRY/sys/dev/pci/pci_pci.c
user/alc/PQ_LAUNDRY/sys/kern/sched_4bsd.c
user/alc/PQ_LAUNDRY/sys/kern/vfs_aio.c
user/alc/PQ_LAUNDRY/sys/ofed/drivers/infiniband/ulp/sdp/sdp.h
user/alc/PQ_LAUNDRY/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c
user/alc/PQ_LAUNDRY/sys/ofed/drivers/infiniband/ulp/sdp/sdp_rx.c
user/alc/PQ_LAUNDRY/sys/ofed/drivers/infiniband/ulp/sdp/sdp_tx.c
user/alc/PQ_LAUNDRY/tests/sys/aio/aio_test.c
user/alc/PQ_LAUNDRY/usr.bin/indent/args.c
user/alc/PQ_LAUNDRY/usr.bin/indent/indent.c
user/alc/PQ_LAUNDRY/usr.bin/indent/io.c
user/alc/PQ_LAUNDRY/usr.bin/indent/lexi.c
user/alc/PQ_LAUNDRY/usr.bin/indent/pr_comment.c
user/alc/PQ_LAUNDRY/usr.bin/resizewin/resizewin.1
Directory Properties:
user/alc/PQ_LAUNDRY/ (props changed)
Modified: user/alc/PQ_LAUNDRY/include/xlocale/_locale.h
==============================================================================
--- user/alc/PQ_LAUNDRY/include/xlocale/_locale.h Fri Jul 29 21:05:37 2016 (r303516)
+++ user/alc/PQ_LAUNDRY/include/xlocale/_locale.h Fri Jul 29 21:07:17 2016 (r303517)
@@ -48,7 +48,7 @@ typedef struct _xlocale *locale_t;
#endif
locale_t duplocale(locale_t base);
-int freelocale(locale_t loc);
+void freelocale(locale_t loc);
locale_t newlocale(int mask, const char *locale, locale_t base);
const char *querylocale(int mask, locale_t loc);
locale_t uselocale(locale_t loc);
Modified: user/alc/PQ_LAUNDRY/lib/libc/locale/freelocale.3
==============================================================================
--- user/alc/PQ_LAUNDRY/lib/libc/locale/freelocale.3 Fri Jul 29 21:05:37 2016 (r303516)
+++ user/alc/PQ_LAUNDRY/lib/libc/locale/freelocale.3 Fri Jul 29 21:07:17 2016 (r303517)
@@ -26,7 +26,7 @@
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD$
-.Dd September 17, 2011
+.Dd July 26, 2016
.Dt FREELOCALE 3
.Os
.Sh NAME
@@ -39,7 +39,7 @@ or
.Lb libc
.Sh SYNOPSIS
.In locale.h
-.Ft int
+.Ft void
.Fn freelocale "locale_t locale"
.Sh DESCRIPTION
Frees a
@@ -47,8 +47,6 @@ Frees a
This relinquishes any resources held exclusively by this locale.
Note that locales share reference-counted components,
so a call to this function is not guaranteed to free all of the components.
-.Sh RETURN VALUES
-Returns 0 on success or -1 on error.
.Sh SEE ALSO
.Xr duplocale 3 ,
.Xr localeconv 3 ,
@@ -57,12 +55,5 @@ Returns 0 on success or -1 on error.
.Xr uselocale 3 ,
.Xr xlocale 3
.Sh STANDARDS
-The
-.Fn freelocale
-function
-differs from
-.St -p1003.1-2008
-in that its return type is
-.Vt int
-rather than
-.Vt void .
+This function conforms to
+.St -p1003.1-2008 .
Modified: user/alc/PQ_LAUNDRY/lib/libc/locale/xlocale.c
==============================================================================
--- user/alc/PQ_LAUNDRY/lib/libc/locale/xlocale.c Fri Jul 29 21:05:37 2016 (r303516)
+++ user/alc/PQ_LAUNDRY/lib/libc/locale/xlocale.c Fri Jul 29 21:07:17 2016 (r303517)
@@ -325,20 +325,18 @@ locale_t duplocale(locale_t base)
* Free a locale_t. This is quite a poorly named function. It actually
* disclaims a reference to a locale_t, rather than freeing it.
*/
-int
+void
freelocale(locale_t loc)
{
- /* Fail if we're passed something that isn't a locale. */
- if ((NULL == loc) || (LC_GLOBAL_LOCALE == loc)) {
- return (-1);
- }
- /* If we're passed the global locale, pretend that we freed it but don't
- * actually do anything. */
- if (&__xlocale_global_locale == loc) {
- return (0);
- }
- xlocale_release(loc);
- return (0);
+
+ /*
+ * Fail if we're passed something that isn't a locale. If we're
+ * passed the global locale, pretend that we freed it but don't
+ * actually do anything.
+ */
+ if (loc != NULL && loc != LC_GLOBAL_LOCALE &&
+ loc != &__xlocale_global_locale)
+ xlocale_release(loc);
}
/*
Modified: user/alc/PQ_LAUNDRY/share/man/man4/if_ntb.4
==============================================================================
--- user/alc/PQ_LAUNDRY/share/man/man4/if_ntb.4 Fri Jul 29 21:05:37 2016 (r303516)
+++ user/alc/PQ_LAUNDRY/share/man/man4/if_ntb.4 Fri Jul 29 21:07:17 2016 (r303517)
@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd July 10, 2016
+.Dd July 29, 2016
.Dt IF_NTB 4
.Os
.Sh NAME
@@ -49,7 +49,7 @@ The following tunables are settable from
.Bl -ohang
.It Va hw.if_ntb.num_queues
Number of transport queues to use per interface.
-Default is 1.
+Default is unlimited.
.El
.Sh DESCRIPTION
The
@@ -84,3 +84,6 @@ Later improvements were done by
.An Conrad E. Meyer Aq Mt cem at FreeBSD.org
and
.An Alexander Motin Aq Mt mav at FreeBSD.org .
+.Sh BUGS
+Linux supports only one queue per interface, so manual configuration
+may be required for compatibility.
Modified: user/alc/PQ_LAUNDRY/share/man/man4/ntb_transport.4
==============================================================================
--- user/alc/PQ_LAUNDRY/share/man/man4/ntb_transport.4 Fri Jul 29 21:05:37 2016 (r303516)
+++ user/alc/PQ_LAUNDRY/share/man/man4/ntb_transport.4 Fri Jul 29 21:07:17 2016 (r303517)
@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd July 10, 2016
+.Dd July 29, 2016
.Dt NTB_TRANSPORT 4
.Os
.Sh NAME
@@ -44,10 +44,15 @@ The following tunables are settable from
.It Va hw.ntb_transport.debug_level
Driver debug level.
The default value is 0, higher means more verbose.
-.It Va hw.ntb_transport.max_num_clients
-Number of bidirectional queues to setup.
-The default value is 0, that means one queue per available memory window.
-Maximal number is limited by number of doorbells.
+.It Va hint.ntb_transport. Ns Ar X Ns Va .config
+Configures queues allocation for consumer devices, separated by commas.
+Each device can be configured as: "<name>[:<queues>]", where:
+.Va name
+is a name of the driver which should attach the device (empty means any),
+.Va queues
+is a number of queues to allocate (empty means automatic),
+The default configuration is empty string, which means single device
+with one queue per memory window allowing any driver attachment.
.El
.Sh DESCRIPTION
The
Modified: user/alc/PQ_LAUNDRY/sys/dev/ntb/if_ntb/if_ntb.c
==============================================================================
--- user/alc/PQ_LAUNDRY/sys/dev/ntb/if_ntb/if_ntb.c Fri Jul 29 21:05:37 2016 (r303516)
+++ user/alc/PQ_LAUNDRY/sys/dev/ntb/if_ntb/if_ntb.c Fri Jul 29 21:07:17 2016 (r303517)
@@ -76,7 +76,7 @@ __FBSDID("$FreeBSD$");
static SYSCTL_NODE(_hw, OID_AUTO, if_ntb, CTLFLAG_RW, 0, "if_ntb");
-static unsigned g_if_ntb_num_queues = 1;
+static unsigned g_if_ntb_num_queues = UINT_MAX;
SYSCTL_UINT(_hw_if_ntb, OID_AUTO, num_queues, CTLFLAG_RWTUN,
&g_if_ntb_num_queues, 0, "Number of queues per interface");
@@ -144,7 +144,8 @@ ntb_net_attach(device_t dev)
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
if_setdev(ifp, dev);
- sc->num_queues = g_if_ntb_num_queues;
+ sc->num_queues = min(g_if_ntb_num_queues,
+ ntb_transport_queue_count(dev));
sc->queues = malloc(sc->num_queues * sizeof(struct ntb_net_queue),
M_DEVBUF, M_WAITOK | M_ZERO);
sc->mtu = INT_MAX;
@@ -152,8 +153,7 @@ ntb_net_attach(device_t dev)
q = &sc->queues[i];
q->sc = sc;
q->ifp = ifp;
- q->qp = ntb_transport_create_queue(q,
- device_get_parent(dev), &handlers);
+ q->qp = ntb_transport_create_queue(dev, i, &handlers, q);
if (q->qp == NULL)
break;
sc->mtu = imin(sc->mtu, ntb_transport_max_size(q->qp));
@@ -167,6 +167,7 @@ ntb_net_attach(device_t dev)
callout_init(&q->queue_full, 1);
}
sc->num_queues = i;
+ device_printf(dev, "%d queue(s)\n", sc->num_queues);
if_setinitfn(ifp, ntb_net_init);
if_setsoftc(ifp, sc);
Modified: user/alc/PQ_LAUNDRY/sys/dev/ntb/ntb_hw/ntb_hw.c
==============================================================================
--- user/alc/PQ_LAUNDRY/sys/dev/ntb/ntb_hw/ntb_hw.c Fri Jul 29 21:05:37 2016 (r303516)
+++ user/alc/PQ_LAUNDRY/sys/dev/ntb/ntb_hw/ntb_hw.c Fri Jul 29 21:07:17 2016 (r303517)
@@ -2649,6 +2649,7 @@ msix_done:
if (val != NTB_MSIX_RECEIVED)
goto reschedule;
+ intel_ntb_spad_clear(ntb->device);
ntb->peer_msix_good = true;
/* Give peer time to see our NTB_MSIX_RECEIVED. */
goto reschedule;
Modified: user/alc/PQ_LAUNDRY/sys/dev/ntb/ntb_transport.c
==============================================================================
--- user/alc/PQ_LAUNDRY/sys/dev/ntb/ntb_transport.c Fri Jul 29 21:05:37 2016 (r303516)
+++ user/alc/PQ_LAUNDRY/sys/dev/ntb/ntb_transport.c Fri Jul 29 21:07:17 2016 (r303517)
@@ -43,7 +43,6 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/systm.h>
-#include <sys/bitset.h>
#include <sys/bus.h>
#include <sys/ktr.h>
#include <sys/limits.h>
@@ -64,13 +63,6 @@ __FBSDID("$FreeBSD$");
#include "ntb.h"
#include "ntb_transport.h"
-#define QP_SETSIZE 64
-BITSET_DEFINE(_qpset, QP_SETSIZE);
-#define test_bit(pos, addr) BIT_ISSET(QP_SETSIZE, (pos), (addr))
-#define set_bit(pos, addr) BIT_SET(QP_SETSIZE, (pos), (addr))
-#define clear_bit(pos, addr) BIT_CLR(QP_SETSIZE, (pos), (addr))
-#define ffs_bit(addr) BIT_FFS(QP_SETSIZE, (addr))
-
#define KTR_NTB KTR_SPARE3
#define NTB_TRANSPORT_VERSION 4
@@ -94,12 +86,6 @@ SYSCTL_UQUAD(_hw_ntb_transport, OID_AUTO
"If enabled (non-zero), limit the size of large memory windows. "
"Both sides of the NTB MUST set the same value here.");
-static unsigned max_num_clients;
-SYSCTL_UINT(_hw_ntb_transport, OID_AUTO, max_num_clients, CTLFLAG_RDTUN,
- &max_num_clients, 0, "Maximum number of NTB transport clients. "
- "0 (default) - use all available NTB memory windows; "
- "positive integer N - Limit to N memory windows.");
-
static unsigned enable_xeon_watchdog;
SYSCTL_UINT(_hw_ntb_transport, OID_AUTO, enable_xeon_watchdog, CTLFLAG_RDTUN,
&enable_xeon_watchdog, 0, "If non-zero, write a register every second to "
@@ -200,14 +186,21 @@ struct ntb_transport_mw {
bus_addr_t dma_addr;
};
+struct ntb_transport_child {
+ device_t dev;
+ int qpoff;
+ int qpcnt;
+ struct ntb_transport_child *next;
+};
+
struct ntb_transport_ctx {
device_t dev;
+ struct ntb_transport_child *child;
struct ntb_transport_mw *mw_vec;
struct ntb_transport_qp *qp_vec;
- struct _qpset qp_bitmap;
- struct _qpset qp_bitmap_free;
unsigned mw_count;
unsigned qp_count;
+ uint64_t qp_bitmap;
volatile bool link_is_up;
struct callout link_work;
struct callout link_watchdog;
@@ -242,7 +235,6 @@ enum {
NTBT_MW0_SZ_LOW,
NTBT_MW1_SZ_HIGH,
NTBT_MW1_SZ_LOW,
- NTBT_MAX_SPAD,
/*
* Some NTB-using hardware have a watchdog to work around NTB hangs; if
@@ -332,13 +324,44 @@ static int
ntb_transport_attach(device_t dev)
{
struct ntb_transport_ctx *nt = device_get_softc(dev);
+ struct ntb_transport_child **cpp = &nt->child;
+ struct ntb_transport_child *nc;
struct ntb_transport_mw *mw;
- uint64_t qp_bitmap;
- int rc;
- unsigned i;
+ uint64_t db_bitmap;
+ int rc, i, db_count, spad_count, qp, qpu, qpo, qpt;
+ char cfg[128] = "";
+ char buf[32];
+ char *n, *np, *c, *name;
nt->dev = dev;
nt->mw_count = ntb_mw_count(dev);
+ spad_count = ntb_spad_count(dev);
+ db_bitmap = ntb_db_valid_mask(dev);
+ db_count = flsll(db_bitmap);
+ 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);
+ }
+ if (spad_count < 6) {
+ device_printf(dev, "At least 6 scratchpads required.\n");
+ return (ENXIO);
+ }
+ if (spad_count < 4 + 2 * nt->mw_count) {
+ nt->mw_count = (spad_count - 4) / 2;
+ device_printf(dev, "Scratchpads enough only for %d "
+ "memory windows.\n", nt->mw_count);
+ }
+ if (db_bitmap == 0) {
+ device_printf(dev, "At least one doorbell required.\n");
+ return (ENXIO);
+ }
+
nt->mw_vec = malloc(nt->mw_count * sizeof(*nt->mw_vec), M_NTB_T,
M_WAITOK | M_ZERO);
for (i = 0; i < nt->mw_count; i++) {
@@ -360,25 +383,59 @@ ntb_transport_attach(device_t dev)
ntb_printf(0, "Unable to set mw%d caching\n", i);
}
- qp_bitmap = ntb_db_valid_mask(dev);
- nt->qp_count = flsll(qp_bitmap);
- KASSERT(nt->qp_count != 0, ("bogus db bitmap"));
- nt->qp_count -= 1;
-
- if (max_num_clients != 0 && max_num_clients < nt->qp_count)
- nt->qp_count = max_num_clients;
- else if (nt->mw_count < nt->qp_count)
- nt->qp_count = nt->mw_count;
- KASSERT(nt->qp_count <= QP_SETSIZE, ("invalid qp_count"));
+ qpu = 0;
+ qpo = imin(db_count, nt->mw_count);
+ qpt = db_count;
+
+ snprintf(buf, sizeof(buf), "hint.%s.%d.config", device_get_name(dev),
+ device_get_unit(dev));
+ TUNABLE_STR_FETCH(buf, cfg, sizeof(cfg));
+ n = cfg;
+ i = 0;
+ while ((c = strsep(&n, ",")) != NULL) {
+ np = c;
+ name = strsep(&np, ":");
+ if (name != NULL && name[0] == 0)
+ name = NULL;
+ qp = (np && np[0] != 0) ? strtol(np, NULL, 10) : qpo - qpu;
+ if (qp <= 0)
+ qp = 1;
+
+ if (qp > qpt - qpu) {
+ device_printf(dev, "Not enough resources for config\n");
+ break;
+ }
+
+ nc = malloc(sizeof(*nc), M_DEVBUF, M_WAITOK | M_ZERO);
+ nc->qpoff = qpu;
+ nc->qpcnt = qp;
+ nc->dev = device_add_child(dev, name, -1);
+ if (nc->dev == NULL) {
+ device_printf(dev, "Can not add child.\n");
+ break;
+ }
+ device_set_ivars(nc->dev, nc);
+ *cpp = nc;
+ cpp = &nc->next;
+
+ if (bootverbose) {
+ device_printf(dev, "%d \"%s\": queues %d",
+ i, name, qpu);
+ if (qp > 1)
+ printf("-%d", qpu + qp - 1);
+ printf("\n");
+ }
+
+ qpu += qp;
+ i++;
+ }
+ nt->qp_count = qpu;
nt->qp_vec = malloc(nt->qp_count * sizeof(*nt->qp_vec), M_NTB_T,
M_WAITOK | M_ZERO);
- for (i = 0; i < nt->qp_count; i++) {
- set_bit(i, &nt->qp_bitmap);
- set_bit(i, &nt->qp_bitmap_free);
+ for (i = 0; i < nt->qp_count; i++)
ntb_transport_init_queue(nt, i);
- }
callout_init(&nt->link_work, 0);
callout_init(&nt->link_watchdog, 0);
@@ -394,10 +451,7 @@ ntb_transport_attach(device_t dev)
if (enable_xeon_watchdog != 0)
callout_reset(&nt->link_watchdog, 0, xeon_link_watchdog_hb, nt);
- /* Attach children to this transport */
- device_add_child(dev, NULL, -1);
bus_generic_attach(dev);
-
return (0);
err:
@@ -410,25 +464,25 @@ static int
ntb_transport_detach(device_t dev)
{
struct ntb_transport_ctx *nt = device_get_softc(dev);
- struct _qpset qp_bitmap_alloc;
- uint8_t i;
-
- /* Detach & delete all children */
- device_delete_children(dev);
+ struct ntb_transport_child **cpp = &nt->child;
+ struct ntb_transport_child *nc;
+ int error = 0, i;
+
+ while ((nc = *cpp) != NULL) {
+ *cpp = (*cpp)->next;
+ error = device_delete_child(dev, nc->dev);
+ if (error)
+ break;
+ free(nc, M_DEVBUF);
+ }
+ KASSERT(nt->qp_bitmap == 0,
+ ("Some queues not freed on detach (%jx)", nt->qp_bitmap));
ntb_transport_link_cleanup(nt);
taskqueue_drain(taskqueue_swi, &nt->link_cleanup);
callout_drain(&nt->link_work);
callout_drain(&nt->link_watchdog);
- BIT_COPY(QP_SETSIZE, &nt->qp_bitmap, &qp_bitmap_alloc);
- BIT_NAND(QP_SETSIZE, &qp_bitmap_alloc, &nt->qp_bitmap_free);
-
- /* Verify that all the QPs are freed */
- for (i = 0; i < nt->qp_count; i++)
- if (test_bit(i, &qp_bitmap_alloc))
- ntb_transport_free_queue(&nt->qp_vec[i]);
-
ntb_link_disable(dev);
ntb_clear_ctx(dev);
@@ -440,6 +494,14 @@ ntb_transport_detach(device_t dev)
return (0);
}
+int
+ntb_transport_queue_count(device_t dev)
+{
+ struct ntb_transport_child *nc = device_get_ivars(dev);
+
+ return (nc->qpcnt);
+}
+
static void
ntb_transport_init_queue(struct ntb_transport_ctx *nt, unsigned int qp_num)
{
@@ -507,11 +569,9 @@ ntb_transport_init_queue(struct ntb_tran
void
ntb_transport_free_queue(struct ntb_transport_qp *qp)
{
+ struct ntb_transport_ctx *nt = qp->transport;
struct ntb_queue_entry *entry;
- if (qp == NULL)
- return;
-
callout_drain(&qp->link_work);
ntb_db_set_mask(qp->dev, 1ull << qp->qp_num);
@@ -532,7 +592,7 @@ ntb_transport_free_queue(struct ntb_tran
while ((entry = ntb_list_rm(&qp->ntb_tx_free_q_lock, &qp->tx_free_q)))
free(entry, M_NTB_T);
- set_bit(qp->qp_num, &qp->transport->qp_bitmap_free);
+ nt->qp_bitmap &= ~(1 << qp->qp_num);
}
/**
@@ -550,24 +610,20 @@ ntb_transport_free_queue(struct ntb_tran
* RETURNS: pointer to newly created ntb_queue, NULL on error.
*/
struct ntb_transport_qp *
-ntb_transport_create_queue(void *data, device_t dev,
- const struct ntb_queue_handlers *handlers)
+ntb_transport_create_queue(device_t dev, int q,
+ const struct ntb_queue_handlers *handlers, void *data)
{
- struct ntb_transport_ctx *nt = device_get_softc(dev);
+ struct ntb_transport_child *nc = device_get_ivars(dev);
+ struct ntb_transport_ctx *nt = device_get_softc(device_get_parent(dev));
struct ntb_queue_entry *entry;
struct ntb_transport_qp *qp;
- unsigned int free_queue;
int i;
- free_queue = ffs_bit(&nt->qp_bitmap_free);
- if (free_queue == 0)
+ if (q < 0 || q >= nc->qpcnt)
return (NULL);
- /* decrement free_queue to make it zero based */
- free_queue--;
-
- qp = &nt->qp_vec[free_queue];
- clear_bit(qp->qp_num, &nt->qp_bitmap_free);
+ qp = &nt->qp_vec[nc->qpoff + q];
+ nt->qp_bitmap |= (1 << qp->qp_num);
qp->cb_data = data;
qp->rx_handler = handlers->rx_handler;
qp->tx_handler = handlers->tx_handler;
@@ -635,7 +691,7 @@ ntb_transport_tx_enqueue(struct ntb_tran
struct ntb_queue_entry *entry;
int rc;
- if (qp == NULL || !qp->link_is_up || len == 0) {
+ if (!qp->link_is_up || len == 0) {
CTR0(KTR_NTB, "TX: link not up");
return (EINVAL);
}
@@ -944,24 +1000,19 @@ ntb_transport_doorbell_callback(void *da
{
struct ntb_transport_ctx *nt = data;
struct ntb_transport_qp *qp;
- struct _qpset db_bits;
uint64_t vec_mask;
unsigned qp_num;
- BIT_COPY(QP_SETSIZE, &nt->qp_bitmap, &db_bits);
- BIT_NAND(QP_SETSIZE, &db_bits, &nt->qp_bitmap_free);
-
vec_mask = ntb_db_vector_mask(nt->dev, vector);
+ vec_mask &= nt->qp_bitmap;
if ((vec_mask & (vec_mask - 1)) != 0)
vec_mask &= ntb_db_read(nt->dev);
while (vec_mask != 0) {
qp_num = ffsll(vec_mask) - 1;
- if (test_bit(qp_num, &db_bits)) {
- qp = &nt->qp_vec[qp_num];
- if (qp->link_is_up)
- taskqueue_enqueue(qp->rxc_tq, &qp->rxc_db_work);
- }
+ qp = &nt->qp_vec[qp_num];
+ if (qp->link_is_up)
+ taskqueue_enqueue(qp->rxc_tq, &qp->rxc_db_work);
vec_mask &= ~(1ull << qp_num);
}
@@ -1005,11 +1056,9 @@ ntb_transport_link_work(void *arg)
size >> 32);
ntb_peer_spad_write(dev, NTBT_MW0_SZ_LOW + (i * 2), size);
}
-
ntb_peer_spad_write(dev, NTBT_NUM_MWS, nt->mw_count);
-
ntb_peer_spad_write(dev, NTBT_NUM_QPS, nt->qp_count);
-
+ ntb_peer_spad_write(dev, NTBT_QP_LINKS, 0);
ntb_peer_spad_write(dev, NTBT_VERSION, NTB_TRANSPORT_VERSION);
/* Query the remote side for its info */
@@ -1191,16 +1240,18 @@ ntb_qp_link_work(void *arg)
struct ntb_transport_qp *qp = arg;
device_t dev = qp->dev;
struct ntb_transport_ctx *nt = qp->transport;
- uint32_t val, dummy;
-
- ntb_spad_read(dev, NTBT_QP_LINKS, &val);
-
- ntb_peer_spad_write(dev, NTBT_QP_LINKS, val | (1ull << qp->qp_num));
+ int i;
+ uint32_t val;
- /* query remote spad for qp ready bits */
- ntb_peer_spad_read(dev, NTBT_QP_LINKS, &dummy);
+ /* Report queues that are up on our side */
+ for (i = 0, val = 0; i < nt->qp_count; i++) {
+ if (nt->qp_vec[i].client_ready)
+ val |= (1 << i);
+ }
+ ntb_peer_spad_write(dev, NTBT_QP_LINKS, val);
/* See if the remote side is up */
+ ntb_spad_read(dev, NTBT_QP_LINKS, &val);
if ((val & (1ull << qp->qp_num)) != 0) {
ntb_printf(2, "qp %d link up\n", qp->qp_num);
qp->link_is_up = true;
@@ -1219,19 +1270,16 @@ static void
ntb_transport_link_cleanup(struct ntb_transport_ctx *nt)
{
struct ntb_transport_qp *qp;
- struct _qpset qp_bitmap_alloc;
- unsigned i;
-
- BIT_COPY(QP_SETSIZE, &nt->qp_bitmap, &qp_bitmap_alloc);
- BIT_NAND(QP_SETSIZE, &qp_bitmap_alloc, &nt->qp_bitmap_free);
+ int i;
/* Pass along the info to any clients */
- for (i = 0; i < nt->qp_count; i++)
- if (test_bit(i, &qp_bitmap_alloc)) {
+ for (i = 0; i < nt->qp_count; i++) {
+ if ((nt->qp_bitmap & (1 << i)) != 0) {
qp = &nt->qp_vec[i];
ntb_qp_link_cleanup(qp);
callout_drain(&qp->link_work);
}
+ }
if (!nt->link_is_up)
callout_drain(&nt->link_work);
@@ -1241,8 +1289,7 @@ ntb_transport_link_cleanup(struct ntb_tr
* goes down, blast them now to give them a sane value the next
* time they are accessed
*/
- for (i = 0; i < NTBT_MAX_SPAD; i++)
- ntb_spad_write(nt->dev, i, 0);
+ ntb_spad_clear(nt->dev);
}
static void
@@ -1300,17 +1347,16 @@ ntb_qp_link_cleanup(struct ntb_transport
void
ntb_transport_link_down(struct ntb_transport_qp *qp)
{
+ struct ntb_transport_ctx *nt = qp->transport;
+ int i;
uint32_t val;
- if (qp == NULL)
- return;
-
qp->client_ready = false;
-
- ntb_spad_read(qp->dev, NTBT_QP_LINKS, &val);
-
- ntb_peer_spad_write(qp->dev, NTBT_QP_LINKS,
- val & ~(1 << qp->qp_num));
+ for (i = 0, val = 0; i < nt->qp_count; i++) {
+ if (nt->qp_vec[i].client_ready)
+ val |= (1 << i);
+ }
+ ntb_peer_spad_write(qp->dev, NTBT_QP_LINKS, val);
if (qp->link_is_up)
ntb_send_link_down(qp);
@@ -1329,8 +1375,6 @@ ntb_transport_link_down(struct ntb_trans
bool
ntb_transport_link_query(struct ntb_transport_qp *qp)
{
- if (qp == NULL)
- return (false);
return (qp->link_is_up);
}
@@ -1429,8 +1473,6 @@ out:
*/
unsigned char ntb_transport_qp_num(struct ntb_transport_qp *qp)
{
- if (qp == NULL)
- return 0;
return (qp->qp_num);
}
@@ -1447,9 +1489,6 @@ unsigned int
ntb_transport_max_size(struct ntb_transport_qp *qp)
{
- if (qp == NULL)
- return (0);
-
return (qp->tx_max_frame - sizeof(struct ntb_payload_header));
}
Modified: user/alc/PQ_LAUNDRY/sys/dev/ntb/ntb_transport.h
==============================================================================
--- user/alc/PQ_LAUNDRY/sys/dev/ntb/ntb_transport.h Fri Jul 29 21:05:37 2016 (r303516)
+++ user/alc/PQ_LAUNDRY/sys/dev/ntb/ntb_transport.h Fri Jul 29 21:07:17 2016 (r303517)
@@ -43,12 +43,13 @@ struct ntb_queue_handlers {
void (*event_handler)(void *data, enum ntb_link_event status);
};
-unsigned char ntb_transport_qp_num(struct ntb_transport_qp *qp);
-unsigned int ntb_transport_max_size(struct ntb_transport_qp *qp);
+int ntb_transport_queue_count(device_t dev);
struct ntb_transport_qp *
-ntb_transport_create_queue(void *data, device_t dev,
- const struct ntb_queue_handlers *handlers);
+ntb_transport_create_queue(device_t dev, int q,
+ const struct ntb_queue_handlers *handlers, void *data);
void ntb_transport_free_queue(struct ntb_transport_qp *qp);
+unsigned char ntb_transport_qp_num(struct ntb_transport_qp *qp);
+unsigned int ntb_transport_max_size(struct ntb_transport_qp *qp);
int ntb_transport_rx_enqueue(struct ntb_transport_qp *qp, void *cb, void *data,
unsigned int len);
int ntb_transport_tx_enqueue(struct ntb_transport_qp *qp, void *cb, void *data,
Modified: user/alc/PQ_LAUNDRY/sys/dev/pci/pci_pci.c
==============================================================================
--- user/alc/PQ_LAUNDRY/sys/dev/pci/pci_pci.c Fri Jul 29 21:05:37 2016 (r303516)
+++ user/alc/PQ_LAUNDRY/sys/dev/pci/pci_pci.c Fri Jul 29 21:07:17 2016 (r303517)
@@ -907,11 +907,19 @@ pcib_set_mem_decode(struct pcib_softc *s
/*
* PCI-express HotPlug support.
*/
+static int pci_enable_pcie_hp = 1;
+SYSCTL_INT(_hw_pci, OID_AUTO, enable_pcie_hp, CTLFLAG_RDTUN,
+ &pci_enable_pcie_hp, 0,
+ "Enable support for native PCI-express HotPlug.");
+
static void
pcib_probe_hotplug(struct pcib_softc *sc)
{
device_t dev;
+ if (!pci_enable_pcie_hp)
+ return;
+
dev = sc->dev;
if (pci_find_cap(dev, PCIY_EXPRESS, NULL) != 0)
return;
Modified: user/alc/PQ_LAUNDRY/sys/kern/sched_4bsd.c
==============================================================================
--- user/alc/PQ_LAUNDRY/sys/kern/sched_4bsd.c Fri Jul 29 21:05:37 2016 (r303516)
+++ user/alc/PQ_LAUNDRY/sys/kern/sched_4bsd.c Fri Jul 29 21:07:17 2016 (r303517)
@@ -1241,7 +1241,7 @@ sched_pickcpu(struct thread *td)
mtx_assert(&sched_lock, MA_OWNED);
- if (THREAD_CAN_SCHED(td, td->td_lastcpu))
+ if (td->td_lastcpu != NOCPU && THREAD_CAN_SCHED(td, td->td_lastcpu))
best = td->td_lastcpu;
else
best = NOCPU;
Modified: user/alc/PQ_LAUNDRY/sys/kern/vfs_aio.c
==============================================================================
--- user/alc/PQ_LAUNDRY/sys/kern/vfs_aio.c Fri Jul 29 21:05:37 2016 (r303516)
+++ user/alc/PQ_LAUNDRY/sys/kern/vfs_aio.c Fri Jul 29 21:07:17 2016 (r303517)
@@ -311,6 +311,7 @@ static void aio_proc_rundown_exec(void *
static int aio_qphysio(struct proc *p, struct kaiocb *job);
static void aio_daemon(void *param);
static void aio_bio_done_notify(struct proc *userp, struct kaiocb *job);
+static bool aio_clear_cancel_function_locked(struct kaiocb *job);
static int aio_kick(struct proc *userp);
static void aio_kick_nowait(struct proc *userp);
static void aio_kick_helper(void *context, int pending);
@@ -919,7 +920,7 @@ notification_done:
if (--sjob->pending > 0)
continue;
TAILQ_REMOVE(&ki->kaio_syncqueue, sjob, list);
- if (!aio_clear_cancel_function(sjob))
+ if (!aio_clear_cancel_function_locked(sjob))
continue;
TAILQ_INSERT_TAIL(&ki->kaio_syncready, sjob, list);
schedule_fsync = true;
@@ -967,40 +968,57 @@ aio_cancel_cleared(struct kaiocb *job)
return ((job->jobflags & KAIOCB_CLEARED) != 0);
}
-bool
-aio_clear_cancel_function(struct kaiocb *job)
+static bool
+aio_clear_cancel_function_locked(struct kaiocb *job)
{
- struct kaioinfo *ki;
- ki = job->userproc->p_aioinfo;
- AIO_LOCK(ki);
+ AIO_LOCK_ASSERT(job->userproc->p_aioinfo, MA_OWNED);
MPASS(job->cancel_fn != NULL);
if (job->jobflags & KAIOCB_CANCELLING) {
job->jobflags |= KAIOCB_CLEARED;
- AIO_UNLOCK(ki);
return (false);
}
job->cancel_fn = NULL;
- AIO_UNLOCK(ki);
return (true);
}
bool
-aio_set_cancel_function(struct kaiocb *job, aio_cancel_fn_t *func)
+aio_clear_cancel_function(struct kaiocb *job)
{
struct kaioinfo *ki;
+ bool ret;
ki = job->userproc->p_aioinfo;
AIO_LOCK(ki);
- if (job->jobflags & KAIOCB_CANCELLED) {
- AIO_UNLOCK(ki);
+ ret = aio_clear_cancel_function_locked(job);
+ AIO_UNLOCK(ki);
+ return (ret);
+}
+
+static bool
+aio_set_cancel_function_locked(struct kaiocb *job, aio_cancel_fn_t *func)
+{
+
+ AIO_LOCK_ASSERT(job->userproc->p_aioinfo, MA_OWNED);
+ if (job->jobflags & KAIOCB_CANCELLED)
return (false);
- }
job->cancel_fn = func;
- AIO_UNLOCK(ki);
return (true);
}
+bool
+aio_set_cancel_function(struct kaiocb *job, aio_cancel_fn_t *func)
+{
+ struct kaioinfo *ki;
+ bool ret;
+
+ ki = job->userproc->p_aioinfo;
+ AIO_LOCK(ki);
+ ret = aio_set_cancel_function_locked(job, func);
+ AIO_UNLOCK(ki);
+ return (ret);
+}
+
void
aio_complete(struct kaiocb *job, long status, int error)
{
@@ -1655,10 +1673,10 @@ aio_cancel_sync(struct kaiocb *job)
struct kaioinfo *ki;
ki = job->userproc->p_aioinfo;
- mtx_lock(&aio_job_mtx);
+ AIO_LOCK(ki);
if (!aio_cancel_cleared(job))
TAILQ_REMOVE(&ki->kaio_syncqueue, job, list);
- mtx_unlock(&aio_job_mtx);
+ AIO_UNLOCK(ki);
aio_cancel(job);
}
@@ -1718,7 +1736,8 @@ queueit:
}
}
if (job->pending != 0) {
- if (!aio_set_cancel_function(job, aio_cancel_sync)) {
+ if (!aio_set_cancel_function_locked(job,
+ aio_cancel_sync)) {
AIO_UNLOCK(ki);
aio_cancel(job);
return (0);
Modified: user/alc/PQ_LAUNDRY/sys/ofed/drivers/infiniband/ulp/sdp/sdp.h
==============================================================================
--- user/alc/PQ_LAUNDRY/sys/ofed/drivers/infiniband/ulp/sdp/sdp.h Fri Jul 29 21:05:37 2016 (r303516)
+++ user/alc/PQ_LAUNDRY/sys/ofed/drivers/infiniband/ulp/sdp/sdp.h Fri Jul 29 21:07:17 2016 (r303517)
@@ -403,8 +403,7 @@ struct sdp_sock {
struct sdp_rx_ring rx_ring;
struct sdp_tx_ring tx_ring;
struct rwlock lock;
- struct mbuf *rx_ctl_q;
- struct mbuf *rx_ctl_tail;
+ struct mbufq rxctlq; /* received control packets */
int qp_active; /* XXX Flag. */
int max_sge;
@@ -456,6 +455,8 @@ struct sdp_sock {
#define SDP_RLOCK_ASSERT(ssk) rw_assert(&(ssk)->lock, RA_RLOCKED)
#define SDP_LOCK_ASSERT(ssk) rw_assert(&(ssk)->lock, RA_LOCKED)
+MALLOC_DECLARE(M_SDP);
+
static inline void tx_sa_reset(struct tx_srcavail_state *tx_sa)
{
memset((void *)&tx_sa->busy, 0,
Modified: user/alc/PQ_LAUNDRY/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c
==============================================================================
--- user/alc/PQ_LAUNDRY/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c Fri Jul 29 21:05:37 2016 (r303516)
+++ user/alc/PQ_LAUNDRY/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c Fri Jul 29 21:07:17 2016 (r303517)
@@ -64,6 +64,10 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/malloc.h>
+
#include "sdp.h"
#include <net/if.h>
@@ -86,7 +90,7 @@ RW_SYSINIT(sdplockinit, &sdp_lock, "SDP
#define SDP_LIST_RLOCK_ASSERT() rw_assert(&sdp_lock, RW_RLOCKED)
#define SDP_LIST_LOCK_ASSERT() rw_assert(&sdp_lock, RW_LOCKED)
-static MALLOC_DEFINE(M_SDP, "sdp", "Socket Direct Protocol");
+MALLOC_DEFINE(M_SDP, "sdp", "Sockets Direct Protocol");
static void sdp_stop_keepalive_timer(struct socket *so);
@@ -156,7 +160,10 @@ sdp_pcbbind(struct sdp_sock *ssk, struct
static void
sdp_pcbfree(struct sdp_sock *ssk)
{
+
KASSERT(ssk->socket == NULL, ("ssk %p socket still attached", ssk));
+ KASSERT((ssk->flags & SDP_DESTROY) == 0,
+ ("ssk %p already destroyed", ssk));
sdp_dbg(ssk->socket, "Freeing pcb");
SDP_WLOCK_ASSERT(ssk);
@@ -167,7 +174,6 @@ sdp_pcbfree(struct sdp_sock *ssk)
LIST_REMOVE(ssk, list);
SDP_LIST_WUNLOCK();
crfree(ssk->cred);
- sdp_destroy_cma(ssk);
ssk->qp_active = 0;
if (ssk->qp) {
ib_destroy_qp(ssk->qp);
@@ -175,9 +181,10 @@ sdp_pcbfree(struct sdp_sock *ssk)
}
sdp_tx_ring_destroy(ssk);
sdp_rx_ring_destroy(ssk);
+ sdp_destroy_cma(ssk);
rw_destroy(&ssk->rx_ring.destroyed_lock);
- uma_zfree(sdp_zone, ssk);
rw_destroy(&ssk->lock);
+ uma_zfree(sdp_zone, ssk);
}
/*
@@ -469,6 +476,7 @@ sdp_attach(struct socket *so, int proto,
ssk->flags = 0;
ssk->qp_active = 0;
ssk->state = TCPS_CLOSED;
+ mbufq_init(&ssk->rxctlq, INT_MAX);
SDP_LIST_WLOCK();
LIST_INSERT_HEAD(&sdp_list, ssk, list);
sdp_count++;
Modified: user/alc/PQ_LAUNDRY/sys/ofed/drivers/infiniband/ulp/sdp/sdp_rx.c
==============================================================================
--- user/alc/PQ_LAUNDRY/sys/ofed/drivers/infiniband/ulp/sdp/sdp_rx.c Fri Jul 29 21:05:37 2016 (r303516)
+++ user/alc/PQ_LAUNDRY/sys/ofed/drivers/infiniband/ulp/sdp/sdp_rx.c Fri Jul 29 21:07:17 2016 (r303517)
@@ -175,7 +175,7 @@ sdp_post_recvs_needed(struct sdp_sock *s
return 1;
buffer_size = ssk->recv_bytes;
- max_bytes = max(ssk->socket->so_snd.sb_hiwat,
+ max_bytes = max(ssk->socket->so_rcv.sb_hiwat,
(1 + SDP_MIN_TX_CREDITS) * buffer_size);
max_bytes *= rcvbuf_scale;
/*
@@ -319,14 +319,14 @@ sdp_recv_completion(struct sdp_sock *ssk
return mb;
}
-/* socket lock should be taken before calling this */
-static int
+static void
sdp_process_rx_ctl_mb(struct sdp_sock *ssk, struct mbuf *mb)
{
struct sdp_bsdh *h;
struct socket *sk;
SDP_WLOCK_ASSERT(ssk);
+
sk = ssk->socket;
h = mtod(mb, struct sdp_bsdh *);
switch (h->mid) {
@@ -339,16 +339,13 @@ sdp_process_rx_ctl_mb(struct sdp_sock *s
sdp_dbg(sk, "RX data when state = FIN_WAIT1\n");
sdp_notify(ssk, ECONNRESET);
}
- m_freem(mb);
break;
#ifdef SDP_ZCOPY
case SDP_MID_RDMARDCOMPL:
- m_freem(mb);
break;
case SDP_MID_SENDSM:
sdp_handle_sendsm(ssk, ntohl(h->mseq_ack));
- m_freem(mb);
break;
case SDP_MID_SRCAVAIL_CANCEL:
sdp_dbg_data(sk, "Handling SrcAvailCancel\n");
@@ -362,7 +359,6 @@ sdp_process_rx_ctl_mb(struct sdp_sock *s
sdp_dbg(sk, "Got SrcAvailCancel - "
"but no SrcAvail in process\n");
}
- m_freem(mb);
break;
case SDP_MID_SINKAVAIL:
sdp_dbg_data(sk, "Got SinkAvail - not supported: ignored\n");
@@ -373,7 +369,6 @@ sdp_process_rx_ctl_mb(struct sdp_sock *s
sdp_dbg_data(sk, "Handling ABORT\n");
sdp_prf(sk, NULL, "Handling ABORT");
sdp_notify(ssk, ECONNRESET);
- m_freem(mb);
break;
case SDP_MID_DISCONN:
sdp_dbg_data(sk, "Handling DISCONN\n");
@@ -383,20 +378,17 @@ sdp_process_rx_ctl_mb(struct sdp_sock *s
case SDP_MID_CHRCVBUF:
sdp_dbg_data(sk, "Handling RX CHRCVBUF\n");
sdp_handle_resize_request(ssk, (struct sdp_chrecvbuf *)(h+1));
- m_freem(mb);
break;
case SDP_MID_CHRCVBUF_ACK:
sdp_dbg_data(sk, "Handling RX CHRCVBUF_ACK\n");
sdp_handle_resize_ack(ssk, (struct sdp_chrecvbuf *)(h+1));
- m_freem(mb);
break;
default:
/* TODO: Handle other messages */
sdp_warn(sk, "SDP: FIXME MID %d\n", h->mid);
- m_freem(mb);
+ break;
}
-
- return 0;
+ m_freem(mb);
}
static int
*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
More information about the svn-src-user
mailing list