From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f195.google.com (mail-wr0-f195.google.com [209.85.128.195]) by dpdk.org (Postfix) with ESMTP id 3992CAAB7 for ; Tue, 27 Mar 2018 01:19:27 +0200 (CEST) Received: by mail-wr0-f195.google.com with SMTP id 80so19432351wrb.2 for ; Mon, 26 Mar 2018 16:19:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:in-reply-to:references:content-transfer-encoding; bh=1TzKa/MJvUUoLE0T4U0aX0By42wrZrQrPMdtkx3GMuA=; b=lNlaBgzW1ghodehTYEiiuDwSaPfPh04HLp9Efiy1vEOwj6/FQ4IOF+V5Hjf6o+EtZr wYozZg2BJb+hfHIuKI/IY3pgsgKRiRGpkSVQQbzo3vqkCFdLWFedlBAsr7q2LdHk9SW+ 25W4cbG0cg7X8XfgV6W0V9QjBLGp/eVZiFJiB+kLbiu4XbcRHJJYhuiV5zynjoAHTzA4 hASE7d5hx+KtmzvpBnzuwhQYHtBhefYZiPwGxPSDABgTjdDdDo2bk61oPCRU3FlLVA0b o5XO/eMl6gV9EqkPnakb40GRWDayGkEPbVcNZtKx01JawqmKLxlFA3IF/s4980zRVCC7 AT7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:in-reply-to:references :content-transfer-encoding; bh=1TzKa/MJvUUoLE0T4U0aX0By42wrZrQrPMdtkx3GMuA=; b=cvU8PH51xuGGMj3RXGFPwn86gxe+hmTnx0FRVNGNhbey7fFg/k8fHj9CbgsXFWG9Sr VfmEUsg7qhL09pIq0XMoYwG641oWwf17FQ+8odvId5OMYMGGRHb0vhwNgR/pxNz0QGAr kYPd4pXNcfe4aXP6uQ+cW0Q0LCTQWvc0ZuSoOoyt5UoEdXcrkjHP578ctaUUbJMalYun rzGIC0EmrvTkx7mXW+svxZO8K0uO4dqn0kDKfrqkMGeuRDIK+ig0BrGf+JtAAeRCkcOm +drTXyUrhvb9XVO+tzd7/PqL01bVhIsITJ12fT43r+RazLV/b8G/Wp6CzIzfz67dmWwB 6mtA== X-Gm-Message-State: AElRT7HR0MD6zLvON67L9/Vum+dFnkBczCOR1/LONqsb4ElmpSOQWP6Q XMl4+FERzJyFhvRwpkuRqen9O2Gf X-Google-Smtp-Source: AG47ELthExolxt6BfefZLwAnLOCTiZyZ+e1QMVnW7PII0yYAIQ9TPQ/qexK2i/EOup2YMaobY2LhEw== X-Received: by 10.223.177.213 with SMTP id r21mr27966345wra.89.1522106366447; Mon, 26 Mar 2018 16:19:26 -0700 (PDT) Received: from bidouze.dev.6wind.com. (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id 67sm343712wra.9.2018.03.26.16.19.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Mar 2018 16:19:25 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Tue, 27 Mar 2018 01:18:42 +0200 Message-Id: <00de9428fafb82c4a76541e12edc5f7753f35d20.1522105876.git.gaetan.rivet@6wind.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: MIME-Version: 1.0 In-Reply-To: References: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v3 18/20] ethdev: register ether layer as a class X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Mar 2018 23:19:27 -0000 Signed-off-by: Gaetan Rivet --- lib/Makefile | 2 +- lib/librte_ether/Makefile | 3 +- lib/librte_ether/rte_class_eth.c | 65 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 lib/librte_ether/rte_class_eth.c diff --git a/lib/Makefile b/lib/Makefile index 1b17526f7..b291dd2cd 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -22,7 +22,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_CMDLINE) += librte_cmdline DEPDIRS-librte_cmdline := librte_eal DIRS-$(CONFIG_RTE_LIBRTE_ETHER) += librte_ether DEPDIRS-librte_ether := librte_net librte_eal librte_mempool librte_ring -DEPDIRS-librte_ether += librte_mbuf +DEPDIRS-librte_ether += librte_mbuf librte_kvargs DIRS-$(CONFIG_RTE_LIBRTE_BBDEV) += librte_bbdev DEPDIRS-librte_bbdev := librte_eal librte_mempool librte_mbuf DIRS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += librte_cryptodev diff --git a/lib/librte_ether/Makefile b/lib/librte_ether/Makefile index 3ca5782bb..a1a0393de 100644 --- a/lib/librte_ether/Makefile +++ b/lib/librte_ether/Makefile @@ -12,13 +12,14 @@ CFLAGS += -DALLOW_EXPERIMENTAL_API CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS) LDLIBS += -lrte_net -lrte_eal -lrte_mempool -lrte_ring -LDLIBS += -lrte_mbuf +LDLIBS += -lrte_mbuf -lrte_kvargs EXPORT_MAP := rte_ethdev_version.map LIBABIVER := 8 SRCS-y += rte_ethdev.c +SRCS-y += rte_class_eth.c SRCS-y += rte_flow.c SRCS-y += rte_tm.c SRCS-y += rte_mtr.c diff --git a/lib/librte_ether/rte_class_eth.c b/lib/librte_ether/rte_class_eth.c new file mode 100644 index 000000000..3f1537c2a --- /dev/null +++ b/lib/librte_ether/rte_class_eth.c @@ -0,0 +1,65 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2018 Gaƫtan Rivet + */ + +#include + +#include +#include +#include +#include +#include + +#include "rte_ethdev.h" +#include "rte_ethdev_core.h" + +static int +eth_dev_match(struct rte_eth_dev *edev, + struct rte_kvargs *kvlist) +{ + (void) kvlist; + (void) edev; + return 0; +} + +static void * +eth_dev_iterate(const void *_start, + const char *str, + const struct rte_dev_iterator *it) +{ + const struct rte_eth_dev *start = _start; + struct rte_device *dev = it->device; + struct rte_kvargs *kvargs = NULL; + struct rte_eth_dev *edev = NULL; + uint16_t p = 0; + + if (str != NULL) { + kvargs = rte_kvargs_parse(str, NULL); + if (kvargs == NULL) { + RTE_LOG(ERR, EAL, "cannot parse argument list\n"); + rte_errno = EINVAL; + return NULL; + } + } + if (start) + p = start->data->port_id + 1; + for (p = rte_eth_find_next(p); + p < RTE_MAX_ETHPORTS; + p = rte_eth_find_next(p + 1)) { + edev = &rte_eth_devices[p]; + if (dev != edev->device) + goto next_ethdev; + if (eth_dev_match(edev, kvargs) == 0) + break; +next_ethdev: + edev = NULL; + } + rte_kvargs_free(kvargs); + return edev; +} + +struct rte_class rte_class_eth = { + .dev_iterate = eth_dev_iterate, +}; + +RTE_REGISTER_CLASS(eth, rte_class_eth); -- 2.11.0