From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f52.google.com (mail-wm0-f52.google.com [74.125.82.52]) by dpdk.org (Postfix) with ESMTP id 7D7032BB8 for ; Thu, 8 Jun 2017 01:53:44 +0200 (CEST) Received: by mail-wm0-f52.google.com with SMTP id x70so67280716wme.0 for ; Wed, 07 Jun 2017 16:53:44 -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=1AIZ6vTPPLEGtWxVGv8BvfJeSqRFXZtCpB9798PxdlI=; b=bvSrG8ZsMPW5u/rq4gDxlut+gRPME/N4o2q3wpkDtH5+AG2MoBW8DuLGYtViGiqF4j NWIXJJkk/ut+hFtLWiYSKSij3R5NZ4EGEW0+KqYub10o34pPpmIgR7LEDcAphMBjjwXQ KPMpOkdK3r6zmiNOwCH9AePd4QHctoyyQ0fJLbxoAlTpTzlPs7+9BB4RHxN2rfiYe1A+ Jnkp+t0tKDG+2GF+6YZ/Pgszg4M/9Kax2KqU0wOFsu70IVA8/APw2fPRu8RMBADZvZB4 AfoZfqwLXdQYXmUwp8gbLx33GpG6YBC8GRNknTSqNnbodUtL6IznGrkYq+A+uqzw/WYN lBXA== 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=1AIZ6vTPPLEGtWxVGv8BvfJeSqRFXZtCpB9798PxdlI=; b=gbh993J6pe/FFv8d3eSxPFXs+kOM6rH0E1mbTVcwJpswvw+nYxAq3qNlNrtctrgj1K AoWEb4g7fPI45IW7wHa2v8pFCCW7/jLK5dc9+sU8JK4Gyq9/dDj70fn0UrWmsLATeI/k AWDT8FWdBt0bsC/nUHVSBjeYNoZiOKQg+tuVe8j2RfpoS11E1RXZJqwc8BEwIsB6pTTl q9Rc0xAI8iTobwiLduSzJnr4vnmtZ4hMAq418f/v95nGXnM8zkDwsHPRCORdGkoHoHnE Exa5cqZPGwFnrTABzOVXIS4Sb6hxnLwIiul4pnli5H9RzQ1J2KG9hi6Lmr9PZPKjRJLF AJvw== X-Gm-Message-State: AODbwcBRV7un/AGmHQZyjcyMq9VhTXuAdRvSGMU01zNl8SYhZZIGisu+ kVIGt6vqS4gDabYUyww= X-Received: by 10.28.127.10 with SMTP id a10mr1448024wmd.36.1496879623942; Wed, 07 Jun 2017 16:53:43 -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 z23sm4589942wrz.0.2017.06.07.16.53.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Jun 2017 16:53:42 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Jan Blunck , Gaetan Rivet Date: Thu, 8 Jun 2017 01:53:19 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v3 05/10] 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: Wed, 07 Jun 2017 23:53:45 -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 451884f..381a0b6 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 eba407d..cb44e46 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