raw/octeontx2_ep: add enqueue operation
[dpdk.git] / drivers / raw / octeontx2_ep / otx2_ep_enqdeq.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(C) 2019 Marvell International Ltd.
3  */
4
5 #ifndef _OTX2_EP_ENQDEQ_H_
6 #define _OTX2_EP_ENQDEQ_H_
7
8 #include <rte_byteorder.h>
9 #include "otx2_ep_rawdev.h"
10
11 #define SDP_IQ_SEND_FAILED      (-1)
12 #define SDP_IQ_SEND_SUCCESS     (0)
13
14
15 static inline uint64_t
16 sdp_endian_swap_8B(uint64_t _d)
17 {
18         return ((((((uint64_t)(_d)) >>  0) & (uint64_t)0xff) << 56) |
19                 (((((uint64_t)(_d)) >>  8) & (uint64_t)0xff) << 48) |
20                 (((((uint64_t)(_d)) >> 16) & (uint64_t)0xff) << 40) |
21                 (((((uint64_t)(_d)) >> 24) & (uint64_t)0xff) << 32) |
22                 (((((uint64_t)(_d)) >> 32) & (uint64_t)0xff) << 24) |
23                 (((((uint64_t)(_d)) >> 40) & (uint64_t)0xff) << 16) |
24                 (((((uint64_t)(_d)) >> 48) & (uint64_t)0xff) <<  8) |
25                 (((((uint64_t)(_d)) >> 56) & (uint64_t)0xff) <<  0));
26 }
27
28 static inline void
29 sdp_swap_8B_data(uint64_t *data, uint32_t blocks)
30 {
31         /* Swap 8B blocks */
32         while (blocks) {
33                 *data = sdp_endian_swap_8B(*data);
34                 blocks--;
35                 data++;
36         }
37 }
38
39 static inline uint32_t
40 sdp_incr_index(uint32_t index, uint32_t count, uint32_t max)
41 {
42         if ((index + count) >= max)
43                 index = index + count - max;
44         else
45                 index += count;
46
47         return index;
48 }
49
50 #endif /* _OTX2_EP_ENQDEQ_H_ */