From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f41.google.com (mail-pa0-f41.google.com [209.85.220.41]) by dpdk.org (Postfix) with ESMTP id 42F958022 for ; Wed, 29 Oct 2014 09:42:25 +0100 (CET) Received: by mail-pa0-f41.google.com with SMTP id rd3so2764370pab.0 for ; Wed, 29 Oct 2014 01:51:15 -0700 (PDT) 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; bh=wvhR1WRrbhalxdUwoQMhnQbl52N1iRG8BHASJ2WoGVQ=; b=KUyRiD7ZwcTo3suUY6l31YL3YRe4DYeS+aDXhGJV2h2RdcQdypFtblhJKbd5VK1r3L X2QE1U0H5miHkPyJJN+pRCjt0GpvRUlDmFBpkqRjLYX+HOimu5YvrqqNiHiSkVdgLAh3 KYWa9QyGwwpK4jFiQj7jXHUyqU7qOaNlcEJC0AgOeASqyQz8q7vKcydUCRh246Cd+DSs zMRVY+t/283m723fSh+2FWmMLRCcePAaFSG+Yi56EESlkFYAHCIfiPey0pJs/87W2eyP rZnNYEqlpaAzq1pDgXPNtrZv2Pnz2hbLYqqVScZ4P0G91o9NGIskQQEC5Gcl2YE0W6bA 1zEg== X-Gm-Message-State: ALoCoQkHk+JYsNdYhcWLumwOYo6ZMhMkWxwFatPlEic5/21Tm54EmnsAfY+ovJQ/fYpqZYhFeorz X-Received: by 10.66.161.197 with SMTP id xu5mr2299239pab.3.1414572675521; Wed, 29 Oct 2014 01:51:15 -0700 (PDT) Received: from eris.hq.igel.co.jp (napt.igel.co.jp. [219.106.231.132]) by mx.google.com with ESMTPSA id dk5sm3686505pbc.61.2014.10.29.01.51.13 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 29 Oct 2014 01:51:14 -0700 (PDT) From: Tetsuya Mukawa To: dev@dpdk.org Date: Wed, 29 Oct 2014 17:51:01 +0900 Message-Id: <1414572662-21408-1-git-send-email-mukawa@igel.co.jp> X-Mailer: git-send-email 1.9.1 Cc: nakajima.yoshihiro@lab.ntt.co.jp, masutani.hitoshi@lab.ntt.co.jp Subject: [dpdk-dev] [RFC PATCH 1/2] librte_pmd_pcap: Add support for port hotplug 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: , X-List-Received-Date: Wed, 29 Oct 2014 08:42:25 -0000 This patch adds finalization code to free resources allocated by the PMD. Signed-off-by: Tetsuya Mukawa --- lib/librte_pmd_pcap/rte_eth_pcap.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/lib/librte_pmd_pcap/rte_eth_pcap.c b/lib/librte_pmd_pcap/rte_eth_pcap.c index f12d1e7..90fc065 100644 --- a/lib/librte_pmd_pcap/rte_eth_pcap.c +++ b/lib/librte_pmd_pcap/rte_eth_pcap.c @@ -499,6 +499,13 @@ static struct eth_dev_ops ops = { .stats_reset = eth_stats_reset, }; +static struct eth_driver rte_pcap_pmd = { + .pci_drv = { + .name = "rte_pcap_pmd", + .drv_flags = RTE_PCI_DRV_DETACHABLE, + }, +}; + /* * Function handler that opens the pcap file for reading a stores a * reference of it for use it later on. @@ -743,6 +750,7 @@ rte_pmd_init_internals(const char *name, const unsigned nb_rx_queues, (*eth_dev)->data = data; (*eth_dev)->dev_ops = &ops; (*eth_dev)->pci_dev = pci_dev; + (*eth_dev)->driver = &rte_pcap_pmd; return 0; @@ -927,10 +935,33 @@ rte_pmd_pcap_devinit(const char *name, const char *params) } +static int +rte_pmd_pcap_devclose(const char *name, const char *params __rte_unused) +{ + struct rte_eth_dev *eth_dev = NULL; + + RTE_LOG(INFO, PMD, "Closing pcap ethdev on numa socket %u\n", + rte_socket_id()); + + /* reserve an ethdev entry */ + eth_dev = rte_eth_dev_allocated(name); + if (eth_dev == NULL) + return -1; + + rte_free(eth_dev->data->dev_private); + rte_free(eth_dev->data); + rte_free(eth_dev->pci_dev); + + rte_eth_dev_free(name); + + return 0; +} + static struct rte_driver pmd_pcap_drv = { .name = "eth_pcap", .type = PMD_VDEV, .init = rte_pmd_pcap_devinit, + .close = rte_pmd_pcap_devclose, }; PMD_REGISTER_DRIVER(pmd_pcap_drv); -- 1.9.1