librte_net: add crc computation support
cover librte_net: add crc computation support
In some applications, CRC (Cyclic Redundancy Check) needs to be computed or updated during packet processing operations. This patchset adds software implementation of some common standard CRCs (32-bit Ethernet CRC as per Ethernet/[ISO/IEC 8802-3] and 16-bit CCITT-CRC [ITU-T X.25]). Two versions of each 32-bit and 16-bit CRC calculation are proposed.
The first version presents a fast and efficient CRC generation on IA processors by using the carry-less multiplication instruction – PCLMULQDQ (i.e SSE4.2 instrinsics). In this implementation, a parallelized folding approach has been used to first reduce an arbitrary length buffer to a small fixed size length buffer (16 bytes) with the help of precomputed constants. The resultant single 16-bytes chunk is further reduced by Barrett reduction method to generate final CRC value. For more details on the implementation, see reference [1].
The second version presents the fallback solution to support the CRC generation without needing any specific support from CPU (for examples- SSE4.2 intrinsics). It is based on generic Look-Up Table(LUT) algorithm that uses precomputed 256 element table as explained in reference[2].
Following APIs have been added;
(i) rte_net_crc_init()
(ii)rte_net_crc_calc()
The first API (i) initalises the data structures required for CRC computation and this api should be used only once in the application before using second API (ii) for 16-bit and 32-bit CRC calculations.
References:
[1] Fast CRC Computation for Generic Polynomials Using PCLMULQDQ Instruction
http://www.intel.com/content/dam/www/public/us/en/documents/white-papers/fast-crc-computation-generic-polynomials-pclmulqdq-paper.pdf
[2] A PAINLESS GUIDE TO CRC ERROR DETECTION ALGORITHMS
http://www.ross.net/crc/download/crc_v3.txt
Jasvinder Singh (2):
librte_net: add crc init and compute APIs
app/test: add unit test for CRC computation
app/test/Makefile | 2 + app/test/test_crc.c | 229 +++++++++++++ lib/librte_net/Makefile | 2 + lib/librte_net/rte_net_crc.c | 657 +++++++++++++++++++++++++++++++++++++ lib/librte_net/rte_net_crc.h | 101 ++++++ lib/librte_net/rte_net_version.map | 8 + 6 files changed, 999 insertions(+) create mode 100644 app/test/test_crc.c create mode 100644 lib/librte_net/rte_net_crc.c create mode 100644 lib/librte_net/rte_net_crc.h
Signature · 1 line
2.5.5
PATCH 1/2 librte_net: add crc init and compute APIs
APIs for initalising and computing the crc (16-bit and 32-bit CRCs) are added. For CRCs calculation, scalar as well as x86 intrinsic(sse4.2) versions are implemented.
The scalar version is based on generic Look-Up Table(LUT) algorithm, while x86 intrinsic version uses carry-less multiplication method for fast CRC computation.
--- lib/librte_net/Makefile | 2 + lib/librte_net/rte_net_crc.c | 657 +++++++++++++++++++++++++++++++++++++ lib/librte_net/rte_net_crc.h | 101 ++++++ lib/librte_net/rte_net_version.map | 8 + 4 files changed, 768 insertions(+) create mode 100644 lib/librte_net/rte_net_crc.c create mode 100644 lib/librte_net/rte_net_crc.h
lib/librte_net/Makefile +2 -0
@@ -39,11 +39,13 @@ EXPORT_MAP := rte_net_version.map LIBABIVER := 1 SRCS-$(CONFIG_RTE_LIBRTE_NET) := rte_net.c +SRCS-$(CONFIG_RTE_LIBRTE_NET) += rte_net_crc.c # install includes SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include := rte_ip.h rte_tcp.h rte_udp.h SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_sctp.h rte_icmp.h rte_arp.h SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_ether.h rte_gre.h rte_net.h +SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_net_crc.h DEPDIRS-$(CONFIG_RTE_LIBRTE_NET) += lib/librte_eal lib/librte_mbuf
lib/librte_net/rte_net_crc.c new file +657 -0
657 lines not on this page · raw message
lib/librte_net/rte_net_crc.h new file +101 -0
101 lines not on this page · raw message
lib/librte_net/rte_net_version.map +8 -0
@@ -4,3 +4,11 @@ DPDK_16.11 { local: *; }; + +DPDK_17.05 { + global: + + rte_net_crc_init; + rte_net_crc_calc; + +} DPDK_16.11;
Signature · 1 line
2.5.5
v2 cover librte_net: add crc computation support
In some applications, CRC (Cyclic Redundancy Check) needs to be computed or updated during packet processing operations. This patchset adds software implementation of some common standard CRCs (32-bit Ethernet CRC as per Ethernet/[ISO/IEC 8802-3] and 16-bit CCITT-CRC [ITU-T X.25]). Two versions of each 32-bit and 16-bit CRC calculation are proposed.
The first version presents a fast and efficient CRC generation on IA processors by using the carry-less multiplication instruction – PCLMULQDQ (i.e SSE4.2 instrinsics). In this implementation, a parallelized folding approach has been used to first reduce an arbitrary length buffer to a small fixed size length buffer (16 bytes) with the help of precomputed constants. The resultant single 16-bytes chunk is further reduced by Barrett reduction method to generate final CRC value. For more details on the implementation, see reference [1].
The second version presents the fallback solution to support the CRC generation without needing any specific support from CPU (for examples- SSE4.2 intrinsics). It is based on generic Look-Up Table(LUT) algorithm that uses precomputed 256 element table as explained in reference[2].
Following APIs have been added;
(i) rte_net_crc_init()
(ii)rte_net_crc_calc()
The first API (i) initalises the data structures required for CRC computation and this api should be used only once in the application before using second API (ii) for 16-bit and 32-bit CRC calculations.
References:
[1] Fast CRC Computation for Generic Polynomials Using PCLMULQDQ Instruction
http://www.intel.com/content/dam/www/public/us/en/documents/white-papers/fast-crc-computation-generic-polynomials-pclmulqdq-paper.pdf
[2] A PAINLESS GUIDE TO CRC ERROR DETECTION ALGORITHMS
http://www.ross.net/crc/download/crc_v3.txt
v2 changes:
- fix build errors for target i686-native-linuxapp-gcc
- fix checkpatch warnings
Notes:
- Build not successful with clang version earlier than 3.7.0 due to missing intrinsics. Refer dpdk known issue section for more details.
Jasvinder Singh (2):
librte_net: add crc init and compute APIs
app/test: add unit test for CRC computation
app/test/Makefile | 2 + app/test/test_crc.c | 229 +++++++++++++ lib/librte_net/Makefile | 2 + lib/librte_net/rte_net_crc.c | 664 +++++++++++++++++++++++++++++++++++++ lib/librte_net/rte_net_crc.h | 101 ++++++ lib/librte_net/rte_net_version.map | 8 + 6 files changed, 1006 insertions(+) create mode 100644 app/test/test_crc.c create mode 100644 lib/librte_net/rte_net_crc.c create mode 100644 lib/librte_net/rte_net_crc.h
Signature · 1 line
2.5.5
PATCH v2 1/2 librte_net: add crc init and compute APIs
APIs for initialising and computing the crc (16-bit and 32-bit CRCs) are added. For CRCs calculation, scalar as well as x86 intrinsic(sse4.2) versions are implemented.
The scalar version is based on generic Look-Up Table(LUT) algorithm, while x86 intrinsic version uses carry-less multiplication for fast CRC computation.
--- lib/librte_net/Makefile | 2 + lib/librte_net/rte_net_crc.c | 664 +++++++++++++++++++++++++++++++++++++ lib/librte_net/rte_net_crc.h | 101 ++++++ lib/librte_net/rte_net_version.map | 8 + 4 files changed, 775 insertions(+) create mode 100644 lib/librte_net/rte_net_crc.c create mode 100644 lib/librte_net/rte_net_crc.h
lib/librte_net/Makefile +2 -0
@@ -39,11 +39,13 @@ EXPORT_MAP := rte_net_version.map LIBABIVER := 1 SRCS-$(CONFIG_RTE_LIBRTE_NET) := rte_net.c +SRCS-$(CONFIG_RTE_LIBRTE_NET) += rte_net_crc.c # install includes SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include := rte_ip.h rte_tcp.h rte_udp.h SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_sctp.h rte_icmp.h rte_arp.h SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_ether.h rte_gre.h rte_net.h +SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_net_crc.h DEPDIRS-$(CONFIG_RTE_LIBRTE_NET) += lib/librte_eal lib/librte_mbuf
lib/librte_net/rte_net_crc.c new file +664 -0
664 lines not on this page · raw message
lib/librte_net/rte_net_crc.h new file +101 -0
101 lines not on this page · raw message
lib/librte_net/rte_net_version.map +8 -0
@@ -4,3 +4,11 @@ DPDK_16.11 { local: *; }; + +DPDK_17.05 { + global: + + rte_net_crc_init; + rte_net_crc_calc; + +} DPDK_16.11;
Signature · 1 line
2.5.5
Re: [PATCH v2 1/2] librte_net: add crc init and compute APIs
Quoted 97 lines · Jasvinder Singh
APIs for initialising and computing the crc (16-bit and 32-bit CRCs) are added. For CRCs calculation, scalar as well as x86 intrinsic(sse4.2) versions are implemented.
The scalar version is based on generic Look-Up Table(LUT) algorithm, while x86 intrinsic version uses carry-less multiplication for fast CRC computation.
Signed-off-by Jasvinder Singh <[email protected]>--- lib/librte_net/Makefile | 2 + lib/librte_net/rte_net_crc.c | 664 +++++++++++++++++++++++++++++++++++++ lib/librte_net/rte_net_crc.h | 101 ++++++ lib/librte_net/rte_net_version.map | 8 + 4 files changed, 775 insertions(+) create mode 100644 lib/librte_net/rte_net_crc.c create mode 100644 lib/librte_net/rte_net_crc.hlib/librte_net/Makefile +2
-0@@ -39,11 +39,13 @@ EXPORT_MAP := rte_net_version.map LIBABIVER := 1 SRCS-$(CONFIG_RTE_LIBRTE_NET) := rte_net.c +SRCS-$(CONFIG_RTE_LIBRTE_NET) += rte_net_crc.c # install includes SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include := rte_ip.h rte_tcp.h rte_udp.h SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_sctp.h rte_icmp.h rte_arp.h SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_ether.h rte_gre.h rte_net.h +SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_net_crc.h DEPDIRS-$(CONFIG_RTE_LIBRTE_NET) += lib/librte_eal lib/librte_mbuflib/librte_net/rte_net_crc.c new file +55
-0@@ -0,0 +1,664 @@ +/*- +* BSD LICENSE +* +* Copyright(c) 2017 Intel Corporation. +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include <rte_net_crc.h> +#include <stddef.h> + +/* Macros for printing using RTE_LOG */ +#define RTE_LOGTYPE_CRC RTE_LOGTYPE_USER1 + +/** CRC polynomials */ +#define CRC32_ETH_POLYNOMIAL 0x04c11db7UL +#define CRC16_CCITT_POLYNOMIAL 0x1021U + +typedef int (*rte_net_crc_handler )(struct rte_net_crc_params *); + +static int rte_crc16_ccitt_handler (struct rte_net_crc_params *p); +static int rte_crc32_eth_handler (struct rte_net_crc_params *p); +static int rte_crc_invalid_handler (struct rte_net_crc_params *p); + +static rte_net_crc_handler *handlers; + +static rte_net_crc_handler handlers_scalar[] = { + [RTE_NET_CRC16_CCITT ] = rte_crc16_ccitt_handler, + [RTE_NET_CRC32_ETH ] = rte_crc32_eth_handler, + [RTE_NET_CRC_REQS ] = rte_crc_invalid_handler,
lib/librte_net/rte_net_crc.c line 65
Quoted 10 lines
lib/librte_net/rte_net_crc.c new file +10
-0+}; + +int +rte_crc_invalid_handler(__rte_unused struct rte_net_crc_params *p) +{ +RTE_LOG (ERR ,CRC ,"CRC type not supported!\n" ); +return -1 ;/* Error */ +} + +#if definedRTE_ARCH_X86_64 && definedRTE_MACHINE_CPUFLAG_SSE4_2
Could you please abstract the vector function and move the SSE implementation to separate file for future clean neon and altivec integration.
Reference: lib/librte_lpm/rte_lpm_sse.h
Re: [PATCH v2 1/2] librte_net: add crc init and compute APIs
In reply to Jasvinder Singh2017-02-28 12:08, Jasvinder Singh:
Quoted 2 lines
lib/librte_net/rte_net_crc.c | 664 +++++++++++++++++++++++++++++++++++++ lib/librte_net/rte_net_crc.h | 101 ++++++
I think it should be in librte_hash.
Please check lib/librte_hash/rte_hash_crc.h
Re: [PATCH v2 1/2] librte_net: add crc init and compute APIs
Hi Thomas,
Quoted 8 lines
-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Wednesday, March 1, 2017 6:46 PM
To: Singh, Jasvinder <[email protected]>
Cc: [email protected]; Doherty, Declan <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2 1/2]librte_net: add crc init and compute APIs
Quoted 8 lines
2017-02-28 12:08, Jasvinder Singh:
Quoted 1 line
lib/librte_net/rte_net_crc.c | 664+++++++++++++++++++++++++++++++++++++
Quoted 1 line
lib/librte_net/rte_net_crc.h | 101 ++++++I think it should be in
librte_hash.Please check
lib/librte_hash/rte_hash_crc.h
Is it good to include payload crc calculation in hash library as I see all hash related functionality there?
Re: [PATCH v2 1/2] librte_net: add crc init and compute APIs
2017-03-02 13:03, Singh, Jasvinder:
Quoted 12 lines
Hi Thomas,
Quoted 10 lines
-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Wednesday, March 1, 2017 6:46 PM
To: Singh, Jasvinder <[email protected]>
Cc: [email protected]; Doherty, Declan <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2 1/2]librte_net: add crc init and compute APIs2017-02-28 12:08, Jasvinder Singh:
Quoted 1 line
lib/librte_net/rte_net_crc.c | 664
Quoted 8 lines
Quoted 6 lines
+++++++++++++++++++++++++++++++++++++
Quoted 1 line
lib/librte_net/rte_net_crc.h | 101 ++++++I think it should be in
librte_hash.Please check
lib/librte_hash/rte_hash_crc.hIs it good to include payload crc calculation in hash library as I see all hash related functionality there?
I think yes. Pablo?
Re: [PATCH v2 1/2] librte_net: add crc init and compute APIs
Quoted 27 lines
-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Monday, March 06, 2017 3:28 PM
To: Singh, Jasvinder
Cc: [email protected]; Doherty, Declan; De Lara Guarch, Pablo
Subject: Re: [dpdk-dev] [PATCH v2 1/2]librte_net: add crc init and compute APIs2017-03-02 13:03, Singh, Jasvinder:
Quoted 8 lines
Hi Thomas,
Quoted 6 lines
-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Wednesday, March 1, 2017 6:46 PM
To: Singh, Jasvinder <[email protected]>
Cc: [email protected]; Doherty, Declan <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2 1/2]librte_net: add crc init andcompute
Quoted 7 lines
Quoted 7 lines
APIs
2017-02-28 12:08, Jasvinder Singh:
Quoted 1 line
lib/librte_net/rte_net_crc.c | 664+++++++++++++++++++++++++++++++++++++
Quoted 1 line
lib/librte_net/rte_net_crc.h | 101 ++++++
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
I think it should be in
librte_hash.Please check
lib/librte_hash/rte_hash_crc.hIs it good to include payload crc calculation in hash library as I see all hash
related functionality there?
I think yes. Pablo?
I think this doesn't belong in the hash library. These new functions calculate CRC, but not as a hash function. Yes, CRC can be used as hash function (in fact, it is used as such in the hash library,
the CRC32C version, and I assume that's why it is in there), but its use is much broader
(its main purpose is not to be a hash function, but for data error detection, for any data).
Therefore, I would suggest either creating a separate library for this, if we want to use this as a broader use, or leave it in net library, if we want to focus on calculating CRC for Ethernet frames.
Regarding to the CRC that we have in the hash library, if we go for a separate library,
we could move that function there, but then it would have to follow the function prototype of a hash function, defined in the hash library.
Thanks,
Pablo
Re: [PATCH v2 1/2] librte_net: add crc init and compute APIs
2017-03-08 11:08, De Lara Guarch, Pablo:
Quoted 9 lines
From: Thomas Monjalon [mailto:[email protected]]
Quoted 8 lines
2017-03-02 13:03, Singh, Jasvinder:
Quoted 7 lines
From: Thomas Monjalon [mailto:[email protected]]
Quoted 6 lines
2017-02-28 12:08, Jasvinder Singh:
Quoted 2 lines
lib/librte_net/rte_net_crc.c | 664 +++++++++++++++++++++++++++++++++++++ lib/librte_net/rte_net_crc.h | 101 ++++++I think it should be in
librte_hash.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Please check
lib/librte_hash/rte_hash_crc.hIs it good to include payload crc calculation in hash library as I see all hash
related functionality there?
I think yes. Pablo?
I think this doesn't belong in the hash library. These new functions calculate CRC, but not as a hash function.
Can't we say that a CRC is a hash? What is a hash?
A function generating the same output bytes from given input bytes.
I think you must separate hash functions and hash table management.
Quoted 3 lines
Yes, CRC can be used as hash function (in fact, it is used as such in the hash library, the CRC32C version, and I assume that's why it is in there), but its use is much broader (its main purpose is not to be a hash function, but for data error detection, for any data).
The librte_hash has several hash functions, including CRC32C and Toeplitz.
Quoted 2 lines
Therefore, I would suggest either creating a separate library for this, if we want to use this as a broader use, or leave it in net library, if we want to focus on calculating CRC for Ethernet frames.
I don't think Toeplitz should go in librte_net.
That's why I suggest to keep every kind of hash functions in librte_hash.
Quoted 3 lines
Regarding to the CRC that we have in the hash library, if we go for a separate library,
we could move that function there, but then it would have to follow the function prototype of a hash function, defined in the hash library.
Re: [PATCH v2 1/2] librte_net: add crc init and compute APIs
... <snip>
Quoted 10 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
I think it should be in
librte_hash.Please check
lib/librte_hash/rte_hash_crc.hIs it good to include payload crc calculation in hash library as I see all
hash
Quoted 4 lines
Quoted 3 lines
related functionality there?
I think yes. Pablo?
Quoted 8 lines
Quoted 1 line
I think this doesn't belong in the hash library. These new functions calculate
CRC, but not as a hash function.
Can't we say that a CRC is a hash? What is a hash?
A function generating the same output bytes from given input bytes.I think you must separate hash functions and hash table management.
The fact that CRC32 instruction is opportunistically used to compute a hash digest/signature for load balancing (affinity-based) or hash tables (flow tables, ARP cache, etc) does not mean that all the code that uses CRC32 instruction should be placed in librte_hash.
The purpose of the hash functions in librte_hash is to compute a digest/signature for a given array of bytes (the key) as fast as possible. Any hash function that produces a hash signature with good uniform distribution in a small amount of cycles belongs here, including those opportunistically using specialized CPU instructions such as CRC32 (or XOR, AESNI, etc).
The code proposed in this patch is used to compute packet fields for various protocols that have a CRC field, such as FCS of Ethernet frames, etc. according to the relevant standard (IEEE 802, others). It is an utility to be used for implementing protocol-level functionality for various protocols from the network stack, similar to e.g. IP or UDP checksum. If we were to add an IP or UDCP checksum calculator, would you put it in librte_hash?
The code from this patch is never going to be used to compute a fast signature/digest. Typically this CRC is computed over the entire frame/packet rather than just selected fields from the packet representing the application-specific flow key. Also note that the signature produced by CRC32 hash function from librte_hash is actually not the correct Cyclic Redundancy Check of that array of bytes (or, for math guys, of the associated polynomial), it is just a partial/intermediate value.
Therefore, I suggest placing this code into: librte_ether (given that it can be used to compute Ethernet FCS), or librte_net, or librte_crc. Definitely not in librte_hash.
Regards,
Cristian
Re: [PATCH v2 1/2] librte_net: add crc init and compute APIs
2017-03-15 19:03, Dumitrescu, Cristian:
Quoted 23 lines
... <snip>
Quoted 10 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
I think it should be in
librte_hash.Please check
lib/librte_hash/rte_hash_crc.hIs it good to include payload crc calculation in hash library as I see all
hash
Quoted 4 lines
Quoted 3 lines
related functionality there?
I think yes. Pablo?
Quoted 8 lines
Quoted 1 line
I think this doesn't belong in the hash library. These new functions calculate
CRC, but not as a hash function.
Can't we say that a CRC is a hash? What is a hash?
A function generating the same output bytes from given input bytes.I think you must separate hash functions and hash table management.
The fact that CRC32 instruction is opportunistically used to compute a hash digest/signature for load balancing (affinity-based) or hash tables (flow tables, ARP cache, etc) does not mean that all the code that uses CRC32 instruction should be placed in
librte_hash.
Quoted 7 lines
The purpose of the hash functions in
librte_hashis to compute a digest/signature for a given array of bytes (the key) as fast as possible. Any hash function that produces a hash signature with good uniform distribution in a small amount of cycles belongs here, including those opportunistically using specialized CPU instructions such as CRC32 (or XOR, AESNI, etc).The code proposed in this patch is used to compute packet fields for various protocols that have a CRC field, such as FCS of Ethernet frames, etc. according to the relevant standard (IEEE 802, others). It is an utility to be used for implementing protocol-level functionality for various protocols from the network stack, similar to e.g. IP or UDP checksum. If we were to add an IP or UDCP checksum calculator, would you put it in
librte_hash?The code from this patch is never going to be used to compute a fast signature/digest. Typically this CRC is computed over the entire frame/packet rather than just selected fields from the packet representing the application-specific flow key. Also note that the signature produced by CRC32 hash function from
librte_hashis actually not the correct Cyclic Redundancy Check of that array of bytes (or, for math guys, of the associated polynomial), it is just a partial/intermediate value.Therefore, I suggest placing this code into:
librte_ether(given that it can be used to compute Ethernet FCS), orlibrte_net, orlibrte_crc. Definitely not inlibrte_hash.
I agree with you Cristian that the protocol layer must be in librte_net. But I think most of this patch is not protocol level.
I think you agree with me that the code computing a "digest/signature for a given array of bytes" must go to librte_hash?
Re: [PATCH v2 1/2] librte_net: add crc init and compute APIs
Quoted 61 lines
-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Wednesday, March 15, 2017 8:16 PM
To: Dumitrescu, Cristian <[email protected]>
Cc: De Lara Guarch, Pablo <[email protected]>; Singh, Jasvinder <[email protected]>; [email protected]; Doherty, Declan <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2 1/2]librte_net: add crc init and compute APIs2017-03-15 19:03, Dumitrescu, Cristian:
Quoted 13 lines
... <snip>
Quoted 11 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
I think it should be in
librte_hash.Please check
lib/librte_hash/rte_hash_crc.hIs it good to include payload crc calculation in hash library as I see all
hash
Quoted 5 lines
Quoted 3 lines
related functionality there?
I think yes. Pablo?
I think this doesn't belong in the hash library. These new functions
calculate
Quoted 9 lines
Quoted 7 lines
CRC, but not as a hash function.
Can't we say that a CRC is a hash? What is a hash?
A function generating the same output bytes from given input bytes.I think you must separate hash functions and hash table management.
The fact that CRC32 instruction is opportunistically used to compute a hash
digest/signature for load balancing (affinity-based) or hash tables (flow tables, ARP cache, etc) does not mean that all the code that uses CRC32 instruction should be placed in
librte_hash.Quoted 2 lines
The purpose of the hash functions in
librte_hashis to compute adigest/signature for a given array of bytes (the key) as fast as possible. Any hash function that produces a hash signature with good uniform distribution in a small amount of cycles belongs here, including those opportunistically using specialized CPU instructions such as CRC32 (or XOR, AESNI, etc).
Quoted 2 lines
The code proposed in this patch is used to compute packet fields for
various protocols that have a CRC field, such as FCS of Ethernet frames, etc. according to the relevant standard (IEEE 802, others). It is an utility to be used for implementing protocol-level functionality for various protocols from the network stack, similar to e.g. IP or UDP checksum. If we were to add an IP or UDCP checksum calculator, would you put it in
librte_hash?Quoted 2 lines
The code from this patch is never going to be used to compute a fast
signature/digest. Typically this CRC is computed over the entire frame/packet rather than just selected fields from the packet representing the application- specific flow key. Also note that the signature produced by CRC32 hash function from
librte_hashis actually not the correct Cyclic Redundancy Check of that array of bytes (or, for math guys, of the associated polynomial), it is just a partial/intermediate value.Quoted 1 line
Quoted 6 lines
Quoted 1 line
Therefore, I suggest placing this code into:
librte_ether(given that it can beused to compute Ethernet FCS), or
librte_net, orlibrte_crc. Definitely not inlibrte_hash.I agree with you Cristian that the protocol layer must be in
librte_net. But I think most of this patch is not protocol level.
Nope, this is the true CRC computed over entire protocol header and/or payload. Similar to to IPv4/UDP/TCP checksum. The only reason for computing it is because the protocol specs require it for data integrity checks, nothing to do with our signature for load balancing/hash tables.
More details on covered protocols from a reliable source :) [1]:
CRC-32 (polynomial = 0x04C11DB7): used for HDLC, ANSI X3.66, ITU-T V.42, Ethernet, Serial ATA, MPEG-2, PKZIP, Gzip, Bzip2, PNG, many others CRC-16-CCITT (polynomial = 0x1021): used for X.25, V.41, HDLC FCS, XMODEM, Bluetooth, PACTOR, SD, DigRF, many others
[1] Wikipedia: https://en.wikipedia.org/wiki/Cyclic_redundancy_check#Standards_and_common_use
Quoted 2 lines
I think you agree with me that the code computing a "digest/signature for a given array of bytes" must go to
librte_hash?
Yes, but this is the true protocol-level CRC, not a digest/signature.
Non-cryptographic hash digest/signature:
-computed over selected packet fields (flow key) for load balancing (affinity scheme) or hash table; key size typical range: 8 .. 192 bytes
-required by application requirements (such as flow packet ordering preservation), not by protocol standards
-has uniform distribution
-requires small amount of cycles to compute
-used as meta-data, not written in the packet
-can be opportunistically generated using specialized CPU instructions, such as CRC32 (or XEOR, or AESNI); in this case, it is a partial/intermediate value, not the correct CRC of the array of bytes
Protocol CRC:
-computed over entire packet header and/or payload
-protocol overhead (required by standards)
-computational cost is typically big and proportional with the packet length; packet length typical range: 64 .. 1514 .. 9K -written in the packet (by the application SW or by the HW)
Re: [PATCH v2 1/2] librte_net: add crc init and compute APIs
In reply to Thomas MonjalonQuoted 60 lines
-----Original Message-----
From: Dumitrescu, Cristian
Sent: Wednesday, March 15, 2017 7:04 PM
To: 'Thomas Monjalon' <[email protected]>; De Lara Guarch, Pablo <[email protected]>
Cc: Singh, Jasvinder <[email protected]>; [email protected]; Doherty, Declan <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2 1/2]librte_net: add crc init and compute APIs... <snip>
Quoted 11 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
I think it should be in
librte_hash.Please check
lib/librte_hash/rte_hash_crc.hIs it good to include payload crc calculation in hash library as I see all
hash
Quoted 5 lines
Quoted 3 lines
related functionality there?
I think yes. Pablo?
I think this doesn't belong in the hash library. These new functions
calculate
Quoted 7 lines
CRC, but not as a hash function.
Can't we say that a CRC is a hash? What is a hash?
A function generating the same output bytes from given input bytes.I think you must separate hash functions and hash table management.
The fact that CRC32 instruction is opportunistically used to compute a hash digest/signature for load balancing (affinity-based) or hash tables (flow tables, ARP cache, etc) does not mean that all the code that uses CRC32 instruction should be placed in
librte_hash.The purpose of the hash functions in
librte_hashis to compute a digest/signature for a given array of bytes (the key) as fast as possible. Any hash function that produces a hash signature with good uniform distribution in a small amount of cycles belongs here, including those opportunistically using specialized CPU instructions such as CRC32 (or XOR, AESNI, etc).The code proposed in this patch is used to compute packet fields for various protocols that have a CRC field, such as FCS of Ethernet frames, etc. according to the relevant standard (IEEE 802, others). It is an utility to be used for implementing protocol-level functionality for various protocols from the network stack, similar to e.g. IP or UDP checksum. If we were to add an IP or UDCP checksum calculator, would you put it in
librte_hash?The code from this patch is never going to be used to compute a fast signature/digest. Typically this CRC is computed over the entire frame/packet rather than just selected fields from the packet representing the application- specific flow key. Also note that the signature produced by CRC32 hash function from
librte_hashis actually not the correct Cyclic Redundancy Check of that array of bytes (or, for math guys, of the associated polynomial), it is just a partial/intermediate value.
Quoted 4 lines
Therefore, I suggest placing this code into:
librte_ether(given that it can be used to compute Ethernet FCS), orlibrte_net, orlibrte_crc. Definitely not inlibrte_hash.
Sorry, my bad on librte_ether: the rte_ether.h where Ethernet frame is defined is located in librte_net, not librte_ether, so librte_ether should not be on the above list. Therefore, my suggestion is: librte_net or a new library librte_crc.
Quoted 2 lines
Regards,
Cristian
v3 cover librte_net: add crc computation support
In reply to Jasvinder SinghIn some applications, CRC (Cyclic Redundancy Check) needs to be computed or updated during packet processing operations. This patchset adds software implementation of some common standard CRCs (32-bit Ethernet CRC as per Ethernet/[ISO/IEC 8802-3] and 16-bit CCITT-CRC [ITU-T X.25]). Two versions of each 32-bit and 16-bit CRC calculation are proposed.
The first version presents a fast and efficient CRC generation on IA processors by using the carry-less multiplication instruction � PCLMULQDQ (i.e SSE4.2 instrinsics). In this implementation, a parallelized folding approach has been used to first reduce an arbitrary length buffer to a small fixed size length buffer (16 bytes) with the help of precomputed constants. The resultant single 16-bytes chunk is further reduced by Barrett reduction method to generate final CRC value. For more details on the implementation, see reference [1].
The second version presents the fallback solution to support the CRC generation without needing any specific support from CPU (for examples- SSE4.2 intrinsics). It is based on generic Look-Up Table(LUT) algorithm that uses precomputed 256 element table as explained in reference[2].
During intialisation, all the data structures required for CRC computation are initialised. Also, x86 specific crc implementation (if supported by the platform) or scalar version is enabled.
Following APIs have been added;
(i) rte_net_crc_set_alg()
(ii)rte_net_crc_calc()
The first API (i) allows user to select the specific CRC implementation in run-time while the second API (ii) is used for computing the 16-bit and 32-bit CRC.
References:
[1] Fast CRC Computation for Generic Polynomials Using PCLMULQDQ Instruction
http://www.intel.com/content/dam/www/public/us/en/documents/white-papers/fast-crc-computation-generic-polynomials-pclmulqdq-paper.pdf
[2] A PAINLESS GUIDE TO CRC ERROR DETECTION ALGORITHMS
http://www.ross.net/crc/download/crc_v3.txt
v3 changes:
- separate the x86 specific implementation into new file
- improve the unit test
v2 changes:
- fix build errors for target i686-native-linuxapp-gcc
- fix checkpatch warnings
Notes:
- Build not successful with clang version earlier than 3.7.0 due to missing intrinsics. Refer dpdk known issue section for more details.
Jasvinder Singh (2):
librte_net: add crc compute APIs
app/test: add unit test for CRC computation
app/test/Makefile | 2 + app/test/test_crc.c | 265 ++++++++++++++++++++++++++++ lib/librte_net/Makefile | 3 + lib/librte_net/rte_net_crc.c | 205 ++++++++++++++++++++++ lib/librte_net/rte_net_crc.h | 104 +++++++++++ lib/librte_net/rte_net_crc_sse.h | 351 +++++++++++++++++++++++++++++++++++++ lib/librte_net/rte_net_version.map | 8 + 7 files changed, 938 insertions(+) create mode 100644 app/test/test_crc.c create mode 100644 lib/librte_net/rte_net_crc.c create mode 100644 lib/librte_net/rte_net_crc.h create mode 100644 lib/librte_net/rte_net_crc_sse.h
Signature · 1 line
2.5.5
PATCH v3 1/2 librte_net: add crc compute APIs
APIs for selecting the architecure specific implementation and computing the crc (16-bit and 32-bit CRCs) are added. For CRCs calculation, scalar as well as x86 intrinsic(sse4.2) versions are implemented.
The scalar version is based on generic Look-Up Table(LUT) algorithm, while x86 intrinsic version uses carry-less multiplication for fast CRC computation.
--- lib/librte_net/Makefile | 3 + lib/librte_net/rte_net_crc.c | 205 ++++++++++++++++++++++ lib/librte_net/rte_net_crc.h | 104 +++++++++++ lib/librte_net/rte_net_crc_sse.h | 351 +++++++++++++++++++++++++++++++++++++ lib/librte_net/rte_net_version.map | 8 + 5 files changed, 671 insertions(+) create mode 100644 lib/librte_net/rte_net_crc.c create mode 100644 lib/librte_net/rte_net_crc.h create mode 100644 lib/librte_net/rte_net_crc_sse.h
lib/librte_net/Makefile +3 -0
@@ -39,11 +39,14 @@ EXPORT_MAP := rte_net_version.map LIBABIVER := 1 SRCS-$(CONFIG_RTE_LIBRTE_NET) := rte_net.c +SRCS-$(CONFIG_RTE_LIBRTE_NET) += rte_net_crc.c # install includes SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include := rte_ip.h rte_tcp.h rte_udp.h SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_sctp.h rte_icmp.h rte_arp.h SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_ether.h rte_gre.h rte_net.h +SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_net_crc.h +SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_net_crc_sse.h DEPDIRS-$(CONFIG_RTE_LIBRTE_NET) += lib/librte_eal lib/librte_mbuf
lib/librte_net/rte_net_crc.c new file +205 -0
205 lines not on this page · raw message
lib/librte_net/rte_net_crc.h new file +104 -0
104 lines not on this page · raw message
lib/librte_net/rte_net_crc_sse.h new file +351 -0
351 lines not on this page · raw message
lib/librte_net/rte_net_version.map +8 -0
@@ -4,3 +4,11 @@ DPDK_16.11 { local: *; }; + +DPDK_17.05 { + global: + + rte_net_crc_set_alg; + rte_net_crc_calc; + +} DPDK_16.11;
Signature · 1 line
2.5.5
Re: [PATCH v3 1/2] librte_net: add crc compute APIs
Hi Jasvinder,
Quoted 32 lines
APIs for selecting the architecure specific implementation and computing the crc (16-bit and 32-bit CRCs) are added. For CRCs calculation, scalar as well as x86 intrinsic(sse4.2) versions are implemented.
The scalar version is based on generic Look-Up Table(LUT) algorithm, while x86 intrinsic version uses carry-less multiplication for fast CRC computation.
Signed-off-by Jasvinder Singh <[email protected]>--- lib/librte_net/Makefile | 3 + lib/librte_net/rte_net_crc.c | 205 ++++++++++++++++++++++ lib/librte_net/rte_net_crc.h | 104 +++++++++++ lib/librte_net/rte_net_crc_sse.h | 351 +++++++++++++++++++++++++++++++++++++ lib/librte_net/rte_net_version.map | 8 + 5 files changed, 671 insertions(+) create mode 100644 lib/librte_net/rte_net_crc.c create mode 100644 lib/librte_net/rte_net_crc.h create mode 100644 lib/librte_net/rte_net_crc_sse.hlib/librte_net/rte_net_crc.h new file +11
-0+ +/** +* CRC compute API +* +* @param mbuf +* Pointer to the packet mbuf for crc computation +* @param data_offset +* Offset to the data in the mbuf +* @param data_len +* length of the data to compute the crc on +* @param type
lib/librte_net/rte_net_crc.h line 93
Quoted 10 lines
lib/librte_net/rte_net_crc.h new file +10
-0+* crc type +* +* @return +* computed crc value +*/ +uint32_t +rte_net_crc_calc (struct rte_mbuf *mbuf, +uint32_t data_offset, +uint32_t data_len, +enum rte_net_crc_type type);
I think it will probably be convenient to have this API not dependent on mbuf, something like:
uint32_t rte_net_crc_calc(const void *buf, uint32_t data_len, enum rte_net_crc_type type);
And if we like to have an extra function that would do similar thing for mbuf, that's fine too, but I suppose such function would have to handle multi-segment case too. Konstantin
Re: [PATCH v3 1/2] librte_net: add crc compute APIs
Hi Konstantin,
Quoted 58 lines
-----Original Message-----
From: Ananyev, Konstantin
Sent: Monday, March 13, 2017 3:06 AM
To: Singh, Jasvinder <[email protected]>; [email protected]
Cc: Doherty, Declan <[email protected]>; De Lara Guarch, Pablo <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v3 1/2]librte_net: add crc compute APIsHi Jasvinder,
Quoted 9 lines
APIs for selecting the architecure specific implementation and computing the crc (16-bit and 32-bit CRCs) are added. For CRCs calculation, scalar as well as x86 intrinsic(sse4.2) versions are implemented.
The scalar version is based on generic Look-Up Table(LUT) algorithm, while x86 intrinsic version uses carry-less multiplication for fast CRC computation.
Quoted 6 lines
Signed-off-by Jasvinder Singh <[email protected]>--- lib/librte_net/Makefile | 3 + lib/librte_net/rte_net_crc.c | 205 ++++++++++++++++++++++ lib/librte_net/rte_net_crc.h | 104 +++++++++++ lib/librte_net/rte_net_crc_sse.h | 351+++++++++++++++++++++++++++++++++++++
Quoted 17 lines
lib/librte_net/rte_net_version.map | 8 + 5 files changed, 671 insertions(+) create mode 100644 lib/librte_net/rte_net_crc.c create mode 100644
lib/librte_net/rte_net_crc.hcreate mode 100644lib/librte_net/rte_net_crc_sse.hlib/librte_net/rte_net_crc.h new file +11
-0+ +/** +* CRC compute API +* +* @param mbuf +* Pointer to the packet mbuf for crc computation +* @param data_offset +* Offset to the data in the mbuf +* @param data_len +* length of the data to compute the crc on +* @param type lib/librte_net/rte_net_crc.h line 93
Quoted 10 lines
lib/librte_net/rte_net_crc.h new file +10
-0+* crc type +* +* @return +* computed crc value +*/ +uint32_t +rte_net_crc_calc (struct rte_mbuf *mbuf, +uint32_t data_offset, +uint32_t data_len, +enum rte_net_crc_type type);I think it will probably be convenient to have this API not dependent on mbuf, something like:
Quoted 7 lines
uint32_trte_net_crc_calc(const void *buf, uint32_t data_len, enum rte_net_crc_type type);And if we like to have an extra function that would do similar thing for mbuf, that's fine too, but I suppose such function would have to handle multi- segment case too.
Konstantin
I will change the api as you suggested. Thanks.
v4 cover librte_net: add crc computation support
In reply to Jasvinder SinghIn some applications, CRC (Cyclic Redundancy Check) needs to be computed or updated during packet processing operations. This patchset adds software implementation of some common standard CRCs (32-bit Ethernet CRC as per Ethernet/[ISO/IEC 8802-3] and 16-bit CCITT-CRC [ITU-T X.25]). Two versions of each 32-bit and 16-bit CRC calculation are proposed.
The first version presents a fast and efficient CRC generation on IA processors by using the carry-less multiplication instruction – PCLMULQDQ (i.e SSE4.2 instrinsics). In this implementation, a parallelized folding approach has been used to first reduce an arbitrary length buffer to a small fixed size length buffer (16 bytes) with the help of precomputed constants. The resultant single 16-bytes chunk is further reduced by Barrett reduction method to generate final CRC value. For more details on the implementation, see reference [1].
The second version presents the fallback solution to support the CRC generation without needing any specific support from CPU (for examples- SSE4.2 intrinsics). It is based on generic Look-Up Table(LUT) algorithm that uses precomputed 256 element table as explained in reference[2].
During intialisation, all the data structures required for CRC computation are initialised. Also, x86 specific crc implementation (if supported by the platform) or scalar version is enabled.
Following APIs have been added;
(i) rte_net_crc_set_alg()
(ii)rte_net_crc_calc()
The first API (i) allows user to select the specific CRC implementation in run-time while the second API (ii) is used for computing the 16-bit and 32-bit CRC.
References:
[1] Fast CRC Computation for Generic Polynomials Using PCLMULQDQ Instruction
http://www.intel.com/content/dam/www/public/us/en/documents/white-papers/fast-crc-computation-generic-polynomials-pclmulqdq-paper.pdf
[2] A PAINLESS GUIDE TO CRC ERROR DETECTION ALGORITHMS
http://www.ross.net/crc/download/crc_v3.txt
v4 changes:
- change crc compute api parameters to make it more generic
- change the unit test to accomodate the crc compute api change
v3 changes:
- separate the x86 specific implementation into new file
- improve the unit test
v2 changes:
- fix build errors for target i686-native-linuxapp-gcc
- fix checkpatch warnings
Notes:
- Build not successful with clang version earlier than 3.7.0 due to missing intrinsics. Refer dpdk known issue section for more details.
Jasvinder Singh (2):
librte_net: add crc compute APIs
app/test: add unit test for CRC computation
app/test/Makefile | 2 + app/test/test_crc.c | 223 ++++++++++++++++++++++++ lib/librte_net/Makefile | 3 + lib/librte_net/rte_net_crc.c | 196 +++++++++++++++++++++ lib/librte_net/rte_net_crc.h | 101 +++++++++++ lib/librte_net/rte_net_crc_sse.h | 345 +++++++++++++++++++++++++++++++++++++ lib/librte_net/rte_net_version.map | 8 + 7 files changed, 878 insertions(+) create mode 100644 app/test/test_crc.c create mode 100644 lib/librte_net/rte_net_crc.c create mode 100644 lib/librte_net/rte_net_crc.h create mode 100644 lib/librte_net/rte_net_crc_sse.h
Signature · 1 line
2.5.5
PATCH v4 1/2 librte_net: add crc compute APIs
APIs for selecting the architecure specific implementation and computing the crc (16-bit and 32-bit CRCs) are added. For CRCs calculation, scalar as well as x86 intrinsic(sse4.2) versions are implemented.
The scalar version is based on generic Look-Up Table(LUT) algorithm, while x86 intrinsic version uses carry-less multiplication for fast CRC computation.
--- lib/librte_net/Makefile | 3 + lib/librte_net/rte_net_crc.c | 196 +++++++++++++++++++++ lib/librte_net/rte_net_crc.h | 101 +++++++++++ lib/librte_net/rte_net_crc_sse.h | 345 +++++++++++++++++++++++++++++++++++++ lib/librte_net/rte_net_version.map | 8 + 5 files changed, 653 insertions(+) create mode 100644 lib/librte_net/rte_net_crc.c create mode 100644 lib/librte_net/rte_net_crc.h create mode 100644 lib/librte_net/rte_net_crc_sse.h
lib/librte_net/Makefile +3 -0
@@ -39,11 +39,14 @@ EXPORT_MAP := rte_net_version.map LIBABIVER := 1 SRCS-$(CONFIG_RTE_LIBRTE_NET) := rte_net.c +SRCS-$(CONFIG_RTE_LIBRTE_NET) += rte_net_crc.c # install includes SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include := rte_ip.h rte_tcp.h rte_udp.h SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_sctp.h rte_icmp.h rte_arp.h SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_ether.h rte_gre.h rte_net.h +SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_net_crc.h +SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_net_crc_sse.h DEPDIRS-$(CONFIG_RTE_LIBRTE_NET) += lib/librte_eal lib/librte_mbuf
lib/librte_net/rte_net_crc.c new file +196 -0
196 lines not on this page · raw message
lib/librte_net/rte_net_crc.h new file +101 -0
101 lines not on this page · raw message
lib/librte_net/rte_net_crc_sse.h new file +345 -0
345 lines not on this page · raw message
lib/librte_net/rte_net_version.map +8 -0
@@ -4,3 +4,11 @@ DPDK_16.11 { local: *; }; + +DPDK_17.05 { + global: + + rte_net_crc_set_alg; + rte_net_crc_calc; + +} DPDK_16.11;
Signature · 1 line
2.5.5
v5 cover librte_net: add crc computation support
In some applications, CRC (Cyclic Redundancy Check) needs to be computed or updated during packet processing operations. This patchset adds software implementation of some common standard CRCs (32-bit Ethernet CRC as per Ethernet/[ISO/IEC 8802-3] and 16-bit CCITT-CRC [ITU-T X.25]). Two versions of each 32-bit and 16-bit CRC calculation are proposed.
The first version presents a fast and efficient CRC generation on IA processors by using the carry-less multiplication instruction � PCLMULQDQ (i.e SSE4.2 instrinsics). In this implementation, a parallelized folding approach has been used to first reduce an arbitrary length buffer to a small fixed size length buffer (16 bytes) with the help of precomputed constants. The resultant single 16-bytes chunk is further reduced by Barrett reduction method to generate final CRC value. For more details on the implementation, see reference [1].
The second version presents the fallback solution to support the CRC generation without needing any specific support from CPU (for examples- SSE4.2 intrinsics). It is based on generic Look-Up Table(LUT) algorithm that uses precomputed 256 element table as explained in reference[2].
During intialisation, all the data structures required for CRC computation are initialised. Also, x86 specific crc implementation (if supported by the platform) or scalar version is enabled.
Following APIs have been added;
(i) rte_net_crc_set_alg()
(ii)rte_net_crc_calc()
The first API (i) allows user to select the specific CRC implementation in run-time while the second API (ii) is used for computing the 16-bit and 32-bit CRC.
References:
[1] Fast CRC Computation for Generic Polynomials Using PCLMULQDQ Instruction
http://www.intel.com/content/dam/www/public/us/en/documents/white-papers/fast-crc-computation-generic-polynomials-pclmulqdq-paper.pdf
[2] A PAINLESS GUIDE TO CRC ERROR DETECTION ALGORITHMS
http://www.ross.net/crc/download/crc_v3.txt
v5 changes:
- rebase to the master
v4 changes:
- change crc compute api parameters to make it more generic
- change the unit test to accomodate the crc compute api change
v3 changes:
- separate the x86 specific implementation into new file
- improve the unit test
v2 changes:
- fix build errors for target i686-native-linuxapp-gcc
- fix checkpatch warnings
Notes:
- Build not successful with clang version earlier than 3.7.0 due to missing intrinsics. Refer dpdk known issue section for more details.
Jasvinder Singh (2):
librte_net: add crc compute APIs
test/test: add unit test for CRC computation
lib/librte_net/Makefile | 3 + lib/librte_net/rte_net_crc.c | 196 +++++++++++++++++++++ lib/librte_net/rte_net_crc.h | 101 +++++++++++ lib/librte_net/rte_net_crc_sse.h | 345 +++++++++++++++++++++++++++++++++++++ lib/librte_net/rte_net_version.map | 8 + test/test/Makefile | 2 + test/test/test_crc.c | 223 ++++++++++++++++++++++++ 7 files changed, 878 insertions(+) create mode 100644 lib/librte_net/rte_net_crc.c create mode 100644 lib/librte_net/rte_net_crc.h create mode 100644 lib/librte_net/rte_net_crc_sse.h create mode 100644 test/test/test_crc.c
Signature · 1 line
2.5.5
PATCH v5 1/2 librte_net: add crc compute APIs
APIs for selecting the architecure specific implementation and computing the crc (16-bit and 32-bit CRCs) are added. For CRCs calculation, scalar as well as x86 intrinsic(sse4.2) versions are implemented.
The scalar version is based on generic Look-Up Table(LUT) algorithm, while x86 intrinsic version uses carry-less multiplication for fast CRC computation.
--- lib/librte_net/Makefile | 3 + lib/librte_net/rte_net_crc.c | 196 +++++++++++++++++++++ lib/librte_net/rte_net_crc.h | 101 +++++++++++ lib/librte_net/rte_net_crc_sse.h | 345 +++++++++++++++++++++++++++++++++++++ lib/librte_net/rte_net_version.map | 8 + 5 files changed, 653 insertions(+) create mode 100644 lib/librte_net/rte_net_crc.c create mode 100644 lib/librte_net/rte_net_crc.h create mode 100644 lib/librte_net/rte_net_crc_sse.h
lib/librte_net/Makefile +3 -0
@@ -39,11 +39,14 @@ EXPORT_MAP := rte_net_version.map LIBABIVER := 1 SRCS-$(CONFIG_RTE_LIBRTE_NET) := rte_net.c +SRCS-$(CONFIG_RTE_LIBRTE_NET) += rte_net_crc.c # install includes SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include := rte_ip.h rte_tcp.h rte_udp.h SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_sctp.h rte_icmp.h rte_arp.h SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_ether.h rte_gre.h rte_net.h +SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_net_crc.h +SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_net_crc_sse.h DEPDIRS-$(CONFIG_RTE_LIBRTE_NET) += lib/librte_eal lib/librte_mbuf
lib/librte_net/rte_net_crc.c new file +196 -0
196 lines not on this page · raw message
lib/librte_net/rte_net_crc.h new file +101 -0
101 lines not on this page · raw message
lib/librte_net/rte_net_crc_sse.h new file +345 -0
345 lines not on this page · raw message
lib/librte_net/rte_net_version.map +8 -0
@@ -4,3 +4,11 @@ DPDK_16.11 { local: *; }; + +DPDK_17.05 { + global: + + rte_net_crc_set_alg; + rte_net_crc_calc; + +} DPDK_16.11;
Signature · 1 line
2.5.5
Re: [PATCH v5 1/2] librte_net: add crc compute APIs
Hi Jasvinder,
Quoted 23 lines
-----Original Message-----
From: Singh, Jasvinder
Sent: Tuesday, March 21, 2017 2:46 PM
To: [email protected]
Cc: [email protected]; Doherty, Declan; De Lara Guarch, Pablo
Subject: [PATCH v5 1/2]librte_net: add crc compute APIsAPIs for selecting the architecure specific implementation and computing the crc (16-bit and 32-bit CRCs) are added. For CRCs calculation, scalar as well as x86 intrinsic(sse4.2) versions are implemented.
The scalar version is based on generic Look-Up Table(LUT) algorithm, while x86 intrinsic version uses carry-less multiplication for fast CRC computation.
Signed-off-by Jasvinder Singh <[email protected]>---
lib/librte_net/rte_net_crc.c new file +0
-0
...
lib/librte_net/rte_net_crc.c line 39
Quoted 7 lines
lib/librte_net/rte_net_crc.c new file +7
-0+ +#include <rte_net_crc.h> +#include <stddef.h> + +/** crc tables */ +static uint32_t crc32_eth_lut[256 ]; +static uint32_t crc16_ccitt_lut[256 ];
Use a macro for 256, that you can use in crc32_eth_init_lut.
lib/librte_net/rte_net_crc.c line 42
Quoted 3 lines
lib/librte_net/rte_net_crc.c new file +3
-0+ +static uint32_t rte_crc16_ccitt_handler (const uint8_t *data, +uint32_t data_len);
Separate "static uint32_t" in another line.
Quoted 4 lines
+/**
+ * Reflect the bits about the middle
+ *
+ * @param x value to be reflected
Should be "val".
lib/librte_net/rte_net_crc.c
Quoted 5 lines
+ *
+ * @return reflected value
+ */lib/librte_net/rte_net_crc.c new file +2
-0+static uint32_t +reflect_32bits (const uint32_t val)
No need for "const" here, as it is not a pointer.
lib/librte_net/rte_net_crc.c line 84
Quoted 12 lines
lib/librte_net/rte_net_crc.c new file +12
-0+{ +uint32_t i, res =0 ; + +for (i =0 ; i <32 ; i++) +if ((val & (1 << i)) !=0 ) + res |= (uint32_t )(1 << (31 - i)); + +return res; +} + +static void +crc32_eth_init_lut(const uint32_t poly,
No need for "const" here.
Quoted 4 lines
lib/librte_net/rte_net_crc.c new file +4
-0+ uint32_t *lut) +{ +uint_fast32_t i, j; +
lib/librte_net/rte_net_crc.c line 98
Quoted 10 lines
lib/librte_net/rte_net_crc.c new file +10
-0+for (i =0 ; i <256 ; i++) { +uint_fast32_t crc =reflect_32bits (i); + +for (j =0 ; j <8 ; j++) { +if (crc &0x80000000L ) + crc = (crc <<1 ) ^ poly; +else + crc <<=1 ; + } + lut[i] =reflect_32bits (crc);
Wrong indentation.
Quoted 23 lines
lib/librte_net/rte_net_crc.c new file +23
-0+ } +} + +static inline __attribute__((always_inline))uint32_t +crc32_eth_calc_lut (const uint8_t *data, +uint32_t data_len, +uint32_t crc, +const uint32_t *lut) +{ +while (data_len--) + crc = lut[(crc ^ *data++) &0xffL ] ^ (crc >>8 ); + +return crc; +} + +static void +rte_net_crc_scalar_init (void ) +{ +/** 32-bit crc init */ +crc32_eth_init_lut (CRC32_ETH_POLYNOMIAL , crc32_eth_lut); + +/** 16-bit CRC init */ + crc32_eth_init_lut(CRC16_CCITT_POLYNOMIAL << 16,
Quoted 2 lines
crc16_ccitt_lut);
+
Remove this blank line.
lib/librte_net/rte_net_crc.c line 131
Quoted 9 lines
lib/librte_net/rte_net_crc.c new file +9
-0+} + +static inline uint32_t +rte_crc16_ccitt_handler (const uint8_t *data,uint32_t data_len) +{ +return (uint16_t )~crc32_eth_calc_lut (data, + data_len, +0xffff , + crc16_ccitt_lut);
Since you are casting to uint16_t, when you are supposed to cast to uint32_t (given the return type), I would add a comment explaining why.
Quoted 10 lines
lib/librte_net/rte_net_crc.c new file +2
-0+} +lib/librte_net/rte_net_crc.h new file +0
-0@@ -0,0 +1,101 @@
...
lib/librte_net/rte_net_crc.h line 67
Quoted 7 lines
lib/librte_net/rte_net_crc.h new file +7
-0+ +/** +* This API set the crc computation algorithm (i.e. scalar version, +* x86 64-bit sse4.2 intrinsic version, etc.) and internal data +* structure. +* +* @param alg
Add extra information (CRC algorithm?).
Quoted 5 lines
+ * -
RTE_NET_CRC_SCALAR
+ * -RTE_NET_CRC_SSE42(Use 64-bit SSE4.2 intrinsic)
+ */lib/librte_net/rte_net_crc.h new file +2
-0+void +rte_net_crc_set_alg (enum rte_net_crc_alg alg);
lib/librte_net/rte_net_crc.h line 82
Quoted 10 lines
lib/librte_net/rte_net_crc.h new file +10
-0+ +/** +* CRC compute API +* +* @param data +* Pointer to the packet data for crc computation +* @param data_len +* Data length for crc computation +* @param type +* Crc type (enum rte_net_crc_type)
CRC
Quoted 3 lines
+ *
+ * @return
+ * crc value
Add two spaces after "@param" and "@return".
lib/librte_net/rte_net_crc.h line 92
Quoted 7 lines
+ */
lib/librte_net/rte_net_crc.h new file +6
-0+uint32_t +rte_net_crc_calc (const void *data, +uint32_t data_len, +enum rte_net_crc_type type); + +#if defined(RTE_ARCH_X86_64 ) || defined(RTE_CPU_FALGS_SSE_4_2 )
Typo in RTE_CPU_FALGS_SSE_4_2 (I missed the same one in rte_net_crc.c ). Also, should it be "&&"?
Quoted 16 lines
lib/librte_net/rte_net_crc.h new file +9
-0+#include <rte_net_crc_sse.h> +#endif + +#ifdef __cplusplus +} +#endif + + +#endif /* _RTE_NET_CRC_H_ */ lib/librte_net/rte_net_crc_sse.h new file +0
-0@@ -0,0 +1,345 @@
...
Quoted 9 lines
+ * @brief Performs one folding round
+ *
+ * Logically function operates as follows:+ * DATA = READ_NEXT_16BYTES(); + * F1 = LSB8(FOLD) + * F2 = MSB8(FOLD) + * T1 = CLMUL(F1, RK1) + * T2 = CLMUL(F2, RK2) + * FOLD = XOR(T1, T2, DATA)
Quoted 6 lines
+ *
+ * @paramdata_block16 byte data block
+ * @param precomp precomputed rk1 constanst
+ * @param fold running 16 byte folded data
+ *
+ * @return New 16 byte folded data
Move parameter/rturn description in a separate line (same for other functions).
lib/librte_net/rte_net_crc_sse.h line 73
Quoted 5 lines
+ */
lib/librte_net/rte_net_crc_sse.h new file +4
-0+static inline __attribute__((always_inline))__m128i +crcr32_folding_round (const __m128i data_block, +const __m128i precomp, +const __m128i fold)
No need to use "const" here.
Quoted 9 lines
lib/librte_net/rte_net_crc_sse.h new file +9
-0+{ +__m128i tmp0 =_mm_clmulepi64_si128 (fold, precomp,0x01 ); +__m128i tmp1 =_mm_clmulepi64_si128 (fold, precomp,0x10 ); + +return _mm_xor_si128 (tmp1,_mm_xor_si128 (data_block, tmp0)); +} + +/** +* Performs reduction from 128 bits to 64 bits
lib/librte_net/rte_net_crc_sse.h line 92
Quoted 10 lines
lib/librte_net/rte_net_crc_sse.h new file +10
-0+* +* @param data128 128 bits data to be reduced +* @param precomp rk5 and rk6 precomputed constants +* +* @return data reduced to 64 bits +*/ + +static inline __attribute__((always_inline))__m128i +crcr32_reduce_128_to_64 (__m128i data128, +const __m128i precomp)
No need to use "const" here.
...
Quoted 38 lines
lib/librte_net/rte_net_crc_sse.h new file +19
-0+ + +static inline void +rte_net_crc_sse42_init (void ) +{ +uint64_t k1, k2, k5, k6; +uint64_t p =0 , q =0 ; + +/** Initialize CRC16 data */ + k1 =0x189aeLLU ; + k2 =0x8e10LLU ; + k5 =0x189aeLLU ; + k6 =0x114aaLLU ; + q =0x11c581910LLU ; + p =0x10811LLU ; + +/** Save the params in context structure */ + crc16_ccitt_pclmulqdq.rk1_rk2 = + _mm_setr_epi64(_mm_cvtsi64_m64(k1),_mm_cvtsi64_m64(k2));lib/librte_net/rte_net_crc_sse.h new file +2
-0+ crc16_ccitt_pclmulqdq.rk5_rk6 = + _mm_setr_epi64(_mm_cvtsi64_m64(k5),_mm_cvtsi64_m64(k6));lib/librte_net/rte_net_crc_sse.h new file +2
-0+ crc16_ccitt_pclmulqdq.rk7_rk8 = + _mm_setr_epi64(_mm_cvtsi64_m64(q),
_mm_cvtsi64_m64(p));lib/librte_net/rte_net_crc_sse.h new file +12
-0+ +/** Initialize CRC32 data */ + k1 =0xccaa009eLLU ; + k2 =0x1751997d0LLU ; + k5 =0xccaa009eLLU ; + k6 =0x163cd6124LLU ; + q =0x1f7011640LLU ; + p =0x1db710641LLU ; + +/** Save the params in context structure */ + crc32_eth_pclmulqdq.rk1_rk2 = + _mm_setr_epi64(_mm_cvtsi64_m64(k1),
Quoted 1 line
_mm_cvtsi64_m64(k2));
Add extra tab for better readability.
lib/librte_net/rte_net_crc_sse.h line 317
Quoted 8 lines
lib/librte_net/rte_net_crc_sse.h new file +2
-0+ crc32_eth_pclmulqdq.rk5_rk6 = + _mm_setr_epi64(_mm_cvtsi64_m64(k5),
_mm_cvtsi64_m64(k6));lib/librte_net/rte_net_crc_sse.h new file +2
-0+ crc32_eth_pclmulqdq.rk7_rk8 = + _mm_setr_epi64(_mm_cvtsi64_m64(q),
_mm_cvtsi64_m64(p));lib/librte_net/rte_net_crc_sse.h new file +2
-0+ +_mm_empty ();
Maybe we need a comment here.
lib/librte_net/rte_net_crc_sse.h line 328
Quoted 11 lines
lib/librte_net/rte_net_crc_sse.h new file +11
-0+ +} + +static inline uint32_t +rte_crc16_ccitt_sse42_handler (const uint8_t *data, +uint32_t data_len) +{ +return (uint16_t )~crc32_eth_calc_pclmulqdq (data, + data_len, +0xffff , + &crc16_ccitt_pclmulqdq);
Same comment about the casting here.
Quoted 23 lines
lib/librte_net/rte_net_crc_sse.h new file +17
-0+} + +static inline uint32_t +rte_crc32_eth_sse42_handler (const uint8_t *data, +uint32_t data_len) +{ +return ~crc32_eth_calc_pclmulqdq (data, + data_len, +0xffffffffUL , + &crc32_eth_pclmulqdq); +} + +#ifdef __cplusplus +} +#endif + +#endif /* _RTE_NET_CRC_SSE_H_ */ lib/librte_net/rte_net_version.map +0
-0
lib/librte_net/rte_net_version.map DPDK_16.11 { · line 12
Quoted 9 lines
lib/librte_net/rte_net_version.map +6
-0@@ -4,3 +4,11 @@ DPDK_16.11 { local: *; }; + +DPDK_17.05 { + global: + + rte_net_crc_set_alg; + rte_net_crc_calc;
This has to be alphabetically sorted.
Quoted 4 lines
lib/librte_net/rte_net_version.map +2
-1+ +} DPDK_16.11; --2.5.5
Re: [PATCH v5 1/2] librte_net: add crc compute APIs
Quoted 11 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of De Lara Guarch, Pablo
Sent: Tuesday, March 28, 2017 7:04 PM
To: Singh, Jasvinder; [email protected]
Cc: [email protected]; Doherty, Declan
Subject: Re: [dpdk-dev] [PATCH v5 1/2]librte_net: add crc compute APIsHi Jasvinder,
There is also an issue when compiling the net library as a shared library.
rte_net_crc.o: In function `rte_net_crc_set_alg':
rte_net_crc.c:(.text+0x502): undefined reference to rte_cpu_get_flag_enabled' rte_net_crc.o: In function rte_net_crc_init':
rte_net_crc.c:(.text.startup+0x15c): undefined reference to `rte_cpu_get_flag_enabled'
collect2: error: ld returned 1 exit status/tmp/dpdk/mk/rte.lib.mk:127: recipe for target 'librte_net.so.1.1' failed
Quoted 1 line
Re: [PATCH v5 1/2] librte_net: add crc compute APIs
In reply to De Lara Guarch, PabloHi Pablo,
Quoted 357 lines
-----Original Message-----
From: De Lara Guarch, Pablo
Sent: Tuesday, March 28, 2017 7:04 PM
To: Singh, Jasvinder <[email protected]>; [email protected]
Cc: [email protected]; Doherty, Declan <[email protected]>
Subject: RE: [PATCH v5 1/2]librte_net: add crc compute APIsHi Jasvinder,
Quoted 23 lines
-----Original Message-----
From: Singh, Jasvinder
Sent: Tuesday, March 21, 2017 2:46 PM
To: [email protected]
Cc: [email protected]; Doherty, Declan; De Lara Guarch, Pablo
Subject: [PATCH v5 1/2]librte_net: add crc compute APIsAPIs for selecting the architecure specific implementation and computing the crc (16-bit and 32-bit CRCs) are added. For CRCs calculation, scalar as well as x86 intrinsic(sse4.2) versions are implemented.
The scalar version is based on generic Look-Up Table(LUT) algorithm, while x86 intrinsic version uses carry-less multiplication for fast CRC computation.
Signed-off-by Jasvinder Singh <[email protected]>---
(quoted diff) +0
-0
b/lib/librte_net/rte_net_crc.cnew file mode 100644 index 0000000..89edd80lib/librte_net/rte_net_crc.c new file +0
-0...
lib/librte_net/rte_net_crc.c line 39
Quoted 7 lines
lib/librte_net/rte_net_crc.c new file +7
-0+ +#include <rte_net_crc.h> +#include <stddef.h> + +/** crc tables */ +static uint32_t crc32_eth_lut[256 ]; +static uint32_t crc16_ccitt_lut[256 ];Use a macro for 256, that you can use in
crc32_eth_init_lut.lib/librte_net/rte_net_crc.c line 42
Quoted 3 lines
lib/librte_net/rte_net_crc.c new file +3
-0+ +static uint32_t rte_crc16_ccitt_handler (const uint8_t *data, +uint32_t data_len);Separate "static
uint32_t" in another line.Quoted 4 lines
+/**
+ * Reflect the bits about the middle
+ *
+ * @param x value to be reflectedShould be "val".
lib/librte_net/rte_net_crc.c
Quoted 5 lines
+ *
+ * @return reflected value
+ */lib/librte_net/rte_net_crc.c new file +2
-0+static uint32_t +reflect_32bits (const uint32_t val)No need for "const" here, as it is not a pointer.
lib/librte_net/rte_net_crc.c line 84
Quoted 12 lines
lib/librte_net/rte_net_crc.c new file +12
-0+{ +uint32_t i, res =0 ; + +for (i =0 ; i <32 ; i++) +if ((val & (1 << i)) !=0 ) + res |= (uint32_t )(1 << (31 - i)); + +return res; +} + +static void +crc32_eth_init_lut(const uint32_t poly,No need for "const" here.
Quoted 4 lines
lib/librte_net/rte_net_crc.c new file +4
-0+ uint32_t *lut) +{ +uint_fast32_t i, j; +lib/librte_net/rte_net_crc.c line 98
Quoted 10 lines
lib/librte_net/rte_net_crc.c new file +10
-0+for (i =0 ; i <256 ; i++) { +uint_fast32_t crc =reflect_32bits (i); + +for (j =0 ; j <8 ; j++) { +if (crc &0x80000000L ) + crc = (crc <<1 ) ^ poly; +else + crc <<=1 ; + } + lut[i] =reflect_32bits (crc);Wrong indentation.
Quoted 23 lines
lib/librte_net/rte_net_crc.c new file +23
-0+ } +} + +static inline __attribute__((always_inline))uint32_t +crc32_eth_calc_lut (const uint8_t *data, +uint32_t data_len, +uint32_t crc, +const uint32_t *lut) +{ +while (data_len--) + crc = lut[(crc ^ *data++) &0xffL ] ^ (crc >>8 ); + +return crc; +} + +static void +rte_net_crc_scalar_init (void ) +{ +/** 32-bit crc init */ +crc32_eth_init_lut (CRC32_ETH_POLYNOMIAL , crc32_eth_lut); + +/** 16-bit CRC init */ + crc32_eth_init_lut(CRC16_CCITT_POLYNOMIAL << 16,Quoted 2 lines
crc16_ccitt_lut);
+Remove this blank line.
lib/librte_net/rte_net_crc.c line 131
Quoted 8 lines
lib/librte_net/rte_net_crc.c new file +8
-0+} + +static inline uint32_t +rte_crc16_ccitt_handler (const uint8_t *data,uint32_t data_len) { +return (uint16_t )~crc32_eth_calc_lut (data, + data_len, +0xffff , + crc16_ccitt_lut);Since you are casting to
uint16_t, when you are supposed to cast touint32_t(given the return type), I would add a comment explaining why.Quoted 10 lines
lib/librte_net/rte_net_crc.c new file +2
-0+} +(quoted diff) +0
-0
b/lib/librte_net/rte_net_crc.hnew file mode 100644 index 0000000..f8c9075lib/librte_net/rte_net_crc.h new file +0
-0@@ -0,0 +1,101 @@...
lib/librte_net/rte_net_crc.h line 67
Quoted 7 lines
lib/librte_net/rte_net_crc.h new file +7
-0+ +/** +* This API set the crc computation algorithm (i.e. scalar version, +* x86 64-bit sse4.2 intrinsic version, etc.) and internal data +* structure. +* +* @param alg Add extra information (CRC algorithm?).
Quoted 5 lines
+ * -
RTE_NET_CRC_SCALAR
+ * -RTE_NET_CRC_SSE42(Use 64-bit SSE4.2 intrinsic)
+ */lib/librte_net/rte_net_crc.h new file +2
-0+void +rte_net_crc_set_alg (enum rte_net_crc_alg alg);lib/librte_net/rte_net_crc.h line 82
Quoted 10 lines
lib/librte_net/rte_net_crc.h new file +10
-0+ +/** +* CRC compute API +* +* @param data +* Pointer to the packet data for crc computation +* @param data_len +* Data length for crc computation +* @param type +* Crc type (enum rte_net_crc_type) CRC
Quoted 3 lines
+ *
+ * @return
+ * crc valueAdd two spaces after "@param" and "@return".
lib/librte_net/rte_net_crc.h line 92
Quoted 7 lines
+ */
lib/librte_net/rte_net_crc.h new file +6
-0+uint32_t +rte_net_crc_calc (const void *data, +uint32_t data_len, +enum rte_net_crc_type type); + +#if defined(RTE_ARCH_X86_64 ) || defined(RTE_CPU_FALGS_SSE_4_2 )Typo in
RTE_CPU_FALGS_SSE_4_2(I missed the same one inrte_net_crc.c). Also, should it be "&&"?Quoted 16 lines
lib/librte_net/rte_net_crc.h new file +9
-0+#include <rte_net_crc_sse.h> +#endif + +#ifdef __cplusplus +} +#endif + + +#endif /* _RTE_NET_CRC_H_ */ lib/librte_net/rte_net_crc_sse.h new file +0
-0@@ -0,0 +1,345 @@...
Quoted 9 lines
+ * @brief Performs one folding round
+ *
+ * Logically function operates as follows:+ * DATA = READ_NEXT_16BYTES(); + * F1 = LSB8(FOLD) + * F2 = MSB8(FOLD) + * T1 = CLMUL(F1, RK1) + * T2 = CLMUL(F2, RK2) + * FOLD = XOR(T1, T2, DATA)Quoted 6 lines
+ *
+ * @paramdata_block16 byte data block
+ * @param precomp precomputed rk1 constanst
+ * @param fold running 16 byte folded data
+ *
+ * @return New 16 byte folded dataMove parameter/rturn description in a separate line (same for other functions).
lib/librte_net/rte_net_crc_sse.h line 73
Quoted 5 lines
+ */
lib/librte_net/rte_net_crc_sse.h new file +4
-0+static inline __attribute__((always_inline))__m128i +crcr32_folding_round (const __m128i data_block, +const __m128i precomp, +const __m128i fold)No need to use "const" here.
Quoted 8 lines
lib/librte_net/rte_net_crc_sse.h new file +8
-0+{ +__m128i tmp0 =_mm_clmulepi64_si128 (fold, precomp,0x01 ); +__m128i tmp1 =_mm_clmulepi64_si128 (fold, precomp,0x10 ); + +return _mm_xor_si128 (tmp1,_mm_xor_si128 (data_block, tmp0)); } + +/** +* Performs reduction from 128 bits to 64 bits lib/librte_net/rte_net_crc_sse.h line 92
Quoted 10 lines
lib/librte_net/rte_net_crc_sse.h new file +10
-0+* +* @param data128 128 bits data to be reduced +* @param precomp rk5 and rk6 precomputed constants +* +* @return data reduced to 64 bits +*/ + +static inline __attribute__((always_inline))__m128i +crcr32_reduce_128_to_64 (__m128i data128, +const __m128i precomp)No need to use "const" here.
...
Quoted 38 lines
lib/librte_net/rte_net_crc_sse.h new file +19
-0+ + +static inline void +rte_net_crc_sse42_init (void ) +{ +uint64_t k1, k2, k5, k6; +uint64_t p =0 , q =0 ; + +/** Initialize CRC16 data */ + k1 =0x189aeLLU ; + k2 =0x8e10LLU ; + k5 =0x189aeLLU ; + k6 =0x114aaLLU ; + q =0x11c581910LLU ; + p =0x10811LLU ; + +/** Save the params in context structure */ + crc16_ccitt_pclmulqdq.rk1_rk2 = + _mm_setr_epi64(_mm_cvtsi64_m64(k1),_mm_cvtsi64_m64(k2));lib/librte_net/rte_net_crc_sse.h new file +2
-0+ crc16_ccitt_pclmulqdq.rk5_rk6 = + _mm_setr_epi64(_mm_cvtsi64_m64(k5),_mm_cvtsi64_m64(k6));lib/librte_net/rte_net_crc_sse.h new file +2
-0+ crc16_ccitt_pclmulqdq.rk7_rk8 = + _mm_setr_epi64(_mm_cvtsi64_m64(q),
_mm_cvtsi64_m64(p));lib/librte_net/rte_net_crc_sse.h new file +12
-0+ +/** Initialize CRC32 data */ + k1 =0xccaa009eLLU ; + k2 =0x1751997d0LLU ; + k5 =0xccaa009eLLU ; + k6 =0x163cd6124LLU ; + q =0x1f7011640LLU ; + p =0x1db710641LLU ; + +/** Save the params in context structure */ + crc32_eth_pclmulqdq.rk1_rk2 = + _mm_setr_epi64(_mm_cvtsi64_m64(k1),Quoted 1 line
_mm_cvtsi64_m64(k2));Add extra tab for better readability.
lib/librte_net/rte_net_crc_sse.h line 317
Quoted 8 lines
lib/librte_net/rte_net_crc_sse.h new file +2
-0+ crc32_eth_pclmulqdq.rk5_rk6 = + _mm_setr_epi64(_mm_cvtsi64_m64(k5),
_mm_cvtsi64_m64(k6));lib/librte_net/rte_net_crc_sse.h new file +2
-0+ crc32_eth_pclmulqdq.rk7_rk8 = + _mm_setr_epi64(_mm_cvtsi64_m64(q),
_mm_cvtsi64_m64(p));lib/librte_net/rte_net_crc_sse.h new file +2
-0+ +_mm_empty ();Maybe we need a comment here.
lib/librte_net/rte_net_crc_sse.h line 328
Quoted 11 lines
lib/librte_net/rte_net_crc_sse.h new file +11
-0+ +} + +static inline uint32_t +rte_crc16_ccitt_sse42_handler (const uint8_t *data, +uint32_t data_len) +{ +return (uint16_t )~crc32_eth_calc_pclmulqdq (data, + data_len, +0xffff , + &crc16_ccitt_pclmulqdq);Same comment about the casting here.
Quoted 24 lines
lib/librte_net/rte_net_crc_sse.h new file +17
-0+} + +static inline uint32_t +rte_crc32_eth_sse42_handler (const uint8_t *data, +uint32_t data_len) +{ +return ~crc32_eth_calc_pclmulqdq (data, + data_len, +0xffffffffUL , + &crc32_eth_pclmulqdq); +} + +#ifdef __cplusplus +} +#endif + +#endif /* _RTE_NET_CRC_SSE_H_ */ lib/librte_net/rte_net_version.map +0
-0@@ -4,3 +4,11 @@ DPDK_16.11 {
Quoted 10 lines
lib/librte_net/rte_net_version.map DPDK_16.11 { · line 12
Quoted 8 lines
lib/librte_net/rte_net_version.map +6
-0local: *; }; + +DPDK_17.05 { + global: + + rte_net_crc_set_alg; + rte_net_crc_calc;This has to be alphabetically sorted.
Thank you for detailed review. I will revise the patch following your comments and will send v6.
Jasvinder
v6 cover librte_net: add crc computation support
In reply to Jasvinder SinghIn some applications, CRC (Cyclic Redundancy Check) needs to be computed or updated during packet processing operations. This patchset adds software implementation of some common standard CRCs (32-bit Ethernet CRC as per Ethernet/[ISO/IEC 8802-3] and 16-bit CCITT-CRC [ITU-T X.25]). Two versions of each 32-bit and 16-bit CRC calculation are proposed.
The first version presents a fast and efficient CRC generation on IA processors by using the carry-less multiplication instruction � PCLMULQDQ (i.e SSE4.2 instrinsics). In this implementation, a parallelized folding approach has been used to first reduce an arbitrary length buffer to a small fixed size length buffer (16 bytes) with the help of precomputed constants. The resultant single 16-bytes chunk is further reduced by Barrett reduction method to generate final CRC value. For more details on the implementation, see reference [1].
The second version presents the fallback solution to support the CRC generation without needing any specific support from CPU (for examples- SSE4.2 intrinsics). It is based on generic Look-Up Table(LUT) algorithm that uses precomputed 256 element table as explained in reference[2].
During intialisation, all the data structures required for CRC computation are initialised. Also, x86 specific crc implementation (if supported by the platform) or scalar version is enabled.
Following APIs have been added;
(i) rte_net_crc_set_alg()
(ii)rte_net_crc_calc()
The first API (i) allows user to select the specific CRC implementation in run-time while the second API (ii) is used for computing the 16-bit and 32-bit CRC.
References:
[1] Fast CRC Computation for Generic Polynomials Using PCLMULQDQ Instruction
http://www.intel.com/content/dam/www/public/us/en/documents/white-papers/fast-crc-computation-generic-polynomials-pclmulqdq-paper.pdf
[2] A PAINLESS GUIDE TO CRC ERROR DETECTION ALGORITHMS
http://www.ross.net/crc/download/crc_v3.txt
v6 changes:
- fixed build error when compiling as a shared library
- addressed review comments on v5, (thanks Pablo)
v5 changes:
- rebase to the master
v4 changes:
- change crc compute api parameters to make it more generic
- change the unit test to accomodate the crc compute api change
v3 changes:
- separate the x86 specific implementation into new file
- improve the unit test
v2 changes:
- fix build errors for target i686-native-linuxapp-gcc
- fix checkpatch warnings
Notes:
- Build not successful with clang version earlier than 3.7.0 due to missing intrinsics. Refer dpdk known issue section for more details.
Jasvinder Singh (2):
librte_net: add crc compute APIs
test/test: add unit test for CRC computation
lib/Makefile | 2 +- lib/librte_net/Makefile | 3 + lib/librte_net/rte_net_crc.c | 199 ++++++++++++++++++++ lib/librte_net/rte_net_crc.h | 104 +++++++++++ lib/librte_net/rte_net_crc_sse.h | 361 +++++++++++++++++++++++++++++++++++++ lib/librte_net/rte_net_version.map | 8 + test/test/Makefile | 2 + test/test/test_crc.c | 241 +++++++++++++++++++++++++ 8 files changed, 919 insertions(+), 1 deletion(-) create mode 100644 lib/librte_net/rte_net_crc.c create mode 100644 lib/librte_net/rte_net_crc.h create mode 100644 lib/librte_net/rte_net_crc_sse.h create mode 100644 test/test/test_crc.c
Signature · 1 line
2.5.5
PATCH v6 1/2 librte_net: add crc compute APIs
APIs for selecting the architecure specific implementation and computing the crc (16-bit and 32-bit CRCs) are added. For CRCs calculation, scalar as well as x86 intrinsic(sse4.2) versions are implemented.
The scalar version is based on generic Look-Up Table(LUT) algorithm, while x86 intrinsic version uses carry-less multiplication for fast CRC computation.
--- lib/Makefile | 2 +- lib/librte_net/Makefile | 3 + lib/librte_net/rte_net_crc.c | 199 ++++++++++++++++++++ lib/librte_net/rte_net_crc.h | 104 +++++++++++ lib/librte_net/rte_net_crc_sse.h | 361 +++++++++++++++++++++++++++++++++++++ lib/librte_net/rte_net_version.map | 8 + 6 files changed, 676 insertions(+), 1 deletion(-) create mode 100644 lib/librte_net/rte_net_crc.c create mode 100644 lib/librte_net/rte_net_crc.h create mode 100644 lib/librte_net/rte_net_crc_sse.h
lib/Makefile +1 -1
@@ -62,7 +62,7 @@ DEPDIRS-librte_lpm := librte_eal DIRS-$(CONFIG_RTE_LIBRTE_ACL) += librte_acl DEPDIRS-librte_acl := librte_eal DIRS-$(CONFIG_RTE_LIBRTE_NET) += librte_net -DEPDIRS-librte_net := librte_mbuf +DEPDIRS-librte_net := librte_mbuf librte_eal DIRS-$(CONFIG_RTE_LIBRTE_IP_FRAG) += librte_ip_frag DEPDIRS-librte_ip_frag := librte_eal librte_mempool librte_mbuf librte_ether DEPDIRS-librte_ip_frag += librte_hash
lib/librte_net/Makefile +3 -0
@@ -39,10 +39,13 @@ EXPORT_MAP := rte_net_version.map LIBABIVER := 1 SRCS-$(CONFIG_RTE_LIBRTE_NET) := rte_net.c +SRCS-$(CONFIG_RTE_LIBRTE_NET) += rte_net_crc.c # install includes SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include := rte_ip.h rte_tcp.h rte_udp.h SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_sctp.h rte_icmp.h rte_arp.h SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_ether.h rte_gre.h rte_net.h +SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_net_crc.h +SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_net_crc_sse.h include $(RTE_SDK)/mk/rte.lib.mk
lib/librte_net/rte_net_crc.c new file +199 -0
199 lines not on this page · raw message
lib/librte_net/rte_net_crc.h new file +104 -0
104 lines not on this page · raw message
lib/librte_net/rte_net_crc_sse.h new file +361 -0
361 lines not on this page · raw message
lib/librte_net/rte_net_version.map +8 -0
@@ -4,3 +4,11 @@ DPDK_16.11 { local: *; }; + +DPDK_17.05 { + global: + + rte_net_crc_calc; + rte_net_crc_set_alg; + +} DPDK_16.11;
Signature · 1 line
2.5.5
Re: [PATCH v6 1/2] librte_net: add crc compute APIs
Quoted 13 lines
-----Original Message-----
From: Singh, Jasvinder
Sent: Wednesday, March 29, 2017 1:42 PM
To: [email protected]
Cc: [email protected]; Doherty, Declan; De Lara Guarch, Pablo
Subject: [PATCH v6 1/2]librte_net: add crc compute APIsAPIs for selecting the architecure specific implementation and computing the crc (16-bit and 32-bit CRCs) are added. For CRCs calculation, scalar as well as x86 intrinsic(sse4.2) versions are implemented.
Quoted 5 lines
The scalar version is based on generic Look-Up Table(LUT) algorithm, while x86 intrinsic version uses carry-less multiplication for fast CRC computation.
Signed-off-by Jasvinder Singh <[email protected]>
Thanks for your work addressing all my comments.
v7 cover librte_net: add crc computation support
In reply to Jasvinder SinghIn some applications, CRC (Cyclic Redundancy Check) needs to be computed or updated during packet processing operations. This patchset adds software implementation of some common standard CRCs (32-bit Ethernet CRC as per Ethernet/[ISO/IEC 8802-3] and 16-bit CCITT-CRC [ITU-T X.25]). Two versions of each 32-bit and 16-bit CRC calculation are proposed.
The first version presents a fast and efficient CRC generation on IA processors by using the carry-less multiplication instruction � PCLMULQDQ (i.e SSE4.2 instrinsics). In this implementation, a parallelized folding approach has been used to first reduce an arbitrary length buffer to a small fixed size length buffer (16 bytes) with the help of precomputed constants. The resultant single 16-bytes chunk is further reduced by Barrett reduction method to generate final CRC value. For more details on the implementation, see reference [1].
The second version presents the fallback solution to support the CRC generation without needing any specific support from CPU (for examples- SSE4.2 intrinsics). It is based on generic Look-Up Table(LUT) algorithm that uses precomputed 256 element table as explained in reference[2].
During intialisation, all the data structures required for CRC computation are initialised. Also, x86 specific crc implementation (if supported by the platform) or scalar version is enabled.
Following APIs have been added;
(i) rte_net_crc_set_alg()
(ii)rte_net_crc_calc()
The first API (i) allows user to select the specific CRC implementation in run-time while the second API (ii) is used for computing the 16-bit and 32-bit CRC.
References:
[1] Fast CRC Computation for Generic Polynomials Using PCLMULQDQ Instruction
http://www.intel.com/content/dam/www/public/us/en/documents/white-papers/fast-crc-computation-generic-polynomials-pclmulqdq-paper.pdf
[2] A PAINLESS GUIDE TO CRC ERROR DETECTION ALGORITHMS
http://www.ross.net/crc/download/crc_v3.txt
v7 changes:
- remove the duplicate function in unit test.
v6 changes:
- fixed build error when compiling net library as a shared library
- addressed review comments on v5, (thanks Pablo)
v5 changes:
- rebase to the master
v4 changes:
- change crc compute api parameters to make it more generic
- change the unit test to accomodate the crc compute api change
v3 changes:
- separate the x86 specific implementation into new file
- improve the unit test
v2 changes:
- fix build errors for target i686-native-linuxapp-gcc
- fix checkpatch warnings
Notes:
- Build not successful with clang version earlier than 3.7.0 due to missing intrinsics. Refer dpdk known issue section for more details.
Jasvinder Singh (2):
librte_net: add crc compute APIs
test/test: add unit test for CRC computation
lib/Makefile | 2 +- lib/librte_net/Makefile | 3 + lib/librte_net/rte_net_crc.c | 199 ++++++++++++++++++++ lib/librte_net/rte_net_crc.h | 104 +++++++++++ lib/librte_net/rte_net_crc_sse.h | 361 +++++++++++++++++++++++++++++++++++++ lib/librte_net/rte_net_version.map | 8 + test/test/Makefile | 2 + test/test/test_crc.c | 173 ++++++++++++++++++ 8 files changed, 851 insertions(+), 1 deletion(-) create mode 100644 lib/librte_net/rte_net_crc.c create mode 100644 lib/librte_net/rte_net_crc.h create mode 100644 lib/librte_net/rte_net_crc_sse.h create mode 100644 test/test/test_crc.c
Signature · 1 line
2.5.5
PATCH v7 1/2 librte_net: add crc compute APIs
APIs for selecting the architecure specific implementation and computing the crc (16-bit and 32-bit CRCs) are added. For CRCs calculation, scalar as well as x86 intrinsic(sse4.2) versions are implemented.
The scalar version is based on generic Look-Up Table(LUT) algorithm, while x86 intrinsic version uses carry-less multiplication for fast CRC computation.
--- lib/Makefile | 2 +- lib/librte_net/Makefile | 3 + lib/librte_net/rte_net_crc.c | 199 ++++++++++++++++++++ lib/librte_net/rte_net_crc.h | 104 +++++++++++ lib/librte_net/rte_net_crc_sse.h | 361 +++++++++++++++++++++++++++++++++++++ lib/librte_net/rte_net_version.map | 8 + 6 files changed, 676 insertions(+), 1 deletion(-) create mode 100644 lib/librte_net/rte_net_crc.c create mode 100644 lib/librte_net/rte_net_crc.h create mode 100644 lib/librte_net/rte_net_crc_sse.h
lib/Makefile +1 -1
@@ -62,7 +62,7 @@ DEPDIRS-librte_lpm := librte_eal DIRS-$(CONFIG_RTE_LIBRTE_ACL) += librte_acl DEPDIRS-librte_acl := librte_eal DIRS-$(CONFIG_RTE_LIBRTE_NET) += librte_net -DEPDIRS-librte_net := librte_mbuf +DEPDIRS-librte_net := librte_mbuf librte_eal DIRS-$(CONFIG_RTE_LIBRTE_IP_FRAG) += librte_ip_frag DEPDIRS-librte_ip_frag := librte_eal librte_mempool librte_mbuf librte_ether DEPDIRS-librte_ip_frag += librte_hash
lib/librte_net/Makefile +3 -0
@@ -39,10 +39,13 @@ EXPORT_MAP := rte_net_version.map LIBABIVER := 1 SRCS-$(CONFIG_RTE_LIBRTE_NET) := rte_net.c +SRCS-$(CONFIG_RTE_LIBRTE_NET) += rte_net_crc.c # install includes SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include := rte_ip.h rte_tcp.h rte_udp.h SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_sctp.h rte_icmp.h rte_arp.h SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_ether.h rte_gre.h rte_net.h +SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_net_crc.h +SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_net_crc_sse.h include $(RTE_SDK)/mk/rte.lib.mk
lib/librte_net/rte_net_crc.c new file +199 -0
199 lines not on this page · raw message
lib/librte_net/rte_net_crc.h new file +104 -0
104 lines not on this page · raw message
lib/librte_net/rte_net_crc_sse.h new file +361 -0
361 lines not on this page · raw message
lib/librte_net/rte_net_version.map +8 -0
@@ -4,3 +4,11 @@ DPDK_16.11 { local: *; }; + +DPDK_17.05 { + global: + + rte_net_crc_calc; + rte_net_crc_set_alg; + +} DPDK_16.11;
Signature · 1 line
2.5.5
v8 cover librte_net: add crc computation support
In some applications, CRC (Cyclic Redundancy Check) needs to be computed or updated during packet processing operations. This patchset adds software implementation of some common standard CRCs (32-bit Ethernet CRC as per Ethernet/[ISO/IEC 8802-3] and 16-bit CCITT-CRC [ITU-T X.25]). Two versions of each 32-bit and 16-bit CRC calculation are proposed.
The first version presents a fast and efficient CRC generation on IA processors by using the carry-less multiplication instruction � PCLMULQDQ (i.e SSE4.2 instrinsics). In this implementation, a parallelized folding approach has been used to first reduce an arbitrary length buffer to a small fixed size length buffer (16 bytes) with the help of precomputed constants. The resultant single 16-bytes chunk is further reduced by Barrett reduction method to generate final CRC value. For more details on the implementation, see reference [1].
The second version presents the fallback solution to support the CRC generation without needing any specific support from CPU (for examples- SSE4.2 intrinsics). It is based on generic Look-Up Table(LUT) algorithm that uses precomputed 256 element table as explained in reference[2].
During intialisation, all the data structures required for CRC computation are initialised. Also, x86 specific crc implementation (if supported by the platform) or scalar version is enabled.
Following APIs have been added;
(i) rte_net_crc_set_alg()
(ii)rte_net_crc_calc()
The first API (i) allows user to select the specific CRC implementation in run-time while the second API (ii) is used for computing the 16-bit and 32-bit CRC.
References:
[1] Fast CRC Computation for Generic Polynomials Using PCLMULQDQ Instruction
http://www.intel.com/content/dam/www/public/us/en/documents/white-papers/fast-crc-computation-generic-polynomials-pclmulqdq-paper.pdf
[2] A PAINLESS GUIDE TO CRC ERROR DETECTION ALGORITHMS
http://www.ross.net/crc/download/crc_v3.txt
v8 changes:
- fixed memory leaks in unit test.
v7 changes:
- removed the duplicate function in unit test.
v6 changes:
- fixed build error when compiling net library as a shared library
- addressed review comments on v5, (thanks Pablo)
v5 changes:
- rebase to the master
v4 changes:
- change crc compute api parameters to make it more generic
- change the unit test to accomodate the crc compute api change
v3 changes:
- separate the x86 specific implementation into new file
- improve the unit test
v2 changes:
- fix build errors for target i686-native-linuxapp-gcc
- fix checkpatch warnings
Notes:
- Build not successful with clang version earlier than 3.7.0 due to missing intrinsics. Refer dpdk known issue section for more details.
Jasvinder Singh (2):
librte_net: add crc compute APIs
test/test: add unit test for CRC computation
lib/Makefile | 2 +- lib/librte_net/Makefile | 3 + lib/librte_net/rte_net_crc.c | 199 ++++++++++++++++++++ lib/librte_net/rte_net_crc.h | 104 +++++++++++ lib/librte_net/rte_net_crc_sse.h | 361 +++++++++++++++++++++++++++++++++++++ lib/librte_net/rte_net_version.map | 8 + test/test/Makefile | 2 + test/test/test_crc.c | 182 +++++++++++++++++++ 8 files changed, 860 insertions(+), 1 deletion(-) create mode 100644 lib/librte_net/rte_net_crc.c create mode 100644 lib/librte_net/rte_net_crc.h create mode 100644 lib/librte_net/rte_net_crc_sse.h create mode 100644 test/test/test_crc.c
Signature · 1 line
2.5.5
PATCH v8 1/2 librte_net: add crc compute APIs
APIs for selecting the architecure specific implementation and computing the crc (16-bit and 32-bit CRCs) are added. For CRCs calculation, scalar as well as x86 intrinsic(sse4.2) versions are implemented.
The scalar version is based on generic Look-Up Table(LUT) algorithm, while x86 intrinsic version uses carry-less multiplication for fast CRC computation.
--- lib/Makefile | 2 +- lib/librte_net/Makefile | 3 + lib/librte_net/rte_net_crc.c | 199 ++++++++++++++++++++ lib/librte_net/rte_net_crc.h | 104 +++++++++++ lib/librte_net/rte_net_crc_sse.h | 361 +++++++++++++++++++++++++++++++++++++ lib/librte_net/rte_net_version.map | 8 + 6 files changed, 676 insertions(+), 1 deletion(-) create mode 100644 lib/librte_net/rte_net_crc.c create mode 100644 lib/librte_net/rte_net_crc.h create mode 100644 lib/librte_net/rte_net_crc_sse.h
lib/Makefile +1 -1
@@ -62,7 +62,7 @@ DEPDIRS-librte_lpm := librte_eal DIRS-$(CONFIG_RTE_LIBRTE_ACL) += librte_acl DEPDIRS-librte_acl := librte_eal DIRS-$(CONFIG_RTE_LIBRTE_NET) += librte_net -DEPDIRS-librte_net := librte_mbuf +DEPDIRS-librte_net := librte_mbuf librte_eal DIRS-$(CONFIG_RTE_LIBRTE_IP_FRAG) += librte_ip_frag DEPDIRS-librte_ip_frag := librte_eal librte_mempool librte_mbuf librte_ether DEPDIRS-librte_ip_frag += librte_hash
lib/librte_net/Makefile +3 -0
@@ -39,10 +39,13 @@ EXPORT_MAP := rte_net_version.map LIBABIVER := 1 SRCS-$(CONFIG_RTE_LIBRTE_NET) := rte_net.c +SRCS-$(CONFIG_RTE_LIBRTE_NET) += rte_net_crc.c # install includes SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include := rte_ip.h rte_tcp.h rte_udp.h SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_sctp.h rte_icmp.h rte_arp.h SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_ether.h rte_gre.h rte_net.h +SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_net_crc.h +SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_net_crc_sse.h include $(RTE_SDK)/mk/rte.lib.mk
lib/librte_net/rte_net_crc.c new file +199 -0
199 lines not on this page · raw message
lib/librte_net/rte_net_crc.h new file +104 -0
104 lines not on this page · raw message
lib/librte_net/rte_net_crc_sse.h new file +361 -0
361 lines not on this page · raw message
lib/librte_net/rte_net_version.map +8 -0
@@ -4,3 +4,11 @@ DPDK_16.11 { local: *; }; + +DPDK_17.05 { + global: + + rte_net_crc_calc; + rte_net_crc_set_alg; + +} DPDK_16.11;
Signature · 1 line
2.5.5
Re: [PATCH v8 1/2] librte_net: add crc compute APIs
Hi Jasvinder,
Quoted 39 lines
lib/librte_net/rte_net_crc.h new file +33
-0@@ -0,0 +1,104 @@ +/*- +* BSD LICENSE +* +* Copyright(c) 2017 Intel Corporation. +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +
lib/librte_net/rte_net_crc.h line 43
Quoted 10 lines
lib/librte_net/rte_net_crc.h new file +10
-0+#ifndef _RTE_NET_CRC_H_ +#define _RTE_NET_CRC_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdint.h> + +#include <rte_mbuf.h>
As a nit: you probably don't need that include.
Konstantin
Quoted 60 lines
lib/librte_net/rte_net_crc.h new file +60
-0+ +/** CRC polynomials */ +#define CRC32_ETH_POLYNOMIAL 0x04c11db7UL +#define CRC16_CCITT_POLYNOMIAL 0x1021U + +#define CRC_LUT_SIZE 256 + +/** CRC types */ +enum rte_net_crc_type { +RTE_NET_CRC16_CCITT =0 , +RTE_NET_CRC32_ETH , +RTE_NET_CRC_REQS +}; + +/** CRC compute algorithm */ +enum rte_net_crc_alg { +RTE_NET_CRC_SCALAR =0 , +RTE_NET_CRC_SSE42 , +}; + +/** +* This API set the CRC computation algorithm (i.e. scalar version, +* x86 64-bit sse4.2 intrinsic version, etc.) and internal data +* structure. +* +* @param alg +* This parameter is used to select the CRC implementation version. +* - RTE_NET_CRC_SCALAR +* - RTE_NET_CRC_SSE42 (Use 64-bit SSE4.2 intrinsic) +*/ +void +rte_net_crc_set_alg (enum rte_net_crc_alg alg); + +/** +* CRC compute API +* +* @param data +* Pointer to the packet data for CRC computation +* @param data_len +* Data length for CRC computation +* @param type +* CRC type (enum rte_net_crc_type) +* +* @return +* CRC value +*/ +uint32_t +rte_net_crc_calc (const void *data, +uint32_t data_len, +enum rte_net_crc_type type); + +#if defined(RTE_ARCH_X86_64 ) && defined(RTE_MACHINE_CPUFLAG_SSE4_2 ) +#include <rte_net_crc_sse.h> +#endif + +#ifdef __cplusplus +} +#endif + +
Re: [PATCH v8 1/2] librte_net: add crc compute APIs
Quoted 60 lines
-----Original Message-----
From: Ananyev, Konstantin
Sent: Thursday, March 30, 2017 12:32 PM
To: Singh, Jasvinder <[email protected]>; [email protected]
Cc: [email protected]; Doherty, Declan <[email protected]>; De Lara Guarch, Pablo <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v8 1/2]librte_net: add crc compute APIsHi Jasvinder,
Quoted 17 lines
(quoted diff) +0
-0
b/lib/librte_net/rte_net_crc.hnew file mode 100644 index 0000000..dd6c110lib/librte_net/rte_net_crc.h new file +11
-0@@ -0,0 +1,104 @@ +/*- +* BSD LICENSE +* +* Copyright(c) 2017 Intel Corporation. +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright lib/librte_net/rte_net_crc.h line 21
Quoted 10 lines
lib/librte_net/rte_net_crc.h new file +10
-0+* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
lib/librte_net/rte_net_crc.h line 22
Quoted 1 line
lib/librte_net/rte_net_crc.h new file +1
-0+* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
lib/librte_net/rte_net_crc.h line 23
Quoted 1 line
lib/librte_net/rte_net_crc.h new file +1
-0+* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
lib/librte_net/rte_net_crc.h line 24
Quoted 1 line
lib/librte_net/rte_net_crc.h new file +1
-0+* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
lib/librte_net/rte_net_crc.h line 25
Quoted 1 line
lib/librte_net/rte_net_crc.h new file +1
-0+* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
lib/librte_net/rte_net_crc.h line 26
Quoted 1 line
lib/librte_net/rte_net_crc.h new file +1
-0+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
lib/librte_net/rte_net_crc.h line 27
Quoted 1 line
lib/librte_net/rte_net_crc.h new file +1
-0+* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
lib/librte_net/rte_net_crc.h line 28
Quoted 1 line
lib/librte_net/rte_net_crc.h new file +1
-0+* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
lib/librte_net/rte_net_crc.h line 29
Quoted 1 line
lib/librte_net/rte_net_crc.h new file +1
-0+* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
lib/librte_net/rte_net_crc.h line 30
Quoted 1 line
lib/librte_net/rte_net_crc.h new file +1
-0+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
lib/librte_net/rte_net_crc.h line 31
Quoted 1 line
lib/librte_net/rte_net_crc.h new file +1
-0+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Quoted 16 lines
lib/librte_net/rte_net_crc.h line 43
Quoted 12 lines
lib/librte_net/rte_net_crc.h new file +12
-0+*/ + +#ifndef _RTE_NET_CRC_H_ +#define _RTE_NET_CRC_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdint.h> + +#include <rte_mbuf.h>As a nit: you probably don't need that include.
Konstantin
Oh, forgot to remove this, will send another version. Thanks Konstantin.
Re: [PATCH v8 1/2] librte_net: add crc compute APIs
In reply to Ananyev, KonstantinHi Jasvinder,
Quoted 101 lines · Konstantin
Hi Jasvinder,
Quoted 39 lines
lib/librte_net/rte_net_crc.h new file +33
-0@@ -0,0 +1,104 @@ +/*- +* BSD LICENSE +* +* Copyright(c) 2017 Intel Corporation. +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +lib/librte_net/rte_net_crc.h line 43
Quoted 10 lines
lib/librte_net/rte_net_crc.h new file +10
-0+#ifndef _RTE_NET_CRC_H_ +#define _RTE_NET_CRC_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdint.h> + +#include <rte_mbuf.h>As a nit: you probably don't need that include.
KonstantinQuoted 46 lines
lib/librte_net/rte_net_crc.h new file +46
-0+ +/** CRC polynomials */ +#define CRC32_ETH_POLYNOMIAL 0x04c11db7UL +#define CRC16_CCITT_POLYNOMIAL 0x1021U + +#define CRC_LUT_SIZE 256 + +/** CRC types */ +enum rte_net_crc_type { +RTE_NET_CRC16_CCITT =0 , +RTE_NET_CRC32_ETH , +RTE_NET_CRC_REQS +}; + +/** CRC compute algorithm */ +enum rte_net_crc_alg { +RTE_NET_CRC_SCALAR =0 , +RTE_NET_CRC_SSE42 , +}; + +/** +* This API set the CRC computation algorithm (i.e. scalar version, +* x86 64-bit sse4.2 intrinsic version, etc.) and internal data +* structure. +* +* @param alg +* This parameter is used to select the CRC implementation version. +* - RTE_NET_CRC_SCALAR +* - RTE_NET_CRC_SSE42 (Use 64-bit SSE4.2 intrinsic) +*/ +void +rte_net_crc_set_alg (enum rte_net_crc_alg alg); + +/** +* CRC compute API +* +* @param data +* Pointer to the packet data for CRC computation +* @param data_len +* Data length for CRC computation +* @param type +* CRC type (enum rte_net_crc_type) +* +* @return +* CRC value +*/
Quoted 8 lines
lib/librte_net/rte_net_crc.h line 97
Quoted 8 lines
lib/librte_net/rte_net_crc.h new file +8
-0+uint32_t +rte_net_crc_calc (const void *data, +uint32_t data_len, +enum rte_net_crc_type type); + +#if defined(RTE_ARCH_X86_64 ) && defined(RTE_MACHINE_CPUFLAG_SSE4_2 ) +#include <rte_net_crc_sse.h> +#endif
I think this include should not be included from rte_net_crc.h.
From what I see, the API is the same for sse and non-sse, so this include could be private, included only from the .c file. If you also remove the include to rte_mbuf.h as suggested by Konstantin, it will require the following includes in rte_net_crc.c:
#include <stddef.h>
#include <string.h>
#include <rte_common.h>
#include <rte_cpuflags.h>
#include <rte_branch_prediction.h>
#include <rte_vect.h>
#include <rte_net_crc.h>
#if defined(RTE_ARCH_X86_64) && defined(RTE_MACHINE_CPUFLAG_SSE4_2) #include <rte_net_crc_sse.h>
#endif
If the sse file is only used in the .c, this line could also be removed in the Makefile:
SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_net_crc_sse.h
I'm not very familiar with crc and sse code. Could you add yourself as maintainer for these files in MAINTAINERS?
Thanks
Olivier
Re: [PATCH v8 1/2] librte_net: add crc compute APIs
Hi Olivier,
Quoted 8 lines
-----Original Message-----
From: Olivier Matz [mailto:[email protected]]
Sent: Thursday, March 30, 2017 3:41 PM
To: Ananyev, Konstantin <[email protected]>
Cc: Singh, Jasvinder <[email protected]>; [email protected]; Doherty, Declan <[email protected]>; De Lara Guarch, Pablo <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v8 1/2]librte_net: add crc compute APIs
<snip>
Quoted 26 lines
I think this include should not be included from
rte_net_crc.h.From what I see, the API is the same for sse and non-sse, so this include could be private, included only from the .c file. If you also remove the include to
rte_mbuf.has suggested by Konstantin, it will require the following includes inrte_net_crc.c:#include <
stddef.h>
#include <string.h>#include <
rte_common.h>
#include <rte_cpuflags.h>
#include <rte_branch_prediction.h>
#include <rte_vect.h>
#include <rte_net_crc.h>
#ifdefined(RTE_ARCH_X86_64)&&defined(RTE_MACHINE_CPUFLAG_SSE4_2)
#include <rte_net_crc_sse.h>
#endifIf the sse file is only used in the .c, this line could also be removed in the
Makefile:SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include +=
rte_net_crc_sse.h
Quoted 6 lines
I'm not very familiar with crc and sse code. Could you add yourself as maintainer for these files in
MAINTAINERS?Thanks
Olivier
Thank you for the review. I will make above suggested changes in the next version.
Jasvinder
v9 cover librte_net: add crc computation support
In reply to Jasvinder SinghIn some applications, CRC (Cyclic Redundancy Check) needs to be computed or updated during packet processing operations. This patchset adds software implementation of some common standard CRCs (32-bit Ethernet CRC as per Ethernet/[ISO/IEC 8802-3] and 16-bit CCITT-CRC [ITU-T X.25]). Two versions of each 32-bit and 16-bit CRC calculation are proposed.
The first version presents a fast and efficient CRC generation on IA processors by using the carry-less multiplication instruction � PCLMULQDQ (i.e SSE4.2 instrinsics). In this implementation, a parallelized folding approach has been used to first reduce an arbitrary length buffer to a small fixed size length buffer (16 bytes) with the help of precomputed constants. The resultant single 16-bytes chunk is further reduced by Barrett reduction method to generate final CRC value. For more details on the implementation, see reference [1].
The second version presents the fallback solution to support the CRC generation without needing any specific support from CPU (for examples- SSE4.2 intrinsics). It is based on generic Look-Up Table(LUT) algorithm that uses precomputed 256 element table as explained in reference[2].
During intialisation, all the data structures required for CRC computation are initialised. Also, x86 specific crc implementation (if supported by the platform) or scalar version is enabled.
Following APIs have been added;
(i) rte_net_crc_set_alg()
(ii)rte_net_crc_calc()
The first API (i) allows user to select the specific CRC implementation in run-time while the second API (ii) is used for computing the 16-bit and 32-bit CRC.
References:
[1] Fast CRC Computation for Generic Polynomials Using PCLMULQDQ Instruction
http://www.intel.com/content/dam/www/public/us/en/documents/white-papers/fast-crc-computation-generic-polynomials-pclmulqdq-paper.pdf
[2] A PAINLESS GUIDE TO CRC ERROR DETECTION ALGORITHMS
http://www.ross.net/crc/download/crc_v3.txt
v9 changes:
- included header files.
- added maintainership
v8 changes:
- improve unit test case.
v7 changes:
- remove the duplicate function in unit test.
v6 changes:
- fixed build error when compiling net library as a shared library
- addressed review comments on v5, (thanks Pablo)
v5 changes:
- rebase to the master
v4 changes:
- change crc compute api parameters to make it more generic
- change the unit test to accomodate the crc compute api change
v3 changes:
- separate the x86 specific implementation into new file
- improve the unit test
v2 changes:
- fix build errors for target i686-native-linuxapp-gcc
- fix checkpatch warnings
Notes:
- Build not successful with clang version earlier than 3.7.0 due to missing intrinsics. Refer dpdk known issue section for more details.
Jasvinder Singh (3):
librte_net: add crc compute APIs
test/test: add unit test for CRC computation
maintainers: add packet crc section and claim maintainership
MAINTAINERS | 6 + lib/Makefile | 2 +- lib/librte_net/Makefile | 2 + lib/librte_net/rte_net_crc.c | 206 +++++++++++++++++++++ lib/librte_net/rte_net_crc.h | 96 ++++++++++ lib/librte_net/rte_net_crc_sse.h | 363 +++++++++++++++++++++++++++++++++++++ lib/librte_net/rte_net_version.map | 8 + test/test/Makefile | 2 + test/test/test_crc.c | 183 +++++++++++++++++++ 9 files changed, 867 insertions(+), 1 deletion(-) create mode 100644 lib/librte_net/rte_net_crc.c create mode 100644 lib/librte_net/rte_net_crc.h create mode 100644 lib/librte_net/rte_net_crc_sse.h create mode 100644 test/test/test_crc.c
Signature · 1 line
2.5.5
PATCH v9 1/3 librte_net: add crc compute APIs
APIs for selecting the architecure specific implementation and computing the crc (16-bit and 32-bit CRCs) are added. For CRCs calculation, scalar as well as x86 intrinsic(sse4.2) versions are implemented.
The scalar version is based on generic Look-Up Table(LUT) algorithm, while x86 intrinsic version uses carry-less multiplication for fast CRC computation.
--- lib/Makefile | 2 +- lib/librte_net/Makefile | 2 + lib/librte_net/rte_net_crc.c | 206 +++++++++++++++++++++ lib/librte_net/rte_net_crc.h | 96 ++++++++++ lib/librte_net/rte_net_crc_sse.h | 363 +++++++++++++++++++++++++++++++++++++ lib/librte_net/rte_net_version.map | 8 + 6 files changed, 676 insertions(+), 1 deletion(-) create mode 100644 lib/librte_net/rte_net_crc.c create mode 100644 lib/librte_net/rte_net_crc.h create mode 100644 lib/librte_net/rte_net_crc_sse.h
lib/Makefile +1 -1
@@ -62,7 +62,7 @@ DEPDIRS-librte_lpm := librte_eal DIRS-$(CONFIG_RTE_LIBRTE_ACL) += librte_acl DEPDIRS-librte_acl := librte_eal DIRS-$(CONFIG_RTE_LIBRTE_NET) += librte_net -DEPDIRS-librte_net := librte_mbuf +DEPDIRS-librte_net := librte_mbuf librte_eal DIRS-$(CONFIG_RTE_LIBRTE_IP_FRAG) += librte_ip_frag DEPDIRS-librte_ip_frag := librte_eal librte_mempool librte_mbuf librte_ether DEPDIRS-librte_ip_frag += librte_hash
lib/librte_net/Makefile +2 -0
@@ -39,10 +39,12 @@ EXPORT_MAP := rte_net_version.map LIBABIVER := 1 SRCS-$(CONFIG_RTE_LIBRTE_NET) := rte_net.c +SRCS-$(CONFIG_RTE_LIBRTE_NET) += rte_net_crc.c # install includes SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include := rte_ip.h rte_tcp.h rte_udp.h SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_sctp.h rte_icmp.h rte_arp.h SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_ether.h rte_gre.h rte_net.h +SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_net_crc.h include $(RTE_SDK)/mk/rte.lib.mk
lib/librte_net/rte_net_crc.c new file +206 -0
206 lines not on this page · raw message
lib/librte_net/rte_net_crc.h new file +96 -0
96 lines not on this page · raw message
lib/librte_net/rte_net_crc_sse.h new file +363 -0
363 lines not on this page · raw message
lib/librte_net/rte_net_version.map +8 -0
@@ -4,3 +4,11 @@ DPDK_16.11 { local: *; }; + +DPDK_17.05 { + global: + + rte_net_crc_calc; + rte_net_crc_set_alg; + +} DPDK_16.11;
Signature · 1 line
2.5.5
Re: [PATCH v9 1/3] librte_net: add crc compute APIs
2017-03-30 17:15, Jasvinder Singh:
Quoted 7 lines
lib/librte_net/rte_net_crc.h new file +7
-0+/** +* CRC compute API +* +* @param data +* Pointer to the packet data for CRC computation +* @param data_len +* Data length for CRC computation
lib/librte_net/rte_net_crc.h line 89
Quoted 10 lines
lib/librte_net/rte_net_crc.h new file +10
-0+* @param type +* CRC type (enum rte_net_crc_type) +* +* @return +* CRC value +*/ +uint32_t +rte_net_crc_calc (const void *data, +uint32_t data_len, +enum rte_net_crc_type type);
I still think returning a value from a data input is a kind of hash. And this is my wikipedia argument:
https://en.wikipedia.org/wiki/List_of_hash_functions
"This is a list of hash functions, including cyclic redundancy checks, checksum functions, and cryptographic hash functions."
Anyway, I must accept the community decision.
Now I would like to see a clear explanations of which algos are in librte_hash, and why we have CRC32c and Toeplitz.
v10 cover librte_net: add crc computation support
In reply to Jasvinder SinghIn some applications, CRC (Cyclic Redundancy Check) needs to be computed or updated during packet processing operations. This patchset adds software implementation of some common standard CRCs (32-bit Ethernet CRC as per Ethernet/[ISO/IEC 8802-3] and 16-bit CCITT-CRC [ITU-T X.25]). Two versions of each 32-bit and 16-bit CRC calculation are proposed.
The first version presents a fast and efficient CRC generation on IA processors by using the carry-less multiplication instruction � PCLMULQDQ (i.e SSE4.2 instrinsics). In this implementation, a parallelized folding approach has been used to first reduce an arbitrary length buffer to a small fixed size length buffer (16 bytes) with the help of precomputed constants. The resultant single 16-bytes chunk is further reduced by Barrett reduction method to generate final CRC value. For more details on the implementation, see reference [1].
The second version presents the fallback solution to support the CRC generation without needing any specific support from CPU (for examples- SSE4.2 intrinsics). It is based on generic Look-Up Table(LUT) algorithm that uses precomputed 256 element table as explained in reference[2].
During intialisation, all the data structures required for CRC computation are initialised. Also, x86 specific crc implementation (if supported by the platform) or scalar version is enabled.
Following APIs have been added;
(i) rte_net_crc_set_alg()
(ii)rte_net_crc_calc()
The first API (i) allows user to select the specific CRC implementation in run-time while the second API (ii) is used for computing the 16-bit and 32-bit CRC.
References:
[1] Fast CRC Computation for Generic Polynomials Using PCLMULQDQ Instruction
http://www.intel.com/content/dam/www/public/us/en/documents/white-papers/fast-crc-computation-generic-polynomials-pclmulqdq-paper.pdf
[2] A PAINLESS GUIDE TO CRC ERROR DETECTION ALGORITHMS
http://www.ross.net/crc/download/crc_v3.txt
v10 changes:
- added check for PCLMULQDQ instructions support to fix FreeBSD 10.4 build error (clang 3.4.0)
- added maintainership claim in the respective patches
v9 changes:
- included header files.
- added maintainership
v8 changes:
- improve unit test case.
v7 changes:
- remove the duplicate function in unit test.
v6 changes:
- fixed build error when compiling net library as a shared library
- addressed review comments on v5, (thanks Pablo)
v5 changes:
- rebase to the master
v4 changes:
- change crc compute api parameters to make it more generic
- change the unit test to accomodate the crc compute api change
v3 changes:
- separate the x86 specific implementation into new file
- improve the unit test
v2 changes:
- fix build errors for target i686-native-linuxapp-gcc
- fix checkpatch warnings
Jasvinder Singh (2):
librte_net: add crc compute APIs
test/test: add unit test for CRC computation
MAINTAINERS | 6 + lib/Makefile | 2 +- lib/librte_net/Makefile | 2 + lib/librte_net/rte_net_crc.c | 209 +++++++++++++++++++++ lib/librte_net/rte_net_crc.h | 96 ++++++++++ lib/librte_net/rte_net_crc_sse.h | 363 +++++++++++++++++++++++++++++++++++++ lib/librte_net/rte_net_version.map | 8 + test/test/Makefile | 2 + test/test/test_crc.c | 183 +++++++++++++++++++ 9 files changed, 870 insertions(+), 1 deletion(-) create mode 100644 lib/librte_net/rte_net_crc.c create mode 100644 lib/librte_net/rte_net_crc.h create mode 100644 lib/librte_net/rte_net_crc_sse.h create mode 100644 test/test/test_crc.c
Signature · 1 line
2.5.5
PATCH v10 1/2 librte_net: add crc compute APIs
APIs for selecting the architecure specific implementation and computing the crc (16-bit and 32-bit CRCs) are added. For CRCs calculation, scalar as well as x86 intrinsic(sse4.2) versions are implemented.
The scalar version is based on generic Look-Up Table(LUT) algorithm, while x86 intrinsic version uses carry-less multiplication for fast CRC computation.
--- MAINTAINERS | 5 + lib/Makefile | 2 +- lib/librte_net/Makefile | 2 + lib/librte_net/rte_net_crc.c | 209 +++++++++++++++++++++ lib/librte_net/rte_net_crc.h | 96 ++++++++++ lib/librte_net/rte_net_crc_sse.h | 363 +++++++++++++++++++++++++++++++++++++ lib/librte_net/rte_net_version.map | 8 + 7 files changed, 684 insertions(+), 1 deletion(-) create mode 100644 lib/librte_net/rte_net_crc.c create mode 100644 lib/librte_net/rte_net_crc.h create mode 100644 lib/librte_net/rte_net_crc_sse.h
MAINTAINERS +5 -0
@@ -480,6 +480,11 @@ Network headers M: Olivier Matz <[email protected]> F: lib/librte_net/ +Packet CRC +M: Jasvinder Singh <[email protected]> +F: lib/librte_net/rte_net_crc* +F: lib/librte_net/rte_net_crc_sse.h + IP fragmentation & reassembly M: Konstantin Ananyev <[email protected]> F: lib/librte_ip_frag/
lib/Makefile +1 -1
@@ -62,7 +62,7 @@ DEPDIRS-librte_lpm := librte_eal DIRS-$(CONFIG_RTE_LIBRTE_ACL) += librte_acl DEPDIRS-librte_acl := librte_eal DIRS-$(CONFIG_RTE_LIBRTE_NET) += librte_net -DEPDIRS-librte_net := librte_mbuf +DEPDIRS-librte_net := librte_mbuf librte_eal DIRS-$(CONFIG_RTE_LIBRTE_IP_FRAG) += librte_ip_frag DEPDIRS-librte_ip_frag := librte_eal librte_mempool librte_mbuf librte_ether DEPDIRS-librte_ip_frag += librte_hash
lib/librte_net/Makefile +2 -0
@@ -39,10 +39,12 @@ EXPORT_MAP := rte_net_version.map LIBABIVER := 1 SRCS-$(CONFIG_RTE_LIBRTE_NET) := rte_net.c +SRCS-$(CONFIG_RTE_LIBRTE_NET) += rte_net_crc.c # install includes SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include := rte_ip.h rte_tcp.h rte_udp.h SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_sctp.h rte_icmp.h rte_arp.h SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_ether.h rte_gre.h rte_net.h +SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_net_crc.h include $(RTE_SDK)/mk/rte.lib.mk
lib/librte_net/rte_net_crc.c new file +209 -0
209 lines not on this page · raw message
lib/librte_net/rte_net_crc.h new file +96 -0
96 lines not on this page · raw message
lib/librte_net/rte_net_crc_sse.h new file +363 -0
363 lines not on this page · raw message
lib/librte_net/rte_net_version.map +8 -0
@@ -4,3 +4,11 @@ DPDK_16.11 { local: *; }; + +DPDK_17.05 { + global: + + rte_net_crc_calc; + rte_net_crc_set_alg; + +} DPDK_16.11;
Signature · 1 line
2.5.5
Re: [PATCH v10 1/2] librte_net: add crc compute APIs
2017-04-05 15:58, Jasvinder Singh:
Quoted 10 lines
APIs for selecting the architecure specific implementation and computing the crc (16-bit and 32-bit CRCs) are added. For CRCs calculation, scalar as well as x86 intrinsic(sse4.2) versions are implemented.
The scalar version is based on generic Look-Up Table(LUT) algorithm, while x86 intrinsic version uses carry-less multiplication for fast CRC computation.
Signed-off-by Jasvinder Singh <[email protected]>Acked-by Pablo de Lara <[email protected]>
There is a remaining error with doxygen:
lib/librte_net/rte_net_crc_sse.h:153:
warning: documented symbol `static const uint8_t crc_xmm_shift_tab' was not declared or defined.
lib/librte_net/Makefile EXPORT_MAP := rte_net_version.map · line 48
Quoted 13 lines
lib/librte_net/Makefile +2
-0@@ -39,10 +39,12 @@ EXPORT_MAP := rte_net_version.map LIBABIVER := 1 SRCS-$(CONFIG_RTE_LIBRTE_NET) := rte_net.c +SRCS-$(CONFIG_RTE_LIBRTE_NET) += rte_net_crc.c # install includes SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include := rte_ip.h rte_tcp.h rte_udp.h SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_sctp.h rte_icmp.h rte_arp.h SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_ether.h rte_gre.h rte_net.h +SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_net_crc.h
As rte_net_crc_sse.h is not exported, you should avoid doxygen generation. I suggest removing the rte_ prefix of the filename, so it will make clear that it is a private header and doxygen should ignore it (because of FILE_PATTERNS = rte_*.h).
Re: [PATCH v10 1/2] librte_net: add crc compute APIs
Hi Thomas,
Quoted 35 lines
-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Wednesday, April 5, 2017 6:50 PM
To: Singh, Jasvinder <[email protected]>
Cc: [email protected]; [email protected]; Doherty, Declan <[email protected]>; De Lara Guarch, Pablo <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v10 1/2]librte_net: add crc compute APIs2017-04-05 15:58, Jasvinder Singh:
Quoted 10 lines
APIs for selecting the architecure specific implementation and computing the crc (16-bit and 32-bit CRCs) are added. For CRCs calculation, scalar as well as x86 intrinsic(sse4.2) versions are implemented.
The scalar version is based on generic Look-Up Table(LUT) algorithm, while x86 intrinsic version uses carry-less multiplication for fast CRC computation.
Signed-off-by Jasvinder Singh <[email protected]>Acked-by Pablo de Lara <[email protected]>There is a remaining error with doxygen:
lib/librte_net/rte_net_crc_sse.h:153: warning: documented symbol `static const uint8_t
crc_xmm_shift_tab'
was not declared or defined.lib/librte_net/Makefile EXPORT_MAP := rte_net_version.map LIBABIVER
Quoted 3 lines
lib/librte_net/Makefile +0
-0@@ -39,10 +39,12 @@ EXPORT_MAP := rte_net_version.map LIBABIVER:= 1
Quoted 4 lines
lib/librte_net/Makefile +1
-0SRCS-$(CONFIG_RTE_LIBRTE_NET) := rte_net.c +SRCS-$(CONFIG_RTE_LIBRTE_NET) += rte_net_crc.c
Quoted 11 lines
Quoted 6 lines
lib/librte_net/Makefile +0
-0# install includes SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include := rte_ip.h rte_tcp.h
rte_udp.hSYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include +=rte_sctp.hrte_icmp.hrte_arp.hSYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include +=rte_ether.hrte_gre.hrte_net.h+SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include +=rte_net_crc.hAs
rte_net_crc_sse.his not exported, you should avoid doxygen generation. I suggest removing therte_prefix of the filename, so it will make clear that it is a private header and doxygen should ignore it (because ofFILE_PATTERNS= rte_*.h).
Thanks, will fix above in next version.
v11 cover librte_net: add crc computation support
In reply to Jasvinder SinghIn some applications, CRC (Cyclic Redundancy Check) needs to be computed or updated during packet processing operations. This patchset adds software implementation of some common standard CRCs (32-bit Ethernet CRC as per Ethernet/[ISO/IEC 8802-3] and 16-bit CCITT-CRC [ITU-T X.25]). Two versions of each 32-bit and 16-bit CRC calculation are proposed.
The first version presents a fast and efficient CRC generation on IA processors by using the carry-less multiplication instruction � PCLMULQDQ (i.e SSE4.2 instrinsics). In this implementation, a parallelized folding approach has been used to first reduce an arbitrary length buffer to a small fixed size length buffer (16 bytes) with the help of precomputed constants. The resultant single 16-bytes chunk is further reduced by Barrett reduction method to generate final CRC value. For more details on the implementation, see reference [1].
The second version presents the fallback solution to support the CRC generation without needing any specific support from CPU (for examples- SSE4.2 intrinsics). It is based on generic Look-Up Table(LUT) algorithm that uses precomputed 256 element table as explained in reference[2].
During intialisation, all the data structures required for CRC computation are initialised. Also, x86 specific crc implementation (if supported by the platform) or scalar version is enabled.
Following APIs have been added;
(i) rte_net_crc_set_alg()
(ii)rte_net_crc_calc()
The first API (i) allows user to select the specific CRC implementation in run-time while the second API (ii) is used for computing the 16-bit and 32-bit CRC.
References:
[1] Fast CRC Computation for Generic Polynomials Using PCLMULQDQ Instruction
http://www.intel.com/content/dam/www/public/us/en/documents/white-papers/fast-crc-computation-generic-polynomials-pclmulqdq-paper.pdf
[2] A PAINLESS GUIDE TO CRC ERROR DETECTION ALGORITHMS
http://www.ross.net/crc/download/crc_v3.txt
v11 changes:
- fixed doxygen warning
v10 changes:
- added check for PCLMULQDQ instructions support to fix FreeBSD 10.4 build error (clang 3.4.0)
v9 changes:
- included header files.
- added maintainership
v8 changes:
- improve unit test case.
v7 changes:
- remove the duplicate function in unit test.
v6 changes:
- fixed build error when compiling net library as a shared library
- addressed review comments on v5, (thanks Pablo)
v5 changes:
- rebase to the master
v4 changes:
- change crc compute api parameters to make it more generic
- change the unit test to accomodate the crc compute api change
v3 changes:
- separate the x86 specific implementation into new file
- improve the unit test
v2 changes:
- fix build errors for target i686-native-linuxapp-gcc
- fix checkpatch warnings
Jasvinder Singh (2):
librte_net: add crc compute APIs
test/test: add unit test for CRC computation
MAINTAINERS | 6 + lib/Makefile | 2 +- lib/librte_net/Makefile | 2 + lib/librte_net/net_crc_sse.h | 363 +++++++++++++++++++++++++++++++++++++ lib/librte_net/rte_net_crc.c | 207 +++++++++++++++++++++ lib/librte_net/rte_net_crc.h | 96 ++++++++++ lib/librte_net/rte_net_version.map | 8 + test/test/Makefile | 2 + test/test/test_crc.c | 183 +++++++++++++++++++ 9 files changed, 868 insertions(+), 1 deletion(-) create mode 100644 lib/librte_net/net_crc_sse.h create mode 100644 lib/librte_net/rte_net_crc.c create mode 100644 lib/librte_net/rte_net_crc.h create mode 100644 test/test/test_crc.c
Signature · 1 line
2.5.5
PATCH v11 1/2 librte_net: add crc compute APIs
APIs for selecting the architecure specific implementation and computing the crc (16-bit and 32-bit CRCs) are added. For CRCs calculation, scalar as well as x86 intrinsic(sse4.2) versions are implemented.
The scalar version is based on generic Look-Up Table(LUT) algorithm, while x86 intrinsic version uses carry-less multiplication for fast CRC computation.
--- MAINTAINERS | 5 + lib/Makefile | 2 +- lib/librte_net/Makefile | 2 + lib/librte_net/net_crc_sse.h | 363 +++++++++++++++++++++++++++++++++++++ lib/librte_net/rte_net_crc.c | 207 +++++++++++++++++++++ lib/librte_net/rte_net_crc.h | 96 ++++++++++ lib/librte_net/rte_net_version.map | 8 + 7 files changed, 682 insertions(+), 1 deletion(-) create mode 100644 lib/librte_net/net_crc_sse.h create mode 100644 lib/librte_net/rte_net_crc.c create mode 100644 lib/librte_net/rte_net_crc.h
MAINTAINERS +5 -0
@@ -480,6 +480,11 @@ Network headers M: Olivier Matz <[email protected]> F: lib/librte_net/ +Packet CRC +M: Jasvinder Singh <[email protected]> +F: lib/librte_net/rte_net_crc* +F: lib/librte_net/net_crc_sse.h + IP fragmentation & reassembly M: Konstantin Ananyev <[email protected]> F: lib/librte_ip_frag/
lib/Makefile +1 -1
@@ -62,7 +62,7 @@ DEPDIRS-librte_lpm := librte_eal DIRS-$(CONFIG_RTE_LIBRTE_ACL) += librte_acl DEPDIRS-librte_acl := librte_eal DIRS-$(CONFIG_RTE_LIBRTE_NET) += librte_net -DEPDIRS-librte_net := librte_mbuf +DEPDIRS-librte_net := librte_mbuf librte_eal DIRS-$(CONFIG_RTE_LIBRTE_IP_FRAG) += librte_ip_frag DEPDIRS-librte_ip_frag := librte_eal librte_mempool librte_mbuf librte_ether DEPDIRS-librte_ip_frag += librte_hash
lib/librte_net/Makefile +2 -0
@@ -39,10 +39,12 @@ EXPORT_MAP := rte_net_version.map LIBABIVER := 1 SRCS-$(CONFIG_RTE_LIBRTE_NET) := rte_net.c +SRCS-$(CONFIG_RTE_LIBRTE_NET) += rte_net_crc.c # install includes SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include := rte_ip.h rte_tcp.h rte_udp.h SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_sctp.h rte_icmp.h rte_arp.h SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_ether.h rte_gre.h rte_net.h +SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_net_crc.h include $(RTE_SDK)/mk/rte.lib.mk
lib/librte_net/net_crc_sse.h new file +363 -0
363 lines not on this page · raw message
lib/librte_net/rte_net_crc.c new file +207 -0
207 lines not on this page · raw message
lib/librte_net/rte_net_crc.h new file +96 -0
96 lines not on this page · raw message
lib/librte_net/rte_net_version.map +8 -0
@@ -4,3 +4,11 @@ DPDK_16.11 { local: *; }; + +DPDK_17.05 { + global: + + rte_net_crc_calc; + rte_net_crc_set_alg; + +} DPDK_16.11;
Signature · 1 line
2.5.5
PATCH v11 2/2 test/test: add unit test for CRC computation
In reply to Jasvinder SinghThis patch provides a set of tests for verifying the functional correctness of 16-bit and 32-bit CRC APIs.
--- MAINTAINERS | 1 + test/test/Makefile | 2 + test/test/test_crc.c | 183 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 186 insertions(+) create mode 100644 test/test/test_crc.c
MAINTAINERS +1 -0
@@ -484,6 +484,7 @@ Packet CRC M: Jasvinder Singh <[email protected]> F: lib/librte_net/rte_net_crc* F: lib/librte_net/net_crc_sse.h +F: test/test/test_crc.c IP fragmentation & reassembly M: Konstantin Ananyev <[email protected]>
test/test/Makefile +2 -0
@@ -160,6 +160,8 @@ SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += test_cmdline_cirbuf.c SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += test_cmdline_string.c SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += test_cmdline_lib.c +SRCS-$(CONFIG_RTE_LIBRTE_NET) += test_crc.c + ifeq ($(CONFIG_RTE_LIBRTE_SCHED),y) SRCS-y += test_red.c SRCS-y += test_sched.c
test/test/test_crc.c new file +183 -0
183 lines not on this page · raw message
Signature · 1 line
2.5.5
Re: [PATCH v11 2/2] test/test: add unit test for CRC computation
2017-04-05 21:49, Jasvinder Singh:
Quoted 5 lines
This patch provides a set of tests for verifying the functional correctness of 16-bit and 32-bit CRC APIs.
Signed-off-by Jasvinder Singh <[email protected]>Acked-by Pablo de Lara <[email protected]>
Now first patch is fine but this one has an issue:
test_crc.c:88:2: fatal error:
implicit declaration of function 'rte_hexdump' is invalid in C99
TEST_HEXDUMP(stdout, NULL, vec, vec_len);
It is fixed by adding
#include <rte_hexdump.h>
2017-04-05 21:49, Jasvinder Singh:
Quoted 15 lines
In some applications, CRC (Cyclic Redundancy Check) needs to be computed or updated during packet processing operations. This patchset adds software implementation of some common standard CRCs (32-bit Ethernet CRC as per Ethernet/[ISO/IEC 8802-3] and 16-bit CCITT-CRC [ITU-T X.25]). Two versions of each 32-bit and 16-bit CRC calculation are proposed.
The first version presents a fast and efficient CRC generation on IA processors by using the carry-less multiplication instruction � PCLMULQDQ (i.e SSE4.2 instrinsics). In this implementation, a parallelized folding approach has been used to first reduce an arbitrary length buffer to a small fixed size length buffer (16 bytes) with the help of precomputed constants. The resultant single 16-bytes chunk is further reduced by Barrett reduction method to generate final CRC value. For more details on the implementation, see reference [1].
Quoted 8 lines
The second version presents the fallback solution to support the CRC generation without needing any specific support from CPU (for examples- SSE4.2 intrinsics). It is based on generic Look-Up Table(LUT) algorithm that uses precomputed 256 element table as explained in reference[2].
During intialisation, all the data structures required for CRC computation are initialised. Also, x86 specific crc implementation (if supported by the platform) or scalar version is enabled.
Applied (with one last fix), thanks
PATCH v10 2/2 test/test: add unit test for CRC computation
In reply to Jasvinder SinghThis patch provides a set of tests for verifying the functional correctness of 16-bit and 32-bit CRC APIs.
--- MAINTAINERS | 1 + test/test/Makefile | 2 + test/test/test_crc.c | 183 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 186 insertions(+) create mode 100644 test/test/test_crc.c
MAINTAINERS +1 -0
@@ -484,6 +484,7 @@ Packet CRC M: Jasvinder Singh <[email protected]> F: lib/librte_net/rte_net_crc* F: lib/librte_net/rte_net_crc_sse.h +F: test/test/test_crc.c IP fragmentation & reassembly M: Konstantin Ananyev <[email protected]>
test/test/Makefile +2 -0
@@ -160,6 +160,8 @@ SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += test_cmdline_cirbuf.c SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += test_cmdline_string.c SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += test_cmdline_lib.c +SRCS-$(CONFIG_RTE_LIBRTE_NET) += test_crc.c + ifeq ($(CONFIG_RTE_LIBRTE_SCHED),y) SRCS-y += test_red.c SRCS-y += test_sched.c
test/test/test_crc.c new file +183 -0
183 lines not on this page · raw message
Signature · 1 line
2.5.5
PATCH v9 2/3 test/test: add unit test for CRC computation
In reply to Jasvinder SinghThis patch provides a set of tests for verifying the functional correctness of 16-bit and 32-bit CRC APIs.
--- test/test/Makefile | 2 + test/test/test_crc.c | 183 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 185 insertions(+) create mode 100644 test/test/test_crc.c
test/test/Makefile +2 -0
@@ -160,6 +160,8 @@ SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += test_cmdline_cirbuf.c SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += test_cmdline_string.c SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += test_cmdline_lib.c +SRCS-$(CONFIG_RTE_LIBRTE_NET) += test_crc.c + ifeq ($(CONFIG_RTE_LIBRTE_SCHED),y) SRCS-y += test_red.c SRCS-y += test_sched.c
test/test/test_crc.c new file +183 -0
183 lines not on this page · raw message
Signature · 1 line
2.5.5
PATCH v9 3/3 maintainers: add packet crc section and claim maintainership
In reply to Jasvinder Singh--- MAINTAINERS | 6 ++++++ 1 file changed, 6 insertions(+)
MAINTAINERS +6 -0
@@ -480,6 +480,12 @@ Network headers M: Olivier Matz <[email protected]> F: lib/librte_net/ +Packet CRC +M: Jasvinder Singh <[email protected]> +F: lib/librte_net/rte_net_crc* +F: lib/librte_net/rte_net_crc_sse.h +F: test/test/test_crc.c + IP fragmentation & reassembly M: Konstantin Ananyev <[email protected]> F: lib/librte_ip_frag/
Signature · 1 line
2.5.5
Re: [PATCH v9 3/3] maintainers: add packet crc section and claim maintainership
2017-03-30 17:15, Jasvinder Singh:
MAINTAINERS Network headers · line 486
Quoted 4 lines
MAINTAINERS +4
-0+Packet CRC +M: Jasvinder Singh <[email protected]> +F: lib/librte_net/rte_net_crc* +F: lib/librte_net/rte_net_crc_sse.h
The above lines should be in the first patch.
Quoted 1 line
+F:
test/test/test_crc.c
This line should be in the second patch.
2017-03-30 17:15, Jasvinder Singh:
Quoted 15 lines
In some applications, CRC (Cyclic Redundancy Check) needs to be computed or updated during packet processing operations. This patchset adds software implementation of some common standard CRCs (32-bit Ethernet CRC as per Ethernet/[ISO/IEC 8802-3] and 16-bit CCITT-CRC [ITU-T X.25]). Two versions of each 32-bit and 16-bit CRC calculation are proposed.
The first version presents a fast and efficient CRC generation on IA processors by using the carry-less multiplication instruction � PCLMULQDQ (i.e SSE4.2 instrinsics). In this implementation, a parallelized folding approach has been used to first reduce an arbitrary length buffer to a small fixed size length buffer (16 bytes) with the help of precomputed constants. The resultant single 16-bytes chunk is further reduced by Barrett reduction method to generate final CRC value. For more details on the implementation, see reference [1].
Quoted 8 lines
The second version presents the fallback solution to support the CRC generation without needing any specific support from CPU (for examples- SSE4.2 intrinsics). It is based on generic Look-Up Table(LUT) algorithm that uses precomputed 256 element table as explained in reference[2].
During intialisation, all the data structures required for CRC computation are initialised. Also, x86 specific crc implementation (if supported by the platform) or scalar version is enabled.
As you can see in patchwork, it does not compile on FreeBSD:
http://dpdk.org/ml/archives/test-report/2017-April/016943.html
Hi Thomas,
Quoted 33 lines
-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Tuesday, April 4, 2017 9:02 PM
To: Singh, Jasvinder <[email protected]>
Cc: [email protected]; [email protected]; Doherty, Declan <[email protected]>; De Lara Guarch, Pablo <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v9 0/3]librte_net: add crc computation support2017-03-30 17:15, Jasvinder Singh:
Quoted 4 lines
In some applications, CRC (Cyclic Redundancy Check) needs to be computed or updated during packet processing operations. This patchset adds software implementation of some common standard CRCs (32-bit Ethernet CRC as per Ethernet/[ISO/IEC 8802-3] and 16-bit CCITT-CRC [ITU-T
X.25]).
Quoted 7 lines
Two versions of each 32-bit and 16-bit CRC calculation are proposed.
The first version presents a fast and efficient CRC generation on IA processors by using the carry-less multiplication instruction PCLMULQDQ (i.e SSE4.2 instrinsics). In this implementation, a parallelized folding approach has been used to first reduce an arbitrary length buffer to a small fixed size length buffer (16 bytes) with the
help of precomputed constants.
Quoted 9 lines
The resultant single 16-bytes chunk is further reduced by Barrett reduction method to generate final CRC value. For more details on the implementation, see reference [1].
The second version presents the fallback solution to support the CRC generation without needing any specific support from CPU (for examples-
SSE4.2 intrinsics). It is based on generic Look-Up Table(LUT) algorithm that uses precomputed 256 element table as explained in
Quoted 8 lines
reference[2].
Quoted 4 lines
During intialisation, all the data structures required for CRC computation are initialised. Also, x86 specific crc implementation (if supported by the platform) or scalar version is enabled.
As you can see in patchwork, it does not compile on FreeBSD:
http://dpdk.org/ml/archives/test-report/2017-April/016943.html
As I stated in the cover letter notes as well that The patchset build fails on clang version earlier than 3.7.0 due to missing intrinsics and this issue is listed in DPDK known issue section. FreeBSD build on gcc target should work fine.
Jasvinder
2017-04-05 08:34, Singh, Jasvinder:
Quoted 32 lines
Hi Thomas,
From: Thomas Monjalon [mailto:[email protected]]
Quoted 29 lines
2017-03-30 17:15, Jasvinder Singh:
Quoted 4 lines
In some applications, CRC (Cyclic Redundancy Check) needs to be computed or updated during packet processing operations. This patchset adds software implementation of some common standard CRCs (32-bit Ethernet CRC as per Ethernet/[ISO/IEC 8802-3] and 16-bit CCITT-CRC [ITU-T
X.25]).
Quoted 7 lines
Two versions of each 32-bit and 16-bit CRC calculation are proposed.
The first version presents a fast and efficient CRC generation on IA processors by using the carry-less multiplication instruction PCLMULQDQ (i.e SSE4.2 instrinsics). In this implementation, a parallelized folding approach has been used to first reduce an arbitrary length buffer to a small fixed size length buffer (16 bytes) with the
help of precomputed constants.
Quoted 9 lines
The resultant single 16-bytes chunk is further reduced by Barrett reduction method to generate final CRC value. For more details on the implementation, see reference [1].
The second version presents the fallback solution to support the CRC generation without needing any specific support from CPU (for examples-
SSE4.2 intrinsics). It is based on generic Look-Up Table(LUT) algorithm that uses precomputed 256 element table as explained inreference[2].
Quoted 4 lines
During intialisation, all the data structures required for CRC computation are initialised. Also, x86 specific crc implementation (if supported by the platform) or scalar version is enabled.
Quoted 5 lines
Quoted 2 lines
As you can see in patchwork, it does not compile on FreeBSD:
http://dpdk.org/ml/archives/test-report/2017-April/016943.htmlAs I stated in the cover letter notes as well that The patchset build fails on clang version earlier than 3.7.0 due to missing intrinsics and this issue is listed in DPDK known issue section. FreeBSD build on gcc target should work fine.
Ah, I have not seen this explanation.
However, we cannot let the build fails.
It is a blocker for patch admission.
Can you, at least, disable the code for some compiler versions?
Quoted 55 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Thomas Monjalon
Sent: Wednesday, April 5, 2017 10:01 AM
To: Singh, Jasvinder <[email protected]>
Cc: [email protected]; [email protected]; Doherty, Declan <[email protected]>; De Lara Guarch, Pablo <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v9 0/3]librte_net: add crc computation support2017-04-05 08:34, Singh, Jasvinder:
Quoted 34 lines
Hi Thomas,
From: Thomas Monjalon [mailto:[email protected]]
Quoted 31 lines
2017-03-30 17:15, Jasvinder Singh:
Quoted 5 lines
In some applications, CRC (Cyclic Redundancy Check) needs to be computed or updated during packet processing operations. This patchset adds software implementation of some common standard CRCs (32-bit Ethernet CRC as per Ethernet/[ISO/IEC 8802-3] and 16-bit CCITT-CRC [ITU-T
X.25]).
Quoted 8 lines
Two versions of each 32-bit and 16-bit CRC calculation are proposed.
The first version presents a fast and efficient CRC generation on IA processors by using the carry-less multiplication instruction PCLMULQDQ (i.e SSE4.2 instrinsics). In this implementation, a parallelized folding approach has been used to first reduce an arbitrary length buffer to a small fixed size length buffer (16 bytes) with the
help of precomputed constants.
Quoted 9 lines
The resultant single 16-bytes chunk is further reduced by Barrett reduction method to generate final CRC value. For more details on the implementation, see reference [1].
The second version presents the fallback solution to support the CRC generation without needing any specific support from CPU (for examples-
SSE4.2 intrinsics). It is based on generic Look-Up Table(LUT) algorithm that uses precomputed 256 element table as explained inreference[2].
Quoted 4 lines
During intialisation, all the data structures required for CRC computation are initialised. Also, x86 specific crc implementation (if supported by the platform) or scalar version is enabled.
Quoted 5 lines
Quoted 2 lines
As you can see in patchwork, it does not compile on FreeBSD:
http://dpdk.org/ml/archives/test-report/2017-April/016943.htmlAs I stated in the cover letter notes as well that The patchset build fails on clang version earlier than 3.7.0 due to missing intrinsics and
this issue is listed in DPDK known issue section. FreeBSD build on gcc target should work fine.
Quoted 6 lines
Ah, I have not seen this explanation.
However, we cannot let the build fails.
It is a blocker for patch admission.Can you, at least, disable the code for some compiler versions?
Hi Jasvinder,
Any chance a work-around for this issue. The default compiler on BSD is clang, and the BSD 10 series of releases uses v3.4. This means this functionality will be unavailable for anyone using DPDK from BSD ports on BSD 10.
/Bruce
Hi Bruce,
Quoted 78 lines
-----Original Message-----
From: Richardson, Bruce
Sent: Wednesday, April 5, 2017 10:37 AM
To: Thomas Monjalon <[email protected]>; Singh, Jasvinder <[email protected]>
Cc: [email protected]; [email protected]; Doherty, Declan <[email protected]>; De Lara Guarch, Pablo <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v9 0/3]librte_net: add crc computation supportQuoted 10 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Thomas Monjalon
Sent: Wednesday, April 5, 2017 10:01 AM
To: Singh, Jasvinder <[email protected]>
Cc: [email protected]; [email protected]; Doherty, Declan <[email protected]>; De Lara Guarch, Pablo <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v9 0/3]librte_net: add crc computation supportQuoted 37 lines
2017-04-05 08:34, Singh, Jasvinder:
Quoted 36 lines
Hi Thomas,
From: Thomas Monjalon [mailto:[email protected]]
Quoted 33 lines
2017-03-30 17:15, Jasvinder Singh:
Quoted 5 lines
In some applications, CRC (Cyclic Redundancy Check) needs to be computed or updated during packet processing operations. This patchset adds software implementation of some common standard CRCs (32-bit Ethernet CRC as per Ethernet/[ISO/IEC 8802-3] and 16-bit CCITT-CRC [ITU-T
X.25]).
Quoted 9 lines
Two versions of each 32-bit and 16-bit CRC calculation are proposed.
The first version presents a fast and efficient CRC generation on IA processors by using the carry-less multiplication instruction PCLMULQDQ (i.e SSE4.2 instrinsics). In this implementation, a parallelized folding approach has been used to first reduce an arbitrary length buffer to a small fixed size length buffer (16
bytes) with thehelp of precomputed constants.
Quoted 11 lines
The resultant single 16-bytes chunk is further reduced by Barrett reduction method to generate final CRC value. For more details on the implementation, see reference [1].
The second version presents the fallback solution to support the CRC generation without needing any specific support from CPU (for
examples-
SSE4.2 intrinsics). It is based on generic Look-Up Table(LUT) algorithm that uses precomputed 256 element table as explained inreference[2].
Quoted 4 lines
During intialisation, all the data structures required for CRC computation are initialised. Also, x86 specific crc implementation (if supported by the platform) or scalar version is
enabled.
Quoted 10 lines
Quoted 7 lines
Quoted 3 lines
As you can see in patchwork, it does not compile on FreeBSD:
http://dpdk.org/ml/archives/test-report/2017-April/016943.htmlAs I stated in the cover letter notes as well that The patchset build fails on clang version earlier than 3.7.0 due to missing intrinsics and
this issue is listed in DPDK known issue section. FreeBSD build on gcc target should work fine.
Quoted 6 lines
Ah, I have not seen this explanation.
However, we cannot let the build fails.
It is a blocker for patch admission.Can you, at least, disable the code for some compiler versions?
Quoted 8 lines
Hi Jasvinder,
Any chance a work-around for this issue. The default compiler on BSD is clang, and the BSD 10 series of releases uses v3.4. This means this functionality will be unavailable for anyone using DPDK from BSD ports on BSD 10.
/Bruce
I will have a look at this and send another version with fix.
Jasvinder
PATCH v8 2/2 test/test: add unit test for CRC computation
In reply to Jasvinder SinghThis patch provides a set of tests for verifying the functional correctness of 16-bit and 32-bit CRC APIs.
--- test/test/Makefile | 2 + test/test/test_crc.c | 182 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 184 insertions(+) create mode 100644 test/test/test_crc.c
test/test/Makefile +2 -0
@@ -160,6 +160,8 @@ SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += test_cmdline_cirbuf.c SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += test_cmdline_string.c SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += test_cmdline_lib.c +SRCS-$(CONFIG_RTE_LIBRTE_NET) += test_crc.c + ifeq ($(CONFIG_RTE_LIBRTE_SCHED),y) SRCS-y += test_red.c SRCS-y += test_sched.c
test/test/test_crc.c new file +182 -0
182 lines not on this page · raw message
Signature · 1 line
2.5.5
PATCH v7 2/2 test/test: add unit test for CRC computation
In reply to Jasvinder SinghThis patch provides a set of tests for verifying the functional correctness of 16-bit and 32-bit CRC APIs.
--- test/test/Makefile | 2 + test/test/test_crc.c | 173 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 175 insertions(+) create mode 100644 test/test/test_crc.c
test/test/Makefile +2 -0
@@ -160,6 +160,8 @@ SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += test_cmdline_cirbuf.c SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += test_cmdline_string.c SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += test_cmdline_lib.c +SRCS-$(CONFIG_RTE_LIBRTE_NET) += test_crc.c + ifeq ($(CONFIG_RTE_LIBRTE_SCHED),y) SRCS-y += test_red.c SRCS-y += test_sched.c
test/test/test_crc.c new file +173 -0
173 lines not on this page · raw message
Signature · 1 line
2.5.5
PATCH v6 2/2 test/test: add unit test for CRC computation
In reply to Jasvinder SinghThis patch provides a set of tests for verifying the functional correctness of 16-bit and 32-bit CRC APIs.
--- test/test/Makefile | 2 + test/test/test_crc.c | 241 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 243 insertions(+) create mode 100644 test/test/test_crc.c
test/test/Makefile +2 -0
@@ -160,6 +160,8 @@ SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += test_cmdline_cirbuf.c SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += test_cmdline_string.c SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += test_cmdline_lib.c +SRCS-$(CONFIG_RTE_LIBRTE_NET) += test_crc.c + ifeq ($(CONFIG_RTE_LIBRTE_SCHED),y) SRCS-y += test_red.c SRCS-y += test_sched.c
test/test/test_crc.c new file +241 -0
241 lines not on this page · raw message
Signature · 1 line
2.5.5
Re: [PATCH v6 2/2] test/test: add unit test for CRC computation
Hi Jasvinder,
Quoted 18 lines
-----Original Message-----
From: Singh, Jasvinder
Sent: Wednesday, March 29, 2017 1:42 PM
To: [email protected]
Cc: [email protected]; Doherty, Declan; De Lara Guarch, Pablo
Subject: [PATCH v6 2/2] test/test: add unit test for CRC computationThis patch provides a set of tests for verifying the functional correctness of 16-bit and 32-bit CRC APIs.
Signed-off-by Jasvinder Singh <[email protected]>--- test/test/Makefile | 2 + test/test/test_crc.c | 241 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 243 insertions(+) create mode 100644 test/test/test_crc.c
...
Quoted 6 lines
test/test/test_crc.c new file +0
-0@@ -0,0 +1,241 @@
...
test/test/test_crc.c
Quoted 2 lines
test/test/test_crc.c new file +2
-0+static int +test_crc_scalar (void )
Could you merge this and the next function in a single one,
as they are duplicated (except for the comments/printfs, which can be a parameter of the function).
Apart from this:
PATCH v5 2/2 test/test: add unit test for CRC computation
In reply to Jasvinder SinghThis patch provides a set of tests for verifying the functional correctness of 16-bit and 32-bit CRC APIs.
--- test/test/Makefile | 2 + test/test/test_crc.c | 223 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 225 insertions(+) create mode 100644 test/test/test_crc.c
test/test/Makefile +2 -0
@@ -160,6 +160,8 @@ SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += test_cmdline_cirbuf.c SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += test_cmdline_string.c SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += test_cmdline_lib.c +SRCS-$(CONFIG_RTE_LIBRTE_NET) += test_crc.c + ifeq ($(CONFIG_RTE_LIBRTE_SCHED),y) SRCS-y += test_red.c SRCS-y += test_sched.c
test/test/test_crc.c new file +223 -0
223 lines not on this page · raw message
Signature · 1 line
2.5.5
Re: [PATCH v5 2/2] test/test: add unit test for CRC computation
Hi Jasvinder,
Quoted 25 lines
-----Original Message-----
From: Singh, Jasvinder
Sent: Tuesday, March 21, 2017 2:46 PM
To: [email protected]
Cc: [email protected]; Doherty, Declan; De Lara Guarch, Pablo
Subject: [PATCH v5 2/2] test/test: add unit test for CRC computationThis patch provides a set of tests for verifying the functional correctness of 16-bit and 32-bit CRC APIs.
Signed-off-by Jasvinder Singh <[email protected]>--- test/test/Makefile | 2 + test/test/test_crc.c | 223 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 225 insertions(+) create mode 100644 test/test/test_crc.ctest/test/test_crc.c new file +0
-0
test/test/test_crc.c line 40
Quoted 6 lines
test/test/test_crc.c new file +4
-0@@ -0,0 +1,223 @@ + +#include "test.h" + +#define CRC_VEC_LEN 32
Unnecessary extra tab.
test/test/test_crc.c line 45
Quoted 5 lines
test/test/test_crc.c new file +5
-0+#define CRC32_VEC_LEN1 1512 +#define CRC32_VEC_LEN2 348 +#define CRC16_VEC_LEN1 12 +#define CRC16_VEC_LEN2 2 +#define LINE_LEN 75
I would align this to the other values above.
...
test/test/test_crc.c
Quoted 2 lines
test/test/test_crc.c new file +2
-0+ +/* 16-bit CRC test vector 1*/
Extra space before "*/".
test/test/test_crc.c line 67
Quoted 6 lines
test/test/test_crc.c new file +6
-0+static const uint8_t crc16_vec1[CRC16_VEC_LEN1 ] = { +0x0D ,0x01 ,0x01 ,0x23 ,0x45 ,0x67 , +0x89 ,0x01 ,0x23 ,0x45 ,0x00 ,0x01 , +}; + +/* 16-bit CRC test vector 2*/
Same here.
Quoted 6 lines
test/test/test_crc.c new file +6
-0+static const uint8_t crc16_vec2[CRC16_VEC_LEN2 ] = { +0x03 ,0x3f , +}; +/** CRC results */ +uint32_t crc32_vec_res, crc32_vec1_res, crc32_vec2_res; +uint32_t crc16_vec_res, crc16_vec1_res, crc16_vec2_res;
test/test/test_crc.c line 83
Quoted 10 lines
test/test/test_crc.c new file +10
-0+ +static int +crc_calc (const uint8_t *vec, +uint32_t vec_len, +enum rte_net_crc_type type) +{ +/* compute CRC */ +uint32_t ret =rte_net_crc_calc (vec, vec_len, type); + +/* dump data on console*/
Same here.
test/test/test_crc.c line 84
Quoted 1 line
test/test/test_crc.c new file +1
-0+rte_hexdump (stdout,NULL , vec, vec_len);
I would use TEST_HEXDUMP, which dumps the stream only if debug is enabled (to avoid too much output).
Quoted 6 lines
test/test/test_crc.c new file +6
-0+ +return ret; +} + +static void +crc_calc_scalar (void )
test/test/test_crc.c line 100
Quoted 10 lines
test/test/test_crc.c new file +10
-0+{ +uint32_t i; +enum rte_net_crc_type type; +uint8_t *test_data; + +/* 32-bit ethernet CRC: scalar result */ + type =RTE_NET_CRC32_ETH ; + crc32_vec_res =crc_calc (crc_vec, +CRC_VEC_LEN , + type);
Remove unnecessary tabs (more of this in the rest of the file).
test/test/test_crc.c line 106
Quoted 6 lines
test/test/test_crc.c new file +6
-0+ +/* 32-bit ethernet CRC scalar result*/ + test_data =rte_zmalloc (NULL ,CRC32_VEC_LEN1 ,0 ); + +for (i =0 ; i <CRC32_VEC_LEN1 ; i +=12 ) +rte_memcpy (&test_data[i], crc32_vec1,12 );
Wrong indentation (more of this in the rest of the file). Also, why not just one memcpy call, with CRC32_VEC_LEN1. A comment would be good to explain why.
...
test/test/test_crc.c line 140
Quoted 2 lines
test/test/test_crc.c new file +2
-0+static int +test_crc (void ) {
Looks strange to start the parameters in a new line.
I would say you can start in the same line as the function name.
test/test/test_crc.c line 146
Quoted 6 lines
test/test/test_crc.c new file +6
-0+uint32_t i; +enum rte_net_crc_type type; +uint8_t *test_data; +uint32_t ret; + +/* set crc scalar mode */
Probably the references of "crc" in comments should be uppercase "CRC".
Quoted 4 lines
test/test/test_crc.c new file +4
-0+rte_net_crc_set_alg (RTE_NET_CRC_SCALAR ); +crc_calc_scalar (); + +/* set crc sse4.2 mode */
test/test/test_crc.c line 160
Quoted 10 lines
test/test/test_crc.c new file +10
-0+rte_net_crc_set_alg (RTE_NET_CRC_SSE42 ); + +/* 32-bit ethernet CRC: Test 1 */ + type =RTE_NET_CRC32_ETH ; + + ret =crc_calc (crc_vec, +CRC_VEC_LEN , + type); +if (ret != crc32_vec_res) { +printf ("test_crc(32-bit): test1 failed !\n" );
Extra space before "!" (keep consistency with the other printfs).
test/test/test_crc.c line 165
Quoted 5 lines
test/test/test_crc.c new file +5
-0+return -1 ; + } + +/* 32-bit ethernet CRC: Test 2 */ + test_data =rte_zmalloc (NULL ,CRC32_VEC_LEN1 ,0 );
Free the memory after the test (also for other calls).
Re: [PATCH v5 2/2] test/test: add unit test for CRC computation
Hi Pablo,
Quoted 155 lines
-----Original Message-----
From: De Lara Guarch, Pablo
Sent: Tuesday, March 28, 2017 8:23 PM
To: Singh, Jasvinder <[email protected]>; [email protected]
Cc: [email protected]; Doherty, Declan <[email protected]>
Subject: RE: [PATCH v5 2/2] test/test: add unit test for CRC computationHi Jasvinder,
Quoted 24 lines
-----Original Message-----
From: Singh, Jasvinder
Sent: Tuesday, March 21, 2017 2:46 PM
To: [email protected]
Cc: [email protected]; Doherty, Declan; De Lara Guarch, Pablo
Subject: [PATCH v5 2/2] test/test: add unit test for CRC computationThis patch provides a set of tests for verifying the functional correctness of 16-bit and 32-bit CRC APIs.
Signed-off-by Jasvinder Singh <[email protected]>--- test/test/Makefile | 2 + test/test/test_crc.c | 223 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 225 insertions(+) create mode 100644 test/test/test_crc.ctest/test/test_crc.c new file mode renamed from test/test/test_crc.c +0
-0100644 index 0000000..2eb0bff
test/test/test_crc.c line 40
Quoted 6 lines
test/test/test_crc.c new file +4
-0@@ -0,0 +1,223 @@ + +#include "test.h" + +#define CRC_VEC_LEN 32Unnecessary extra tab.
test/test/test_crc.c line 45
Quoted 5 lines
test/test/test_crc.c new file +5
-0+#define CRC32_VEC_LEN1 1512 +#define CRC32_VEC_LEN2 348 +#define CRC16_VEC_LEN1 12 +#define CRC16_VEC_LEN2 2 +#define LINE_LEN 75I would align this to the other values above.
...
test/test/test_crc.c
Quoted 2 lines
test/test/test_crc.c new file +2
-0+ +/* 16-bit CRC test vector 1*/ Extra space before "*/".
test/test/test_crc.c line 67
Quoted 6 lines
test/test/test_crc.c new file +6
-0+static const uint8_t crc16_vec1[CRC16_VEC_LEN1 ] = { +0x0D ,0x01 ,0x01 ,0x23 ,0x45 ,0x67 , +0x89 ,0x01 ,0x23 ,0x45 ,0x00 ,0x01 , +}; + +/* 16-bit CRC test vector 2*/ Same here.
Quoted 6 lines
test/test/test_crc.c new file +6
-0+static const uint8_t crc16_vec2[CRC16_VEC_LEN2 ] = { +0x03 ,0x3f , +}; +/** CRC results */ +uint32_t crc32_vec_res, crc32_vec1_res, crc32_vec2_res;uint32_t +crc16_vec_res, crc16_vec1_res, crc16_vec2_res;test/test/test_crc.c line 83
Quoted 10 lines
test/test/test_crc.c new file +10
-0+ +static int +crc_calc (const uint8_t *vec, +uint32_t vec_len, +enum rte_net_crc_type type) +{ +/* compute CRC */ +uint32_t ret =rte_net_crc_calc (vec, vec_len, type); + +/* dump data on console*/ Same here.
test/test/test_crc.c line 84
Quoted 1 line
test/test/test_crc.c new file +1
-0+rte_hexdump (stdout,NULL , vec, vec_len);I would use
TEST_HEXDUMP, which dumps the stream only if debug is enabled (to avoid too much output).Quoted 6 lines
test/test/test_crc.c new file +6
-0+ +return ret; +} + +static void +crc_calc_scalar (void )test/test/test_crc.c line 100
Quoted 10 lines
test/test/test_crc.c new file +10
-0+{ +uint32_t i; +enum rte_net_crc_type type; +uint8_t *test_data; + +/* 32-bit ethernet CRC: scalar result */ + type =RTE_NET_CRC32_ETH ; + crc32_vec_res =crc_calc (crc_vec, +CRC_VEC_LEN , + type);Remove unnecessary tabs (more of this in the rest of the file).
test/test/test_crc.c line 106
Quoted 6 lines
test/test/test_crc.c new file +6
-0+ +/* 32-bit ethernet CRC scalar result*/ + test_data =rte_zmalloc (NULL ,CRC32_VEC_LEN1 ,0 ); + +for (i =0 ; i <CRC32_VEC_LEN1 ; i +=12 ) +rte_memcpy (&test_data[i], crc32_vec1,12 );Wrong indentation (more of this in the rest of the file). Also, why not just one memcpy call, with
CRC32_VEC_LEN1. A comment would be good to explain why....
test/test/test_crc.c line 140
Quoted 2 lines
test/test/test_crc.c new file +2
-0+static int +test_crc (void ) {Looks strange to start the parameters in a new line.
I would say you can start in the same line as the function name.test/test/test_crc.c line 146
Quoted 6 lines
test/test/test_crc.c new file +6
-0+uint32_t i; +enum rte_net_crc_type type; +uint8_t *test_data; +uint32_t ret; + +/* set crc scalar mode */ Probably the references of "crc" in comments should be uppercase "CRC".
Quoted 4 lines
test/test/test_crc.c new file +4
-0+rte_net_crc_set_alg (RTE_NET_CRC_SCALAR ); +crc_calc_scalar (); + +/* set crc sse4.2 mode */ test/test/test_crc.c line 160
Quoted 10 lines
test/test/test_crc.c new file +10
-0+rte_net_crc_set_alg (RTE_NET_CRC_SSE42 ); + +/* 32-bit ethernet CRC: Test 1 */ + type =RTE_NET_CRC32_ETH ; + + ret =crc_calc (crc_vec, +CRC_VEC_LEN , + type); +if (ret != crc32_vec_res) { +printf ("test_crc(32-bit): test1 failed !\n" );Extra space before "!" (keep consistency with the other printfs).
Quoted 7 lines
test/test/test_crc.c line 165
Quoted 5 lines
test/test/test_crc.c new file +5
-0+return -1 ; + } + +/* 32-bit ethernet CRC: Test 2 */ + test_data =rte_zmalloc (NULL ,CRC32_VEC_LEN1 ,0 );Free the memory after the test (also for other calls).
Will correct the patch and send the next version. Thank you.
Jasvinder
PATCH v4 2/2 app/test: add unit test for CRC computation
In reply to Jasvinder SinghThis patch provides a set of tests for verifying the functional correctness of 16-bit and 32-bit CRC APIs.
--- app/test/Makefile | 2 + app/test/test_crc.c | 223 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 225 insertions(+) create mode 100644 app/test/test_crc.c
app/test/Makefile +2 -0
@@ -160,6 +160,8 @@ SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += test_cmdline_cirbuf.c SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += test_cmdline_string.c SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += test_cmdline_lib.c +SRCS-$(CONFIG_RTE_LIBRTE_NET) += test_crc.c + ifeq ($(CONFIG_RTE_LIBRTE_SCHED),y) SRCS-y += test_red.c SRCS-y += test_sched.c
app/test/test_crc.c new file +223 -0
223 lines not on this page · raw message
Signature · 1 line
2.5.5
Re: [PATCH v4 2/2] app/test: add unit test for CRC computation
Hi Singh,
The second patch cannot be applied, since the test folder has moved to the DPDK root directory.
[root@localhost dpdk]# git apply dpdk-dev-v4-2-2-app-test-add-unit-test-for-CRC-computation.patch
error: app/test/Makefile: No such file or directory
Thank you.
Yuan.
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Jasvinder Singh
Sent: Tuesday, March 21, 2017 3:30 AM
To: [email protected]
Cc: Doherty, Declan <[email protected]>; De Lara Guarch, Pablo <[email protected]>
Subject: [dpdk-dev] [PATCH v4 2/2] app/test: add unit test for CRC computation
This patch provides a set of tests for verifying the functional correctness of 16-bit and 32-bit CRC APIs.
--- app/test/Makefile | 2 + app/test/test_crc.c | 223 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 225 insertions(+) create mode 100644 app/test/test_crc.c
app/test/Makefile +2 -0
@@ -160,6 +160,8 @@ SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += test_cmdline_cirbuf.c SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += test_cmdline_string.c SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += test_cmdline_lib.c +SRCS-$(CONFIG_RTE_LIBRTE_NET) += test_crc.c + ifeq ($(CONFIG_RTE_LIBRTE_SCHED),y) SRCS-y += test_red.c SRCS-y += test_sched.c
app/test/test_crc.c new file +222 -0
222 lines not on this page · raw message
--
2.5.5
PATCH v3 2/2 app/test: add unit test for CRC computation
In reply to Jasvinder SinghThis patch provides a set of tests for verifying the functional correctness of 16-bit and 32-bit CRC APIs.
--- app/test/Makefile | 2 + app/test/test_crc.c | 265 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 267 insertions(+) create mode 100644 app/test/test_crc.c
app/test/Makefile +2 -0
@@ -160,6 +160,8 @@ SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += test_cmdline_cirbuf.c SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += test_cmdline_string.c SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += test_cmdline_lib.c +SRCS-$(CONFIG_RTE_LIBRTE_NET) += test_crc.c + ifeq ($(CONFIG_RTE_LIBRTE_SCHED),y) SRCS-y += test_red.c SRCS-y += test_sched.c
app/test/test_crc.c new file +265 -0
265 lines not on this page · raw message
Signature · 1 line
2.5.5
PATCH v2 2/2 app/test: add unit test for CRC computation
In reply to Jasvinder SinghThis patch provides a set of tests for verifying the functional correctness of 16-bit and 32-bit CRC APIs.
--- app/test/Makefile | 2 + app/test/test_crc.c | 229 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 231 insertions(+) create mode 100644 app/test/test_crc.c
app/test/Makefile +2 -0
@@ -160,6 +160,8 @@ SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += test_cmdline_cirbuf.c SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += test_cmdline_string.c SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += test_cmdline_lib.c +SRCS-$(CONFIG_RTE_LIBRTE_NET) += test_crc.c + ifeq ($(CONFIG_RTE_LIBRTE_SCHED),y) SRCS-y += test_red.c SRCS-y += test_sched.c
app/test/test_crc.c new file +229 -0
229 lines not on this page · raw message
Signature · 1 line
2.5.5
PATCH 2/2 app/test: add unit test for CRC computation
In reply to Jasvinder SinghThis patch provides a set of unit tests for verifying the functional correctness of 16-bit and 32-bit CRC APIs.
--- app/test/Makefile | 2 + app/test/test_crc.c | 229 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 231 insertions(+) create mode 100644 app/test/test_crc.c
app/test/Makefile +2 -0
@@ -160,6 +160,8 @@ SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += test_cmdline_cirbuf.c SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += test_cmdline_string.c SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += test_cmdline_lib.c +SRCS-$(CONFIG_RTE_LIBRTE_NET) += test_crc.c + ifeq ($(CONFIG_RTE_LIBRTE_SCHED),y) SRCS-y += test_red.c SRCS-y += test_sched.c
app/test/test_crc.c new file +229 -0
229 lines not on this page · raw message
Signature · 1 line
2.5.5