diff mbox

[API-NEXT,PATCHv2,1/5] drv: adding driver registration interface (stub)

Message ID 1478517324-11324-2-git-send-email-christophe.milard@linaro.org
State New
Headers show

Commit Message

Christophe Milard Nov. 7, 2016, 11:15 a.m. UTC
The driver registration function (and a draft of its parameters) is
defined, the goal being to define the driver registration framework only.

Signed-off-by: Christophe Milard <christophe.milard@linaro.org>

---
 include/odp/drv/spec/driver.h | 76 +++++++++++++++++++++++++++++++++++++++++++
 platform/Makefile.inc         |  1 +
 2 files changed, 77 insertions(+)
 create mode 100644 include/odp/drv/spec/driver.h

-- 
2.7.4

Comments

Yi He Nov. 8, 2016, 5:53 a.m. UTC | #1
Thanks Christophe for the answers to the questions.

For this series:

Reviewed-and-tested-by: Yi He <yi.he@linaro.org>

On 7 November 2016 at 19:15, Christophe Milard <christophe.milard@linaro.org
> wrote:


> The driver registration function (and a draft of its parameters) is

> defined, the goal being to define the driver registration framework only.

>

> Signed-off-by: Christophe Milard <christophe.milard@linaro.org>

> ---

>  include/odp/drv/spec/driver.h | 76 ++++++++++++++++++++++++++++++

> +++++++++++++

>  platform/Makefile.inc         |  1 +

>  2 files changed, 77 insertions(+)

>  create mode 100644 include/odp/drv/spec/driver.h

>

> diff --git a/include/odp/drv/spec/driver.h b/include/odp/drv/spec/driver.h

> new file mode 100644

> index 0000000..406112b

> --- /dev/null

> +++ b/include/odp/drv/spec/driver.h

> @@ -0,0 +1,76 @@

> +/* Copyright (c) 2016, Linaro Limited

> + * All rights reserved.

> + *

> + * SPDX-License-Identifier:     BSD-3-Clause

> + */

> +

> +/**

> + * @file

> + *

> + * ODPDRV driver

> + */

> +

> +#ifndef ODPDRV_DRIVER_H_

> +#define ODPDRV_DRIVER_H_

> +#include <odp/visibility_begin.h>

> +

> +#ifdef __cplusplus

> +extern "C" {

> +#endif

> +

> +/**

> + * @addtogroup odpdrv_driver

> + * @details

> + * NIC driver interface to ODP

> + *

> + * @{

> + */

> +

> +/**

> + * Different busses drivers can handle:

> + */

> +typedef enum odpdrv_bus_t {

> +       ODPDRV_BUS_UNKNOWN,     /**< error case: no driver should use that

> */

> +       ODPDRV_BUS_PCI          /**< pci bus, for all kind of pci drivers

> */

> +} odpdrv_bus_t;

> +

> +/**

> + * Different driver types

> + */

> +typedef enum odpdrv_driver_types_t {

> +       ODPDRV_UNKNOWN_TYPE,    /**< error case: no driver should use that

> */

> +       ODPDRV_PCI_VIRTIO,      /**< pci virtio driver

>  */

> +       ODPDRV_PCI_VFIO         /**< pci_vfio: vfio interface required

>  */

> +} odpdrv_driver_type_t;

> +

> +/**

> + * Parameter to be given at driver registration:

> + */

> +typedef struct odpdrv_driver_param_t {

> +       const char              *name;  /**< Driver name. */

> +       odpdrv_bus_t            bus;    /**< Driver bus.  */

> +       odpdrv_driver_type_t    type;   /**< Driver type. */

> +} odpdrv_driver_param_t;

> +

> +/**

> + * Register a Driver.

> + * A call to this function should be made by all drivers at init time.

> + * (called by an init function in the driver, probably using gcc/clang

> + * __constructor__ attribute.

> + *

> + * @param drv_param Pointer to a driver registration structure.

> + * @return 0 on success, non-zero on error. On error, drivers

> + * should release allocated resources and return.

> + */

> +int odpdrv_driver_register(odpdrv_driver_param_t *drv_param);

> +

> +/**

> + * @}

> + */

> +

> +#ifdef __cplusplus

> +}

> +#endif

> +

> +#include <odp/visibility_end.h>

> +#endif

> diff --git a/platform/Makefile.inc b/platform/Makefile.inc

> index b31b95b..69ee878 100644

> --- a/platform/Makefile.inc

> +++ b/platform/Makefile.inc

> @@ -67,6 +67,7 @@ odpdrvspecinclude_HEADERS = \

>                   $(top_srcdir)/include/odp/drv/spec/barrier.h \

>                   $(top_srcdir)/include/odp/drv/spec/byteorder.h \

>                   $(top_srcdir)/include/odp/drv/spec/compiler.h \

> +                 $(top_srcdir)/include/odp/drv/spec/driver.h \

>                   $(top_srcdir)/include/odp/drv/spec/shm.h \

>                   $(top_srcdir)/include/odp/drv/spec/spinlock.h \

>                   $(top_srcdir)/include/odp/drv/spec/std_types.h \

> --

> 2.7.4

>

>
diff mbox

Patch

diff --git a/include/odp/drv/spec/driver.h b/include/odp/drv/spec/driver.h
new file mode 100644
index 0000000..406112b
--- /dev/null
+++ b/include/odp/drv/spec/driver.h
@@ -0,0 +1,76 @@ 
+/* Copyright (c) 2016, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:     BSD-3-Clause
+ */
+
+/**
+ * @file
+ *
+ * ODPDRV driver
+ */
+
+#ifndef ODPDRV_DRIVER_H_
+#define ODPDRV_DRIVER_H_
+#include <odp/visibility_begin.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @addtogroup odpdrv_driver
+ * @details
+ * NIC driver interface to ODP
+ *
+ * @{
+ */
+
+/**
+ * Different busses drivers can handle:
+ */
+typedef enum odpdrv_bus_t {
+	ODPDRV_BUS_UNKNOWN,	/**< error case: no driver should use that */
+	ODPDRV_BUS_PCI		/**< pci bus, for all kind of pci drivers  */
+} odpdrv_bus_t;
+
+/**
+ * Different driver types
+ */
+typedef enum odpdrv_driver_types_t {
+	ODPDRV_UNKNOWN_TYPE,	/**< error case: no driver should use that */
+	ODPDRV_PCI_VIRTIO,	/**< pci virtio driver			   */
+	ODPDRV_PCI_VFIO		/**< pci_vfio: vfio interface required	   */
+} odpdrv_driver_type_t;
+
+/**
+ * Parameter to be given at driver registration:
+ */
+typedef struct odpdrv_driver_param_t {
+	const char		*name;	/**< Driver name. */
+	odpdrv_bus_t		bus;    /**< Driver bus.  */
+	odpdrv_driver_type_t	type;   /**< Driver type. */
+} odpdrv_driver_param_t;
+
+/**
+ * Register a Driver.
+ * A call to this function should be made by all drivers at init time.
+ * (called by an init function in the driver, probably using gcc/clang
+ * __constructor__ attribute.
+ *
+ * @param drv_param Pointer to a driver registration structure.
+ * @return 0 on success, non-zero on error. On error, drivers
+ * should release allocated resources and return.
+ */
+int odpdrv_driver_register(odpdrv_driver_param_t *drv_param);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#include <odp/visibility_end.h>
+#endif
diff --git a/platform/Makefile.inc b/platform/Makefile.inc
index b31b95b..69ee878 100644
--- a/platform/Makefile.inc
+++ b/platform/Makefile.inc
@@ -67,6 +67,7 @@  odpdrvspecinclude_HEADERS = \
 		  $(top_srcdir)/include/odp/drv/spec/barrier.h \
 		  $(top_srcdir)/include/odp/drv/spec/byteorder.h \
 		  $(top_srcdir)/include/odp/drv/spec/compiler.h \
+		  $(top_srcdir)/include/odp/drv/spec/driver.h \
 		  $(top_srcdir)/include/odp/drv/spec/shm.h \
 		  $(top_srcdir)/include/odp/drv/spec/spinlock.h \
 		  $(top_srcdir)/include/odp/drv/spec/std_types.h \