From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by dpdk.org (Postfix) with ESMTP id 36A387CAC for ; Thu, 29 Jun 2017 20:22:39 +0200 (CEST) Received: by mail-wm0-f67.google.com with SMTP id j85so4072376wmj.0 for ; Thu, 29 Jun 2017 11:22:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=491IGe1LuqQjciND7OvhbsocJM+2D2AN9dcTJkvgA28=; b=szMu80pA0mZX7RT9mVLOEpFKwRyIxcbROGkYmEUgKrJ9PWH9h2m+6rhgD1vRmGqp2Y JrlkriWdYuPEo0JgbOOSqmRMl5js0W3G2bxXa1TFyABShBf+HQO70OG/KctC+ax7apIY AMe6Rj0GVx+f9A333F6HxEWL+T9+oCGYz8YZLuDQHuzfbyRHcUuyERqjaet/SOgyk4rG YZmRBuWagnEIDKdVHLoVj7ZDP7EBNlSgLHUzvRRhWgcZHBxaWV6+I0SSvTKpspEFgV1q fvJKsopupIhMXnRwvB2PMxu2TS9fDMb4IAz5T83LgO0xxfkVbufdGBkBYU0JL0dSosuk bukg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=491IGe1LuqQjciND7OvhbsocJM+2D2AN9dcTJkvgA28=; b=Qtf6y+pilJhGp3XQflSs0+10SPLaoxGKfYZ5vfjdH9BpnpaGe/mSCES1AyF8XPI0g4 HEa+5aX15jjQ8Y7vrci38wBnNT+Una69oyi/B5X3aof/w+biKN9cJPC97Y6rMS1gaQAl MrUiEjfqK36gz6xWb3jJ/8Xp2rpk3QF43UuIdzRwd8dvpljja4yAgARL8PT3kOKT7iTr LsSnSoFhTN6yM4sA4H0YAX1gl2vDFmk8lDIvJOsKxHaRnt0caaUrV+/SwE3BJpUSZd5n wFqWf+o5juXoLdIsMvNPUIBWDizSrzW/cMERZOcyEokeUrLuGgq9S67BFgLgfa0PEGfG 0Lcw== X-Gm-Message-State: AKS2vOxqL8HW2gfN6nwxLAG/vy2nx635e3yJ/P2PQL9JkqcQ0bs+Nl/0 jbnaJPQCw+oBM/AX X-Received: by 10.80.170.74 with SMTP id p10mr2709599edc.33.1498760558568; Thu, 29 Jun 2017 11:22:38 -0700 (PDT) Received: from weierstrass.local ([91.200.110.13]) by smtp.gmail.com with ESMTPSA id e28sm1446366ede.14.2017.06.29.11.22.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Jun 2017 11:22:37 -0700 (PDT) Sender: Jan Blunck From: Jan Blunck To: dev@dpdk.org Cc: gaetan.rivet@6wind.com, shreyansh.jain@nxp.com Date: Thu, 29 Jun 2017 20:22:01 +0200 Message-Id: <20170629182206.1072-11-jblunck@infradead.org> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170629182206.1072-1-jblunck@infradead.org> References: <20170629182206.1072-1-jblunck@infradead.org> Subject: [dpdk-dev] [PATCH v7 10/15] bus: introduce device plug/unplug 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: Thu, 29 Jun 2017 18:22:39 -0000 This allows the buses to plug and probe specific devices. This is meant to be a building block for hotplug support. Signed-off-by: Jan Blunck --- lib/librte_eal/common/eal_common_bus.c | 2 ++ lib/librte_eal/common/include/rte_bus.h | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c index 418804a..22ff0f6 100644 --- a/lib/librte_eal/common/eal_common_bus.c +++ b/lib/librte_eal/common/eal_common_bus.c @@ -51,6 +51,8 @@ rte_bus_register(struct rte_bus *bus) RTE_VERIFY(bus->scan); RTE_VERIFY(bus->probe); RTE_VERIFY(bus->find_device); + /* Buses supporting driver plug 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 08f8d46..4b6c73b 100644 --- a/lib/librte_eal/common/include/rte_bus.h +++ b/lib/librte_eal/common/include/rte_bus.h @@ -108,6 +108,36 @@ typedef struct rte_device * const void *data); /** + * Implementation specific probe function which is responsible for linking + * devices on that bus with applicable drivers. + * + * @param dev + * Device pointer that was returned by a previous call to find_device. + * + * @param devargs + * 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 int (*rte_bus_plug_t)(struct rte_device *dev, + const char *devargs); + +/** + * 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 call to find_device. + * + * @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 { @@ -116,6 +146,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 a device on the bus */ + rte_bus_plug_t plug; /**< Probe single device for drivers */ + rte_bus_unplug_t unplug; /**< Remove single device from driver */ }; /** -- 2.9.4