From mboxrd@z Thu Jan 1 00:00:00 1970 From: Reshma Pattan Subject: [PATCH 06/15] net/softnic: add function to get eth device from softnic Date: Thu, 6 Sep 2018 17:26:53 +0100 Message-ID: <1536251222-17275-7-git-send-email-reshma.pattan@intel.com> References: <1536251222-17275-1-git-send-email-reshma.pattan@intel.com> Cc: Cristian Dumitrescu , Reshma Pattan To: dev@dpdk.org Return-path: Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id 7F1715323 for ; Thu, 6 Sep 2018 18:27:13 +0200 (CEST) In-Reply-To: <1536251222-17275-1-git-send-email-reshma.pattan@intel.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add utility function to get the rte_eth_dev from a given softnic. Signed-off-by: Cristian Dumitrescu Signed-off-by: Reshma Pattan --- drivers/net/softnic/rte_eth_softnic_internals.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/net/softnic/rte_eth_softnic_internals.h b/drivers/net/softnic/rte_eth_softnic_internals.h index 9c587bc7d..1857ec50d 100644 --- a/drivers/net/softnic/rte_eth_softnic_internals.h +++ b/drivers/net/softnic/rte_eth_softnic_internals.h @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -537,6 +538,22 @@ struct pmd_internals { struct softnic_thread_data thread_data[RTE_MAX_LCORE]; }; +static inline struct rte_eth_dev * +ETHDEV(struct pmd_internals *softnic) +{ + uint16_t port_id; + int status; + + if (softnic == NULL) + return NULL; + + status = rte_eth_dev_get_port_by_name(softnic->params.name, &port_id); + if (status) + return NULL; + + return &rte_eth_devices[port_id]; +} + /** * Ethdev Flow API */ -- 2.14.4