From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by dpdk.org (Postfix) with ESMTP id EEF735A6E for ; Fri, 30 Jun 2017 20:20:11 +0200 (CEST) Received: by mail-wm0-f66.google.com with SMTP id y5so9305751wmh.3 for ; Fri, 30 Jun 2017 11:20:11 -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=yodIIty+M/RonPTEz1sl5BfgGTY3MD2HP3XWVQs663w=; b=CepZVZ1TJjIzAEDGPGGy0Q9L/UjTX/mcOV6drOO5YvqsbS+ja8fjlVlaSN4GYn8k4V 8aWUNBp9ZQjP6seTVpDvEma0bwTRkXinJDOUH2pHcmt+0NElnzWWQg17f6lc4DxZIolz OiUN5+YRBkb2XaeVOZJxwcx2hsYyfvWeFB0U5KvO4//9UYeFqhKryVAdVX5D1suZ05jA f7LbT1fLaF6W48He/dr7QbCt3pdpNhDLY3U+1oDXvl0Imh33R6ur4Q1JS3I66EZKutGP 3YZiw9gX0fSNCRzhjogRsVs1bUlTcHRi0f+DrSJa5MhycY/vRwBfX5y3O4aNpFXJ/4nY CCbw== 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=yodIIty+M/RonPTEz1sl5BfgGTY3MD2HP3XWVQs663w=; b=cQZHgBaRAnUrd5HeWaX5L5xfQxlFWv6N+iPdmV7KT+PhAfnYfhEvFOMAB25wq4v02u r/yd+gVobeZ16vokQAbADw1+dVdFTgM5ghnnaQ+m1N8wnf4FCsxiyTXOuDtu3PzbPkV3 XI8wTl8C1aV7X6T/GwI8eiHwilGCbIvwMR55bsYSu083fpF6vzSZKlKz1hlJ+Z0qvHqH h6RutPCzEV2mZ9ou+PIyLqmNJkNQIK/FFKHffPGBFbM2vKNAS4IypX4HsHRgtX+uYVmt dTg2W9Fc/dmvu9ez44ra05AaLjUArGyVLEXfP+6HTEhhT5bxqoTIA6dItNqIixmMzDSe g4yg== X-Gm-Message-State: AKS2vOzA1hRj3oek+IAgorDOcmG0gEh9w+xomlk+hZjWze9Pbu3yyufD XZKljcgz9lm9VzE1 X-Received: by 10.80.159.165 with SMTP id c34mr6383323edf.11.1498846811578; Fri, 30 Jun 2017 11:20:11 -0700 (PDT) Received: from weierstrass.local ([91.200.110.13]) by smtp.gmail.com with ESMTPSA id r28sm2826940edd.33.2017.06.30.11.20.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Jun 2017 11:20:10 -0700 (PDT) Sender: Jan Blunck From: Jan Blunck To: dev@dpdk.org Cc: gaetan.rivet@6wind.com, shreyansh.jain@nxp.com Date: Fri, 30 Jun 2017 20:19:38 +0200 Message-Id: <20170630181943.23929-10-jblunck@infradead.org> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170630181943.23929-1-jblunck@infradead.org> References: <20170629182206.1072-1-jblunck@infradead.org> <20170630181943.23929-1-jblunck@infradead.org> Subject: [dpdk-dev] [PATCH v8 09/14] 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: Fri, 30 Jun 2017 18:20:12 -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 bf2b138..87b0c6e 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 509292d..34ea9d5 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