From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31AF9C531C9 for ; Fri, 24 Jul 2026 16:46:34 +0000 (UTC) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BE88E40689; Fri, 24 Jul 2026 18:45:41 +0200 (CEST) Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) by mails.dpdk.org (Postfix) with ESMTP id 11D4F40A8B for ; Fri, 24 Jul 2026 18:45:39 +0200 (CEST) Received: by mail-pg1-f174.google.com with SMTP id 41be03b00d2f7-c9e0b89e228so542064a12.1 for ; Fri, 24 Jul 2026 09:45:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20251104.gappssmtp.com; s=20251104; t=1784911538; x=1785516338; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=clsEp9ykfwwZpM+vhYsdne7OA3tkqOgu+HcPYDTYU1Q=; b=DR546j3T1P/cvgKExiDdT37vZRLi9cFa8t3DJ/tRpXoZT0SWebZVnSWsl3MoqCWgDx ieJ7ZzX9wcBP+LeiR/laJS1xboP7YSKLbPk4KQBBvjMc5f6SBLdA4b1LzMlum5XPdobR xacYjWjwel8WeYmLedb++8L/A/+IZXS8jeRjxvdhySUG2QhUtFbPZ0XQkIbsoFmqEhAY UKoSv2nvQRU4TgDfpQcZPn5qbrxK/WOaEeqX39DZSfsDmE8VZYDhnOMA/W0SFM8Bw6Ii T1OibQA56KlTymBXg38h4KK6NjgAJg6mkpFw5O9TKb3Shm/ycVw5vZImM9/AnK9Qe4kY /nig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784911538; x=1785516338; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=clsEp9ykfwwZpM+vhYsdne7OA3tkqOgu+HcPYDTYU1Q=; b=rY9LdSxaxU6mXgCGVgU+xmEyuXt0Ol/8FILswTopPfwd7ZHoj68gJcDoBFA+M40DmH nY9U7PPuxuDB7oJBmfjig+Y1of5Fc4w9hM51M65L4xu4QCQoS6qcXFSmkvclaX0n58Bt Tzhbaa0qeWPXsQ/SZLxFEKcAGQxF9InBYwlueuNYPUVNOKh6hDpHCvbyBx9s9kQvbTWz YjEMHjuniTw396fV98q8NFQX3Eo9Ppze5/Y654g5ogRZ0KJyvOmuhICf/Ixeg9UO1aY2 rt6028wAUfLL+VK/GBwC5boYOoLeKEkH1z7gzrqfODBb4U1L5OyQHVBhkMsIUFqUp/te ddBA== X-Gm-Message-State: AOJu0Yxh2NLky8fsXNMZF4wu74I9x99VnTDAjmzbdKm2oU13T/Rdi/xT 1BX3YUHdsnGVbJJPesdb/yTW1EBcgaAz46TgK11YmdaN4zzOwDOAHmeIvt3B8hkWPsfdBfWYYa5 NuyQJ X-Gm-Gg: AR+sD12LdkbpjVwMOU4oEXjF+V6c3BddlQJosdBzytFharceS0e3HzoYedyuUlUlIKC 5bH3Q+EMr76PYJyi2evJk/K+XuUQjgvpdC6/G5t4Fe5EqVuIbUxyWRzlhpx2vQW2Nc9Y3y460pm cE4o38ofydparHzNQWcUGwHHW4cfn66PleA7VhJZP2LTpzeJRRwQ9sWlbMzrc46dcGNrGRDR8Ez xdR6g/53AJZZ5fDu35nCK+cAyp+o20JlLZM5ezYDHOU0OT5FVK6BDyNxRbtRVdVhVg2JU9lIE/1 vezVLTfvMVcdvFk0XGOtatUcCvn4Tw8zQPSDMNVdwJgVMg27pSljHX2RsWq1qQt6lBAEpwnt4Nj Lwry9j6L8G+kgzry3s+LYEWuFi+zLY/FR1IF4nkg+/w9o0s1Jie6wKMEpQYVGQLH0AOGEQ8S7ww +FUVORd/PzCc3dMdqTlaq9DZCKKBEfvu83tN5c1WOV X-Received: by 2002:a05:6a21:3390:b0:3c3:daa2:2b7 with SMTP id adf61e73a8af0-3c44b14e8ecmr8429052637.44.1784911536700; Fri, 24 Jul 2026 09:45:36 -0700 (PDT) Received: from phoenix.lan (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-314bc549cacsm972872eec.16.2026.07.24.09.45.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jul 2026 09:45:36 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Cristian Dumitrescu Subject: [RFC 6/6] port: remove legacy API Date: Fri, 24 Jul 2026 09:44:02 -0700 Message-ID: <20260724164520.192203-7-stephen@networkplumber.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260724164520.192203-1-stephen@networkplumber.org> References: <20260724164520.192203-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Remove the legacy port library API (rte_port_*) as announced for removal in the 24.11 release. The SWX port API remains. The sched, ip_frag, cryptodev and eventdev dependencies were only used by the legacy port types, so drop them. The pcap dependency is kept for the SWX source/sink port. Signed-off-by: Stephen Hemminger --- doc/api/doxy-api-index.md | 7 - doc/guides/prog_guide/img/figure32.png | Bin 11603 -> 0 bytes doc/guides/prog_guide/packet_framework.rst | 132 +--- doc/guides/rel_notes/deprecation.rst | 5 - doc/guides/rel_notes/release_26_11.rst | 3 + lib/port/meson.build | 22 +- lib/port/port_log.c | 7 - lib/port/port_log.h | 11 - lib/port/rte_port.h | 223 ------ lib/port/rte_port_ethdev.c | 530 -------------- lib/port/rte_port_ethdev.h | 75 -- lib/port/rte_port_eventdev.c | 590 --------------- lib/port/rte_port_eventdev.h | 94 --- lib/port/rte_port_fd.c | 524 -------------- lib/port/rte_port_fd.h | 74 -- lib/port/rte_port_frag.c | 280 -------- lib/port/rte_port_frag.h | 70 -- lib/port/rte_port_ras.c | 336 --------- lib/port/rte_port_ras.h | 58 -- lib/port/rte_port_ring.c | 796 --------------------- lib/port/rte_port_ring.h | 91 --- lib/port/rte_port_sched.c | 298 -------- lib/port/rte_port_sched.h | 52 -- lib/port/rte_port_source_sink.c | 616 ---------------- lib/port/rte_port_source_sink.h | 57 -- lib/port/rte_port_sym_crypto.c | 558 --------------- lib/port/rte_port_sym_crypto.h | 92 --- 27 files changed, 10 insertions(+), 5591 deletions(-) delete mode 100644 doc/guides/prog_guide/img/figure32.png delete mode 100644 lib/port/port_log.c delete mode 100644 lib/port/port_log.h delete mode 100644 lib/port/rte_port.h delete mode 100644 lib/port/rte_port_ethdev.c delete mode 100644 lib/port/rte_port_ethdev.h delete mode 100644 lib/port/rte_port_eventdev.c delete mode 100644 lib/port/rte_port_eventdev.h delete mode 100644 lib/port/rte_port_fd.c delete mode 100644 lib/port/rte_port_fd.h delete mode 100644 lib/port/rte_port_frag.c delete mode 100644 lib/port/rte_port_frag.h delete mode 100644 lib/port/rte_port_ras.c delete mode 100644 lib/port/rte_port_ras.h delete mode 100644 lib/port/rte_port_ring.c delete mode 100644 lib/port/rte_port_ring.h delete mode 100644 lib/port/rte_port_sched.c delete mode 100644 lib/port/rte_port_sched.h delete mode 100644 lib/port/rte_port_source_sink.c delete mode 100644 lib/port/rte_port_source_sink.h delete mode 100644 lib/port/rte_port_sym_crypto.c delete mode 100644 lib/port/rte_port_sym_crypto.h diff --git a/doc/api/doxy-api-index.md b/doc/api/doxy-api-index.md index 760b770d6f..16827a602b 100644 --- a/doc/api/doxy-api-index.md +++ b/doc/api/doxy-api-index.md @@ -182,13 +182,6 @@ The public API headers are grouped by topics: [bitmap](@ref rte_bitmap.h) - **packet framework**: - * [port](@ref rte_port.h): - [ethdev](@ref rte_port_ethdev.h), - [ring](@ref rte_port_ring.h), - [frag](@ref rte_port_frag.h), - [reass](@ref rte_port_ras.h), - [sched](@ref rte_port_sched.h), - [src/sink](@ref rte_port_source_sink.h) * SWX pipeline: [control](@ref rte_swx_ctl.h), [extern](@ref rte_swx_extern.h), diff --git a/doc/guides/prog_guide/img/figure32.png b/doc/guides/prog_guide/img/figure32.png deleted file mode 100644 index 5215113fd9d533ff56526e21e1832bc7a6cabd04..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 11603 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 diff --git a/doc/guides/prog_guide/packet_framework.rst b/doc/guides/prog_guide/packet_framework.rst index 98cf3be109..3b5ede7dc2 100644 --- a/doc/guides/prog_guide/packet_framework.rst +++ b/doc/guides/prog_guide/packet_framework.rst @@ -4,132 +4,12 @@ Packet Framework Library ======================== -Design Objectives ------------------ - -The main design objectives for the DPDK Packet Framework are: - -* Provide standard methodology to build complex packet processing pipelines. - Provide reusable and extensible templates for the commonly used pipeline functional blocks; - -* Provide capability to switch between pure software and hardware-accelerated implementations for the same pipeline functional block; - -* Provide the best trade-off between flexibility and performance. - Hardcoded pipelines usually provide the best performance, but are not flexible, - while developing flexible frameworks is never a problem, but performance is usually low; - -* Provide a framework that is logically similar to Open Flow. - -Overview --------- - -Packet processing applications are frequently structured as pipelines of multiple stages, -with the logic of each stage glued around a lookup table. -For each incoming packet, the table defines the set of actions to be applied to the packet, -as well as the next stage to send the packet to. - -The DPDK Packet Framework minimizes the development effort required to build packet processing pipelines -by defining a standard methodology for pipeline development, -as well as providing libraries of reusable templates for the commonly used pipeline blocks. - -The pipeline is constructed by connecting the set of input ports with the set of output ports -through the set of tables in a tree-like topology. -As a result of lookup operation for the current packet in the current table, -one of the table entries (on lookup hit) or the default table entry (on lookup miss) -provides the set of actions to be applied on the current packet, -as well as the next hop for the packet, which can be either another table, an output port or packet drop. - -An example of packet processing pipeline is presented in :numref:`packet_framework_figure_32`: - -.. _packet_framework_figure_32: - -.. figure:: img/figure32.* - - Example of Packet Processing Pipeline where Input Ports 0 and 1 - are Connected with Output Ports 0, 1 and 2 through Tables 0 and 1 - - -Port Library Design -------------------- - -Port Types -~~~~~~~~~~ - -:numref:`packet_framework_table_qos_19` is a non-exhaustive list of ports -that can be implemented with the Packet Framework. - -.. _packet_framework_table_qos_19: - -.. table:: Port Types - - +---+------------------+---------------------------------------------------------------------------------------+ - | # | Port type | Description | - | | | | - +===+==================+=======================================================================================+ - | 1 | SW ring | SW circular buffer used for message passing between the application threads. Uses | - | | | the DPDK rte_ring primitive. Expected to be the most commonly used type of | - | | | port. | - | | | | - +---+------------------+---------------------------------------------------------------------------------------+ - | 2 | HW ring | Queue of buffer descriptors used to interact with NIC, switch or accelerator ports. | - | | | For NIC ports, it uses the DPDK rte_eth_rx_queue or rte_eth_tx_queue | - | | | primitives. | - | | | | - +---+------------------+---------------------------------------------------------------------------------------+ - | 3 | IP reassembly | Input packets are either IP fragments or complete IP datagrams. Output packets are | - | | | complete IP datagrams. | - | | | | - +---+------------------+---------------------------------------------------------------------------------------+ - | 4 | IP fragmentation | Input packets are jumbo (IP datagrams with length bigger than MTU) or non-jumbo | - | | | packets. Output packets are non-jumbo packets. | - | | | | - +---+------------------+---------------------------------------------------------------------------------------+ - | 5 | Traffic manager | Traffic manager attached to a specific NIC output port, performing congestion | - | | | management and hierarchical scheduling according to pre-defined SLAs. | - | | | | - +---+------------------+---------------------------------------------------------------------------------------+ - | 6 | Source | Input port used as packet generator. Similar to Linux kernel /dev/zero character | - | | | device. | - | | | | - +---+------------------+---------------------------------------------------------------------------------------+ - | 7 | Sink | Output port used to drop all input packets. Similar to Linux kernel /dev/null | - | | | character device. | - | | | | - +---+------------------+---------------------------------------------------------------------------------------+ - | 8 | Sym_crypto | Output port used to extract DPDK Cryptodev operations from a fixed offset of the | - | | | packet and then enqueue to the Cryptodev PMD. Input port used to dequeue the | - | | | Cryptodev operations from the Cryptodev PMD and then retrieve the packets from them. | - +---+------------------+---------------------------------------------------------------------------------------+ - -Port Interface -~~~~~~~~~~~~~~ - -Each port is unidirectional, i.e. either input port or output port. -Each input/output port is required to implement an abstract interface that -defines the initialization and run-time operation of the port. -The port abstract interface is described below. - -.. table:: 20 Port Abstract Interface - - +---+----------------+-----------------------------------------------------------------------------------------+ - | # | Port Operation | Description | - | | | | - +===+================+=========================================================================================+ - | 1 | Create | Create the low-level port object (e.g. queue). Can internally allocate memory. | - | | | | - +---+----------------+-----------------------------------------------------------------------------------------+ - | 2 | Free | Free the resources (e.g. memory) used by the low-level port object. | - | | | | - +---+----------------+-----------------------------------------------------------------------------------------+ - | 3 | RX | Read a burst of input packets. Non-blocking operation. Only defined for input ports. | - | | | | - +---+----------------+-----------------------------------------------------------------------------------------+ - | 4 | TX | Write a burst of input packets. Non-blocking operation. Only defined for output ports. | - | | | | - +---+----------------+-----------------------------------------------------------------------------------------+ - | 5 | Flush | Flush the output buffer. Only defined for output ports. | - | | | | - +---+----------------+-----------------------------------------------------------------------------------------+ +The Packet Framework is a set of libraries (port, table and pipeline) +for building flexible packet processing pipelines: +the pipeline is constructed by connecting a set of input ports +with a set of output ports through a set of match-action tables. +The current framework API is the Software Switch (SWX) pipeline +described below. The Software Switch (SWX) Pipeline ---------------------------------- diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/deprecation.rst index 9dcf86098f..75b56b0e10 100644 --- a/doc/guides/rel_notes/deprecation.rst +++ b/doc/guides/rel_notes/deprecation.rst @@ -148,11 +148,6 @@ Deprecation Notices The graph walk functions will process nodes in topological order using bitmap scanning instead of the circular buffer. -* port: The port library legacy API (functions rte_port_*) - will be deprecated and subsequently removed in DPDK 24.11 release. - Before this, the new port library API (functions rte_swx_port_*) - will gradually transition from experimental to stable status. - * bus/vmbus: Starting DPDK 25.11, all the vmbus API defined in ``drivers/bus/vmbus/rte_bus_vmbus.h`` will become internal to DPDK. Those API functions are used internally by DPDK core and netvsc PMD. diff --git a/doc/guides/rel_notes/release_26_11.rst b/doc/guides/rel_notes/release_26_11.rst index 306482c1d9..bc0ac01d5d 100644 --- a/doc/guides/rel_notes/release_26_11.rst +++ b/doc/guides/rel_notes/release_26_11.rst @@ -82,6 +82,9 @@ Removed Items * Removed the legacy table library API (``rte_table_*`` functions). The SWX table API (``rte_swx_table_*``) remains. +* Removed the legacy port library API (``rte_port_*`` functions). + The SWX port API (``rte_swx_port_*``) remains. + API Changes ----------- diff --git a/lib/port/meson.build b/lib/port/meson.build index b597772872..ef88b917a3 100644 --- a/lib/port/meson.build +++ b/lib/port/meson.build @@ -8,39 +8,19 @@ if is_windows endif sources = files( - 'port_log.c', - 'rte_port_ethdev.c', - 'rte_port_fd.c', - 'rte_port_frag.c', - 'rte_port_ras.c', - 'rte_port_ring.c', - 'rte_port_sched.c', - 'rte_port_source_sink.c', - 'rte_port_sym_crypto.c', - 'rte_port_eventdev.c', 'rte_swx_port_ethdev.c', 'rte_swx_port_fd.c', 'rte_swx_port_ring.c', 'rte_swx_port_source_sink.c', ) headers = files( - 'rte_port_ethdev.h', - 'rte_port_fd.h', - 'rte_port_frag.h', - 'rte_port_ras.h', - 'rte_port.h', - 'rte_port_ring.h', - 'rte_port_sched.h', - 'rte_port_source_sink.h', - 'rte_port_sym_crypto.h', - 'rte_port_eventdev.h', 'rte_swx_port.h', 'rte_swx_port_ethdev.h', 'rte_swx_port_fd.h', 'rte_swx_port_ring.h', 'rte_swx_port_source_sink.h', ) -deps += ['ethdev', 'sched', 'ip_frag', 'cryptodev', 'eventdev'] +deps += ['ethdev'] if dpdk_conf.has('RTE_HAS_LIBPCAP') dpdk_conf.set('RTE_PORT_PCAP', 1) diff --git a/lib/port/port_log.c b/lib/port/port_log.c deleted file mode 100644 index e7a10d80ef..0000000000 --- a/lib/port/port_log.c +++ /dev/null @@ -1,7 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright (c) 2024 Stephen Hemminger - */ - -#include - -RTE_LOG_REGISTER_DEFAULT(port_logtype, INFO); diff --git a/lib/port/port_log.h b/lib/port/port_log.h deleted file mode 100644 index 28d75ee48b..0000000000 --- a/lib/port/port_log.h +++ /dev/null @@ -1,11 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright (c) 2023 Red Hat, Inc. - */ - -#include - -extern int port_logtype; -#define RTE_LOGTYPE_PORT port_logtype - -#define PORT_LOG(level, ...) \ - RTE_LOG_LINE(level, PORT, "" __VA_ARGS__) diff --git a/lib/port/rte_port.h b/lib/port/rte_port.h deleted file mode 100644 index 81f57c41a5..0000000000 --- a/lib/port/rte_port.h +++ /dev/null @@ -1,223 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2010-2014 Intel Corporation - */ - -#ifndef __INCLUDE_RTE_PORT_H__ -#define __INCLUDE_RTE_PORT_H__ - -/** - * @file - * RTE Port - * - * This tool is part of the DPDK Packet Framework tool suite and provides - * a standard interface to implement different types of packet ports. - */ - -#include -#include - -/**@{ - * Macros to allow accessing metadata stored in the mbuf headroom - * just beyond the end of the mbuf data structure returned by a port - */ -#define RTE_MBUF_METADATA_UINT8_PTR(mbuf, offset) \ - (&((uint8_t *)(mbuf))[offset]) -#define RTE_MBUF_METADATA_UINT16_PTR(mbuf, offset) \ - ((uint16_t *) RTE_MBUF_METADATA_UINT8_PTR(mbuf, offset)) -#define RTE_MBUF_METADATA_UINT32_PTR(mbuf, offset) \ - ((uint32_t *) RTE_MBUF_METADATA_UINT8_PTR(mbuf, offset)) -#define RTE_MBUF_METADATA_UINT64_PTR(mbuf, offset) \ - ((uint64_t *) RTE_MBUF_METADATA_UINT8_PTR(mbuf, offset)) - -#define RTE_MBUF_METADATA_UINT8(mbuf, offset) \ - (*RTE_MBUF_METADATA_UINT8_PTR(mbuf, offset)) -#define RTE_MBUF_METADATA_UINT16(mbuf, offset) \ - (*RTE_MBUF_METADATA_UINT16_PTR(mbuf, offset)) -#define RTE_MBUF_METADATA_UINT32(mbuf, offset) \ - (*RTE_MBUF_METADATA_UINT32_PTR(mbuf, offset)) -#define RTE_MBUF_METADATA_UINT64(mbuf, offset) \ - (*RTE_MBUF_METADATA_UINT64_PTR(mbuf, offset)) -/**@}*/ - -/* - * Port IN - */ -/** Maximum number of packets read from any input port in a single burst. -Cannot be changed. */ -#define RTE_PORT_IN_BURST_SIZE_MAX 64 - -/** Input port statistics */ -struct rte_port_in_stats { - uint64_t n_pkts_in; - uint64_t n_pkts_drop; -}; - -/** - * Input port create - * - * @param params - * Parameters for input port creation - * @param socket_id - * CPU socket ID (e.g. for memory allocation purpose) - * @return - * Handle to input port instance - */ -typedef void* (*rte_port_in_op_create)(void *params, int socket_id); - -/** - * Input port free - * - * @param port - * Handle to input port instance - * @return - * 0 on success, error code otherwise - */ -typedef int (*rte_port_in_op_free)(void *port); - -/** - * Input port packet burst RX - * - * @param port - * Handle to input port instance - * @param pkts - * Burst of input packets - * @param n_pkts - * Number of packets in the input burst - * @return - * 0 on success, error code otherwise - */ -typedef int (*rte_port_in_op_rx)( - void *port, - struct rte_mbuf **pkts, - uint32_t n_pkts); - -/** - * Input port stats get - * - * @param port - * Handle to output port instance - * @param stats - * Handle to port_in stats struct to copy data - * @param clear - * Flag indicating that stats should be cleared after read - * - * @return - * Error code or 0 on success. - */ -typedef int (*rte_port_in_op_stats_read)( - void *port, - struct rte_port_in_stats *stats, - int clear); - -/** Input port interface defining the input port operation */ -struct rte_port_in_ops { - rte_port_in_op_create f_create; /**< Create */ - rte_port_in_op_free f_free; /**< Free */ - rte_port_in_op_rx f_rx; /**< Packet RX (packet burst) */ - rte_port_in_op_stats_read f_stats; /**< Stats */ -}; - -/* - * Port OUT - */ -/** Output port statistics */ -struct rte_port_out_stats { - uint64_t n_pkts_in; - uint64_t n_pkts_drop; -}; - -/** - * Output port create - * - * @param params - * Parameters for output port creation - * @param socket_id - * CPU socket ID (e.g. for memory allocation purpose) - * @return - * Handle to output port instance - */ -typedef void* (*rte_port_out_op_create)(void *params, int socket_id); - -/** - * Output port free - * - * @param port - * Handle to output port instance - * @return - * 0 on success, error code otherwise - */ -typedef int (*rte_port_out_op_free)(void *port); - -/** - * Output port single packet TX - * - * @param port - * Handle to output port instance - * @param pkt - * Input packet - * @return - * 0 on success, error code otherwise - */ -typedef int (*rte_port_out_op_tx)( - void *port, - struct rte_mbuf *pkt); - -/** - * Output port packet burst TX - * - * @param port - * Handle to output port instance - * @param pkts - * Burst of input packets specified as array of up to 64 pointers to struct - * rte_mbuf - * @param pkts_mask - * 64-bit bitmask specifying which packets in the input burst are valid. When - * pkts_mask bit n is set, then element n of pkts array is pointing to a - * valid packet. Otherwise, element n of pkts array will not be accessed. - * @return - * 0 on success, error code otherwise - */ -typedef int (*rte_port_out_op_tx_bulk)( - void *port, - struct rte_mbuf **pkts, - uint64_t pkts_mask); - -/** - * Output port flush - * - * @param port - * Handle to output port instance - * @return - * 0 on success, error code otherwise - */ -typedef int (*rte_port_out_op_flush)(void *port); - -/** - * Output port stats read - * - * @param port - * Handle to output port instance - * @param stats - * Handle to port_out stats struct to copy data - * @param clear - * Flag indicating that stats should be cleared after read - * - * @return - * Error code or 0 on success. - */ -typedef int (*rte_port_out_op_stats_read)( - void *port, - struct rte_port_out_stats *stats, - int clear); - -/** Output port interface defining the output port operation */ -struct rte_port_out_ops { - rte_port_out_op_create f_create; /**< Create */ - rte_port_out_op_free f_free; /**< Free */ - rte_port_out_op_tx f_tx; /**< Packet TX (single packet) */ - rte_port_out_op_tx_bulk f_tx_bulk; /**< Packet TX (packet burst) */ - rte_port_out_op_flush f_flush; /**< Flush */ - rte_port_out_op_stats_read f_stats; /**< Stats */ -}; - -#endif diff --git a/lib/port/rte_port_ethdev.c b/lib/port/rte_port_ethdev.c deleted file mode 100644 index bdab2fbf6c..0000000000 --- a/lib/port/rte_port_ethdev.c +++ /dev/null @@ -1,530 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2010-2014 Intel Corporation - */ -#include -#include - -#include -#include -#include -#include - -#include "rte_port_ethdev.h" - -#include "port_log.h" - -/* - * Port ETHDEV Reader - */ -#ifdef RTE_PORT_STATS_COLLECT - -#define RTE_PORT_ETHDEV_READER_STATS_PKTS_IN_ADD(port, val) \ - port->stats.n_pkts_in += val -#define RTE_PORT_ETHDEV_READER_STATS_PKTS_DROP_ADD(port, val) \ - port->stats.n_pkts_drop += val - -#else - -#define RTE_PORT_ETHDEV_READER_STATS_PKTS_IN_ADD(port, val) -#define RTE_PORT_ETHDEV_READER_STATS_PKTS_DROP_ADD(port, val) - -#endif - -struct rte_port_ethdev_reader { - struct rte_port_in_stats stats; - - uint16_t queue_id; - uint16_t port_id; -}; - -static void * -rte_port_ethdev_reader_create(void *params, int socket_id) -{ - struct rte_port_ethdev_reader_params *conf = - params; - struct rte_port_ethdev_reader *port; - - /* Check input parameters */ - if (conf == NULL) { - PORT_LOG(ERR, "%s: params is NULL", __func__); - return NULL; - } - - /* Memory allocation */ - port = rte_zmalloc_socket("PORT", sizeof(*port), - RTE_CACHE_LINE_SIZE, socket_id); - if (port == NULL) { - PORT_LOG(ERR, "%s: Failed to allocate port", __func__); - return NULL; - } - - /* Initialization */ - port->port_id = conf->port_id; - port->queue_id = conf->queue_id; - - return port; -} - -static int -rte_port_ethdev_reader_rx(void *port, struct rte_mbuf **pkts, uint32_t n_pkts) -{ - struct rte_port_ethdev_reader *p = - port; - uint16_t rx_pkt_cnt; - - rx_pkt_cnt = rte_eth_rx_burst(p->port_id, p->queue_id, pkts, n_pkts); - RTE_PORT_ETHDEV_READER_STATS_PKTS_IN_ADD(p, rx_pkt_cnt); - return rx_pkt_cnt; -} - -static int -rte_port_ethdev_reader_free(void *port) -{ - if (port == NULL) { - PORT_LOG(ERR, "%s: port is NULL", __func__); - return -EINVAL; - } - - rte_free(port); - - return 0; -} - -static int rte_port_ethdev_reader_stats_read(void *port, - struct rte_port_in_stats *stats, int clear) -{ - struct rte_port_ethdev_reader *p = - port; - - if (stats != NULL) - memcpy(stats, &p->stats, sizeof(p->stats)); - - if (clear) - memset(&p->stats, 0, sizeof(p->stats)); - - return 0; -} - -/* - * Port ETHDEV Writer - */ -#ifdef RTE_PORT_STATS_COLLECT - -#define RTE_PORT_ETHDEV_WRITER_STATS_PKTS_IN_ADD(port, val) \ - port->stats.n_pkts_in += val -#define RTE_PORT_ETHDEV_WRITER_STATS_PKTS_DROP_ADD(port, val) \ - port->stats.n_pkts_drop += val - -#else - -#define RTE_PORT_ETHDEV_WRITER_STATS_PKTS_IN_ADD(port, val) -#define RTE_PORT_ETHDEV_WRITER_STATS_PKTS_DROP_ADD(port, val) - -#endif - -struct rte_port_ethdev_writer { - struct rte_port_out_stats stats; - - struct rte_mbuf *tx_buf[2 * RTE_PORT_IN_BURST_SIZE_MAX]; - uint32_t tx_burst_sz; - uint16_t tx_buf_count; - uint64_t bsz_mask; - uint16_t queue_id; - uint16_t port_id; -}; - -static void * -rte_port_ethdev_writer_create(void *params, int socket_id) -{ - struct rte_port_ethdev_writer_params *conf = - params; - struct rte_port_ethdev_writer *port; - - /* Check input parameters */ - if ((conf == NULL) || - (conf->tx_burst_sz == 0) || - (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) || - (!rte_is_power_of_2(conf->tx_burst_sz))) { - PORT_LOG(ERR, "%s: Invalid input parameters", __func__); - return NULL; - } - - /* Memory allocation */ - port = rte_zmalloc_socket("PORT", sizeof(*port), - RTE_CACHE_LINE_SIZE, socket_id); - if (port == NULL) { - PORT_LOG(ERR, "%s: Failed to allocate port", __func__); - return NULL; - } - - /* Initialization */ - port->port_id = conf->port_id; - port->queue_id = conf->queue_id; - port->tx_burst_sz = conf->tx_burst_sz; - port->tx_buf_count = 0; - port->bsz_mask = 1LLU << (conf->tx_burst_sz - 1); - - return port; -} - -static inline void -send_burst(struct rte_port_ethdev_writer *p) -{ - uint32_t nb_tx; - - nb_tx = rte_eth_tx_burst(p->port_id, p->queue_id, - p->tx_buf, p->tx_buf_count); - - RTE_PORT_ETHDEV_WRITER_STATS_PKTS_DROP_ADD(p, p->tx_buf_count - nb_tx); - for ( ; nb_tx < p->tx_buf_count; nb_tx++) - rte_pktmbuf_free(p->tx_buf[nb_tx]); - - p->tx_buf_count = 0; -} - -static int -rte_port_ethdev_writer_tx(void *port, struct rte_mbuf *pkt) -{ - struct rte_port_ethdev_writer *p = - port; - - p->tx_buf[p->tx_buf_count++] = pkt; - RTE_PORT_ETHDEV_WRITER_STATS_PKTS_IN_ADD(p, 1); - if (p->tx_buf_count >= p->tx_burst_sz) - send_burst(p); - - return 0; -} - -static int -rte_port_ethdev_writer_tx_bulk(void *port, - struct rte_mbuf **pkts, - uint64_t pkts_mask) -{ - struct rte_port_ethdev_writer *p = - port; - uint64_t bsz_mask = p->bsz_mask; - uint32_t tx_buf_count = p->tx_buf_count; - uint64_t expr = (pkts_mask & (pkts_mask + 1)) | - ((pkts_mask & bsz_mask) ^ bsz_mask); - - if (expr == 0) { - uint64_t n_pkts = rte_popcount64(pkts_mask); - uint32_t n_pkts_ok; - - if (tx_buf_count) - send_burst(p); - - RTE_PORT_ETHDEV_WRITER_STATS_PKTS_IN_ADD(p, n_pkts); - n_pkts_ok = rte_eth_tx_burst(p->port_id, p->queue_id, pkts, - n_pkts); - - RTE_PORT_ETHDEV_WRITER_STATS_PKTS_DROP_ADD(p, n_pkts - n_pkts_ok); - for ( ; n_pkts_ok < n_pkts; n_pkts_ok++) { - struct rte_mbuf *pkt = pkts[n_pkts_ok]; - - rte_pktmbuf_free(pkt); - } - } else { - for ( ; pkts_mask; ) { - uint32_t pkt_index = rte_ctz64(pkts_mask); - uint64_t pkt_mask = 1LLU << pkt_index; - struct rte_mbuf *pkt = pkts[pkt_index]; - - p->tx_buf[tx_buf_count++] = pkt; - RTE_PORT_ETHDEV_WRITER_STATS_PKTS_IN_ADD(p, 1); - pkts_mask &= ~pkt_mask; - } - - p->tx_buf_count = tx_buf_count; - if (tx_buf_count >= p->tx_burst_sz) - send_burst(p); - } - - return 0; -} - -static int -rte_port_ethdev_writer_flush(void *port) -{ - struct rte_port_ethdev_writer *p = - port; - - if (p->tx_buf_count > 0) - send_burst(p); - - return 0; -} - -static int -rte_port_ethdev_writer_free(void *port) -{ - if (port == NULL) { - PORT_LOG(ERR, "%s: Port is NULL", __func__); - return -EINVAL; - } - - rte_port_ethdev_writer_flush(port); - rte_free(port); - - return 0; -} - -static int rte_port_ethdev_writer_stats_read(void *port, - struct rte_port_out_stats *stats, int clear) -{ - struct rte_port_ethdev_writer *p = - port; - - if (stats != NULL) - memcpy(stats, &p->stats, sizeof(p->stats)); - - if (clear) - memset(&p->stats, 0, sizeof(p->stats)); - - return 0; -} - -/* - * Port ETHDEV Writer Nodrop - */ -#ifdef RTE_PORT_STATS_COLLECT - -#define RTE_PORT_ETHDEV_WRITER_NODROP_STATS_PKTS_IN_ADD(port, val) \ - port->stats.n_pkts_in += val -#define RTE_PORT_ETHDEV_WRITER_NODROP_STATS_PKTS_DROP_ADD(port, val) \ - port->stats.n_pkts_drop += val - -#else - -#define RTE_PORT_ETHDEV_WRITER_NODROP_STATS_PKTS_IN_ADD(port, val) -#define RTE_PORT_ETHDEV_WRITER_NODROP_STATS_PKTS_DROP_ADD(port, val) - -#endif - -struct rte_port_ethdev_writer_nodrop { - struct rte_port_out_stats stats; - - struct rte_mbuf *tx_buf[2 * RTE_PORT_IN_BURST_SIZE_MAX]; - uint32_t tx_burst_sz; - uint16_t tx_buf_count; - uint64_t bsz_mask; - uint64_t n_retries; - uint16_t queue_id; - uint16_t port_id; -}; - -static void * -rte_port_ethdev_writer_nodrop_create(void *params, int socket_id) -{ - struct rte_port_ethdev_writer_nodrop_params *conf = - params; - struct rte_port_ethdev_writer_nodrop *port; - - /* Check input parameters */ - if ((conf == NULL) || - (conf->tx_burst_sz == 0) || - (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) || - (!rte_is_power_of_2(conf->tx_burst_sz))) { - PORT_LOG(ERR, "%s: Invalid input parameters", __func__); - return NULL; - } - - /* Memory allocation */ - port = rte_zmalloc_socket("PORT", sizeof(*port), - RTE_CACHE_LINE_SIZE, socket_id); - if (port == NULL) { - PORT_LOG(ERR, "%s: Failed to allocate port", __func__); - return NULL; - } - - /* Initialization */ - port->port_id = conf->port_id; - port->queue_id = conf->queue_id; - port->tx_burst_sz = conf->tx_burst_sz; - port->tx_buf_count = 0; - port->bsz_mask = 1LLU << (conf->tx_burst_sz - 1); - - /* - * When n_retries is 0 it means that we should wait for every packet to - * send no matter how many retries should it take. To limit number of - * branches in fast path, we use UINT64_MAX instead of branching. - */ - port->n_retries = (conf->n_retries == 0) ? UINT64_MAX : conf->n_retries; - - return port; -} - -static inline void -send_burst_nodrop(struct rte_port_ethdev_writer_nodrop *p) -{ - uint32_t nb_tx = 0, i; - - nb_tx = rte_eth_tx_burst(p->port_id, p->queue_id, p->tx_buf, - p->tx_buf_count); - - /* We sent all the packets in a first try */ - if (nb_tx >= p->tx_buf_count) { - p->tx_buf_count = 0; - return; - } - - for (i = 0; i < p->n_retries; i++) { - nb_tx += rte_eth_tx_burst(p->port_id, p->queue_id, - p->tx_buf + nb_tx, p->tx_buf_count - nb_tx); - - /* We sent all the packets in more than one try */ - if (nb_tx >= p->tx_buf_count) { - p->tx_buf_count = 0; - return; - } - } - - /* We didn't send the packets in maximum allowed attempts */ - RTE_PORT_ETHDEV_WRITER_NODROP_STATS_PKTS_DROP_ADD(p, p->tx_buf_count - nb_tx); - for ( ; nb_tx < p->tx_buf_count; nb_tx++) - rte_pktmbuf_free(p->tx_buf[nb_tx]); - - p->tx_buf_count = 0; -} - -static int -rte_port_ethdev_writer_nodrop_tx(void *port, struct rte_mbuf *pkt) -{ - struct rte_port_ethdev_writer_nodrop *p = - port; - - p->tx_buf[p->tx_buf_count++] = pkt; - RTE_PORT_ETHDEV_WRITER_NODROP_STATS_PKTS_IN_ADD(p, 1); - if (p->tx_buf_count >= p->tx_burst_sz) - send_burst_nodrop(p); - - return 0; -} - -static int -rte_port_ethdev_writer_nodrop_tx_bulk(void *port, - struct rte_mbuf **pkts, - uint64_t pkts_mask) -{ - struct rte_port_ethdev_writer_nodrop *p = - port; - - uint64_t bsz_mask = p->bsz_mask; - uint32_t tx_buf_count = p->tx_buf_count; - uint64_t expr = (pkts_mask & (pkts_mask + 1)) | - ((pkts_mask & bsz_mask) ^ bsz_mask); - - if (expr == 0) { - uint64_t n_pkts = rte_popcount64(pkts_mask); - uint32_t n_pkts_ok; - - if (tx_buf_count) - send_burst_nodrop(p); - - RTE_PORT_ETHDEV_WRITER_NODROP_STATS_PKTS_IN_ADD(p, n_pkts); - n_pkts_ok = rte_eth_tx_burst(p->port_id, p->queue_id, pkts, - n_pkts); - - if (n_pkts_ok >= n_pkts) - return 0; - - /* - * If we did not manage to send all packets in single burst, - * move remaining packets to the buffer and call send burst. - */ - for (; n_pkts_ok < n_pkts; n_pkts_ok++) { - struct rte_mbuf *pkt = pkts[n_pkts_ok]; - p->tx_buf[p->tx_buf_count++] = pkt; - } - send_burst_nodrop(p); - } else { - for ( ; pkts_mask; ) { - uint32_t pkt_index = rte_ctz64(pkts_mask); - uint64_t pkt_mask = 1LLU << pkt_index; - struct rte_mbuf *pkt = pkts[pkt_index]; - - p->tx_buf[tx_buf_count++] = pkt; - RTE_PORT_ETHDEV_WRITER_NODROP_STATS_PKTS_IN_ADD(p, 1); - pkts_mask &= ~pkt_mask; - } - - p->tx_buf_count = tx_buf_count; - if (tx_buf_count >= p->tx_burst_sz) - send_burst_nodrop(p); - } - - return 0; -} - -static int -rte_port_ethdev_writer_nodrop_flush(void *port) -{ - struct rte_port_ethdev_writer_nodrop *p = - port; - - if (p->tx_buf_count > 0) - send_burst_nodrop(p); - - return 0; -} - -static int -rte_port_ethdev_writer_nodrop_free(void *port) -{ - if (port == NULL) { - PORT_LOG(ERR, "%s: Port is NULL", __func__); - return -EINVAL; - } - - rte_port_ethdev_writer_nodrop_flush(port); - rte_free(port); - - return 0; -} - -static int rte_port_ethdev_writer_nodrop_stats_read(void *port, - struct rte_port_out_stats *stats, int clear) -{ - struct rte_port_ethdev_writer_nodrop *p = - port; - - if (stats != NULL) - memcpy(stats, &p->stats, sizeof(p->stats)); - - if (clear) - memset(&p->stats, 0, sizeof(p->stats)); - - return 0; -} - -/* - * Summary of port operations - */ -RTE_EXPORT_SYMBOL(rte_port_ethdev_reader_ops) -struct rte_port_in_ops rte_port_ethdev_reader_ops = { - .f_create = rte_port_ethdev_reader_create, - .f_free = rte_port_ethdev_reader_free, - .f_rx = rte_port_ethdev_reader_rx, - .f_stats = rte_port_ethdev_reader_stats_read, -}; - -RTE_EXPORT_SYMBOL(rte_port_ethdev_writer_ops) -struct rte_port_out_ops rte_port_ethdev_writer_ops = { - .f_create = rte_port_ethdev_writer_create, - .f_free = rte_port_ethdev_writer_free, - .f_tx = rte_port_ethdev_writer_tx, - .f_tx_bulk = rte_port_ethdev_writer_tx_bulk, - .f_flush = rte_port_ethdev_writer_flush, - .f_stats = rte_port_ethdev_writer_stats_read, -}; - -RTE_EXPORT_SYMBOL(rte_port_ethdev_writer_nodrop_ops) -struct rte_port_out_ops rte_port_ethdev_writer_nodrop_ops = { - .f_create = rte_port_ethdev_writer_nodrop_create, - .f_free = rte_port_ethdev_writer_nodrop_free, - .f_tx = rte_port_ethdev_writer_nodrop_tx, - .f_tx_bulk = rte_port_ethdev_writer_nodrop_tx_bulk, - .f_flush = rte_port_ethdev_writer_nodrop_flush, - .f_stats = rte_port_ethdev_writer_nodrop_stats_read, -}; diff --git a/lib/port/rte_port_ethdev.h b/lib/port/rte_port_ethdev.h deleted file mode 100644 index 7729ff0da3..0000000000 --- a/lib/port/rte_port_ethdev.h +++ /dev/null @@ -1,75 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2010-2014 Intel Corporation - */ - -#ifndef __INCLUDE_RTE_PORT_ETHDEV_H__ -#define __INCLUDE_RTE_PORT_ETHDEV_H__ - -/** - * @file - * RTE Port Ethernet Device - * - * ethdev_reader: input port built on top of pre-initialized NIC RX queue - * ethdev_writer: output port built on top of pre-initialized NIC TX queue - */ - -#include - -#include "rte_port.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** ethdev_reader port parameters */ -struct rte_port_ethdev_reader_params { - /** NIC RX port ID */ - uint16_t port_id; - - /** NIC RX queue ID */ - uint16_t queue_id; -}; - -/** ethdev_reader port operations */ -extern struct rte_port_in_ops rte_port_ethdev_reader_ops; - -/** ethdev_writer port parameters */ -struct rte_port_ethdev_writer_params { - /** NIC RX port ID */ - uint16_t port_id; - - /** NIC RX queue ID */ - uint16_t queue_id; - - /** Recommended burst size to NIC TX queue. The actual burst size can be - bigger or smaller than this value. */ - uint32_t tx_burst_sz; -}; - -/** ethdev_writer port operations */ -extern struct rte_port_out_ops rte_port_ethdev_writer_ops; - -/** ethdev_writer_nodrop port parameters */ -struct rte_port_ethdev_writer_nodrop_params { - /** NIC RX port ID */ - uint16_t port_id; - - /** NIC RX queue ID */ - uint16_t queue_id; - - /** Recommended burst size to NIC TX queue. The actual burst size can be - bigger or smaller than this value. */ - uint32_t tx_burst_sz; - - /** Maximum number of retries, 0 for no limit */ - uint32_t n_retries; -}; - -/** ethdev_writer_nodrop port operations */ -extern struct rte_port_out_ops rte_port_ethdev_writer_nodrop_ops; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/port/rte_port_eventdev.c b/lib/port/rte_port_eventdev.c deleted file mode 100644 index c3a287b834..0000000000 --- a/lib/port/rte_port_eventdev.c +++ /dev/null @@ -1,590 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2019 Intel Corporation - */ - -#include -#include - -#include -#include -#include - -#include "rte_port_eventdev.h" - -#include "port_log.h" - -/* - * Port EVENTDEV Reader - */ -#ifdef RTE_PORT_STATS_COLLECT - -#define RTE_PORT_EVENTDEV_READER_STATS_PKTS_IN_ADD(port, val) \ - do {port->stats.n_pkts_in += val;} while (0) -#define RTE_PORT_EVENTDEV_READER_STATS_PKTS_DROP_ADD(port, val) \ - do {port->stats.n_pkts_drop += val;} while (0) - -#else - -#define RTE_PORT_EVENTDEV_READER_STATS_PKTS_IN_ADD(port, val) -#define RTE_PORT_EVENTDEV_READER_STATS_PKTS_DROP_ADD(port, val) - -#endif - -struct rte_port_eventdev_reader { - struct rte_port_in_stats stats; - - uint8_t eventdev_id; - uint16_t port_id; - - struct rte_event ev[RTE_PORT_IN_BURST_SIZE_MAX]; -}; - -static void * -rte_port_eventdev_reader_create(void *params, int socket_id) -{ - struct rte_port_eventdev_reader_params *conf = - params; - struct rte_port_eventdev_reader *port; - - /* Check input parameters */ - if (conf == NULL) { - PORT_LOG(ERR, "%s: params is NULL", __func__); - return NULL; - } - - /* Memory allocation */ - port = rte_zmalloc_socket("PORT", sizeof(*port), - RTE_CACHE_LINE_SIZE, socket_id); - if (port == NULL) { - PORT_LOG(ERR, "%s: Failed to allocate port", __func__); - return NULL; - } - - /* Initialization */ - port->eventdev_id = conf->eventdev_id; - port->port_id = conf->port_id; - - return port; -} - -static int -rte_port_eventdev_reader_rx(void *port, struct rte_mbuf **pkts, uint32_t n_pkts) -{ - struct rte_port_eventdev_reader *p = port; - uint16_t rx_evts_cnt, i; - - rx_evts_cnt = rte_event_dequeue_burst(p->eventdev_id, p->port_id, - p->ev, n_pkts, 0); - - for (i = 0; i < rx_evts_cnt; i++) - pkts[i] = p->ev[i].mbuf; - - RTE_PORT_EVENTDEV_READER_STATS_PKTS_IN_ADD(p, rx_evts_cnt); - - return rx_evts_cnt; -} - -static int -rte_port_eventdev_reader_free(void *port) -{ - if (port == NULL) { - PORT_LOG(ERR, "%s: port is NULL", __func__); - return -EINVAL; - } - - rte_free(port); - - return 0; -} - -static int rte_port_eventdev_reader_stats_read(void *port, - struct rte_port_in_stats *stats, int clear) -{ - struct rte_port_eventdev_reader *p = - port; - - if (stats != NULL) - memcpy(stats, &p->stats, sizeof(p->stats)); - - if (clear) - memset(&p->stats, 0, sizeof(p->stats)); - - return 0; -} - -/* - * Port EVENTDEV Writer - */ -#ifdef RTE_PORT_STATS_COLLECT - -#define RTE_PORT_EVENTDEV_WRITER_STATS_PKTS_IN_ADD(port, val) \ - do {port->stats.n_pkts_in += val;} while (0) -#define RTE_PORT_EVENTDEV_WRITER_STATS_PKTS_DROP_ADD(port, val) \ - do {port->stats.n_pkts_drop += val;} while (0) - -#else - -#define RTE_PORT_EVENTDEV_WRITER_STATS_PKTS_IN_ADD(port, val) -#define RTE_PORT_EVENTDEV_WRITER_STATS_PKTS_DROP_ADD(port, val) - -#endif - -struct rte_port_eventdev_writer { - struct rte_port_out_stats stats; - - struct rte_event ev[2 * RTE_PORT_IN_BURST_SIZE_MAX]; - - uint32_t enq_burst_sz; - uint32_t enq_buf_count; - uint64_t bsz_mask; - - uint8_t eventdev_id; - uint8_t port_id; - uint8_t queue_id; - uint8_t sched_type; - uint8_t evt_op; -}; - -static void * -rte_port_eventdev_writer_create(void *params, int socket_id) -{ - struct rte_port_eventdev_writer_params *conf = - params; - struct rte_port_eventdev_writer *port; - unsigned int i; - - /* Check input parameters */ - if ((conf == NULL) || - (conf->enq_burst_sz == 0) || - (conf->enq_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) || - (!rte_is_power_of_2(conf->enq_burst_sz))) { - PORT_LOG(ERR, "%s: Invalid input parameters", __func__); - return NULL; - } - - /* Memory allocation */ - port = rte_zmalloc_socket("PORT", sizeof(*port), - RTE_CACHE_LINE_SIZE, socket_id); - if (port == NULL) { - PORT_LOG(ERR, "%s: Failed to allocate port", __func__); - return NULL; - } - - /* Initialization */ - port->enq_burst_sz = conf->enq_burst_sz; - port->enq_buf_count = 0; - port->bsz_mask = 1LLU << (conf->enq_burst_sz - 1); - - port->eventdev_id = conf->eventdev_id; - port->port_id = conf->port_id; - port->queue_id = conf->queue_id; - port->sched_type = conf->sched_type; - port->evt_op = conf->evt_op; - memset(&port->ev, 0, sizeof(port->ev)); - - for (i = 0; i < RTE_DIM(port->ev); i++) { - port->ev[i].queue_id = port->queue_id; - port->ev[i].sched_type = port->sched_type; - port->ev[i].op = port->evt_op; - } - - return port; -} - -static inline void -send_burst(struct rte_port_eventdev_writer *p) -{ - uint32_t nb_enq; - - nb_enq = rte_event_enqueue_burst(p->eventdev_id, p->port_id, - p->ev, p->enq_buf_count); - - RTE_PORT_EVENTDEV_WRITER_STATS_PKTS_DROP_ADD(p, p->enq_buf_count - - nb_enq); - - for (; nb_enq < p->enq_buf_count; nb_enq++) - rte_pktmbuf_free(p->ev[nb_enq].mbuf); - - p->enq_buf_count = 0; -} - -static int -rte_port_eventdev_writer_tx(void *port, struct rte_mbuf *pkt) -{ - struct rte_port_eventdev_writer *p = port; - - p->ev[p->enq_buf_count++].mbuf = pkt; - RTE_PORT_EVENTDEV_WRITER_STATS_PKTS_IN_ADD(p, 1); - if (p->enq_buf_count >= p->enq_burst_sz) - send_burst(p); - - return 0; -} - -static int -rte_port_eventdev_writer_tx_bulk(void *port, - struct rte_mbuf **pkts, - uint64_t pkts_mask) -{ - struct rte_port_eventdev_writer *p = - port; - uint64_t bsz_mask = p->bsz_mask; - uint32_t enq_buf_count = p->enq_buf_count; - uint64_t expr = (pkts_mask & (pkts_mask + 1)) | - ((pkts_mask & bsz_mask) ^ bsz_mask); - - if (expr == 0) { - uint64_t n_pkts = rte_popcount64(pkts_mask); - uint32_t i, n_enq_ok; - - if (enq_buf_count) - send_burst(p); - - RTE_PORT_EVENTDEV_WRITER_STATS_PKTS_IN_ADD(p, n_pkts); - - struct rte_event events[2 * RTE_PORT_IN_BURST_SIZE_MAX] = {}; - for (i = 0; i < n_pkts; i++) { - events[i].mbuf = pkts[i]; - events[i].queue_id = p->queue_id; - events[i].sched_type = p->sched_type; - events[i].op = p->evt_op; - } - - n_enq_ok = rte_event_enqueue_burst(p->eventdev_id, p->port_id, - events, n_pkts); - - RTE_PORT_EVENTDEV_WRITER_STATS_PKTS_DROP_ADD(p, - n_pkts - n_enq_ok); - for (; n_enq_ok < n_pkts; n_enq_ok++) - rte_pktmbuf_free(pkts[n_enq_ok]); - - } else { - for (; pkts_mask;) { - uint32_t pkt_index = rte_ctz64(pkts_mask); - uint64_t pkt_mask = 1LLU << pkt_index; - - p->ev[enq_buf_count++].mbuf = pkts[pkt_index]; - - RTE_PORT_EVENTDEV_WRITER_STATS_PKTS_IN_ADD(p, 1); - pkts_mask &= ~pkt_mask; - } - - p->enq_buf_count = enq_buf_count; - if (enq_buf_count >= p->enq_burst_sz) - send_burst(p); - } - - return 0; -} - -static int -rte_port_eventdev_writer_flush(void *port) -{ - struct rte_port_eventdev_writer *p = - port; - - if (p->enq_buf_count > 0) - send_burst(p); - - return 0; -} - -static int -rte_port_eventdev_writer_free(void *port) -{ - if (port == NULL) { - PORT_LOG(ERR, "%s: Port is NULL", __func__); - return -EINVAL; - } - - rte_port_eventdev_writer_flush(port); - rte_free(port); - - return 0; -} - -static int rte_port_eventdev_writer_stats_read(void *port, - struct rte_port_out_stats *stats, int clear) -{ - struct rte_port_eventdev_writer *p = - port; - - if (stats != NULL) - memcpy(stats, &p->stats, sizeof(p->stats)); - - if (clear) - memset(&p->stats, 0, sizeof(p->stats)); - - return 0; -} - -/* - * Port EVENTDEV Writer Nodrop - */ -#ifdef RTE_PORT_STATS_COLLECT - -#define RTE_PORT_EVENTDEV_WRITER_NODROP_STATS_PKTS_IN_ADD(port, val) \ - do {port->stats.n_pkts_in += val;} while (0) -#define RTE_PORT_EVENTDEV_WRITER_NODROP_STATS_PKTS_DROP_ADD(port, val) \ - do {port->stats.n_pkts_drop += val;} while (0) - -#else - -#define RTE_PORT_EVENTDEV_WRITER_NODROP_STATS_PKTS_IN_ADD(port, val) -#define RTE_PORT_EVENTDEV_WRITER_NODROP_STATS_PKTS_DROP_ADD(port, val) - -#endif - -struct rte_port_eventdev_writer_nodrop { - struct rte_port_out_stats stats; - - struct rte_event ev[2 * RTE_PORT_IN_BURST_SIZE_MAX]; - - uint32_t enq_burst_sz; - uint32_t enq_buf_count; - uint64_t bsz_mask; - uint64_t n_retries; - uint8_t eventdev_id; - uint8_t port_id; - uint8_t queue_id; - uint8_t sched_type; - uint8_t evt_op; -}; - - -static void * -rte_port_eventdev_writer_nodrop_create(void *params, int socket_id) -{ - struct rte_port_eventdev_writer_nodrop_params *conf = - params; - struct rte_port_eventdev_writer_nodrop *port; - unsigned int i; - - /* Check input parameters */ - if ((conf == NULL) || - (conf->enq_burst_sz == 0) || - (conf->enq_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) || - (!rte_is_power_of_2(conf->enq_burst_sz))) { - PORT_LOG(ERR, "%s: Invalid input parameters", __func__); - return NULL; - } - - /* Memory allocation */ - port = rte_zmalloc_socket("PORT", sizeof(*port), - RTE_CACHE_LINE_SIZE, socket_id); - if (port == NULL) { - PORT_LOG(ERR, "%s: Failed to allocate port", __func__); - return NULL; - } - - /* Initialization */ - port->enq_burst_sz = conf->enq_burst_sz; - port->enq_buf_count = 0; - port->bsz_mask = 1LLU << (conf->enq_burst_sz - 1); - - port->eventdev_id = conf->eventdev_id; - port->port_id = conf->port_id; - port->queue_id = conf->queue_id; - port->sched_type = conf->sched_type; - port->evt_op = conf->evt_op; - memset(&port->ev, 0, sizeof(port->ev)); - - for (i = 0; i < RTE_DIM(port->ev); i++) { - port->ev[i].queue_id = port->queue_id; - port->ev[i].sched_type = port->sched_type; - port->ev[i].op = port->evt_op; - } - /* - * When n_retries is 0 it means that we should wait for every event to - * send no matter how many retries should it take. To limit number of - * branches in fast path, we use UINT64_MAX instead of branching. - */ - port->n_retries = (conf->n_retries == 0) ? UINT64_MAX : conf->n_retries; - - return port; -} - -static inline void -send_burst_nodrop(struct rte_port_eventdev_writer_nodrop *p) -{ - uint32_t nb_enq, i; - - nb_enq = rte_event_enqueue_burst(p->eventdev_id, p->port_id, - p->ev, p->enq_buf_count); - - /* We sent all the packets in a first try */ - if (nb_enq >= p->enq_buf_count) { - p->enq_buf_count = 0; - return; - } - - for (i = 0; i < p->n_retries; i++) { - nb_enq += rte_event_enqueue_burst(p->eventdev_id, p->port_id, - p->ev + nb_enq, - p->enq_buf_count - nb_enq); - - /* We sent all the events in more than one try */ - if (nb_enq >= p->enq_buf_count) { - p->enq_buf_count = 0; - return; - } - } - /* We didn't send the events in maximum allowed attempts */ - RTE_PORT_EVENTDEV_WRITER_NODROP_STATS_PKTS_DROP_ADD(p, - p->enq_buf_count - nb_enq); - for (; nb_enq < p->enq_buf_count; nb_enq++) - rte_pktmbuf_free(p->ev[nb_enq].mbuf); - - p->enq_buf_count = 0; -} - -static int -rte_port_eventdev_writer_nodrop_tx(void *port, struct rte_mbuf *pkt) -{ - struct rte_port_eventdev_writer_nodrop *p = port; - - p->ev[p->enq_buf_count++].mbuf = pkt; - - RTE_PORT_EVENTDEV_WRITER_NODROP_STATS_PKTS_IN_ADD(p, 1); - if (p->enq_buf_count >= p->enq_burst_sz) - send_burst_nodrop(p); - - return 0; -} - -static int -rte_port_eventdev_writer_nodrop_tx_bulk(void *port, - struct rte_mbuf **pkts, - uint64_t pkts_mask) -{ - struct rte_port_eventdev_writer_nodrop *p = - port; - - uint64_t bsz_mask = p->bsz_mask; - uint32_t enq_buf_count = p->enq_buf_count; - uint64_t expr = (pkts_mask & (pkts_mask + 1)) | - ((pkts_mask & bsz_mask) ^ bsz_mask); - - if (expr == 0) { - uint64_t n_pkts = rte_popcount64(pkts_mask); - uint32_t i, n_enq_ok; - - if (enq_buf_count) - send_burst_nodrop(p); - - RTE_PORT_EVENTDEV_WRITER_NODROP_STATS_PKTS_IN_ADD(p, n_pkts); - - struct rte_event events[RTE_PORT_IN_BURST_SIZE_MAX] = {}; - - for (i = 0; i < n_pkts; i++) { - events[i].mbuf = pkts[i]; - events[i].queue_id = p->queue_id; - events[i].sched_type = p->sched_type; - events[i].op = p->evt_op; - } - - n_enq_ok = rte_event_enqueue_burst(p->eventdev_id, p->port_id, - events, n_pkts); - - if (n_enq_ok >= n_pkts) - return 0; - - /* - * If we did not manage to enqueue all events in single burst, - * move remaining events to the buffer and call send burst. - */ - for (; n_enq_ok < n_pkts; n_enq_ok++) { - struct rte_mbuf *pkt = pkts[n_enq_ok]; - p->ev[p->enq_buf_count++].mbuf = pkt; - } - send_burst_nodrop(p); - } else { - for (; pkts_mask;) { - uint32_t pkt_index = rte_ctz64(pkts_mask); - uint64_t pkt_mask = 1LLU << pkt_index; - - p->ev[enq_buf_count++].mbuf = pkts[pkt_index]; - - RTE_PORT_EVENTDEV_WRITER_STATS_PKTS_IN_ADD(p, 1); - pkts_mask &= ~pkt_mask; - } - - p->enq_buf_count = enq_buf_count; - if (enq_buf_count >= p->enq_burst_sz) - send_burst_nodrop(p); - } - - return 0; -} - -static int -rte_port_eventdev_writer_nodrop_flush(void *port) -{ - struct rte_port_eventdev_writer_nodrop *p = - port; - - if (p->enq_buf_count > 0) - send_burst_nodrop(p); - - return 0; -} - -static int -rte_port_eventdev_writer_nodrop_free(void *port) -{ - if (port == NULL) { - PORT_LOG(ERR, "%s: Port is NULL", __func__); - return -EINVAL; - } - - rte_port_eventdev_writer_nodrop_flush(port); - rte_free(port); - - return 0; -} - -static int rte_port_eventdev_writer_nodrop_stats_read(void *port, - struct rte_port_out_stats *stats, int clear) -{ - struct rte_port_eventdev_writer_nodrop *p = - port; - - if (stats != NULL) - memcpy(stats, &p->stats, sizeof(p->stats)); - - if (clear) - memset(&p->stats, 0, sizeof(p->stats)); - - return 0; -} - -/* - * Summary of port operations - */ -RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_port_eventdev_reader_ops, 19.11) -struct rte_port_in_ops rte_port_eventdev_reader_ops = { - .f_create = rte_port_eventdev_reader_create, - .f_free = rte_port_eventdev_reader_free, - .f_rx = rte_port_eventdev_reader_rx, - .f_stats = rte_port_eventdev_reader_stats_read, -}; - -RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_port_eventdev_writer_ops, 19.11) -struct rte_port_out_ops rte_port_eventdev_writer_ops = { - .f_create = rte_port_eventdev_writer_create, - .f_free = rte_port_eventdev_writer_free, - .f_tx = rte_port_eventdev_writer_tx, - .f_tx_bulk = rte_port_eventdev_writer_tx_bulk, - .f_flush = rte_port_eventdev_writer_flush, - .f_stats = rte_port_eventdev_writer_stats_read, -}; - -RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_port_eventdev_writer_nodrop_ops, 19.11) -struct rte_port_out_ops rte_port_eventdev_writer_nodrop_ops = { - .f_create = rte_port_eventdev_writer_nodrop_create, - .f_free = rte_port_eventdev_writer_nodrop_free, - .f_tx = rte_port_eventdev_writer_nodrop_tx, - .f_tx_bulk = rte_port_eventdev_writer_nodrop_tx_bulk, - .f_flush = rte_port_eventdev_writer_nodrop_flush, - .f_stats = rte_port_eventdev_writer_nodrop_stats_read, -}; diff --git a/lib/port/rte_port_eventdev.h b/lib/port/rte_port_eventdev.h deleted file mode 100644 index d9eccf07d4..0000000000 --- a/lib/port/rte_port_eventdev.h +++ /dev/null @@ -1,94 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2019 Intel Corporation - */ - -#ifndef __INCLUDE_RTE_PORT_EVENTDEV_H__ -#define __INCLUDE_RTE_PORT_EVENTDEV_H__ - -/** - * @file - * RTE Port Eventdev Interface - * - * eventdev_reader: input port built on top of pre-initialized eventdev - * interface - * eventdev_writer: output port built on top of pre-initialized eventdev - * interface - */ - -#include -#include - -#include "rte_port.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** Eventdev_reader port parameters */ -struct rte_port_eventdev_reader_params { - /** Eventdev Device ID */ - uint8_t eventdev_id; - - /** Eventdev Port ID */ - uint8_t port_id; -}; - -/** Eventdev_reader port operations. */ -extern struct rte_port_in_ops rte_port_eventdev_reader_ops; - -/** Eventdev_writer port parameters. */ -struct rte_port_eventdev_writer_params { - /** Eventdev Device ID. */ - uint8_t eventdev_id; - - /** Eventdev Port ID. */ - uint8_t port_id; - - /** Eventdev Queue ID. */ - uint8_t queue_id; - - /** Burst size to eventdev interface. */ - uint32_t enq_burst_sz; - - /** Scheduler synchronization type (RTE_SCHED_TYPE_*)*/ - uint8_t sched_type; - - /** The type of eventdev enqueue operation - new/forward/release */ - uint8_t evt_op; -}; - -/** Eventdev_writer port operations. */ -extern struct rte_port_out_ops rte_port_eventdev_writer_ops; - -/** Event_writer_nodrop port parameters. */ -struct rte_port_eventdev_writer_nodrop_params { - /** Eventdev Device ID. */ - uint8_t eventdev_id; - - /** Eventdev Port ID. */ - uint16_t port_id; - - /** Eventdev Queue ID. */ - uint16_t queue_id; - - /** Burst size to eventdev interface. */ - uint32_t enq_burst_sz; - - /** Scheduler synchronization type (RTE_SCHED_TYPE_*)*/ - uint8_t sched_type; - - /** The type of eventdev enqueue operation - new/forward/release */ - uint8_t evt_op; - - /** Maximum number of retries, 0 for no limit. */ - uint32_t n_retries; -}; - -/** Eventdev_writer_nodrop port operations. */ -extern struct rte_port_out_ops rte_port_eventdev_writer_nodrop_ops; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/port/rte_port_fd.c b/lib/port/rte_port_fd.c deleted file mode 100644 index dbc9efef1b..0000000000 --- a/lib/port/rte_port_fd.c +++ /dev/null @@ -1,524 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2016 Intel Corporation - */ -#include -#include -#include - -#include -#include -#include - -#include "rte_port_fd.h" - -#include "port_log.h" - -/* - * Port FD Reader - */ -#ifdef RTE_PORT_STATS_COLLECT - -#define RTE_PORT_FD_READER_STATS_PKTS_IN_ADD(port, val) \ - do { port->stats.n_pkts_in += val; } while (0) -#define RTE_PORT_FD_READER_STATS_PKTS_DROP_ADD(port, val) \ - do { port->stats.n_pkts_drop += val; } while (0) - -#else - -#define RTE_PORT_FD_READER_STATS_PKTS_IN_ADD(port, val) -#define RTE_PORT_FD_READER_STATS_PKTS_DROP_ADD(port, val) - -#endif - -struct rte_port_fd_reader { - struct rte_port_in_stats stats; - int fd; - uint32_t mtu; - struct rte_mempool *mempool; -}; - -static void * -rte_port_fd_reader_create(void *params, int socket_id) -{ - struct rte_port_fd_reader_params *conf = - params; - struct rte_port_fd_reader *port; - - /* Check input parameters */ - if (conf == NULL) { - PORT_LOG(ERR, "%s: params is NULL", __func__); - return NULL; - } - if (conf->fd < 0) { - PORT_LOG(ERR, "%s: Invalid file descriptor", __func__); - return NULL; - } - if (conf->mtu == 0) { - PORT_LOG(ERR, "%s: Invalid MTU", __func__); - return NULL; - } - if (conf->mempool == NULL) { - PORT_LOG(ERR, "%s: Invalid mempool", __func__); - return NULL; - } - - /* Memory allocation */ - port = rte_zmalloc_socket("PORT", sizeof(*port), - RTE_CACHE_LINE_SIZE, socket_id); - if (port == NULL) { - PORT_LOG(ERR, "%s: Failed to allocate port", __func__); - return NULL; - } - - /* Initialization */ - port->fd = conf->fd; - port->mtu = conf->mtu; - port->mempool = conf->mempool; - - return port; -} - -static int -rte_port_fd_reader_rx(void *port, struct rte_mbuf **pkts, uint32_t n_pkts) -{ - struct rte_port_fd_reader *p = port; - uint32_t i, j; - - if (rte_pktmbuf_alloc_bulk(p->mempool, pkts, n_pkts) != 0) - return 0; - - for (i = 0; i < n_pkts; i++) { - struct rte_mbuf *pkt = pkts[i]; - void *pkt_data = rte_pktmbuf_mtod(pkt, void *); - ssize_t n_bytes; - - n_bytes = read(p->fd, pkt_data, (size_t) p->mtu); - if (n_bytes <= 0) - break; - - pkt->data_len = n_bytes; - pkt->pkt_len = n_bytes; - } - - for (j = i; j < n_pkts; j++) - rte_pktmbuf_free(pkts[j]); - - RTE_PORT_FD_READER_STATS_PKTS_IN_ADD(p, i); - - return i; -} - -static int -rte_port_fd_reader_free(void *port) -{ - if (port == NULL) { - PORT_LOG(ERR, "%s: port is NULL", __func__); - return -EINVAL; - } - - rte_free(port); - - return 0; -} - -static int rte_port_fd_reader_stats_read(void *port, - struct rte_port_in_stats *stats, int clear) -{ - struct rte_port_fd_reader *p = - port; - - if (stats != NULL) - memcpy(stats, &p->stats, sizeof(p->stats)); - - if (clear) - memset(&p->stats, 0, sizeof(p->stats)); - - return 0; -} - -/* - * Port FD Writer - */ -#ifdef RTE_PORT_STATS_COLLECT - -#define RTE_PORT_FD_WRITER_STATS_PKTS_IN_ADD(port, val) \ - do { port->stats.n_pkts_in += val; } while (0) -#define RTE_PORT_FD_WRITER_STATS_PKTS_DROP_ADD(port, val) \ - do { port->stats.n_pkts_drop += val; } while (0) - -#else - -#define RTE_PORT_FD_WRITER_STATS_PKTS_IN_ADD(port, val) -#define RTE_PORT_FD_WRITER_STATS_PKTS_DROP_ADD(port, val) - -#endif - -struct rte_port_fd_writer { - struct rte_port_out_stats stats; - - struct rte_mbuf *tx_buf[2 * RTE_PORT_IN_BURST_SIZE_MAX]; - uint32_t tx_burst_sz; - uint16_t tx_buf_count; - uint32_t fd; -}; - -static void * -rte_port_fd_writer_create(void *params, int socket_id) -{ - struct rte_port_fd_writer_params *conf = - params; - struct rte_port_fd_writer *port; - - /* Check input parameters */ - if ((conf == NULL) || - (conf->tx_burst_sz == 0) || - (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) || - (!rte_is_power_of_2(conf->tx_burst_sz))) { - PORT_LOG(ERR, "%s: Invalid input parameters", __func__); - return NULL; - } - - /* Memory allocation */ - port = rte_zmalloc_socket("PORT", sizeof(*port), - RTE_CACHE_LINE_SIZE, socket_id); - if (port == NULL) { - PORT_LOG(ERR, "%s: Failed to allocate port", __func__); - return NULL; - } - - /* Initialization */ - port->fd = conf->fd; - port->tx_burst_sz = conf->tx_burst_sz; - port->tx_buf_count = 0; - - return port; -} - -static inline void -send_burst(struct rte_port_fd_writer *p) -{ - uint32_t i; - - for (i = 0; i < p->tx_buf_count; i++) { - struct rte_mbuf *pkt = p->tx_buf[i]; - void *pkt_data = rte_pktmbuf_mtod(pkt, void*); - size_t n_bytes = rte_pktmbuf_data_len(pkt); - ssize_t ret; - - ret = write(p->fd, pkt_data, n_bytes); - if (ret < 0) - break; - } - - RTE_PORT_FD_WRITER_STATS_PKTS_DROP_ADD(p, p->tx_buf_count - i); - - for (i = 0; i < p->tx_buf_count; i++) - rte_pktmbuf_free(p->tx_buf[i]); - - p->tx_buf_count = 0; -} - -static int -rte_port_fd_writer_tx(void *port, struct rte_mbuf *pkt) -{ - struct rte_port_fd_writer *p = - port; - - p->tx_buf[p->tx_buf_count++] = pkt; - RTE_PORT_FD_WRITER_STATS_PKTS_IN_ADD(p, 1); - if (p->tx_buf_count >= p->tx_burst_sz) - send_burst(p); - - return 0; -} - -static int -rte_port_fd_writer_tx_bulk(void *port, - struct rte_mbuf **pkts, - uint64_t pkts_mask) -{ - struct rte_port_fd_writer *p = - port; - uint32_t tx_buf_count = p->tx_buf_count; - - if ((pkts_mask & (pkts_mask + 1)) == 0) { - uint64_t n_pkts = rte_popcount64(pkts_mask); - uint32_t i; - - for (i = 0; i < n_pkts; i++) - p->tx_buf[tx_buf_count++] = pkts[i]; - RTE_PORT_FD_WRITER_STATS_PKTS_IN_ADD(p, n_pkts); - } else - for ( ; pkts_mask; ) { - uint32_t pkt_index = rte_ctz64(pkts_mask); - uint64_t pkt_mask = 1LLU << pkt_index; - struct rte_mbuf *pkt = pkts[pkt_index]; - - p->tx_buf[tx_buf_count++] = pkt; - RTE_PORT_FD_WRITER_STATS_PKTS_IN_ADD(p, 1); - pkts_mask &= ~pkt_mask; - } - - p->tx_buf_count = tx_buf_count; - if (tx_buf_count >= p->tx_burst_sz) - send_burst(p); - - return 0; -} - -static int -rte_port_fd_writer_flush(void *port) -{ - struct rte_port_fd_writer *p = - port; - - if (p->tx_buf_count > 0) - send_burst(p); - - return 0; -} - -static int -rte_port_fd_writer_free(void *port) -{ - if (port == NULL) { - PORT_LOG(ERR, "%s: Port is NULL", __func__); - return -EINVAL; - } - - rte_port_fd_writer_flush(port); - rte_free(port); - - return 0; -} - -static int rte_port_fd_writer_stats_read(void *port, - struct rte_port_out_stats *stats, int clear) -{ - struct rte_port_fd_writer *p = - port; - - if (stats != NULL) - memcpy(stats, &p->stats, sizeof(p->stats)); - - if (clear) - memset(&p->stats, 0, sizeof(p->stats)); - - return 0; -} - -/* - * Port FD Writer Nodrop - */ -#ifdef RTE_PORT_STATS_COLLECT - -#define RTE_PORT_FD_WRITER_NODROP_STATS_PKTS_IN_ADD(port, val) \ - do { port->stats.n_pkts_in += val; } while (0) -#define RTE_PORT_FD_WRITER_NODROP_STATS_PKTS_DROP_ADD(port, val) \ - do { port->stats.n_pkts_drop += val; } while (0) - -#else - -#define RTE_PORT_FD_WRITER_NODROP_STATS_PKTS_IN_ADD(port, val) -#define RTE_PORT_FD_WRITER_NODROP_STATS_PKTS_DROP_ADD(port, val) - -#endif - -struct rte_port_fd_writer_nodrop { - struct rte_port_out_stats stats; - - struct rte_mbuf *tx_buf[2 * RTE_PORT_IN_BURST_SIZE_MAX]; - uint32_t tx_burst_sz; - uint16_t tx_buf_count; - uint64_t n_retries; - uint32_t fd; -}; - -static void * -rte_port_fd_writer_nodrop_create(void *params, int socket_id) -{ - struct rte_port_fd_writer_nodrop_params *conf = - params; - struct rte_port_fd_writer_nodrop *port; - - /* Check input parameters */ - if ((conf == NULL) || - (conf->fd < 0) || - (conf->tx_burst_sz == 0) || - (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) || - (!rte_is_power_of_2(conf->tx_burst_sz))) { - PORT_LOG(ERR, "%s: Invalid input parameters", __func__); - return NULL; - } - - /* Memory allocation */ - port = rte_zmalloc_socket("PORT", sizeof(*port), - RTE_CACHE_LINE_SIZE, socket_id); - if (port == NULL) { - PORT_LOG(ERR, "%s: Failed to allocate port", __func__); - return NULL; - } - - /* Initialization */ - port->fd = conf->fd; - port->tx_burst_sz = conf->tx_burst_sz; - port->tx_buf_count = 0; - - /* - * When n_retries is 0 it means that we should wait for every packet to - * send no matter how many retries should it take. To limit number of - * branches in fast path, we use UINT64_MAX instead of branching. - */ - port->n_retries = (conf->n_retries == 0) ? UINT64_MAX : conf->n_retries; - - return port; -} - -static inline void -send_burst_nodrop(struct rte_port_fd_writer_nodrop *p) -{ - uint64_t n_retries; - uint32_t i; - - n_retries = 0; - for (i = 0; (i < p->tx_buf_count) && (n_retries < p->n_retries); i++) { - struct rte_mbuf *pkt = p->tx_buf[i]; - void *pkt_data = rte_pktmbuf_mtod(pkt, void*); - size_t n_bytes = rte_pktmbuf_data_len(pkt); - - for ( ; n_retries < p->n_retries; n_retries++) { - ssize_t ret; - - ret = write(p->fd, pkt_data, n_bytes); - if (ret) - break; - } - } - - RTE_PORT_FD_WRITER_NODROP_STATS_PKTS_DROP_ADD(p, p->tx_buf_count - i); - - for (i = 0; i < p->tx_buf_count; i++) - rte_pktmbuf_free(p->tx_buf[i]); - - p->tx_buf_count = 0; -} - -static int -rte_port_fd_writer_nodrop_tx(void *port, struct rte_mbuf *pkt) -{ - struct rte_port_fd_writer_nodrop *p = - port; - - p->tx_buf[p->tx_buf_count++] = pkt; - RTE_PORT_FD_WRITER_NODROP_STATS_PKTS_IN_ADD(p, 1); - if (p->tx_buf_count >= p->tx_burst_sz) - send_burst_nodrop(p); - - return 0; -} - -static int -rte_port_fd_writer_nodrop_tx_bulk(void *port, - struct rte_mbuf **pkts, - uint64_t pkts_mask) -{ - struct rte_port_fd_writer_nodrop *p = - port; - uint32_t tx_buf_count = p->tx_buf_count; - - if ((pkts_mask & (pkts_mask + 1)) == 0) { - uint64_t n_pkts = rte_popcount64(pkts_mask); - uint32_t i; - - for (i = 0; i < n_pkts; i++) - p->tx_buf[tx_buf_count++] = pkts[i]; - RTE_PORT_FD_WRITER_NODROP_STATS_PKTS_IN_ADD(p, n_pkts); - } else - for ( ; pkts_mask; ) { - uint32_t pkt_index = rte_ctz64(pkts_mask); - uint64_t pkt_mask = 1LLU << pkt_index; - struct rte_mbuf *pkt = pkts[pkt_index]; - - p->tx_buf[tx_buf_count++] = pkt; - RTE_PORT_FD_WRITER_NODROP_STATS_PKTS_IN_ADD(p, 1); - pkts_mask &= ~pkt_mask; - } - - p->tx_buf_count = tx_buf_count; - if (tx_buf_count >= p->tx_burst_sz) - send_burst_nodrop(p); - - return 0; -} - -static int -rte_port_fd_writer_nodrop_flush(void *port) -{ - struct rte_port_fd_writer_nodrop *p = - port; - - if (p->tx_buf_count > 0) - send_burst_nodrop(p); - - return 0; -} - -static int -rte_port_fd_writer_nodrop_free(void *port) -{ - if (port == NULL) { - PORT_LOG(ERR, "%s: Port is NULL", __func__); - return -EINVAL; - } - - rte_port_fd_writer_nodrop_flush(port); - rte_free(port); - -return 0; -} - -static int rte_port_fd_writer_nodrop_stats_read(void *port, - struct rte_port_out_stats *stats, int clear) -{ - struct rte_port_fd_writer_nodrop *p = - port; - - if (stats != NULL) - memcpy(stats, &p->stats, sizeof(p->stats)); - - if (clear) - memset(&p->stats, 0, sizeof(p->stats)); - - return 0; -} - -/* - * Summary of port operations - */ -RTE_EXPORT_SYMBOL(rte_port_fd_reader_ops) -struct rte_port_in_ops rte_port_fd_reader_ops = { - .f_create = rte_port_fd_reader_create, - .f_free = rte_port_fd_reader_free, - .f_rx = rte_port_fd_reader_rx, - .f_stats = rte_port_fd_reader_stats_read, -}; - -RTE_EXPORT_SYMBOL(rte_port_fd_writer_ops) -struct rte_port_out_ops rte_port_fd_writer_ops = { - .f_create = rte_port_fd_writer_create, - .f_free = rte_port_fd_writer_free, - .f_tx = rte_port_fd_writer_tx, - .f_tx_bulk = rte_port_fd_writer_tx_bulk, - .f_flush = rte_port_fd_writer_flush, - .f_stats = rte_port_fd_writer_stats_read, -}; - -RTE_EXPORT_SYMBOL(rte_port_fd_writer_nodrop_ops) -struct rte_port_out_ops rte_port_fd_writer_nodrop_ops = { - .f_create = rte_port_fd_writer_nodrop_create, - .f_free = rte_port_fd_writer_nodrop_free, - .f_tx = rte_port_fd_writer_nodrop_tx, - .f_tx_bulk = rte_port_fd_writer_nodrop_tx_bulk, - .f_flush = rte_port_fd_writer_nodrop_flush, - .f_stats = rte_port_fd_writer_nodrop_stats_read, -}; diff --git a/lib/port/rte_port_fd.h b/lib/port/rte_port_fd.h deleted file mode 100644 index 40a5e4a426..0000000000 --- a/lib/port/rte_port_fd.h +++ /dev/null @@ -1,74 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2016 Intel Corporation - */ - -#ifndef __INCLUDE_RTE_PORT_FD_H__ -#define __INCLUDE_RTE_PORT_FD_H__ - -/** - * @file - * RTE Port FD Device - * - * fd_reader: input port built on top of valid non-blocking file descriptor - * fd_writer: output port built on top of valid non-blocking file descriptor - */ - -#include - -#include "rte_port.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** fd_reader port parameters */ -struct rte_port_fd_reader_params { - /** File descriptor */ - int fd; - - /** Maximum Transfer Unit (MTU) */ - uint32_t mtu; - - /** Pre-initialized buffer pool */ - struct rte_mempool *mempool; -}; - -/** fd_reader port operations */ -extern struct rte_port_in_ops rte_port_fd_reader_ops; - -/** fd_writer port parameters */ -struct rte_port_fd_writer_params { - /** File descriptor */ - int fd; - - /**< Recommended write burst size. The actual burst size can be - * bigger or smaller than this value. - */ - uint32_t tx_burst_sz; -}; - -/** fd_writer port operations */ -extern struct rte_port_out_ops rte_port_fd_writer_ops; - -/** fd_writer_nodrop port parameters */ -struct rte_port_fd_writer_nodrop_params { - /** File descriptor */ - int fd; - - /**< Recommended write burst size. The actual burst size can be - * bigger or smaller than this value. - */ - uint32_t tx_burst_sz; - - /** Maximum number of retries, 0 for no limit */ - uint32_t n_retries; -}; - -/** fd_writer_nodrop port operations */ -extern struct rte_port_out_ops rte_port_fd_writer_nodrop_ops; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/port/rte_port_frag.c b/lib/port/rte_port_frag.c deleted file mode 100644 index 9444f5939c..0000000000 --- a/lib/port/rte_port_frag.c +++ /dev/null @@ -1,280 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2010-2014 Intel Corporation - */ -#include - -#include -#include - -#include "rte_port_frag.h" - -#include "port_log.h" - -/* Max number of fragments per packet allowed */ -#define RTE_PORT_FRAG_MAX_FRAGS_PER_PACKET 0x80 - -#ifdef RTE_PORT_STATS_COLLECT - -#define RTE_PORT_RING_READER_FRAG_STATS_PKTS_IN_ADD(port, val) \ - port->stats.n_pkts_in += val -#define RTE_PORT_RING_READER_FRAG_STATS_PKTS_DROP_ADD(port, val) \ - port->stats.n_pkts_drop += val - -#else - -#define RTE_PORT_RING_READER_FRAG_STATS_PKTS_IN_ADD(port, val) -#define RTE_PORT_RING_READER_FRAG_STATS_PKTS_DROP_ADD(port, val) - -#endif - -typedef int32_t - (*frag_op)(struct rte_mbuf *pkt_in, - struct rte_mbuf **pkts_out, - uint16_t nb_pkts_out, - uint16_t mtu_size, - struct rte_mempool *pool_direct, - struct rte_mempool *pool_indirect); - -struct __rte_cache_aligned rte_port_ring_reader_frag { - struct rte_port_in_stats stats; - - /* Input parameters */ - struct rte_ring *ring; - uint32_t mtu; - uint32_t metadata_size; - struct rte_mempool *pool_direct; - struct rte_mempool *pool_indirect; - - /* Internal buffers */ - struct rte_mbuf *pkts[RTE_PORT_IN_BURST_SIZE_MAX]; - struct rte_mbuf *frags[RTE_PORT_FRAG_MAX_FRAGS_PER_PACKET]; - uint32_t n_pkts; - uint32_t pos_pkts; - uint32_t n_frags; - uint32_t pos_frags; - - frag_op f_frag; -}; - -static void * -rte_port_ring_reader_frag_create(void *params, int socket_id, int is_ipv4) -{ - struct rte_port_ring_reader_frag_params *conf = - params; - struct rte_port_ring_reader_frag *port; - - /* Check input parameters */ - if (conf == NULL) { - PORT_LOG(ERR, "%s: Parameter conf is NULL", __func__); - return NULL; - } - if (conf->ring == NULL) { - PORT_LOG(ERR, "%s: Parameter ring is NULL", __func__); - return NULL; - } - if (conf->mtu == 0) { - PORT_LOG(ERR, "%s: Parameter mtu is invalid", __func__); - return NULL; - } - if (conf->pool_direct == NULL) { - PORT_LOG(ERR, "%s: Parameter pool_direct is NULL", - __func__); - return NULL; - } - if (conf->pool_indirect == NULL) { - PORT_LOG(ERR, "%s: Parameter pool_indirect is NULL", - __func__); - return NULL; - } - - /* Memory allocation */ - port = rte_zmalloc_socket("PORT", sizeof(*port), RTE_CACHE_LINE_SIZE, - socket_id); - if (port == NULL) { - PORT_LOG(ERR, "%s: port is NULL", __func__); - return NULL; - } - - /* Initialization */ - port->ring = conf->ring; - port->mtu = conf->mtu; - port->metadata_size = conf->metadata_size; - port->pool_direct = conf->pool_direct; - port->pool_indirect = conf->pool_indirect; - - port->n_pkts = 0; - port->pos_pkts = 0; - port->n_frags = 0; - port->pos_frags = 0; - - port->f_frag = (is_ipv4) ? - rte_ipv4_fragment_packet : rte_ipv6_fragment_packet; - - return port; -} - -static void * -rte_port_ring_reader_ipv4_frag_create(void *params, int socket_id) -{ - return rte_port_ring_reader_frag_create(params, socket_id, 1); -} - -static void * -rte_port_ring_reader_ipv6_frag_create(void *params, int socket_id) -{ - return rte_port_ring_reader_frag_create(params, socket_id, 0); -} - -static int -rte_port_ring_reader_frag_rx(void *port, - struct rte_mbuf **pkts, - uint32_t n_pkts) -{ - struct rte_port_ring_reader_frag *p = - port; - uint32_t n_pkts_out; - - n_pkts_out = 0; - - /* Get packets from the "frag" buffer */ - if (p->n_frags >= n_pkts) { - memcpy(pkts, &p->frags[p->pos_frags], n_pkts * sizeof(void *)); - p->pos_frags += n_pkts; - p->n_frags -= n_pkts; - - return n_pkts; - } - - memcpy(pkts, &p->frags[p->pos_frags], p->n_frags * sizeof(void *)); - n_pkts_out = p->n_frags; - p->n_frags = 0; - - /* Look to "pkts" buffer to get more packets */ - for ( ; ; ) { - struct rte_mbuf *pkt; - uint32_t n_pkts_to_provide, i; - int status; - - /* If "pkts" buffer is empty, read packet burst from ring */ - if (p->n_pkts == 0) { - p->n_pkts = rte_ring_sc_dequeue_burst(p->ring, - (void **) p->pkts, RTE_PORT_IN_BURST_SIZE_MAX, - NULL); - RTE_PORT_RING_READER_FRAG_STATS_PKTS_IN_ADD(p, p->n_pkts); - if (p->n_pkts == 0) - return n_pkts_out; - p->pos_pkts = 0; - } - - /* Read next packet from "pkts" buffer */ - pkt = p->pkts[p->pos_pkts++]; - p->n_pkts--; - - /* If not jumbo, pass current packet to output */ - if (pkt->pkt_len <= p->mtu) { - pkts[n_pkts_out++] = pkt; - - n_pkts_to_provide = n_pkts - n_pkts_out; - if (n_pkts_to_provide == 0) - return n_pkts; - - continue; - } - - /* Fragment current packet into the "frags" buffer */ - status = p->f_frag( - pkt, - p->frags, - RTE_PORT_FRAG_MAX_FRAGS_PER_PACKET, - p->mtu, - p->pool_direct, - p->pool_indirect - ); - - if (status < 0) { - rte_pktmbuf_free(pkt); - RTE_PORT_RING_READER_FRAG_STATS_PKTS_DROP_ADD(p, 1); - continue; - } - - p->n_frags = (uint32_t) status; - p->pos_frags = 0; - - /* Copy meta-data from input jumbo packet to its fragments */ - for (i = 0; i < p->n_frags; i++) { - uint8_t *src = - RTE_MBUF_METADATA_UINT8_PTR(pkt, sizeof(struct rte_mbuf)); - uint8_t *dst = - RTE_MBUF_METADATA_UINT8_PTR(p->frags[i], sizeof(struct rte_mbuf)); - - memcpy(dst, src, p->metadata_size); - } - - /* Free input jumbo packet */ - rte_pktmbuf_free(pkt); - - /* Get packets from "frag" buffer */ - n_pkts_to_provide = n_pkts - n_pkts_out; - if (p->n_frags >= n_pkts_to_provide) { - memcpy(&pkts[n_pkts_out], p->frags, - n_pkts_to_provide * sizeof(void *)); - p->n_frags -= n_pkts_to_provide; - p->pos_frags += n_pkts_to_provide; - - return n_pkts; - } - - memcpy(&pkts[n_pkts_out], p->frags, - p->n_frags * sizeof(void *)); - n_pkts_out += p->n_frags; - p->n_frags = 0; - } -} - -static int -rte_port_ring_reader_frag_free(void *port) -{ - if (port == NULL) { - PORT_LOG(ERR, "%s: Parameter port is NULL", __func__); - return -1; - } - - rte_free(port); - - return 0; -} - -static int -rte_port_frag_reader_stats_read(void *port, - struct rte_port_in_stats *stats, int clear) -{ - struct rte_port_ring_reader_frag *p = - port; - - if (stats != NULL) - memcpy(stats, &p->stats, sizeof(p->stats)); - - if (clear) - memset(&p->stats, 0, sizeof(p->stats)); - - return 0; -} - -/* - * Summary of port operations - */ -RTE_EXPORT_SYMBOL(rte_port_ring_reader_ipv4_frag_ops) -struct rte_port_in_ops rte_port_ring_reader_ipv4_frag_ops = { - .f_create = rte_port_ring_reader_ipv4_frag_create, - .f_free = rte_port_ring_reader_frag_free, - .f_rx = rte_port_ring_reader_frag_rx, - .f_stats = rte_port_frag_reader_stats_read, -}; - -RTE_EXPORT_SYMBOL(rte_port_ring_reader_ipv6_frag_ops) -struct rte_port_in_ops rte_port_ring_reader_ipv6_frag_ops = { - .f_create = rte_port_ring_reader_ipv6_frag_create, - .f_free = rte_port_ring_reader_frag_free, - .f_rx = rte_port_ring_reader_frag_rx, - .f_stats = rte_port_frag_reader_stats_read, -}; diff --git a/lib/port/rte_port_frag.h b/lib/port/rte_port_frag.h deleted file mode 100644 index 9a10f10523..0000000000 --- a/lib/port/rte_port_frag.h +++ /dev/null @@ -1,70 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2010-2014 Intel Corporation - */ - -#ifndef __INCLUDE_RTE_PORT_IP_FRAG_H__ -#define __INCLUDE_RTE_PORT_IP_FRAG_H__ - -/** - * @file - * RTE Port for IPv4 Fragmentation - * - * This port is built on top of pre-initialized single consumer rte_ring. In - * order to minimize the amount of packets stored in the ring at any given - * time, the IP fragmentation functionality is executed on ring read operation, - * hence this port is implemented as an input port. A regular ring_writer port - * can be created to write to the same ring. - * - * The packets written to the ring are either complete IP datagrams or jumbo - * frames (i.e. IP packets with length bigger than provided MTU value). The - * packets read from the ring are all non-jumbo frames. The complete IP - * datagrams written to the ring are not changed. The jumbo frames are - * fragmented into several IP packets with length less or equal to MTU. - */ - -#include - - -#include "rte_port.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** ring_reader_ipv4_frag port parameters */ -struct rte_port_ring_reader_frag_params { - /** Underlying single consumer ring that has to be pre-initialized. */ - struct rte_ring *ring; - - /** Maximum Transfer Unit (MTU). Maximum IP packet size (in bytes). */ - uint32_t mtu; - - /** Size of application dependent meta-data stored per each input packet - that has to be copied to each of the fragments originating from the - same input IP datagram. */ - uint32_t metadata_size; - - /** Pre-initialized buffer pool used for allocating direct buffers for - the output fragments. */ - struct rte_mempool *pool_direct; - - /** Pre-initialized buffer pool used for allocating indirect buffers for - the output fragments. */ - struct rte_mempool *pool_indirect; -}; - -#define rte_port_ring_reader_ipv4_frag_params rte_port_ring_reader_frag_params - -#define rte_port_ring_reader_ipv6_frag_params rte_port_ring_reader_frag_params - -/** ring_reader_ipv4_frag port operations */ -extern struct rte_port_in_ops rte_port_ring_reader_ipv4_frag_ops; - -/** ring_reader_ipv6_frag port operations */ -extern struct rte_port_in_ops rte_port_ring_reader_ipv6_frag_ops; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/port/rte_port_ras.c b/lib/port/rte_port_ras.c deleted file mode 100644 index 58ab7a1c5b..0000000000 --- a/lib/port/rte_port_ras.c +++ /dev/null @@ -1,336 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2010-2014 Intel Corporation - */ -#include - -#include -#include -#include -#include - -#include "rte_port_ras.h" - -#include "port_log.h" - -#ifndef RTE_PORT_RAS_N_BUCKETS -#define RTE_PORT_RAS_N_BUCKETS 4094 -#endif - -#ifndef RTE_PORT_RAS_N_ENTRIES_PER_BUCKET -#define RTE_PORT_RAS_N_ENTRIES_PER_BUCKET 8 -#endif - -#ifndef RTE_PORT_RAS_N_ENTRIES -#define RTE_PORT_RAS_N_ENTRIES (RTE_PORT_RAS_N_BUCKETS * RTE_PORT_RAS_N_ENTRIES_PER_BUCKET) -#endif - -#ifdef RTE_PORT_STATS_COLLECT - -#define RTE_PORT_RING_WRITER_RAS_STATS_PKTS_IN_ADD(port, val) \ - port->stats.n_pkts_in += val -#define RTE_PORT_RING_WRITER_RAS_STATS_PKTS_DROP_ADD(port, val) \ - port->stats.n_pkts_drop += val - -#else - -#define RTE_PORT_RING_WRITER_RAS_STATS_PKTS_IN_ADD(port, val) -#define RTE_PORT_RING_WRITER_RAS_STATS_PKTS_DROP_ADD(port, val) - -#endif - -struct rte_port_ring_writer_ras; - -typedef void (*ras_op)( - struct rte_port_ring_writer_ras *p, - struct rte_mbuf *pkt); - -static void -process_ipv4(struct rte_port_ring_writer_ras *p, struct rte_mbuf *pkt); -static void -process_ipv6(struct rte_port_ring_writer_ras *p, struct rte_mbuf *pkt); - -struct rte_port_ring_writer_ras { - struct rte_port_out_stats stats; - - struct rte_mbuf *tx_buf[RTE_PORT_IN_BURST_SIZE_MAX]; - struct rte_ring *ring; - uint32_t tx_burst_sz; - uint32_t tx_buf_count; - struct rte_ip_frag_tbl *frag_tbl; - struct rte_ip_frag_death_row death_row; - - ras_op f_ras; -}; - -static void * -rte_port_ring_writer_ras_create(void *params, int socket_id, int is_ipv4) -{ - struct rte_port_ring_writer_ras_params *conf = - params; - struct rte_port_ring_writer_ras *port; - uint64_t frag_cycles; - - /* Check input parameters */ - if (conf == NULL) { - PORT_LOG(ERR, "%s: Parameter conf is NULL", __func__); - return NULL; - } - if (conf->ring == NULL) { - PORT_LOG(ERR, "%s: Parameter ring is NULL", __func__); - return NULL; - } - if ((conf->tx_burst_sz == 0) || - (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX)) { - PORT_LOG(ERR, "%s: Parameter tx_burst_sz is invalid", - __func__); - return NULL; - } - - /* Memory allocation */ - port = rte_zmalloc_socket("PORT", sizeof(*port), - RTE_CACHE_LINE_SIZE, socket_id); - if (port == NULL) { - PORT_LOG(ERR, "%s: Failed to allocate socket", __func__); - return NULL; - } - - /* Create fragmentation table */ - frag_cycles = (rte_get_tsc_hz() + MS_PER_S - 1) / MS_PER_S * MS_PER_S; - frag_cycles *= 100; - - port->frag_tbl = rte_ip_frag_table_create( - RTE_PORT_RAS_N_BUCKETS, - RTE_PORT_RAS_N_ENTRIES_PER_BUCKET, - RTE_PORT_RAS_N_ENTRIES, - frag_cycles, - socket_id); - - if (port->frag_tbl == NULL) { - PORT_LOG(ERR, "%s: rte_ip_frag_table_create failed", - __func__); - rte_free(port); - return NULL; - } - - /* Initialization */ - port->ring = conf->ring; - port->tx_burst_sz = conf->tx_burst_sz; - port->tx_buf_count = 0; - - port->f_ras = (is_ipv4 == 1) ? process_ipv4 : process_ipv6; - - return port; -} - -static void * -rte_port_ring_writer_ipv4_ras_create(void *params, int socket_id) -{ - return rte_port_ring_writer_ras_create(params, socket_id, 1); -} - -static void * -rte_port_ring_writer_ipv6_ras_create(void *params, int socket_id) -{ - return rte_port_ring_writer_ras_create(params, socket_id, 0); -} - -static inline void -send_burst(struct rte_port_ring_writer_ras *p) -{ - uint32_t nb_tx; - - nb_tx = rte_ring_sp_enqueue_burst(p->ring, (void **)p->tx_buf, - p->tx_buf_count, NULL); - - RTE_PORT_RING_WRITER_RAS_STATS_PKTS_DROP_ADD(p, p->tx_buf_count - nb_tx); - for ( ; nb_tx < p->tx_buf_count; nb_tx++) - rte_pktmbuf_free(p->tx_buf[nb_tx]); - - p->tx_buf_count = 0; -} - -static void -process_ipv4(struct rte_port_ring_writer_ras *p, struct rte_mbuf *pkt) -{ - /* Assume there is no ethernet header */ - struct rte_ipv4_hdr *pkt_hdr = - rte_pktmbuf_mtod(pkt, struct rte_ipv4_hdr *); - - /* Get "More fragments" flag and fragment offset */ - uint16_t frag_field = rte_be_to_cpu_16(pkt_hdr->fragment_offset); - uint16_t frag_offset = (uint16_t)(frag_field & RTE_IPV4_HDR_OFFSET_MASK); - uint16_t frag_flag = (uint16_t)(frag_field & RTE_IPV4_HDR_MF_FLAG); - - /* If it is a fragmented packet, then try to reassemble */ - if ((frag_flag == 0) && (frag_offset == 0)) - p->tx_buf[p->tx_buf_count++] = pkt; - else { - struct rte_mbuf *mo; - struct rte_ip_frag_tbl *tbl = p->frag_tbl; - struct rte_ip_frag_death_row *dr = &p->death_row; - - pkt->l3_len = sizeof(*pkt_hdr); - - /* Process this fragment */ - mo = rte_ipv4_frag_reassemble_packet(tbl, dr, pkt, rte_rdtsc(), - pkt_hdr); - if (mo != NULL) - p->tx_buf[p->tx_buf_count++] = mo; - - rte_ip_frag_free_death_row(&p->death_row, 3); - } -} - -static void -process_ipv6(struct rte_port_ring_writer_ras *p, struct rte_mbuf *pkt) -{ - /* Assume there is no ethernet header */ - struct rte_ipv6_hdr *pkt_hdr = - rte_pktmbuf_mtod(pkt, struct rte_ipv6_hdr *); - - struct rte_ipv6_fragment_ext *frag_hdr; - uint16_t frag_data = 0; - frag_hdr = rte_ipv6_frag_get_ipv6_fragment_header(pkt_hdr); - if (frag_hdr != NULL) - frag_data = rte_be_to_cpu_16(frag_hdr->frag_data); - - /* If it is a fragmented packet, then try to reassemble */ - if ((frag_data & RTE_IPV6_FRAG_USED_MASK) == 0) - p->tx_buf[p->tx_buf_count++] = pkt; - else { - struct rte_mbuf *mo; - struct rte_ip_frag_tbl *tbl = p->frag_tbl; - struct rte_ip_frag_death_row *dr = &p->death_row; - - pkt->l3_len = sizeof(*pkt_hdr) + sizeof(*frag_hdr); - - /* Process this fragment */ - mo = rte_ipv6_frag_reassemble_packet(tbl, dr, pkt, rte_rdtsc(), pkt_hdr, - frag_hdr); - if (mo != NULL) - p->tx_buf[p->tx_buf_count++] = mo; - - rte_ip_frag_free_death_row(&p->death_row, 3); - } -} - -static int -rte_port_ring_writer_ras_tx(void *port, struct rte_mbuf *pkt) -{ - struct rte_port_ring_writer_ras *p = - port; - - RTE_PORT_RING_WRITER_RAS_STATS_PKTS_IN_ADD(p, 1); - p->f_ras(p, pkt); - if (p->tx_buf_count >= p->tx_burst_sz) - send_burst(p); - - return 0; -} - -static int -rte_port_ring_writer_ras_tx_bulk(void *port, - struct rte_mbuf **pkts, - uint64_t pkts_mask) -{ - struct rte_port_ring_writer_ras *p = - port; - - if ((pkts_mask & (pkts_mask + 1)) == 0) { - uint64_t n_pkts = rte_popcount64(pkts_mask); - uint32_t i; - - for (i = 0; i < n_pkts; i++) { - struct rte_mbuf *pkt = pkts[i]; - - RTE_PORT_RING_WRITER_RAS_STATS_PKTS_IN_ADD(p, 1); - p->f_ras(p, pkt); - if (p->tx_buf_count >= p->tx_burst_sz) - send_burst(p); - } - } else { - for ( ; pkts_mask; ) { - uint32_t pkt_index = rte_ctz64(pkts_mask); - uint64_t pkt_mask = 1LLU << pkt_index; - struct rte_mbuf *pkt = pkts[pkt_index]; - - RTE_PORT_RING_WRITER_RAS_STATS_PKTS_IN_ADD(p, 1); - p->f_ras(p, pkt); - if (p->tx_buf_count >= p->tx_burst_sz) - send_burst(p); - - pkts_mask &= ~pkt_mask; - } - } - - return 0; -} - -static int -rte_port_ring_writer_ras_flush(void *port) -{ - struct rte_port_ring_writer_ras *p = - port; - - if (p->tx_buf_count > 0) - send_burst(p); - - return 0; -} - -static int -rte_port_ring_writer_ras_free(void *port) -{ - struct rte_port_ring_writer_ras *p = - port; - - if (port == NULL) { - PORT_LOG(ERR, "%s: Parameter port is NULL", __func__); - return -1; - } - - rte_port_ring_writer_ras_flush(port); - rte_ip_frag_table_destroy(p->frag_tbl); - rte_free(port); - - return 0; -} - -static int -rte_port_ras_writer_stats_read(void *port, - struct rte_port_out_stats *stats, int clear) -{ - struct rte_port_ring_writer_ras *p = - port; - - if (stats != NULL) - memcpy(stats, &p->stats, sizeof(p->stats)); - - if (clear) - memset(&p->stats, 0, sizeof(p->stats)); - - return 0; -} - -/* - * Summary of port operations - */ -RTE_EXPORT_SYMBOL(rte_port_ring_writer_ipv4_ras_ops) -struct rte_port_out_ops rte_port_ring_writer_ipv4_ras_ops = { - .f_create = rte_port_ring_writer_ipv4_ras_create, - .f_free = rte_port_ring_writer_ras_free, - .f_tx = rte_port_ring_writer_ras_tx, - .f_tx_bulk = rte_port_ring_writer_ras_tx_bulk, - .f_flush = rte_port_ring_writer_ras_flush, - .f_stats = rte_port_ras_writer_stats_read, -}; - -RTE_EXPORT_SYMBOL(rte_port_ring_writer_ipv6_ras_ops) -struct rte_port_out_ops rte_port_ring_writer_ipv6_ras_ops = { - .f_create = rte_port_ring_writer_ipv6_ras_create, - .f_free = rte_port_ring_writer_ras_free, - .f_tx = rte_port_ring_writer_ras_tx, - .f_tx_bulk = rte_port_ring_writer_ras_tx_bulk, - .f_flush = rte_port_ring_writer_ras_flush, - .f_stats = rte_port_ras_writer_stats_read, -}; diff --git a/lib/port/rte_port_ras.h b/lib/port/rte_port_ras.h deleted file mode 100644 index 86e36f5362..0000000000 --- a/lib/port/rte_port_ras.h +++ /dev/null @@ -1,58 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2010-2014 Intel Corporation - */ - -#ifndef __INCLUDE_RTE_PORT_RAS_H__ -#define __INCLUDE_RTE_PORT_RAS_H__ - -/** - * @file - * RTE Port for IPv4 Reassembly - * - * This port is built on top of pre-initialized single producer rte_ring. In - * order to minimize the amount of packets stored in the ring at any given - * time, the IP reassembly functionality is executed on ring write operation, - * hence this port is implemented as an output port. A regular ring_reader port - * can be created to read from the same ring. - * - * The packets written to the ring are either complete IP datagrams or IP - * fragments. The packets read from the ring are all complete IP datagrams, - * either jumbo frames (i.e. IP packets with length bigger than MTU) or not. - * The complete IP datagrams written to the ring are not changed. The IP - * fragments written to the ring are first reassembled and into complete IP - * datagrams or dropped on error or IP reassembly time-out. - */ - -#include - -#include "rte_port.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** ring_writer_ipv4_ras port parameters */ -struct rte_port_ring_writer_ras_params { - /** Underlying single consumer ring that has to be pre-initialized. */ - struct rte_ring *ring; - - /** Recommended burst size to ring. The actual burst size can be bigger - or smaller than this value. */ - uint32_t tx_burst_sz; -}; - -#define rte_port_ring_writer_ipv4_ras_params rte_port_ring_writer_ras_params - -#define rte_port_ring_writer_ipv6_ras_params rte_port_ring_writer_ras_params - -/** ring_writer_ipv4_ras port operations */ -extern struct rte_port_out_ops rte_port_ring_writer_ipv4_ras_ops; - -/** ring_writer_ipv6_ras port operations */ -extern struct rte_port_out_ops rte_port_ring_writer_ipv6_ras_ops; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/port/rte_port_ring.c b/lib/port/rte_port_ring.c deleted file mode 100644 index 307a576d65..0000000000 --- a/lib/port/rte_port_ring.c +++ /dev/null @@ -1,796 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2010-2014 Intel Corporation - */ -#include -#include - -#include -#include -#include -#include - -#include "rte_port_ring.h" - -#include "port_log.h" - -/* - * Port RING Reader - */ -#ifdef RTE_PORT_STATS_COLLECT - -#define RTE_PORT_RING_READER_STATS_PKTS_IN_ADD(port, val) \ - port->stats.n_pkts_in += val -#define RTE_PORT_RING_READER_STATS_PKTS_DROP_ADD(port, val) \ - port->stats.n_pkts_drop += val - -#else - -#define RTE_PORT_RING_READER_STATS_PKTS_IN_ADD(port, val) -#define RTE_PORT_RING_READER_STATS_PKTS_DROP_ADD(port, val) - -#endif - -struct rte_port_ring_reader { - struct rte_port_in_stats stats; - - struct rte_ring *ring; -}; - -static void * -rte_port_ring_reader_create_internal(void *params, int socket_id, - uint32_t is_multi) -{ - struct rte_port_ring_reader_params *conf = - params; - struct rte_port_ring_reader *port; - - /* Check input parameters */ - if ((conf == NULL) || - (conf->ring == NULL) || - (rte_ring_is_cons_single(conf->ring) && is_multi) || - (!rte_ring_is_cons_single(conf->ring) && !is_multi)) { - PORT_LOG(ERR, "%s: Invalid Parameters", __func__); - return NULL; - } - - /* Memory allocation */ - port = rte_zmalloc_socket("PORT", sizeof(*port), - RTE_CACHE_LINE_SIZE, socket_id); - if (port == NULL) { - PORT_LOG(ERR, "%s: Failed to allocate port", __func__); - return NULL; - } - - /* Initialization */ - port->ring = conf->ring; - - return port; -} - -static void * -rte_port_ring_reader_create(void *params, int socket_id) -{ - return rte_port_ring_reader_create_internal(params, socket_id, 0); -} - -static void * -rte_port_ring_multi_reader_create(void *params, int socket_id) -{ - return rte_port_ring_reader_create_internal(params, socket_id, 1); -} - -static int -rte_port_ring_reader_rx(void *port, struct rte_mbuf **pkts, uint32_t n_pkts) -{ - struct rte_port_ring_reader *p = port; - uint32_t nb_rx; - - nb_rx = rte_ring_sc_dequeue_burst(p->ring, (void **) pkts, - n_pkts, NULL); - RTE_PORT_RING_READER_STATS_PKTS_IN_ADD(p, nb_rx); - - return nb_rx; -} - -static int -rte_port_ring_multi_reader_rx(void *port, struct rte_mbuf **pkts, - uint32_t n_pkts) -{ - struct rte_port_ring_reader *p = port; - uint32_t nb_rx; - - nb_rx = rte_ring_mc_dequeue_burst(p->ring, (void **) pkts, - n_pkts, NULL); - RTE_PORT_RING_READER_STATS_PKTS_IN_ADD(p, nb_rx); - - return nb_rx; -} - -static int -rte_port_ring_reader_free(void *port) -{ - if (port == NULL) { - PORT_LOG(ERR, "%s: port is NULL", __func__); - return -EINVAL; - } - - rte_free(port); - - return 0; -} - -static int -rte_port_ring_reader_stats_read(void *port, - struct rte_port_in_stats *stats, int clear) -{ - struct rte_port_ring_reader *p = - port; - - if (stats != NULL) - memcpy(stats, &p->stats, sizeof(p->stats)); - - if (clear) - memset(&p->stats, 0, sizeof(p->stats)); - - return 0; -} - -/* - * Port RING Writer - */ -#ifdef RTE_PORT_STATS_COLLECT - -#define RTE_PORT_RING_WRITER_STATS_PKTS_IN_ADD(port, val) \ - port->stats.n_pkts_in += val -#define RTE_PORT_RING_WRITER_STATS_PKTS_DROP_ADD(port, val) \ - port->stats.n_pkts_drop += val - -#else - -#define RTE_PORT_RING_WRITER_STATS_PKTS_IN_ADD(port, val) -#define RTE_PORT_RING_WRITER_STATS_PKTS_DROP_ADD(port, val) - -#endif - -struct rte_port_ring_writer { - struct rte_port_out_stats stats; - - struct rte_mbuf *tx_buf[2 * RTE_PORT_IN_BURST_SIZE_MAX]; - struct rte_ring *ring; - uint32_t tx_burst_sz; - uint32_t tx_buf_count; - uint64_t bsz_mask; - uint32_t is_multi; -}; - -static void * -rte_port_ring_writer_create_internal(void *params, int socket_id, - uint32_t is_multi) -{ - struct rte_port_ring_writer_params *conf = - params; - struct rte_port_ring_writer *port; - - /* Check input parameters */ - if ((conf == NULL) || - (conf->ring == NULL) || - (rte_ring_is_prod_single(conf->ring) && is_multi) || - (!rte_ring_is_prod_single(conf->ring) && !is_multi) || - (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX)) { - PORT_LOG(ERR, "%s: Invalid Parameters", __func__); - return NULL; - } - - /* Memory allocation */ - port = rte_zmalloc_socket("PORT", sizeof(*port), - RTE_CACHE_LINE_SIZE, socket_id); - if (port == NULL) { - PORT_LOG(ERR, "%s: Failed to allocate port", __func__); - return NULL; - } - - /* Initialization */ - port->ring = conf->ring; - port->tx_burst_sz = conf->tx_burst_sz; - port->tx_buf_count = 0; - port->bsz_mask = 1LLU << (conf->tx_burst_sz - 1); - port->is_multi = is_multi; - - return port; -} - -static void * -rte_port_ring_writer_create(void *params, int socket_id) -{ - return rte_port_ring_writer_create_internal(params, socket_id, 0); -} - -static void * -rte_port_ring_multi_writer_create(void *params, int socket_id) -{ - return rte_port_ring_writer_create_internal(params, socket_id, 1); -} - -static inline void -send_burst(struct rte_port_ring_writer *p) -{ - uint32_t nb_tx; - - nb_tx = rte_ring_sp_enqueue_burst(p->ring, (void **)p->tx_buf, - p->tx_buf_count, NULL); - - RTE_PORT_RING_WRITER_STATS_PKTS_DROP_ADD(p, p->tx_buf_count - nb_tx); - for ( ; nb_tx < p->tx_buf_count; nb_tx++) - rte_pktmbuf_free(p->tx_buf[nb_tx]); - - p->tx_buf_count = 0; -} - -static inline void -send_burst_mp(struct rte_port_ring_writer *p) -{ - uint32_t nb_tx; - - nb_tx = rte_ring_mp_enqueue_burst(p->ring, (void **)p->tx_buf, - p->tx_buf_count, NULL); - - RTE_PORT_RING_WRITER_STATS_PKTS_DROP_ADD(p, p->tx_buf_count - nb_tx); - for ( ; nb_tx < p->tx_buf_count; nb_tx++) - rte_pktmbuf_free(p->tx_buf[nb_tx]); - - p->tx_buf_count = 0; -} - -static int -rte_port_ring_writer_tx(void *port, struct rte_mbuf *pkt) -{ - struct rte_port_ring_writer *p = port; - - p->tx_buf[p->tx_buf_count++] = pkt; - RTE_PORT_RING_WRITER_STATS_PKTS_IN_ADD(p, 1); - if (p->tx_buf_count >= p->tx_burst_sz) - send_burst(p); - - return 0; -} - -static int -rte_port_ring_multi_writer_tx(void *port, struct rte_mbuf *pkt) -{ - struct rte_port_ring_writer *p = port; - - p->tx_buf[p->tx_buf_count++] = pkt; - RTE_PORT_RING_WRITER_STATS_PKTS_IN_ADD(p, 1); - if (p->tx_buf_count >= p->tx_burst_sz) - send_burst_mp(p); - - return 0; -} - -static __rte_always_inline int -rte_port_ring_writer_tx_bulk_internal(void *port, - struct rte_mbuf **pkts, - uint64_t pkts_mask, - uint32_t is_multi) -{ - struct rte_port_ring_writer *p = - port; - - uint64_t bsz_mask = p->bsz_mask; - uint32_t tx_buf_count = p->tx_buf_count; - uint64_t expr = (pkts_mask & (pkts_mask + 1)) | - ((pkts_mask & bsz_mask) ^ bsz_mask); - - if (expr == 0) { - uint64_t n_pkts = rte_popcount64(pkts_mask); - uint32_t n_pkts_ok; - - if (tx_buf_count) { - if (is_multi) - send_burst_mp(p); - else - send_burst(p); - } - - RTE_PORT_RING_WRITER_STATS_PKTS_IN_ADD(p, n_pkts); - if (is_multi) - n_pkts_ok = rte_ring_mp_enqueue_burst(p->ring, - (void **)pkts, n_pkts, NULL); - else - n_pkts_ok = rte_ring_sp_enqueue_burst(p->ring, - (void **)pkts, n_pkts, NULL); - - RTE_PORT_RING_WRITER_STATS_PKTS_DROP_ADD(p, n_pkts - n_pkts_ok); - for ( ; n_pkts_ok < n_pkts; n_pkts_ok++) { - struct rte_mbuf *pkt = pkts[n_pkts_ok]; - - rte_pktmbuf_free(pkt); - } - } else { - for ( ; pkts_mask; ) { - uint32_t pkt_index = rte_ctz64(pkts_mask); - uint64_t pkt_mask = 1LLU << pkt_index; - struct rte_mbuf *pkt = pkts[pkt_index]; - - p->tx_buf[tx_buf_count++] = pkt; - RTE_PORT_RING_WRITER_STATS_PKTS_IN_ADD(p, 1); - pkts_mask &= ~pkt_mask; - } - - p->tx_buf_count = tx_buf_count; - if (tx_buf_count >= p->tx_burst_sz) { - if (is_multi) - send_burst_mp(p); - else - send_burst(p); - } - } - - return 0; -} - -static int -rte_port_ring_writer_tx_bulk(void *port, - struct rte_mbuf **pkts, - uint64_t pkts_mask) -{ - return rte_port_ring_writer_tx_bulk_internal(port, pkts, pkts_mask, 0); -} - -static int -rte_port_ring_multi_writer_tx_bulk(void *port, - struct rte_mbuf **pkts, - uint64_t pkts_mask) -{ - return rte_port_ring_writer_tx_bulk_internal(port, pkts, pkts_mask, 1); -} - -static int -rte_port_ring_writer_flush(void *port) -{ - struct rte_port_ring_writer *p = port; - - if (p->tx_buf_count > 0) - send_burst(p); - - return 0; -} - -static int -rte_port_ring_multi_writer_flush(void *port) -{ - struct rte_port_ring_writer *p = port; - - if (p->tx_buf_count > 0) - send_burst_mp(p); - - return 0; -} - -static int -rte_port_ring_writer_free(void *port) -{ - struct rte_port_ring_writer *p = port; - - if (port == NULL) { - PORT_LOG(ERR, "%s: Port is NULL", __func__); - return -EINVAL; - } - - if (p->is_multi) - rte_port_ring_multi_writer_flush(port); - else - rte_port_ring_writer_flush(port); - - rte_free(port); - - return 0; -} - -static int -rte_port_ring_writer_stats_read(void *port, - struct rte_port_out_stats *stats, int clear) -{ - struct rte_port_ring_writer *p = - port; - - if (stats != NULL) - memcpy(stats, &p->stats, sizeof(p->stats)); - - if (clear) - memset(&p->stats, 0, sizeof(p->stats)); - - return 0; -} - -/* - * Port RING Writer Nodrop - */ -#ifdef RTE_PORT_STATS_COLLECT - -#define RTE_PORT_RING_WRITER_NODROP_STATS_PKTS_IN_ADD(port, val) \ - port->stats.n_pkts_in += val -#define RTE_PORT_RING_WRITER_NODROP_STATS_PKTS_DROP_ADD(port, val) \ - port->stats.n_pkts_drop += val - -#else - -#define RTE_PORT_RING_WRITER_NODROP_STATS_PKTS_IN_ADD(port, val) -#define RTE_PORT_RING_WRITER_NODROP_STATS_PKTS_DROP_ADD(port, val) - -#endif - -struct rte_port_ring_writer_nodrop { - struct rte_port_out_stats stats; - - struct rte_mbuf *tx_buf[2 * RTE_PORT_IN_BURST_SIZE_MAX]; - struct rte_ring *ring; - uint32_t tx_burst_sz; - uint32_t tx_buf_count; - uint64_t bsz_mask; - uint64_t n_retries; - uint32_t is_multi; -}; - -static void * -rte_port_ring_writer_nodrop_create_internal(void *params, int socket_id, - uint32_t is_multi) -{ - struct rte_port_ring_writer_nodrop_params *conf = - params; - struct rte_port_ring_writer_nodrop *port; - - /* Check input parameters */ - if ((conf == NULL) || - (conf->ring == NULL) || - (rte_ring_is_prod_single(conf->ring) && is_multi) || - (!rte_ring_is_prod_single(conf->ring) && !is_multi) || - (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX)) { - PORT_LOG(ERR, "%s: Invalid Parameters", __func__); - return NULL; - } - - /* Memory allocation */ - port = rte_zmalloc_socket("PORT", sizeof(*port), - RTE_CACHE_LINE_SIZE, socket_id); - if (port == NULL) { - PORT_LOG(ERR, "%s: Failed to allocate port", __func__); - return NULL; - } - - /* Initialization */ - port->ring = conf->ring; - port->tx_burst_sz = conf->tx_burst_sz; - port->tx_buf_count = 0; - port->bsz_mask = 1LLU << (conf->tx_burst_sz - 1); - port->is_multi = is_multi; - - /* - * When n_retries is 0 it means that we should wait for every packet to - * send no matter how many retries should it take. To limit number of - * branches in fast path, we use UINT64_MAX instead of branching. - */ - port->n_retries = (conf->n_retries == 0) ? UINT64_MAX : conf->n_retries; - - return port; -} - -static void * -rte_port_ring_writer_nodrop_create(void *params, int socket_id) -{ - return rte_port_ring_writer_nodrop_create_internal(params, socket_id, 0); -} - -static void * -rte_port_ring_multi_writer_nodrop_create(void *params, int socket_id) -{ - return rte_port_ring_writer_nodrop_create_internal(params, socket_id, 1); -} - -static inline void -send_burst_nodrop(struct rte_port_ring_writer_nodrop *p) -{ - uint32_t nb_tx = 0, i; - - nb_tx = rte_ring_sp_enqueue_burst(p->ring, (void **)p->tx_buf, - p->tx_buf_count, NULL); - - /* We sent all the packets in a first try */ - if (nb_tx >= p->tx_buf_count) { - p->tx_buf_count = 0; - return; - } - - for (i = 0; i < p->n_retries; i++) { - nb_tx += rte_ring_sp_enqueue_burst(p->ring, - (void **) (p->tx_buf + nb_tx), - p->tx_buf_count - nb_tx, NULL); - - /* We sent all the packets in more than one try */ - if (nb_tx >= p->tx_buf_count) { - p->tx_buf_count = 0; - return; - } - } - - /* We didn't send the packets in maximum allowed attempts */ - RTE_PORT_RING_WRITER_NODROP_STATS_PKTS_DROP_ADD(p, p->tx_buf_count - nb_tx); - for ( ; nb_tx < p->tx_buf_count; nb_tx++) - rte_pktmbuf_free(p->tx_buf[nb_tx]); - - p->tx_buf_count = 0; -} - -static inline void -send_burst_mp_nodrop(struct rte_port_ring_writer_nodrop *p) -{ - uint32_t nb_tx = 0, i; - - nb_tx = rte_ring_mp_enqueue_burst(p->ring, (void **)p->tx_buf, - p->tx_buf_count, NULL); - - /* We sent all the packets in a first try */ - if (nb_tx >= p->tx_buf_count) { - p->tx_buf_count = 0; - return; - } - - for (i = 0; i < p->n_retries; i++) { - nb_tx += rte_ring_mp_enqueue_burst(p->ring, - (void **) (p->tx_buf + nb_tx), - p->tx_buf_count - nb_tx, NULL); - - /* We sent all the packets in more than one try */ - if (nb_tx >= p->tx_buf_count) { - p->tx_buf_count = 0; - return; - } - } - - /* We didn't send the packets in maximum allowed attempts */ - RTE_PORT_RING_WRITER_NODROP_STATS_PKTS_DROP_ADD(p, p->tx_buf_count - nb_tx); - for ( ; nb_tx < p->tx_buf_count; nb_tx++) - rte_pktmbuf_free(p->tx_buf[nb_tx]); - - p->tx_buf_count = 0; -} - -static int -rte_port_ring_writer_nodrop_tx(void *port, struct rte_mbuf *pkt) -{ - struct rte_port_ring_writer_nodrop *p = - port; - - p->tx_buf[p->tx_buf_count++] = pkt; - RTE_PORT_RING_WRITER_NODROP_STATS_PKTS_IN_ADD(p, 1); - if (p->tx_buf_count >= p->tx_burst_sz) - send_burst_nodrop(p); - - return 0; -} - -static int -rte_port_ring_multi_writer_nodrop_tx(void *port, struct rte_mbuf *pkt) -{ - struct rte_port_ring_writer_nodrop *p = - port; - - p->tx_buf[p->tx_buf_count++] = pkt; - RTE_PORT_RING_WRITER_NODROP_STATS_PKTS_IN_ADD(p, 1); - if (p->tx_buf_count >= p->tx_burst_sz) - send_burst_mp_nodrop(p); - - return 0; -} - -static __rte_always_inline int -rte_port_ring_writer_nodrop_tx_bulk_internal(void *port, - struct rte_mbuf **pkts, - uint64_t pkts_mask, - uint32_t is_multi) -{ - struct rte_port_ring_writer_nodrop *p = - port; - - uint64_t bsz_mask = p->bsz_mask; - uint32_t tx_buf_count = p->tx_buf_count; - uint64_t expr = (pkts_mask & (pkts_mask + 1)) | - ((pkts_mask & bsz_mask) ^ bsz_mask); - - if (expr == 0) { - uint64_t n_pkts = rte_popcount64(pkts_mask); - uint32_t n_pkts_ok; - - if (tx_buf_count) { - if (is_multi) - send_burst_mp_nodrop(p); - else - send_burst_nodrop(p); - } - - RTE_PORT_RING_WRITER_NODROP_STATS_PKTS_IN_ADD(p, n_pkts); - if (is_multi) - n_pkts_ok = - rte_ring_mp_enqueue_burst(p->ring, - (void **)pkts, n_pkts, NULL); - else - n_pkts_ok = - rte_ring_sp_enqueue_burst(p->ring, - (void **)pkts, n_pkts, NULL); - - if (n_pkts_ok >= n_pkts) - return 0; - - /* - * If we didn't manage to send all packets in single burst, move - * remaining packets to the buffer and call send burst. - */ - for (; n_pkts_ok < n_pkts; n_pkts_ok++) { - struct rte_mbuf *pkt = pkts[n_pkts_ok]; - - p->tx_buf[p->tx_buf_count++] = pkt; - } - if (is_multi) - send_burst_mp_nodrop(p); - else - send_burst_nodrop(p); - } else { - for ( ; pkts_mask; ) { - uint32_t pkt_index = rte_ctz64(pkts_mask); - uint64_t pkt_mask = 1LLU << pkt_index; - struct rte_mbuf *pkt = pkts[pkt_index]; - - p->tx_buf[tx_buf_count++] = pkt; - RTE_PORT_RING_WRITER_NODROP_STATS_PKTS_IN_ADD(p, 1); - pkts_mask &= ~pkt_mask; - } - - p->tx_buf_count = tx_buf_count; - if (tx_buf_count >= p->tx_burst_sz) { - if (is_multi) - send_burst_mp_nodrop(p); - else - send_burst_nodrop(p); - } - } - - return 0; -} - -static int -rte_port_ring_writer_nodrop_tx_bulk(void *port, - struct rte_mbuf **pkts, - uint64_t pkts_mask) -{ - return - rte_port_ring_writer_nodrop_tx_bulk_internal(port, pkts, pkts_mask, 0); -} - -static int -rte_port_ring_multi_writer_nodrop_tx_bulk(void *port, - struct rte_mbuf **pkts, - uint64_t pkts_mask) -{ - return - rte_port_ring_writer_nodrop_tx_bulk_internal(port, pkts, pkts_mask, 1); -} - -static int -rte_port_ring_writer_nodrop_flush(void *port) -{ - struct rte_port_ring_writer_nodrop *p = - port; - - if (p->tx_buf_count > 0) - send_burst_nodrop(p); - - return 0; -} - -static int -rte_port_ring_multi_writer_nodrop_flush(void *port) -{ - struct rte_port_ring_writer_nodrop *p = - port; - - if (p->tx_buf_count > 0) - send_burst_mp_nodrop(p); - - return 0; -} - -static int -rte_port_ring_writer_nodrop_free(void *port) -{ - struct rte_port_ring_writer_nodrop *p = - port; - - if (port == NULL) { - PORT_LOG(ERR, "%s: Port is NULL", __func__); - return -EINVAL; - } - - if (p->is_multi) - rte_port_ring_multi_writer_nodrop_flush(port); - else - rte_port_ring_writer_nodrop_flush(port); - - rte_free(port); - - return 0; -} - -static int -rte_port_ring_writer_nodrop_stats_read(void *port, - struct rte_port_out_stats *stats, int clear) -{ - struct rte_port_ring_writer_nodrop *p = - port; - - if (stats != NULL) - memcpy(stats, &p->stats, sizeof(p->stats)); - - if (clear) - memset(&p->stats, 0, sizeof(p->stats)); - - return 0; -} - -/* - * Summary of port operations - */ -RTE_EXPORT_SYMBOL(rte_port_ring_reader_ops) -struct rte_port_in_ops rte_port_ring_reader_ops = { - .f_create = rte_port_ring_reader_create, - .f_free = rte_port_ring_reader_free, - .f_rx = rte_port_ring_reader_rx, - .f_stats = rte_port_ring_reader_stats_read, -}; - -RTE_EXPORT_SYMBOL(rte_port_ring_writer_ops) -struct rte_port_out_ops rte_port_ring_writer_ops = { - .f_create = rte_port_ring_writer_create, - .f_free = rte_port_ring_writer_free, - .f_tx = rte_port_ring_writer_tx, - .f_tx_bulk = rte_port_ring_writer_tx_bulk, - .f_flush = rte_port_ring_writer_flush, - .f_stats = rte_port_ring_writer_stats_read, -}; - -RTE_EXPORT_SYMBOL(rte_port_ring_writer_nodrop_ops) -struct rte_port_out_ops rte_port_ring_writer_nodrop_ops = { - .f_create = rte_port_ring_writer_nodrop_create, - .f_free = rte_port_ring_writer_nodrop_free, - .f_tx = rte_port_ring_writer_nodrop_tx, - .f_tx_bulk = rte_port_ring_writer_nodrop_tx_bulk, - .f_flush = rte_port_ring_writer_nodrop_flush, - .f_stats = rte_port_ring_writer_nodrop_stats_read, -}; - -RTE_EXPORT_SYMBOL(rte_port_ring_multi_reader_ops) -struct rte_port_in_ops rte_port_ring_multi_reader_ops = { - .f_create = rte_port_ring_multi_reader_create, - .f_free = rte_port_ring_reader_free, - .f_rx = rte_port_ring_multi_reader_rx, - .f_stats = rte_port_ring_reader_stats_read, -}; - -RTE_EXPORT_SYMBOL(rte_port_ring_multi_writer_ops) -struct rte_port_out_ops rte_port_ring_multi_writer_ops = { - .f_create = rte_port_ring_multi_writer_create, - .f_free = rte_port_ring_writer_free, - .f_tx = rte_port_ring_multi_writer_tx, - .f_tx_bulk = rte_port_ring_multi_writer_tx_bulk, - .f_flush = rte_port_ring_multi_writer_flush, - .f_stats = rte_port_ring_writer_stats_read, -}; - -RTE_EXPORT_SYMBOL(rte_port_ring_multi_writer_nodrop_ops) -struct rte_port_out_ops rte_port_ring_multi_writer_nodrop_ops = { - .f_create = rte_port_ring_multi_writer_nodrop_create, - .f_free = rte_port_ring_writer_nodrop_free, - .f_tx = rte_port_ring_multi_writer_nodrop_tx, - .f_tx_bulk = rte_port_ring_multi_writer_nodrop_tx_bulk, - .f_flush = rte_port_ring_multi_writer_nodrop_flush, - .f_stats = rte_port_ring_writer_nodrop_stats_read, -}; diff --git a/lib/port/rte_port_ring.h b/lib/port/rte_port_ring.h deleted file mode 100644 index 2089d0889b..0000000000 --- a/lib/port/rte_port_ring.h +++ /dev/null @@ -1,91 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2010-2014 Intel Corporation - */ - -#ifndef __INCLUDE_RTE_PORT_RING_H__ -#define __INCLUDE_RTE_PORT_RING_H__ - -/** - * @file - * RTE Port Ring - * - * ring_reader: - * input port built on top of pre-initialized single consumer ring - * ring_writer: - * output port built on top of pre-initialized single producer ring - * ring_multi_reader: - * input port built on top of pre-initialized multi consumers ring - * ring_multi_writer: - * output port built on top of pre-initialized multi producers ring - */ - -#include - -#include "rte_port.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** ring_reader port parameters */ -struct rte_port_ring_reader_params { - /** Underlying consumer ring that has to be pre-initialized */ - struct rte_ring *ring; -}; - -/** ring_reader port operations */ -extern struct rte_port_in_ops rte_port_ring_reader_ops; - -/** ring_writer port parameters */ -struct rte_port_ring_writer_params { - /** Underlying producer ring that has to be pre-initialized */ - struct rte_ring *ring; - - /** Recommended burst size to ring. The actual burst size can be - bigger or smaller than this value. */ - uint32_t tx_burst_sz; -}; - -/** ring_writer port operations */ -extern struct rte_port_out_ops rte_port_ring_writer_ops; - -/** ring_writer_nodrop port parameters */ -struct rte_port_ring_writer_nodrop_params { - /** Underlying producer ring that has to be pre-initialized */ - struct rte_ring *ring; - - /** Recommended burst size to ring. The actual burst size can be - bigger or smaller than this value. */ - uint32_t tx_burst_sz; - - /** Maximum number of retries, 0 for no limit */ - uint32_t n_retries; -}; - -/** ring_writer_nodrop port operations */ -extern struct rte_port_out_ops rte_port_ring_writer_nodrop_ops; - -/** ring_multi_reader port parameters */ -#define rte_port_ring_multi_reader_params rte_port_ring_reader_params - -/** ring_multi_reader port operations */ -extern struct rte_port_in_ops rte_port_ring_multi_reader_ops; - -/** ring_multi_writer port parameters */ -#define rte_port_ring_multi_writer_params rte_port_ring_writer_params - -/** ring_multi_writer port operations */ -extern struct rte_port_out_ops rte_port_ring_multi_writer_ops; - -/** ring_multi_writer_nodrop port parameters */ -#define rte_port_ring_multi_writer_nodrop_params \ - rte_port_ring_writer_nodrop_params - -/** ring_multi_writer_nodrop port operations */ -extern struct rte_port_out_ops rte_port_ring_multi_writer_nodrop_ops; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/port/rte_port_sched.c b/lib/port/rte_port_sched.c deleted file mode 100644 index 3091078aa1..0000000000 --- a/lib/port/rte_port_sched.c +++ /dev/null @@ -1,298 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2010-2014 Intel Corporation - */ -#include - -#include -#include - -#include "rte_port_sched.h" - -#include "port_log.h" - -/* - * Reader - */ -#ifdef RTE_PORT_STATS_COLLECT - -#define RTE_PORT_SCHED_READER_PKTS_IN_ADD(port, val) \ - port->stats.n_pkts_in += val -#define RTE_PORT_SCHED_READER_PKTS_DROP_ADD(port, val) \ - port->stats.n_pkts_drop += val - -#else - -#define RTE_PORT_SCHED_READER_PKTS_IN_ADD(port, val) -#define RTE_PORT_SCHED_READER_PKTS_DROP_ADD(port, val) - -#endif - -struct rte_port_sched_reader { - struct rte_port_in_stats stats; - - struct rte_sched_port *sched; -}; - -static void * -rte_port_sched_reader_create(void *params, int socket_id) -{ - struct rte_port_sched_reader_params *conf = - params; - struct rte_port_sched_reader *port; - - /* Check input parameters */ - if ((conf == NULL) || - (conf->sched == NULL)) { - PORT_LOG(ERR, "%s: Invalid params", __func__); - return NULL; - } - - /* Memory allocation */ - port = rte_zmalloc_socket("PORT", sizeof(*port), - RTE_CACHE_LINE_SIZE, socket_id); - if (port == NULL) { - PORT_LOG(ERR, "%s: Failed to allocate port", __func__); - return NULL; - } - - /* Initialization */ - port->sched = conf->sched; - - return port; -} - -static int -rte_port_sched_reader_rx(void *port, struct rte_mbuf **pkts, uint32_t n_pkts) -{ - struct rte_port_sched_reader *p = port; - uint32_t nb_rx; - - nb_rx = rte_sched_port_dequeue(p->sched, pkts, n_pkts); - RTE_PORT_SCHED_READER_PKTS_IN_ADD(p, nb_rx); - - return nb_rx; -} - -static int -rte_port_sched_reader_free(void *port) -{ - if (port == NULL) { - PORT_LOG(ERR, "%s: port is NULL", __func__); - return -EINVAL; - } - - rte_free(port); - - return 0; -} - -static int -rte_port_sched_reader_stats_read(void *port, - struct rte_port_in_stats *stats, int clear) -{ - struct rte_port_sched_reader *p = - port; - - if (stats != NULL) - memcpy(stats, &p->stats, sizeof(p->stats)); - - if (clear) - memset(&p->stats, 0, sizeof(p->stats)); - - return 0; -} - -/* - * Writer - */ -#ifdef RTE_PORT_STATS_COLLECT - -#define RTE_PORT_SCHED_WRITER_STATS_PKTS_IN_ADD(port, val) \ - port->stats.n_pkts_in += val -#define RTE_PORT_SCHED_WRITER_STATS_PKTS_DROP_ADD(port, val) \ - port->stats.n_pkts_drop += val - -#else - -#define RTE_PORT_SCHED_WRITER_STATS_PKTS_IN_ADD(port, val) -#define RTE_PORT_SCHED_WRITER_STATS_PKTS_DROP_ADD(port, val) - -#endif - -struct rte_port_sched_writer { - struct rte_port_out_stats stats; - - struct rte_mbuf *tx_buf[2 * RTE_PORT_IN_BURST_SIZE_MAX]; - struct rte_sched_port *sched; - uint32_t tx_burst_sz; - uint32_t tx_buf_count; - uint64_t bsz_mask; -}; - -static void * -rte_port_sched_writer_create(void *params, int socket_id) -{ - struct rte_port_sched_writer_params *conf = - params; - struct rte_port_sched_writer *port; - - /* Check input parameters */ - if ((conf == NULL) || - (conf->sched == NULL) || - (conf->tx_burst_sz == 0) || - (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) || - (!rte_is_power_of_2(conf->tx_burst_sz))) { - PORT_LOG(ERR, "%s: Invalid params", __func__); - return NULL; - } - - /* Memory allocation */ - port = rte_zmalloc_socket("PORT", sizeof(*port), - RTE_CACHE_LINE_SIZE, socket_id); - if (port == NULL) { - PORT_LOG(ERR, "%s: Failed to allocate port", __func__); - return NULL; - } - - /* Initialization */ - port->sched = conf->sched; - port->tx_burst_sz = conf->tx_burst_sz; - port->tx_buf_count = 0; - port->bsz_mask = 1LLU << (conf->tx_burst_sz - 1); - - return port; -} - -static int -rte_port_sched_writer_tx(void *port, struct rte_mbuf *pkt) -{ - struct rte_port_sched_writer *p = (struct rte_port_sched_writer *) port; - - p->tx_buf[p->tx_buf_count++] = pkt; - RTE_PORT_SCHED_WRITER_STATS_PKTS_IN_ADD(p, 1); - if (p->tx_buf_count >= p->tx_burst_sz) { - __rte_unused uint32_t nb_tx; - - nb_tx = rte_sched_port_enqueue(p->sched, p->tx_buf, p->tx_buf_count); - RTE_PORT_SCHED_WRITER_STATS_PKTS_DROP_ADD(p, p->tx_buf_count - nb_tx); - p->tx_buf_count = 0; - } - - return 0; -} - -static int -rte_port_sched_writer_tx_bulk(void *port, - struct rte_mbuf **pkts, - uint64_t pkts_mask) -{ - struct rte_port_sched_writer *p = (struct rte_port_sched_writer *) port; - uint64_t bsz_mask = p->bsz_mask; - uint32_t tx_buf_count = p->tx_buf_count; - uint64_t expr = (pkts_mask & (pkts_mask + 1)) | - ((pkts_mask & bsz_mask) ^ bsz_mask); - - if (expr == 0) { - __rte_unused uint32_t nb_tx; - uint64_t n_pkts = rte_popcount64(pkts_mask); - - if (tx_buf_count) { - nb_tx = rte_sched_port_enqueue(p->sched, p->tx_buf, - tx_buf_count); - RTE_PORT_SCHED_WRITER_STATS_PKTS_DROP_ADD(p, tx_buf_count - nb_tx); - p->tx_buf_count = 0; - } - - nb_tx = rte_sched_port_enqueue(p->sched, pkts, n_pkts); - RTE_PORT_SCHED_WRITER_STATS_PKTS_DROP_ADD(p, n_pkts - nb_tx); - } else { - for ( ; pkts_mask; ) { - uint32_t pkt_index = rte_ctz64(pkts_mask); - uint64_t pkt_mask = 1LLU << pkt_index; - struct rte_mbuf *pkt = pkts[pkt_index]; - - p->tx_buf[tx_buf_count++] = pkt; - RTE_PORT_SCHED_WRITER_STATS_PKTS_IN_ADD(p, 1); - pkts_mask &= ~pkt_mask; - } - p->tx_buf_count = tx_buf_count; - - if (tx_buf_count >= p->tx_burst_sz) { - __rte_unused uint32_t nb_tx; - - nb_tx = rte_sched_port_enqueue(p->sched, p->tx_buf, - tx_buf_count); - RTE_PORT_SCHED_WRITER_STATS_PKTS_DROP_ADD(p, tx_buf_count - nb_tx); - p->tx_buf_count = 0; - } - } - - return 0; -} - -static int -rte_port_sched_writer_flush(void *port) -{ - struct rte_port_sched_writer *p = (struct rte_port_sched_writer *) port; - - if (p->tx_buf_count) { - __rte_unused uint32_t nb_tx; - - nb_tx = rte_sched_port_enqueue(p->sched, p->tx_buf, p->tx_buf_count); - RTE_PORT_SCHED_WRITER_STATS_PKTS_DROP_ADD(p, p->tx_buf_count - nb_tx); - p->tx_buf_count = 0; - } - - return 0; -} - -static int -rte_port_sched_writer_free(void *port) -{ - if (port == NULL) { - PORT_LOG(ERR, "%s: port is NULL", __func__); - return -EINVAL; - } - - rte_port_sched_writer_flush(port); - rte_free(port); - - return 0; -} - -static int -rte_port_sched_writer_stats_read(void *port, - struct rte_port_out_stats *stats, int clear) -{ - struct rte_port_sched_writer *p = - port; - - if (stats != NULL) - memcpy(stats, &p->stats, sizeof(p->stats)); - - if (clear) - memset(&p->stats, 0, sizeof(p->stats)); - - return 0; -} - -/* - * Summary of port operations - */ -RTE_EXPORT_SYMBOL(rte_port_sched_reader_ops) -struct rte_port_in_ops rte_port_sched_reader_ops = { - .f_create = rte_port_sched_reader_create, - .f_free = rte_port_sched_reader_free, - .f_rx = rte_port_sched_reader_rx, - .f_stats = rte_port_sched_reader_stats_read, -}; - -RTE_EXPORT_SYMBOL(rte_port_sched_writer_ops) -struct rte_port_out_ops rte_port_sched_writer_ops = { - .f_create = rte_port_sched_writer_create, - .f_free = rte_port_sched_writer_free, - .f_tx = rte_port_sched_writer_tx, - .f_tx_bulk = rte_port_sched_writer_tx_bulk, - .f_flush = rte_port_sched_writer_flush, - .f_stats = rte_port_sched_writer_stats_read, -}; diff --git a/lib/port/rte_port_sched.h b/lib/port/rte_port_sched.h deleted file mode 100644 index 1bf08ae6a9..0000000000 --- a/lib/port/rte_port_sched.h +++ /dev/null @@ -1,52 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2010-2014 Intel Corporation - */ - -#ifndef __INCLUDE_RTE_PORT_SCHED_H__ -#define __INCLUDE_RTE_PORT_SCHED_H__ - -/** - * @file - * RTE Port Hierarchical Scheduler - * - * sched_reader: input port built on top of pre-initialized rte_sched_port - * sched_writer: output port built on top of pre-initialized rte_sched_port - */ - -#include - -#include - -#include "rte_port.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** sched_reader port parameters */ -struct rte_port_sched_reader_params { - /** Underlying pre-initialized rte_sched_port */ - struct rte_sched_port *sched; -}; - -/** sched_reader port operations */ -extern struct rte_port_in_ops rte_port_sched_reader_ops; - -/** sched_writer port parameters */ -struct rte_port_sched_writer_params { - /** Underlying pre-initialized rte_sched_port */ - struct rte_sched_port *sched; - - /** Recommended burst size. The actual burst size can be bigger or - smaller than this value. */ - uint32_t tx_burst_sz; -}; - -/** sched_writer port operations */ -extern struct rte_port_out_ops rte_port_sched_writer_ops; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/port/rte_port_source_sink.c b/lib/port/rte_port_source_sink.c deleted file mode 100644 index 0557e12506..0000000000 --- a/lib/port/rte_port_source_sink.c +++ /dev/null @@ -1,616 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2010-2016 Intel Corporation - */ -#include -#include - -#include -#include -#include -#include - -#ifdef RTE_PORT_PCAP -#include -#include -#endif - -#include "rte_port_source_sink.h" - -#include "port_log.h" - -/* - * Port SOURCE - */ -#ifdef RTE_PORT_STATS_COLLECT - -#define RTE_PORT_SOURCE_STATS_PKTS_IN_ADD(port, val) \ - port->stats.n_pkts_in += val -#define RTE_PORT_SOURCE_STATS_PKTS_DROP_ADD(port, val) \ - port->stats.n_pkts_drop += val - -#else - -#define RTE_PORT_SOURCE_STATS_PKTS_IN_ADD(port, val) -#define RTE_PORT_SOURCE_STATS_PKTS_DROP_ADD(port, val) - -#endif - -struct rte_port_source { - struct rte_port_in_stats stats; - - struct rte_mempool *mempool; - - /* PCAP buffers and indices */ - uint8_t **pkts; - uint8_t *pkt_buff; - uint32_t *pkt_len; - uint32_t n_pkts; - uint32_t pkt_index; -}; - -#ifdef RTE_PORT_PCAP - -static int -pcap_source_load(struct rte_port_source *port, - const char *file_name, - uint32_t n_bytes_per_pkt, - int socket_id) -{ - uint32_t n_pkts = 0; - uint32_t i; - uint32_t *pkt_len_aligns = NULL; - size_t total_buff_len = 0; - pcap_t *pcap_handle; - char pcap_errbuf[PCAP_ERRBUF_SIZE]; - uint32_t max_len; - struct pcap_pkthdr pcap_hdr; - const uint8_t *pkt; - uint8_t *buff = NULL; - uint32_t pktmbuf_maxlen = (uint32_t) - (rte_pktmbuf_data_room_size(port->mempool) - - RTE_PKTMBUF_HEADROOM); - - if (n_bytes_per_pkt == 0) - max_len = pktmbuf_maxlen; - else - max_len = RTE_MIN(n_bytes_per_pkt, pktmbuf_maxlen); - - /* first time open, get packet number */ - pcap_handle = pcap_open_offline(file_name, pcap_errbuf); - if (pcap_handle == NULL) { - PORT_LOG(ERR, "Failed to open pcap file " - "'%s' for reading", file_name); - goto error_exit; - } - - while ((pkt = pcap_next(pcap_handle, &pcap_hdr)) != NULL) - n_pkts++; - - pcap_close(pcap_handle); - - port->pkt_len = rte_zmalloc_socket("PCAP", - (sizeof(*port->pkt_len) * n_pkts), 0, socket_id); - if (port->pkt_len == NULL) { - PORT_LOG(ERR, "No enough memory"); - goto error_exit; - } - - pkt_len_aligns = rte_malloc("PCAP", - (sizeof(*pkt_len_aligns) * n_pkts), 0); - if (pkt_len_aligns == NULL) { - PORT_LOG(ERR, "No enough memory"); - goto error_exit; - } - - port->pkts = rte_zmalloc_socket("PCAP", - (sizeof(*port->pkts) * n_pkts), 0, socket_id); - if (port->pkts == NULL) { - PORT_LOG(ERR, "No enough memory"); - goto error_exit; - } - - /* open 2nd time, get pkt_len */ - pcap_handle = pcap_open_offline(file_name, pcap_errbuf); - if (pcap_handle == NULL) { - PORT_LOG(ERR, "Failed to open pcap file " - "'%s' for reading", file_name); - goto error_exit; - } - - for (i = 0; i < n_pkts; i++) { - pcap_next(pcap_handle, &pcap_hdr); - port->pkt_len[i] = RTE_MIN(max_len, pcap_hdr.len); - pkt_len_aligns[i] = RTE_CACHE_LINE_ROUNDUP( - port->pkt_len[i]); - total_buff_len += pkt_len_aligns[i]; - } - - pcap_close(pcap_handle); - - /* allocate a big trunk of data for pcap file load */ - buff = rte_zmalloc_socket("PCAP", - total_buff_len, 0, socket_id); - if (buff == NULL) { - PORT_LOG(ERR, "No enough memory"); - goto error_exit; - } - - port->pkt_buff = buff; - - /* open file one last time to copy the pkt content */ - pcap_handle = pcap_open_offline(file_name, pcap_errbuf); - if (pcap_handle == NULL) { - PORT_LOG(ERR, "Failed to open pcap file " - "'%s' for reading", file_name); - goto error_exit; - } - - for (i = 0; i < n_pkts; i++) { - pkt = pcap_next(pcap_handle, &pcap_hdr); - rte_memcpy(buff, pkt, port->pkt_len[i]); - port->pkts[i] = buff; - buff += pkt_len_aligns[i]; - } - - pcap_close(pcap_handle); - - port->n_pkts = n_pkts; - - rte_free(pkt_len_aligns); - - PORT_LOG(INFO, "Successfully load pcap file " - "'%s' with %u pkts", - file_name, port->n_pkts); - - return 0; - -error_exit: - rte_free(pkt_len_aligns); - rte_free(port->pkt_len); - rte_free(port->pkts); - rte_free(port->pkt_buff); - - return -1; -} - -#define PCAP_SOURCE_LOAD(port, file_name, n_bytes, socket_id) \ - pcap_source_load(port, file_name, n_bytes, socket_id) - -#else /* RTE_PORT_PCAP */ - -#define PCAP_SOURCE_LOAD(port, file_name, n_bytes, socket_id) \ -__extension__ ({ \ - int _ret = 0; \ - \ - if (file_name) { \ - PORT_LOG(ERR, "Source port field " \ - "\"file_name\" is not NULL."); \ - _ret = -1; \ - } \ - \ - _ret; \ -}) - -#endif /* RTE_PORT_PCAP */ - -static void * -rte_port_source_create(void *params, int socket_id) -{ - struct rte_port_source_params *p = - params; - struct rte_port_source *port; - - /* Check input arguments*/ - if ((p == NULL) || (p->mempool == NULL)) { - PORT_LOG(ERR, "%s: Invalid params", __func__); - return NULL; - } - - /* Memory allocation */ - port = rte_zmalloc_socket("PORT", sizeof(*port), - RTE_CACHE_LINE_SIZE, socket_id); - if (port == NULL) { - PORT_LOG(ERR, "%s: Failed to allocate port", __func__); - return NULL; - } - - /* Initialization */ - port->mempool = (struct rte_mempool *) p->mempool; - - if (p->file_name) { - int status = PCAP_SOURCE_LOAD(port, p->file_name, - p->n_bytes_per_pkt, socket_id); - - if (status < 0) { - rte_free(port); - port = NULL; - } - } - - return port; -} - -static int -rte_port_source_free(void *port) -{ - struct rte_port_source *p = - port; - - /* Check input parameters */ - if (p == NULL) - return 0; - - rte_free(p->pkt_len); - rte_free(p->pkts); - rte_free(p->pkt_buff); - - rte_free(p); - - return 0; -} - -static int -rte_port_source_rx(void *port, struct rte_mbuf **pkts, uint32_t n_pkts) -{ - struct rte_port_source *p = port; - uint32_t i; - - if (rte_pktmbuf_alloc_bulk(p->mempool, pkts, n_pkts) != 0) - return 0; - - if (p->pkt_buff != NULL) { - for (i = 0; i < n_pkts; i++) { - uint8_t *pkt_data = rte_pktmbuf_mtod(pkts[i], - uint8_t *); - - rte_memcpy(pkt_data, p->pkts[p->pkt_index], - p->pkt_len[p->pkt_index]); - pkts[i]->data_len = p->pkt_len[p->pkt_index]; - pkts[i]->pkt_len = pkts[i]->data_len; - - p->pkt_index++; - if (p->pkt_index >= p->n_pkts) - p->pkt_index = 0; - } - } - - RTE_PORT_SOURCE_STATS_PKTS_IN_ADD(p, n_pkts); - - return n_pkts; -} - -static int -rte_port_source_stats_read(void *port, - struct rte_port_in_stats *stats, int clear) -{ - struct rte_port_source *p = - port; - - if (stats != NULL) - memcpy(stats, &p->stats, sizeof(p->stats)); - - if (clear) - memset(&p->stats, 0, sizeof(p->stats)); - - return 0; -} - -/* - * Port SINK - */ -#ifdef RTE_PORT_STATS_COLLECT - -#define RTE_PORT_SINK_STATS_PKTS_IN_ADD(port, val) \ - (port->stats.n_pkts_in += val) -#define RTE_PORT_SINK_STATS_PKTS_DROP_ADD(port, val) \ - (port->stats.n_pkts_drop += val) - -#else - -#define RTE_PORT_SINK_STATS_PKTS_IN_ADD(port, val) -#define RTE_PORT_SINK_STATS_PKTS_DROP_ADD(port, val) - -#endif - -struct rte_port_sink { - struct rte_port_out_stats stats; - - /* PCAP dumper handle and pkts number */ - void *dumper; - uint32_t max_pkts; - uint32_t pkt_index; - uint32_t dump_finish; -}; - -#ifdef RTE_PORT_PCAP - -static int -pcap_sink_open(struct rte_port_sink *port, - const char *file_name, - uint32_t max_n_pkts) -{ - pcap_t *tx_pcap; - pcap_dumper_t *pcap_dumper; - - /** Open a dead pcap handler for opening dumper file */ - tx_pcap = pcap_open_dead(DLT_EN10MB, 65535); - if (tx_pcap == NULL) { - PORT_LOG(ERR, "Cannot open pcap dead handler"); - return -1; - } - - /* The dumper is created using the previous pcap_t reference */ - pcap_dumper = pcap_dump_open(tx_pcap, file_name); - if (pcap_dumper == NULL) { - PORT_LOG(ERR, "Failed to open pcap file " - "\"%s\" for writing", file_name); - return -1; - } - - port->dumper = pcap_dumper; - port->max_pkts = max_n_pkts; - port->pkt_index = 0; - port->dump_finish = 0; - - PORT_LOG(INFO, "Ready to dump packets to file \"%s\"", - file_name); - - return 0; -} - -static void -pcap_sink_write_pkt(struct rte_port_sink *port, struct rte_mbuf *mbuf) -{ - uint8_t *pcap_dumper = (port->dumper); - struct pcap_pkthdr pcap_hdr; - uint8_t jumbo_pkt_buf[RTE_ETHER_MAX_JUMBO_FRAME_LEN]; - uint8_t *pkt; - - /* Maximum num packets already reached */ - if (port->dump_finish) - return; - - pkt = rte_pktmbuf_mtod(mbuf, uint8_t *); - - pcap_hdr.len = mbuf->pkt_len; - pcap_hdr.caplen = pcap_hdr.len; - gettimeofday(&(pcap_hdr.ts), NULL); - - if (mbuf->nb_segs > 1) { - struct rte_mbuf *jumbo_mbuf; - uint32_t pkt_index = 0; - - /* if packet size longer than RTE_ETHER_MAX_JUMBO_FRAME_LEN, - * ignore it. - */ - if (mbuf->pkt_len > RTE_ETHER_MAX_JUMBO_FRAME_LEN) - return; - - for (jumbo_mbuf = mbuf; jumbo_mbuf != NULL; - jumbo_mbuf = jumbo_mbuf->next) { - rte_memcpy(&jumbo_pkt_buf[pkt_index], - rte_pktmbuf_mtod(jumbo_mbuf, uint8_t *), - jumbo_mbuf->data_len); - pkt_index += jumbo_mbuf->data_len; - } - - jumbo_pkt_buf[pkt_index] = '\0'; - - pkt = jumbo_pkt_buf; - } - - pcap_dump(pcap_dumper, &pcap_hdr, pkt); - - port->pkt_index++; - - if ((port->max_pkts != 0) && (port->pkt_index >= port->max_pkts)) { - port->dump_finish = 1; - PORT_LOG(INFO, "Dumped %u packets to file", - port->pkt_index); - } - -} - -#define PCAP_SINK_OPEN(port, file_name, max_n_pkts) \ - pcap_sink_open(port, file_name, max_n_pkts) - -#define PCAP_SINK_WRITE_PKT(port, mbuf) \ - pcap_sink_write_pkt(port, mbuf) - -#define PCAP_SINK_FLUSH_PKT(dumper) \ -do { \ - if (dumper) \ - pcap_dump_flush((pcap_dumper_t *)dumper); \ -} while (0) - -#define PCAP_SINK_CLOSE(dumper) \ -do { \ - if (dumper) \ - pcap_dump_close((pcap_dumper_t *)dumper); \ -} while (0) - -#else - -#define PCAP_SINK_OPEN(port, file_name, max_n_pkts) \ -__extension__ ({ \ - int _ret = 0; \ - \ - if (file_name) { \ - PORT_LOG(ERR, "Sink port field " \ - "\"file_name\" is not NULL."); \ - _ret = -1; \ - } \ - \ - _ret; \ -}) - -#define PCAP_SINK_WRITE_PKT(port, mbuf) {} - -#define PCAP_SINK_FLUSH_PKT(dumper) - -#define PCAP_SINK_CLOSE(dumper) - -#endif - -static void * -rte_port_sink_create(void *params, int socket_id) -{ - struct rte_port_sink *port; - struct rte_port_sink_params *p = params; - - /* Memory allocation */ - port = rte_zmalloc_socket("PORT", sizeof(*port), - RTE_CACHE_LINE_SIZE, socket_id); - if (port == NULL) { - PORT_LOG(ERR, "%s: Failed to allocate port", __func__); - return NULL; - } - - if (!p) - return port; - - if (p->file_name) { - int status = PCAP_SINK_OPEN(port, p->file_name, - p->max_n_pkts); - - if (status < 0) { - rte_free(port); - port = NULL; - } - } - - return port; -} - -static int -rte_port_sink_tx(void *port, struct rte_mbuf *pkt) -{ - struct rte_port_sink *p = port; - - RTE_PORT_SINK_STATS_PKTS_IN_ADD(p, 1); - if (p->dumper != NULL) - PCAP_SINK_WRITE_PKT(p, pkt); - rte_pktmbuf_free(pkt); - RTE_PORT_SINK_STATS_PKTS_DROP_ADD(p, 1); - - return 0; -} - -static int -rte_port_sink_tx_bulk(void *port, struct rte_mbuf **pkts, - uint64_t pkts_mask) -{ - struct rte_port_sink *p = port; - - if ((pkts_mask & (pkts_mask + 1)) == 0) { - uint64_t n_pkts = rte_popcount64(pkts_mask); - uint32_t i; - - RTE_PORT_SINK_STATS_PKTS_IN_ADD(p, n_pkts); - RTE_PORT_SINK_STATS_PKTS_DROP_ADD(p, n_pkts); - - if (p->dumper) { - for (i = 0; i < n_pkts; i++) - PCAP_SINK_WRITE_PKT(p, pkts[i]); - } - - for (i = 0; i < n_pkts; i++) { - struct rte_mbuf *pkt = pkts[i]; - - rte_pktmbuf_free(pkt); - } - - } else { - if (p->dumper) { - uint64_t dump_pkts_mask = pkts_mask; - uint32_t pkt_index; - - for ( ; dump_pkts_mask; ) { - pkt_index = rte_ctz64( - dump_pkts_mask); - PCAP_SINK_WRITE_PKT(p, pkts[pkt_index]); - dump_pkts_mask &= ~(1LLU << pkt_index); - } - } - - for ( ; pkts_mask; ) { - uint32_t pkt_index = rte_ctz64(pkts_mask); - uint64_t pkt_mask = 1LLU << pkt_index; - struct rte_mbuf *pkt = pkts[pkt_index]; - - RTE_PORT_SINK_STATS_PKTS_IN_ADD(p, 1); - RTE_PORT_SINK_STATS_PKTS_DROP_ADD(p, 1); - rte_pktmbuf_free(pkt); - pkts_mask &= ~pkt_mask; - } - } - - return 0; -} - -static int -rte_port_sink_flush(void *port) -{ - struct rte_port_sink *p = - port; - - if (p == NULL) - return 0; - - PCAP_SINK_FLUSH_PKT(p->dumper); - - return 0; -} - -static int -rte_port_sink_free(void *port) -{ - struct rte_port_sink *p = - port; - - if (p == NULL) - return 0; - - PCAP_SINK_CLOSE(p->dumper); - - rte_free(p); - - return 0; -} - -static int -rte_port_sink_stats_read(void *port, struct rte_port_out_stats *stats, - int clear) -{ - struct rte_port_sink *p = - port; - - if (stats != NULL) - memcpy(stats, &p->stats, sizeof(p->stats)); - - if (clear) - memset(&p->stats, 0, sizeof(p->stats)); - - return 0; -} - -/* - * Summary of port operations - */ -RTE_EXPORT_SYMBOL(rte_port_source_ops) -struct rte_port_in_ops rte_port_source_ops = { - .f_create = rte_port_source_create, - .f_free = rte_port_source_free, - .f_rx = rte_port_source_rx, - .f_stats = rte_port_source_stats_read, -}; - -RTE_EXPORT_SYMBOL(rte_port_sink_ops) -struct rte_port_out_ops rte_port_sink_ops = { - .f_create = rte_port_sink_create, - .f_free = rte_port_sink_free, - .f_tx = rte_port_sink_tx, - .f_tx_bulk = rte_port_sink_tx_bulk, - .f_flush = rte_port_sink_flush, - .f_stats = rte_port_sink_stats_read, -}; diff --git a/lib/port/rte_port_source_sink.h b/lib/port/rte_port_source_sink.h deleted file mode 100644 index 3122dd5038..0000000000 --- a/lib/port/rte_port_source_sink.h +++ /dev/null @@ -1,57 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2010-2016 Intel Corporation - */ - -#ifndef __INCLUDE_RTE_PORT_SOURCE_SINK_H__ -#define __INCLUDE_RTE_PORT_SOURCE_SINK_H__ - -/** - * @file - * RTE Port Source/Sink - * - * source: input port that can be used to generate packets - * sink: output port that drops all packets written to it - */ - -#include "rte_port.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** source port parameters */ -struct rte_port_source_params { - /** Pre-initialized buffer pool */ - struct rte_mempool *mempool; - - /** The full path of the pcap file to read packets from */ - const char *file_name; - /** The number of bytes to be read from each packet in the - * pcap file. If this value is 0, the whole packet is read; - * if it is bigger than packet size, the generated packets - * will contain the whole packet */ - uint32_t n_bytes_per_pkt; -}; - -/** source port operations */ -extern struct rte_port_in_ops rte_port_source_ops; - -/** sink port parameters */ -struct rte_port_sink_params { - /** The full path of the pcap file to write the packets to */ - const char *file_name; - /** The maximum number of packets write to the pcap file. - * If this value is 0, the "infinite" write will be carried - * out. - */ - uint32_t max_n_pkts; -}; - -/** sink port operations */ -extern struct rte_port_out_ops rte_port_sink_ops; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/port/rte_port_sym_crypto.c b/lib/port/rte_port_sym_crypto.c deleted file mode 100644 index 30c9d1283e..0000000000 --- a/lib/port/rte_port_sym_crypto.c +++ /dev/null @@ -1,558 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2018 Intel Corporation - */ -#include - -#include -#include -#include - -#include "rte_port_sym_crypto.h" - -#include "port_log.h" - -/* - * Port Crypto Reader - */ -#ifdef RTE_PORT_STATS_COLLECT - -#define RTE_PORT_SYM_CRYPTO_READER_STATS_PKTS_IN_ADD(port, val) \ - (port)->stats.n_pkts_in += (val) -#define RTE_PORT_SYM_CRYPTO_READER_STATS_PKTS_DROP_ADD(port, val) \ - (port)->stats.n_pkts_drop += (val) - -#else - -#define RTE_PORT_SYM_CRYPTO_READER_STATS_PKTS_IN_ADD(port, val) -#define RTE_PORT_SYM_CRYPTO_READER_STATS_PKTS_DROP_ADD(port, val) - -#endif - -struct rte_port_sym_crypto_reader { - struct rte_port_in_stats stats; - - uint8_t cryptodev_id; - uint16_t queue_id; - struct rte_crypto_op *ops[RTE_PORT_IN_BURST_SIZE_MAX]; - rte_port_sym_crypto_reader_callback_fn f_callback; - void *arg_callback; -}; - -static void * -rte_port_sym_crypto_reader_create(void *params, int socket_id) -{ - struct rte_port_sym_crypto_reader_params *conf = - params; - struct rte_port_sym_crypto_reader *port; - - /* Check input parameters */ - if (conf == NULL) { - PORT_LOG(ERR, "%s: params is NULL", __func__); - return NULL; - } - - /* Memory allocation */ - port = rte_zmalloc_socket("PORT", sizeof(*port), - RTE_CACHE_LINE_SIZE, socket_id); - if (port == NULL) { - PORT_LOG(ERR, "%s: Failed to allocate port", __func__); - return NULL; - } - - /* Initialization */ - port->cryptodev_id = conf->cryptodev_id; - port->queue_id = conf->queue_id; - port->f_callback = conf->f_callback; - port->arg_callback = conf->arg_callback; - - return port; -} - -static int -rte_port_sym_crypto_reader_rx(void *port, struct rte_mbuf **pkts, uint32_t n_pkts) -{ - struct rte_port_sym_crypto_reader *p = - port; - uint16_t rx_ops_cnt, i, n = 0; - - rx_ops_cnt = rte_cryptodev_dequeue_burst(p->cryptodev_id, p->queue_id, - p->ops, n_pkts); - - for (i = 0; i < rx_ops_cnt; i++) { - struct rte_crypto_op *op = p->ops[i]; - - /** Drop failed pkts */ - if (unlikely(op->status != RTE_CRYPTO_OP_STATUS_SUCCESS)) { - rte_pktmbuf_free(op->sym->m_src); - continue; - } - - pkts[n++] = op->sym->m_src; - } - - if (p->f_callback) - (*p->f_callback)(pkts, n, p->arg_callback); - - RTE_PORT_SYM_CRYPTO_READER_STATS_PKTS_IN_ADD(p, n); - RTE_PORT_SYM_CRYPTO_READER_STATS_PKTS_DROP_ADD(p, rx_ops_cnt - n); - - return n; -} - -static int -rte_port_sym_crypto_reader_free(void *port) -{ - if (port == NULL) { - PORT_LOG(ERR, "%s: port is NULL", __func__); - return -EINVAL; - } - - rte_free(port); - - return 0; -} - -static int rte_port_sym_crypto_reader_stats_read(void *port, - struct rte_port_in_stats *stats, int clear) -{ - struct rte_port_sym_crypto_reader *p = - port; - - if (stats != NULL) - memcpy(stats, &p->stats, sizeof(p->stats)); - - if (clear) - memset(&p->stats, 0, sizeof(p->stats)); - - return 0; -} - -/* - * Port crypto Writer - */ -#ifdef RTE_PORT_STATS_COLLECT - -#define RTE_PORT_SYM_CRYPTO_WRITER_STATS_PKTS_IN_ADD(port, val) \ - (port)->stats.n_pkts_in += (val) -#define RTE_PORT_SYM_CRYPTO_WRITER_STATS_PKTS_DROP_ADD(port, val) \ - (port)->stats.n_pkts_drop += (val) - -#else - -#define RTE_PORT_SYM_CRYPTO_WRITER_STATS_PKTS_IN_ADD(port, val) -#define RTE_PORT_SYM_CRYPTO_WRITER_STATS_PKTS_DROP_ADD(port, val) - -#endif - -struct rte_port_sym_crypto_writer { - struct rte_port_out_stats stats; - - struct rte_crypto_op *tx_buf[2 * RTE_PORT_IN_BURST_SIZE_MAX]; - - uint32_t tx_burst_sz; - uint32_t tx_buf_count; - uint64_t bsz_mask; - - uint8_t cryptodev_id; - uint16_t queue_id; - uint16_t crypto_op_offset; -}; - -static void * -rte_port_sym_crypto_writer_create(void *params, int socket_id) -{ - struct rte_port_sym_crypto_writer_params *conf = - params; - struct rte_port_sym_crypto_writer *port; - - /* Check input parameters */ - if ((conf == NULL) || - (conf->tx_burst_sz == 0) || - (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) || - (!rte_is_power_of_2(conf->tx_burst_sz))) { - PORT_LOG(ERR, "%s: Invalid input parameters", __func__); - return NULL; - } - - /* Memory allocation */ - port = rte_zmalloc_socket("PORT", sizeof(*port), - RTE_CACHE_LINE_SIZE, socket_id); - if (port == NULL) { - PORT_LOG(ERR, "%s: Failed to allocate port", __func__); - return NULL; - } - - /* Initialization */ - port->tx_burst_sz = conf->tx_burst_sz; - port->tx_buf_count = 0; - port->bsz_mask = 1LLU << (conf->tx_burst_sz - 1); - - port->cryptodev_id = conf->cryptodev_id; - port->queue_id = conf->queue_id; - port->crypto_op_offset = conf->crypto_op_offset; - - return port; -} - -static inline void -send_burst(struct rte_port_sym_crypto_writer *p) -{ - uint32_t nb_tx; - - nb_tx = rte_cryptodev_enqueue_burst(p->cryptodev_id, p->queue_id, - p->tx_buf, p->tx_buf_count); - - RTE_PORT_SYM_CRYPTO_WRITER_STATS_PKTS_DROP_ADD(p, p->tx_buf_count - - nb_tx); - for (; nb_tx < p->tx_buf_count; nb_tx++) - rte_pktmbuf_free(p->tx_buf[nb_tx]->sym->m_src); - - p->tx_buf_count = 0; -} - -static int -rte_port_sym_crypto_writer_tx(void *port, struct rte_mbuf *pkt) -{ - struct rte_port_sym_crypto_writer *p = - port; - - p->tx_buf[p->tx_buf_count++] = (struct rte_crypto_op *) - RTE_MBUF_METADATA_UINT8_PTR(pkt, p->crypto_op_offset); - RTE_PORT_SYM_CRYPTO_WRITER_STATS_PKTS_IN_ADD(p, 1); - if (p->tx_buf_count >= p->tx_burst_sz) - send_burst(p); - - return 0; -} - -static int -rte_port_sym_crypto_writer_tx_bulk(void *port, - struct rte_mbuf **pkts, - uint64_t pkts_mask) -{ - struct rte_port_sym_crypto_writer *p = - port; - uint64_t bsz_mask = p->bsz_mask; - uint32_t tx_buf_count = p->tx_buf_count; - uint64_t expr = (pkts_mask & (pkts_mask + 1)) | - ((pkts_mask & bsz_mask) ^ bsz_mask); - - if (expr == 0) { - uint64_t n_pkts = rte_popcount64(pkts_mask); - uint32_t i; - - RTE_PORT_SYM_CRYPTO_WRITER_STATS_PKTS_IN_ADD(p, n_pkts); - - for (i = 0; i < n_pkts; i++) - p->tx_buf[p->tx_buf_count++] = (struct rte_crypto_op *) - RTE_MBUF_METADATA_UINT8_PTR(pkts[i], - p->crypto_op_offset); - - if (p->tx_buf_count >= p->tx_burst_sz) - send_burst(p); - } else { - for (; pkts_mask;) { - uint32_t pkt_index = rte_ctz64(pkts_mask); - uint64_t pkt_mask = 1LLU << pkt_index; - struct rte_mbuf *pkt = pkts[pkt_index]; - - p->tx_buf[tx_buf_count++] = (struct rte_crypto_op *) - RTE_MBUF_METADATA_UINT8_PTR(pkt, - p->crypto_op_offset); - - RTE_PORT_SYM_CRYPTO_WRITER_STATS_PKTS_IN_ADD(p, 1); - pkts_mask &= ~pkt_mask; - } - - p->tx_buf_count = tx_buf_count; - if (tx_buf_count >= p->tx_burst_sz) - send_burst(p); - } - - return 0; -} - -static int -rte_port_sym_crypto_writer_flush(void *port) -{ - struct rte_port_sym_crypto_writer *p = - port; - - if (p->tx_buf_count > 0) - send_burst(p); - - return 0; -} - -static int -rte_port_sym_crypto_writer_free(void *port) -{ - if (port == NULL) { - PORT_LOG(ERR, "%s: Port is NULL", __func__); - return -EINVAL; - } - - rte_port_sym_crypto_writer_flush(port); - rte_free(port); - - return 0; -} - -static int rte_port_sym_crypto_writer_stats_read(void *port, - struct rte_port_out_stats *stats, int clear) -{ - struct rte_port_sym_crypto_writer *p = - port; - - if (stats != NULL) - memcpy(stats, &p->stats, sizeof(p->stats)); - - if (clear) - memset(&p->stats, 0, sizeof(p->stats)); - - return 0; -} - -/* - * Port crypto Writer Nodrop - */ -#ifdef RTE_PORT_STATS_COLLECT - -#define RTE_PORT_SYM_CRYPTO_WRITER_NODROP_STATS_PKTS_IN_ADD(port, val) \ - (port)->stats.n_pkts_in += (val) -#define RTE_PORT_SYM_CRYPTO_WRITER_NODROP_STATS_PKTS_DROP_ADD(port, val) \ - (port)->stats.n_pkts_drop += (val) - -#else - -#define RTE_PORT_SYM_CRYPTO_WRITER_NODROP_STATS_PKTS_IN_ADD(port, val) -#define RTE_PORT_SYM_CRYPTO_WRITER_NODROP_STATS_PKTS_DROP_ADD(port, val) - -#endif - -struct rte_port_sym_crypto_writer_nodrop { - struct rte_port_out_stats stats; - - struct rte_crypto_op *tx_buf[2 * RTE_PORT_IN_BURST_SIZE_MAX]; - uint32_t tx_burst_sz; - uint32_t tx_buf_count; - uint64_t bsz_mask; - uint64_t n_retries; - - uint8_t cryptodev_id; - uint16_t queue_id; - uint16_t crypto_op_offset; -}; - -static void * -rte_port_sym_crypto_writer_nodrop_create(void *params, int socket_id) -{ - struct rte_port_sym_crypto_writer_nodrop_params *conf = - params; - struct rte_port_sym_crypto_writer_nodrop *port; - - /* Check input parameters */ - if ((conf == NULL) || - (conf->tx_burst_sz == 0) || - (conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) || - (!rte_is_power_of_2(conf->tx_burst_sz))) { - PORT_LOG(ERR, "%s: Invalid input parameters", __func__); - return NULL; - } - - /* Memory allocation */ - port = rte_zmalloc_socket("PORT", sizeof(*port), - RTE_CACHE_LINE_SIZE, socket_id); - if (port == NULL) { - PORT_LOG(ERR, "%s: Failed to allocate port", __func__); - return NULL; - } - - /* Initialization */ - port->cryptodev_id = conf->cryptodev_id; - port->queue_id = conf->queue_id; - port->crypto_op_offset = conf->crypto_op_offset; - port->tx_burst_sz = conf->tx_burst_sz; - port->tx_buf_count = 0; - port->bsz_mask = 1LLU << (conf->tx_burst_sz - 1); - - /* - * When n_retries is 0 it means that we should wait for every packet to - * send no matter how many retries should it take. To limit number of - * branches in fast path, we use UINT64_MAX instead of branching. - */ - port->n_retries = (conf->n_retries == 0) ? UINT64_MAX : conf->n_retries; - - return port; -} - -static inline void -send_burst_nodrop(struct rte_port_sym_crypto_writer_nodrop *p) -{ - uint32_t nb_tx = 0, i; - - nb_tx = rte_cryptodev_enqueue_burst(p->cryptodev_id, p->queue_id, - p->tx_buf, p->tx_buf_count); - - /* We sent all the packets in a first try */ - if (nb_tx >= p->tx_buf_count) { - p->tx_buf_count = 0; - return; - } - - for (i = 0; i < p->n_retries; i++) { - nb_tx += rte_cryptodev_enqueue_burst(p->cryptodev_id, - p->queue_id, p->tx_buf + nb_tx, - p->tx_buf_count - nb_tx); - - /* We sent all the packets in more than one try */ - if (nb_tx >= p->tx_buf_count) { - p->tx_buf_count = 0; - return; - } - } - - /* We didn't send the packets in maximum allowed attempts */ - RTE_PORT_SYM_CRYPTO_WRITER_NODROP_STATS_PKTS_DROP_ADD(p, - p->tx_buf_count - nb_tx); - for ( ; nb_tx < p->tx_buf_count; nb_tx++) - rte_pktmbuf_free(p->tx_buf[nb_tx]->sym->m_src); - - p->tx_buf_count = 0; -} - -static int -rte_port_sym_crypto_writer_nodrop_tx(void *port, struct rte_mbuf *pkt) -{ - struct rte_port_sym_crypto_writer_nodrop *p = - port; - - p->tx_buf[p->tx_buf_count++] = (struct rte_crypto_op *) - RTE_MBUF_METADATA_UINT8_PTR(pkt, p->crypto_op_offset); - RTE_PORT_SYM_CRYPTO_WRITER_STATS_PKTS_IN_ADD(p, 1); - if (p->tx_buf_count >= p->tx_burst_sz) - send_burst_nodrop(p); - - return 0; -} - -static int -rte_port_sym_crypto_writer_nodrop_tx_bulk(void *port, - struct rte_mbuf **pkts, - uint64_t pkts_mask) -{ - struct rte_port_sym_crypto_writer_nodrop *p = - port; - - uint64_t bsz_mask = p->bsz_mask; - uint32_t tx_buf_count = p->tx_buf_count; - uint64_t expr = (pkts_mask & (pkts_mask + 1)) | - ((pkts_mask & bsz_mask) ^ bsz_mask); - - if (expr == 0) { - uint64_t n_pkts = rte_popcount64(pkts_mask); - uint32_t i; - - RTE_PORT_SYM_CRYPTO_WRITER_NODROP_STATS_PKTS_IN_ADD(p, n_pkts); - - for (i = 0; i < n_pkts; i++) - p->tx_buf[p->tx_buf_count++] = (struct rte_crypto_op *) - RTE_MBUF_METADATA_UINT8_PTR(pkts[i], - p->crypto_op_offset); - - if (p->tx_buf_count >= p->tx_burst_sz) - send_burst_nodrop(p); - } else { - for ( ; pkts_mask; ) { - uint32_t pkt_index = rte_ctz64(pkts_mask); - uint64_t pkt_mask = 1LLU << pkt_index; - struct rte_mbuf *pkt = pkts[pkt_index]; - - p->tx_buf[tx_buf_count++] = (struct rte_crypto_op *) - RTE_MBUF_METADATA_UINT8_PTR(pkt, - p->crypto_op_offset); - RTE_PORT_SYM_CRYPTO_WRITER_NODROP_STATS_PKTS_IN_ADD(p, - 1); - pkts_mask &= ~pkt_mask; - } - - p->tx_buf_count = tx_buf_count; - if (tx_buf_count >= p->tx_burst_sz) - send_burst_nodrop(p); - } - - return 0; -} - -static int -rte_port_sym_crypto_writer_nodrop_flush(void *port) -{ - struct rte_port_sym_crypto_writer_nodrop *p = - port; - - if (p->tx_buf_count > 0) - send_burst_nodrop(p); - - return 0; -} - -static int -rte_port_sym_crypto_writer_nodrop_free(void *port) -{ - if (port == NULL) { - PORT_LOG(ERR, "%s: Port is NULL", __func__); - return -EINVAL; - } - - rte_port_sym_crypto_writer_nodrop_flush(port); - rte_free(port); - - return 0; -} - -static int rte_port_sym_crypto_writer_nodrop_stats_read(void *port, - struct rte_port_out_stats *stats, int clear) -{ - struct rte_port_sym_crypto_writer_nodrop *p = - port; - - if (stats != NULL) - memcpy(stats, &p->stats, sizeof(p->stats)); - - if (clear) - memset(&p->stats, 0, sizeof(p->stats)); - - return 0; -} - - -/* - * Summary of port operations - */ -RTE_EXPORT_SYMBOL(rte_port_sym_crypto_reader_ops) -struct rte_port_in_ops rte_port_sym_crypto_reader_ops = { - .f_create = rte_port_sym_crypto_reader_create, - .f_free = rte_port_sym_crypto_reader_free, - .f_rx = rte_port_sym_crypto_reader_rx, - .f_stats = rte_port_sym_crypto_reader_stats_read, -}; - -RTE_EXPORT_SYMBOL(rte_port_sym_crypto_writer_ops) -struct rte_port_out_ops rte_port_sym_crypto_writer_ops = { - .f_create = rte_port_sym_crypto_writer_create, - .f_free = rte_port_sym_crypto_writer_free, - .f_tx = rte_port_sym_crypto_writer_tx, - .f_tx_bulk = rte_port_sym_crypto_writer_tx_bulk, - .f_flush = rte_port_sym_crypto_writer_flush, - .f_stats = rte_port_sym_crypto_writer_stats_read, -}; - -RTE_EXPORT_SYMBOL(rte_port_sym_crypto_writer_nodrop_ops) -struct rte_port_out_ops rte_port_sym_crypto_writer_nodrop_ops = { - .f_create = rte_port_sym_crypto_writer_nodrop_create, - .f_free = rte_port_sym_crypto_writer_nodrop_free, - .f_tx = rte_port_sym_crypto_writer_nodrop_tx, - .f_tx_bulk = rte_port_sym_crypto_writer_nodrop_tx_bulk, - .f_flush = rte_port_sym_crypto_writer_nodrop_flush, - .f_stats = rte_port_sym_crypto_writer_nodrop_stats_read, -}; diff --git a/lib/port/rte_port_sym_crypto.h b/lib/port/rte_port_sym_crypto.h deleted file mode 100644 index d03cdc1e8b..0000000000 --- a/lib/port/rte_port_sym_crypto.h +++ /dev/null @@ -1,92 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2018 Intel Corporation - */ - -#ifndef __INCLUDE_RTE_PORT_SYM_CRYPTO_H__ -#define __INCLUDE_RTE_PORT_SYM_CRYPTO_H__ - -/** - * @file - * RTE Port sym crypto Interface - * - * crypto_reader: input port built on top of pre-initialized crypto interface - * crypto_writer: output port built on top of pre-initialized crypto interface - */ - -#include - -#include - -#include "rte_port.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** Function prototype for reader post action. */ -typedef void (*rte_port_sym_crypto_reader_callback_fn)(struct rte_mbuf **pkts, - uint16_t n_pkts, void *arg); - -/** Crypto_reader port parameters */ -struct rte_port_sym_crypto_reader_params { - /** Target cryptodev ID. */ - uint8_t cryptodev_id; - - /** Target cryptodev Queue Pair ID. */ - uint16_t queue_id; - - /** Crypto reader post callback function. */ - rte_port_sym_crypto_reader_callback_fn f_callback; - - /** Crypto reader post callback function arguments. */ - void *arg_callback; -}; - -/** Crypto_reader port operations. */ -extern struct rte_port_in_ops rte_port_sym_crypto_reader_ops; - - -/** Crypto_writer port parameters. */ -struct rte_port_sym_crypto_writer_params { - /** Target cryptodev ID. */ - uint8_t cryptodev_id; - - /** Target cryptodev Queue Pair ID. */ - uint16_t queue_id; - - /** offset to rte_crypto_op in the mbufs. */ - uint16_t crypto_op_offset; - - /** Burst size to crypto interface. */ - uint32_t tx_burst_sz; -}; - -/** Crypto_writer port operations. */ -extern struct rte_port_out_ops rte_port_sym_crypto_writer_ops; - -/** Crypto_writer_nodrop port parameters. */ -struct rte_port_sym_crypto_writer_nodrop_params { - /** Target cryptodev ID. */ - uint8_t cryptodev_id; - - /** Target cryptodev queue pair id. */ - uint16_t queue_id; - - /** Offset to rte_crypto_op in the mbufs. */ - uint16_t crypto_op_offset; - - /** Burst size to crypto interface. */ - uint32_t tx_burst_sz; - - /** Maximum number of retries, 0 for no limit. */ - uint32_t n_retries; -}; - -/** Crypto_writer_nodrop port operations. */ -extern struct rte_port_out_ops rte_port_sym_crypto_writer_nodrop_ops; - -#ifdef __cplusplus -} -#endif - -#endif -- 2.53.0