From patchwork Thu Apr 21 00:14:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 66264 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp2742558qge; Wed, 20 Apr 2016 17:18:06 -0700 (PDT) X-Received: by 10.141.41.130 with SMTP id s124mr15558793qhe.69.1461197886469; Wed, 20 Apr 2016 17:18:06 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id t18si2891qgd.30.2016.04.20.17.18.06; Wed, 20 Apr 2016 17:18:06 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 242D462C0C; Thu, 21 Apr 2016 00:18:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 349576854E; Thu, 21 Apr 2016 00:15:08 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 60FCE6854E; Thu, 21 Apr 2016 00:14:57 +0000 (UTC) Received: from mail-oi0-f51.google.com (mail-oi0-f51.google.com [209.85.218.51]) by lists.linaro.org (Postfix) with ESMTPS id A3C02669E4 for ; Thu, 21 Apr 2016 00:14:23 +0000 (UTC) Received: by mail-oi0-f51.google.com with SMTP id r78so61171779oie.0 for ; Wed, 20 Apr 2016 17:14:23 -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=2pStMB7t0p9fWNlRyEDZXdtDcNej0EAaG/xTFhLZcwg=; b=anrwB4e3m3V6cKknf5fYQEKQoMIUQRulwNrcqiTGt/wTy/9QVGngyX34Qd9Bn+fVxE JQEiovV6NJJfh8+oeFbT4VZhKJtbR1m488NZnDjAfOMWnFzBst5DfDD8sjse68xlgg4J 5T6hMYlppKQCT0p8k7MyNiw7SWPN2yr4cec1tlsfn64DYMl4MRPqIurk8BEChcwF+VYy 3k74wfKAqv1UHjUba8yH4g9lHYQidsQVgBN6z5lV8NzMDBH/qARklJ4Hi5xyt8bt9btb YPNxhiZHqRP7cuYx78CViY3Cl5nWENI5mwwtnVjb/5eeYa967YOOSS8sPz4PLtl4FuDh pJLg== X-Gm-Message-State: AOPr4FXhalNhc4bkxyA3nUPhZP8HaiUq+8anVaFoe3hU1M41K0v926gpaF9zxX84K3Rn0F41xLs= X-Received: by 10.202.185.214 with SMTP id j205mr4982207oif.68.1461197663140; Wed, 20 Apr 2016 17:14:23 -0700 (PDT) Received: from Ubuntu15.localdomain (cpe-66-68-129-43.austin.res.rr.com. [66.68.129.43]) by smtp.gmail.com with ESMTPSA id a34sm335otb.1.2016.04.20.17.14.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 Apr 2016 17:14:22 -0700 (PDT) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Wed, 20 Apr 2016 19:14:09 -0500 Message-Id: <1461197655-23743-6-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1461197655-23743-1-git-send-email-bill.fischofer@linaro.org> References: <1461197655-23743-1-git-send-email-bill.fischofer@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv4 05/11] linux-generic: pktio: implement odp_pktio_config() X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Matias Elo Add default implementations for odp_pktio_config(). Signed-off-by: Matias Elo Reviewed-and-tested-by: Bill Fischofer --- .../linux-generic/include/odp_packet_io_internal.h | 3 +++ platform/linux-generic/odp_packet_io.c | 27 +++++++++++++++++----- platform/linux-generic/pktio/dpdk.c | 1 + platform/linux-generic/pktio/ipc.c | 1 + platform/linux-generic/pktio/loop.c | 1 + platform/linux-generic/pktio/netmap.c | 1 + platform/linux-generic/pktio/pcap.c | 1 + platform/linux-generic/pktio/socket.c | 1 + platform/linux-generic/pktio/socket_mmap.c | 1 + platform/linux-generic/pktio/tap.c | 1 + 10 files changed, 32 insertions(+), 6 deletions(-) diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index ee7fc71..a807d13 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -131,6 +131,7 @@ struct pktio_entry { STATE_STOPPED /**< Same as OPENED, but only happens after STARTED */ } state; + odp_pktio_config_t config; /**< Device configuration */ classifier_t cls; /**< classifier linked with this pktio*/ odp_pktio_stats_t stats; /**< statistic counters for pktio */ enum { @@ -197,6 +198,8 @@ typedef struct pktio_if_ops { int (*link_status)(pktio_entry_t *pktio_entry); int (*capability)(pktio_entry_t *pktio_entry, odp_pktio_capability_t *capa); + int (*config)(pktio_entry_t *pktio_entry, + const odp_pktio_config_t *config); int (*input_queues_config)(pktio_entry_t *pktio_entry, const odp_pktin_queue_param_t *param); int (*output_queues_config)(pktio_entry_t *pktio_entry, diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index 2650124..c597e83 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -384,7 +384,9 @@ int odp_pktio_close(odp_pktio_t id) int odp_pktio_config(odp_pktio_t id, const odp_pktio_config_t *config) { pktio_entry_t *entry; + odp_pktio_capability_t capa; odp_pktio_config_t default_config; + int res = 0; entry = get_pktio_entry(id); if (!entry) @@ -395,21 +397,34 @@ int odp_pktio_config(odp_pktio_t id, const odp_pktio_config_t *config) config = &default_config; } - /* Currently nothing is supported. Capability returns 0 for both bit - * fields. */ - if (config->pktin.all_bits != 0 || - config->pktout.all_bits != 0) + if (odp_pktio_capability(id, &capa)) + return -1; + + /* Check config for invalid values */ + if (config->pktin.all_bits & ~capa.config.pktin.all_bits) { + ODP_ERR("Unsupported input configuration option\n"); return -1; + } + if (config->pktout.all_bits & ~capa.config.pktout.all_bits) { + ODP_ERR("Unsupported output configuration option\n"); + return -1; + } lock_entry(entry); - if (entry->s.state != STATE_STARTED) { + if (entry->s.state == STATE_STARTED) { unlock_entry(entry); + ODP_DBG("pktio %s: not stopped\n", entry->s.name); return -1; } + entry->s.config = *config; + + if (entry->s.ops->config) + res = entry->s.ops->config(entry, config); + unlock_entry(entry); - return 0; + return res; } int odp_pktio_start(odp_pktio_t id) diff --git a/platform/linux-generic/pktio/dpdk.c b/platform/linux-generic/pktio/dpdk.c index ea7b925..83fb1ba 100644 --- a/platform/linux-generic/pktio/dpdk.c +++ b/platform/linux-generic/pktio/dpdk.c @@ -929,6 +929,7 @@ const pktio_if_ops_t dpdk_pktio_ops = { .capability = dpdk_capability, .pktin_ts_res = NULL, .pktin_ts_from_ns = NULL, + .config = NULL, .input_queues_config = dpdk_input_queues_config, .output_queues_config = dpdk_output_queues_config }; diff --git a/platform/linux-generic/pktio/ipc.c b/platform/linux-generic/pktio/ipc.c index cd7e32f..18dbe15 100644 --- a/platform/linux-generic/pktio/ipc.c +++ b/platform/linux-generic/pktio/ipc.c @@ -728,4 +728,5 @@ const pktio_if_ops_t ipc_pktio_ops = { .mac_get = ipc_mac_addr_get, .pktin_ts_res = NULL, .pktin_ts_from_ns = NULL, + .config = NULL }; diff --git a/platform/linux-generic/pktio/loop.c b/platform/linux-generic/pktio/loop.c index 396b769..2fc1381 100644 --- a/platform/linux-generic/pktio/loop.c +++ b/platform/linux-generic/pktio/loop.c @@ -186,6 +186,7 @@ const pktio_if_ops_t loopback_pktio_ops = { .capability = NULL, .pktin_ts_res = NULL, .pktin_ts_from_ns = NULL, + .config = NULL, .input_queues_config = NULL, .output_queues_config = NULL, .recv_queue = NULL, diff --git a/platform/linux-generic/pktio/netmap.c b/platform/linux-generic/pktio/netmap.c index c2a6b34..0b794a0 100644 --- a/platform/linux-generic/pktio/netmap.c +++ b/platform/linux-generic/pktio/netmap.c @@ -863,6 +863,7 @@ const pktio_if_ops_t netmap_pktio_ops = { .capability = netmap_capability, .pktin_ts_res = NULL, .pktin_ts_from_ns = NULL, + .config = NULL, .input_queues_config = netmap_input_queues_config, .output_queues_config = netmap_output_queues_config, .recv_queue = netmap_recv_queue, diff --git a/platform/linux-generic/pktio/pcap.c b/platform/linux-generic/pktio/pcap.c index c8769f5..a47d2cc 100644 --- a/platform/linux-generic/pktio/pcap.c +++ b/platform/linux-generic/pktio/pcap.c @@ -409,6 +409,7 @@ const pktio_if_ops_t pcap_pktio_ops = { .capability = NULL, .pktin_ts_res = NULL, .pktin_ts_from_ns = NULL, + .config = NULL, .input_queues_config = NULL, .output_queues_config = NULL, .recv_queue = NULL, diff --git a/platform/linux-generic/pktio/socket.c b/platform/linux-generic/pktio/socket.c index c5cbc2d..44f18c2 100644 --- a/platform/linux-generic/pktio/socket.c +++ b/platform/linux-generic/pktio/socket.c @@ -858,6 +858,7 @@ const pktio_if_ops_t sock_mmsg_pktio_ops = { .capability = NULL, .pktin_ts_res = NULL, .pktin_ts_from_ns = NULL, + .config = NULL, .input_queues_config = NULL, .output_queues_config = NULL, .recv_queue = NULL, diff --git a/platform/linux-generic/pktio/socket_mmap.c b/platform/linux-generic/pktio/socket_mmap.c index 6d211ec..da0f7b7 100644 --- a/platform/linux-generic/pktio/socket_mmap.c +++ b/platform/linux-generic/pktio/socket_mmap.c @@ -627,6 +627,7 @@ const pktio_if_ops_t sock_mmap_pktio_ops = { .capability = NULL, .pktin_ts_res = NULL, .pktin_ts_from_ns = NULL, + .config = NULL, .input_queues_config = NULL, .output_queues_config = NULL, .recv_queue = NULL, diff --git a/platform/linux-generic/pktio/tap.c b/platform/linux-generic/pktio/tap.c index abc49fa..e02d311 100644 --- a/platform/linux-generic/pktio/tap.c +++ b/platform/linux-generic/pktio/tap.c @@ -326,4 +326,5 @@ const pktio_if_ops_t tap_pktio_ops = { .mac_get = tap_mac_addr_get, .pktin_ts_res = NULL, .pktin_ts_from_ns = NULL, + .config = NULL };