This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "".
The branch, master has been updated
via 50ebc616ddd9d05651923134d7bfaa02c103fbce (commit)
via 1ff6b7a7e44e7d7376920f1e1ee81dbf28f95563 (commit)
from c15da68b8dc3187c1929ff7d7705a0958856cbad (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 50ebc616ddd9d05651923134d7bfaa02c103fbce
Author: Matias Elo <matias.elo(a)nokia.com>
Date: Mon Jan 9 12:56:14 2017 +0200
linux-gen: netmap: bump supported netmap version to 11.2
Signed-off-by: Matias Elo <matias.elo(a)nokia.com>
Signed-off-by: Maxim Uvarov <maxim.uvarov(a)linaro.org>
diff --git a/DEPENDENCIES b/DEPENDENCIES
index f1f0edd..574859c 100644
--- a/DEPENDENCIES
+++ b/DEPENDENCIES
@@ -83,13 +83,13 @@ Prerequisites for building the OpenDataPlane (ODP) API
3.3.1 Building netmap kernel modules
ODP works at least with the latest release version of netmap, which is
- currently 11.1. However, if possible one should try to use the latest netmap
+ currently 11.2. However, if possible one should try to use the latest netmap
master branch commit for the best performance and the latest bug fixes.
# Checkout netmap code
$ git clone https://github.com/luigirizzo/netmap.git
$ cd netmap
- $ git checkout v11.1 (optional)
+ $ git checkout v11.2 (optional)
This is enough to build ODP. If you don't want to build netmap kernel
modules you can jump to section 3.3.2.
commit 1ff6b7a7e44e7d7376920f1e1ee81dbf28f95563
Author: Matias Elo <matias.elo(a)nokia.com>
Date: Mon Jan 9 12:56:13 2017 +0200
linux-gen: netmap: fix interface flags initialization
Previously netmap interface flags parsed by nm_open() were always
overwritten by netmap_start() function. In netmap v11.2 release this breaks
pipe interface initialization. Fix this by setting the netmap flags only
when needed.
Signed-off-by: Matias Elo <matias.elo(a)nokia.com>
Signed-off-by: Maxim Uvarov <maxim.uvarov(a)linaro.org>
diff --git a/platform/linux-generic/pktio/netmap.c b/platform/linux-generic/pktio/netmap.c
index 8eb8145..208984b 100644
--- a/platform/linux-generic/pktio/netmap.c
+++ b/platform/linux-generic/pktio/netmap.c
@@ -452,7 +452,7 @@ static int netmap_start(pktio_entry_t *pktio_entry)
{
pkt_netmap_t *pkt_nm = &pktio_entry->s.pkt_nm;
netmap_ring_t *desc_ring;
- struct nm_desc base_desc;
+ struct nm_desc *desc_ptr;
unsigned i;
unsigned j;
unsigned num_rx_desc = 0;
@@ -503,18 +503,27 @@ static int netmap_start(pktio_entry_t *pktio_entry)
pktio_entry->s.num_out_queue,
pktio_entry->s.num_out_queue);
- memset(&base_desc, 0, sizeof(struct nm_desc));
- base_desc.self = &base_desc;
- base_desc.mem = NULL;
- memcpy(base_desc.req.nr_name, pkt_nm->if_name, sizeof(pkt_nm->if_name));
- base_desc.req.nr_flags &= ~NR_REG_MASK;
+ /* Use nm_open() to parse netmap flags from interface name */
+ desc_ptr = nm_open(pkt_nm->nm_name, NULL, 0, NULL);
+ if (desc_ptr == NULL) {
+ ODP_ERR("nm_start(%s) failed\n", pkt_nm->nm_name);
+ goto error;
+ }
+ struct nm_desc base_desc = *desc_ptr;
- if (num_rx_desc == 1)
- base_desc.req.nr_flags |= NR_REG_ALL_NIC;
- else
- base_desc.req.nr_flags |= NR_REG_ONE_NIC;
+ nm_close(desc_ptr);
+ base_desc.self = &base_desc;
+ base_desc.mem = NULL;
base_desc.req.nr_ringid = 0;
+ if ((base_desc.req.nr_flags & NR_REG_MASK) == NR_REG_ALL_NIC ||
+ (base_desc.req.nr_flags & NR_REG_MASK) == NR_REG_ONE_NIC) {
+ base_desc.req.nr_flags &= ~NR_REG_MASK;
+ if (num_rx_desc == 1)
+ base_desc.req.nr_flags |= NR_REG_ALL_NIC;
+ else
+ base_desc.req.nr_flags |= NR_REG_ONE_NIC;
+ }
/* Only the first rx descriptor does mmap */
desc_ring = pkt_nm->rx_desc_ring;
@@ -548,8 +557,12 @@ static int netmap_start(pktio_entry_t *pktio_entry)
/* Open tx descriptors */
desc_ring = pkt_nm->tx_desc_ring;
flags = NM_OPEN_IFNAME | NM_OPEN_NO_MMAP;
- base_desc.req.nr_flags &= ~NR_REG_ALL_NIC;
- base_desc.req.nr_flags |= NR_REG_ONE_NIC;
+
+ if ((base_desc.req.nr_flags & NR_REG_MASK) == NR_REG_ALL_NIC) {
+ base_desc.req.nr_flags &= ~NR_REG_ALL_NIC;
+ base_desc.req.nr_flags |= NR_REG_ONE_NIC;
+ }
+
for (i = 0; i < pktio_entry->s.num_out_queue; i++) {
for (j = desc_ring[i].s.first; j <= desc_ring[i].s.last; j++) {
base_desc.req.nr_ringid = j;
-----------------------------------------------------------------------
Summary of changes:
DEPENDENCIES | 4 ++--
platform/linux-generic/pktio/netmap.c | 37 +++++++++++++++++++++++------------
2 files changed, 27 insertions(+), 14 deletions(-)
hooks/post-receive
--
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "".
The annotated tag, v1.13.0.0 has been created
at 3119269aae4a904a235f95748ccc5a74344111c8 (tag)
tagging 3875d6ebf690e07b69f11621caefab1afc58e100 (commit)
replaces v1.12.0.0
tagged by Maxim Uvarov
on Thu Jan 19 16:44:47 2017 +0300
- Log -----------------------------------------------------------------
== OpenDataPlane (1.13.0.0)
=== New Features
==== APIs
ODP v1.13.0.0 represents the initial preview of the Tiger Moth release series
and as such introduces new APIs and extensions that will be built on as this
release matures.
===== Crypto Parameter Normalization
Many ODP APIs take parameter structs of type `odp_xxx_param_t`. The crypto APIs,
for historical reasons, failed to follow this convention, using instead structs
of type `odp_crypto_params_t`, etc. These pluralized names are now deprecated
and their singular forms are introduced as the preferred names for these
structs. The old names are retained (for now) to ease migration, however
applications should convert to the new forms at their convenience as these
deprecated forms will be removed in the final Tiger Moth release.
The changes introduced for this include:
* `odp_crypto_op_params_t` => `odp_crypto_op_param_t`
* `odp_crypto_session_params_t` => `odp_crypto_session_param_t`
===== Crypto Decouple Key Length from Algorithm Specification
To provide a more flexible programming for handling all possible
key/digest/iv length combinations, the enums used for crypto specification
are split to decouple lengths from algorithm names. The only exception
is the SHA-2 family of hash routines, which have well-established naming
conventions that incorporate digest lengths (SHA-224, SHA-256, etc.)
Changes included with this restructure include:
* The `odp_crypto_capability_t` structure returned by the
`odp_crypto_capability()` API contains streamlined `odp_crypto_cipher_algos_t`
and `odp_crypto_auth_algos_t` substructures.
* A new `odp_crypto_cipher_capability()` API is added to return detailed
information about available cipher capabilities.
* A new `odp_crypto_auth_capability()` API is added to return detailed
information about available authentication capabilities.
===== `odp_crypto_session_param_init()` API
For completeness the `odp_crypto_session_param_init()` API is provided to
enable platform-independent initialization of the `odp_crypto_session_param_t`
structure used as input to `odp_crypto_session_create()`.
===== Bitfield and Byteorder Cleanup
The `ODP_BITFIELD_ORDER` define is added to the ODP specification to parallel
the existing `ODP_BYTEFIELD_ORDER` define. This will be set to the value
`ODP_BIG_ENDIAN_BITFIELD` or `ODP_LITTLE_ENDIAN_BITFIELD`. This also addresses
https://bugs.linaro.org/show_bug.cgi?id=2402[Bug 2402], however since fixing
this required a small API change this was deferred until an API release
boundary.
===== Improved Name Argument Definitions in `odp_xxx_create()` Functions
The use of name arguments to the various resource creation APIs has
been standardized and documentation improved to clarify that unique
names are not required and that these may be specified as NULL for
anonymous resource creation. When non-unique resource names are used, it is
unspecified which of these are returned by a corresponding lookup API.
===== Pool Parameters for Packet Pools
The `odp_pool_param_t` structure adds the new field `max_len` to be used in
packet pools to advise the implementation of the maximum sized packet that
the application will allocate with a single `odp_packet_alloc()` call. This
may enable storage pool optimization.
===== Packet Clarifications
API documentation for `odp_packet_concat()` and `odp_packet_copy_from_pkt()`
is clarified to specify that the source and destination packets supplied to
these APIs should not refer to the same packet.
===== Packet Allocation Length Clarification
API documentation for `odp_packet_alloc()` is clarified to specify that
the supplied length for requested packet allocation should be greater
than zero.
===== Random API Changes
The APIs provided for working with random data have been revised. The third
parameter to `odp_random_data()` is now of type `odp_random_kind_t`, which is
an `enum` that is used to specify the quality of random data required. The
kinds of random data defined are:
`ODP_RANDOM_BASIC`::
No specific quality guarantees. This is assumed to be pseudo-random data
generated by software where speed of generation is more important than the
quality of the results.This is the lowest kind of random.
`ODP_RANDOM_CRYPTO`::
Random data suitable for use in cryptographic operations.
`ODP_RANDOM_TRUE`::
True random data generated from a hardware entropy source. This is the
highest kind of random.
The `odp_random_max_kind()` API is provided that returns the highest kind of
data available on this implementation. Requests for higher kinds than can be
supplied will fail.
For testing purposes it is often desirable to generate "random" sequences that
are repeatable. To support this use case, the `odp_random_test_data()` API is
introduced. This always returns BASIC random data but uses a user-supplied
64-byte seed parameter that is update for each call and can be used to
repeat the same sequence as needed.
===== Shared Memory Improvements
The `odp_shm_reserve()` API adds two new additional flags to support external
memory.
* `ODP_SHM_SINGLE_VA` guarantees that all ODP threads sharing this memory
will see the block at the same virtual address regardless of whether threads
are implemented as pthreads or processes and when `fork()` calls are made to
create them.
* `ODP_SHM_EXPORT` allows the memory block to be visible to other ODP
instances. Other ODP instances can retrieve this block via the new
`odp_shm_import()` API.
===== Classification Clarifications
The relationship between classification and queue configuration in the
`odp_pktin_queue_param_t` structure is clarified to emphasize that
classification subsumes queue-based I/O processing. This is an API
documentation change only.
=== Helpers
New helper APIs are introduced for IP table lookup support for longest prefix
matching as well as cuckoo hash tables. These are designed to provide analogs
to functions available in DPDK to assist applications being ported to ODP.
=== Performance Improvements
The odp-linux reference implementation includes a number of improvements to
make it more suitable for production use on platforms that rely on software
implementations of key ODP APIs.
==== Ring-based Pool Implementation
Storage pools used for buffers and packets are now implemented via lockless
ring structures that support burst mode read/writes to local caches for
significantly improved multi-core scalability
==== Buffer/Packet Header Optimizations
The layout of the structs used to support buffers and packets has been
optimized to reduce cache footprint and minimize path lengths in packet
manipulation.
==== Ordered Queue Improvements
The implementation of ordered queues has been streamlined and made more
scaleable in multi-core systems.
==== Packet Segmentation Improvements
The more advance segmentation capabilities present in the new ODP packet
implementation are used to streamline the implementation of APIs like
`odp_packet_concat()` and the head/tail extend/trunc APIs.
=== Bug Fixes
==== https://bugs.linaro.org/show_bug.cgi?id=2405[Bug 2405]
A number of "todos" were removed from the packet validation test suite.
==== https://bugs.linaro.org/show_bug.cgi?id=2472[Bug 2472]
The CPU affinity is now correctly read from the cpuset.
==== https://bugs.linaro.org/show_bug.cgi?id=2496[Bug 2496]
The PktIO validation test no longer uses invalid MAC addresses.
==== https://bugs.linaro.org/show_bug.cgi?id=2512[Bug 2512]
The TCP checksum is now properly calculated for generated packets.
==== https://bugs.linaro.org/show_bug.cgi?id=2798[Bug 2798]
The odp-linux reference implementation makes use of the OpenSSL library to
support the `odp_random_xxx()` APIs and some crypto operations. To support
OpenSSL versions prior to 1.1.0, which are not thread safe, support is added
for OpenSSL locking callbacks that use ODP ticketlocks to provide OpenSSL thread
safety.
=== Known Issues
==== https://bugs.linaro.org/show_bug.cgi?id=2812[Bug 2812]
Make check fails on a single core VM in the process mode helper test.
Balakrishna Garapati (1):
platform: linux-generic: reading cpu affinity from cpuset
Balasubramanian Manoharan (3):
validation: classification: fix TCP/UDP checksum update
validation: pktio: fix invalid mac addr
api: pktio: adds further definition for classification configuration
Bill Fischofer (11):
validation: packet: remove todos from packet tests
test: perf: add assert since src_idx cannot be negative
api: byteorder: avoid bitfield order doxygen omissions
linux-generic: pool: reset origin_qe on buffer allocation
api: random: add explicit controls over random data
doc: userguide: move crypto documentation to its own sub-document
doc: userguide: expand crypto documentation to cover random apis
api: pktio: pktio documentation typo correction
linux-generic: pool: defer ring allocation until pool creation
linux-generic: crypto: add openssl locking support for thread safety
changelog: summary of changes for odp v1.13.0.0
Christophe Milard (38):
linux-generic: Makefile: reintroducing lost change for drv
linux-generic: moving the visibility files one step up
linux-generic: cosmetic changes on sync files
linux-generic: cosmetic changes on atomic
linux-generic: cosmetic changes on spinlock
helper: test: gitignore add iplookuptable
linux-gen: cosmetic changes on barrier
linux-gen: fdserver: new fdserver added
linux-generic: system_info: adding huge page dir
linux-generic: _fdserver: fixing comment typo
linux-generic: _fdserver: allocating data table dynamicaly
linux-gen: init: removing possible obsolete ODP files at startup
linux-gen: push internal flag definition
api: shm: add flags to shm_reserve and function to find external mem
test: api: shmem: new proper tests for shm API
doc: updating docs for the shm interface extension
test: api: shm: test using the same block name multiple times
doc: shm: defining behaviour when blocks have same name
linux-gen: _fdserver: request sigterm if parent dies
linux-gen: ishm: internal shared memory allocator (ishm) added
linux-gen: _ishm: create description file for external memory sharing
linux-gen: use ishm as north API mem allocator
linux-gen: ishm: adding debug function
linux-gen: _ishm: adding function to map memory from other ODP
linux-gen: shm: new ODP_SHM_SINGLE_VA flag implementation
linux-gen: shm: add flag and function to share memory between ODP instances
linux-gen: shared_memory: remove flag forcing mlock
linux-gen: _ishm: accept multiple usage of same block name
linux_gen: _ishm: decreasing the number of error messages when no huge pages
linux-gen: _ishm: fix for alignment request matching page size
linux-gen: _ishm: allow memory alloc/free at global init/term
linux-gen: _ishm: cleaning remaining block at odp_term_global
test: linux-gen: api: shmem: test sharing memory between ODP instances
linux-gen: _ishm: unlinking files asap for cleaner termination
linux-gen: _ishm: exporting/importing user len and flags
test: shm: checking exported vs imported block length
linux-gen: _ishm: fixing typos
linux-gen: init: avoiding segfault if cleaning files
Joe Savage (1):
helper: fix odph_ipv4_csum functions for L3 offset 0
Matias Elo (15):
example: free reserved shared memory blocks
validation: free reserved shared memory blocks
api: improve name argument definitions in *_create() functions
linux-gen: schedule: fix creating event group with no name
linux-gen: queue: fix creating queue with no name
linux-gen: classification: fix creating cos with no name
linux-gen: timer: fix creating timer pool with no name
linux-gen: sched: add internal APIs for locking/unlocking ordered processing
linux-gen: sched: remove old ordered queue implementation
linux-gen: sched: add internal API for max number of ordered locks per queue
linux-gen: sched: new ordered queue implementation
linux-gen: sched: new ordered lock implementation
api: unify ODP_*_NAME_LEN specifications
api: move ODP_*_NAME_LEN definitions from API to implementation
validation: test creating pool and timer pool with no name
Maxim Uvarov (13):
configure.ac: do not disable shared lib for non abi mode
test: tm: queue id can be not updated
travis: do not print dpdk build log
travis: accelerate dpdk cloning
scripts/build-pktio-dpdk: do not download full dpdk git
helper: cuckootable: add missing return codes
linux-gen: pktio ipc: ring changes
linux-gen: pktio ipc: more accurate settings of pool flags
linux-gen: pktio ipc: update tests
linux-gen: pktio ipc: make it work again
linux-gen: pktio ipc: tests: remove comment about master-slave
linux-gen: pktio ipc: fix clang build
update API version number from v1.12.0.0 to v1.13.0.0
Mike Holmes (4):
configure: if no ABI reset .so to 0
configure: remove duplicate info
helper: remove unused variable
doc: driver-guide: initial revision
Nicolas Morey-Chaisemartin (3):
validation: pktio: use PRIu32 to print uint32_t values
validation: traffic_mngr: use PRI macro to print uint*
example: traffic_mgmt: use PRIu32 instead of %u
Petri Savolainen (49):
test: l2fwd: lookup table for sched mode
test: l2fwd: lockless output queues in sched mode
test: l2fwd: add missing output event queue read
linux-gen: ipc: disable build of ipc pktio
linux-gen: pktio: do not free zero packets
linux-gen: ring: created common ring implementation
linux-gen: align: added round up power of two
linux-gen: pool: reimplement pool with ring
linux-gen: ring: added multi enq and deq
linux-gen: pool: use ring multi enq and deq operations
linux-gen: pool: optimize buffer alloc
linux-gen: pool: clean up pool inlines functions
linux-gen: pool: ptr instead of hdl in buffer_alloc_multi
test: validation: buf: test alignment
test: performance: crypto: use capability to select max packet
test: correctly initialize pool parameters
test: validation: packet: fix bugs in tailroom and concat tests
linux-gen: packet: added support for segmented packets
test: validation: packet: improved multi-segment alloc test
api: packet: added limits for packet len on alloc
linux-gen: packet: remove zero len support from alloc
linux-gen: socket: use trunc instead of pull tail
validation: crypto: honour pool capability limits
validation: pktio: honour pool capability limits
linux-gen: pool: check pool parameters
linux-gen: packet: enable multi-segment packets
api: crypto: rename _params_t to _param_t
linux-gen: crypto: rename params to param
api: crypto: decouple key length from algorithm enumeration
linux-gen: crypto: add algo capability functions
linux-gen: crypto: add support to new enumerations
api: crypto: added session param init
api: crypto: documentation clean up
test: crypto: use odp_crypto_session_param_init
validation: crypto: use algorithm capability
example: ipsec: use op_param_t instead of op_params_t
linux-gen: schedule_sp: use ring as priority queue
api: packet: src and dst packet must not be the same
linux-gen: packet: fix bug in tailroom calculation
linux-gen: packet: improve packet print
validation: packet: concat-split test bug fix
linux-gen: packet: optimize concat
validation: packet: add new concat and extend tests
linux-gen: config: increase max num of segments
linux-gen: packet: clean and pack packet header struct
linux-gen: packet: optimize alloc and init
linux-gen: packet: replace base_len with constant
validation: packet: add line number to compare data checks
validation: packet: limit number of failed asserts
Ru Jia (4):
helper: table: add impl of cuckoo hash table
helper: test: add test of cuckoo hash table
helper: table: add impl of ip lookup table
helper: test: add validation test of ip lookup table
Stanislaw Kardach (1):
helper: do not break odp_term_global protocol
Xuelin Shi (2):
linux-generic: move tm system barrier to tm group
linux-generic: only enable pktout when egress kind is pktio
-----------------------------------------------------------------------
hooks/post-receive
--
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "".
The branch, master has been updated
via 3875d6ebf690e07b69f11621caefab1afc58e100 (commit)
via b99095485be4ac14d16bef372b5c6521b396abaa (commit)
from f53fda91d2919eee33b5a177ef818be1092c890b (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 3875d6ebf690e07b69f11621caefab1afc58e100
Author: Maxim Uvarov <maxim.uvarov(a)linaro.org>
Date: Fri Jan 13 16:50:36 2017 +0300
update API version number from v1.12.0.0 to v1.13.0.0
Signed-off-by: Maxim Uvarov <maxim.uvarov(a)linaro.org>
Reviewed-by: Mike Holmes <mike.holmes(a)linaro.org>
diff --git a/configure.ac b/configure.ac
index 3a20959..67d60d2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3,7 +3,7 @@ AC_PREREQ([2.5])
# Set correct API version
##########################################################################
m4_define([odpapi_generation_version], [1])
-m4_define([odpapi_major_version], [12])
+m4_define([odpapi_major_version], [13])
m4_define([odpapi_minor_version], [0])
m4_define([odpapi_point_version], [0])
m4_define([odpapi_version],
@@ -38,10 +38,10 @@ AM_SILENT_RULES([yes])
# 3. if interfaces were removed, then use C+1:0:0
##########################################################################
-ODP_LIBSO_VERSION=112:0:0
+ODP_LIBSO_VERSION=113:0:0
AC_SUBST(ODP_LIBSO_VERSION)
-ODPHELPER_LIBSO_VERSION=110:1:1
+ODPHELPER_LIBSO_VERSION=111:0:2
AC_SUBST(ODPHELPER_LIBSO_VERSION)
# Checks for programs.
commit b99095485be4ac14d16bef372b5c6521b396abaa
Author: Bill Fischofer <bill.fischofer(a)linaro.org>
Date: Fri Jan 13 10:14:04 2017 -0600
changelog: summary of changes for odp v1.13.0.0
Signed-off-by: Bill Fischofer <bill.fischofer(a)linaro.org>
Reviewed-by: Mike Holmes <mike.holmes(a)linaro.org>
Signed-off-by: Maxim Uvarov <maxim.uvarov(a)linaro.org>
diff --git a/CHANGELOG b/CHANGELOG
index 17afe44..72bf225 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,181 @@
+== OpenDataPlane (1.13.0.0)
+
+=== New Features
+
+==== APIs
+ODP v1.13.0.0 represents the initial preview of the Tiger Moth release series
+and as such introduces new APIs and extensions that will be built on as this
+release matures.
+
+===== Crypto Parameter Normalization
+Many ODP APIs take parameter structs of type `odp_xxx_param_t`. The crypto APIs,
+for historical reasons, failed to follow this convention, using instead structs
+of type `odp_crypto_params_t`, etc. These pluralized names are now deprecated
+and their singular forms are introduced as the preferred names for these
+structs. The old names are retained (for now) to ease migration, however
+applications should convert to the new forms at their convenience as these
+deprecated forms will be removed in the final Tiger Moth release.
+
+The changes introduced for this include:
+
+* `odp_crypto_op_params_t` => `odp_crypto_op_param_t`
+* `odp_crypto_session_params_t` => `odp_crypto_session_param_t`
+
+===== Crypto Decouple Key Length from Algorithm Specification
+To provide a more flexible programming for handling all possible
+key/digest/iv length combinations, the enums used for crypto specification
+are split to decouple lengths from algorithm names. The only exception
+is the SHA-2 family of hash routines, which have well-established naming
+conventions that incorporate digest lengths (SHA-224, SHA-256, etc.)
+
+Changes included with this restructure include:
+
+* The `odp_crypto_capability_t` structure returned by the
+`odp_crypto_capability()` API contains streamlined `odp_crypto_cipher_algos_t`
+and `odp_crypto_auth_algos_t` substructures.
+* A new `odp_crypto_cipher_capability()` API is added to return detailed
+information about available cipher capabilities.
+* A new `odp_crypto_auth_capability()` API is added to return detailed
+information about available authentication capabilities.
+
+===== `odp_crypto_session_param_init()` API
+For completeness the `odp_crypto_session_param_init()` API is provided to
+enable platform-independent initialization of the `odp_crypto_session_param_t`
+structure used as input to `odp_crypto_session_create()`.
+
+===== Bitfield and Byteorder Cleanup
+The `ODP_BITFIELD_ORDER` define is added to the ODP specification to parallel
+the existing `ODP_BYTEFIELD_ORDER` define. This will be set to the value
+`ODP_BIG_ENDIAN_BITFIELD` or `ODP_LITTLE_ENDIAN_BITFIELD`. This also addresses
+https://bugs.linaro.org/show_bug.cgi?id=2402[Bug 2402], however since fixing
+this required a small API change this was deferred until an API release
+boundary.
+
+===== Improved Name Argument Definitions in `odp_xxx_create()` Functions
+The use of name arguments to the various resource creation APIs has
+been standardized and documentation improved to clarify that unique
+names are not required and that these may be specified as NULL for
+anonymous resource creation. When non-unique resource names are used, it is
+unspecified which of these are returned by a corresponding lookup API.
+
+===== Pool Parameters for Packet Pools
+The `odp_pool_param_t` structure adds the new field `max_len` to be used in
+packet pools to advise the implementation of the maximum sized packet that
+the application will allocate with a single `odp_packet_alloc()` call. This
+may enable storage pool optimization.
+
+===== Packet Clarifications
+API documentation for `odp_packet_concat()` and `odp_packet_copy_from_pkt()`
+is clarified to specify that the source and destination packets supplied to
+these APIs should not refer to the same packet.
+
+===== Packet Allocation Length Clarification
+API documentation for `odp_packet_alloc()` is clarified to specify that
+the supplied length for requested packet allocation should be greater
+than zero.
+
+===== Random API Changes
+The APIs provided for working with random data have been revised. The third
+parameter to `odp_random_data()` is now of type `odp_random_kind_t`, which is
+an `enum` that is used to specify the quality of random data required. The
+kinds of random data defined are:
+
+`ODP_RANDOM_BASIC`::
+No specific quality guarantees. This is assumed to be pseudo-random data
+generated by software where speed of generation is more important than the
+quality of the results.This is the lowest kind of random.
+
+`ODP_RANDOM_CRYPTO`::
+Random data suitable for use in cryptographic operations.
+
+`ODP_RANDOM_TRUE`::
+True random data generated from a hardware entropy source. This is the
+highest kind of random.
+
+The `odp_random_max_kind()` API is provided that returns the highest kind of
+data available on this implementation. Requests for higher kinds than can be
+supplied will fail.
+
+For testing purposes it is often desirable to generate "random" sequences that
+are repeatable. To support this use case, the `odp_random_test_data()` API is
+introduced. This always returns BASIC random data but uses a user-supplied
+64-byte seed parameter that is update for each call and can be used to
+repeat the same sequence as needed.
+
+===== Shared Memory Improvements
+The `odp_shm_reserve()` API adds two new additional flags to support external
+memory.
+
+* `ODP_SHM_SINGLE_VA` guarantees that all ODP threads sharing this memory
+will see the block at the same virtual address regardless of whether threads
+are implemented as pthreads or processes and when `fork()` calls are made to
+create them.
+
+* `ODP_SHM_EXPORT` allows the memory block to be visible to other ODP
+instances. Other ODP instances can retrieve this block via the new
+`odp_shm_import()` API.
+
+===== Classification Clarifications
+The relationship between classification and queue configuration in the
+`odp_pktin_queue_param_t` structure is clarified to emphasize that
+classification subsumes queue-based I/O processing. This is an API
+documentation change only.
+
+=== Helpers
+New helper APIs are introduced for IP table lookup support for longest prefix
+matching as well as cuckoo hash tables. These are designed to provide analogs
+to functions available in DPDK to assist applications being ported to ODP.
+
+=== Performance Improvements
+The odp-linux reference implementation includes a number of improvements to
+make it more suitable for production use on platforms that rely on software
+implementations of key ODP APIs.
+
+==== Ring-based Pool Implementation
+Storage pools used for buffers and packets are now implemented via lockless
+ring structures that support burst mode read/writes to local caches for
+significantly improved multi-core scalability
+
+==== Buffer/Packet Header Optimizations
+The layout of the structs used to support buffers and packets has been
+optimized to reduce cache footprint and minimize path lengths in packet
+manipulation.
+
+==== Ordered Queue Improvements
+The implementation of ordered queues has been streamlined and made more
+scaleable in multi-core systems.
+
+==== Packet Segmentation Improvements
+The more advance segmentation capabilities present in the new ODP packet
+implementation are used to streamline the implementation of APIs like
+`odp_packet_concat()` and the head/tail extend/trunc APIs.
+
+=== Bug Fixes
+
+==== https://bugs.linaro.org/show_bug.cgi?id=2405[Bug 2405]
+A number of "todos" were removed from the packet validation test suite.
+
+==== https://bugs.linaro.org/show_bug.cgi?id=2472[Bug 2472]
+The CPU affinity is now correctly read from the cpuset.
+
+==== https://bugs.linaro.org/show_bug.cgi?id=2496[Bug 2496]
+The PktIO validation test no longer uses invalid MAC addresses.
+
+==== https://bugs.linaro.org/show_bug.cgi?id=2512[Bug 2512]
+The TCP checksum is now properly calculated for generated packets.
+
+==== https://bugs.linaro.org/show_bug.cgi?id=2798[Bug 2798]
+The odp-linux reference implementation makes use of the OpenSSL library to
+support the `odp_random_xxx()` APIs and some crypto operations. To support
+OpenSSL versions prior to 1.1.0, which are not thread safe, support is added
+for OpenSSL locking callbacks that use ODP ticketlocks to provide OpenSSL thread
+safety.
+
+=== Known Issues
+
+==== https://bugs.linaro.org/show_bug.cgi?id=2812[Bug 2812]
+Make check fails on a single core VM in the process mode helper test.
+
== OpenDataPlane (1.12.0.0)
=== New Features
-----------------------------------------------------------------------
Summary of changes:
CHANGELOG | 178 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
configure.ac | 6 +-
2 files changed, 181 insertions(+), 3 deletions(-)
hooks/post-receive
--
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "".
The branch, api-next has been updated
via 1588c49a0bf0332512d5e08e1feaad5e4005df31 (commit)
via 9f88e0b17e7e814f2c15c3c9ee0103196864a7d5 (commit)
via 0abda2f57e088c9db6e48a265a417f47b1e4720c (commit)
via 9107db16944d821a1c959049acc1fe3ff29f2341 (commit)
via 567c2e8a0fd6b51db8b82ce926cc41d4c0e7898b (commit)
via 91f1ce71dc3d2694152d71690c1e7638716b9391 (commit)
from 00070be1d569bd575b100d52e5e263eb89ac962c (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 1588c49a0bf0332512d5e08e1feaad5e4005df31
Author: Christophe Milard <christophe.milard(a)linaro.org>
Date: Tue Jan 17 19:18:03 2017 +0100
test: drv: shm: adding buddy allocation stress tests
Stress tests for the random size allocator (buddy allocator in
linux-generic) are added here.
Signed-off-by: Christophe Milard <christophe.milard(a)linaro.org>
Reviewed-and-tested-by: Yi He <yi.he(a)linaro.org>
Signed-off-by: Maxim Uvarov <maxim.uvarov(a)linaro.org>
diff --git a/test/common_plat/validation/drv/drvshmem/drvshmem.c b/test/common_plat/validation/drv/drvshmem/drvshmem.c
index d4dedea..0f882ae 100644
--- a/test/common_plat/validation/drv/drvshmem/drvshmem.c
+++ b/test/common_plat/validation/drv/drvshmem/drvshmem.c
@@ -938,6 +938,182 @@ void drvshmem_test_slab_basic(void)
odpdrv_shm_pool_destroy(pool);
}
+/*
+ * thread part for the drvshmem_test_buddy_stress
+ */
+static int run_test_buddy_stress(void *arg ODP_UNUSED)
+{
+ odpdrv_shm_t shm;
+ odpdrv_shm_pool_t pool;
+ uint8_t *address;
+ shared_test_data_t *glob_data;
+ uint8_t random_bytes[STRESS_RANDOM_SZ];
+ uint32_t index;
+ uint32_t size;
+ uint8_t data;
+ uint32_t iter;
+ uint32_t i;
+
+ shm = odpdrv_shm_lookup_by_name(MEM_NAME);
+ glob_data = odpdrv_shm_addr(shm);
+ CU_ASSERT_PTR_NOT_NULL(glob_data);
+
+ /* get the pool to test */
+ pool = odpdrv_shm_pool_lookup(POOL_NAME);
+
+ /* wait for general GO! */
+ odpdrv_barrier_wait(&glob_data->test_barrier1);
+ /*
+
+ * at each iteration: pick up a random index for
+ * glob_data->stress[index]: If the entry is free, allocated small mem
+ * randomly. If it is already allocated, make checks and free it:
+ * Note that different tread can allocate or free a given block
+ */
+ for (iter = 0; iter < STRESS_ITERATION; iter++) {
+ /* get 4 random bytes from which index, size ,align, flags
+ * and data will be derived:
+ */
+ odp_random_data(random_bytes, STRESS_RANDOM_SZ, 0);
+ index = random_bytes[0] & (STRESS_SIZE - 1);
+
+ odp_spinlock_lock(&glob_data->stress_lock);
+
+ switch (glob_data->stress[index].state) {
+ case STRESS_FREE:
+ /* allocated a new block for this entry */
+
+ glob_data->stress[index].state = STRESS_BUSY;
+ odp_spinlock_unlock(&glob_data->stress_lock);
+
+ size = (random_bytes[1] + 1) << 4; /* up to 4Kb */
+ data = random_bytes[2];
+
+ address = odpdrv_shm_pool_alloc(pool, size);
+ glob_data->stress[index].address = address;
+ if (address == NULL) { /* out of mem ? */
+ odp_spinlock_lock(&glob_data->stress_lock);
+ glob_data->stress[index].state = STRESS_ALLOC;
+ odp_spinlock_unlock(&glob_data->stress_lock);
+ continue;
+ }
+
+ glob_data->stress[index].size = size;
+ glob_data->stress[index].data_val = data;
+
+ /* write some data: */
+ for (i = 0; i < size; i++)
+ address[i] = (data++) & 0xFF;
+ odp_spinlock_lock(&glob_data->stress_lock);
+ glob_data->stress[index].state = STRESS_ALLOC;
+ odp_spinlock_unlock(&glob_data->stress_lock);
+
+ break;
+
+ case STRESS_ALLOC:
+ /* free the block for this entry */
+
+ glob_data->stress[index].state = STRESS_BUSY;
+ odp_spinlock_unlock(&glob_data->stress_lock);
+ address = glob_data->stress[index].address;
+
+ if (shm == NULL) { /* out of mem ? */
+ odp_spinlock_lock(&glob_data->stress_lock);
+ glob_data->stress[index].state = STRESS_FREE;
+ odp_spinlock_unlock(&glob_data->stress_lock);
+ continue;
+ }
+
+ /* check that data is reachable and correct: */
+ data = glob_data->stress[index].data_val;
+ size = glob_data->stress[index].size;
+ for (i = 0; i < size; i++) {
+ CU_ASSERT(address[i] == (data & 0xFF));
+ data++;
+ }
+
+ odpdrv_shm_pool_free(pool, address);
+
+ odp_spinlock_lock(&glob_data->stress_lock);
+ glob_data->stress[index].state = STRESS_FREE;
+ odp_spinlock_unlock(&glob_data->stress_lock);
+
+ break;
+
+ case STRESS_BUSY:
+ default:
+ odp_spinlock_unlock(&glob_data->stress_lock);
+ break;
+ }
+ }
+
+ fflush(stdout);
+ return CU_get_number_of_failures();
+}
+
+/*
+ * stress tests
+ */
+void drvshmem_test_buddy_stress(void)
+{
+ odpdrv_shm_pool_param_t pool_params;
+ odpdrv_shm_pool_t pool;
+ pthrd_arg thrdarg;
+ odpdrv_shm_t shm;
+ shared_test_data_t *glob_data;
+ odp_cpumask_t unused;
+ uint32_t i;
+ uint8_t *address;
+
+ /* create a pool and check that it can be looked up */
+ pool_params.pool_size = POOL_SZ;
+ pool_params.min_alloc = 0;
+ pool_params.max_alloc = POOL_SZ;
+ pool = odpdrv_shm_pool_create(POOL_NAME, &pool_params);
+ odpdrv_shm_pool_print("Stress test start", pool);
+
+ shm = odpdrv_shm_reserve(MEM_NAME, sizeof(shared_test_data_t),
+ 0, ODPDRV_SHM_LOCK);
+ CU_ASSERT(ODPDRV_SHM_INVALID != shm);
+ glob_data = odpdrv_shm_addr(shm);
+ CU_ASSERT_PTR_NOT_NULL(glob_data);
+
+ thrdarg.numthrds = odp_cpumask_default_worker(&unused, 0);
+ if (thrdarg.numthrds > MAX_WORKERS)
+ thrdarg.numthrds = MAX_WORKERS;
+
+ glob_data->nb_threads = thrdarg.numthrds;
+ odpdrv_barrier_init(&glob_data->test_barrier1, thrdarg.numthrds);
+ odp_spinlock_init(&glob_data->stress_lock);
+
+ /* before starting the threads, mark all entries as free: */
+ for (i = 0; i < STRESS_SIZE; i++)
+ glob_data->stress[i].state = STRESS_FREE;
+
+ /* create threads */
+ odp_cunit_thread_create(run_test_buddy_stress, &thrdarg);
+
+ /* wait for all thread endings: */
+ CU_ASSERT(odp_cunit_thread_exit(&thrdarg) >= 0);
+
+ odpdrv_shm_pool_print("Stress test all thread finished", pool);
+
+ /* release left overs: */
+ for (i = 0; i < STRESS_SIZE; i++) {
+ address = glob_data->stress[i].address;
+ if (glob_data->stress[i].state == STRESS_ALLOC)
+ odpdrv_shm_pool_free(pool, address);
+ }
+
+ CU_ASSERT(0 == odpdrv_shm_free_by_name(MEM_NAME));
+
+ /* check that no memory is left over: */
+ odpdrv_shm_pool_print("Stress test all released", pool);
+
+ /* destroy pool: */
+ odpdrv_shm_pool_destroy(pool);
+}
+
odp_testinfo_t drvshmem_suite[] = {
ODP_TEST_INFO(drvshmem_test_basic),
ODP_TEST_INFO(drvshmem_test_reserve_after_fork),
@@ -945,6 +1121,7 @@ odp_testinfo_t drvshmem_suite[] = {
ODP_TEST_INFO(drvshmem_test_stress),
ODP_TEST_INFO(drvshmem_test_buddy_basic),
ODP_TEST_INFO(drvshmem_test_slab_basic),
+ ODP_TEST_INFO(drvshmem_test_buddy_stress),
ODP_TEST_INFO_NULL,
};
diff --git a/test/common_plat/validation/drv/drvshmem/drvshmem.h b/test/common_plat/validation/drv/drvshmem/drvshmem.h
index fdc1080..817b3d5 100644
--- a/test/common_plat/validation/drv/drvshmem/drvshmem.h
+++ b/test/common_plat/validation/drv/drvshmem/drvshmem.h
@@ -16,6 +16,7 @@ void drvshmem_test_singleva_after_fork(void);
void drvshmem_test_stress(void);
void drvshmem_test_buddy_basic(void);
void drvshmem_test_slab_basic(void);
+void drvshmem_test_buddy_stress(void);
/* test arrays: */
extern odp_testinfo_t drvshmem_suite[];
commit 9f88e0b17e7e814f2c15c3c9ee0103196864a7d5
Author: Christophe Milard <christophe.milard(a)linaro.org>
Date: Tue Jan 17 19:18:02 2017 +0100
test: drv: shm: adding basic fixed size allocation tests
Basic tests for odpdrv_shm_pool are added here, creating a fixed size
pool and performing basic alloc/free on it
Signed-off-by: Christophe Milard <christophe.milard(a)linaro.org>
Reviewed-and-tested-by: Yi He <yi.he(a)linaro.org>
Signed-off-by: Maxim Uvarov <maxim.uvarov(a)linaro.org>
diff --git a/test/common_plat/validation/drv/drvshmem/drvshmem.c b/test/common_plat/validation/drv/drvshmem/drvshmem.c
index 5843573..d4dedea 100644
--- a/test/common_plat/validation/drv/drvshmem/drvshmem.c
+++ b/test/common_plat/validation/drv/drvshmem/drvshmem.c
@@ -853,12 +853,98 @@ void drvshmem_test_buddy_basic(void)
odpdrv_shm_pool_destroy(pool);
}
+void drvshmem_test_slab_basic(void)
+{
+ odpdrv_shm_pool_param_t pool_params;
+ odpdrv_shm_pool_t pool, found_pool;
+ uint8_t *buff;
+ uint8_t *addrs[TEST_SZ];
+ uint16_t length;
+ int i, j;
+
+ /* create a pool and check that it can be looked up */
+ pool_params.pool_size = POOL_SZ;
+ pool_params.min_alloc = SZ_1K; /* constant size will give slab */
+ pool_params.max_alloc = SZ_1K;
+ pool = odpdrv_shm_pool_create(POOL_NAME, &pool_params);
+ found_pool = odpdrv_shm_pool_lookup(POOL_NAME);
+ CU_ASSERT(found_pool == pool);
+
+ /* alloc a 1k buffer, filling its contents: */
+ buff = odpdrv_shm_pool_alloc(pool, SZ_1K);
+ CU_ASSERT_PTR_NOT_NULL(buff);
+ for (i = 0; i < SZ_1K; i++)
+ buff[i] = BUFF_PATTERN;
+ odpdrv_shm_pool_print("buddy test: 1K reserved", pool);
+
+ /* alloc as many 1K buffer a possible */
+ for (i = 0; i < TEST_SZ; i++) {
+ length = SZ_1K;
+ addrs[i] = odpdrv_shm_pool_alloc(pool, length);
+ /* if alloc was success, fill buffer for later check */
+ if (addrs[i]) {
+ for (j = 0; j < length; j++)
+ addrs[i][j] = (uint8_t)(length & 0xFF);
+ }
+ }
+ odpdrv_shm_pool_print("slab test: after many mallocs", pool);
+
+ /* release every 3rth buffer, checking contents: */
+ for (i = 0; i < TEST_SZ; i += 3) {
+ /* if buffer was allocated, check the pattern in it */
+ if (addrs[i]) {
+ length = SZ_1K;
+ for (j = 0; j < length; j++)
+ CU_ASSERT(addrs[i][j] ==
+ (uint8_t)(length & 0xFF));
+ }
+ odpdrv_shm_pool_free(pool, addrs[i]);
+ }
+ odpdrv_shm_pool_print("slab test: after 1/3 free:", pool);
+
+ /* realloc them:*/
+ for (i = 0; i < TEST_SZ; i += 3) {
+ length = SZ_1K;
+ addrs[i] = odpdrv_shm_pool_alloc(pool, length);
+ /* if alloc was success, fill buffer for later check */
+ if (addrs[i]) {
+ for (j = 0; j < length; j++)
+ addrs[i][j] = (uint8_t)(length & 0xFF);
+ }
+ }
+ odpdrv_shm_pool_print("slab test: after realloc:", pool);
+
+ /* free all (except buff), checking contents: */
+ for (i = 0; i < TEST_SZ; i++) {
+ /* if buffer was allocated, check the pattern in it */
+ if (addrs[i]) {
+ length = SZ_1K;
+ for (j = 0; j < length; j++)
+ CU_ASSERT(addrs[i][j] ==
+ (uint8_t)(length & 0xFF))
+ }
+ odpdrv_shm_pool_free(pool, addrs[i]);
+ }
+ odpdrv_shm_pool_print("slab test: after all but 1K free:", pool);
+
+ /* check contents of our initial 1K buffer: */
+ for (i = 0; i < SZ_1K; i++)
+ CU_ASSERT((buff[i] == BUFF_PATTERN))
+ odpdrv_shm_pool_free(pool, buff);
+
+ odpdrv_shm_pool_print("slab test: after all free", pool);
+
+ /* destroy pool: */
+ odpdrv_shm_pool_destroy(pool);
+}
+
odp_testinfo_t drvshmem_suite[] = {
ODP_TEST_INFO(drvshmem_test_basic),
ODP_TEST_INFO(drvshmem_test_reserve_after_fork),
ODP_TEST_INFO(drvshmem_test_singleva_after_fork),
ODP_TEST_INFO(drvshmem_test_stress),
ODP_TEST_INFO(drvshmem_test_buddy_basic),
+ ODP_TEST_INFO(drvshmem_test_slab_basic),
ODP_TEST_INFO_NULL,
};
diff --git a/test/common_plat/validation/drv/drvshmem/drvshmem.h b/test/common_plat/validation/drv/drvshmem/drvshmem.h
index ab45f7c..fdc1080 100644
--- a/test/common_plat/validation/drv/drvshmem/drvshmem.h
+++ b/test/common_plat/validation/drv/drvshmem/drvshmem.h
@@ -15,6 +15,7 @@ void drvshmem_test_reserve_after_fork(void);
void drvshmem_test_singleva_after_fork(void);
void drvshmem_test_stress(void);
void drvshmem_test_buddy_basic(void);
+void drvshmem_test_slab_basic(void);
/* test arrays: */
extern odp_testinfo_t drvshmem_suite[];
commit 0abda2f57e088c9db6e48a265a417f47b1e4720c
Author: Christophe Milard <christophe.milard(a)linaro.org>
Date: Tue Jan 17 19:18:01 2017 +0100
test: drv: shm: adding basic buddy allocation tests
Basic tests for odpdrv_shm_pool are added here, creating a buddy
pool and performing basic alloc/free on it
Signed-off-by: Christophe Milard <christophe.milard(a)linaro.org>
Reviewed-and-tested-by: Yi He <yi.he(a)linaro.org>
Signed-off-by: Maxim Uvarov <maxim.uvarov(a)linaro.org>
diff --git a/test/common_plat/validation/drv/drvshmem/drvshmem.c b/test/common_plat/validation/drv/drvshmem/drvshmem.c
index 0247a03..5843573 100644
--- a/test/common_plat/validation/drv/drvshmem/drvshmem.c
+++ b/test/common_plat/validation/drv/drvshmem/drvshmem.c
@@ -21,6 +21,12 @@
#define STRESS_RANDOM_SZ 5
#define STRESS_ITERATION 5000
+#define POOL_NAME "test_pool"
+#define POOL_SZ (1UL << 20) /* 1 MBytes */
+#define TEST_SZ 1000
+#define SZ_1K 1024
+#define BUFF_PATTERN 0xA3
+
typedef enum {
STRESS_FREE, /* entry is free and can be allocated */
STRESS_BUSY, /* entry is being processed: don't touch */
@@ -762,11 +768,97 @@ void drvshmem_test_stress(void)
CU_ASSERT(odpdrv_shm_print_all("After stress tests") == base);
}
+void drvshmem_test_buddy_basic(void)
+{
+ odpdrv_shm_pool_param_t pool_params;
+ odpdrv_shm_pool_t pool, found_pool;
+ uint8_t *buff;
+ uint8_t *addrs[TEST_SZ];
+ uint8_t length;
+ int i, j;
+
+ /* create a pool and check that it can be looked up */
+ pool_params.pool_size = POOL_SZ;
+ pool_params.min_alloc = 1;
+ pool_params.max_alloc = POOL_SZ;
+ pool = odpdrv_shm_pool_create(POOL_NAME, &pool_params);
+ found_pool = odpdrv_shm_pool_lookup(POOL_NAME);
+ CU_ASSERT(found_pool == pool);
+
+ /* alloc a 1k buffer, filling its contents: */
+ buff = odpdrv_shm_pool_alloc(pool, SZ_1K);
+ CU_ASSERT_PTR_NOT_NULL(buff);
+ for (i = 0; i < SZ_1K; i++)
+ buff[i] = BUFF_PATTERN;
+ odpdrv_shm_pool_print("buddy test: 1K reserved", pool);
+
+ /* alloc as many buffer a possible on increseasing sz */
+ for (i = 0; i < TEST_SZ; i++) {
+ length = i * 16;
+ addrs[i] = odpdrv_shm_pool_alloc(pool, length);
+ /* if alloc was success, fill buffer for later check */
+ if (addrs[i]) {
+ for (j = 0; j < length; j++)
+ addrs[i][j] = (uint8_t)(length & 0xFF);
+ }
+ }
+ odpdrv_shm_pool_print("buddy test: after many mallocs", pool);
+
+ /* release every 3rth buffer, checking contents: */
+ for (i = 0; i < TEST_SZ; i += 3) {
+ /* if buffer was allocated, check the pattern in it */
+ if (addrs[i]) {
+ length = i * 16;
+ for (j = 0; j < length; j++)
+ CU_ASSERT(addrs[i][j] ==
+ (uint8_t)(length & 0xFF));
+ }
+ odpdrv_shm_pool_free(pool, addrs[i]);
+ }
+ odpdrv_shm_pool_print("buddy test: after 1/3 free:", pool);
+
+ /* realloc them:*/
+ for (i = 0; i < TEST_SZ; i += 3) {
+ length = i * 16;
+ addrs[i] = odpdrv_shm_pool_alloc(pool, length);
+ /* if alloc was success, fill buffer for later check */
+ if (addrs[i]) {
+ for (j = 0; j < length; j++)
+ addrs[i][j] = (uint8_t)(length & 0xFF);
+ }
+ }
+ odpdrv_shm_pool_print("buddy test: after realloc:", pool);
+
+ /* free all (except buff), checking contents: */
+ for (i = 0; i < TEST_SZ; i++) {
+ /* if buffer was allocated, check the pattern in it */
+ if (addrs[i]) {
+ length = i * 16;
+ for (j = 0; j < length; j++)
+ CU_ASSERT(addrs[i][j] ==
+ (uint8_t)(length & 0xFF))
+ }
+ odpdrv_shm_pool_free(pool, addrs[i]);
+ }
+ odpdrv_shm_pool_print("buddy test: after all but 1K free:", pool);
+
+ /* check contents of our initial 1K buffer: */
+ for (i = 0; i < SZ_1K; i++)
+ CU_ASSERT((buff[i] == BUFF_PATTERN))
+ odpdrv_shm_pool_free(pool, buff);
+
+ odpdrv_shm_pool_print("buddy test: after all free", pool);
+
+ /* destroy pool: */
+ odpdrv_shm_pool_destroy(pool);
+}
+
odp_testinfo_t drvshmem_suite[] = {
ODP_TEST_INFO(drvshmem_test_basic),
ODP_TEST_INFO(drvshmem_test_reserve_after_fork),
ODP_TEST_INFO(drvshmem_test_singleva_after_fork),
ODP_TEST_INFO(drvshmem_test_stress),
+ ODP_TEST_INFO(drvshmem_test_buddy_basic),
ODP_TEST_INFO_NULL,
};
diff --git a/test/common_plat/validation/drv/drvshmem/drvshmem.h b/test/common_plat/validation/drv/drvshmem/drvshmem.h
index f4c26a1..ab45f7c 100644
--- a/test/common_plat/validation/drv/drvshmem/drvshmem.h
+++ b/test/common_plat/validation/drv/drvshmem/drvshmem.h
@@ -14,6 +14,7 @@ void drvshmem_test_basic(void);
void drvshmem_test_reserve_after_fork(void);
void drvshmem_test_singleva_after_fork(void);
void drvshmem_test_stress(void);
+void drvshmem_test_buddy_basic(void);
/* test arrays: */
extern odp_testinfo_t drvshmem_suite[];
commit 9107db16944d821a1c959049acc1fe3ff29f2341
Author: Christophe Milard <christophe.milard(a)linaro.org>
Date: Tue Jan 17 19:18:00 2017 +0100
linux-gen: drv: shm: adding pool allocator
Adding functions to create memory pools and allocate / free memory from
the created pools.
These functions calls their _ishm conterpart, of course.
Signed-off-by: Christophe Milard <christophe.milard(a)linaro.org>
Reviewed-and-tested-by: Yi He <yi.he(a)linaro.org>
Signed-off-by: Maxim Uvarov <maxim.uvarov(a)linaro.org>
diff --git a/platform/linux-generic/drv_shm.c b/platform/linux-generic/drv_shm.c
index 9b2560d..325632e 100644
--- a/platform/linux-generic/drv_shm.c
+++ b/platform/linux-generic/drv_shm.c
@@ -8,6 +8,7 @@
#include <odp/api/std_types.h>
#include <odp/drv/shm.h>
#include <_ishm_internal.h>
+#include <_ishmpool_internal.h>
static inline uint32_t from_handle(odpdrv_shm_t shm)
{
@@ -100,3 +101,46 @@ int odpdrv_shm_print_all(const char *title)
{
return _odp_ishm_status(title);
}
+
+odpdrv_shm_pool_t odpdrv_shm_pool_create(const char *pool_name,
+ odpdrv_shm_pool_param_t *param)
+{
+ int flags;
+
+ /* force unique address for all ODP threads */
+ flags = _ODP_ISHM_SINGLE_VA;
+ return (odpdrv_shm_pool_t)_odp_ishm_pool_create(pool_name,
+ param->pool_size,
+ param->min_alloc,
+ param->max_alloc,
+ flags);
+}
+
+int odpdrv_shm_pool_destroy(odpdrv_shm_pool_t pool)
+{
+ return _odp_ishm_pool_destroy((_odp_ishm_pool_t *)(void*)pool);
+}
+
+odpdrv_shm_pool_t odpdrv_shm_pool_lookup(const char *name)
+{
+ return (odpdrv_shm_pool_t)_odp_ishm_pool_lookup(name);
+}
+
+void *odpdrv_shm_pool_alloc(odpdrv_shm_pool_t pool, uint64_t size)
+{
+ return _odp_ishm_pool_alloc((_odp_ishm_pool_t *)(void*)pool, size);
+}
+
+void odpdrv_shm_pool_free(odpdrv_shm_pool_t pool, void *addr)
+{
+ (void)_odp_ishm_pool_free((_odp_ishm_pool_t *)(void*)pool, addr);
+}
+
+int odpdrv_shm_pool_print(const char *title, odpdrv_shm_pool_t pool)
+{
+ return _odp_ishm_pool_status(title, (_odp_ishm_pool_t *)(void*)pool);
+}
+
+/**
+ * @}
+ */
commit 567c2e8a0fd6b51db8b82ce926cc41d4c0e7898b
Author: Christophe Milard <christophe.milard(a)linaro.org>
Date: Tue Jan 17 19:17:59 2017 +0100
drv: adding odpdrv_shm_pool functions
Adding functions to create and destroy memory pools (from which memory
can be allocated and freed) are added.
These functions enable the usage of small memory amount (compared to
drvshm_reserve() whose granularity is the page size).
The usage of this pool guatantees that allocated memory is sharable
between ODP threads. (using malloc would not work when ODP threads
are linux processes).
Signed-off-by: Christophe Milard <christophe.milard(a)linaro.org>
Reviewed-by: Petri Savolainen <petri.savolainen(a)nokia.com>
Reviewed-and-tested-by: Yi He <yi.he(a)linaro.org>
Signed-off-by: Maxim Uvarov <maxim.uvarov(a)linaro.org>
diff --git a/include/odp/drv/spec/shm.h b/include/odp/drv/spec/shm.h
index ef64f5d..ee8181f 100644
--- a/include/odp/drv/spec/shm.h
+++ b/include/odp/drv/spec/shm.h
@@ -220,6 +220,105 @@ int odpdrv_shm_print_all(const char *title);
uint64_t odpdrv_shm_to_u64(odpdrv_shm_t hdl);
/**
+ * drv shm pool parameters
+ * Used to communicate pool creation options.
+ */
+typedef struct {
+ /** Sum of all (simultaneous) allocs (bytes)*/
+ uint64_t pool_size;
+
+ /** Minimum alloc size user will request from pool (bytes)*/
+ uint64_t min_alloc;
+
+ /** Maximum alloc size user will request from pool (bytes)*/
+ uint64_t max_alloc;
+} odpdrv_shm_pool_param_t;
+
+/**
+ * @typedef odpdrv_shm_pool_t
+ * odpdrv shared memory pool
+ */
+
+/**
+ * @def ODPDRV_SHM_POOL_INVALID
+ * Invalid odpdrv shared memory pool
+ */
+
+/**
+ * Create a memory pool
+ *
+ * This routine is used to create a memory pool. The use of pool name is
+ * optional.
+ * Unique names are not required. However, odpdrv_shm_pool_lookup()
+ * returns only a single matching pool.
+ *
+ * @param pool_name Name of the pool or NULL.
+ * @param param Pool parameters.
+ *
+ * @return Handle of the created drv shm memory pool
+ * @retval ODPDRV_SHM_POOL_INVALID Pool could not be created
+ */
+odpdrv_shm_pool_t odpdrv_shm_pool_create(const char *pool_name,
+ odpdrv_shm_pool_param_t *param);
+
+/**
+ * Destroy a pool previously created by odpdrv_shm_pool_create()
+ *
+ * @param pool Handle of the pool to be destroyed
+ *
+ * @retval 0 Success
+ * @retval <0 Failure
+ *
+ * @note This routine destroys a previously created pool, and will destroy any
+ * internal shared memory objects associated with the pool. Results are
+ * undefined if an attempt is made to destroy a pool that contains allocated
+ * or otherwise active allocations.
+ */
+int odpdrv_shm_pool_destroy(odpdrv_shm_pool_t pool);
+
+/**
+ * Find a memory pool by name
+ *
+ * @param name Name of the pool
+ *
+ * @return Handle of the first matching pool
+ * @retval ODPDRV_SHM_POOL_INVALID Pool could not be found
+ */
+odpdrv_shm_pool_t odpdrv_shm_pool_lookup(const char *name);
+
+/**
+ * Allocate memory from a memory pool
+ *
+ * @param pool Memory pool handle
+ * @param size Number of bytes to allocate (bytes)
+ *
+ * @return A pointer to the allocated memory
+ * @retval NULL on error.
+ */
+void *odpdrv_shm_pool_alloc(odpdrv_shm_pool_t pool, uint64_t size);
+
+/**
+ * Free memory back to a memory pool
+ *
+ * @param pool Memory pool handle
+ * @param addr pointer to a previously allocated memory
+ * (as returned by a previous call to odpdrv_shm_pool_alloc)
+ */
+void odpdrv_shm_pool_free(odpdrv_shm_pool_t pool, void *addr);
+
+/**
+ * Print memory pool info
+ *
+ * @param title A string to be printed as a title (e.g. location)
+ * @param pool Memory pool handle
+ *
+ * @return 0 on success, negative value if pool inconsistency is detected.
+ *
+ * @note This routine writes implementation-defined information about the
+ * specified pool to the ODP log. The intended use is for debugging.
+ */
+int odpdrv_shm_pool_print(const char *title, odpdrv_shm_pool_t pool);
+/**
* @}
*/
diff --git a/platform/linux-generic/include/odp/drv/plat/shm_types.h b/platform/linux-generic/include/odp/drv/plat/shm_types.h
index c48eeca..50a0837 100644
--- a/platform/linux-generic/include/odp/drv/plat/shm_types.h
+++ b/platform/linux-generic/include/odp/drv/plat/shm_types.h
@@ -35,6 +35,9 @@ static inline uint64_t odpdrv_shm_to_u64(odpdrv_shm_t hdl)
return _odpdrv_pri(hdl);
}
+typedef ODPDRV_HANDLE_T(odpdrv_shm_pool_t);
+
+#define ODPDRV_SHM_POOL_INVALID _odpdrv_cast_scalar(odpdrv_shm_pool_t, NULL)
/**
* @}
*/
commit 91f1ce71dc3d2694152d71690c1e7638716b9391
Author: Christophe Milard <christophe.milard(a)linaro.org>
Date: Tue Jan 17 19:17:58 2017 +0100
linux-gen: _ishm: adding buddy and slab allocation
_ishm now provides functions to create/destroy pools for buddy/slab
memory allocation, as well as functions to allocated/release memory
from the created pools.
Signed-off-by: Christophe Milard <christophe.milard(a)linaro.org>
Reviewed-and-tested-by: Yi He <yi.he(a)linaro.org>
Signed-off-by: Maxim Uvarov <maxim.uvarov(a)linaro.org>
diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am
index eeb401f..74e606d 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -127,6 +127,7 @@ noinst_HEADERS = \
${srcdir}/include/_fdserver_internal.h \
${srcdir}/include/_ishm_internal.h \
${srcdir}/include/_ishmphy_internal.h \
+ ${srcdir}/include/_ishmpool_internal.h \
${srcdir}/include/odp_align_internal.h \
${srcdir}/include/odp_atomic_internal.h \
${srcdir}/include/odp_buffer_inlines.h \
@@ -172,6 +173,7 @@ __LIB__libodp_linux_la_SOURCES = \
_fdserver.c \
_ishm.c \
_ishmphy.c \
+ _ishmpool.c \
odp_atomic.c \
odp_barrier.c \
odp_bitmap.c \
diff --git a/platform/linux-generic/_ishm.c b/platform/linux-generic/_ishm.c
index 23f620d..4c2578b 100644
--- a/platform/linux-generic/_ishm.c
+++ b/platform/linux-generic/_ishm.c
@@ -59,6 +59,7 @@
#include <_fdserver_internal.h>
#include <_ishm_internal.h>
#include <_ishmphy_internal.h>
+#include <_ishmpool_internal.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
@@ -1441,8 +1442,19 @@ int _odp_ishm_init_global(void)
* is performed for the main thread... Many init_global() functions
* indeed assume the availability of odp_shm_reserve()...:
*/
- return do_odp_ishm_init_local();
+ if (do_odp_ishm_init_local()) {
+ ODP_ERR("unable to init the main thread\n.");
+ goto init_glob_err4;
+ }
+
+ /* get ready to create pools: */
+ _odp_ishm_pool_init();
+ return 0;
+
+init_glob_err4:
+ if (_odp_ishmphy_unbook_va())
+ ODP_ERR("unable to unbook virtual space\n.");
init_glob_err3:
if (munmap(ishm_ftbl, sizeof(ishm_ftable_t)) < 0)
ODP_ERR("unable to munmap main fragment table\n.");
diff --git a/platform/linux-generic/_ishmpool.c b/platform/linux-generic/_ishmpool.c
new file mode 100644
index 0000000..df6e49e
--- /dev/null
+++ b/platform/linux-generic/_ishmpool.c
@@ -0,0 +1,811 @@
+/* Copyright (c) 2017, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+/* This file gathers the buddy and slab allocation functionality provided
+ * by _ishm.
+ * _odp_ishmpool_create() can be used to create a pool for buddy/slab
+ * allocation. _odp_ishmpool_create() will allocate a memory area using
+ * ishm_reserve() for both the control part (needed for tracking
+ * allocation/free...) and the user memory itself (part of which will be given
+ * at each ishmpool_alloc()).
+ * The element size provided at pool creation time determines whether
+ * to pool will of type buddy or slab.
+ * For buddy, all allocations are rounded to the nearest power of 2.
+ *
+ * The implementation of the buddy allocator is very traditional: it
+ * maintains N lists of free buffers.
+ * The control part actually contains these N queue heads, (N-M are actually
+ * used), the free buffers themselves being used for chaining (the chaining info
+ * is in the buffers: as they are "free" they should not be touched by the
+ * user). The control part also contains a array of bytes for remembering
+ * the size (actually the order) of the allocated buffers:
+ * There are 2^(N-M) such bytes, this number being the maximum number of
+ * allocated buffers (when all allocation are <= 2^M bytes)
+ * Buddy allocators handle fragmentation by splitting or merging blocks by 2.
+ * They guarantee a minimum efficiency of 50%, at worse case fragmentation.
+ *
+ * Slab implementation is even simpler, all free elements being queued in
+ * one single queue at init, taken from this queue when allocated and
+ * returned to this same queue when freed.
+ *
+ * The reason for not using malloc() is that malloc does not guarantee
+ * memory sharability between ODP threads (regardless of their implememtation)
+ * which ishm_reserve() can do. see the comments around
+ * _odp_ishmbud_pool_create() and ishm_reserve() for more details.
+ *
+ * This file is divided in 3 sections: the first one regroups functions
+ * needed by the buddy allocation.
+ * The second one regroups the functions needed by the slab allocator.
+ * The third section regroups the common functions exported externally.
+ */
+
+#include <odp_posix_extensions.h>
+#include <odp_internal.h>
+#include <odp/api/spinlock.h>
+#include <odp/api/align.h>
+#include <odp/api/debug.h>
+#include <odp/drv/shm.h>
+#include <odp_shm_internal.h>
+#include <odp_debug_internal.h>
+#include <odp_align_internal.h>
+#include <_ishm_internal.h>
+#include <_ishmpool_internal.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <inttypes.h>
+
+#define BUDDY_MIN_SIZE 32 /* minimal buddy allocation size */
+
+typedef _odp_ishm_pool_t pool_t; /* for shorter writing */
+
+/* array of ishm block index used for pools. only used for pool
+ * lookup by name */
+#define MAX_NB_POOL 100
+static int pool_blk_idx[MAX_NB_POOL];
+
+/* section 1: functions for buddy allocation: */
+
+/* free buddy blocks contains the following structure, used to link the
+ * free blocks together.
+ */
+typedef struct bblock_t {
+ struct bblock_t *next;
+ uint32_t order;
+} bblock_t;
+
+/* value set in the 'order' table when the block is not allocated: */
+#define BBLOCK_FREE 0
+
+/* compute ceil(log2(size)) */
+static uint8_t clog2(uint64_t size)
+{
+ uint64_t sz;
+ uint32_t bit;
+ uint8_t res;
+
+ sz = size; /* we start by computing res = log2(sz)... */
+ res = 0;
+ for (bit = 32; bit ; bit >>= 1) {
+ if (sz >= ((uint64_t)1 << bit)) {
+ sz >>= bit;
+ res += bit;
+ }
+ }
+ if (((uint64_t)1 << res) < size) /* ...and then ceil(x) */
+ res++;
+
+ return res;
+}
+
+/*
+ * given a bblock address, and an order value, returns the address
+ * of the buddy bblock (the other "half")
+ */
+static inline bblock_t *get_bblock_buddy(pool_t *bpool, bblock_t *addr,
+ uint8_t order)
+{
+ uintptr_t b;
+
+ b = ((uintptr_t)addr - (uintptr_t)bpool->ctrl.user_addr);
+ b ^= 1 << order;
+ return (void *)(b + (uintptr_t)bpool->ctrl.user_addr);
+}
+
+/*
+ * given a buddy block address, return its number (used for busy flags):
+ */
+static inline uintptr_t get_bblock_nr(pool_t *bpool, void *addr)
+{
+ uintptr_t b;
+ uint8_t min_order;
+
+ min_order = bpool->ctrl.min_order;
+ b = ((uintptr_t)addr - (uintptr_t)bpool->ctrl.user_addr) >> min_order;
+ return b;
+}
+
+/* remove bblock from the list for bblocks of rank order. The bblock to be
+ * removed is really expected to be on the list: not finding it is an error */
+static inline void remove_from_list(pool_t *bpool, uint8_t order,
+ bblock_t *bblock)
+{
+ bblock_t *curr; /* current bblock (when parsing list) */
+ bblock_t *prev; /* previous bblock (when parsing list) */
+
+ curr = bpool->ctrl.free_heads[order];
+ if (!curr)
+ goto remove_from_list_error;
+
+ if (curr == bblock) {
+ bpool->ctrl.free_heads[order] = curr->next;
+ return;
+ }
+
+ while (curr) {
+ if (curr == bblock) {
+ prev->next = curr->next;
+ return;
+ }
+ prev = curr;
+ curr = curr->next;
+ }
+
+remove_from_list_error:
+ ODP_ERR("List corrupted\n");
+}
+
+/*
+ * create a buddy memory pool of given size (actually nearest power of 2),
+ * where allocation will never be smaller than min_alloc.
+ * returns a pointer to the created buddy_pool
+ * The allocated area contains:
+ * - The _odp_ishm_pool_ctrl_t structure
+ * - The array of ((order - min_order) of free list heads
+ * - The array of 'order' values, remembering sizes of allocated bblocks
+ * - alignment to cache line
+ * - The user memory
+ */
+static pool_t *_odp_ishmbud_pool_create(const char *pool_name, int store_idx,
+ uint64_t size,
+ uint64_t min_alloc, int flags)
+{
+ uint8_t order; /* pool order = ceil(log2(size)) */
+ uint8_t min_order; /* pool min_order = ceil(log2(min_alloc))*/
+ uint32_t max_nb_bblock; /* max number of bblock, when smallest */
+ uint32_t control_sz; /* size of control area */
+ uint32_t free_head_sz; /* mem area needed for list heads */
+ uint32_t saved_order_sz; /* mem area to remember given sizes */
+ uint64_t user_sz; /* 2^order bytes */
+ uint64_t total_sz; /* total size to request */
+ int blk_idx; /* as returned by _ishm_resrve() */
+ pool_t *bpool;
+ int i;
+ bblock_t *first_block;
+
+ /* a bblock_t must fit in the buffers for linked chain! */
+ if (min_alloc < sizeof(bblock_t))
+ min_alloc = sizeof(bblock_t);
+
+ /* pool order is such that 2^order = size. same for min_order */
+ order = clog2(size);
+ min_order = clog2(min_alloc);
+
+ /* check parameters obvious wishes: */
+ if (order >= 64)
+ return NULL;
+ if (order < min_order)
+ return NULL;
+
+ /* at worst case, all bblocks have smallest (2^min_order) size */
+ max_nb_bblock = (1 << (order - min_order));
+
+ /* space needed for the control area (padded to cache line size)*/
+ control_sz =
+ ODP_CACHE_LINE_SIZE_ROUNDUP(sizeof(_odp_ishm_pool_ctrl_t));
+
+ /* space needed for 'order' free bblock list heads: */
+ /* Note that only lists from min_order to order are really used.*/
+ free_head_sz = ODP_CACHE_LINE_SIZE_ROUNDUP(sizeof(void *) *
+ (order + 1));
+
+ /* space needed for order -i.e. size- storage of alloc'd bblock:*/
+ saved_order_sz = ODP_CACHE_LINE_SIZE_ROUNDUP(max_nb_bblock *
+ sizeof(uint8_t));
+
+ /* space needed for user area is 2^order bytes: */
+ user_sz = 1 << order;
+
+ total_sz = control_sz +
+ free_head_sz +
+ saved_order_sz +
+ user_sz;
+
+ /* allocate required memory: */
+ blk_idx = _odp_ishm_reserve(pool_name, total_sz, -1,
+ ODP_CACHE_LINE_SIZE, flags, 0);
+ if (blk_idx < 0) {
+ ODP_ERR("_odp_ishm_reserve failed.");
+ return NULL;
+ }
+
+ bpool = _odp_ishm_address(blk_idx);
+ if (bpool == NULL) {
+ ODP_ERR("_odp_ishm_address failed.");
+ return NULL;
+ }
+
+ /* store in pool array (needed for look up): */
+ pool_blk_idx[store_idx] = blk_idx;
+
+ /* remember block index, needed when pool is destroyed */
+ bpool->ctrl.ishm_blk_idx = blk_idx;
+
+ /* remember element size: 0 means unknown size, i.e. buddy alloation*/
+ bpool->ctrl.element_sz = 0;
+
+ /* prepare mutex: */
+ odp_spinlock_init(&bpool->ctrl.lock);
+
+ /* initialise pointers and things... */
+ bpool->ctrl.order = order;
+ bpool->ctrl.min_order = min_order;
+ bpool->ctrl.free_heads =
+ (void *)((uintptr_t)bpool + control_sz);
+ bpool->ctrl.alloced_order =
+ (uint8_t *)((uintptr_t)bpool->ctrl.free_heads + free_head_sz);
+ bpool->ctrl.user_addr =
+ (void *)((uintptr_t)bpool->ctrl.alloced_order + saved_order_sz);
+
+ /* initialize all free list to NULL, except the top biggest element:*/
+ for (i = 0; i < (order - min_order); i++)
+ bpool->ctrl.free_heads[i] = NULL;
+ bpool->ctrl.free_heads[order] = bpool->ctrl.user_addr;
+ first_block = (bblock_t *)bpool->ctrl.user_addr;
+ first_block->next = NULL;
+ first_block->order = order;
+
+ /* set all 'order' of allocated bblocks to free: */
+ memset(bpool->ctrl.alloced_order, BBLOCK_FREE, saved_order_sz);
+
+ return bpool;
+}
+
+/* allocated memory from the given buddy pool */
+static void *_odp_ishmbud_alloc(pool_t *bpool, uint64_t size)
+{
+ uint32_t rq_order; /* requested order */
+ uint32_t try_order;
+ bblock_t *bblock;
+ bblock_t *buddy;
+ uintptr_t nr;
+
+ /* if size is zero or too big reject: */
+ if ((!size) && (size > (1U << bpool->ctrl.order))) {
+ ODP_ERR("Invalid alloc size (0 or larger than whole pool)\n");
+ return NULL;
+ }
+
+ /* compute ceil(log2(size)), to get the requested block order: */
+ rq_order = clog2(size);
+
+ /* make sure the requested order is bigger (or same) as minimum! */
+ if (rq_order < bpool->ctrl.min_order)
+ rq_order = bpool->ctrl.min_order;
+
+ /* mutex from here: */
+ odp_spinlock_lock(&bpool->ctrl.lock);
+
+ /* now, start trying to allocate a bblock of rq_order. If that
+ * fails keep trying larger orders until pool order is reached */
+ bblock = NULL;
+ for (try_order = rq_order; try_order <= bpool->ctrl.order;
+ try_order++) {
+ if (bpool->ctrl.free_heads[try_order]) {
+ /* remove from list: */
+ bblock =
+ (bblock_t *)(bpool->ctrl.free_heads[try_order]);
+ bpool->ctrl.free_heads[try_order] = bblock->next;
+ break;
+ }
+ }
+
+ if (!bblock) {
+ odp_spinlock_unlock(&bpool->ctrl.lock);
+ ODP_ERR("Out of memory. (Buddy pool full)\n");
+ return NULL;
+ }
+
+ /* OK: we got a block, but possibbly too large (if try_order>rq_order)
+ * return the extra halves to the pool hence splitting the bblock at
+ * each 'extra' order: */
+ while (try_order-- > rq_order) {
+ /* split: */
+ buddy = (bblock_t *)((uintptr_t)bblock + (1 << try_order));
+ buddy->order = try_order;
+ /* add to list: */
+ buddy->next = bpool->ctrl.free_heads[try_order];
+ bpool->ctrl.free_heads[try_order] = buddy;
+ /* mark as free (non allocated block get size 0): */
+ nr = get_bblock_nr(bpool, buddy);
+ bpool->ctrl.alloced_order[nr] = BBLOCK_FREE;
+ }
+
+ /* remember the size if the allocated block: */
+ nr = get_bblock_nr(bpool, bblock);
+ bpool->ctrl.alloced_order[nr] = rq_order;
+
+ /* and return the allocated block! */
+ odp_spinlock_unlock(&bpool->ctrl.lock);
+ return (void *)bblock;
+}
+
+/* free a previously allocated buffer from a given buddy pool */
+static int _odp_ishmbud_free(pool_t *bpool, void *addr)
+{
+ uintptr_t user_start; /* start of user area */
+ uintptr_t user_stop; /* stop of user area */
+ uintptr_t mask; /* 2^min_order - 1 */
+ bblock_t *bblock; /* bblock being freed */
+ bblock_t *buddy; /* buddy bblock of bblock being freed */
+ uint8_t order; /* order of block being freed */
+ uintptr_t nr; /* block number */
+
+ /* freeing NULL is regarded as OK, though without any effect: */
+ if (!addr)
+ return 0;
+
+ user_start = (uintptr_t)bpool->ctrl.user_addr;
+ user_stop = user_start + ((uintptr_t)1 << bpool->ctrl.order);
+ mask = ((uintptr_t)1 << bpool->ctrl.min_order) - 1;
+
+ /* some sanity checks: check that given address is within pool and
+ * that relative address has 2^min_order granularity: */
+ if (((uintptr_t)addr < user_start) ||
+ ((uintptr_t)addr > user_stop) ||
+ (((uintptr_t)addr - user_start) & mask)) {
+ ODP_ERR("Invalid address to be freed\n");
+ return -1;
+ }
+
+ /* mutex from here: */
+ odp_spinlock_lock(&bpool->ctrl.lock);
+
+ /* collect saved block order and make sure bblock was allocated */
+ bblock = (bblock_t *)addr;
+ nr = get_bblock_nr(bpool, bblock);
+ order = bpool->ctrl.alloced_order[nr];
+ if (order == BBLOCK_FREE) {
+ ODP_ERR("Double free error\n");
+ odp_spinlock_unlock(&bpool->ctrl.lock);
+ return -1;
+ }
+
+ /* this looks like a valid free, mark at least this as free: */
+ bpool->ctrl.alloced_order[nr] = BBLOCK_FREE;
+
+ /* go up in orders, trying to merge buddies... */
+ while (order < bpool->ctrl.order) {
+ buddy = get_bblock_buddy(bpool, bblock, order);
+ /*if buddy is not free: no further merge possible */
+ nr = get_bblock_nr(bpool, buddy);
+ if (bpool->ctrl.alloced_order[nr] != BBLOCK_FREE)
+ break;
+ /*merge only bblock of same order:*/
+ if (buddy->order != order)
+ break;
+ /*merge: remove buddy from free list: */
+ remove_from_list(bpool, order, buddy);
+ /*merge: make sure we point at start of block: */
+ if (bblock > buddy)
+ bblock = buddy;
+ /*merge: size of bloack has dubbled: increse order: */
+ order++;
+ }
+
+ /* insert the bblock into its correct free block list: */
+ bblock->next = bpool->ctrl.free_heads[order];
+ bpool->ctrl.free_heads[order] = bblock;
+
+ /* remember the (possibly now merged) block order: */
+ bblock->order = order;
+
+ odp_spinlock_unlock(&bpool->ctrl.lock);
+ return 0;
+}
+
+/* print buddy pool status and performs sanity checks */
+static int _odp_ishmbud_pool_status(const char *title, pool_t *bpool)
+{
+ uint8_t order, pool_order, pool_min_order;
+ uint64_t free_q_nb_bblocks[64];
+ uint64_t allocated_nb_bblocks[64];
+ uint64_t free_q_nb_bblocks_bytes[64];
+ uint64_t allocated_nb_bblocks_bytes[64];
+ uint64_t total_bytes_free;
+ uint64_t total_bytes_allocated;
+ uint64_t nr;
+ bblock_t *bblock;
+ int res = 0;
+
+ odp_spinlock_lock(&bpool->ctrl.lock);
+
+ pool_order = bpool->ctrl.order;
+ pool_min_order = bpool->ctrl.min_order;
+
+ ODP_DBG("\n%s\n", title);
+ ODP_DBG("Pool Type: BUDDY\n");
+ ODP_DBG("pool size: %" PRIu64 " (bytes)\n", (1UL << pool_order));
+ ODP_DBG("pool order: %d\n", (int)pool_order);
+ ODP_DBG("pool min_order: %d\n", (int)pool_min_order);
+
+ /* a pool wholse order is more than 64 cannot even be reached on 64
+ * bit machines! */
+ if (pool_order > 64) {
+ odp_spinlock_unlock(&bpool->ctrl.lock);
+ return -1;
+ }
+
+ total_bytes_free = 0;
+ total_bytes_allocated = 0;
+
+ /* for each queue */
+ for (order = pool_min_order; order <= pool_order; order++) {
+ free_q_nb_bblocks[order] = 0;
+ free_q_nb_bblocks_bytes[order] = 0;
+ allocated_nb_bblocks[order] = 0;
+ allocated_nb_bblocks_bytes[order] = 0;
+
+ /* get the number of buffs in the free queue for this order: */
+ bblock = bpool->ctrl.free_heads[order];
+ while (bblock) {
+ free_q_nb_bblocks[order]++;
+ free_q_nb_bblocks_bytes[order] += (1 << order);
+ bblock = bblock->next;
+ }
+
+ total_bytes_free += free_q_nb_bblocks_bytes[order];
+
+ /* get the number of allocated buffers of this order */
+ for (nr = 0;
+ nr < (1U << (pool_order - pool_min_order)); nr++) {
+ if (bpool->ctrl.alloced_order[nr] == order)
+ allocated_nb_bblocks[order]++;
+ }
+
+ allocated_nb_bblocks_bytes[order] =
+ allocated_nb_bblocks[order] * (1 << order);
+
+ total_bytes_allocated += allocated_nb_bblocks_bytes[order];
+
+ ODP_DBG("Order %d => Free: %" PRIu64 " buffers "
+ "(%" PRIu64" bytes) "
+ "Allocated %" PRIu64 " buffers (%" PRIu64 " bytes) "
+ "Total: %" PRIu64 " bytes\n",
+ (int)order, free_q_nb_bblocks[order],
+ free_q_nb_bblocks_bytes[order],
+ allocated_nb_bblocks[order],
+ allocated_nb_bblocks_bytes[order],
+ free_q_nb_bblocks_bytes[order] +
+ allocated_nb_bblocks_bytes[order]);
+ }
+
+ ODP_DBG("Allocated space: %" PRIu64 " (bytes)\n",
+ total_bytes_allocated);
+ ODP_DBG("Free space: %" PRIu64 " (bytes)\n", total_bytes_free);
+
+ if (total_bytes_free + total_bytes_allocated != (1U << pool_order)) {
+ ODP_DBG("Lost bytes on this pool!\n");
+ res = -1;
+ }
+
+ if (res)
+ ODP_DBG("Pool inconsistent!\n");
+
+ odp_spinlock_unlock(&bpool->ctrl.lock);
+ return res;
+}
+
+/* section 2: functions for slab allocation: */
+
+/* free slab blocks contains the following structure, used to link the
+ * free blocks together.
+ */
+typedef struct sblock_t {
+ struct sblock_t *next;
+} sblock_t;
+
+/*
+ * create a slab memory pool of given size (rounded up to the nearest integer
+ * number of element, where each element has size 'elt_size').
+ * returns a pointer to the created slab pool.
+ * The allocated area contains:
+ * - The _odp_ishm_pool_ctrl_t structure
+ * - alignment to cache line
+ * - The user memory
+ */
+static pool_t *_odp_ishmslab_pool_create(const char *pool_name, int store_idx,
+ uint64_t size,
+ uint64_t elt_size, int flags)
+{
+ uint32_t nb_sblock; /* number of elements in the pool */
+ uint32_t control_sz; /* size of control area */
+ uint64_t total_sz; /* total size to request */
+ uint64_t user_sz; /* 2^order bytes */
+ int blk_idx; /* as returned by _ishm_reserve() */
+ pool_t *spool;
+ unsigned int i;
+ sblock_t *block;
+
+ /* a sblock_t must fit in the buffers for linked chain! */
+ if (elt_size < sizeof(bblock_t)) {
+ elt_size = sizeof(bblock_t);
+ size = size * (sizeof(bblock_t) / elt_size +
+ ((sizeof(bblock_t) % elt_size) ? 1 : 0));
+ }
+
+ /* nb of element fitting in the pool is just ceil(size/elt_size)*/
+ nb_sblock = (size / elt_size) + ((size % elt_size) ? 1 : 0);
+
+ /* space needed for the control area (padded to cache line size)*/
+ control_sz =
+ ODP_CACHE_LINE_SIZE_ROUNDUP(sizeof(_odp_ishm_pool_ctrl_t));
+
+ /* space needed for user area is : */
+ user_sz = nb_sblock * elt_size;
+
+ total_sz = control_sz +
+ user_sz;
+
+ /* allocate required memory: */
+ blk_idx = _odp_ishm_reserve(pool_name, total_sz, -1,
+ ODP_CACHE_LINE_SIZE, flags, 0);
+ if (blk_idx < 0) {
+ ODP_ERR("_odp_ishm_reserve failed.");
+ return NULL;
+ }
+
+ spool = _odp_ishm_address(blk_idx);
+ if (spool == NULL) {
+ ODP_ERR("_odp_ishm_address failed.");
+ return NULL;
+ }
+
+ /* store in pool array (needed for look up): */
+ pool_blk_idx[store_idx] = blk_idx;
+
+ /* remember block index, needed when pool is destroyed */
+ spool->ctrl.ishm_blk_idx = blk_idx;
+
+ /* remember element (sblock) size and their number: */
+ spool->ctrl.element_sz = elt_size;
+ spool->ctrl.nb_elem = nb_sblock;
+
+ /* prepare mutex: */
+ odp_spinlock_init(&spool->ctrl.lock);
+
+ /* initialise pointers and things... */
+ spool->ctrl.user_addr =
+ (void *)((uintptr_t)spool + control_sz);
+
+ /* initialise the free list with the list of all elements:*/
+ spool->ctrl.free_head = spool->ctrl.user_addr;
+ for (i = 0; i < nb_sblock - 1; i++) {
+ block = (sblock_t *)((uintptr_t)spool->ctrl.user_addr +
+ i * (uintptr_t)elt_size);
+ block->next = (sblock_t *)((uintptr_t)block +
+ (uintptr_t)elt_size);
+ }
+ block = (sblock_t *)((uintptr_t)spool->ctrl.user_addr +
+ (nb_sblock - 1) * (uintptr_t)elt_size);
+ block->next = NULL;
+
+ return spool;
+}
+
+/* allocated memory from the given slab pool */
+static void *_odp_ishmslab_alloc(pool_t *spool, uint64_t size)
+{
+ void *ret;
+ sblock_t *block;
+
+ if (size > spool->ctrl.element_sz)
+ return NULL;
+
+ odp_spinlock_lock(&spool->ctrl.lock);
+ ret = spool->ctrl.free_head;
+ if (!ret) {
+ odp_spinlock_unlock(&spool->ctrl.lock);
+ ODP_ERR("Out of memory. (Slab pool full)\n");
+ return NULL;
+ }
+
+ block = (sblock_t *)ret;
+ spool->ctrl.free_head = block->next;
+
+ odp_spinlock_unlock(&spool->ctrl.lock);
+ return ret;
+}
+
+/* free a previously allocated buffer from a given slab pool */
+static int _odp_ishmslab_free(pool_t *spool, void *addr)
+{
+ uintptr_t user_start; /* start of user area */
+ uintptr_t user_stop; /* stop of user area */
+ sblock_t *block;
+
+ /* freeing NULL is regarded as OK, though without any effect: */
+ if (!addr)
+ return 0;
+
+ user_start = (uintptr_t)spool->ctrl.user_addr;
+ user_stop = user_start + spool->ctrl.element_sz * spool->ctrl.nb_elem;
+
+ /* some sanity checks: check that given address is within pool and
+ * that relative address has element_sz granularity: */
+ if (((uintptr_t)addr < user_start) ||
+ ((uintptr_t)addr > user_stop) ||
+ (((uintptr_t)addr - user_start) % spool->ctrl.element_sz)) {
+ ODP_ERR("Invalid address to be freed\n");
+ return -1;
+ }
+
+ odp_spinlock_lock(&spool->ctrl.lock);
+ block = (sblock_t *)addr;
+ block->next = (sblock_t *)spool->ctrl.free_head;
+ spool->ctrl.free_head = addr;
+ odp_spinlock_unlock(&spool->ctrl.lock);
+
+ return 0;
+}
+
+/* print slab pool status and performs sanity checks */
+static int _odp_ishmslab_pool_status(const char *title, pool_t *spool)
+{
+ sblock_t *sblock;
+ uint64_t nb_free_elts; /* number of free elements */
+
+ odp_spinlock_lock(&spool->ctrl.lock);
+
+ ODP_DBG("\n%s\n", title);
+ ODP_DBG("Pool Type: FIXED SIZE\n");
+ ODP_DBG("pool size: %" PRIu64 " (bytes)\n",
+ spool->ctrl.nb_elem * spool->ctrl.element_sz);
+
+ /* count the number of free elements in the free list: */
+ nb_free_elts = 0;
+ sblock = (sblock_t *)spool->ctrl.free_head;
+ while (sblock) {
+ nb_free_elts++;
+ sblock = sblock->next;
+ }
+
+ ODP_DBG("%" PRIu64 "/%" PRIu64 " available elements.\n",
+ nb_free_elts, spool->ctrl.nb_elem);
+
+ odp_spinlock_unlock(&spool->ctrl.lock);
+ return 0;
+}
+
+/* section 3: common, external functions: */
+
+/* create a pool: either with fixed alloc size (if max_alloc/min_alloc<2) or
+ * of variable block size (if max_alloc == 0) */
+pool_t *_odp_ishm_pool_create(const char *pool_name, uint64_t size,
+ uint64_t min_alloc, uint64_t max_alloc, int flags)
+{
+ int store_idx;
+ uint64_t real_pool_sz;
+
+ if (min_alloc > max_alloc) {
+ ODP_ERR("invalid parameter: min_alloc > max_alloc");
+ return NULL;
+ }
+
+ /* search for a free index in pool_blk_idx for the pool */
+ for (store_idx = 0; store_idx < MAX_NB_POOL; store_idx++) {
+ if (pool_blk_idx[store_idx] < 0)
+ break;
+ }
+ if (store_idx == MAX_NB_POOL) {
+ ODP_ERR("Max number of pool reached (MAX_NB_POOL)");
+ return NULL;
+ }
+
+ if ((min_alloc == 0) || ((max_alloc / min_alloc) > 2)) {
+ /* alloc variation is not constant enough: we go for a buddy
+ * allocator. The pool efficiency may go as low as 50%
+ * so we double the required size to make sure we can satisfy
+ * the user request */
+ real_pool_sz = 2 * size;
+ return _odp_ishmbud_pool_create(pool_name, store_idx,
+ real_pool_sz,
+ BUDDY_MIN_SIZE, flags);
+ } else {
+ /* min and max are close enough so we go for constant size
+ * allocator:
+ * make sure the pool can fit the required size, even when
+ * only min_alloc allocation are performed: */
+ real_pool_sz = ((size / min_alloc) +
+ ((size % min_alloc) ? 1 : 0))
+ * max_alloc;
+ return _odp_ishmslab_pool_create(pool_name, store_idx,
+ real_pool_sz,
+ max_alloc, flags);
+ }
+}
+
+/* destroy a pool. everything goes away. no operation on the pool should
+ * follow. */
+int _odp_ishm_pool_destroy(pool_t *pool)
+{
+ int store_idx;
+
+ for (store_idx = 0; store_idx < MAX_NB_POOL; store_idx++) {
+ if (pool_blk_idx[store_idx] == pool->ctrl.ishm_blk_idx) {
+ pool_blk_idx[store_idx] = -1;
+ break;
+ }
+ }
+
+ return _odp_ishm_free_by_index(pool->ctrl.ishm_blk_idx);
+}
+
+/* allocated a buffer from a pool */
+void *_odp_ishm_pool_alloc(_odp_ishm_pool_t *pool, uint64_t size)
+{
+ if (!pool->ctrl.element_sz)
+ return _odp_ishmbud_alloc(pool, size);
+ else
+ return _odp_ishmslab_alloc(pool, size);
+}
+
+/* free a previously allocated buffer from a pool */
+int _odp_ishm_pool_free(_odp_ishm_pool_t *pool, void *addr)
+{
+ if (!pool->ctrl.element_sz)
+ return _odp_ishmbud_free(pool, addr);
+ else
+ return _odp_ishmslab_free(pool, addr);
+}
+
+/* Print a pool status */
+int _odp_ishm_pool_status(const char *title, _odp_ishm_pool_t *pool)
+{
+ if (!pool->ctrl.element_sz)
+ return _odp_ishmbud_pool_status(title, pool);
+ else
+ return _odp_ishmslab_pool_status(title, pool);
+}
+
+void _odp_ishm_pool_init(void)
+{
+ int i;
+
+ for (i = 0; i < MAX_NB_POOL; i++)
+ pool_blk_idx[i] = -1;
+}
+
+_odp_ishm_pool_t *_odp_ishm_pool_lookup(const char *pool_name)
+{
+ int block_idx;
+ int store_idx;
+
+ /* search for a _ishm block with the given name */
+ block_idx = _odp_ishm_lookup_by_name(pool_name);
+ if (block_idx < 0)
+ return NULL;
+
+ /* a block with that name exists: make sure it is within
+ * the registered pools */
+ for (store_idx = 0; store_idx < MAX_NB_POOL; store_idx++) {
+ if (pool_blk_idx[store_idx] == block_idx)
+ return _odp_ishm_address(block_idx);
+ }
+
+ return NULL;
+}
diff --git a/platform/linux-generic/include/_ishmpool_internal.h b/platform/linux-generic/include/_ishmpool_internal.h
new file mode 100644
index 0000000..5c5304a
--- /dev/null
+++ b/platform/linux-generic/include/_ishmpool_internal.h
@@ -0,0 +1,56 @@
+/* Copyright (c) 2017, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef ODP_ISHMBUDDY_INTERNAL_H_
+#define ODP_ISHMBUDDY_INTERNAL_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+#include <odp/api/spinlock.h>
+
+typedef struct _odp_ishm_pool_ctrl_t {
+ uint32_t element_sz; /* 0 for buddy pools, >0 for slab. */
+ int ishm_blk_idx; /* the block index returned by _ishm_resrve()*/
+ odp_spinlock_t lock; /* for pool access mutex */
+ void *user_addr; /* user pool area ('real user pool') */
+ union {
+ struct { /* things needed for buddy pools: */
+ uint8_t order; /* pool is 2^order bytes long */
+ uint8_t min_order; /*alloc won't go below 2^min_order*/
+ void **free_heads; /* 'order' free list heads. */
+ uint8_t *alloced_order; /* size of blocks, 0=free */
+ };
+ struct { /* things needed for slab pools: */
+ void *free_head; /* free element list head */
+ uint64_t nb_elem;/* total number of elements in pool */
+ };
+ };
+} _odp_ishm_pool_ctrl_t;
+
+typedef struct _odp_ishm_pool_t {
+ _odp_ishm_pool_ctrl_t ctrl; /* control part */
+ uint8_t mem[1]; /* area for heads, saved alloc'd orders, data*/
+} _odp_ishm_pool_t;
+
+_odp_ishm_pool_t *_odp_ishm_pool_create(const char *pool_name,
+ uint64_t size,
+ uint64_t min_alloc,
+ uint64_t max_alloc, int flags);
+int _odp_ishm_pool_destroy(_odp_ishm_pool_t *pool);
+void *_odp_ishm_pool_alloc(_odp_ishm_pool_t *pool, uint64_t size);
+int _odp_ishm_pool_free(_odp_ishm_pool_t *pool, void *addr);
+int _odp_ishm_pool_status(const char *title, _odp_ishm_pool_t *pool);
+_odp_ishm_pool_t *_odp_ishm_pool_lookup(const char *pool_name);
+void _odp_ishm_pool_init(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
-----------------------------------------------------------------------
Summary of changes:
include/odp/drv/spec/shm.h | 99 +++
platform/linux-generic/Makefile.am | 2 +
platform/linux-generic/_ishm.c | 14 +-
platform/linux-generic/_ishmpool.c | 811 +++++++++++++++++++++
platform/linux-generic/drv_shm.c | 44 ++
.../linux-generic/include/_ishmpool_internal.h | 56 ++
.../linux-generic/include/odp/drv/plat/shm_types.h | 3 +
.../common_plat/validation/drv/drvshmem/drvshmem.c | 355 +++++++++
.../common_plat/validation/drv/drvshmem/drvshmem.h | 3 +
9 files changed, 1386 insertions(+), 1 deletion(-)
create mode 100644 platform/linux-generic/_ishmpool.c
create mode 100644 platform/linux-generic/include/_ishmpool_internal.h
hooks/post-receive
--