From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) by dpdk.org (Postfix) with ESMTP id 100D21B5BD for ; Wed, 11 Jul 2018 23:46:01 +0200 (CEST) Received: by mail-wr1-f51.google.com with SMTP id a3-v6so10374096wrt.2 for ; Wed, 11 Jul 2018 14:46:01 -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:content-transfer-encoding; bh=4GVoPGxPVbEi4xXKoRREOyrMdd30uHc6auy6dlwC1CU=; b=s7VvSwj+HDLO+PtOIhgYKlavgAFPC1k3m0xyarRU56M7o/IR6quCEt3w3SF9YAhbjx SDaB3cKXIxNlY8BFf3e9xlH96ukFeIGN3/kY8qsiYi0Kpm794qXGgGSfmEZ/oIMA/8/W agWyhdXGOODVxBY/6FrVjZlcKOooZlD94YaDjOAALN7d7nn9aZgyebYhqnq4DjLsn7NS GZq2fQ1nH/rpX6Ky56uoHWOyXIiypZkfWep5hZRIr3tV/OxeCSXpXzYop3tRlaYai0E7 kMT6XK1Eqyv6oa0mmO2X+pupIX9iEnjIdiP0josCfK/8w5pUffJtQpUYv6d4mDtRVAWV TtcQ== 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:content-transfer-encoding; bh=4GVoPGxPVbEi4xXKoRREOyrMdd30uHc6auy6dlwC1CU=; b=WyApgEp0O2yxULNbvHij6Kudu/rD+ZHtAjb39taSJt+tBWt4PM9+M1394gV5Nk5iOz 4nm/C7diqmUJVBkTr+DuQsP/oNlQGvoxB9UKRJXfxc5M5HMMTSn6QqeKJP4Q+0AiFzgK yepfAUrZs7A5A8HXfReJmO3ji9wG9zn9g0Ia5cEatPonClvpGTppmmTpbThPmu/tpS1c hbXe3O65gldURdf1Tp4nEqbexyrpu7ZPqHY5hW07SxzYoMPDJigsko3Viv5543Aa6Nop xaPtTRG0DPQllldlLQ1Xu5o3jnS8QlKufAnqV4Wmxe2ocQGqcuifgroPVEP889RaXIrk fwTg== X-Gm-Message-State: AOUpUlHS2dzuCi+PLonk5/MoXs1OwoZRVQtn3vPGRR4ncfqwTUNQZIFk MrGEMrguBLjyMRjtaS8PCNSNGnQd X-Google-Smtp-Source: AAOMgpc8vAPoSQkZNgTcSNhCec5yAFLuE8Tx+mmUGVO0VRi0WxoG25Q6uI8l2P3otZNNeLrgRbAErA== X-Received: by 2002:adf:8806:: with SMTP id d6-v6mr202835wrd.41.1531345560372; Wed, 11 Jul 2018 14:46:00 -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 h5-v6sm10550936wrr.19.2018.07.11.14.45.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Jul 2018 14:45:59 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Wed, 11 Jul 2018 23:45:08 +0200 Message-Id: <469ae14d6183850a5105a36726121af2f2743e59.1531345404.git.gaetan.rivet@6wind.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v11 18/25] 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: Wed, 11 Jul 2018 21:46:01 -0000 Signed-off-by: Gaetan Rivet --- lib/librte_ethdev/Makefile | 3 +- lib/librte_ethdev/meson.build | 1 + lib/librte_ethdev/rte_class_eth.c | 79 +++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 lib/librte_ethdev/rte_class_eth.c diff --git a/lib/librte_ethdev/Makefile b/lib/librte_ethdev/Makefile index 2fa133fbc..d4c3a8d06 100644 --- a/lib/librte_ethdev/Makefile +++ b/lib/librte_ethdev/Makefile @@ -12,7 +12,7 @@ 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 @@ -20,6 +20,7 @@ LIBABIVER := 9 SRCS-y += eth_private.c 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_ethdev/meson.build b/lib/librte_ethdev/meson.build index a0c001847..f9538770b 100644 --- a/lib/librte_ethdev/meson.build +++ b/lib/librte_ethdev/meson.build @@ -6,6 +6,7 @@ version = 9 allow_experimental_apis = true sources = files('eth_private.c', 'ethdev_profile.c', + 'rte_class_eth.c', 'rte_ethdev.c', 'rte_flow.c', 'rte_mtr.c', diff --git a/lib/librte_ethdev/rte_class_eth.c b/lib/librte_ethdev/rte_class_eth.c new file mode 100644 index 000000000..32c736d32 --- /dev/null +++ b/lib/librte_ethdev/rte_class_eth.c @@ -0,0 +1,79 @@ +/* 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" +#include "eth_private.h" + +enum eth_params { + RTE_ETH_PARAMS_MAX, +}; + +static const char * const eth_params_keys[] = { + [RTE_ETH_PARAMS_MAX] = NULL, +}; + +struct eth_dev_match_arg { + struct rte_device *device; + struct rte_kvargs *kvlist; +}; + +#define eth_dev_match_arg(d, k) \ + (&(const struct eth_dev_match_arg) { \ + .device = (d), \ + .kvlist = (k), \ + }) + +static int +eth_dev_match(const struct rte_eth_dev *edev, + const void *_arg) +{ + const struct eth_dev_match_arg *arg = _arg; + const struct rte_kvargs *kvlist = arg->kvlist; + + if (edev->state == RTE_ETH_DEV_UNUSED) + return -1; + if (edev->device != arg->device) + return -1; + if (kvlist == NULL) + /* Empty string matches everything. */ + return 0; + return 0; +} + +static void * +eth_dev_iterate(const void *start, + const char *str, + const struct rte_dev_iterator *it) +{ + struct rte_kvargs *kvargs = NULL; + struct rte_eth_dev *edev = NULL; + + if (str != NULL) { + kvargs = rte_kvargs_parse(str, eth_params_keys); + if (kvargs == NULL) { + RTE_LOG(ERR, EAL, "cannot parse argument list\n"); + rte_errno = EINVAL; + return NULL; + } + } + edev = eth_find_device(start, eth_dev_match, + eth_dev_match_arg(it->device, kvargs)); + 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.18.0