CNDP  22.08.0
cne_pktcpy.h File Reference
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <cne_vect.h>
#include <cne_common.h>

Go to the source code of this file.

Macros

#define MOVEUNALIGNED_LEFT47_IMM(dst, src, len, offset)
 
#define MOVEUNALIGNED_LEFT47(dst, src, len, offset)
 

Functions

static __cne_always_inline void cne_mov16 (uint8_t *dst, const uint8_t *src)
 
static __cne_always_inline void cne_mov32 (uint8_t *dst, const uint8_t *src)
 
static __cne_always_inline void cne_mov64 (uint8_t *dst, const uint8_t *src)
 
static __cne_always_inline void cne_mov128 (uint8_t *dst, const uint8_t *src)
 
static __cne_always_inline void cne_mov256 (uint8_t *dst, const uint8_t *src)
 
static __cne_always_inline void * cne_pktcpy (void *dst, const void *src, size_t n)
 
static __cne_always_inline void * cne_pktcpy_generic (void *dst, const void *src, size_t n)
 
static __cne_always_inline void * cne_pktcpy_aligned (void *dst, const void *src, size_t n)
 

Detailed Description

Functions for SSE/AVX/AVX2/AVX512 implementation of memcpy() suitable for copying large packets.

Definition in file cne_pktcpy.h.

Macro Definition Documentation

◆ MOVEUNALIGNED_LEFT47_IMM

#define MOVEUNALIGNED_LEFT47_IMM (   dst,
  src,
  len,
  offset 
)

Macro for copying unaligned block from one location to another with constant load offset, 47 bytes leftover maximum, locations should not overlap. Requirements:

  • Store is aligned
  • Load offset is offset, which must be immediate value within [1, 15]
  • For src, make sure offset bit backwards & <16 - offset> bit forwards are available for loading
  • dst, src, len must be variables
  • __m128i <xmm0> ~ <xmm8> must be pre-defined

Definition at line 647 of file cne_pktcpy.h.

◆ MOVEUNALIGNED_LEFT47

#define MOVEUNALIGNED_LEFT47 (   dst,
  src,
  len,
  offset 
)
Value:
__extension__ ({ \
switch (offset) { \
case 0x01: MOVEUNALIGNED_LEFT47_IMM(dst, src, n, 0x01); break; \
case 0x02: MOVEUNALIGNED_LEFT47_IMM(dst, src, n, 0x02); break; \
case 0x03: MOVEUNALIGNED_LEFT47_IMM(dst, src, n, 0x03); break; \
case 0x04: MOVEUNALIGNED_LEFT47_IMM(dst, src, n, 0x04); break; \
case 0x05: MOVEUNALIGNED_LEFT47_IMM(dst, src, n, 0x05); break; \
case 0x06: MOVEUNALIGNED_LEFT47_IMM(dst, src, n, 0x06); break; \
case 0x07: MOVEUNALIGNED_LEFT47_IMM(dst, src, n, 0x07); break; \
case 0x08: MOVEUNALIGNED_LEFT47_IMM(dst, src, n, 0x08); break; \
case 0x09: MOVEUNALIGNED_LEFT47_IMM(dst, src, n, 0x09); break; \
case 0x0A: MOVEUNALIGNED_LEFT47_IMM(dst, src, n, 0x0A); break; \
case 0x0B: MOVEUNALIGNED_LEFT47_IMM(dst, src, n, 0x0B); break; \
case 0x0C: MOVEUNALIGNED_LEFT47_IMM(dst, src, n, 0x0C); break; \
case 0x0D: MOVEUNALIGNED_LEFT47_IMM(dst, src, n, 0x0D); break; \
case 0x0E: MOVEUNALIGNED_LEFT47_IMM(dst, src, n, 0x0E); break; \
case 0x0F: MOVEUNALIGNED_LEFT47_IMM(dst, src, n, 0x0F); break; \
default:; \
} \
})
#define MOVEUNALIGNED_LEFT47_IMM(dst, src, len, offset)
Definition: cne_pktcpy.h:647

Macro for copying unaligned block from one location to another, 47 bytes leftover maximum, locations should not overlap. Use switch here because the aligning instruction requires immediate value for shift count. Requirements:

  • Store is aligned
  • Load offset is offset, which must be within [1, 15]
  • For src, make sure offset bit backwards & <16 - offset> bit forwards are available for loading
  • dst, src, len must be variables
  • __m128i <xmm0> ~ <xmm8> used in MOVEUNALIGNED_LEFT47_IMM must be pre-defined

Definition at line 708 of file cne_pktcpy.h.

Function Documentation

◆ cne_mov16()

static __cne_always_inline void cne_mov16 ( uint8_t *  dst,
const uint8_t *  src 
)
static

Copy 16 bytes from one location to another using optimised instructions. The locations should not overlap.

Parameters
dstPointer to the destination of the data.
srcPointer to the source data.

SSE & AVX implementation below Copy 16 bytes from one location to another, locations should not overlap.

Definition at line 560 of file cne_pktcpy.h.

◆ cne_mov32()

static __cne_always_inline void cne_mov32 ( uint8_t *  dst,
const uint8_t *  src 
)
static

Copy 32 bytes from one location to another using optimised instructions. The locations should not overlap.

Parameters
dstPointer to the destination of the data.
srcPointer to the source data.

Copy 32 bytes from one location to another, locations should not overlap.

Definition at line 573 of file cne_pktcpy.h.

◆ cne_mov64()

static __cne_always_inline void cne_mov64 ( uint8_t *  dst,
const uint8_t *  src 
)
static

Copy 64 bytes from one location to another using optimised instructions. The locations should not overlap.

Parameters
dstPointer to the destination of the data.
srcPointer to the source data.

Copy 64 bytes from one location to another, locations should not overlap.

Definition at line 584 of file cne_pktcpy.h.

◆ cne_mov128()

static __cne_always_inline void cne_mov128 ( uint8_t *  dst,
const uint8_t *  src 
)
static

Copy 128 bytes from one location to another using optimised instructions. The locations should not overlap.

Parameters
dstPointer to the destination of the data.
srcPointer to the source data.

Copy 128 bytes from one location to another, locations should not overlap.

Definition at line 597 of file cne_pktcpy.h.

◆ cne_mov256()

static __cne_always_inline void cne_mov256 ( uint8_t *  dst,
const uint8_t *  src 
)
static

Copy 256 bytes from one location to another using optimised instructions. The locations should not overlap.

Parameters
dstPointer to the destination of the data.
srcPointer to the source data.

Copy 256 bytes from one location to another, locations should not overlap.

Definition at line 614 of file cne_pktcpy.h.

◆ cne_pktcpy()

static __cne_always_inline void * cne_pktcpy ( void *  dst,
const void *  src,
size_t  n 
)
static

Copy bytes from one location to another. The locations must not overlap.

Note
This is implemented as a macro, so it's address should not be taken and care is needed as parameter expressions may be evaluated multiple times.
Parameters
dstPointer to the destination of the data.
srcPointer to the source data.
nNumber of bytes to copy.
Returns
Pointer to the destination data.

Definition at line 962 of file cne_pktcpy.h.

◆ cne_pktcpy_generic()

static __cne_always_inline void* cne_pktcpy_generic ( void *  dst,
const void *  src,
size_t  n 
)
static

Generic packet copy routine for the given addresses and size.

The routine attempts to use AVX registers to copy the data.

Parameters
dstThe memory address to copy the data too
srcThe memory address to copy the data from
nThe number of bytes to copy
Returns
The address of the starting address of the destination is returned

Copy less than 16 bytes

Fast way when copy size doesn't exceed 512 bytes

Make store aligned when copy size exceeds 512 bytes, and make sure the first 15 bytes are copied, because unaligned copy functions require up to 15 bytes backwards access.

For aligned copy

Copy 256-byte blocks

Copy whatever left

For copy with unaligned load

Copy whatever left

Definition at line 746 of file cne_pktcpy.h.

◆ cne_pktcpy_aligned()

static __cne_always_inline void* cne_pktcpy_aligned ( void *  dst,
const void *  src,
size_t  n 
)
static

Generic packet copy routine of aligned data for the given addresses and size.

The routine attempts to use AVX registers to copy the data.

Parameters
dstThe memory address to copy the data too
srcThe memory address to copy the data from
nThe number of bytes to copy
Returns
The address of the starting address of the destination is returned

Definition at line 905 of file cne_pktcpy.h.