1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2021 HiSilicon Limited 3 */ 4 5 #ifndef SKELETON_DMADEV_H 6 #define SKELETON_DMADEV_H 7 8 #include <pthread.h> 9 10 #include <rte_ring.h> 11 12 #define SKELDMA_ARG_LCORE "lcore" 13 14 struct skeldma_desc { 15 void *src; 16 void *dst; 17 uint32_t len; 18 uint16_t ridx; /* ring idx */ 19 }; 20 21 struct skeldma_hw { 22 int lcore_id; /* cpucopy task affinity core */ 23 int socket_id; 24 pthread_t thread; /* cpucopy task thread */ 25 volatile int exit_flag; /* cpucopy task exit flag */ 26 27 struct skeldma_desc *desc_mem; 28 29 /* Descriptor ring state machine: 30 * 31 * ----------- enqueue without submit ----------- 32 * | empty |------------------------------->| pending | 33 * -----------\ ----------- 34 * ^ \------------ | 35 * | | |submit doorbell 36 * | | | 37 * | |enqueue with submit | 38 * |get completed |------------------| | 39 * | | | 40 * | v v 41 * ----------- cpucopy thread working ----------- 42 * |completed|<-------------------------------| running | 43 * ----------- ----------- 44 */ 45 struct rte_ring *desc_empty; 46 struct rte_ring *desc_pending; 47 struct rte_ring *desc_running; 48 struct rte_ring *desc_completed; 49 50 /* Cache delimiter for dataplane API's operation data */ 51 char cache1 __rte_cache_aligned; 52 uint16_t ridx; /* ring idx */ 53 uint64_t submitted_count; 54 55 /* Cache delimiter for cpucopy thread's operation data */ 56 char cache2 __rte_cache_aligned; 57 volatile uint32_t zero_req_count; 58 uint64_t completed_count; 59 }; 60 61 #endif /* SKELETON_DMADEV_H */ 62