From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f181.google.com (mail-wr0-f181.google.com [209.85.128.181]) by dpdk.org (Postfix) with ESMTP id 5A1EC9E3 for ; Wed, 21 Jun 2017 01:29:52 +0200 (CEST) Received: by mail-wr0-f181.google.com with SMTP id y25so72185202wrd.2 for ; Tue, 20 Jun 2017 16:29:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=DlRLtpAxzGpG/csTve9KdvlDhpok30X/aiTuPEftDWA=; b=G736F9Z6i26xgUk5uqKDpYtUWI9LMsO3Lg2XqY8/h6lixVlrb+e+dZ5VrRSV0rJg1Q PI+b89IOzD/SatfTMsP+1Q9fTR1IsyjOar130fJSgXw8U4BEfr1rXk2AQcLp+JiSrhvA xShxPFwuPffOJVtKMbPXPSY9AWDQQdyCK+O+jMFHjDOd2pITVI1+GS8Qun38428WMy61 3AlvGMY80wMgEy0VkFe7RdPdZfXgiB57qEDzCQ2AvDBRExvuGOXc5LvpZEMqN+UaYzhQ +6x+OTznNIZ1nJh88GWGfRADBNxIeIfcJ5Elrx29n4EJtTgalwREFZRN7Y+OkKx00Ftu M5kQ== 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:in-reply-to:references; bh=DlRLtpAxzGpG/csTve9KdvlDhpok30X/aiTuPEftDWA=; b=OqROh1XrjIVu1Xqof5q3QCTA9lbB1xJ0W18T73b1pcUCryBaFm15aDglaxcdOHAZoD z6DPTgxGZLFj0tPi6TwjTv5/qcUv3AGrIhGbymQ6GDh2gTKEUNXT7hHJqR84gG2zVnpZ IgGGfyW4w6ZDZCCtp7MlHQb8L9okcFo1YbEdFj3rzfDo7wmqa/xr4pFYhLyB0cXVB386 sawdltcg2hRRlfFtYNF7Mxm/5ST2ZWocK6QUGShAcJPkjIejtTNvV9sLSSQD7BfTA3D2 fK8fsWwZn26IVKif22IpRaR3ubyL36DZSSnyESxZPTKW94xiz6F6vzfa9ujAU1RhfgXd re9g== X-Gm-Message-State: AKS2vOwsEFoV7VjKdoQP2LdCTLZFTOvUE2eJIBLbWkf6oCZ35CGCU4rm 1zFlNmaa2QerfN863Xc= X-Received: by 10.223.162.208 with SMTP id t16mr5956982wra.151.1498001391770; Tue, 20 Jun 2017 16:29:51 -0700 (PDT) Received: from bidouze.dev.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id l127sm8592248wml.26.2017.06.20.16.29.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 20 Jun 2017 16:29:50 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Jan Blunck , Gaetan Rivet Date: Wed, 21 Jun 2017 01:29:26 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v4 5/9] bus: introduce hotplug functionality X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Jun 2017 23:29:52 -0000 From: Jan Blunck Signed-off-by: Jan Blunck Signed-off-by: Gaetan Rivet --- lib/librte_eal/common/eal_common_bus.c | 2 ++ lib/librte_eal/common/include/rte_bus.h | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c index 9d84727..b6bf57e 100644 --- a/lib/librte_eal/common/eal_common_bus.c +++ b/lib/librte_eal/common/eal_common_bus.c @@ -50,6 +50,8 @@ rte_bus_register(struct rte_bus *bus) /* A bus should mandatorily have the scan implemented */ RTE_VERIFY(bus->scan); RTE_VERIFY(bus->probe); + /* Buses supporting hotplug also require unplug. */ + RTE_VERIFY(!bus->plug || bus->unplug); TAILQ_INSERT_TAIL(&rte_bus_list, bus, next); RTE_LOG(DEBUG, EAL, "Registered [%s] bus.\n", bus->name); diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h index e078c00..fcc2442 100644 --- a/lib/librte_eal/common/include/rte_bus.h +++ b/lib/librte_eal/common/include/rte_bus.h @@ -88,6 +88,35 @@ typedef struct rte_device * (*rte_bus_find_device_t)(rte_dev_cmp_t match, const void *data); /** + * Implementation specific probe function which is responsible for linking + * devices on that bus with applicable drivers. + * The plugged device might already have been used previously by the bus, + * in which case some buses might prefer to detect and re-use the relevant + * information pertaining to this device. + * + * @param da + * Device declaration. + * + * @return + * The pointer to a valid rte_device usable by the bus on success. + * NULL on error. rte_errno is then set. + */ +typedef struct rte_device * (*rte_bus_plug_t)(struct rte_devargs *da); + +/** + * Implementation specific remove function which is responsible for unlinking + * devices on that bus from assigned driver. + * + * @param dev + * Device pointer that was returned by a previous device plug call. + * + * @return + * 0 on success. + * !0 on error. rte_errno is then set. + */ +typedef int (*rte_bus_unplug_t)(struct rte_device *dev); + +/** * A structure describing a generic bus. */ struct rte_bus { @@ -96,6 +125,8 @@ struct rte_bus { rte_bus_scan_t scan; /**< Scan for devices attached to bus */ rte_bus_probe_t probe; /**< Probe devices on bus */ rte_bus_find_device_t find_device; /**< Find device on bus */ + rte_bus_plug_t plug; /**< Probe single device for drivers */ + rte_bus_unplug_t unplug; /**< Remove single device from driver */ }; /** -- 2.1.4