[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[UNIKRAFT PATCH v3 2/3] lib/uknetdev: Save nw_stack data in a netdevice



We extend the uk_netdev to store network stack specific data into
uk_netdev. The size of the of this data is passed to network stack
by setting the CONFIG_UK_NETDEV_SCRATCH_SIZE.

Signed-off-by: Sharan Santhanam <sharan.santhanam@xxxxxxxxx>
Reviewed-by: Hugo Lefeuvre <hugo.lefeuvre@xxxxxxxxx>
---
 lib/uknetdev/Makefile.rules           | 17 +++++++++++++++++
 lib/uknetdev/include/uk/netdev_core.h |  7 +++++++
 2 files changed, 24 insertions(+)
 create mode 100644 lib/uknetdev/Makefile.rules

diff --git a/lib/uknetdev/Makefile.rules b/lib/uknetdev/Makefile.rules
new file mode 100644
index 0000000..80997e5
--- /dev/null
+++ b/lib/uknetdev/Makefile.rules
@@ -0,0 +1,17 @@
+UK_SCRATCH_MEM=0
+UK_SCRATCH_RULE_SET=
+
+uk_scratch_mem_set: $$(eval 
CFLAGS-y+=-DCONFIG_UK_NETDEV_SCRATCH_SIZE=$$(UK_SCRATCH_MEM))
+       @:;
+
+.PHONY : uk_scratch_mem_set
+
+
+## reserve memory for the network stack
+## uknetdev_scratch_mem,bytes_of_memory
+define uknetdev_scratch_mem =
+$(if $(strip $(1)),\
+       $(if $(shell test $(1) -gt $(UK_SCRATCH_MEM) && echo "scratch mem 
set"), $(eval UK_SCRATCH_MEM:=$(1))))
+
+$(if $(strip $(UK_SCRATCH_RULE_SET)),,$(eval UK_SCRATCH_RULE_SET:=1) $(eval 
UK_PREPARE-$(CONFIG_LIBUKNETDEV)+=uk_scratch_mem_set))
+endef
diff --git a/lib/uknetdev/include/uk/netdev_core.h 
b/lib/uknetdev/include/uk/netdev_core.h
index d2e8da0..e9d9113 100644
--- a/lib/uknetdev/include/uk/netdev_core.h
+++ b/lib/uknetdev/include/uk/netdev_core.h
@@ -65,6 +65,10 @@
 extern "C" {
 #endif
 
+#ifndef CONFIG_UK_NETDEV_SCRATCH_SIZE
+#define CONFIG_UK_NETDEV_SCRATCH_SIZE 0
+#endif /* CONFIG_UK_NETDEV_SCRATCH_SIZE */
+
 struct uk_netdev;
 UK_TAILQ_HEAD(uk_netdev_list, struct uk_netdev);
 
@@ -409,6 +413,9 @@ struct uk_netdev {
 
        /** Netdevice address configuration */
        struct uk_netdev_config    *_config;
+#if (CONFIG_UK_NETDEV_SCRATCH_SIZE > 0)
+       char scratch_pad[CONFIG_UK_NETDEV_SCRATCH_SIZE];
+#endif /* CONFIG_UK_NETDEV_SCRATCH_SIZE */
 };
 
 #ifdef __cplusplus
-- 
2.7.4




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.