From patchwork Tue Jan 24 17:48:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 92374 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp1788704obz; Tue, 24 Jan 2017 08:49:44 -0800 (PST) X-Received: by 10.200.54.178 with SMTP id a47mr17256577qtc.132.1485276583949; Tue, 24 Jan 2017 08:49:43 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id x134si13563021qka.1.2017.01.24.08.49.43; Tue, 24 Jan 2017 08:49:43 -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 8864160820; Tue, 24 Jan 2017 16:49:43 +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 65E986085F; Tue, 24 Jan 2017 16:49:03 +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 E55B5608FF; Tue, 24 Jan 2017 16:48:55 +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 D5A30607B4 for ; Tue, 24 Jan 2017 16:48:51 +0000 (UTC) Received: by mail-lf0-f53.google.com with SMTP id x1so27765647lff.0 for ; Tue, 24 Jan 2017 08:48:51 -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=SLr/FffZncAMgmiue6k6Vz6pov68xCfXfo3Zc0OUlreqPZYcN97hyitJJFireFH9+X uw3k5/36FsqaURVinzNqrO3NcRCg8cFD46B01BPdexCsSKStAqoswF1pYIu7vWlNIQ54 y5FheCImcjoumZ9LLLSzY3HQmmFOahykC+5+OVMUXt4MsxKDE7c45Zf18cKnhF6zvuL0 CJvDJH2197yIQNwYSGUbhRhj3sVnowpAOj8/uJUlb9LAsSJv3NvPhHBJbdZvsOhs+VXy sKdLw8JpJgCJ6mr8rdQ4t9ce8T/QWpCbNjBOqo0uBe0IDYDYcD4LGJI6fLbBl5uPzsUx uZhw== X-Gm-Message-State: AIkVDXIxxFwNHy11Q4cn68ZqxKBJeIokD9SZh1UweRZbJBweJC7tRYI5JvCutLwyu7LIicbrwTw= X-Received: by 10.25.135.130 with SMTP id j124mr11405333lfd.11.1485276530360; Tue, 24 Jan 2017 08:48:50 -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 y10sm7605276lja.22.2017.01.24.08.48.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 24 Jan 2017 08:48:49 -0800 (PST) From: Christophe Milard To: mike.holmes@linaro.org, yi.he@linaro.org, maxim.uvarov@linaro.com, lng-odp@lists.linaro.org Date: Tue, 24 Jan 2017 18:48:02 +0100 Message-Id: <1485280086-3958-2-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1485280086-3958-1-git-send-email-christophe.milard@linaro.org> References: <1485280086-3958-1-git-send-email-christophe.milard@linaro.org> Subject: [lng-odp] [API-NEXT PATCHv11 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 Tue Jan 24 17:48:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 92375 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp1789139obz; Tue, 24 Jan 2017 08:50:48 -0800 (PST) X-Received: by 10.55.86.70 with SMTP id k67mr32153713qkb.280.1485276648359; Tue, 24 Jan 2017 08:50:48 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id o38si13516045qkh.312.2017.01.24.08.50.48; Tue, 24 Jan 2017 08:50:48 -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 E9EF860913; Tue, 24 Jan 2017 16:50: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 D4DF660F1E; Tue, 24 Jan 2017 16:49:07 +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 45DC4608FF; Tue, 24 Jan 2017 16:48:57 +0000 (UTC) Received: from mail-lf0-f49.google.com (mail-lf0-f49.google.com [209.85.215.49]) by lists.linaro.org (Postfix) with ESMTPS id 2CD3A6075E for ; Tue, 24 Jan 2017 16:48:53 +0000 (UTC) Received: by mail-lf0-f49.google.com with SMTP id z134so114451233lff.3 for ; Tue, 24 Jan 2017 08:48:53 -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=aHMxVVAKrxztcVIjxi6Vj9LnAZOmYMmPVb+IMhLMYW4=; b=f1hCVy16F0nlXOYRCEbh3QbPyP67QS/2UVbkR+1pFR/905fkFMXAl1FxobkHiKSWl3 LFiZy9ExNsw4cXwI4CkSFPGeIw5dgs9Xhzyik2tiAsgIzBHnZkltdhX2Fqb9xrOvS9BG 2suMOH0cfhltBLxUx4Qf4tCWvrWNZX5u5QAJ8y7QIp1BgDN2YAlLklBdMy26wv5hdeIB /pIZHF2sJefDhOoaOtzoVlTWeoYPwafHh/t1TIUn4nwJxlt+zh6zpId32IW5jd4gUwx9 mQPwt9oRBzX73ER4oYd/9Y2/sJtwhO4rxW+V8HId+YoDdA5Cn3fJ7T6BvveaYw4D/qU3 vCsw== X-Gm-Message-State: AIkVDXKfmlHpjKNY+bdWP4LFbiv/H8E6EowWxVK61BfxO4xw/32KMqQTb2vB0iifMElSvKNtkLQ= X-Received: by 10.25.216.3 with SMTP id p3mr11268109lfg.16.1485276531537; Tue, 24 Jan 2017 08:48:51 -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 y10sm7605276lja.22.2017.01.24.08.48.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 24 Jan 2017 08:48:50 -0800 (PST) From: Christophe Milard To: mike.holmes@linaro.org, yi.he@linaro.org, maxim.uvarov@linaro.com, lng-odp@lists.linaro.org Date: Tue, 24 Jan 2017 18:48:03 +0100 Message-Id: <1485280086-3958-3-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1485280086-3958-1-git-send-email-christophe.milard@linaro.org> References: <1485280086-3958-1-git-send-email-christophe.milard@linaro.org> Subject: [lng-odp] [API-NEXT PATCHv11 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 | 3 + 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, 157 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..2d97414 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 \ @@ -119,6 +120,7 @@ odpdrvplatinclude_HEADERS = \ $(srcdir)/include/odp/drv/plat/atomic_types.h \ $(srcdir)/include/odp/drv/plat/barrier_types.h \ $(srcdir)/include/odp/drv/plat/byteorder_types.h \ + $(srcdir)/include/odp/drv/plat/driver_types.h \ $(srcdir)/include/odp/drv/plat/shm_types.h \ $(srcdir)/include/odp/drv/plat/spinlock_types.h \ $(srcdir)/include/odp/drv/plat/strong_types.h @@ -233,6 +235,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 Tue Jan 24 17:48:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 92376 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp1789485obz; Tue, 24 Jan 2017 08:51:38 -0800 (PST) X-Received: by 10.55.11.13 with SMTP id 13mr32729025qkl.201.1485276698179; Tue, 24 Jan 2017 08:51:38 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id b132si13534520qka.270.2017.01.24.08.51.37; Tue, 24 Jan 2017 08:51:38 -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 CC97461063; Tue, 24 Jan 2017 16:51:37 +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 2BD1762D83; Tue, 24 Jan 2017 16:49:11 +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 8273B6085F; Tue, 24 Jan 2017 16:48:58 +0000 (UTC) Received: from mail-lf0-f43.google.com (mail-lf0-f43.google.com [209.85.215.43]) by lists.linaro.org (Postfix) with ESMTPS id DF684607F9 for ; Tue, 24 Jan 2017 16:48:53 +0000 (UTC) Received: by mail-lf0-f43.google.com with SMTP id x1so27766131lff.0 for ; Tue, 24 Jan 2017 08:48:53 -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=qxtX4n7Ath3aNeULDBA2ITIWeQYyTL/2752bItmFR8U=; b=q8KxoBY6A3BWp5R8FXLvmA/A4pLV8N45SKh0H/sCJQcVRdaZnY4CWNVc5bKnyUT9Pj 0HVHmBnagv7lkAJo6U8HmkA828Zg5rljlfi4BhiBvIJXaRuKmfMe2EVCljCkZXGw+qzc wMqEEZc4MJKwoRXOWFkB7NpBQ67+qKyG+g7DKeEZt6q6P96Wg0WqwNMv7o0xpw8+303D o4hnjU6xHFli0AZu0oK8Bndd0Ru2X4NB0wJK22qFc/1accSs6nySXqRxE4wGsHdEviiL rRGwanJMZ1BTpbsM5ZnB7rYEIcLTXNGsy9IPUx39y/E/wWL4AfNcffX0G71jA0GGo3DQ d+JQ== X-Gm-Message-State: AIkVDXIghODiGZgihH2uTL0D08aY98VGSudAUJ4Erlq/fMGp3iq0afAywwNiB4DHPEU39Q+8aZI= X-Received: by 10.25.163.130 with SMTP id m124mr6544771lfe.19.1485276532584; Tue, 24 Jan 2017 08:48:52 -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 y10sm7605276lja.22.2017.01.24.08.48.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 24 Jan 2017 08:48:52 -0800 (PST) From: Christophe Milard To: mike.holmes@linaro.org, yi.he@linaro.org, maxim.uvarov@linaro.com, lng-odp@lists.linaro.org Date: Tue, 24 Jan 2017 18:48:04 +0100 Message-Id: <1485280086-3958-4-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1485280086-3958-1-git-send-email-christophe.milard@linaro.org> References: <1485280086-3958-1-git-send-email-christophe.milard@linaro.org> Subject: [lng-odp] [API-NEXT PATCHv11 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 2d97414..579fc3c 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 Tue Jan 24 17:48:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 92377 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp1789996obz; Tue, 24 Jan 2017 08:52:47 -0800 (PST) X-Received: by 10.55.221.5 with SMTP id n5mr29360241qki.58.1485276767802; Tue, 24 Jan 2017 08:52:47 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id z59si13560573qtd.75.2017.01.24.08.52.47; Tue, 24 Jan 2017 08:52: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 4B20A60F1E; Tue, 24 Jan 2017 16:52: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=-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 D6F3462D8A; Tue, 24 Jan 2017 16:49: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 AD4F362D87; Tue, 24 Jan 2017 16:49:14 +0000 (UTC) Received: from mail-lf0-f51.google.com (mail-lf0-f51.google.com [209.85.215.51]) by lists.linaro.org (Postfix) with ESMTPS id E8F826082B for ; Tue, 24 Jan 2017 16:48:54 +0000 (UTC) Received: by mail-lf0-f51.google.com with SMTP id x1so27766398lff.0 for ; Tue, 24 Jan 2017 08:48:54 -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=HTrcaFY49E0spMigcfP3uZlg+NdjIkJw+xfmiJffkTfnxN9Wo/rUfHs2q+vjtwmh1v QlA6f4APPWjq+dP6QSdKp9uCH14LK1xyhzIrkbSzs1i9XxulhBffEEj4npKxtzZ/B8I2 yCOi61fClPEzOt5264WwM78uBSyJsZVGlOcIwMATk9Jmsrq0l9lhl8KaM102foQrbhCp /bR+t1Z0yyQKhke8mT+4I5ah+XmMPDHIFsht+6S+g2Tu4tDaY+LMOuvzTozBQWROH+7j 1QhMGWlECcgMdiLT1P0BPEO/APQuc+CcpyG3c5Lp0mKgjsIr45NNJjh0cKUz9wLPITnk k7fw== X-Gm-Message-State: AIkVDXLQMIqI6OV97Pqvx6qxQY6yByhMnz9JMB0y5ClL/OPNgiJEd3Hkn3MyYfDb/+RtVhGBhU8= X-Received: by 10.25.104.20 with SMTP id d20mr11496224lfc.108.1485276533699; Tue, 24 Jan 2017 08:48:53 -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 y10sm7605276lja.22.2017.01.24.08.48.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 24 Jan 2017 08:48:53 -0800 (PST) From: Christophe Milard To: mike.holmes@linaro.org, yi.he@linaro.org, maxim.uvarov@linaro.com, lng-odp@lists.linaro.org Date: Tue, 24 Jan 2017 18:48:05 +0100 Message-Id: <1485280086-3958-5-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1485280086-3958-1-git-send-email-christophe.milard@linaro.org> References: <1485280086-3958-1-git-send-email-christophe.milard@linaro.org> Subject: [lng-odp] [API-NEXT PATCHv11 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 Tue Jan 24 17:48:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 92378 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp1790209obz; Tue, 24 Jan 2017 08:53:14 -0800 (PST) X-Received: by 10.200.35.105 with SMTP id b38mr28555300qtb.1.1485276793927; Tue, 24 Jan 2017 08:53:13 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 21si13552647qki.181.2017.01.24.08.53.13; Tue, 24 Jan 2017 08:53:13 -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 8AB0C6081B; Tue, 24 Jan 2017 16:53:13 +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 58C0960820; Tue, 24 Jan 2017 16:49:48 +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 3E09F60820; Tue, 24 Jan 2017 16:49:40 +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 404C5607B4 for ; Tue, 24 Jan 2017 16:48:56 +0000 (UTC) Received: by mail-lf0-f44.google.com with SMTP id v186so114496408lfa.1 for ; Tue, 24 Jan 2017 08:48:56 -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=G97f5gfkVkiO9vCXHIqNYpWOcoCE/OaFtBvl/mN8CQ4=; b=j4TYVswA5KNGdgHx+DhEPqeOqKPXforFcegV15Lu6bH62x6v/NnnfgeeyEJsyYKQ1O 5QgLQ3b8veg+JREcMUNkWPsc53b3FTKDRIC4qqazfpFTDpgk1qaCttmx5XaNlESR7xKN +Im9lt+hAHfeByhEgzKuch6v8S6i6KQUpTiwA5QavXRR3GStvmy/mQJFTWiNB8WZCe0g LXUyu9ykUx/jrbC8AoXLoYFx3iDOfI19DvV0wJ549nhL0xVCJHbVvH1sFgVjHPuqMDv5 dhqAzDtkzcqO+rgaU8OK0sKjnk95SxSljkAcb5RUmRJjru2it8LXZUClXyNmRJ6RYMK4 MZvA== X-Gm-Message-State: AIkVDXIQjJogup9jri5P2y+NJWITbZ97pE5vaM5yb3+YB7QyBE5Awmx13KLsDqDQOx3cBmhaLOU= X-Received: by 10.25.206.145 with SMTP id e139mr11939094lfg.168.1485276534862; Tue, 24 Jan 2017 08:48:54 -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 y10sm7605276lja.22.2017.01.24.08.48.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 24 Jan 2017 08:48:54 -0800 (PST) From: Christophe Milard To: mike.holmes@linaro.org, yi.he@linaro.org, maxim.uvarov@linaro.com, lng-odp@lists.linaro.org Date: Tue, 24 Jan 2017 18:48:06 +0100 Message-Id: <1485280086-3958-6-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1485280086-3958-1-git-send-email-christophe.milard@linaro.org> References: <1485280086-3958-1-git-send-email-christophe.milard@linaro.org> Subject: [lng-odp] [API-NEXT PATCHv11 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 579fc3c..f4ef497 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -177,6 +177,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");