From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f49.google.com (mail-pa0-f49.google.com [209.85.220.49]) by dpdk.org (Postfix) with ESMTP id 3D06D5AA9 for ; Fri, 30 Jan 2015 06:45:11 +0100 (CET) Received: by mail-pa0-f49.google.com with SMTP id fa1so48166091pad.8 for ; Thu, 29 Jan 2015 21:45:10 -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=XJM5rDny05Dc36O7xetnwinf9uWjXzEfVGc1MWvElLc=; b=TcB8jO6qWyppW0M/BTKjvx5Ah7NvRaLOy5zic5EzqLWe+RjBIXIN/ungFlH2mKGw+z kgHrqwTlEcAvpA5h1ZJ57ZJnQo5aRU+YdQzTsn0GJPDZcAwOYvap9C53PuHUOzEtbuW/ pksQQpG5e/kr0Nbev1i1t2gppJdm+Hknl8yvkxfhmK9pxxsaOciETi5iNU29DzxKOTOO RD+FUqIW3p7TxRudGdkwFstUNnkQ0J1lJAeMS9kPymWGfp4W0uPtolUx7ZlPO3BTMlD+ wjVEZ1hysskiSwov4OjP+faVZfwgQrkMYewaablX7iXl4PuzQrc4/GSKjMJ6uS566h87 KQ3w== X-Gm-Message-State: ALoCoQkEP7ANNOA3Z1oUiDs/yFqHRMcMEnEZmjxyyl8er83n6aMbmvZYOuxTlikGyK676ivDzPSO X-Received: by 10.66.162.41 with SMTP id xx9mr6593341pab.68.1422596710524; Thu, 29 Jan 2015 21:45:10 -0800 (PST) Received: from localhost.localdomain (napt.igel.co.jp. [219.106.231.132]) by mx.google.com with ESMTPSA id ki4sm9482266pdb.34.2015.01.29.21.45.08 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 29 Jan 2015 21:45:09 -0800 (PST) From: Tetsuya Mukawa To: dev@dpdk.org Date: Fri, 30 Jan 2015 14:42:42 +0900 Message-Id: <1422596563-26310-15-git-send-email-mukawa@igel.co.jp> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1422596563-26310-1-git-send-email-mukawa@igel.co.jp> References: <1421664027-17971-9-git-send-email-mukawa@igel.co.jp> <1422596563-26310-1-git-send-email-mukawa@igel.co.jp> Subject: [dpdk-dev] [PATCH v5] librte_pmd_pcap: Add port hotplug support 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: Fri, 30 Jan 2015 05:45:11 -0000 This patch adds finalization code to free resources allocated by the PMD. v4: - Change function name. Signed-off-by: Tetsuya Mukawa --- lib/librte_pmd_pcap/rte_eth_pcap.c | 40 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/lib/librte_pmd_pcap/rte_eth_pcap.c b/lib/librte_pmd_pcap/rte_eth_pcap.c index af7fae8..9263eab 100644 --- a/lib/librte_pmd_pcap/rte_eth_pcap.c +++ b/lib/librte_pmd_pcap/rte_eth_pcap.c @@ -498,6 +498,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. @@ -713,6 +720,10 @@ rte_pmd_init_internals(const char *name, const unsigned nb_rx_queues, if (*eth_dev == NULL) goto error; + /* check length of device name */ + if ((strlen((*eth_dev)->data->name) + 1) > sizeof(data->name)) + goto error; + /* now put it all together * - store queue data in internals, * - store numa_node info in pci_driver @@ -739,10 +750,13 @@ rte_pmd_init_internals(const char *name, const unsigned nb_rx_queues, data->nb_tx_queues = (uint16_t)nb_tx_queues; data->dev_link = pmd_link; data->mac_addrs = ð_addr; + strncpy(data->name, + (*eth_dev)->data->name, strlen((*eth_dev)->data->name)); (*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 +941,36 @@ rte_pmd_pcap_devinit(const char *name, const char *params) } +static int +rte_pmd_pcap_devuninit(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()); + + if (name == NULL) + return -1; + + /* 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, + .uninit = rte_pmd_pcap_devuninit, }; PMD_REGISTER_DRIVER(pmd_pcap_drv); -- 1.9.1