From patchwork Thu Jan 19 16:54:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 91963 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp331682obz; Thu, 19 Jan 2017 07:56:00 -0800 (PST) X-Received: by 10.233.235.214 with SMTP id b205mr8971923qkg.156.1484841360142; Thu, 19 Jan 2017 07:56:00 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id g9si2860562qte.195.2017.01.19.07.55.59; Thu, 19 Jan 2017 07:56:00 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id C2CDE6065E; Thu, 19 Jan 2017 15:55:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id A18FD6064C; Thu, 19 Jan 2017 15:55:12 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 6A4DE6064C; Thu, 19 Jan 2017 15:55:03 +0000 (UTC) Received: from mail-lf0-f53.google.com (mail-lf0-f53.google.com [209.85.215.53]) by lists.linaro.org (Postfix) with ESMTPS id 4B31060641 for ; Thu, 19 Jan 2017 15:55:01 +0000 (UTC) Received: by mail-lf0-f53.google.com with SMTP id n124so39676805lfd.2 for ; Thu, 19 Jan 2017 07:55:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=CoewyIBNmYyl/b5jVTD8MXC4689oJEJQy/ex6AJTya0=; b=lXlOsi7KuVIQHgK3YSXeoZROXK3ab9+3hKIDZBQxyfkhQWkBChxgjgcb1HY6NOV8qx bzlDw4l2Obe1tZsTTQeOaodF+CVGaJnD4Vrhe1JJsVE3Wn+RYU7+xyrjZZ0vQijTDh+5 84HZ3sFoxqdZl0VxNwFK+XVL3wwH33bCm3jHCkdMZsERQIPjr52dgVoEEoDEQK50EilY ZJer8kTiG9+Tdq9nGB9JylGCol1gRzBjrzljt0zhU7F+UuSs5lIkt2luypi/eFjUAOKl hfIikvc16PbaBH06BAV7ZuNUZsUYB2Ex/Je/gfUFd8RwIVglO17GoDMGDBbHjh8XIrJ5 avzw== X-Gm-Message-State: AIkVDXJ1Eyat3X2OE1OO15+OJJrCJXRiRmVE4dl1f80Uv1TTN6Apds2pbGo3XU4tlIyuCuTldYs= X-Received: by 10.25.227.14 with SMTP id a14mr2865711lfh.43.1484841299851; Thu, 19 Jan 2017 07:54:59 -0800 (PST) Received: from erachmi-ericsson.ki.sw.ericsson.se (c-83-233-76-66.cust.bredband2.com. [83.233.76.66]) by smtp.gmail.com with ESMTPSA id b7sm927770lfe.33.2017.01.19.07.54.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Jan 2017 07:54:59 -0800 (PST) From: Christophe Milard To: mike.holmes@linaro.org, bill.fischofer@linaro.org, yi.he@linaro.org, forrest.shi@linaro.org, maxim.uvarov@linaro.com, lng-odp@lists.linaro.org Date: Thu, 19 Jan 2017 17:54:17 +0100 Message-Id: <1484844861-1302-2-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1484844861-1302-1-git-send-email-christophe.milard@linaro.org> References: <1484844861-1302-1-git-send-email-christophe.milard@linaro.org> Subject: [lng-odp] [API-NEXT PATCHv10 1/5] drv: adding driver registration interface (stub) X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" The enumerator class, enumerator instance, devio and driver registration functions prototypes (and a draft of their parameters) are defined, the goal being to define the registration framework only. Signed-off-by: Christophe Milard --- include/odp/drv/spec/driver.h | 389 ++++++++++++++++++++++++++++++++++++++++++ platform/Makefile.inc | 1 + 2 files changed, 390 insertions(+) create mode 100644 include/odp/drv/spec/driver.h -- 2.7.4 diff --git a/include/odp/drv/spec/driver.h b/include/odp/drv/spec/driver.h new file mode 100644 index 0000000..d83e907 --- /dev/null +++ b/include/odp/drv/spec/driver.h @@ -0,0 +1,389 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * ODPDRV driver + */ + +#ifndef ODPDRV_DRIVER_H_ +#define ODPDRV_DRIVER_H_ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** +* @addtogroup odpdrv_driver +* @details +* enumerator and driver interface to ODP +* +* 1) ODP loads the different modules (i.e. it loads shared libraries, *.so). +* In the context of drivers, shared libraries may contain enumerators, +* drivers and devios. These register in step 2. +* +* 2) +* @code +* odpdrv_enumr_class_register(int (probe*)()...) +* -----------------------------------------------------------> +* odpdrv_driver_register(int (probe*)()...) +* -----------------------------------------------------------> +* odpdrv_devio_register() +* -----------------------------------------------------------> +* @endcode +* A number of device_enumerator_classes are registered at the ODP startup. +* Many classes are expected: static, ACPI, PCI, switchdev, virtual, DPAA2... +* A number of drivers also register to ODP (passing their own probe function). +* A number of device IO may also register to ODP (defining available devices +* interfaces). +* +* 3) ODP calls the probe function of each enumerator class
+* @code +* enumerator class probe() +* <----------------------------------------------------------- +* odpdrv_emum_register(int (probe*)()...) +* -----------------------------------------------------------> +* -----------------------------------------------------------> +* -----------------------------------------------------------> +* odpdrv_devio_register(...) +* -----------------------------------------------------------> +* -----------------------------------------------------------> +* -----------------------------------------------------------> +* @endcode +* ODP calls the probe function of each registered enumerator_class. +* This result in the enumerator_class registering some +* enumerators (instances of the class) by calling +* odpdrv_emumerator_register() for each instance. +* A given enumerator_class may create many enumerators based on its platform: +* For instance Linux defines a number of PCI domains that can be viewed as +* multiple PCI enumerators. In addition, it could be considered that each PCI +* root of each processor socket in a NUMA environment has its own PCI +* enumerator. +* For enumerator class PCI, there could be one instance for each PCI +* domain. +* The devios delivered with their enumerator may also register at this stage. +* +* 4) +* @code +* enumerator probe() +* <----------------------------------------------------------- +* odpdrv_device_create() +* -----------------------------------------------------------> +* odpdrv_device_create() +* -----------------------------------------------------------> +* odpdrv_device_create() +* -----------------------------------------------------------> +* @endcode +* For each enumerator instance, odp calls the probe function. +* This will trigger devices creation (Enumerators calls odpdrv +* odpdrv_device_create() for each new device). Enumerators are allowed +* to call odpdrv_device_create() at any time once they have been probed +* (hotplug). They also may call odpdrv_device_destroy() if needed. +* +* 5) The driver framework calls the drivers probe(D,I) functions of the +* drivers, with device D and devio I as parameter, assuming that: +* -devio I was on the driver supported list of devio (and version matches) +* -the devio I is registered and found its enumerator interface(E) api +* (name and version) +* -device D was enumerated by an enumerator providing interface E. +* The return value of the driver probe function tells whether the driver +* can handle the device or not. +* +* @{ +*/ + +/* Forward declarations for a top down description of structures */ +/** Parameters for enumerator class registration */ +typedef struct odpdrv_enumr_class_param_t odpdrv_enumr_class_param_t; +/** Parameters for enumerator registration */ +typedef struct odpdrv_enumr_param_t odpdrv_enumr_param_t; +/** Parameters for new device creation */ +typedef struct odpdrv_device_param_t odpdrv_device_param_t; +/** Parameters for devio registration*/ +typedef struct odpdrv_devio_param_t odpdrv_devio_param_t; +/** Parameters for driver registration*/ +typedef struct odpdrv_driver_param_t odpdrv_driver_param_t; + +/** + * @typedef odpdrv_enumr_class_t + * ODPDRV enumerator class, such as PCI. + */ +/** + * @def ODPDRV_ENUMR_CLASS_INVALID + * Invalid odpdrv enumerator class + */ + +/** + * @typedef odpdrv_enumr_t + * ODPDRV enumerator. Instance of odpdrv_enumr_class_t. + */ +/** + * @def ODPDRV_ENUMR_INVALID + * Invalid odpdrv enumerator + */ + +/** + * @typedef odpdrv_device_t + * ODPDRV device. Created and destroyed by enumerators + */ +/** + * @def ODPDRV_DEVICE_INVALID + * Invalid odpdrv device + */ + +/** + * @typedef odpdrv_devio_t + * ODPDRV device IO interface. + */ +/** + * @def ODPDRV_DEVIO_INVALID + * Invalid odpdrv device IO + */ + +/** + * @typedef odpdrv_driver_t + * ODPDRV device driver. + */ +/** + * @def ODPDRV_DRIVER_INVALID + * Invalid odpdrv driver + */ + +/** Maximum size for driver and enumerator names */ +#define ODPDRV_NAME_SIZE 32 + +/** Maximum size for the enumerator dependent address */ +#define ODPDRV_NAME_ADDR_SZ 64 + +/** The maximum number of interfaces a driver may support */ +#define ODPDRV_MAX_DEVIOS 3 + +/** +* Parameters to be given at enumerator class registration +*/ +struct odpdrv_enumr_class_param_t { + /** Enumerator name: mostly used for debug purpose. + * Name must be unique (e.g. "PCI-DPAA2") + */ + const char name[ODPDRV_NAME_SIZE]; + + /** Probe function: + * Called by ODP to get the enumerator class instances registered + */ + int (*probe)(void); + + /** Remove function: + * Free whatever resource the class may have allocated. + */ + int (*remove)(void); +}; + +/** +* Parameter to be given at enumerator (instance) registration +*/ +struct odpdrv_enumr_param_t { + /** Class + * Identifies the class of the enumerator + */ + odpdrv_enumr_class_t enumr_class; + + /** Enumerator api_name and version are used by the devio + * to make sure the device can be accessed: + * E.g. "PCI" + * The format of the enum_dev part for the odpdrv_device_param_t + * structure is identified by the api-name and version below + */ + const char api_name[ODPDRV_NAME_SIZE]; + uint32_t api_version; /**<< the version of the provided API */ + + /** Probe function: + * Called by ODP when it is ready for device creation/deletion + * returns an negative value on error or 0 on success. + */ + int (*probe)(void); + + /** Remove function: + * destroy all enumerated devices and release all resources + */ + int (*remove)(void); + + /** Register event notifier function for hotplug events: + * register_notifier(fcnt,event_mask) registers fcnt as a callback when + * one of the event specified in event_mask occurs. + */ + int (*register_notifier)(void (*event_handler) (uint64_t event), + int64_t event_mask); +}; + +/* The following events are supported by enumerators */ +#define ODPDRV_ENUM_EV_REMOVED 0x0000000000000001 /**<< remove event */ + +/** This structure defines a generic enumerated device, or actually the +* common part between all devices, the enumerator specific part being pointed +* by the enum_dev field below. +*/ +struct odpdrv_device_param_t { + /** enumerator + * enumerator which enumerated the device: as returned by + * odpdrv_enumr_register + * devices with parents get destroyed when the parents dies. + */ + odpdrv_enumr_t enumerator; + + /** Device address: + * An enumerator dependent string giving the device address, + * e.g. "0000.23.12.1" for PCI domain 0, bus 23, device 12, function 1. + * This string identifies the device uniquely. + */ + const char address[ODPDRV_NAME_ADDR_SZ]; + + /** Enumerator dependent part + * This part is allocated by the enumerator and is enumerator dependent + * (i.e. different devices types will have different contents for + * enum_dev). + */ + void *enum_dev; +}; + +/** + * Parameter to be given at devio registration + */ +struct odpdrv_devio_param_t { + /** Devio name + * Identifies devio interface implemented by this devio + * (i.e:many devios may have the same name, but none of those + * with same provided interface should refer to a common enumerator + * class) + */ + const char api_name[ODPDRV_NAME_SIZE]; + uint32_t api_version; /**<< the version of the provided API */ + + /** Enumerator interface name and version + * The enumerator interface this devio needs. + */ + const char enumr_api_name[ODPDRV_NAME_SIZE]; + uint32_t enumr_api_version; /**<< required enumerator API version */ + + /** Ops + * Pointer to a devio ops structure (specific to each devio) + */ + void *ops; +}; + +/** +* Parameter to be given at driver registration +*/ +struct odpdrv_driver_param_t { + /** Driver name + * The driver name (the pair {driver-name, enum-api-name} must + * be unique) + */ + const char name[ODPDRV_NAME_SIZE]; + + /** Supported devios: + * The list of supported devio: one of the following devio + * (with correct version) must be available for the driver to work: + */ + struct { + const char api_name[ODPDRV_NAME_SIZE]; /**<< devio API name */ + uint32_t api_version; /**<< devio API version */ + } devios[ODPDRV_MAX_DEVIOS]; + + /** Probe function: + * Called by ODP to see if the driver can drive a given device + * + */ + int (*probe)(odpdrv_device_t *dev); + + /** Remove function: + * Only called with devices whose probe() returned true + * + */ + int (*remove)(odpdrv_device_param_t *dev); + +}; + +/** +* Register an enumerator class. +* Each enumerator class calls this function at init time. +* (probably using gcc/clang * __constructor__ attribute.) +* +* @param param Pointer to a enumerator class registration structure. +* @return an enumerator class handle or ODPDRV_ENUMR_CLASS_INVALID on error. +* On errors, enumerators classes should release allocated resources and return. +*/ +odpdrv_enumr_class_t odpdrv_enumr_class_register(odpdrv_enumr_class_param_t + *param); + +/** +* Register an enumerator. +* Each enumerator calls this function at init time. +* (probably using gcc/clang * __constructor__ attribute.) +* +* @param param Pointer to a enumerator registration parameter structure. +* @return an enumerator handle or ODPDRV_ENUMR_INVALID on error. +* On errors, enumerators should release allocated resources and return. +*/ +odpdrv_enumr_t odpdrv_enumr_register(odpdrv_enumr_param_t *param); + +/** +* Create a device +* Called by each enumerator at probe time, or anytime later, for each +* new created device +* @param param Pointer to a device parameter structure. +* @return an odpdrv devuice handle or ODPDRV_DEVICE_INVALID on error. +*/ +odpdrv_device_t odpdrv_device_create(odpdrv_device_param_t *param); + +/** +* Destroy a device +* Called by each enumerator at probe time, or anytime later, for each +* destroyed created device +* @param dev A odpdrv device handle as returned by odpdrv_device_create. +* @return 0 on success or a negative value on error. +*/ +void odpdrv_device_destroy(odpdrv_device_t dev); + +/** +* Register an devio. +* Each devio calls this function at init time. +* (probably using gcc/clang * __constructor__ attribute.) +* +* @param param Pointer to a devio registration structure. +* @return an odpdrv_devio_t handle or ODPDRV_DEVIO_INVALID on error. +*/ +odpdrv_devio_t odpdrv_devio_register(odpdrv_devio_param_t *param); + +/** +* Register a Driver. +* Each driver calls this function at init time. +* (probably using gcc/clang * __constructor__ attribute.) +* +* @param param Pointer to a driver registration structure. +* @return an odpdrv_driver_t handle or ODPDRV_DRIVER_INVALID on error. +* On errors, drivers should release allocated resources and return. +*/ +odpdrv_driver_t odpdrv_driver_register(odpdrv_driver_param_t *param); + +/** +* Print (ODP_DBG) the driver interface status (debug). +* +* @return 0 on success, less than zero on error (inconsistency detected) +*/ +int odpdrv_print_all(void); + +/** +* @} +*/ + +#ifdef __cplusplus +} +#endif + +#include +#endif diff --git a/platform/Makefile.inc b/platform/Makefile.inc index aefbf9a..57026d0 100644 --- a/platform/Makefile.inc +++ b/platform/Makefile.inc @@ -68,6 +68,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 \ From patchwork Thu Jan 19 16:54:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 91964 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp332060obz; Thu, 19 Jan 2017 07:56:57 -0800 (PST) X-Received: by 10.36.159.3 with SMTP id c3mr30757673ite.50.1484841417780; Thu, 19 Jan 2017 07:56:57 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id i85si4660665ioo.159.2017.01.19.07.56.57; Thu, 19 Jan 2017 07:56:57 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 50E0A6064F; Thu, 19 Jan 2017 15:56:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id EE9B962B88; Thu, 19 Jan 2017 15:55:15 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id A36C46064D; Thu, 19 Jan 2017 15:55:04 +0000 (UTC) Received: from mail-lf0-f50.google.com (mail-lf0-f50.google.com [209.85.215.50]) by lists.linaro.org (Postfix) with ESMTPS id 5988E60649 for ; Thu, 19 Jan 2017 15:55:02 +0000 (UTC) Received: by mail-lf0-f50.google.com with SMTP id k86so39654252lfi.0 for ; Thu, 19 Jan 2017 07:55:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=p/ZdD2eu+Hn3CQhWBdf2YaYrnkYcx+fbqG77h7JpEcY=; b=EUvi2sLNwmga2/AbHqC76W9e8MuSEQ5yp6aF1Q8guevu8bfzgLQ+HmmpJHMQQ3I33h MAwGvlFrJRwQGGp63p2bTPLttbaXkWqCWIA0XpITJ0VfwPec8qVPEPlnwGRjSkOJIJgv ZIdzol/beMfvyunq2I+vM0vhkBjgyzjjQXgioh9fjXTvuyL2o+bEhF8KUW6VB1Jdv9np hC9XJt1UJWnJE1aWH4pMqKHn/fUf5zORPCgg01YrHNklFIfqlbA33VrRS1ktwDU3kFA6 DrB3ktea27rvDeCyBHTXXKuRvMMm9SkSeWfzW6gDysx5/cp0Y2jhWsQFSMWPuBe+863U JoHw== X-Gm-Message-State: AIkVDXKydUcwgPT9QDY05TeHX96lB7JT/R8TGTxQCMl6smM0gdPkMuSjaCLOk6VWKounizuXgQU= X-Received: by 10.25.20.152 with SMTP id 24mr2860810lfu.152.1484841301064; Thu, 19 Jan 2017 07:55:01 -0800 (PST) Received: from erachmi-ericsson.ki.sw.ericsson.se (c-83-233-76-66.cust.bredband2.com. [83.233.76.66]) by smtp.gmail.com with ESMTPSA id b7sm927770lfe.33.2017.01.19.07.54.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Jan 2017 07:55:00 -0800 (PST) From: Christophe Milard To: mike.holmes@linaro.org, bill.fischofer@linaro.org, yi.he@linaro.org, forrest.shi@linaro.org, maxim.uvarov@linaro.com, lng-odp@lists.linaro.org Date: Thu, 19 Jan 2017 17:54:18 +0100 Message-Id: <1484844861-1302-3-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1484844861-1302-1-git-send-email-christophe.milard@linaro.org> References: <1484844861-1302-1-git-send-email-christophe.milard@linaro.org> Subject: [lng-odp] [API-NEXT PATCHv10 2/5] linux-gen: adding enum, devio and driver registration interface (stub) X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" The linux implementation for the enumerator class registration function, enumerator instance registration function, devio and driver registration functions (stub) Signed-off-by: Christophe Milard --- include/odp_drv.h | 1 + platform/linux-generic/Makefile.am | 2 + platform/linux-generic/drv_driver.c | 64 ++++++++++++++++++++++ platform/linux-generic/include/odp/drv/driver.h | 37 +++++++++++++ .../include/odp/drv/plat/driver_types.h | 52 ++++++++++++++++++ 5 files changed, 156 insertions(+) create mode 100644 platform/linux-generic/drv_driver.c create mode 100644 platform/linux-generic/include/odp/drv/driver.h create mode 100644 platform/linux-generic/include/odp/drv/plat/driver_types.h -- 2.7.4 diff --git a/include/odp_drv.h b/include/odp_drv.h index 0959879..96d81ba 100644 --- a/include/odp_drv.h +++ b/include/odp_drv.h @@ -23,6 +23,7 @@ extern C { #include #include #include +#include #include #include #include diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index 74e606d..c752645 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -109,6 +109,7 @@ odpdrvinclude_HEADERS = \ $(srcdir)/include/odp/drv/barrier.h \ $(srcdir)/include/odp/drv/byteorder.h \ $(srcdir)/include/odp/drv/compiler.h \ + $(srcdir)/include/odp/drv/driver.h \ $(srcdir)/include/odp/drv/shm.h \ $(srcdir)/include/odp/drv/spinlock.h \ $(srcdir)/include/odp/drv/std_types.h \ @@ -233,6 +234,7 @@ __LIB__libodp_linux_la_SOURCES = \ odp_weak.c \ drv_atomic.c \ drv_barrier.c \ + drv_driver.c \ drv_shm.c \ drv_spinlock.c \ arch/@ARCH_DIR@/odp_cpu_arch.c \ diff --git a/platform/linux-generic/drv_driver.c b/platform/linux-generic/drv_driver.c new file mode 100644 index 0000000..529da48 --- /dev/null +++ b/platform/linux-generic/drv_driver.c @@ -0,0 +1,64 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include + +#include +#include +#include +#include + +odpdrv_enumr_class_t odpdrv_enumr_class_register(odpdrv_enumr_class_param_t + *param) +{ + ODP_ERR("NOT Supported yet! Enumerator Class %s Registration!\n.", + param->name); + + return ODPDRV_ENUMR_CLASS_INVALID; +} + +odpdrv_enumr_t odpdrv_enumr_register(odpdrv_enumr_param_t *param) +{ + ODP_ERR("NOT Supported yet! Enumerator API %s Registration!\n.", + param->api_name); + + return ODPDRV_ENUMR_INVALID; +} + +odpdrv_device_t odpdrv_device_create(odpdrv_device_param_t *param) +{ + ODP_ERR("odpdrv_device_create not Supported yet! devaddress: %s\n.", + param->address); + return ODPDRV_DEVICE_INVALID; +} + +void odpdrv_device_destroy(odpdrv_device_t dev) +{ + if (dev == ODPDRV_DEVICE_INVALID) + ODP_ERR("Invalid device\n"); +} + +odpdrv_devio_t odpdrv_devio_register(odpdrv_devio_param_t *param) +{ + ODP_ERR("NOT Supported yet! Driver %s Registration!\n.", + param->api_name); + + return ODPDRV_DEVIO_INVALID; +} + +odpdrv_driver_t odpdrv_driver_register(odpdrv_driver_param_t *param) +{ + ODP_ERR("NOT Supported yet! Driver %s Registration!\n.", + param->name); + + return ODPDRV_DRIVER_INVALID; +} + +int odpdrv_print_all(void) +{ + ODP_ERR("odpdrv_print_all not Supported yet!\n."); + return 0; +} diff --git a/platform/linux-generic/include/odp/drv/driver.h b/platform/linux-generic/include/odp/drv/driver.h new file mode 100644 index 0000000..b12c83d --- /dev/null +++ b/platform/linux-generic/include/odp/drv/driver.h @@ -0,0 +1,37 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * ODPDRV drivers + */ + +#ifndef ODPDRV_PLAT_DRIVER_H_ +#define ODPDRV_PLAT_DRIVER_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/** @ingroup odpdrv_driver + * @{ + */ + +/** + * @} + */ + +#include +#include + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/platform/linux-generic/include/odp/drv/plat/driver_types.h b/platform/linux-generic/include/odp/drv/plat/driver_types.h new file mode 100644 index 0000000..6c611bd --- /dev/null +++ b/platform/linux-generic/include/odp/drv/plat/driver_types.h @@ -0,0 +1,52 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * ODP shared memory + */ + +#ifndef ODPDRV_DRIVER_TYPES_H_ +#define ODPDRV_DRIVER_TYPES_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/** @addtogroup odpdrv_driver ODPDRV DRIVER + * Operations on driver related items (enumerator class, enumerators, + * devios and drivers). + * @{ + */ + +typedef ODPDRV_HANDLE_T(odpdrv_enumr_class_t); +#define ODPDRV_ENUMR_CLASS_INVALID _odpdrv_cast_scalar(odpdrv_enumr_class_t, 0) + +typedef ODPDRV_HANDLE_T(odpdrv_enumr_t); +#define ODPDRV_ENUMR_INVALID _odpdrv_cast_scalar(odpdrv_enumr_t, 0) + +typedef ODPDRV_HANDLE_T(odpdrv_device_t); +#define ODPDRV_DEVICE_INVALID _odpdrv_cast_scalar(odpdrv_device_t, 0) + +typedef ODPDRV_HANDLE_T(odpdrv_devio_t); +#define ODPDRV_DEVIO_INVALID _odpdrv_cast_scalar(odpdrv_devio_t, 0) + +typedef ODPDRV_HANDLE_T(odpdrv_driver_t); +#define ODPDRV_DRIVER_INVALID _odpdrv_cast_scalar(odpdrv_driver_t, 0) + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif From patchwork Thu Jan 19 16:54:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 91965 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp332385obz; Thu, 19 Jan 2017 07:57:47 -0800 (PST) X-Received: by 10.107.47.21 with SMTP id j21mr6435419ioo.154.1484841467495; Thu, 19 Jan 2017 07:57:47 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id u123si11171299itb.7.2017.01.19.07.57.47; Thu, 19 Jan 2017 07:57:47 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 0BB6A60D99; Thu, 19 Jan 2017 15:57:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 2F18F60809; Thu, 19 Jan 2017 15:55:17 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 81874607B9; Thu, 19 Jan 2017 15:55:06 +0000 (UTC) Received: from mail-lf0-f41.google.com (mail-lf0-f41.google.com [209.85.215.41]) by lists.linaro.org (Postfix) with ESMTPS id 7EC9A60513 for ; Thu, 19 Jan 2017 15:55:03 +0000 (UTC) Received: by mail-lf0-f41.google.com with SMTP id z134so39717746lff.3 for ; Thu, 19 Jan 2017 07:55:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=PcL95RScK+g5OcV3Oqb9nsJtW3Ht7j4JHlmfiEWX+BM=; b=On/DJcikB+0eUO7UKUdF/T7CH00iJpegUmqIlqShFoej6GJj4JjnzZxetGnerbAFct pN/cicOP33RgcvVczGk9WxY91rm5q4931vbfT5+wu5eS+o6mYS421gxnRy2D2aWq8LC5 7VZ4N2GL8wLwdTRvqJPovxrm1mY/VwPzQ2C5PIduVBRczLamHuptRpR6/Zg78UFXrbYP LRAz9O3PbWIvDe1mS+/RJqYntXok1qy5pqLaP6AW32KuhtuHEwuC00Av3OoglJnKlt9G AIWmulBoVLOJQFjBUllDWvgsgHHr8BLwdl4/vaRmcro3c3fC/nmoEtD5zD88KQftIb4q mCRA== X-Gm-Message-State: AIkVDXK03zUfCJ4o6kVSwq6BO02snAYgNivw5ugzD/82z4OVrQL0g6PB8crV+EHUGZ78sLMPz1s= X-Received: by 10.25.213.78 with SMTP id m75mr3186511lfg.36.1484841302191; Thu, 19 Jan 2017 07:55:02 -0800 (PST) Received: from erachmi-ericsson.ki.sw.ericsson.se (c-83-233-76-66.cust.bredband2.com. [83.233.76.66]) by smtp.gmail.com with ESMTPSA id b7sm927770lfe.33.2017.01.19.07.55.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Jan 2017 07:55:01 -0800 (PST) From: Christophe Milard To: mike.holmes@linaro.org, bill.fischofer@linaro.org, yi.he@linaro.org, forrest.shi@linaro.org, maxim.uvarov@linaro.com, lng-odp@lists.linaro.org Date: Thu, 19 Jan 2017 17:54:19 +0100 Message-Id: <1484844861-1302-4-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1484844861-1302-1-git-send-email-christophe.milard@linaro.org> References: <1484844861-1302-1-git-send-email-christophe.milard@linaro.org> Subject: [lng-odp] [API-NEXT PATCHv10 3/5] linux-gen: init: adding configuration file parsing X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" The parsing of the odp.conf configuration file is added. The file is searched first in filename specified in the environment variable $ODP_SYSCONFIG_FILE (where the special string "none" prevent any file loading) The file is then searched in the user home directory (~) and then is the $prefix/etc directory. This requires libconfig (sudo apt-get install libconfig-dev) Signed-off-by: Christophe Milard --- .travis.yml | 2 +- DEPENDENCIES | 8 +-- platform/linux-generic/Makefile.am | 1 + platform/linux-generic/include/odp_internal.h | 2 + platform/linux-generic/m4/configure.m4 | 11 ++++ platform/linux-generic/odp_init.c | 80 +++++++++++++++++++++++++++ 6 files changed, 99 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/.travis.yml b/.travis.yml index 03e61b1..a6f770c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,7 @@ sudo: required before_install: - sudo apt-get -qq update - - sudo apt-get install automake autoconf libtool libssl-dev graphviz mscgen doxygen + - sudo apt-get install automake autoconf libtool libssl-dev graphviz mscgen doxygen libconfig-dev - sudo apt-get install libpcap-dev linux-headers-`uname -r` - gem install asciidoctor diff --git a/DEPENDENCIES b/DEPENDENCIES index f1f0edd..f285783 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -18,18 +18,18 @@ Prerequisites for building the OpenDataPlane (ODP) API 3. Required libraries - Libraries currently required to link: openssl + Libraries currently required to link: openssl, libconfig -3.1 OpenSSL native compile +3.1 OpenSSL and libconf native compile For native compilation, simply load the necessary libraries using the appropriate tool set. On Debian/Ubuntu systems: - $ sudo apt-get install libssl-dev + $ sudo apt-get install libssl-dev libconfig-dev On CentOS/RedHat/Fedora systems: - $ sudo yum install openssl-devel + $ sudo yum install openssl-devel libconfig-devel 3.2 OpenSSL cross compilation diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index c752645..2d92c97 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -8,6 +8,7 @@ AM_CFLAGS += -I$(srcdir)/include AM_CFLAGS += -I$(top_srcdir)/include AM_CFLAGS += -I$(top_builddir)/include AM_CFLAGS += -Iinclude +AM_CFLAGS += -DSYSCONFDIR=\"@sysconfdir@\" include_HEADERS = \ $(top_srcdir)/include/odp.h \ diff --git a/platform/linux-generic/include/odp_internal.h b/platform/linux-generic/include/odp_internal.h index b313b1f..9d1fc58 100644 --- a/platform/linux-generic/include/odp_internal.h +++ b/platform/linux-generic/include/odp_internal.h @@ -22,6 +22,7 @@ extern "C" { #include #include #include +#include extern __thread int __odp_errno; @@ -50,6 +51,7 @@ struct odp_global_data_s { odp_cpumask_t control_cpus; odp_cpumask_t worker_cpus; int num_cpus_installed; + config_t configuration; }; enum init_stage { diff --git a/platform/linux-generic/m4/configure.m4 b/platform/linux-generic/m4/configure.m4 index d3e5528..5fab0cc 100644 --- a/platform/linux-generic/m4/configure.m4 +++ b/platform/linux-generic/m4/configure.m4 @@ -28,6 +28,17 @@ AC_LINK_IFELSE( echo "Use newer version. For gcc > 4.7.0" exit -1) +# Check for libconfig (required) +AC_CHECK_HEADERS([libconfig.h], HEADER_LIBCONFIG="yes") +PKG_CHECK_MODULES([PKGCONFIG], [libconfig >= 1.3.2], LIBRARY_LIBCONFIG="yes") +if test "x$LIBRARY_LIBCONFIG" != "x" && test "x$HEADER_LIBCONFIG" != "x" ; then + CFLAGS="$CFLAGS $PKGCONFIG_CFLAGS" + LIBS="$LIBS $PKGCONFIG_LIBS" + AM_CPPFLAGS="$AM_CPPFLAGS `pkg-config --cflags-only-I libconfig`" +else + AC_MSG_FAILURE([libconfig not found (required)]) +fi + m4_include([platform/linux-generic/m4/odp_pthread.m4]) m4_include([platform/linux-generic/m4/odp_openssl.m4]) m4_include([platform/linux-generic/m4/odp_pcap.m4]) diff --git a/platform/linux-generic/odp_init.c b/platform/linux-generic/odp_init.c index 06c6143..0e9167c 100644 --- a/platform/linux-generic/odp_init.c +++ b/platform/linux-generic/odp_init.c @@ -10,6 +10,8 @@ #include #include #include +#include +#include #include #include #include @@ -21,6 +23,15 @@ #define _ODP_FILES_FMT "odp-%d-" #define _ODP_TMPDIR "/tmp" +/* the name of the ODP configuration file: */ +#define CONFIGURATION_FILE_ENV_NONE "none" +#define CONFIGURATION_FILE "odp.conf" +#define CONFIGURATION_FILE_USR ("." CONFIGURATION_FILE) +#define CONFIGURATION_FILE_SYS (SYSCONFDIR "/" CONFIGURATION_FILE) + +/* the ODP configuration file name can also be oveerwritten by env. variable: */ +#define ODP_SYSCONFIG_FILE_ENV "ODP_SYSCONFIG_FILE" + struct odp_global_data_s odp_global_data; /* remove all files staring with "odp-" from a directory "dir" */ @@ -65,6 +76,72 @@ static int cleanup_files(const char *dirpath, int odp_pid) return 0; } +/* read the odp configuration file + * + * the configuration file is read from: + * 1) Wherever env variable ODP_SYSCONFIG_FILE says (or "none") + * 2) ./odp.conf + * 3) the @sysconfig@/odp.conf + * (checked in reverse order overwritting each-other) + * So the environment variable setting supperseeds any other file. + * If the environment variable exists and set to the string "none" + * the configuration file reading is inibited (used to prevent + * test which do not need a file to read the user or system files) + */ +static int read_configfile(void) +{ + config_t *cf; + const char *config_filename; + char user_config_filename[PATH_MAX]; + char *env_config_filename; + + /* initialize and read the configuration file if any: */ + cf = &odp_global_data.configuration; + config_init(cf); + config_filename = NULL; + /* check if the system config file can be reached :*/ + if (access(CONFIGURATION_FILE_SYS, R_OK) != -1) + config_filename = CONFIGURATION_FILE_SYS; + /* check if the user config file can be reached (overwrite if so) :*/ + strncpy(user_config_filename, getenv("HOME"), PATH_MAX); + if (user_config_filename[0]) { + strncat(user_config_filename, "/", PATH_MAX); + strncat(user_config_filename, CONFIGURATION_FILE_USR, PATH_MAX); + if ((access(user_config_filename, R_OK) != -1)) + config_filename = user_config_filename; + } + /* check if other config file is specified via env (overwrite if so):*/ + env_config_filename = getenv(ODP_SYSCONFIG_FILE_ENV); + if (env_config_filename) { + /* none means "read no file": */ + if (!strcmp(env_config_filename, CONFIGURATION_FILE_ENV_NONE)) + return 0; + if (access(env_config_filename, R_OK) != -1) { + config_filename = env_config_filename; + } else { + ODP_ERR("Cannot read ODP configurattion file %s " + "(set by env variable " + ODP_SYSCONFIG_FILE_ENV ")\n", + env_config_filename); + config_filename = NULL; + return -1; + } + } + if (config_filename) { + ODP_DBG("Reading configuration file: %s\n", config_filename); + if (!config_read_file(cf, config_filename)) { + ODP_ERR("%s:%d - %s\n", + config_error_file(cf), + config_error_line(cf), + config_error_text(cf)); + config_destroy(cf); + return(-1); + } + } + + return 0; +} + int odp_init_global(odp_instance_t *instance, const odp_init_t *params, const odp_platform_init_t *platform_params ODP_UNUSED) @@ -87,6 +164,9 @@ int odp_init_global(odp_instance_t *instance, cleanup_files(_ODP_TMPDIR, odp_global_data.main_pid); + if (read_configfile()) + goto init_failed; + if (odp_cpumask_init_global(params)) { ODP_ERR("ODP cpumask init failed.\n"); goto init_failed; From patchwork Thu Jan 19 16:54:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 91966 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp332693obz; Thu, 19 Jan 2017 07:58:40 -0800 (PST) X-Received: by 10.55.86.196 with SMTP id k187mr8960145qkb.203.1484841520158; Thu, 19 Jan 2017 07:58:40 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 129si2860375qkh.165.2017.01.19.07.58.39; Thu, 19 Jan 2017 07:58:40 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id CA58F60D99; Thu, 19 Jan 2017 15:58:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 9991462C44; Thu, 19 Jan 2017 15:55:20 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 54B146074E; Thu, 19 Jan 2017 15:55:06 +0000 (UTC) Received: from mail-lf0-f44.google.com (mail-lf0-f44.google.com [209.85.215.44]) by lists.linaro.org (Postfix) with ESMTPS id 5376D60641 for ; Thu, 19 Jan 2017 15:55:04 +0000 (UTC) Received: by mail-lf0-f44.google.com with SMTP id n124so39677889lfd.2 for ; Thu, 19 Jan 2017 07:55:04 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=o92g8WBLaMXE+A06xMeElpJM0zQAI6SQyF2oiMOLSlI=; b=UlFSUQksEPC/xCOprhM8gg/gRQyPQcFPefyEd6sf5DrMcAxJdgSAdHdiqrJ/xL+9hc 9RkpENboKl159PO7RvkjcgwKbp2XBWw0wNWlMGySGV8P/Sh4V7S4BrIrHbUvHfK3zrJ8 Zz18RQs1f03OaLS1rD578PZ6+zcNp0AT7kc3rqpFRsAIpS7s9BWhKwi+ZGUILFOj7JgK iIdHP+NwSYeQbKZDFKvL0luqQpV1NF09+zWjaJAhyjRkgzFPNP6DKcdE0JtEhrmQPGys s+WRZHV0IpiJK4it/jU7jE/q5QU8cVC4/AwMZ4gK6tAwPlVG3BIq3qCmq2GsPoaEIuvb 1C8g== X-Gm-Message-State: AIkVDXJ9vAtKhe63vvC3RMcXfLcPDIO7YkhOXoABG1Qv3bNI/CoOKtj2v/xz58rIJi6yZvM9nSg= X-Received: by 10.25.127.2 with SMTP id a2mr3315346lfd.68.1484841303166; Thu, 19 Jan 2017 07:55:03 -0800 (PST) Received: from erachmi-ericsson.ki.sw.ericsson.se (c-83-233-76-66.cust.bredband2.com. [83.233.76.66]) by smtp.gmail.com with ESMTPSA id b7sm927770lfe.33.2017.01.19.07.55.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Jan 2017 07:55:02 -0800 (PST) From: Christophe Milard To: mike.holmes@linaro.org, bill.fischofer@linaro.org, yi.he@linaro.org, forrest.shi@linaro.org, maxim.uvarov@linaro.com, lng-odp@lists.linaro.org Date: Thu, 19 Jan 2017 17:54:20 +0100 Message-Id: <1484844861-1302-5-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1484844861-1302-1-git-send-email-christophe.milard@linaro.org> References: <1484844861-1302-1-git-send-email-christophe.milard@linaro.org> Subject: [lng-odp] [API-NEXT PATCHv10 4/5] test: preventing odp.conf loading for tests X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" The tests should not be affected by any system or user ODP configuration file. The ODP_SYSCONFIG_FILE environment variables is therefore set to "none" in TESTS_ENVIRONMENT. Tests which need specific a configuration file will have to overwrite this setting. Note that tests ran manually (not using make check) may be affected by configuration files. Setting ODP_SYSCONFIG_FILE to an appropriate value (possibly "none") may be required. Signed-off-by: Christophe Milard --- test/Makefile.inc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/test/Makefile.inc b/test/Makefile.inc index 1ebc047..896f863 100644 --- a/test/Makefile.inc +++ b/test/Makefile.inc @@ -22,4 +22,6 @@ AM_LDFLAGS += -L$(LIB) @VALGRIND_CHECK_RULES@ valgrind_tools = memcheck -TESTS_ENVIRONMENT= ODP_PLATFORM=${with_platform} EXEEXT=${EXEEXT} +TESTS_ENVIRONMENT = ODP_PLATFORM=${with_platform} \ + EXEEXT=${EXEEXT} \ + ODP_SYSCONFIG_FILE=none From patchwork Thu Jan 19 16:54:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 91967 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp332889obz; Thu, 19 Jan 2017 07:59:09 -0800 (PST) X-Received: by 10.55.141.133 with SMTP id p127mr8049655qkd.187.1484841548989; Thu, 19 Jan 2017 07:59:08 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id r8si2878696qte.59.2017.01.19.07.59.08; Thu, 19 Jan 2017 07:59:08 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 9E7E060D99; Thu, 19 Jan 2017 15:59:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 5CA1462C3F; Thu, 19 Jan 2017 15:55:32 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 5CB9660649; Thu, 19 Jan 2017 15:55:11 +0000 (UTC) Received: from mail-lf0-f53.google.com (mail-lf0-f53.google.com [209.85.215.53]) by lists.linaro.org (Postfix) with ESMTPS id 79B6260649 for ; Thu, 19 Jan 2017 15:55:05 +0000 (UTC) Received: by mail-lf0-f53.google.com with SMTP id n124so39678330lfd.2 for ; Thu, 19 Jan 2017 07:55:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=w8fdiWwrqu20lxlH3XSFVIuPtBTXIcfvYHoqX2KzrRg=; b=LbBsIKN65eq57wYrf3f3kCo9SkfFr3i8w7nXtmrnN3vuIqozyCL3v09W71mBfNGFc5 Y0GQbGu2UUL6zDyguBTZD5mdVB+eLWfqBBBk10KbS22bZkhDw2HaQags1DTMx0lUYQXl klpwfosuwipnzP4dKRTb/FQ8z9F0xBotiAA7IXNPVcd0MJ8Yd5O1B4npz8t5jLLElmRN HYDaOiupUZkiI5Lx/Kev+KzbpDnzx3YjNREBplHvgfPr3NWr7tVbRWohRMz22MQPBovm T6im0ZOyAxXOhanhZ2SySW2g6cdiMAMhhv1k/xmQN/26gj1ntzh9fgm7D8RN0gIeP9fE JVDA== X-Gm-Message-State: AIkVDXJ+5XTdJjNO7p3aVelkZmajh5+WkbGmWrSJbYKNnTPbLgZP3AeWkIVa4juDlrrRiVocWu4= X-Received: by 10.25.199.213 with SMTP id x204mr414023lff.122.1484841304273; Thu, 19 Jan 2017 07:55:04 -0800 (PST) Received: from erachmi-ericsson.ki.sw.ericsson.se (c-83-233-76-66.cust.bredband2.com. [83.233.76.66]) by smtp.gmail.com with ESMTPSA id b7sm927770lfe.33.2017.01.19.07.55.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Jan 2017 07:55:03 -0800 (PST) From: Christophe Milard To: mike.holmes@linaro.org, bill.fischofer@linaro.org, yi.he@linaro.org, forrest.shi@linaro.org, maxim.uvarov@linaro.com, lng-odp@lists.linaro.org Date: Thu, 19 Jan 2017 17:54:21 +0100 Message-Id: <1484844861-1302-6-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1484844861-1302-1-git-send-email-christophe.milard@linaro.org> References: <1484844861-1302-1-git-send-email-christophe.milard@linaro.org> Subject: [lng-odp] [API-NEXT PATCHv10 5/5] linux-gen: modules: adding initial file to load modules X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" The shared objects listed in the ODP configuration files are loaded at init time. The odp configuration file lists the shared objects to be loaded as shown in the following example: module = { modules = ["enumerator1.so", "driver1.so"]; }; Signed-off-by: Christophe Milard --- configure.ac | 4 +- platform/linux-generic/Makefile.am | 1 + platform/linux-generic/_modules.c | 53 +++++++++++++++++++++++++++ platform/linux-generic/include/odp_internal.h | 3 ++ platform/linux-generic/m4/configure.m4 | 1 + platform/linux-generic/m4/odp_modules.m4 | 11 ++++++ platform/linux-generic/odp_init.c | 7 ++++ 7 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 platform/linux-generic/_modules.c create mode 100644 platform/linux-generic/m4/odp_modules.m4 -- 2.7.4 diff --git a/configure.ac b/configure.ac index 3a20959..e2b4f9d 100644 --- a/configure.ac +++ b/configure.ac @@ -55,7 +55,7 @@ AC_PROG_MAKE_SET AM_PROG_AR #Use libtool -LT_INIT([]) +LT_INIT([dlopen]) AC_SUBST([LIBTOOL_DEPS]) AM_PROG_LIBTOOL @@ -66,7 +66,7 @@ AC_CHECK_FUNCS([bzero clock_gettime gethostbyname getpagesize gettimeofday memse # Checks for header files. AC_HEADER_RESOLV -AC_CHECK_HEADERS([arpa/inet.h fcntl.h inttypes.h limits.h netdb.h netinet/in.h stddef.h stdint.h stdlib.h string.h sys/ioctl.h sys/socket.h sys/time.h unistd.h]) +AC_CHECK_HEADERS([arpa/inet.h fcntl.h inttypes.h limits.h netdb.h netinet/in.h stddef.h stdint.h stdlib.h string.h sys/ioctl.h sys/socket.h sys/time.h unistd.h dlfcn.h]) # Checks for typedefs, structures, and compiler characteristics. AC_HEADER_STDBOOL diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index 2d92c97..855f04e 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -176,6 +176,7 @@ __LIB__libodp_linux_la_SOURCES = \ _ishm.c \ _ishmphy.c \ _ishmpool.c \ + _modules.c \ odp_atomic.c \ odp_barrier.c \ odp_bitmap.c \ diff --git a/platform/linux-generic/_modules.c b/platform/linux-generic/_modules.c new file mode 100644 index 0000000..6bb854e --- /dev/null +++ b/platform/linux-generic/_modules.c @@ -0,0 +1,53 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include + +#include +#include +#include +#include +#include + +static int load_modules(void) +{ + config_t *cf; + const config_setting_t *modules_section; + int module_count; + int i; + const char *module_name; + + cf = &odp_global_data.configuration; + modules_section = config_lookup(cf, "module.modules"); + if (!modules_section) + return 0; + + module_count = config_setting_length(modules_section); + if (!module_count) + return 0; + + for (i = 0; i < module_count; i++) { + module_name = config_setting_get_string_elem(modules_section, + i); + if (dlopen(module_name, RTLD_NOW) == NULL) { + ODP_ERR("dlopen failed for %s: %s\n", + module_name, dlerror()); + return -1; + } + ODP_DBG("module %s loaded.\n", module_name); + } + + return 0; +} + +int _odp_modules_init_global(void) +{ + /* load modules (enumerator and drivers...) */ + if (load_modules()) + return -1; + + return 0; +} diff --git a/platform/linux-generic/include/odp_internal.h b/platform/linux-generic/include/odp_internal.h index 9d1fc58..05c8a42 100644 --- a/platform/linux-generic/include/odp_internal.h +++ b/platform/linux-generic/include/odp_internal.h @@ -71,6 +71,7 @@ enum init_stage { CLASSIFICATION_INIT, TRAFFIC_MNGR_INIT, NAME_TABLE_INIT, + MODULES_INIT, ALL_INIT /* All init stages completed */ }; @@ -129,6 +130,8 @@ int _odp_ishm_init_local(void); int _odp_ishm_term_global(void); int _odp_ishm_term_local(void); +int _odp_modules_init_global(void); + int cpuinfo_parser(FILE *file, system_info_t *sysinfo); uint64_t odp_cpu_hz_current(int id); diff --git a/platform/linux-generic/m4/configure.m4 b/platform/linux-generic/m4/configure.m4 index 5fab0cc..f5f076a 100644 --- a/platform/linux-generic/m4/configure.m4 +++ b/platform/linux-generic/m4/configure.m4 @@ -42,6 +42,7 @@ fi m4_include([platform/linux-generic/m4/odp_pthread.m4]) m4_include([platform/linux-generic/m4/odp_openssl.m4]) m4_include([platform/linux-generic/m4/odp_pcap.m4]) +m4_include([platform/linux-generic/m4/odp_modules.m4]) m4_include([platform/linux-generic/m4/odp_netmap.m4]) m4_include([platform/linux-generic/m4/odp_dpdk.m4]) m4_include([platform/linux-generic/m4/odp_ipc.m4]) diff --git a/platform/linux-generic/m4/odp_modules.m4 b/platform/linux-generic/m4/odp_modules.m4 new file mode 100644 index 0000000..03f61f8 --- /dev/null +++ b/platform/linux-generic/m4/odp_modules.m4 @@ -0,0 +1,11 @@ +########################################################################## +# Check for dlopen and lt equivalent availability +########################################################################## + +AC_SEARCH_LIBS([dlopen], [dl dld], + [ + AM_LDFLAGS="$AM_LDFLAGS -ldl" + ], + [ + AC_MSG_ERROR([Error! dlopen not available!]) + ]) diff --git a/platform/linux-generic/odp_init.c b/platform/linux-generic/odp_init.c index 0e9167c..2cd8fe3 100644 --- a/platform/linux-generic/odp_init.c +++ b/platform/linux-generic/odp_init.c @@ -259,6 +259,12 @@ int odp_init_global(odp_instance_t *instance, ODP_ERR("ODP name table init failed\n"); goto init_failed; } + stage = NAME_TABLE_INIT; + + if (_odp_modules_init_global()) { + ODP_ERR("ODP modules init failed\n"); + goto init_failed; + } *instance = (odp_instance_t)odp_global_data.main_pid; @@ -284,6 +290,7 @@ int _odp_term_global(enum init_stage stage) switch (stage) { case ALL_INIT: + case MODULES_INIT: case NAME_TABLE_INIT: if (_odp_int_name_tbl_term_global()) { ODP_ERR("Name table term failed.\n");