From patchwork Tue Dec 9 06:30:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tetsuya Mukawa X-Patchwork-Id: 1861 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 42C6B8077; Tue, 9 Dec 2014 07:30:59 +0100 (CET) Received: from mail-pa0-f43.google.com (mail-pa0-f43.google.com [209.85.220.43]) by dpdk.org (Postfix) with ESMTP id 77E8C8053 for ; Tue, 9 Dec 2014 07:30:55 +0100 (CET) Received: by mail-pa0-f43.google.com with SMTP id kx10so6821374pab.2 for ; Mon, 08 Dec 2014 22:30:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=SkrUM1Hbwasz6qBV9Nv2O4nbYvXwBnpfkH/e6WciXXI=; b=WGPSq166NipAZvQv8zo422U8cuq3hAHX281fxvC9DFJuQgGsZbi/Klh9n0btuEawkV 8NMiJAkokNuDylVWxUnz7YTpB0+LTUNZ5t+mh0fq/W7bbKZk1HUMv/x6I2B1YMHyp1wC oPF5TEvITep5lcZ5fVrT9k7+vgADMeFgV/FL5G3bHOmtPwULUlHKbI1EOMY7024K+K4p DOJ/LMDO0luj9TLoUUdZkQU5FJ2j5hVG68Qu4s00+1U0fA0W8Q681Ep1HGToVW+z4rI/ AC0OvxFWmyGgc2Ric31HWefIJfgewNPOGZwt+SaROrP3JOdFmcJmZLJQbNkbNP0uLt8u TaEg== X-Gm-Message-State: ALoCoQkjqCbyp/T+mfV+VI3zGe9+ZH/FlG7Xa0eJKVOroKNCdtW5OfCHOSWtgATZxhLRLZNd7r78 X-Received: by 10.70.91.176 with SMTP id cf16mr27612178pdb.100.1418106654706; Mon, 08 Dec 2014 22:30:54 -0800 (PST) Received: from eris.hq.igel.co.jp (napt.igel.co.jp. [219.106.231.132]) by mx.google.com with ESMTPSA id f12sm403088pat.43.2014.12.08.22.30.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 08 Dec 2014 22:30:54 -0800 (PST) From: Tetsuya Mukawa To: dev@dpdk.org Date: Tue, 9 Dec 2014 15:30:06 +0900 Message-Id: <1418106629-22227-6-git-send-email-mukawa@igel.co.jp> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1418106629-22227-1-git-send-email-mukawa@igel.co.jp> References: <1416474399-16851-1-git-send-email-mukawa@igel.co.jp> <1418106629-22227-1-git-send-email-mukawa@igel.co.jp> Cc: nakajima.yoshihiro@lab.ntt.co.jp, menrigh@brocade.com, masutani.hitoshi@lab.ntt.co.jp Subject: [dpdk-dev] [PATCH v3 05/28] eal, ethdev: Add function pointer for closing a device X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The patch adds function pointer to rte_pci_driver and eth_driver structure. These function pointers are used when ports are detached. Signed-off-by: Tetsuya Mukawa --- lib/librte_eal/common/include/rte_pci.h | 7 +++++++ lib/librte_ether/rte_ethdev.h | 24 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h index fe374a8..74720d1 100644 --- a/lib/librte_eal/common/include/rte_pci.h +++ b/lib/librte_eal/common/include/rte_pci.h @@ -181,12 +181,19 @@ struct rte_pci_driver; typedef int (pci_devinit_t)(struct rte_pci_driver *, struct rte_pci_device *); /** + * Shutdown function for the driver called during hotplugging. + */ +typedef int (pci_devshutdown_t)( + struct rte_pci_driver *, struct rte_pci_device *); + +/** * A structure describing a PCI driver. */ struct rte_pci_driver { TAILQ_ENTRY(rte_pci_driver) next; /**< Next in list. */ const char *name; /**< Driver name. */ pci_devinit_t *devinit; /**< Device init. function. */ + pci_devshutdown_t *devshutdown; /**< Device shutdown function. */ struct rte_pci_id *id_table; /**< ID table, NULL terminated. */ uint32_t drv_flags; /**< Flags contolling handling of device. */ }; diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index fb1caea..b329e11 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -1702,6 +1702,27 @@ typedef int (*eth_dev_init_t)(struct eth_driver *eth_drv, /** * @internal + * Finalization function of an Ethernet driver invoked for each matching + * Ethernet PCI device detected during the PCI closing phase. + * + * @param eth_drv + * The pointer to the [matching] Ethernet driver structure supplied by + * the PMD when it registered itself. + * @param eth_dev + * The *eth_dev* pointer is the address of the *rte_eth_dev* structure + * associated with the matching device and which have been [automatically] + * allocated in the *rte_eth_devices* array. + * @return + * - 0: Success, the device is properly finalized by the driver. + * In particular, the driver MUST free the *dev_ops* pointer + * of the *eth_dev* structure. + * - <0: Error code of the device initialization failure. + */ +typedef int (*eth_dev_shutdown_t)(struct eth_driver *eth_drv, + struct rte_eth_dev *eth_dev); + +/** + * @internal * The structure associated with a PMD Ethernet driver. * * Each Ethernet driver acts as a PCI driver and is represented by a generic @@ -1711,11 +1732,14 @@ typedef int (*eth_dev_init_t)(struct eth_driver *eth_drv, * * - The *eth_dev_init* function invoked for each matching PCI device. * + * - The *eth_dev_shutdown* function invoked for each matching PCI device. + * * - The size of the private data to allocate for each matching device. */ struct eth_driver { struct rte_pci_driver pci_drv; /**< The PMD is also a PCI driver. */ eth_dev_init_t eth_dev_init; /**< Device init function. */ + eth_dev_shutdown_t eth_dev_shutdown;/**< Device shutdown function. */ unsigned int dev_private_size; /**< Size of device private data. */ };