From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f48.google.com (mail-pa0-f48.google.com [209.85.220.48]) by dpdk.org (Postfix) with ESMTP id 39CB58076 for ; Tue, 9 Dec 2014 07:31:09 +0100 (CET) Received: by mail-pa0-f48.google.com with SMTP id rd3so6793074pab.21 for ; Mon, 08 Dec 2014 22:31:08 -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=qfaCAE5j5b6nKpoxyb5rpihtg6rEQEEji1epyP40+lQ=; b=MAs3TbTnA76nzpiaeeLduP8h1UQj1jf1gUwsRecGsQRQySl54OQdwPC+TsYQKxOcS0 y9lemurNlJLFGrO79tAUY2XLRKmu8VR4PVeF3Be9LuembP5g7pMofVQ/IKTiY7xM4R/L CrykS9otVmxCoqS8NkSj/s/MpwA8pM0CNcQXVrFx8FXC3C/IHlxfAhnPItzrsmq0pSpR gcDS8gwsj6c/i0iHkbuUePomj08rZuxc3pPh2uOpDBQH4WcRKDxQNcCYP9dgLiCtArPz JH1pbaD+1WoLXiMTbwrzmuerkvFmh/msPOGmtg4jb75uxlm3zzNitWvMjrdq62+CwTpx qBcQ== X-Gm-Message-State: ALoCoQnVyhUKnFrCzK7yuvX/dEmgcUI82Mrqnm3klqj7ASgBjbx990Y+3ckXZaJ3kGFIt6dLw6pj X-Received: by 10.66.146.135 with SMTP id tc7mr2192197pab.155.1418106668565; Mon, 08 Dec 2014 22:31:08 -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.31.05 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 08 Dec 2014 22:31:07 -0800 (PST) From: Tetsuya Mukawa To: dev@dpdk.org Date: Tue, 9 Dec 2014 15:30:11 +0900 Message-Id: <1418106629-22227-11-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 10/28] ethdev: Add rte_eth_dev_get_name_by_port 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: Tue, 09 Dec 2014 06:31:09 -0000 The function returns a unique identifier name of a ethdev specified by port identifier. Signed-off-by: Tetsuya Mukawa --- lib/librte_ether/rte_ethdev.c | 22 ++++++++++++++++++++++ lib/librte_ether/rte_ethdev.h | 12 ++++++++++++ 2 files changed, 34 insertions(+) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 4e9f0f7..1d82f69 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -476,6 +476,28 @@ rte_eth_dev_get_port_by_addr(struct rte_pci_addr *addr, uint8_t *port_id) return -1; } +int +rte_eth_dev_get_name_by_port(uint8_t port_id, char *name) +{ + char *tmp; + + if (rte_eth_dev_validate_port(port_id) == DEV_INVALID) { + PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); + return -EINVAL; + } + + if (name == NULL) { + PMD_DEBUG_TRACE("Null pointer is specified\n"); + return -EINVAL; + } + + /* shouldn't check 'rte_eth_devices[i].data', + * because it might be overwritten by VDEV PMD */ + tmp = rte_eth_dev_data[port_id].name; + strncpy(name, tmp, strlen(tmp) + 1); + return 0; +} + static int rte_eth_dev_rx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues) { diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index 8c55c56..bd921d0 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -1689,6 +1689,18 @@ extern int rte_eth_dev_get_port_by_addr( struct rte_pci_addr *addr, uint8_t *port_id); /** + * Function for internal use by port hotplug functions. + * Returns a unique identifier name of a ethdev specified by port identifier. + * @param port_id + * The port identifier. + * @param name + * The pointer to the Unique identifier name for each Ethernet device + * @return + * - 0 on success, negative on error + */ +extern int rte_eth_dev_get_name_by_port(uint8_t port_id, char *name); + +/** * Function for internal use by dummy drivers primarily, e.g. ring-based * driver. * Allocates a new ethdev slot for an ethernet device and returns the pointer -- 1.9.1