diff mbox

[API-NEXT,PATCHv2,2/2] linux-generic: dev: implement device id apis

Message ID 1476319476-18500-2-git-send-email-bill.fischofer@linaro.org
State New
Headers show

Commit Message

Bill Fischofer Oct. 13, 2016, 12:44 a.m. UTC
Add support for the odp_dev_id() API. This is a set of arch-specific
placeholder functions that simply return ODP_DEV_ANY to indicate that any
device will do. This also adds odp_dev_t fields to the various param
structs used to create pools, timer pools, and crypto sessions. These
all default to ODP_DEV_ANY.

Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>

---
Change in v2:
- Correct doxygen comment typo to enable make doxygen-doc to work properly

 include/odp/api/spec/crypto.h                      |  3 ++
 include/odp/api/spec/pool.h                        |  7 ++++
 include/odp/api/spec/timer.h                       |  3 ++
 include/odp_api.h                                  |  1 +
 platform/linux-generic/Makefile.am                 |  3 ++
 platform/linux-generic/arch/arm/odp_dev.c          | 13 ++++++
 platform/linux-generic/arch/default/odp_dev.c      | 13 ++++++
 platform/linux-generic/arch/mips64/odp_dev.c       | 13 ++++++
 platform/linux-generic/arch/powerpc/odp_dev.c      | 13 ++++++
 platform/linux-generic/arch/x86/odp_dev.c          | 13 ++++++
 platform/linux-generic/include/odp/api/dev.h       | 37 ++++++++++++++++
 .../linux-generic/include/odp/api/plat/dev_types.h | 49 ++++++++++++++++++++++
 12 files changed, 168 insertions(+)
 create mode 100644 platform/linux-generic/arch/arm/odp_dev.c
 create mode 100644 platform/linux-generic/arch/default/odp_dev.c
 create mode 100644 platform/linux-generic/arch/mips64/odp_dev.c
 create mode 100644 platform/linux-generic/arch/powerpc/odp_dev.c
 create mode 100644 platform/linux-generic/arch/x86/odp_dev.c
 create mode 100644 platform/linux-generic/include/odp/api/dev.h
 create mode 100644 platform/linux-generic/include/odp/api/plat/dev_types.h

-- 
2.7.4

Comments

Savolainen, Petri (Nokia - FI/Espoo) Oct. 24, 2016, 12:03 p.m. UTC | #1
> -----Original Message-----

> From: lng-odp [mailto:lng-odp-bounces@lists.linaro.org] On Behalf Of Bill

> Fischofer

> Sent: Thursday, October 13, 2016 3:45 AM

> To: lng-odp@lists.linaro.org

> Subject: [lng-odp] [API-NEXT PATCHv2 2/2] linux-generic: dev: implement

> device id apis

> 

> Add support for the odp_dev_id() API. This is a set of arch-specific

> placeholder functions that simply return ODP_DEV_ANY to indicate that any

> device will do. This also adds odp_dev_t fields to the various param

> structs used to create pools, timer pools, and crypto sessions. These

> all default to ODP_DEV_ANY.

> 

> Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>

> ---

> Change in v2:

> - Correct doxygen comment typo to enable make doxygen-doc to work properly

> 

>  include/odp/api/spec/crypto.h                      |  3 ++

>  include/odp/api/spec/pool.h                        |  7 ++++

>  include/odp/api/spec/timer.h                       |  3 ++

>  include/odp_api.h                                  |  1 +



These include API changes and should be introduced in a separate patch(es).



>  platform/linux-generic/Makefile.am                 |  3 ++

>  platform/linux-generic/arch/arm/odp_dev.c          | 13 ++++++

>  platform/linux-generic/arch/default/odp_dev.c      | 13 ++++++

>  platform/linux-generic/arch/mips64/odp_dev.c       | 13 ++++++

>  platform/linux-generic/arch/powerpc/odp_dev.c      | 13 ++++++

>  platform/linux-generic/arch/x86/odp_dev.c          | 13 ++++++



There's no reason to make device IDs CPU architecture specific. Device specification is ODP implementation specific (odp-linux have only one mapping from e.g. "dram0" to odp_dev_t).



>  platform/linux-generic/include/odp/api/dev.h       | 37 ++++++++++++++++

>  .../linux-generic/include/odp/api/plat/dev_types.h | 49

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

>  12 files changed, 168 insertions(+)

>  create mode 100644 platform/linux-generic/arch/arm/odp_dev.c

>  create mode 100644 platform/linux-generic/arch/default/odp_dev.c

>  create mode 100644 platform/linux-generic/arch/mips64/odp_dev.c

>  create mode 100644 platform/linux-generic/arch/powerpc/odp_dev.c

>  create mode 100644 platform/linux-generic/arch/x86/odp_dev.c

>  create mode 100644 platform/linux-generic/include/odp/api/dev.h

>  create mode 100644 platform/linux-

> generic/include/odp/api/plat/dev_types.h

> 

> diff --git a/include/odp/api/spec/crypto.h b/include/odp/api/spec/crypto.h

> index 0cb8814..c885a73 100644

> --- a/include/odp/api/spec/crypto.h

> +++ b/include/odp/api/spec/crypto.h

> @@ -19,6 +19,8 @@

>  extern "C" {

>  #endif

> 

> +#include <odp/api/dev.h>

> +

>  /** @defgroup odp_crypto ODP CRYPTO

>   *  Macros, enums, types and operations to utilise crypto.

>   *  @{

> @@ -182,6 +184,7 @@ typedef struct odp_crypto_session_params {

>  	odp_crypto_key_t auth_key;         /**< Authentication key */

>  	odp_queue_t compl_queue;           /**< Async mode completion event

> queue */

>  	odp_pool_t output_pool;            /**< Output buffer pool */

> +	odp_dev_t dev_id;                  /**< NUMA id of this crypto dev



No need to mention NUMA. It's just a crypto device (independent of the HW hierarchy).

"Crypto device to be used for the session."


> */

>  } odp_crypto_session_params_t;

> 

>  /**

> diff --git a/include/odp/api/spec/pool.h b/include/odp/api/spec/pool.h

> index c80c98a..0ce8af2 100644

> --- a/include/odp/api/spec/pool.h

> +++ b/include/odp/api/spec/pool.h

> @@ -20,6 +20,7 @@ extern "C" {

>  #endif

> 

>  #include <odp/api/std_types.h>

> +#include <odp/api/dev.h>

> 

>  /** @defgroup odp_pool ODP POOL

>   *  Operations on a pool.

> @@ -164,6 +165,12 @@ typedef struct odp_pool_param_t {

>  	/** Pool type */

>  	int type;

> 

> +	/** NUMA id for this pool */

> +	odp_dev_t pool_id;


No need to mention NUMA, just:

/** Pool device */
odp_dev_t pool_dev;

> +

> +	/** NUMA id for dram used for this pool */

> +	odp_dev_t dram_id;

> +


No need to mention NUMA or even DRAM (since selection may be also some internal, non-DRAM based memory) just:

/** Memory device */
odp_dev_t memory_dev;



>  	union {

>  		struct {

>  			/** Number of buffers in the pool */

> diff --git a/include/odp/api/spec/timer.h b/include/odp/api/spec/timer.h

> index df37189..459a030 100644

> --- a/include/odp/api/spec/timer.h

> +++ b/include/odp/api/spec/timer.h

> @@ -19,6 +19,8 @@

>  extern "C" {

>  #endif

> 

> +#include <odp/api/dev.h>

> +

>  /** @defgroup odp_timer ODP TIMER

>   *  @{

>   */

> @@ -103,6 +105,7 @@ typedef struct {

>  	uint32_t num_timers; /**< (Minimum) number of supported timers */

>  	int priv; /**< Shared (false) or private (true) timer pool */

>  	odp_timer_clk_src_t clk_src; /**< Clock source for timers */

> +	odp_dev_t dev_id; /**< NUMA id of this timer resource */


No NUMA, just timer_dev.


>  } odp_timer_pool_param_t;

> 



> diff --git a/platform/linux-generic/arch/arm/odp_dev.c b/platform/linux-

> generic/arch/arm/odp_dev.c

> new file mode 100644

> index 0000000..b136a37

> --- /dev/null

> +++ b/platform/linux-generic/arch/arm/odp_dev.c

> @@ -0,0 +1,13 @@

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

> + * All rights reserved.

> + *

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

> + */

> +

> +#include <odp/api/dev.h>

> +#include <odp/api/hints.h>

> +

> +odp_dev_t odp_dev_id(const char *name ODP_UNUSED)

> +{

> +	return ODP_DEV_ANY;

> +}


Just one implementation for odp-linux.


-Petri
diff mbox

Patch

diff --git a/include/odp/api/spec/crypto.h b/include/odp/api/spec/crypto.h
index 0cb8814..c885a73 100644
--- a/include/odp/api/spec/crypto.h
+++ b/include/odp/api/spec/crypto.h
@@ -19,6 +19,8 @@ 
 extern "C" {
 #endif
 
+#include <odp/api/dev.h>
+
 /** @defgroup odp_crypto ODP CRYPTO
  *  Macros, enums, types and operations to utilise crypto.
  *  @{
@@ -182,6 +184,7 @@  typedef struct odp_crypto_session_params {
 	odp_crypto_key_t auth_key;         /**< Authentication key */
 	odp_queue_t compl_queue;           /**< Async mode completion event queue */
 	odp_pool_t output_pool;            /**< Output buffer pool */
+	odp_dev_t dev_id;                  /**< NUMA id of this crypto dev */
 } odp_crypto_session_params_t;
 
 /**
diff --git a/include/odp/api/spec/pool.h b/include/odp/api/spec/pool.h
index c80c98a..0ce8af2 100644
--- a/include/odp/api/spec/pool.h
+++ b/include/odp/api/spec/pool.h
@@ -20,6 +20,7 @@  extern "C" {
 #endif
 
 #include <odp/api/std_types.h>
+#include <odp/api/dev.h>
 
 /** @defgroup odp_pool ODP POOL
  *  Operations on a pool.
@@ -164,6 +165,12 @@  typedef struct odp_pool_param_t {
 	/** Pool type */
 	int type;
 
+	/** NUMA id for this pool */
+	odp_dev_t pool_id;
+
+	/** NUMA id for dram used for this pool */
+	odp_dev_t dram_id;
+
 	union {
 		struct {
 			/** Number of buffers in the pool */
diff --git a/include/odp/api/spec/timer.h b/include/odp/api/spec/timer.h
index df37189..459a030 100644
--- a/include/odp/api/spec/timer.h
+++ b/include/odp/api/spec/timer.h
@@ -19,6 +19,8 @@ 
 extern "C" {
 #endif
 
+#include <odp/api/dev.h>
+
 /** @defgroup odp_timer ODP TIMER
  *  @{
  */
@@ -103,6 +105,7 @@  typedef struct {
 	uint32_t num_timers; /**< (Minimum) number of supported timers */
 	int priv; /**< Shared (false) or private (true) timer pool */
 	odp_timer_clk_src_t clk_src; /**< Clock source for timers */
+	odp_dev_t dev_id; /**< NUMA id of this timer resource */
 } odp_timer_pool_param_t;
 
 /**
diff --git a/include/odp_api.h b/include/odp_api.h
index ec7fcd2..89a99ae 100644
--- a/include/odp_api.h
+++ b/include/odp_api.h
@@ -25,6 +25,7 @@  extern "C" {
 #include <odp/api/hash.h>
 #include <odp/api/hints.h>
 #include <odp/api/debug.h>
+#include <odp/api/dev.h>
 #include <odp/api/byteorder.h>
 #include <odp/api/cpu.h>
 #include <odp/api/cpumask.h>
diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am
index 0d59877..9ab7378 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -31,6 +31,7 @@  odpapiinclude_HEADERS = \
 		  $(srcdir)/include/odp/api/cpumask.h \
 		  $(srcdir)/include/odp/api/crypto.h \
 		  $(srcdir)/include/odp/api/debug.h \
+		  $(srcdir)/include/odp/api/dev.h \
 		  $(srcdir)/include/odp/api/errno.h \
 		  $(srcdir)/include/odp/api/event.h \
 		  $(srcdir)/include/odp/api/hash.h \
@@ -75,6 +76,7 @@  odpapiplatinclude_HEADERS = \
 		  $(srcdir)/include/odp/api/plat/classification_types.h \
 		  $(srcdir)/include/odp/api/plat/cpumask_types.h \
 		  $(srcdir)/include/odp/api/plat/crypto_types.h \
+		  $(srcdir)/include/odp/api/plat/dev_types.h \
 		  $(srcdir)/include/odp/api/plat/event_types.h \
 		  $(srcdir)/include/odp/api/plat/init_types.h \
 		  $(srcdir)/include/odp/api/plat/packet_types.h \
@@ -228,6 +230,7 @@  __LIB__libodp_linux_la_SOURCES = \
 			   drv_shm.c \
 			   drv_spinlock.c \
 			   arch/@ARCH_DIR@/odp_cpu_arch.c \
+			   arch/@ARCH_DIR@/odp_dev.c \
 			   arch/@ARCH_DIR@/odp_sysinfo_parse.c
 
 if HAVE_PCAP
diff --git a/platform/linux-generic/arch/arm/odp_dev.c b/platform/linux-generic/arch/arm/odp_dev.c
new file mode 100644
index 0000000..b136a37
--- /dev/null
+++ b/platform/linux-generic/arch/arm/odp_dev.c
@@ -0,0 +1,13 @@ 
+/* Copyright (c) 2016, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:     BSD-3-Clause
+ */
+
+#include <odp/api/dev.h>
+#include <odp/api/hints.h>
+
+odp_dev_t odp_dev_id(const char *name ODP_UNUSED)
+{
+	return ODP_DEV_ANY;
+}
diff --git a/platform/linux-generic/arch/default/odp_dev.c b/platform/linux-generic/arch/default/odp_dev.c
new file mode 100644
index 0000000..b136a37
--- /dev/null
+++ b/platform/linux-generic/arch/default/odp_dev.c
@@ -0,0 +1,13 @@ 
+/* Copyright (c) 2016, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:     BSD-3-Clause
+ */
+
+#include <odp/api/dev.h>
+#include <odp/api/hints.h>
+
+odp_dev_t odp_dev_id(const char *name ODP_UNUSED)
+{
+	return ODP_DEV_ANY;
+}
diff --git a/platform/linux-generic/arch/mips64/odp_dev.c b/platform/linux-generic/arch/mips64/odp_dev.c
new file mode 100644
index 0000000..b136a37
--- /dev/null
+++ b/platform/linux-generic/arch/mips64/odp_dev.c
@@ -0,0 +1,13 @@ 
+/* Copyright (c) 2016, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:     BSD-3-Clause
+ */
+
+#include <odp/api/dev.h>
+#include <odp/api/hints.h>
+
+odp_dev_t odp_dev_id(const char *name ODP_UNUSED)
+{
+	return ODP_DEV_ANY;
+}
diff --git a/platform/linux-generic/arch/powerpc/odp_dev.c b/platform/linux-generic/arch/powerpc/odp_dev.c
new file mode 100644
index 0000000..b136a37
--- /dev/null
+++ b/platform/linux-generic/arch/powerpc/odp_dev.c
@@ -0,0 +1,13 @@ 
+/* Copyright (c) 2016, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:     BSD-3-Clause
+ */
+
+#include <odp/api/dev.h>
+#include <odp/api/hints.h>
+
+odp_dev_t odp_dev_id(const char *name ODP_UNUSED)
+{
+	return ODP_DEV_ANY;
+}
diff --git a/platform/linux-generic/arch/x86/odp_dev.c b/platform/linux-generic/arch/x86/odp_dev.c
new file mode 100644
index 0000000..b136a37
--- /dev/null
+++ b/platform/linux-generic/arch/x86/odp_dev.c
@@ -0,0 +1,13 @@ 
+/* Copyright (c) 2016, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:     BSD-3-Clause
+ */
+
+#include <odp/api/dev.h>
+#include <odp/api/hints.h>
+
+odp_dev_t odp_dev_id(const char *name ODP_UNUSED)
+{
+	return ODP_DEV_ANY;
+}
diff --git a/platform/linux-generic/include/odp/api/dev.h b/platform/linux-generic/include/odp/api/dev.h
new file mode 100644
index 0000000..f8faddd
--- /dev/null
+++ b/platform/linux-generic/include/odp/api/dev.h
@@ -0,0 +1,37 @@ 
+/* Copyright (c) 2016, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:     BSD-3-Clause
+ */
+
+/**
+ * @file
+ *
+ * ODP Device
+ */
+
+#ifndef ODP_PLAT_DEV_H_
+#define ODP_PLAT_DEV_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <odp/api/std_types.h>
+#include <odp/api/plat/dev_types.h>
+
+/** @ingroup odp_dev
+ *  @{
+ */
+
+/**
+ * @}
+ */
+
+#include <odp/api/spec/dev.h>
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/platform/linux-generic/include/odp/api/plat/dev_types.h b/platform/linux-generic/include/odp/api/plat/dev_types.h
new file mode 100644
index 0000000..669069d
--- /dev/null
+++ b/platform/linux-generic/include/odp/api/plat/dev_types.h
@@ -0,0 +1,49 @@ 
+/* Copyright (c) 2016, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:     BSD-3-Clause
+ */
+
+/**
+ * @file
+ *
+ * ODP device
+ */
+
+#ifndef ODP_DEV_TYPES_H_
+#define ODP_DEV_TYPES_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <odp/api/std_types.h>
+#include <odp/api/plat/strong_types.h>
+
+/** @addtogroup odp_dev ODP DEVICE
+ *  Macros and operation on a device.
+ *  @{
+ */
+
+typedef ODP_HANDLE_T(odp_dev_t);
+
+#define ODP_DEV_ANY      _odp_cast_scalar(odp_dev_t, 0)
+#define ODP_DEV_INVALID  _odp_cast_scalar(odp_dev_t, 0xffffffff)
+
+#define ODP_DEV_NAME_LEN 32
+
+/** Get printable format of odp_dev_t */
+static inline uint64_t odp_dev_id_to_u64(odp_dev_t hdl)
+{
+	return _odp_pri(hdl);
+}
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif