From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pd0-f169.google.com (mail-pd0-f169.google.com [209.85.192.169]) by dpdk.org (Postfix) with ESMTP id 1D662B54C for ; Thu, 19 Feb 2015 03:50:41 +0100 (CET) Received: by pdbfl12 with SMTP id fl12so5636256pdb.4 for ; Wed, 18 Feb 2015 18:50:40 -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=n6icZ14qOdsxykUtZqYjwVukXjd0YyDenh1KFT8/V8E=; b=MgumBQFs1Ph2rPwj0PMbjOkPqG2bCIguAovd5lZzKz3JU3Yb8LnmO8bl2iY3jT5U0Q Z1k2Dc84Hp6a59CTC1PNGNMmcUak4LbLcRtH9TwK6zD5UhZIT7TRs0TiYITJLn2+6csW rgKbEXPDztf/Mu6wfY70DSItTErelRJFXxZoK2N83Ts3D3kPZN2R1LwNeqpnWTwTmANL xPZnjyZRLOfPmsibPVJEMGCxd6zr69/by8CBa4YJqVXwyeyb8RlDXqvyFYfZgR+AVK64 Jgny8x5wxYy1zu9IbhTmegh5gMvZH6seFBiwIcBN2xLSHO7nr330Z9nvdVdzrJz71SlZ wH5w== X-Gm-Message-State: ALoCoQlikKGN5zOKecXOvro3siSNIouNYhK2sjBy65cFP6Izj9eIS9pBIBk3QP6J47KK9IpSx67w X-Received: by 10.70.28.130 with SMTP id b2mr4074175pdh.48.1424314240542; Wed, 18 Feb 2015 18:50:40 -0800 (PST) Received: from localhost.localdomain (napt.igel.co.jp. [219.106.231.132]) by mx.google.com with ESMTPSA id iy1sm17860786pbb.14.2015.02.18.18.50.38 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 18 Feb 2015 18:50:39 -0800 (PST) From: Tetsuya Mukawa To: dev@dpdk.org Date: Thu, 19 Feb 2015 11:49:46 +0900 Message-Id: <1424314187-25177-16-git-send-email-mukawa@igel.co.jp> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1424314187-25177-1-git-send-email-mukawa@igel.co.jp> References: <1424060073-23484-12-git-send-email-mukawa@igel.co.jp> <1424314187-25177-1-git-send-email-mukawa@igel.co.jp> Subject: [dpdk-dev] [PATCH v9] 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: Thu, 19 Feb 2015 02:50:42 -0000 This patch adds finalization code to free resources allocated by the PMD. v6: - Fix a paramter of rte_eth_dev_free(). 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..5e94930 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) +{ + 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_release_port(eth_dev); + + 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