summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Hellstrom <daniel@gaisler.com>2014-05-30 16:38:03 +0200
committerDaniel Cederman <cederman@gaisler.com>2014-06-27 11:03:25 +0200
commitf1651688194c343c05fc011ffd93fde48b52ad99 (patch)
treefff3be24bbb6f2e3b53e0a5c0f75f9d2f1937cdd
parentb09b8e5255f6ae94445b12fecbbd38ab536b5956 (diff)
Net: add network task affinity config
This patch adds a default network tasks CPU affinity configuration option. The network drivers have the option to create their own daemon tasks with a custom CPU affinity set, or rely on the default set.
-rw-r--r--cpukit/libnetworking/rtems/rtems_bsdnet.h10
-rw-r--r--cpukit/libnetworking/rtems/rtems_bsdnet_internal.h11
-rw-r--r--cpukit/libnetworking/rtems/rtems_glue.c34
3 files changed, 55 insertions, 0 deletions
diff --git a/cpukit/libnetworking/rtems/rtems_bsdnet.h b/cpukit/libnetworking/rtems/rtems_bsdnet.h
index 9dd44fec84..da6f76748d 100644
--- a/cpukit/libnetworking/rtems/rtems_bsdnet.h
+++ b/cpukit/libnetworking/rtems/rtems_bsdnet.h
@@ -11,6 +11,9 @@ extern "C" {
#endif
#include <rtems.h>
+#ifdef RTEMS_SMP
+#include <sys/cpuset.h>
+#endif
/*
* If this file is included from inside the Network Stack proper or
@@ -181,6 +184,13 @@ struct rtems_bsdnet_config {
*/
unsigned long tcp_tx_buf_size;
unsigned long tcp_rx_buf_size;
+
+ /*
+ * Default Network Tasks CPU Affinity
+ */
+#ifdef RTEMS_SMP
+ const cpu_set_t network_task_cpuset;
+#endif
};
/*
diff --git a/cpukit/libnetworking/rtems/rtems_bsdnet_internal.h b/cpukit/libnetworking/rtems/rtems_bsdnet_internal.h
index 05e54b272f..6869579b83 100644
--- a/cpukit/libnetworking/rtems/rtems_bsdnet_internal.h
+++ b/cpukit/libnetworking/rtems/rtems_bsdnet_internal.h
@@ -155,6 +155,17 @@ rtems_id rtems_bsdnet_newproc (
void *arg
);
+#ifdef RTEMS_SMP
+/* As rtems_bsdnet_newproc() but with ability to set CPU affinity too */
+rtems_id rtems_bsdnet_newproc_affinity (
+ char *name,
+ int stacksize,
+ void (*entry)(void *),
+ void *arg,
+ const cpu_set_t *set
+);
+#endif
+
rtems_status_code rtems_bsdnet_event_receive (
rtems_event_set event_in,
rtems_option option_set,
diff --git a/cpukit/libnetworking/rtems/rtems_glue.c b/cpukit/libnetworking/rtems/rtems_glue.c
index 8ed17d1bf0..458cb2f19f 100644
--- a/cpukit/libnetworking/rtems/rtems_glue.c
+++ b/cpukit/libnetworking/rtems/rtems_glue.c
@@ -56,6 +56,9 @@ Semaphore_Control *the_networkSemaphore;
#endif
static rtems_id networkDaemonTid;
static uint32_t networkDaemonPriority;
+#ifdef RTEMS_SMP
+static cpu_set_t networkDaemonCpuset;
+#endif
static void networkDaemon (void *task_argument);
/*
@@ -281,6 +284,13 @@ rtems_bsdnet_initialize (void)
networkDaemonPriority = rtems_bsdnet_config.network_task_priority;
/*
+ * Default network task CPU affinity
+ */
+#ifdef RTEMS_SMP
+ networkDaemonCpuset = rtems_bsdnet_config.network_task_cpuset;
+#endif
+
+ /*
* Set the memory allocation limits
*/
if (rtems_bsdnet_config.mbuf_bytecount)
@@ -660,11 +670,29 @@ taskEntry (rtems_task_argument arg)
rtems_panic ("Network task returned!\n");
}
+
/*
* Start a network task
*/
+#ifdef RTEMS_SMP
+rtems_id
+rtems_bsdnet_newproc (char *name, int stacksize, void(*entry)(void *), void *arg)
+{
+ cpu_set_t *set = NULL;
+
+ if (!CPU_EMPTY(&networkDaemonCpuset))
+ set = &networkDaemonCpuset;
+
+ return rtems_bsdnet_newproc_affinity(name, stacksize, entry, arg, set);
+}
+
+rtems_id
+rtems_bsdnet_newproc_affinity (char *name, int stacksize, void(*entry)(void *),
+ void *arg, const cpu_set_t *set)
+#else
rtems_id
rtems_bsdnet_newproc (char *name, int stacksize, void(*entry)(void *), void *arg)
+#endif
{
struct newtask *t;
char nm[4];
@@ -681,6 +709,12 @@ rtems_bsdnet_newproc (char *name, int stacksize, void(*entry)(void *), void *arg
if (sc != RTEMS_SUCCESSFUL)
rtems_panic ("Can't create network daemon `%s': `%s'\n", name, rtems_status_text (sc));
+#ifdef RTEMS_SMP
+ /* Use the default affinity or use the user-provided CPU set */
+ if (set)
+ rtems_task_set_affinity(tid, sizeof(cpu_set_t), set);
+#endif
+
/*
* Set up task arguments
*/