From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jerin Jacob Subject: Re: [PATCH v2 1/2] librte_net: add crc init and compute APIs Date: Tue, 28 Feb 2017 17:45:13 +0530 Message-ID: <20170228121512.GB30817@localhost.localdomain> References: <1487969657-172541-2-git-send-email-jasvinder.singh@intel.com> <1488283701-186162-1-git-send-email-jasvinder.singh@intel.com> <1488283701-186162-2-git-send-email-jasvinder.singh@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: dev@dpdk.org, declan.doherty@intel.com To: Jasvinder Singh Return-path: Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0055.outbound.protection.outlook.com [104.47.33.55]) by dpdk.org (Postfix) with ESMTP id A187A2BAA for ; Tue, 28 Feb 2017 13:15:29 +0100 (CET) Content-Disposition: inline In-Reply-To: <1488283701-186162-2-git-send-email-jasvinder.singh@intel.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Tue, Feb 28, 2017 at 12:08:20PM +0000, Jasvinder Singh wrote: > 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 > --- > 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 > > diff --git a/lib/librte_net/Makefile b/lib/librte_net/Makefile > index 20cf664..41be751 100644 > --- a/lib/librte_net/Makefile > +++ b/lib/librte_net/Makefile > @@ -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 > > diff --git a/lib/librte_net/rte_net_crc.c b/lib/librte_net/rte_net_crc.c > new file mode 100644 > index 0000000..78a49dd > --- /dev/null > +++ b/lib/librte_net/rte_net_crc.c > @@ -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 > +#include > + > +/* 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, > +}; > + > +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 defined RTE_ARCH_X86_64 && defined RTE_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