199a2dd95SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause 299a2dd95SBruce Richardson * Copyright(c) 2010-2014 Intel Corporation 399a2dd95SBruce Richardson */ 499a2dd95SBruce Richardson 599a2dd95SBruce Richardson #ifndef _RTE_MEMCPY_H_ 699a2dd95SBruce Richardson #define _RTE_MEMCPY_H_ 799a2dd95SBruce Richardson 8*719834a6SMattias Rönnblom #ifdef __cplusplus 9*719834a6SMattias Rönnblom extern "C" { 10*719834a6SMattias Rönnblom #endif 11*719834a6SMattias Rönnblom 1299a2dd95SBruce Richardson /** 1399a2dd95SBruce Richardson * @file 1499a2dd95SBruce Richardson * 1599a2dd95SBruce Richardson * Functions for vectorised implementation of memcpy(). 1699a2dd95SBruce Richardson */ 1799a2dd95SBruce Richardson 1899a2dd95SBruce Richardson /** 1999a2dd95SBruce Richardson * Copy 16 bytes from one location to another using optimised 2099a2dd95SBruce Richardson * instructions. The locations should not overlap. 2199a2dd95SBruce Richardson * 2299a2dd95SBruce Richardson * @param dst 2399a2dd95SBruce Richardson * Pointer to the destination of the data. 2499a2dd95SBruce Richardson * @param src 2599a2dd95SBruce Richardson * Pointer to the source data. 2699a2dd95SBruce Richardson */ 2799a2dd95SBruce Richardson static inline void 2899a2dd95SBruce Richardson rte_mov16(uint8_t *dst, const uint8_t *src); 2999a2dd95SBruce Richardson 3099a2dd95SBruce Richardson /** 3199a2dd95SBruce Richardson * Copy 32 bytes from one location to another using optimised 3299a2dd95SBruce Richardson * instructions. The locations should not overlap. 3399a2dd95SBruce Richardson * 3499a2dd95SBruce Richardson * @param dst 3599a2dd95SBruce Richardson * Pointer to the destination of the data. 3699a2dd95SBruce Richardson * @param src 3799a2dd95SBruce Richardson * Pointer to the source data. 3899a2dd95SBruce Richardson */ 3999a2dd95SBruce Richardson static inline void 4099a2dd95SBruce Richardson rte_mov32(uint8_t *dst, const uint8_t *src); 4199a2dd95SBruce Richardson 4299a2dd95SBruce Richardson #ifdef __DOXYGEN__ 4399a2dd95SBruce Richardson 4499a2dd95SBruce Richardson /** 4599a2dd95SBruce Richardson * Copy 48 bytes from one location to another using optimised 4699a2dd95SBruce Richardson * instructions. The locations should not overlap. 4799a2dd95SBruce Richardson * 4899a2dd95SBruce Richardson * @param dst 4999a2dd95SBruce Richardson * Pointer to the destination of the data. 5099a2dd95SBruce Richardson * @param src 5199a2dd95SBruce Richardson * Pointer to the source data. 5299a2dd95SBruce Richardson */ 5399a2dd95SBruce Richardson static inline void 5499a2dd95SBruce Richardson rte_mov48(uint8_t *dst, const uint8_t *src); 5599a2dd95SBruce Richardson 5699a2dd95SBruce Richardson #endif /* __DOXYGEN__ */ 5799a2dd95SBruce Richardson 5899a2dd95SBruce Richardson /** 5999a2dd95SBruce Richardson * Copy 64 bytes from one location to another using optimised 6099a2dd95SBruce Richardson * instructions. The locations should not overlap. 6199a2dd95SBruce Richardson * 6299a2dd95SBruce Richardson * @param dst 6399a2dd95SBruce Richardson * Pointer to the destination of the data. 6499a2dd95SBruce Richardson * @param src 6599a2dd95SBruce Richardson * Pointer to the source data. 6699a2dd95SBruce Richardson */ 6799a2dd95SBruce Richardson static inline void 6899a2dd95SBruce Richardson rte_mov64(uint8_t *dst, const uint8_t *src); 6999a2dd95SBruce Richardson 7099a2dd95SBruce Richardson /** 7199a2dd95SBruce Richardson * Copy 128 bytes from one location to another using optimised 7299a2dd95SBruce Richardson * instructions. The locations should not overlap. 7399a2dd95SBruce Richardson * 7499a2dd95SBruce Richardson * @param dst 7599a2dd95SBruce Richardson * Pointer to the destination of the data. 7699a2dd95SBruce Richardson * @param src 7799a2dd95SBruce Richardson * Pointer to the source data. 7899a2dd95SBruce Richardson */ 7999a2dd95SBruce Richardson static inline void 8099a2dd95SBruce Richardson rte_mov128(uint8_t *dst, const uint8_t *src); 8199a2dd95SBruce Richardson 8299a2dd95SBruce Richardson /** 8399a2dd95SBruce Richardson * Copy 256 bytes from one location to another using optimised 8499a2dd95SBruce Richardson * instructions. The locations should not overlap. 8599a2dd95SBruce Richardson * 8699a2dd95SBruce Richardson * @param dst 8799a2dd95SBruce Richardson * Pointer to the destination of the data. 8899a2dd95SBruce Richardson * @param src 8999a2dd95SBruce Richardson * Pointer to the source data. 9099a2dd95SBruce Richardson */ 9199a2dd95SBruce Richardson static inline void 9299a2dd95SBruce Richardson rte_mov256(uint8_t *dst, const uint8_t *src); 9399a2dd95SBruce Richardson 9499a2dd95SBruce Richardson #ifdef __DOXYGEN__ 9599a2dd95SBruce Richardson 9699a2dd95SBruce Richardson /** 9799a2dd95SBruce Richardson * Copy bytes from one location to another. The locations must not overlap. 9899a2dd95SBruce Richardson * 9999a2dd95SBruce Richardson * @note This is implemented as a macro, so it's address should not be taken 10099a2dd95SBruce Richardson * and care is needed as parameter expressions may be evaluated multiple times. 10199a2dd95SBruce Richardson * 10299a2dd95SBruce Richardson * @note For x86 platforms to enable the AVX-512 memcpy implementation, set 10399a2dd95SBruce Richardson * -DRTE_MEMCPY_AVX512 macro in CFLAGS, or define the RTE_MEMCPY_AVX512 macro 10499a2dd95SBruce Richardson * explicitly in the source file before including the rte_memcpy header file. 10599a2dd95SBruce Richardson * 10699a2dd95SBruce Richardson * @param dst 10799a2dd95SBruce Richardson * Pointer to the destination of the data. 10899a2dd95SBruce Richardson * @param src 10999a2dd95SBruce Richardson * Pointer to the source data. 11099a2dd95SBruce Richardson * @param n 11199a2dd95SBruce Richardson * Number of bytes to copy. 11299a2dd95SBruce Richardson * @return 11399a2dd95SBruce Richardson * Pointer to the destination data. 11499a2dd95SBruce Richardson */ 11599a2dd95SBruce Richardson static void * 11699a2dd95SBruce Richardson rte_memcpy(void *dst, const void *src, size_t n); 11799a2dd95SBruce Richardson 11899a2dd95SBruce Richardson #endif /* __DOXYGEN__ */ 11999a2dd95SBruce Richardson 120*719834a6SMattias Rönnblom #ifdef __cplusplus 121*719834a6SMattias Rönnblom } 122*719834a6SMattias Rönnblom #endif 123*719834a6SMattias Rönnblom 12499a2dd95SBruce Richardson #endif /* _RTE_MEMCPY_H_ */ 125