svn commit: r218211 - in head/sys: conf netinet

2011-02-03 Thread Randall Stewart
Author: rrs
Date: Thu Feb  3 10:05:30 2011
New Revision: 218211
URL: http://svn.freebsd.org/changeset/base/218211

Log:
  Adds an experimental option to create a pool of
  threads. These serve as input threads and are queued
  packets based on the V-tag number. This is similar to
  what a modern card can do with queue's for TCP... but
  alas modern cards know nothing about SCTP.
  
  MFC after:3 months (maybe)

Modified:
  head/sys/conf/options
  head/sys/netinet/sctp_bsd_addr.c
  head/sys/netinet/sctp_constants.h
  head/sys/netinet/sctp_input.c
  head/sys/netinet/sctp_lock_bsd.h
  head/sys/netinet/sctp_os_bsd.h
  head/sys/netinet/sctp_pcb.c
  head/sys/netinet/sctp_pcb.h
  head/sys/netinet/sctp_structs.h

Modified: head/sys/conf/options
==
--- head/sys/conf/options   Thu Feb  3 08:55:45 2011(r218210)
+++ head/sys/conf/options   Thu Feb  3 10:05:30 2011(r218211)
@@ -439,6 +439,7 @@ SCTP_PACKET_LOGGING opt_sctp.h # Log to 
 SCTP_LTRACE_CHUNKS opt_sctp.h # Log to KTR chunks processed
 SCTP_LTRACE_ERRORS opt_sctp.h # Log to KTR error returns.
 SCTP_USE_PERCPU_STATopt_sctp.h # Use per cpu stats.
+SCTP_MCORE_INPUTopt_sctp.h # Have multiple input threads for input 
mbufs
 #
 #
 #

Modified: head/sys/netinet/sctp_bsd_addr.c
==
--- head/sys/netinet/sctp_bsd_addr.cThu Feb  3 08:55:45 2011
(r218210)
+++ head/sys/netinet/sctp_bsd_addr.cThu Feb  3 10:05:30 2011
(r218211)
@@ -68,6 +68,7 @@ MALLOC_DEFINE(SCTP_M_TIMW, "sctp_timw", 
 MALLOC_DEFINE(SCTP_M_MVRF, "sctp_mvrf", "sctp mvrf pcb list");
 MALLOC_DEFINE(SCTP_M_ITER, "sctp_iter", "sctp iterator control");
 MALLOC_DEFINE(SCTP_M_SOCKOPT, "sctp_socko", "sctp socket option");
+MALLOC_DEFINE(SCTP_M_MCORE, "sctp_mcore", "sctp mcore queue");
 
 /* Global NON-VNET structure that controls the iterator */
 struct iterator_control sctp_it_ctl;

Modified: head/sys/netinet/sctp_constants.h
==
--- head/sys/netinet/sctp_constants.h   Thu Feb  3 08:55:45 2011
(r218210)
+++ head/sys/netinet/sctp_constants.h   Thu Feb  3 10:05:30 2011
(r218211)
@@ -91,6 +91,8 @@ __FBSDID("$FreeBSD$");
 #define SCTP_KTRHEAD_NAME "sctp_iterator"
 #define SCTP_KTHREAD_PAGES 0
 
+#define SCTP_MCORE_NAME "sctp_core_worker"
+
 
 /* If you support Multi-VRF how big to
  * make the initial array of VRF's to.

Modified: head/sys/netinet/sctp_input.c
==
--- head/sys/netinet/sctp_input.c   Thu Feb  3 08:55:45 2011
(r218210)
+++ head/sys/netinet/sctp_input.c   Thu Feb  3 10:05:30 2011
(r218211)
@@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 
 
 
@@ -5921,10 +5922,32 @@ bad:
}
return;
 }
+
+
 void
-sctp_input(i_pak, off)
-   struct mbuf *i_pak;
-   int off;
+sctp_input(struct mbuf *m, int off)
 {
-   sctp_input_with_port(i_pak, off, 0);
+#if defined(__FreeBSD__) && defined(SCTP_MCORE_INPUT) && defined(SMP)
+   struct ip *ip;
+   struct sctphdr *sh;
+   int offset;
+   int cpu_to_use;
+
+   if (mp_ncpus > 1) {
+   ip = mtod(m, struct ip *);
+   offset = off + sizeof(*sh);
+   if (SCTP_BUF_LEN(m) < offset) {
+   if ((m = m_pullup(m, offset)) == 0) {
+   SCTP_STAT_INCR(sctps_hdrops);
+   return;
+   }
+   ip = mtod(m, struct ip *);
+   }
+   sh = (struct sctphdr *)((caddr_t)ip + off);
+   cpu_to_use = ntohl(sh->v_tag) % mp_ncpus;
+   sctp_queue_to_mcore(m, off, cpu_to_use);
+   return;
+   }
+#endif
+   sctp_input_with_port(m, off, 0);
 }

Modified: head/sys/netinet/sctp_lock_bsd.h
==
--- head/sys/netinet/sctp_lock_bsd.hThu Feb  3 08:55:45 2011
(r218210)
+++ head/sys/netinet/sctp_lock_bsd.hThu Feb  3 10:05:30 2011
(r218211)
@@ -97,6 +97,48 @@ extern int sctp_logoff_stuff;
  rw_rlock(&SCTP_BASE_INFO(ipi_ep_mtx)); \
 } while (0)
 
+#define SCTP_MCORE_QLOCK_INIT(cpstr) do { \
+   mtx_init(&(cpstr)->que_mtx,   \
+"sctp-mcore_queue","queue_lock",   \
+MTX_DEF|MTX_DUPOK);\
+} while (0)
+
+#define SCTP_MCORE_QLOCK(cpstr)  do { \
+   mtx_lock(&(cpstr)->que_mtx);\
+} while (0)
+
+#define SCTP_MCORE_QUNLOCK(cpstr)  do { \
+   mtx_unlock(&(cpstr)->que_mtx);  \
+} while (0)
+
+#define SCTP_MCORE_QDESTROY(cpstr)  do { \
+   if(mtx_owned(&(cpstr)->core_mtx)) { \
+   

svn commit: r218214 - head/sbin/hastd

2011-02-03 Thread Pawel Jakub Dawidek
Author: pjd
Date: Thu Feb  3 10:37:44 2011
New Revision: 218214
URL: http://svn.freebsd.org/changeset/base/218214

Log:
  Let the caller log info about successful privilege drop.
  We don't want to log this in hastctl.
  
  MFC after:1 week

Modified:
  head/sbin/hastd/primary.c
  head/sbin/hastd/secondary.c
  head/sbin/hastd/subr.c

Modified: head/sbin/hastd/primary.c
==
--- head/sbin/hastd/primary.c   Thu Feb  3 10:29:04 2011(r218213)
+++ head/sbin/hastd/primary.c   Thu Feb  3 10:37:44 2011(r218214)
@@ -850,6 +850,7 @@ hastd_primary(struct hast_resource *res)
cleanup(res);
exit(EX_CONFIG);
}
+   pjdlog_info("Privileges successfully dropped.");
 
/*
 * Create the guard thread first, so we can handle signals from the

Modified: head/sbin/hastd/secondary.c
==
--- head/sbin/hastd/secondary.c Thu Feb  3 10:29:04 2011(r218213)
+++ head/sbin/hastd/secondary.c Thu Feb  3 10:37:44 2011(r218214)
@@ -414,6 +414,7 @@ hastd_secondary(struct hast_resource *re
 
if (drop_privs() != 0)
exit(EX_CONFIG);
+   pjdlog_info("Privileges successfully dropped.");
 
/*
 * Create the control thread before sending any event to the parent,

Modified: head/sbin/hastd/subr.c
==
--- head/sbin/hastd/subr.c  Thu Feb  3 10:29:04 2011(r218213)
+++ head/sbin/hastd/subr.c  Thu Feb  3 10:37:44 2011(r218214)
@@ -184,7 +184,5 @@ drop_privs(void)
PJDLOG_VERIFY(getgroups(1, gidset) == 1);
PJDLOG_VERIFY(gidset[0] == pw->pw_gid);
 
-   pjdlog_info("Privileges successfully dropped.");
-
return (0);
 }
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218215 - head/sbin/hastctl

2011-02-03 Thread Pawel Jakub Dawidek
Author: pjd
Date: Thu Feb  3 10:44:40 2011
New Revision: 218215
URL: http://svn.freebsd.org/changeset/base/218215

Log:
  Drop privileges after connecting to hastd, but before sending or receiving
  anything.
  
  MFC after:1 week

Modified:
  head/sbin/hastctl/hastctl.c

Modified: head/sbin/hastctl/hastctl.c
==
--- head/sbin/hastctl/hastctl.c Thu Feb  3 10:37:44 2011(r218214)
+++ head/sbin/hastctl/hastctl.c Thu Feb  3 10:44:40 2011(r218215)
@@ -491,6 +491,11 @@ main(int argc, char *argv[])
pjdlog_exit(EX_OSERR, "Unable to connect to hastd via %s",
cfg->hc_controladdr);
}
+
+   if (drop_privs() != 0)
+   exit(EX_CONFIG);
+   pjdlog_debug(1, "Privileges successfully dropped.");
+
/* Send the command to the server... */
if (hast_proto_send(NULL, controlconn, nv, NULL, 0) < 0) {
pjdlog_exit(EX_UNAVAILABLE,
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218217 - head/sbin/hastd

2011-02-03 Thread Pawel Jakub Dawidek
Author: pjd
Date: Thu Feb  3 11:33:32 2011
New Revision: 218217
URL: http://svn.freebsd.org/changeset/base/218217

Log:
  Add missing locking after moving keepalive_send() to remote send thread
  in r214692.
  
  MFC after:1 week

Modified:
  head/sbin/hastd/primary.c

Modified: head/sbin/hastd/primary.c
==
--- head/sbin/hastd/primary.c   Thu Feb  3 11:09:27 2011(r218216)
+++ head/sbin/hastd/primary.c   Thu Feb  3 11:33:32 2011(r218217)
@@ -1230,8 +1230,12 @@ keepalive_send(struct hast_resource *res
 {
struct nv *nv;
 
-   if (!ISCONNECTED(res, ncomp))
+   rw_rlock(&hio_remote_lock[ncomp]);
+
+   if (!ISCONNECTED(res, ncomp)) {
+   rw_unlock(&hio_remote_lock[ncomp]);
return;
+   }

PJDLOG_ASSERT(res->hr_remotein != NULL);
PJDLOG_ASSERT(res->hr_remoteout != NULL);
@@ -1239,20 +1243,22 @@ keepalive_send(struct hast_resource *res
nv = nv_alloc();
nv_add_uint8(nv, HIO_KEEPALIVE, "cmd");
if (nv_error(nv) != 0) {
+   rw_unlock(&hio_remote_lock[ncomp]);
nv_free(nv);
pjdlog_debug(1,
"keepalive_send: Unable to prepare header to send.");
return;
}
if (hast_proto_send(res, res->hr_remoteout, nv, NULL, 0) < 0) {
+   rw_unlock(&hio_remote_lock[ncomp]);
pjdlog_common(LOG_DEBUG, 1, errno,
"keepalive_send: Unable to send request");
nv_free(nv);
-   rw_unlock(&hio_remote_lock[ncomp]);
remote_close(res, ncomp);
-   rw_rlock(&hio_remote_lock[ncomp]);
return;
}
+
+   rw_unlock(&hio_remote_lock[ncomp]);
nv_free(nv);
pjdlog_debug(2, "keepalive_send: Request sent.");
 }
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218218 - head/sbin/hastd

2011-02-03 Thread Pawel Jakub Dawidek
Author: pjd
Date: Thu Feb  3 11:39:49 2011
New Revision: 218218
URL: http://svn.freebsd.org/changeset/base/218218

Log:
  Setup another socketpair between parent and child, so that primary sandboxed
  worker can ask the main privileged process to connect in worker's behalf
  and then we can migrate descriptor using this socketpair to worker.
  This is not really needed now, but will be needed once we start to use
  capsicum for sandboxing.
  
  MFC after:1 week

Modified:
  head/sbin/hastd/control.c
  head/sbin/hastd/hast.h
  head/sbin/hastd/hastd.c
  head/sbin/hastd/primary.c
  head/sbin/hastd/secondary.c

Modified: head/sbin/hastd/control.c
==
--- head/sbin/hastd/control.c   Thu Feb  3 11:33:32 2011(r218217)
+++ head/sbin/hastd/control.c   Thu Feb  3 11:39:49 2011(r218218)
@@ -62,6 +62,10 @@ child_cleanup(struct hast_resource *res)
proto_close(res->hr_event);
res->hr_event = NULL;
}
+   if (res->hr_conn != NULL) {
+   proto_close(res->hr_conn);
+   res->hr_conn = NULL;
+   }
res->hr_workerpid = 0;
 }
 

Modified: head/sbin/hastd/hast.h
==
--- head/sbin/hastd/hast.h  Thu Feb  3 11:33:32 2011(r218217)
+++ head/sbin/hastd/hast.h  Thu Feb  3 11:39:49 2011(r218218)
@@ -182,10 +182,12 @@ struct hast_resource {
int hr_previous_role;
/* PID of child worker process. 0 - no child. */
pid_t   hr_workerpid;
-   /* Control connection between parent and child. */
+   /* Control commands from parent to child. */
struct proto_conn *hr_ctrl;
/* Events from child to parent. */
struct proto_conn *hr_event;
+   /* Connection requests from child to parent. */
+   struct proto_conn *hr_conn;
 
/* Activemap structure. */
struct activemap *hr_amp;

Modified: head/sbin/hastd/hastd.c
==
--- head/sbin/hastd/hastd.c Thu Feb  3 11:33:32 2011(r218217)
+++ head/sbin/hastd/hastd.c Thu Feb  3 11:39:49 2011(r218218)
@@ -214,6 +214,19 @@ descriptors_assert(const struct hast_res
fd, dtype2str(mode), dtype2str(S_IFSOCK));
break;
}
+   } else if (fd == proto_descriptor(res->hr_conn)) {
+   if (!isopen) {
+   snprintf(msg, sizeof(msg),
+   "Descriptor %d (conn) is closed, but should 
be open.",
+   fd);
+   break;
+   }
+   if (!S_ISSOCK(mode)) {
+   snprintf(msg, sizeof(msg),
+   "Descriptor %d (conn) is %s, but should be 
%s.",
+   fd, dtype2str(mode), dtype2str(S_IFSOCK));
+   break;
+   }
} else if (res->hr_role == HAST_ROLE_SECONDARY &&
fd == proto_descriptor(res->hr_remotein)) {
if (!isopen) {
@@ -802,6 +815,41 @@ close:
 }
 
 static void
+connection_migrate(struct hast_resource *res)
+{
+   struct proto_conn *conn;
+   int16_t val = 0;
+
+   if (proto_recv(res->hr_conn, &val, sizeof(val)) < 0) {
+   pjdlog_errno(LOG_WARNING,
+   "Unable to receive connection command");
+   return;
+   }
+   if (proto_client(res->hr_remoteaddr, &conn) < 0) {
+   val = errno;
+   pjdlog_errno(LOG_WARNING,
+   "Unable to create outgoing connection to %s",
+   res->hr_remoteaddr);
+   goto out;
+   }
+   if (proto_connect(conn, -1) < 0) {
+   val = errno;
+   pjdlog_errno(LOG_WARNING, "Unable to connect to %s",
+   res->hr_remoteaddr);
+   proto_close(conn);
+   goto out;
+   }
+   val = 0;
+out:
+   if (proto_send(res->hr_conn, &val, sizeof(val)) < 0) {
+   pjdlog_errno(LOG_WARNING,
+   "Unable to send reply to connection request");
+   }
+   if (val == 0 && proto_connection_send(res->hr_conn, conn) < 0)
+   pjdlog_errno(LOG_WARNING, "Unable to send connection");
+}
+
+static void
 main_loop(void)
 {
struct hast_resource *res;
@@ -858,10 +906,18 @@ main_loop(void)
TAILQ_FOREACH(res, &cfg->hc_resources, hr_next) {
if (res->hr_event == NULL)
continue;
+   PJDLOG_ASSERT(res->hr_conn != NULL);
fd = proto_descriptor(res->hr_event);
PJ

svn commit: r218219 - head/sys/netinet

2011-02-03 Thread Randall Stewart
Author: rrs
Date: Thu Feb  3 11:52:22 2011
New Revision: 218219
URL: http://svn.freebsd.org/changeset/base/218219

Log:
  Fix the per CPU stats so that:
  1) They don't use the giant "MAX_CPU" define and instead
 are allocated dynamically based on mp_ncpus
  2) Will zero with the netstat -z -s -p sctp
  3) Will be properly handled by both the sctp_init and finish
 (the multi-net stuff was incorrectly bzero'ing in sctp_init
  the wrong size.. the bzero is now moved to the right places).
  And of course the free is put in at the very end.
  
  MFC after:3 Months

Modified:
  head/sys/netinet/sctp_pcb.c
  head/sys/netinet/sctp_pcb.h
  head/sys/netinet/sctp_sysctl.c
  head/sys/netinet/sctp_usrreq.c

Modified: head/sys/netinet/sctp_pcb.c
==
--- head/sys/netinet/sctp_pcb.c Thu Feb  3 11:39:49 2011(r218218)
+++ head/sys/netinet/sctp_pcb.c Thu Feb  3 11:52:22 2011(r218219)
@@ -1,5 +1,8 @@
 /*-
  * Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved.
+ * Copyright (c) 2008-2011, by Randall Stewart, r...@lakerest.net and
+ *  Michael Tuexen, tue...@fh-muenster.de
+ *  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -5599,11 +5602,18 @@ sctp_pcb_init()
 #if defined(SCTP_LOCAL_TRACE_BUF)
bzero(&SCTP_BASE_SYSCTL(sctp_log), sizeof(struct sctp_log));
 #endif
+#if defined(__FreeBSD__) && defined(SMP) && defined(SCTP_USE_PERCPU_STAT)
+   SCTP_MALLOC(SCTP_BASE_STATS, struct sctpstat *,
+   (mp_ncpus * sizeof(struct sctpstat)),
+   SCTP_M_MCORE);
+#endif
(void)SCTP_GETTIME_TIMEVAL(&tv);
 #if defined(__FreeBSD__) && defined(SMP) && defined(SCTP_USE_PERCPU_STAT)
+   bzero(SCTP_BASE_STATS, (sizeof(struct sctpstat) * mp_ncpus));
SCTP_BASE_STATS[PCPU_GET(cpuid)].sctps_discontinuitytime.tv_sec = 
(uint32_t) tv.tv_sec;
SCTP_BASE_STATS[PCPU_GET(cpuid)].sctps_discontinuitytime.tv_usec = 
(uint32_t) tv.tv_usec;
 #else
+   bzero(&SCTP_BASE_STATS, sizeof(struct sctpstat));
SCTP_BASE_STAT(sctps_discontinuitytime).tv_sec = (uint32_t) tv.tv_sec;
SCTP_BASE_STAT(sctps_discontinuitytime).tv_usec = (uint32_t) tv.tv_usec;
 #endif
@@ -5846,7 +5856,9 @@ sctp_pcb_finish(void)
SCTP_HASH_FREE(SCTP_BASE_INFO(sctp_ephash), 
SCTP_BASE_INFO(hashmark));
if (SCTP_BASE_INFO(sctp_tcpephash) != NULL)
SCTP_HASH_FREE(SCTP_BASE_INFO(sctp_tcpephash), 
SCTP_BASE_INFO(hashtcpmark));
-
+#if defined(__FreeBSD__) && defined(SMP) && defined(SCTP_USE_PERCPU_STAT)
+   SCTP_FREE(SCTP_BASE_STATS, SCTP_M_MCORE);
+#endif
 }
 
 

Modified: head/sys/netinet/sctp_pcb.h
==
--- head/sys/netinet/sctp_pcb.h Thu Feb  3 11:39:49 2011(r218218)
+++ head/sys/netinet/sctp_pcb.h Thu Feb  3 11:52:22 2011(r218219)
@@ -1,6 +1,8 @@
 /*-
  * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
- *
+ * Copyright (c) 2008-2011, by Randall Stewart, r...@lakerest.net and
+ *  Michael Tuexen, tue...@fh-muenster.de
+ *  All rights reserved.
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
  *
@@ -240,7 +242,7 @@ struct sctp_base_info {
 */
struct sctp_epinfo sctppcbinfo;
 #if defined(__FreeBSD__) && defined(SMP) && defined(SCTP_USE_PERCPU_STAT)
-   struct sctpstat sctpstat[MAXCPU];
+   struct sctpstat *sctpstat;
 #else
struct sctpstat sctpstat;
 #endif

Modified: head/sys/netinet/sctp_sysctl.c
==
--- head/sys/netinet/sctp_sysctl.c  Thu Feb  3 11:39:49 2011
(r218218)
+++ head/sys/netinet/sctp_sysctl.c  Thu Feb  3 11:52:22 2011
(r218219)
@@ -1,5 +1,8 @@
 /*-
  * Copyright (c) 2007, by Cisco Systems, Inc. All rights reserved.
+ * Copyright (c) 2008-2011, by Randall Stewart, r...@lakerest.net and
+ *  Michael Tuexen, tue...@fh-muenster.de
+ *  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -648,8 +651,18 @@ static int
 sysctl_stat_get(SYSCTL_HANDLER_ARGS)
 {
int cpu, error;
-   struct sctpstat sb, *sarry;
+   struct sctpstat sb, *sarry, *cpin = NULL;
 
+   if ((req->newptr) && (req->newlen == sizeof(struct sctpstat))) {
+   /*
+* User wants us to clear or at least reset the counters to
+* the specified values.
+*/
+   cpin = (struct s

svn commit: r218221 - head/sys/x86/x86

2011-02-03 Thread John Baldwin
Author: jhb
Date: Thu Feb  3 13:09:22 2011
New Revision: 218221
URL: http://svn.freebsd.org/changeset/base/218221

Log:
  Use a dedicated taskqueue with a thread that runs at a software-interrupt
  priority for the periodic polling of the machine check registers.

Modified:
  head/sys/x86/x86/mca.c

Modified: head/sys/x86/x86/mca.c
==
--- head/sys/x86/x86/mca.c  Thu Feb  3 12:19:07 2011(r218220)
+++ head/sys/x86/x86/mca.c  Thu Feb  3 13:09:22 2011(r218221)
@@ -105,6 +105,7 @@ SYSCTL_INT(_hw_mca, OID_AUTO, erratum383
 static STAILQ_HEAD(, mca_internal) mca_records;
 static struct callout mca_timer;
 static int mca_ticks = 3600;   /* Check hourly by default. */
+static struct taskqueue *mca_tq;
 static struct task mca_task;
 static struct mtx mca_lock;
 
@@ -606,7 +607,7 @@ static void
 mca_periodic_scan(void *arg)
 {
 
-   taskqueue_enqueue(taskqueue_thread, &mca_task);
+   taskqueue_enqueue(mca_tq, &mca_task);
callout_reset(&mca_timer, mca_ticks * hz, mca_periodic_scan, NULL);
 }
 
@@ -620,7 +621,7 @@ sysctl_mca_scan(SYSCTL_HANDLER_ARGS)
if (error)
return (error);
if (i)
-   taskqueue_enqueue(taskqueue_thread, &mca_task);
+   taskqueue_enqueue(mca_tq, &mca_task);
return (0);
 }
 
@@ -631,6 +632,9 @@ mca_startup(void *dummy)
if (!mca_enabled || !(cpu_feature & CPUID_MCA))
return;
 
+   mca_tq = taskqueue_create("mca", M_WAITOK, taskqueue_thread_enqueue,
+   &mca_tq);
+   taskqueue_start_threads(&mca_tq, 1, PI_SWI(SWI_TQ), "mca taskq");
callout_reset(&mca_timer, mca_ticks * hz, mca_periodic_scan,
NULL);
 }
@@ -670,7 +674,7 @@ mca_setup(uint64_t mcg_cap)
 
mtx_init(&mca_lock, "mca", NULL, MTX_SPIN);
STAILQ_INIT(&mca_records);
-   TASK_INIT(&mca_task, 0x8000, mca_scan_cpus, NULL);
+   TASK_INIT(&mca_task, 0, mca_scan_cpus, NULL);
callout_init(&mca_timer, CALLOUT_MPSAFE);
SYSCTL_ADD_INT(NULL, SYSCTL_STATIC_CHILDREN(_hw_mca), OID_AUTO,
"count", CTLFLAG_RD, &mca_count, 0, "Record count");
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r218195 - in head/sys: amd64/amd64 arm/arm i386/i386 ia64/ia64 kern mips/mips powerpc/powerpc sparc64/sparc64 sun4v/sun4v sys ufs/ffs

2011-02-03 Thread Bruce Evans

On Wed, 2 Feb 2011, Juli Mallett wrote:


On Wed, Feb 2, 2011 at 08:35, Matthew D Fleming  wrote:

Author: mdf
Date: Wed Feb ?2 16:35:10 2011
New Revision: 218195
URL: http://svn.freebsd.org/changeset/base/218195

Log:
?Put the general logic for being a CPU hog into a new function
?should_yield(). ?Use this in various places. ?Encapsulate the common
?case of check-and-yield into a new function maybe_yield().

?Change several checks for a magic number of iterations to use
?should_yield() instead.


Grr, hard \xa0.


First off, I admittedly don't know or care very much about this area,
but this commit stood out to me and I had a few minor concerns.


I sent a long private mail saying how it is quite broken.  The hogticks
hasn't worked for 10.4 years, since switchtime is reset on every context
switch and there are lots of context switches for ithreads).  Thus
should_yield() almost always returns false, and the old code that used
its logic was mostly dead.  The old code that didn't use its logic
worked, but now mostly doesn't.  Also, preemption makes the non-preemptive
yielding mostly unnecessary.  When preemption occurs, it doesn't do
the right thing in cases where it is necessary to drop all locks, while
manual yielding does. But preemption certainly resets switchtime, so
if is happening then sched_yield() returns false always instead of
only almost always.  (Almost always is when the context switch rate
is less than 5 Hz.  Non-fast interrups at more than 5 Hz normally
prevent this.)


I'm slightly uncomfortable with the flat namespace here.  It isn't
obvious from the names that maybe_yield() and should_yield() relate
only to uio_yield() and not other types of yielding (from DELAY() to
cpu_idle() to sched_yield().)  The other problematic element here is


I noted many namespace problems too, starting with my static uio_yield()
already being exported for abuse by non-uio things.


Linuxy.  I think names like uio_should_yield() and uio_maybe_yield()
wouldn't have nearly as much of a problem, since the context of the
question of "should" is isolated to uio operations rather than, say,
whether the scheduler would *like* for us, as the running thread, to
yield, or other considerations that may be more general.


But this has nothing to do with uio.   The uio case has been most
perfectly broken for 10.4 years, since the uio_yield() calls for actual
uio things are the main places that use the should_yield() condition.
Non-uio places mostly did an unconditional uio_yield(), and this worked.
I think uio also doesn't hold any locks, for the same reason that
copyin()/out() don't (it might fault and have to sleep for a long time).
Thus preemption works right for the uio case, and its perfect brokenness
10.4 years ago turned into mostly just dead code when the kernel became
preemptible.

The breakage is perfect in bdeBSD, since it uses ithreads for clock
interrupts.  Thus switchticks is guaranteed to be reset by the same
interrupts that advance `ticks', and so (ticks - switchticks) is
either 0 or 1 (mostly 1?).

Bruce___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Re: svn commit: r218219 - head/sys/netinet

2011-02-03 Thread John Baldwin
On Thursday, February 03, 2011 6:52:22 am Randall Stewart wrote:
> Author: rrs
> Date: Thu Feb  3 11:52:22 2011
> New Revision: 218219
> URL: http://svn.freebsd.org/changeset/base/218219
> 
> Log:
>   Fix the per CPU stats so that:
>   1) They don't use the giant "MAX_CPU" define and instead
>  are allocated dynamically based on mp_ncpus

You probably want to use mp_maxid instead.  CPU IDs are not guaranteed to be 
contiguous (though they currently are).  Instead, the only guarantee are that 
there are mp_ncpus CPUs numbered 0 ... mp_maxid.  There may be gaps in that 
range (and there have been in the past).

-- 
John Baldwin
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r218195 - in head/sys: amd64/amd64 arm/arm i386/i386 ia64/ia64 kern mips/mips powerpc/powerpc sparc64/sparc64 sun4v/sun4v sys ufs/ffs

2011-02-03 Thread John Baldwin
On Thursday, February 03, 2011 2:47:20 am Juli Mallett wrote:
> On Wed, Feb 2, 2011 at 08:35, Matthew D Fleming  wrote:
> > Author: mdf
> > Date: Wed Feb  2 16:35:10 2011
> > New Revision: 218195
> > URL: http://svn.freebsd.org/changeset/base/218195
> >
> > Log:
> >  Put the general logic for being a CPU hog into a new function
> >  should_yield().  Use this in various places.  Encapsulate the common
> >  case of check-and-yield into a new function maybe_yield().
> >
> >  Change several checks for a magic number of iterations to use
> >  should_yield() instead.
> 
> First off, I admittedly don't know or care very much about this area,
> but this commit stood out to me and I had a few minor concerns.
> 
> I'm slightly uncomfortable with the flat namespace here.  It isn't
> obvious from the names that maybe_yield() and should_yield() relate
> only to uio_yield() and not other types of yielding (from DELAY() to
> cpu_idle() to sched_yield().)  The other problematic element here is
> that "maybe_yield" and "should_yield" could quite reasonably be
> variables or functions in existing code in the kernel, and although we
> don't try to protect against changes that could cause such collisions,
> we shouldn't do them gratuitously, and there's even something that
> seems aesthetically off about these; they seem...informal, even
> Linuxy.  I think names like uio_should_yield() and uio_maybe_yield()
> wouldn't have nearly as much of a problem, since the context of the
> question of "should" is isolated to uio operations rather than, say,
> whether the scheduler would *like* for us, as the running thread, to
> yield, or other considerations that may be more general.

I mostly agree, but these checks are no longer specific to uio.  Matt used 
them to replace many ad-hoc checks using counters with hardcoded maximums in 
places like softupdates, etc.

I don't have any good suggestions for what else you would call these.  I'm not 
sure 'sched_amcpuhog() or sched_hoggingcpu()' are really better (and these are 
not scheduler dependent, so sched_ would probably not be a good prefix).

-- 
John Baldwin
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218223 - head/sys/kern

2011-02-03 Thread Alan Cox
Author: alc
Date: Thu Feb  3 14:42:46 2011
New Revision: 218223
URL: http://svn.freebsd.org/changeset/base/218223

Log:
  Eliminate unnecessary page hold_count checks.  These checks predate
  r90944, which introduced a general mechanism for handling the freeing
  of held pages.
  
  Reviewed by:  kib@

Modified:
  head/sys/kern/uipc_syscalls.c
  head/sys/kern/vfs_bio.c

Modified: head/sys/kern/uipc_syscalls.c
==
--- head/sys/kern/uipc_syscalls.c   Thu Feb  3 13:10:13 2011
(r218222)
+++ head/sys/kern/uipc_syscalls.c   Thu Feb  3 14:42:46 2011
(r218223)
@@ -2115,8 +2115,7 @@ retry_space:
 * then free it.
 */
if (pg->wire_count == 0 && pg->valid == 0 &&
-   pg->busy == 0 && !(pg->oflags & VPO_BUSY) &&
-   pg->hold_count == 0)
+   pg->busy == 0 && !(pg->oflags & VPO_BUSY))
vm_page_free(pg);
vm_page_unlock(pg);
VM_OBJECT_UNLOCK(obj);

Modified: head/sys/kern/vfs_bio.c
==
--- head/sys/kern/vfs_bio.c Thu Feb  3 13:10:13 2011(r218222)
+++ head/sys/kern/vfs_bio.c Thu Feb  3 14:42:46 2011(r218223)
@@ -1647,8 +1647,7 @@ vfs_vmio_release(struct buf *bp)
 * no valid data.  We also free the page if the
 * buffer was used for direct I/O
 */
-   if ((bp->b_flags & B_ASYNC) == 0 && !m->valid &&
-   m->hold_count == 0) {
+   if ((bp->b_flags & B_ASYNC) == 0 && !m->valid) {
vm_page_free(m);
} else if (bp->b_flags & B_DIRECT) {
vm_page_try_to_free(m);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218225 - head/contrib/bsnmp

2011-02-03 Thread Hartmut Brandt
Author: harti
Date: Thu Feb  3 15:19:18 2011
New Revision: 218225
URL: http://svn.freebsd.org/changeset/base/218225

Log:
  Bring the list of OIDs up-to-date to prevent conflicts.

Modified:
  head/contrib/bsnmp/oid-list

Modified: head/contrib/bsnmp/oid-list
==
--- head/contrib/bsnmp/oid-list Thu Feb  3 15:13:15 2011(r218224)
+++ head/contrib/bsnmp/oid-list Thu Feb  3 15:19:18 2011(r218225)
@@ -1,4 +1,4 @@
-$Begemot: bsnmp/oid-list,v 1.5 2006/02/27 09:55:45 brandt_h Exp $
+$Begemot: bsnmp/trunk/oid-list 1512 2011-02-03 15:16:22Z brandt_h $
 
 This file documents the OID assignments under BSNMP's private OID.
 
@@ -12,12 +12,30 @@ enterprises
   1BEGEMOT-SNMPD
   2BEGEMOT-NETGRAPHsnmpd netgraph module
   3BEGEMOT-IP  snmpd IP related stuff.
+  4BEGEMOT-IFACE-MIB   interface MIB private stuff
+  5BEGEMOT-IPSTATS-MIB IP statistics
+  6BEGEMOT-IP-MIB  IP objects
   100  BEGEMOT-ILMID   snmpd ILMID module
   101  BEGEMOT-ATM snmpd ATM module
   200  BEGEMOT-PF  snmpd PF module (phil...@freebsd.org)
   201  BEGEMOT-NTP snmpd NTP module
   202  BEGEMOT-HOSTRES snmpd HOSTRES module private stuff
+  203  regexData   bsnmp-regex (Nate Nielsen 
)
+  204  pingDatabsnmp-ping (Nate Nielsen 
)
+  205  begemotBridge   bridge module
+  210  begemotWlan WLAN module
+
   300  BEGEMOT-ACM DLR ACM project
+  303  BEGEMOT-WLINK   DLR WLINK simulator
+  304  BEGEMOT-SATXDLR SatX simulator
+
+  405  mysql   (vani...@fatpipi.com)
+  406  varnish (vani...@fatpipi.com)
+
+  500  DLR-MOSAKA  DLR Mosaka simulation platform
+
+   bsnmp-jails per-jail network, cpu, disk, memory 
statistics (Stef Walter )
+  1112 bsnmp-pcap  monitor traffic for specific network 
flows (Stef Walter )
 
 If you need an OID and don't know where to stuck it in, I can assign you one -
 just drop me a mail.
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r218195 - in head/sys: amd64/amd64 arm/arm i386/i386 ia64/ia64 kern mips/mips powerpc/powerpc sparc64/sparc64 sun4v/sun4v sys ufs/ffs

2011-02-03 Thread mdf
On Thu, Feb 3, 2011 at 4:50 AM, John Baldwin  wrote:
> On Thursday, February 03, 2011 2:47:20 am Juli Mallett wrote:
>> On Wed, Feb 2, 2011 at 08:35, Matthew D Fleming  wrote:
>> > Author: mdf
>> > Date: Wed Feb  2 16:35:10 2011
>> > New Revision: 218195
>> > URL: http://svn.freebsd.org/changeset/base/218195
>> >
>> > Log:
>> >  Put the general logic for being a CPU hog into a new function
>> >  should_yield().  Use this in various places.  Encapsulate the common
>> >  case of check-and-yield into a new function maybe_yield().
>> >
>> >  Change several checks for a magic number of iterations to use
>> >  should_yield() instead.
>>
>> First off, I admittedly don't know or care very much about this area,
>> but this commit stood out to me and I had a few minor concerns.
>>
>> I'm slightly uncomfortable with the flat namespace here.  It isn't
>> obvious from the names that maybe_yield() and should_yield() relate
>> only to uio_yield() and not other types of yielding (from DELAY() to
>> cpu_idle() to sched_yield().)  The other problematic element here is
>> that "maybe_yield" and "should_yield" could quite reasonably be
>> variables or functions in existing code in the kernel, and although we
>> don't try to protect against changes that could cause such collisions,
>> we shouldn't do them gratuitously, and there's even something that
>> seems aesthetically off about these; they seem...informal, even
>> Linuxy.  I think names like uio_should_yield() and uio_maybe_yield()
>> wouldn't have nearly as much of a problem, since the context of the
>> question of "should" is isolated to uio operations rather than, say,
>> whether the scheduler would *like* for us, as the running thread, to
>> yield, or other considerations that may be more general.
>
> I mostly agree, but these checks are no longer specific to uio.  Matt used
> them to replace many ad-hoc checks using counters with hardcoded maximums in
> places like softupdates, etc.
>
> I don't have any good suggestions for what else you would call these.  I'm not
> sure 'sched_amcpuhog() or sched_hoggingcpu()' are really better (and these are
> not scheduler dependent, so sched_ would probably not be a good prefix).

Bruce correctly points out that the code doesn't work like I expect
with PREEMPTION, which most people will be running.

I'm thinking of adding a new per-thread field to record the last ticks
value that a voluntary mi_switch() was done, so that there's a
standard way of checking if a thread is being a hog; this will work
for both PREEMPTION and !PREEMPTION, and would be appropriate for the
places that previously used a counter.  (This would require
uio_yield() to be SW_VOL, but I can't see why it's not a voluntary
context switch anyways).

I'm happy to rename the functions (perhaps just yield_foo() rather
than foo_yield()?) and stop using uio_yield as the base name since
it's not a uio function.  I wanted to keep the uio_yield symbol to
preserve the KBI/KPI.

Any suggestions for names are welcome.

Thanks,
matthew
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218227 - head/sys/arm/arm

2011-02-03 Thread Marcel Moolenaar
Author: marcel
Date: Thu Feb  3 17:35:16 2011
New Revision: 218227
URL: http://svn.freebsd.org/changeset/base/218227

Log:
  Accept r1 as having the metadata pointer argument if r0 is 0.
  This provides backward compatibility with Juniper loaders.
  
  Sponsored by: Juniper Networks

Modified:
  head/sys/arm/arm/locore.S

Modified: head/sys/arm/arm/locore.S
==
--- head/sys/arm/arm/locore.S   Thu Feb  3 15:46:54 2011(r218226)
+++ head/sys/arm/arm/locore.S   Thu Feb  3 17:35:16 2011(r218227)
@@ -65,14 +65,20 @@ __FBSDID("$FreeBSD$");
 
 ENTRY_NP(btext)
 
-ASENTRY_NP(_start)
-
 /*
- * Move metadata ptr to r12 (ip)
+ * On entry:
+ * r0 - metadata pointer or 0
+ * r1 - if (r0 == 0) then metadata pointer
  */
+ASENTRY_NP(_start)
 
+   /* Move metadata ptr to r12 (ip) */
mov ip, r0
-
+   ldr r0, =0
+   cmp ip, r0
+   bne 1f
+   mov ip, r1
+1:
/* Make sure interrupts are disabled. */
mrs r7, cpsr
orr r7, r7, #(I32_bit|F32_bit)
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218228 - head/sys/arm/mv

2011-02-03 Thread Marcel Moolenaar
Author: marcel
Date: Thu Feb  3 18:07:05 2011
New Revision: 218228
URL: http://svn.freebsd.org/changeset/base/218228

Log:
  The FDT describes the host controller directly. There's no need to
  get properties from the parent. The parent is in fact the FDT bus
  itself and will therefore not have the properties we're looking
  for.
  
  Sponsored by: Juniper Networks

Modified:
  head/sys/arm/mv/mv_pci.c

Modified: head/sys/arm/mv/mv_pci.c
==
--- head/sys/arm/mv/mv_pci.cThu Feb  3 17:35:16 2011(r218227)
+++ head/sys/arm/mv/mv_pci.cThu Feb  3 18:07:05 2011(r218228)
@@ -212,23 +212,17 @@ static struct mtx pcicfg_mtx;
 static int
 mv_pcib_probe(device_t self)
 {
-   phandle_t parnode;
+   phandle_t node;
 
-   /*
-* The PCI subnode does not have the 'compatible' property, so we need
-* to check in the parent PCI node. However the parent is not
-* represented by a separate ofw_bus child, and therefore
-* ofw_bus_is_compatible() cannot be used, but direct fdt equivalent.
-*/
-   parnode = OF_parent(ofw_bus_get_node(self));
-   if (parnode == 0)
+   node = ofw_bus_get_node(self);
+   if (!fdt_is_type(node, "pci"))
return (ENXIO);
-   if (!(fdt_is_compatible(parnode, "mrvl,pcie") ||
-   fdt_is_compatible(parnode, "mrvl,pci")))
+
+   if (!(fdt_is_compatible(node, "mrvl,pcie") ||
+   fdt_is_compatible(node, "mrvl,pci")))
return (ENXIO);
 
device_set_desc(self, "Marvell Integrated PCI/PCI-E Controller");
-
return (BUS_PROBE_DEFAULT);
 }
 
@@ -243,15 +237,16 @@ mv_pcib_attach(device_t self)
sc = device_get_softc(self);
sc->sc_dev = self;
 
-   parnode = OF_parent(ofw_bus_get_node(self));
-   if (fdt_is_compatible(parnode, "mrvl,pcie")) {
+   node = ofw_bus_get_node(self);
+   parnode = OF_parent(node);
+   if (fdt_is_compatible(node, "mrvl,pcie")) {
sc->sc_type = MV_TYPE_PCIE;
sc->sc_mem_win_target = MV_WIN_PCIE_MEM_TARGET;
sc->sc_mem_win_attr = MV_WIN_PCIE_MEM_ATTR;
sc->sc_io_win_target = MV_WIN_PCIE_IO_TARGET;
sc->sc_io_win_attr = MV_WIN_PCIE_IO_ATTR;
 #ifdef SOC_MV_ORION
-   } else if (fdt_is_compatible(parnode, "mrvl,pci")) {
+   } else if (fdt_is_compatible(node, "mrvl,pci")) {
sc->sc_type = MV_TYPE_PCI;
sc->sc_mem_win_target = MV_WIN_PCI_MEM_TARGET;
sc->sc_mem_win_attr = MV_WIN_PCI_MEM_ATTR;
@@ -261,8 +256,6 @@ mv_pcib_attach(device_t self)
} else
return (ENXIO);
 
-   node = ofw_bus_get_node(self);
-
/*
 * Get PCI interrupt info.
 */
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218229 - in head/sys/dev/usb: . serial

2011-02-03 Thread Hans Petter Selasky
Author: hselasky
Date: Thu Feb  3 18:25:55 2011
New Revision: 218229
URL: http://svn.freebsd.org/changeset/base/218229

Log:
  Fix for detection of MTK 3329 GPS USB devices.
  
  Submitted by: Mykhaylo Yehorov
  PR:   usb/153929
  Approved by:  thompsa (mentor)

Modified:
  head/sys/dev/usb/serial/umodem.c
  head/sys/dev/usb/usbdevs

Modified: head/sys/dev/usb/serial/umodem.c
==
--- head/sys/dev/usb/serial/umodem.cThu Feb  3 18:07:05 2011
(r218228)
+++ head/sys/dev/usb/serial/umodem.cThu Feb  3 18:25:55 2011
(r218229)
@@ -197,6 +197,8 @@ static void *umodem_get_desc(struct usb_
 static usb_error_t umodem_set_comm_feature(struct usb_device *, uint8_t,
uint16_t, uint16_t);
 static voidumodem_poll(struct ucom_softc *ucom);
+static voidumodem_find_data_iface(struct usb_attach_arg *uaa,
+   uint8_t, uint8_t *, uint8_t *);
 
 static const struct usb_config umodem_config[UMODEM_N_TRANSFER] = {
 
@@ -311,13 +313,30 @@ umodem_attach(device_t dev)
0 - 1, UDESCSUB_CDC_UNION, 0 - 1);
 
if ((cud == NULL) || (cud->bLength < sizeof(*cud))) {
-   device_printf(dev, "Missing descriptor. "
+   DPRINTF("Missing descriptor. "
"Assuming data interface is next.\n");
-   if (sc->sc_ctrl_iface_no == 0xFF)
+   if (sc->sc_ctrl_iface_no == 0xFF) {
goto detach;
-   else
-   sc->sc_data_iface_no = 
-   sc->sc_ctrl_iface_no + 1;
+   } else {
+   uint8_t class_match = 0;
+
+   /* set default interface number */
+   sc->sc_data_iface_no = 0xFF;
+
+   /* try to find the data interface backwards */
+   umodem_find_data_iface(uaa,
+   uaa->info.bIfaceIndex - 1,
+   &sc->sc_data_iface_no, &class_match);
+
+   /* try to find the data interface forwards */
+   umodem_find_data_iface(uaa,
+   uaa->info.bIfaceIndex + 1,
+   &sc->sc_data_iface_no, &class_match);
+
+   /* check if nothing was found */
+   if (sc->sc_data_iface_no == 0xFF)
+   goto detach;
+   }
} else {
sc->sc_data_iface_no = cud->bSlaveInterface[0];
}
@@ -398,6 +417,36 @@ detach:
 }
 
 static void
+umodem_find_data_iface(struct usb_attach_arg *uaa,
+uint8_t iface_index, uint8_t *p_data_no, uint8_t *p_match_class)
+{
+   struct usb_interface_descriptor *id;
+   struct usb_interface *iface;
+   
+   iface = usbd_get_iface(uaa->device, iface_index);
+
+   /* check for end of interfaces */
+   if (iface == NULL)
+   return;
+
+   id = usbd_get_interface_descriptor(iface);
+
+   /* check for non-matching interface class */
+   if (id->bInterfaceClass != UICLASS_CDC_DATA ||
+   id->bInterfaceSubClass != UISUBCLASS_DATA) {
+   /* if we got a class match then return */
+   if (*p_match_class)
+   return;
+   } else {
+   *p_match_class = 1;
+   }
+
+   DPRINTFN(11, "Match at index %u\n", iface_index);
+
+   *p_data_no = id->bInterfaceNumber;
+}
+
+static void
 umodem_start_read(struct ucom_softc *ucom)
 {
struct umodem_softc *sc = ucom->sc_parent;

Modified: head/sys/dev/usb/usbdevs
==
--- head/sys/dev/usb/usbdevsThu Feb  3 18:07:05 2011(r218228)
+++ head/sys/dev/usb/usbdevsThu Feb  3 18:25:55 2011(r218229)
@@ -536,6 +536,7 @@ vendor SPEEDDRAGON  0x0e55  Speed Dragon M
 vendor HAWKING 0x0e66  Hawking
 vendor FOSSIL  0x0e67  Fossil, Inc
 vendor GMATE   0x0e7e  G.Mate, Inc
+vendor MEDIATEK0x0e8d  MediaTek, Inc.
 vendor OTI 0x0ea0  Ours Technology
 vendor YISO0x0eab  Yiso Wireless Co.
 vendor PILOTECH0x0eaf  Pilotech
@@ -2120,6 +2121,9 @@ product MCT DU_H3SP_USB2320x0200  D-Link
 product MCT USB232 0x0210  USB-232 Interface
 product MCT SITECOM_USB232 0x0230  Sitecom USB-232 Products
 
+/* MediaTek, Inc. */
+product MEDIATEK MTK3329   0x3329  MTK II GPS Receiver
+
 /* Meizu Electronics */
 product MEIZU M6_SL0x0140  MiniPlayer M6 (SL)
 
___
svn-src-head@freebsd.org mailing list
http://lists.f

Re: svn commit: r218219 - head/sys/netinet

2011-02-03 Thread Randall Stewart
John:

Ahh.. thanks for the information .. I did not know that.

I will change it to use it..

Before it was using the define.. which as Julian said a while ago was a
bad idea.

R
On Feb 3, 2011, at 7:45 AM, John Baldwin wrote:

> On Thursday, February 03, 2011 6:52:22 am Randall Stewart wrote:
>> Author: rrs
>> Date: Thu Feb  3 11:52:22 2011
>> New Revision: 218219
>> URL: http://svn.freebsd.org/changeset/base/218219
>> 
>> Log:
>>  Fix the per CPU stats so that:
>>  1) They don't use the giant "MAX_CPU" define and instead
>> are allocated dynamically based on mp_ncpus
> 
> You probably want to use mp_maxid instead.  CPU IDs are not guaranteed to be 
> contiguous (though they currently are).  Instead, the only guarantee are that 
> there are mp_ncpus CPUs numbered 0 ... mp_maxid.  There may be gaps in that 
> range (and there have been in the past).
> 
> -- 
> John Baldwin
> 

--
Randall Stewart
803-317-4952 (cell)

___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218232 - head/sys/netinet

2011-02-03 Thread Randall Stewart
Author: rrs
Date: Thu Feb  3 19:22:21 2011
New Revision: 218232
URL: http://svn.freebsd.org/changeset/base/218232

Log:
  1) Move per John Baldwin to mp_maxid
  2) Some signed/unsigned errors found by Mac OS compiler (from Michael)
  3) a couple of copyright updates on the effected files.
  
  MFC after:3 months

Modified:
  head/sys/netinet/sctp_asconf.c
  head/sys/netinet/sctp_cc_functions.c
  head/sys/netinet/sctp_constants.h
  head/sys/netinet/sctp_input.c
  head/sys/netinet/sctp_output.c
  head/sys/netinet/sctp_pcb.c
  head/sys/netinet/sctp_sysctl.c

Modified: head/sys/netinet/sctp_asconf.c
==
--- head/sys/netinet/sctp_asconf.c  Thu Feb  3 18:50:10 2011
(r218231)
+++ head/sys/netinet/sctp_asconf.c  Thu Feb  3 19:22:21 2011
(r218232)
@@ -1,5 +1,8 @@
 /*-
  * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
+ * Copyright (c) 2008-2011, by Randall Stewart, r...@lakerest.net and
+ *  Michael Tuexen, tue...@fh-muenster.de
+ *  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -1348,7 +1351,7 @@ sctp_asconf_queue_mgmt(struct sctp_tcb *
 
TAILQ_INSERT_TAIL(&stcb->asoc.asconf_queue, aa, next);
 #ifdef SCTP_DEBUG
-   if (SCTP_BASE_SYSCTL(sctp_debug_on) && SCTP_DEBUG_ASCONF2) {
+   if (SCTP_BASE_SYSCTL(sctp_debug_on) & SCTP_DEBUG_ASCONF2) {
if (type == SCTP_ADD_IP_ADDRESS) {
SCTP_PRINTF("asconf_queue_mgmt: inserted asconf 
ADD_IP_ADDRESS: ");
SCTPDBG_ADDR(SCTP_DEBUG_ASCONF2, sa);

Modified: head/sys/netinet/sctp_cc_functions.c
==
--- head/sys/netinet/sctp_cc_functions.cThu Feb  3 18:50:10 2011
(r218231)
+++ head/sys/netinet/sctp_cc_functions.cThu Feb  3 19:22:21 2011
(r218232)
@@ -1,5 +1,8 @@
 /*-
  * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
+ * Copyright (c) 2008-2011, by Randall Stewart, r...@lakerest.net and
+ *  Michael Tuexen, tue...@fh-muenster.de
+ *  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -375,8 +378,6 @@ sctp_cwnd_update_after_sack(struct sctp_
}
} else {
/* We are in congestion avoidance */
-   uint32_t incr;
-
/*
 * Add to pba
 */
@@ -514,7 +515,8 @@ sctp_cwnd_update_after_packet_dropped(st
 uint32_t * bottle_bw, uint32_t * on_queue)
 {
uint32_t bw_avail;
-   int rtt, incr;
+   int rtt;
+   unsigned int incr;
int old_cwnd = net->cwnd;
 
/* need real RTT for this calc */

Modified: head/sys/netinet/sctp_constants.h
==
--- head/sys/netinet/sctp_constants.h   Thu Feb  3 18:50:10 2011
(r218231)
+++ head/sys/netinet/sctp_constants.h   Thu Feb  3 19:22:21 2011
(r218232)
@@ -1,5 +1,8 @@
 /*-
  * Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved.
+ * Copyright (c) 2008-2011, by Randall Stewart, r...@lakerest.net and
+ *  Michael Tuexen, tue...@fh-muenster.de
+ *  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -915,11 +918,11 @@ __FBSDID("$FreeBSD$");
 
 /* modular comparison */
 /* See RFC 1982 for details. */
-#define SCTP_SSN_GT(a, b) (((a < b) && ((b - a) > (1<<15))) || \
-   ((a > b) && ((a - b) < (1<<15
+#define SCTP_SSN_GT(a, b) (((a < b) && ((uint16_t)(b - a) > (1U<<15))) || \
+   ((a > b) && ((uint16_t)(a - b) < (1U<<15
 #define SCTP_SSN_GE(a, b) (SCTP_SSN_GT(a, b) || (a == b))
-#define SCTP_TSN_GT(a, b) (((a < b) && ((b - a) > (1<<31))) || \
-   ((a > b) && ((a - b) < (1<<31
+#define SCTP_TSN_GT(a, b) (((a < b) && ((uint32_t)(b - a) > (1U<<31))) || \
+   ((a > b) && ((uint32_t)(a - b) < (1U<<31
 #define SCTP_TSN_GE(a, b) (SCTP_TSN_GT(a, b) || (a == b))
 
 /* Mapping array manipulation routines */

Modified: head/sys/netinet/sctp_input.c
==
--- head/sys/netinet/sctp_input.c   Thu Feb  3 18:50:10 2011
(r218231)
+++ head/sys/netinet/sctp_input.c   Thu Feb  3 19:22:21 2011

svn commit: r218235 - head/sys/netinet

2011-02-03 Thread Michael Tuexen
Author: tuexen
Date: Thu Feb  3 19:59:00 2011
New Revision: 218235
URL: http://svn.freebsd.org/changeset/base/218235

Log:
  Make sure that changing the ECN sysctl does not affect
  exisiting associations and endpoints.
  
  MFC after: 3 months.

Modified:
  head/sys/netinet/sctp_input.c
  head/sys/netinet/sctp_output.c
  head/sys/netinet/sctp_pcb.c
  head/sys/netinet/sctp_pcb.h
  head/sys/netinet/sctp_peeloff.c
  head/sys/netinet/sctputil.c

Modified: head/sys/netinet/sctp_input.c
==
--- head/sys/netinet/sctp_input.c   Thu Feb  3 19:50:42 2011
(r218234)
+++ head/sys/netinet/sctp_input.c   Thu Feb  3 19:59:00 2011
(r218235)
@@ -2719,6 +2719,7 @@ sctp_handle_cookie_echo(struct mbuf *m, 
inp->sctp_socket = so;
inp->sctp_frag_point = (*inp_p)->sctp_frag_point;
inp->sctp_cmt_on_off = (*inp_p)->sctp_cmt_on_off;
+   inp->sctp_ecn_enable = (*inp_p)->sctp_ecn_enable;
inp->partial_delivery_point = 
(*inp_p)->partial_delivery_point;
inp->sctp_context = (*inp_p)->sctp_context;
inp->inp_starting_point_for_iterator = NULL;
@@ -5614,7 +5615,8 @@ sctp_common_input_processing(struct mbuf
 */
}
/* take care of ecn */
-   if (stcb->asoc.ecn_allowed && ((ecn_bits & SCTP_CE_BITS) == 
SCTP_CE_BITS)) {
+   if ((stcb->asoc.ecn_allowed == 1) &&
+   ((ecn_bits & SCTP_CE_BITS) == SCTP_CE_BITS)) {
/* Yep, we need to add a ECNE */
sctp_send_ecn_echo(stcb, net, high_tsn);
}

Modified: head/sys/netinet/sctp_output.c
==
--- head/sys/netinet/sctp_output.c  Thu Feb  3 19:50:42 2011
(r218234)
+++ head/sys/netinet/sctp_output.c  Thu Feb  3 19:59:00 2011
(r218235)
@@ -3392,10 +3392,11 @@ static uint8_t
 sctp_get_ect(struct sctp_tcb *stcb,
 struct sctp_tmit_chunk *chk)
 {
-   if (SCTP_BASE_SYSCTL(sctp_ecn_enable) == 0)
+   if ((stcb != NULL) && (stcb->asoc.ecn_allowed == 1)) {
+   return (SCTP_ECT0_BIT);
+   } else {
return (0);
-
-   return (SCTP_ECT0_BIT);
+   }
 }
 
 static int
@@ -3502,17 +3503,9 @@ sctp_lowlevel_chunk_output(struct sctp_i
 
ip->ip_ttl = inp->ip_inp.inp.inp_ip_ttl;
ip->ip_len = packet_length;
-   if (stcb) {
-   if ((stcb->asoc.ecn_allowed) && ecn_ok) {
-   /* Enable ECN */
-   ip->ip_tos = ((u_char)(tos_value & 0xfc) | 
sctp_get_ect(stcb, chk));
-   } else {
-   /* No ECN */
-   ip->ip_tos = (u_char)(tos_value & 0xfc);
-   }
-   } else {
-   /* no association at all */
-   ip->ip_tos = (tos_value & 0xfc);
+   ip->ip_tos = tos_value & 0xfc;
+   if (ecn_ok) {
+   ip->ip_tos |= sctp_get_ect(stcb, chk);
}
if (port) {
ip->ip_p = IPPROTO_UDP;
@@ -3839,18 +3832,11 @@ sctp_lowlevel_chunk_output(struct sctp_i
} else {
ro = (sctp_route_t *) & net->ro;
}
-   if (stcb != NULL) {
-   if ((stcb->asoc.ecn_allowed) && ecn_ok) {
-   /* Enable ECN */
-   tosBottom = (struct in6pcb 
*)inp)->in6p_flowinfo & 0x0c) | sctp_get_ect(stcb, chk)) << 4);
-   } else {
-   /* No ECN */
-   tosBottom = struct in6pcb 
*)inp)->in6p_flowinfo & 0x0c) << 4);
-   }
-   } else {
-   /* we could get no asoc if it is a O-O-T-B packet */
-   tosBottom = struct in6pcb *)inp)->in6p_flowinfo & 
0x0c) << 4);
+   tosBottom = (((struct in6pcb *)inp)->in6p_flowinfo & 0x0c);
+   if (ecn_ok) {
+   tosBottom |= sctp_get_ect(stcb, chk);
}
+   tosBottom <<= 4;
ip6h->ip6_flow = htonl(((tosTop << 24) | ((tosBottom | flowTop) 
<< 16) | flowBottom));
if (port) {
ip6h->ip6_nxt = IPPROTO_UDP;
@@ -4247,7 +4233,7 @@ sctp_send_initiate(struct sctp_inpcb *in
stcb->asoc.cookie_preserve_req = 0;
}
/* ECN parameter */
-   if (SCTP_BASE_SYSCTL(sctp_ecn_enable) == 1) {
+   if (stcb->asoc.ecn_allowed == 1) {
ecn->ph.param_type = htons(SCTP_ECN_CAPABLE);
ecn->ph.param_length = htons(sizeof(*ecn));
SCTP_BUF_LEN(m) += sizeof(*

svn commit: r218238 - head/sys/dev/ath

2011-02-03 Thread Adrian Chadd
Author: adrian
Date: Thu Feb  3 20:26:26 2011
New Revision: 218238
URL: http://svn.freebsd.org/changeset/base/218238

Log:
  Disable the code I previously added from Rui's 802.11n branch.
  
  A-MPDU RX interferes with packet retransmission/reordering.
  In local testing, I was seeing A-MPDU being negotiated and then
  not used by the AP sending frames to the STA; the STA would then
  treat non A-MPDU frames that are retransmits as out of the window
  and get plain confused.
  
  The hardware RX status descriptor has a "I'm part of an aggregate"
  bit; so this should eventually be tested and then punted to the
  A-MPDU reorder handling only if it has this bit set.

Modified:
  head/sys/dev/ath/if_ath.c

Modified: head/sys/dev/ath/if_ath.c
==
--- head/sys/dev/ath/if_ath.c   Thu Feb  3 20:10:16 2011(r218237)
+++ head/sys/dev/ath/if_ath.c   Thu Feb  3 20:26:26 2011(r218238)
@@ -3892,9 +3892,15 @@ rx_accept:
IEEE80211_KEYIX_NONE : rs->rs_keyix);
sc->sc_lastrs = rs;
if (ni != NULL) {
+#if NOTYET
/* tag AMPDU aggregates for reorder processing */
+   /*
+* XXX this should only tag frames marked as aggregate; rather
+* XXX than all frames.
+*/
if (ni->ni_flags & IEEE80211_NODE_HT)
m->m_flags |= M_AMPDU;
+#endif
 
/*
 * Sending station is known, dispatch directly.
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218240 - head/sys/dev/ath

2011-02-03 Thread Adrian Chadd
Author: adrian
Date: Thu Feb  3 20:30:17 2011
New Revision: 218240
URL: http://svn.freebsd.org/changeset/base/218240

Log:
  Modify the TX path to set and use the 11n rate scenario bits.
  
  This isn't strictly required to TX (at least non-agg and non-HT40,
  non-short-GI) frames; but as it needs to be done anyway, just get
  it done.
  
  Linux ath9k uses the rate scenario style path for -all- packets,
  legacy or otherwise. This code does much the same.
  
  Beacon TX still uses the legacy, non-rate-scenario TX descriptor
  setup. Ath9k also does this.
  
  This 11n rate scenario path is only called for chips in the AR5416
  HAL; legacy chips use the previous interface for TX'ing.

Modified:
  head/sys/dev/ath/if_ath_tx.c

Modified: head/sys/dev/ath/if_ath_tx.c
==
--- head/sys/dev/ath/if_ath_tx.cThu Feb  3 20:27:20 2011
(r218239)
+++ head/sys/dev/ath/if_ath_tx.cThu Feb  3 20:30:17 2011
(r218240)
@@ -97,6 +97,7 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
+#include 
 
 /*
  * Whether to use the 11n rate scenario functions or not
@@ -482,6 +483,10 @@ ath_tx_start(struct ath_softc *sc, struc
HAL_BOOL shortPreamble;
struct ath_node *an;
u_int pri;
+   uint8_t try[4], rate[4];
+
+   bzero(try, sizeof(try));
+   bzero(rate, sizeof(rate));
 
wh = mtod(m0, struct ieee80211_frame *);
iswep = wh->i_fc[1] & IEEE80211_FC1_WEP;
@@ -768,10 +773,17 @@ ath_tx_start(struct ath_softc *sc, struc
txq->axq_intrcnt = 0;
}
 
+   if (ath_tx_is_11n(sc)) {
+   rate[0] = rix;
+   try[0] = try0;
+   }
+
/*
 * Formulate first tx descriptor with tx controls.
 */
/* XXX check return value? */
+   /* XXX is this ok to call for 11n descriptors? */
+   /* XXX or should it go through the first, next, last 11n calls? */
ath_hal_setuptxdesc(ah, ds
, pktlen/* packet length */
, hdrlen/* header length */
@@ -792,8 +804,16 @@ ath_tx_start(struct ath_softc *sc, struc
 * when the hardware supports multi-rate retry and
 * we don't use it.
 */
-   if (ismrr)
-   ath_rate_setupxtxdesc(sc, an, ds, shortPreamble, rix);
+if (ismrr) {
+if (ath_tx_is_11n(sc))
+ath_rate_getxtxrates(sc, an, rix, rate, try);
+else
+ath_rate_setupxtxdesc(sc, an, ds, shortPreamble, rix);
+}
+
+if (ath_tx_is_11n(sc)) {
+ath_buf_set_rate(sc, ni, bf, pktlen, flags, ctsrate, rate, 
try);
+}
 
ath_tx_handoff(sc, txq, bf);
return 0;
@@ -817,6 +837,10 @@ ath_tx_raw_start(struct ath_softc *sc, s
const HAL_RATE_TABLE *rt;
struct ath_desc *ds;
u_int pri;
+   uint8_t try[4], rate[4];
+
+   bzero(try, sizeof(try));
+   bzero(rate, sizeof(rate));
 
wh = mtod(m0, struct ieee80211_frame *);
ismcast = IEEE80211_IS_MULTICAST(wh->i_addr1);
@@ -925,30 +949,56 @@ ath_tx_raw_start(struct ath_softc *sc, s
);
bf->bf_txflags = flags;
 
-   if (ismrr) {
-   rix = ath_tx_findrix(sc, params->ibp_rate1);
-   rate1 = rt->info[rix].rateCode;
-   if (params->ibp_flags & IEEE80211_BPF_SHORTPRE)
-   rate1 |= rt->info[rix].shortPreamble;
-   if (params->ibp_try2) {
-   rix = ath_tx_findrix(sc, params->ibp_rate2);
-   rate2 = rt->info[rix].rateCode;
-   if (params->ibp_flags & IEEE80211_BPF_SHORTPRE)
-   rate2 |= rt->info[rix].shortPreamble;
-   } else
-   rate2 = 0;
-   if (params->ibp_try3) {
-   rix = ath_tx_findrix(sc, params->ibp_rate3);
-   rate3 = rt->info[rix].rateCode;
+   if (ath_tx_is_11n(sc)) {
+   rate[0] = ath_tx_findrix(sc, params->ibp_rate0);
+   try[0] = params->ibp_try0;
+
+   if (ismrr) {
+   /* Remember, rate[] is actually an array of rix's 
-adrian */
+   rate[0] = ath_tx_findrix(sc, params->ibp_rate0);
+   rate[1] = ath_tx_findrix(sc, params->ibp_rate1);
+   rate[2] = ath_tx_findrix(sc, params->ibp_rate2);
+   rate[3] = ath_tx_findrix(sc, params->ibp_rate3);
+
+   try[0] = params->ibp_try0;
+   try[1] = params->ibp_try1;
+   try[2] = params->ibp_try2;
+   try[3] = params->ibp_try3;
+   }
+   } else {
+   if (ismrr) {
+   rix = ath_tx_findrix(sc, params->ibp_rate1);
+   rate1 = rt->info[rix].

Re: svn commit: r218232 - head/sys/netinet

2011-02-03 Thread John Baldwin
On Thursday, February 03, 2011 2:22:21 pm Randall Stewart wrote:
> Author: rrs
> Date: Thu Feb  3 19:22:21 2011
> New Revision: 218232
> URL: http://svn.freebsd.org/changeset/base/218232
> 
> Log:
>   1) Move per John Baldwin to mp_maxid
>   2) Some signed/unsigned errors found by Mac OS compiler (from Michael)
>   3) a couple of copyright updates on the effected files.

Note that mp_maxid is the maxium valid ID, so you typically have to do things 
like:

for (i = 0; i <= mp_maxid; i++) {
if (CPU_ABSENT(i))
continue;
...
}

There is a CPU_FOREACH() macro that does the above (but assumes you want to 
skip over non-existent CPUs).

> Modified: head/sys/netinet/sctp_input.c
> 
==
> --- head/sys/netinet/sctp_input.c Thu Feb  3 18:50:10 2011
> (r218231)
> +++ head/sys/netinet/sctp_input.c Thu Feb  3 19:22:21 2011
> (r218232)
> @@ -1,5 +1,8 @@
>  /*-
>   * Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved.
> + * Copyright (c) 2008-2011, by Randall Stewart, r...@lakerest.net and
> + *  Michael Tuexen, tue...@fh-muenster.de
> + *  All rights reserved.
>   *
>   * Redistribution and use in source and binary forms, with or without
>   * modification, are permitted provided that the following conditions are 
met:
> @@ -2918,7 +2921,7 @@ sctp_handle_ecn_echo(struct sctp_ecne_ch
>   uint8_t override_bit = 0;
>   uint32_t tsn, window_data_tsn;
>   int len;
> - int pkt_cnt;
> + unsigned int pkt_cnt;
>  
>   len = ntohs(cp->ch.chunk_length);
>   if ((len != sizeof(struct sctp_ecne_chunk)) &&
> @@ -5933,7 +5936,7 @@ sctp_input(struct mbuf *m, int off)
>   int offset;
>   int cpu_to_use;
>  
> - if (mp_ncpus > 1) {
> + if (mp_maxid > 1) {

The old version of this is still correct.

>   ip = mtod(m, struct ip *);
>   offset = off + sizeof(*sh);
>   if (SCTP_BUF_LEN(m) < offset) {
> @@ -5944,7 +5947,7 @@ sctp_input(struct mbuf *m, int off)
>   ip = mtod(m, struct ip *);
>   }
>   sh = (struct sctphdr *)((caddr_t)ip + off);
> - cpu_to_use = ntohl(sh->v_tag) % mp_ncpus;
> + cpu_to_use = ntohl(sh->v_tag) % mp_maxid;

Hmmm, this is more complicated.   Can sctp_queue_to_mcore() handle the fact 
that a cpu_to_use value might not be valid?  If not you might want to maintain 
a separate "dense" virtual CPU ID table numbered 0 .. mp_ncpus - 1 that maps 
to "present" FreeBSD CPU IDs.  I think Robert has done something similar to 
support RSS in TCP.  Does that make sense?

-- 
John Baldwin
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218241 - head/sys/netinet

2011-02-03 Thread Michael Tuexen
Author: tuexen
Date: Thu Feb  3 20:44:49 2011
New Revision: 218241
URL: http://svn.freebsd.org/changeset/base/218241

Log:
  Fix several bugs in the stream schedulers.
  From Robin Seggelmann.
  
  MFC after: 3 months.

Modified:
  head/sys/netinet/sctp_output.c
  head/sys/netinet/sctp_ss_functions.c
  head/sys/netinet/sctp_structs.h
  head/sys/netinet/sctp_timer.c
  head/sys/netinet/sctp_usrreq.c
  head/sys/netinet/sctputil.c

Modified: head/sys/netinet/sctp_output.c
==
--- head/sys/netinet/sctp_output.c  Thu Feb  3 20:30:17 2011
(r218240)
+++ head/sys/netinet/sctp_output.c  Thu Feb  3 20:44:49 2011
(r218241)
@@ -12342,7 +12342,7 @@ sctp_lower_sosend(struct socket *so,

TAILQ_INIT(&asoc->strmout[i].outqueue);

asoc->strmout[i].stream_no = i;

asoc->strmout[i].last_msg_incomplete = 0;
-   
asoc->ss_functions.sctp_ss_init_stream(&asoc->strmout[i]);
+   
asoc->ss_functions.sctp_ss_init_stream(&asoc->strmout[i], NULL);
}
}
}

Modified: head/sys/netinet/sctp_ss_functions.c
==
--- head/sys/netinet/sctp_ss_functions.cThu Feb  3 20:30:17 2011
(r218240)
+++ head/sys/netinet/sctp_ss_functions.cThu Feb  3 20:44:49 2011
(r218241)
@@ -1,6 +1,7 @@
 /*-
- * Copyright (c) 2010, by Randall Stewart & Michael Tuexen,
- * All rights reserved.
+ * Copyright (c) 2010-2011, by Randall Stewart, r...@lakerest.net and
+ *  Michael Tuexen, tue...@fh-muenster.de
+ *  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -56,6 +57,11 @@ sctp_ss_default_init(struct sctp_tcb *st
uint16_t i;
 
TAILQ_INIT(&asoc->ss_data.out_wheel);
+   /*
+* If there is data in the stream queues already, the scheduler of
+* an existing association has been changed. We need to add all
+* stream queues to the wheel.
+*/
for (i = 0; i < stcb->asoc.streamoutcnt; i++) {
if (!TAILQ_EMPTY(&stcb->asoc.strmout[i].outqueue)) {
sctp_ss_default_add(stcb, &stcb->asoc,
@@ -83,7 +89,7 @@ sctp_ss_default_clear(struct sctp_tcb *s
 }
 
 static void
-sctp_ss_default_init_stream(struct sctp_stream_out *strq)
+sctp_ss_default_init_stream(struct sctp_stream_out *strq, struct 
sctp_stream_out *with_strq)
 {
strq->ss_params.rr.next_spoke.tqe_next = NULL;
strq->ss_params.rr.next_spoke.tqe_prev = NULL;
@@ -411,11 +417,15 @@ sctp_ss_prio_clear(struct sctp_tcb *stcb
 }
 
 static void
-sctp_ss_prio_init_stream(struct sctp_stream_out *strq)
+sctp_ss_prio_init_stream(struct sctp_stream_out *strq, struct sctp_stream_out 
*with_strq)
 {
strq->ss_params.prio.next_spoke.tqe_next = NULL;
strq->ss_params.prio.next_spoke.tqe_prev = NULL;
-   strq->ss_params.prio.priority = 0;
+   if (with_strq != NULL) {
+   strq->ss_params.prio.priority = 
with_strq->ss_params.prio.priority;
+   } else {
+   strq->ss_params.prio.priority = 0;
+   }
return;
 }
 
@@ -575,11 +585,15 @@ sctp_ss_fb_clear(struct sctp_tcb *stcb, 
 }
 
 static void
-sctp_ss_fb_init_stream(struct sctp_stream_out *strq)
+sctp_ss_fb_init_stream(struct sctp_stream_out *strq, struct sctp_stream_out 
*with_strq)
 {
strq->ss_params.fb.next_spoke.tqe_next = NULL;
strq->ss_params.fb.next_spoke.tqe_prev = NULL;
-   strq->ss_params.fb.rounds = -1;
+   if (with_strq != NULL) {
+   strq->ss_params.fb.rounds = with_strq->ss_params.fb.rounds;
+   } else {
+   strq->ss_params.fb.rounds = -1;
+   }
return;
 }
 
@@ -697,28 +711,40 @@ sctp_ss_fb_scheduled(struct sctp_tcb *st
  * Maintains the order provided by the application.
  */
 static void
+sctp_ss_fcfs_add(struct sctp_tcb *stcb, struct sctp_association *asoc,
+struct sctp_stream_out *strq, struct sctp_stream_queue_pending *sp,
+int holds_lock);
+
+static void
 sctp_ss_fcfs_init(struct sctp_tcb *stcb, struct sctp_association *asoc,
 int holds_lock)
 {
-   int x, element = 0, add_more = 1;
+   uint32_t x, n = 0, add_more = 1;
struct sctp_stream_queue_pending *sp;
uint16_t i;
 
TAILQ_INIT(&asoc->ss_data.out_list);
+   /*
+* If there is data in the stream queues already, the scheduler of
+* an existing association has been changed. We can

Re: svn commit: r218232 - head/sys/netinet

2011-02-03 Thread Juli Mallett
On Thu, Feb 3, 2011 at 12:29, John Baldwin  wrote:
>>               ip = mtod(m, struct ip *);
>>               offset = off + sizeof(*sh);
>>               if (SCTP_BUF_LEN(m) < offset) {
>> @@ -5944,7 +5947,7 @@ sctp_input(struct mbuf *m, int off)
>>                       ip = mtod(m, struct ip *);
>>               }
>>               sh = (struct sctphdr *)((caddr_t)ip + off);
>> -             cpu_to_use = ntohl(sh->v_tag) % mp_ncpus;
>> +             cpu_to_use = ntohl(sh->v_tag) % mp_maxid;
>
> Hmmm, this is more complicated.   Can sctp_queue_to_mcore() handle the fact
> that a cpu_to_use value might not be valid?  If not you might want to maintain
> a separate "dense" virtual CPU ID table numbered 0 .. mp_ncpus - 1 that maps
> to "present" FreeBSD CPU IDs.  I think Robert has done something similar to
> support RSS in TCP.  Does that make sense?

Plus mp_maxid is inclusive, so rrs probably meant (mp_maxid + 1) not
mp_maxid in that modulus.
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r218238 - head/sys/dev/ath

2011-02-03 Thread Bruce Cran
On Thu, Feb 03, 2011 at 08:26:26PM +, Adrian Chadd wrote:
>   if (ni != NULL) {
> +#if NOTYET
>   /* tag AMPDU aggregates for reorder processing */

This seems to have broken the build because NOTYET isn't defined.

-- 
Bruce Cran
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218242 - head/bin/sh

2011-02-03 Thread Jilles Tjoelker
Author: jilles
Date: Thu Feb  3 23:38:11 2011
New Revision: 218242
URL: http://svn.freebsd.org/changeset/base/218242

Log:
  sh: Return only 126 or 127 for execve() failures.
  
  Do not return 2 for errors other than [EACCES] or [ENOENT].

Modified:
  head/bin/sh/exec.c

Modified: head/bin/sh/exec.c
==
--- head/bin/sh/exec.c  Thu Feb  3 20:44:49 2011(r218241)
+++ head/bin/sh/exec.c  Thu Feb  3 23:38:11 2011(r218242)
@@ -129,20 +129,13 @@ shellexec(char **argv, char **envp, cons
}
 
/* Map to POSIX errors */
-   switch (e) {
-   case EACCES:
-   exerrno = 126;
-   break;
-   case ENOENT:
+   if (e == ENOENT || e == ENOTDIR) {
exerrno = 127;
-   break;
-   default:
-   exerrno = 2;
-   break;
-   }
-   if (e == ENOENT || e == ENOTDIR)
exerror(EXEXEC, "%s: not found", argv[0]);
-   exerror(EXEXEC, "%s: %s", argv[0], strerror(e));
+   } else {
+   exerrno = 126;
+   exerror(EXEXEC, "%s: %s", argv[0], strerror(e));
+   }
 }
 
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218243 - head/sys/dev/ath

2011-02-03 Thread Adrian Chadd
Author: adrian
Date: Fri Feb  4 00:25:18 2011
New Revision: 218243
URL: http://svn.freebsd.org/changeset/base/218243

Log:
  Oops, fix newbie mistake that breaks the normal build.

Modified:
  head/sys/dev/ath/if_ath.c

Modified: head/sys/dev/ath/if_ath.c
==
--- head/sys/dev/ath/if_ath.c   Thu Feb  3 23:38:11 2011(r218242)
+++ head/sys/dev/ath/if_ath.c   Fri Feb  4 00:25:18 2011(r218243)
@@ -3892,7 +3892,7 @@ rx_accept:
IEEE80211_KEYIX_NONE : rs->rs_keyix);
sc->sc_lastrs = rs;
if (ni != NULL) {
-#if NOTYET
+#ifdef NOTYET
/* tag AMPDU aggregates for reorder processing */
/*
 * XXX this should only tag frames marked as aggregate; rather
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r218246 - head/sys/boot/fdt/dts

2011-02-03 Thread Marcel Moolenaar
Author: marcel
Date: Fri Feb  4 01:09:02 2011
New Revision: 218246
URL: http://svn.freebsd.org/changeset/base/218246

Log:
  Add PEX0 and select the first serial port as console.

Modified:
  head/sys/boot/fdt/dts/db78100.dts

Modified: head/sys/boot/fdt/dts/db78100.dts
==
--- head/sys/boot/fdt/dts/db78100.dts   Fri Feb  4 00:57:04 2011
(r218245)
+++ head/sys/boot/fdt/dts/db78100.dts   Fri Feb  4 01:09:02 2011
(r218246)
@@ -308,8 +308,36 @@
};
};
 
+   pci0: pcie@f104 {
+   compatible = "mrvl,pcie";
+   device_type = "pci";
+   #interrupt-cells = <1>;
+   #size-cells = <2>;
+   #address-cells = <3>;
+   reg = <0xf104 0x2000>;
+   bus-range = <0 255>;
+   ranges = <0x0200 0x0 0xf200 0xf200 0x0 0x0400
+ 0x0100 0x0 0x 0xf110 0x0 0x0010>;
+   clock-frequency = <>;
+   interrupt-parent = <&PIC>;
+   interrupts = <68>;
+   interrupt-map-mask = <0xf800 0x0 0x0 0x7>;
+   interrupt-map = <
+   /* IDSEL 0x1 */
+   0x0800 0x0 0x0 0x1 &PIC 0x20
+   0x0800 0x0 0x0 0x2 &PIC 0x21
+   0x0800 0x0 0x0 0x3 &PIC 0x22
+   0x0800 0x0 0x0 0x4 &PIC 0x23
+   >;
+   };
+
sram@fd00 {
compatible = "mrvl,cesa-sram";
reg = <0xfd00 0x0010>;
};
+
+   chosen {
+   stdin = "serial0";
+   stdout = "serial0";
+   };
 };
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r218195 - in head/sys: amd64/amd64 arm/arm i386/i386 ia64/ia64 kern mips/mips powerpc/powerpc sparc64/sparc64 sun4v/sun4v sys ufs/ffs

2011-02-03 Thread Bruce Evans

On Thu, 3 Feb 2011 m...@freebsd.org wrote:


Bruce correctly points out that the code doesn't work like I expect
with PREEMPTION, which most people will be running.


Not just PREEMPTION, but with almost any non-fast^Wfiltered interrupt
activity.


I'm thinking of adding a new per-thread field to record the last ticks
value that a voluntary mi_switch() was done, so that there's a
standard way of checking if a thread is being a hog; this will work
for both PREEMPTION and !PREEMPTION, and would be appropriate for the
places that previously used a counter.  (This would require
uio_yield() to be SW_VOL, but I can't see why it's not a voluntary
context switch anyways).


I don't like using a ticks value for this at all.  It gives complexities
and doing the scheduler's work for it.  If you don't count involuntary
context switches, then the ticks spent by involuntarily-switch-to threads
will be counted against the hog thread.  And switches back from these
threads are probably voluntary (this is the case for ithreads), so you
would need complexities to not reset the last ticks values for some
voluntary context switches too.  A perfectly fair way to keep track of
hoggishness might be to monitor the thread's runtime and yield if this
is too large a percentage of the real time, but this might be complex
and is doing the scheduler's work for it (better than the scheduler does
-- schedulers still use ticks, but the runtime is much more accurate).
OTOH, yielding on every tick might work well.  This is equivalent to
reducing hogticks to 1 and doesn't need an externally maintained last-
tick value.  Just do an atomic cmpset of `ticks' with a previous value
and yield if it changed.  This could probably be used for increments of
larger than 1 too.  But I now remember that the hogticks checks are
intentionally not done like this, so that they can be as small and
efficient as possible and not need local state or a function call.
I must have expected them to be used more.  The reason to consider
yielding on every tick is that 2 quanta (200 mS) isn't as long as it
was when it was first used for hogticks.  Back then, memory speeds were
maybe 50 MB/S at best and you could reach hogticks limit simply by
reading a few MB from /dev/zero.


I'm happy to rename the functions (perhaps just yield_foo() rather
than foo_yield()?) and stop using uio_yield as the base name since
it's not a uio function.  I wanted to keep the uio_yield symbol to
preserve the KBI/KPI.


Errors should not be preserved.

Bruce
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r218238 - head/sys/dev/ath

2011-02-03 Thread Bruce Evans

On Thu, 3 Feb 2011, Bruce Cran wrote:


On Thu, Feb 03, 2011 at 08:26:26PM +, Adrian Chadd wrote:

if (ni != NULL) {
+#if NOTYET
/* tag AMPDU aggregates for reorder processing */


This seems to have broken the build because NOTYET isn't defined.


It is a style bug ("#ifdefnotyet" is normal), but it only breaks
the build because kernel builds don't use a C compiler (they use -Wundef
to break the compiler).

Bruce
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r218211 - in head/sys: conf netinet

2011-02-03 Thread Robert Watson


On Thu, 3 Feb 2011, Randall Stewart wrote:


Author: rrs
Date: Thu Feb  3 10:05:30 2011
New Revision: 218211
URL: http://svn.freebsd.org/changeset/base/218211

Log:
 Adds an experimental option to create a pool of
 threads. These serve as input threads and are queued
 packets based on the V-tag number. This is similar to
 what a modern card can do with queue's for TCP... but
 alas modern cards know nothing about SCTP.


Hmm.  It might be better to add a new NETISR_SCTP and use netisr's support for 
multithreading?


(I'm preparing a patch for review that enhances that a bit so that protocols 
can be a bit more expressive in terms of specifying dispatch policy, etc, 
currently).


Robert




 MFC after: 3 months (maybe)

Modified:
 head/sys/conf/options
 head/sys/netinet/sctp_bsd_addr.c
 head/sys/netinet/sctp_constants.h
 head/sys/netinet/sctp_input.c
 head/sys/netinet/sctp_lock_bsd.h
 head/sys/netinet/sctp_os_bsd.h
 head/sys/netinet/sctp_pcb.c
 head/sys/netinet/sctp_pcb.h
 head/sys/netinet/sctp_structs.h

Modified: head/sys/conf/options
==
--- head/sys/conf/options   Thu Feb  3 08:55:45 2011(r218210)
+++ head/sys/conf/options   Thu Feb  3 10:05:30 2011(r218211)
@@ -439,6 +439,7 @@ SCTP_PACKET_LOGGING opt_sctp.h # Log to
SCTP_LTRACE_CHUNKS  opt_sctp.h # Log to KTR chunks processed
SCTP_LTRACE_ERRORS  opt_sctp.h # Log to KTR error returns.
SCTP_USE_PERCPU_STATopt_sctp.h # Use per cpu stats.
+SCTP_MCORE_INPUTopt_sctp.h # Have multiple input threads for input 
mbufs
#
#
#

Modified: head/sys/netinet/sctp_bsd_addr.c
==
--- head/sys/netinet/sctp_bsd_addr.cThu Feb  3 08:55:45 2011
(r218210)
+++ head/sys/netinet/sctp_bsd_addr.cThu Feb  3 10:05:30 2011
(r218211)
@@ -68,6 +68,7 @@ MALLOC_DEFINE(SCTP_M_TIMW, "sctp_timw",
MALLOC_DEFINE(SCTP_M_MVRF, "sctp_mvrf", "sctp mvrf pcb list");
MALLOC_DEFINE(SCTP_M_ITER, "sctp_iter", "sctp iterator control");
MALLOC_DEFINE(SCTP_M_SOCKOPT, "sctp_socko", "sctp socket option");
+MALLOC_DEFINE(SCTP_M_MCORE, "sctp_mcore", "sctp mcore queue");

/* Global NON-VNET structure that controls the iterator */
struct iterator_control sctp_it_ctl;

Modified: head/sys/netinet/sctp_constants.h
==
--- head/sys/netinet/sctp_constants.h   Thu Feb  3 08:55:45 2011
(r218210)
+++ head/sys/netinet/sctp_constants.h   Thu Feb  3 10:05:30 2011
(r218211)
@@ -91,6 +91,8 @@ __FBSDID("$FreeBSD$");
#define SCTP_KTRHEAD_NAME "sctp_iterator"
#define SCTP_KTHREAD_PAGES 0

+#define SCTP_MCORE_NAME "sctp_core_worker"
+

/* If you support Multi-VRF how big to
 * make the initial array of VRF's to.

Modified: head/sys/netinet/sctp_input.c
==
--- head/sys/netinet/sctp_input.c   Thu Feb  3 08:55:45 2011
(r218210)
+++ head/sys/netinet/sctp_input.c   Thu Feb  3 10:05:30 2011
(r218211)
@@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$");
#include 
#include 
#include 
+#include 



@@ -5921,10 +5922,32 @@ bad:
}
return;
}
+
+
void
-sctp_input(i_pak, off)
-   struct mbuf *i_pak;
-   int off;
+sctp_input(struct mbuf *m, int off)
{
-   sctp_input_with_port(i_pak, off, 0);
+#if defined(__FreeBSD__) && defined(SCTP_MCORE_INPUT) && defined(SMP)
+   struct ip *ip;
+   struct sctphdr *sh;
+   int offset;
+   int cpu_to_use;
+
+   if (mp_ncpus > 1) {
+   ip = mtod(m, struct ip *);
+   offset = off + sizeof(*sh);
+   if (SCTP_BUF_LEN(m) < offset) {
+   if ((m = m_pullup(m, offset)) == 0) {
+   SCTP_STAT_INCR(sctps_hdrops);
+   return;
+   }
+   ip = mtod(m, struct ip *);
+   }
+   sh = (struct sctphdr *)((caddr_t)ip + off);
+   cpu_to_use = ntohl(sh->v_tag) % mp_ncpus;
+   sctp_queue_to_mcore(m, off, cpu_to_use);
+   return;
+   }
+#endif
+   sctp_input_with_port(m, off, 0);
}

Modified: head/sys/netinet/sctp_lock_bsd.h
==
--- head/sys/netinet/sctp_lock_bsd.hThu Feb  3 08:55:45 2011
(r218210)
+++ head/sys/netinet/sctp_lock_bsd.hThu Feb  3 10:05:30 2011
(r218211)
@@ -97,6 +97,48 @@ extern int sctp_logoff_stuff;
 rw_rlock(&SCTP_BASE_INFO(ipi_ep_mtx)); \
} while (0)

+#define SCTP_MCORE_QLOCK_INIT(cpstr) do { \
+   mtx_init(&(cpstr)->que_mtx,\
+"sctp-mcore_queue","queue_lock",   \
+MTX_DEF|MTX_DUPOK);\
+} while (0)
+
+#define SCTP_MCORE_QLOCK(cpstr)  do { \
+