From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk0-f182.google.com (mail-qk0-f182.google.com [209.85.220.182]) by dpdk.org (Postfix) with ESMTP id 5295EB38D for ; Thu, 11 Jun 2015 00:06:26 +0200 (CEST) Received: by qkx62 with SMTP id 62so32023716qkx.3 for ; Wed, 10 Jun 2015 15:06:25 -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:in-reply-to :references; bh=x3yakIriuvrs+Th3CeL1j8f9GBvNVr0at3FcqT7qYXI=; b=EqZRGx9ZZncF1RxN2d2bVEsV6VPrygljlFlf/Wj53QTWXX8DJvABp7U3djJc+QRHj5 a0aheX5x/drwYcQHBS31IMgZVUiz7ac44fjKyJRfI15fgJPIONHYGCj+JN6AhAh/37mE N0ETlyoyjzi3pzDFEfJPFA+wDbm6EtTbma5W4kcTwrHv1ELwmtC46RyrbYXb7as4nP0t +bhFg7OFAOZNxhQqILagZ2OUETsylnjHI7eTp+iS+uej5tSbstiCDXJDq4LFsE7G+EPC kLG3aMPgOIpEZcHwODPG7RlCc0ncgl3AOVnoBgXWyxQ/11bvoUh3To6K+ArlyI9LJgUa thrg== X-Gm-Message-State: ALoCoQnI9/ZET5BMOtu7yzYg4FOlexttZwvLSc+XY+9X9RVwF5gGDLeH3Pfl2uQC/p4d0nWHRbMe X-Received: by 10.140.85.137 with SMTP id n9mr6885644qgd.67.1433973985656; Wed, 10 Jun 2015 15:06:25 -0700 (PDT) Received: from urahara.home.lan (static-50-53-82-155.bvtn.or.frontiernet.net. [50.53.82.155]) by mx.google.com with ESMTPSA id g92sm4748995qgf.20.2015.06.10.15.06.23 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 10 Jun 2015 15:06:24 -0700 (PDT) From: Stephen Hemminger To: declan.doherty@intel.com Date: Wed, 10 Jun 2015 15:06:24 -0700 Message-Id: <1433973985-17940-2-git-send-email-stephen@networkplumber.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1433973985-17940-1-git-send-email-stephen@networkplumber.org> References: <1433973985-17940-1-git-send-email-stephen@networkplumber.org> Cc: dev@dpdk.org, Stephen Hemminger Subject: [dpdk-dev] [PATCH 1/2] ethdev: make rte_eth_dev_is_valid_port public 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, 10 Jun 2015 22:06:26 -0000 From: Stephen Hemminger The function rte_eth_dev_is_valid_port is good way to have all drivers using same function and solves several hotplug related bugs from drivers not checking attached flag. Signed-off-by: Stephen Hemminger --- lib/librte_ether/rte_ethdev.c | 2 +- lib/librte_ether/rte_ethdev.h | 11 +++++++++++ lib/librte_ether/rte_ether_version.map | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 5a94654..ae4d86d 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -401,7 +401,7 @@ rte_eth_driver_register(struct eth_driver *eth_drv) rte_eal_pci_register(ð_drv->pci_drv); } -static int +int rte_eth_dev_is_valid_port(uint8_t port_id) { if (port_id >= RTE_MAX_ETHPORTS || diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index 16dbe00..b640e5b 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -1853,6 +1853,17 @@ extern int rte_eth_tx_queue_setup(uint8_t port_id, uint16_t tx_queue_id, extern int rte_eth_dev_socket_id(uint8_t port_id); /* + * Check if port_id of device is attached + * + * @param port_id + * The port identifier of the Ethernet device + * @return + * 0 if port is out of range or not attached + * 1 if device is attached + */ +extern int rte_eth_dev_is_valid_port(uint8_t port_id); + +/* * Allocate mbuf from mempool, setup the DMA physical address * and then start RX for specified queue of a port. It is used * when rx_deferred_start flag of the specified queue is true. diff --git a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_version.map index a2d25a6..8aa3501 100644 --- a/lib/librte_ether/rte_ether_version.map +++ b/lib/librte_ether/rte_ether_version.map @@ -63,6 +63,7 @@ DPDK_2.0 { rte_eth_dev_set_vlan_offload; rte_eth_dev_set_vlan_pvid; rte_eth_dev_set_vlan_strip_on_queue; + rte_eth_dev_is_valid_port; rte_eth_dev_socket_id; rte_eth_dev_start; rte_eth_dev_stop; -- 2.1.4