diff mbox

[API-NEXT,RFC,11/31] defining the location for ODP drivers

Message ID 1452285014-60320-12-git-send-email-christophe.milard@linaro.org
State New
Headers show

Commit Message

Christophe Milard Jan. 8, 2016, 8:29 p.m. UTC
ODP nic drivers should be OS and platform agnosic (the only assumption
being that pci is available through the odp pci interface, and the
availability the the C lib). The drivers are hence placed directely
into /drivers.
This also defines the driver compilation option: --enable-drivers
which should be used to compiles the ODP nic drivers with ODP.

Signed-off-by: Christophe Milard <christophe.milard@linaro.org>
---
 Makefile.am                        |  6 +++++-
 configure.ac                       | 16 ++++++++++++++++
 drivers/Makefile.am                |  6 ++++++
 drivers/README                     |  1 +
 drivers/driver_init.c              | 11 +++++++++++
 drivers/driver_init.h              |  7 +++++++
 drivers/m4/configure.m4            |  3 +++
 platform/linux-generic/Makefile.am | 11 +++++++++++
 8 files changed, 60 insertions(+), 1 deletion(-)
 create mode 100644 drivers/Makefile.am
 create mode 100644 drivers/README
 create mode 100644 drivers/driver_init.c
 create mode 100644 drivers/driver_init.h
 create mode 100644 drivers/m4/configure.m4
diff mbox

Patch

diff --git a/Makefile.am b/Makefile.am
index 2acbe3d..66b7431 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -6,7 +6,11 @@  AM_DISTCHECK_CONFIGURE_FLAGS = --enable-test-cpp \
 			       --with-testdir
 
 #@with_platform@ works alone in subdir but not as part of a path???
-SUBDIRS = @platform_with_platform@ \
+SUBDIRS =
+if WITH_DRIVERS
+SUBDIRS += drivers
+endif
+SUBDIRS += @platform_with_platform@ \
 	  helper \
 	  test \
 	  @platform_with_platform_test@ \
diff --git a/configure.ac b/configure.ac
index 4f89f03..52efaef 100644
--- a/configure.ac
+++ b/configure.ac
@@ -135,6 +135,22 @@  AC_ARG_ENABLE([cunit_support],
         cunit_support=yes
     fi])
 
+##########################################################################
+# Enable NIC driver support
+##########################################################################
+nic_driver_support=no
+AC_ARG_ENABLE([drivers],
+    [  --enable-drivers  include NIC drivers],
+    [if test x$enableval = xyes; then
+        nic_driver_support=yes
+    fi])
+AM_CONDITIONAL([WITH_DRIVERS], [test x$nic_driver_support = xyes ])
+
+if test "x$nic_driver_support" == "xyes";
+then
+    AM_CFLAGS="$AM_CFLAGS -DWITH_DRIVERS"
+    m4_include([./drivers/m4/configure.m4])
+fi
 
 ##########################################################################
 # Setup doxygen documentation
diff --git a/drivers/Makefile.am b/drivers/Makefile.am
new file mode 100644
index 0000000..9f922a8
--- /dev/null
+++ b/drivers/Makefile.am
@@ -0,0 +1,6 @@ 
+INCFLAGS = -I$(top_srcdir)/platform/@with_platform@/include \
+	-I$(top_srcdir)/platform/linux-generic/include \
+	-I$(top_srcdir)/include
+
+noinst_LTLIBRARIES = libdrivers.la
+libdrivers_la_SOURCES = driver_init.c
diff --git a/drivers/README b/drivers/README
new file mode 100644
index 0000000..54d2d37
--- /dev/null
+++ b/drivers/README
@@ -0,0 +1 @@ 
+This is the directory for ODP drivers
diff --git a/drivers/driver_init.c b/drivers/driver_init.c
new file mode 100644
index 0000000..acacffa
--- /dev/null
+++ b/drivers/driver_init.c
@@ -0,0 +1,11 @@ 
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:     BSD-3-Clause
+ */
+
+#include "driver_init.h"
+void _odp_driver_init(void)
+{
+	/* call each driver init function here */
+}
diff --git a/drivers/driver_init.h b/drivers/driver_init.h
new file mode 100644
index 0000000..a8710ab
--- /dev/null
+++ b/drivers/driver_init.h
@@ -0,0 +1,7 @@ 
+/* Copyright (c) 2015, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:     BSD-3-Clause
+ */
+
+void _odp_driver_init(void);
diff --git a/drivers/m4/configure.m4 b/drivers/m4/configure.m4
new file mode 100644
index 0000000..cca047a
--- /dev/null
+++ b/drivers/m4/configure.m4
@@ -0,0 +1,3 @@ 
+AC_CONFIG_FILES([
+		 drivers/Makefile
+		])
diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am
index 999c932..a070cb3 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -7,6 +7,10 @@  AM_CFLAGS +=  -I$(srcdir)/include
 AM_CFLAGS +=  -I$(top_srcdir)/include
 AM_CFLAGS +=  -I$(top_srcdir)/helper/include
 
+if WITH_DRIVERS
+AM_CFLAGS +=  -I$(top_srcdir)/drivers
+endif
+
 include_HEADERS = \
 		  $(top_srcdir)/include/odp.h
 
@@ -119,6 +123,9 @@  noinst_HEADERS = \
 		  ${srcdir}/include/odp_timer_wheel_internal.h \
 		  ${srcdir}/include/odp_traffic_mngr_internal.h \
 		  ${srcdir}/Makefile.inc
+if WITH_DRIVERS
+noinst_HEADERS += $(top_srcdir)/drivers/driver_init.h
+endif
 
 __LIB__libodp_la_SOURCES = \
 			   odp_atomic.c \
@@ -178,3 +185,7 @@  EXTRA_DIST = \
 if HAVE_PCAP
 __LIB__libodp_la_SOURCES += pktio/pcap.c
 endif
+
+if WITH_DRIVERS
+__LIB__libodp_la_LIBADD = $(top_srcdir)/drivers/libdrivers.la
+endif