From patchwork Fri Apr 15 13:04:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Elo, Matias \(Nokia - FI/Espoo\)" X-Patchwork-Id: 65913 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp1170106qge; Fri, 15 Apr 2016 06:07:25 -0700 (PDT) X-Received: by 10.140.217.208 with SMTP id n199mr26507381qhb.83.1460725645861; Fri, 15 Apr 2016 06:07:25 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id f1si36401372qhe.110.2016.04.15.06.07.25; Fri, 15 Apr 2016 06:07:25 -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=fail (p=NONE dis=NONE) header.from=nokia.com Received: by lists.linaro.org (Postfix, from userid 109) id 77BBA62F47; Fri, 15 Apr 2016 13:07:25 +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=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 EB24C669E4; Fri, 15 Apr 2016 13:04:50 +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 C477D62041; Fri, 15 Apr 2016 13:04:36 +0000 (UTC) Received: from demumfd002.nsn-inter.net (demumfd002.nsn-inter.net [93.183.12.31]) by lists.linaro.org (Postfix) with ESMTPS id 951FA62BF8 for ; Fri, 15 Apr 2016 13:04:33 +0000 (UTC) Received: from demuprx016.emea.nsn-intra.net ([10.150.129.55]) by demumfd002.nsn-inter.net (8.15.2/8.15.2) with ESMTPS id u3FD4WQ0023186 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 15 Apr 2016 13:04:32 GMT Received: from 10.144.19.15 ([10.144.104.112]) by demuprx016.emea.nsn-intra.net (8.12.11.20060308/8.12.11) with ESMTP id u3FD4UHi019910 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO) for ; Fri, 15 Apr 2016 15:04:32 +0200 From: Matias Elo To: lng-odp@lists.linaro.org Date: Fri, 15 Apr 2016 16:04:24 +0300 Message-Id: <1460725470-4457-6-git-send-email-matias.elo@nokia.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1460725470-4457-1-git-send-email-matias.elo@nokia.com> References: <1460725470-4457-1-git-send-email-matias.elo@nokia.com> X-purgate-type: clean X-purgate-Ad: Categorized by eleven eXpurgate (R) http://www.eleven.de X-purgate: clean X-purgate: This mail is considered clean (visit http://www.eleven.de for further information) X-purgate-size: 7081 X-purgate-ID: 151667::1460725472-00002418-4F80A99B/0/0 X-Topics: patch Subject: [lng-odp] [API-NEXT PATCH v2 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" Add default implementations for odp_pktio_config(). Signed-off-by: Matias Elo --- .../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 4946f78..746c53d 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 };