Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause 2 : : * Copyright(c) 2021 Intel Corporation 3 : : */ 4 : : 5 : : #ifndef _RTE_THASH_GFNI_H_ 6 : : #define _RTE_THASH_GFNI_H_ 7 : : 8 : : #include <rte_compat.h> 9 : : #include <rte_log.h> 10 : : 11 : : #ifdef RTE_ARCH_X86 12 : : 13 : : #include <rte_thash_x86_gfni.h> 14 : : 15 : : #endif 16 : : 17 : : #ifdef __cplusplus 18 : : extern "C" { 19 : : #endif 20 : : 21 : : /** 22 : : * @internal 23 : : * Stubs only used when GFNI is not available. 24 : : */ 25 : : uint32_t 26 : : rte_thash_gfni_stub(const uint64_t *mtrx, const uint8_t *key, int len); 27 : : 28 : : void 29 : : rte_thash_gfni_bulk_stub(const uint64_t *mtrx, int len, uint8_t *tuple[], 30 : : uint32_t val[], uint32_t num); 31 : : 32 : : #ifndef RTE_THASH_GFNI_DEFINED 33 : : /** 34 : : * Calculate Toeplitz hash. 35 : : * 36 : : * @param m 37 : : * Pointer to the matrices generated from the corresponding 38 : : * RSS hash key using rte_thash_complete_matrix(). 39 : : * @param tuple 40 : : * Pointer to the data to be hashed. Data must be in network byte order. 41 : : * @param len 42 : : * Length of the data to be hashed. 43 : : * @return 44 : : * Calculated Toeplitz hash value. 45 : : */ 46 : : static inline uint32_t 47 : : rte_thash_gfni(const uint64_t *mtrx, const uint8_t *key, int len) 48 : : { 49 : 0 : return rte_thash_gfni_stub(mtrx, key, len); 50 : : } 51 : : 52 : : /** 53 : : * Bulk implementation for Toeplitz hash. 54 : : * 55 : : * @param m 56 : : * Pointer to the matrices generated from the corresponding 57 : : * RSS hash key using rte_thash_complete_matrix(). 58 : : * @param len 59 : : * Length of the largest data buffer to be hashed. 60 : : * @param tuple 61 : : * Array of the pointers on data to be hashed. 62 : : * Data must be in network byte order. 63 : : * @param val 64 : : * Array of uint32_t where to put calculated Toeplitz hash values 65 : : * @param num 66 : : * Number of tuples to hash. 67 : : */ 68 : : static inline void 69 : : rte_thash_gfni_bulk(const uint64_t *mtrx, int len, uint8_t *tuple[], 70 : : uint32_t val[], uint32_t num) 71 : : { 72 : 0 : rte_thash_gfni_bulk_stub(mtrx, len, tuple, val, num); 73 : : } 74 : : 75 : : #endif /* RTE_THASH_GFNI_DEFINED */ 76 : : 77 : : #ifdef __cplusplus 78 : : } 79 : : #endif 80 : : 81 : : #endif /* _RTE_THASH_GFNI_H_ */