| 1 |
|
| 2 | |
| 3 | * dibs loopback (aka loopback-ism) device structure definitions.
|
| 4 | *
|
| 5 | * Copyright (c) 2024, Alibaba Inc.
|
| 6 | *
|
| 7 | * Author: Wen Gu <[email protected]>
|
| 8 | * Tony Lu <[email protected]>
|
| 9 | *
|
| 10 |
|
| 11 |
|
| 12 | #ifndef _DIBS_LOOPBACK_H
|
| 13 | #define _DIBS_LOOPBACK_H
|
| 14 |
|
| 15 | #include <linux/dibs.h>
|
| 16 | #include <linux/hashtable.h>
|
| 17 | #include <linux/spinlock.h>
|
| 18 | #include <linux/types.h>
|
| 19 | #include <linux/wait.h>
|
| 20 |
|
| 21 | #if IS_ENABLED(CONFIG_DIBS_LO)
|
| 22 | #define DIBS_LO_DMBS_HASH_BITS 12
|
| 23 | #define DIBS_LO_MAX_DMBS 5000
|
| 24 |
|
| 25 | struct dibs_lo_dmb_node {
|
| 26 | struct hlist_node list;
|
| 27 | u64 token;
|
| 28 | u32 len;
|
| 29 | u32 sba_idx;
|
| 30 | void *cpu_addr;
|
| 31 | dma_addr_t dma_addr;
|
| 32 | refcount_t refcnt;
|
| 33 | };
|
| 34 |
|
| 35 | struct dibs_lo_dev {
|
| 36 | struct dibs_dev *dibs;
|
| 37 | atomic_t dmb_cnt;
|
| 38 | rwlock_t dmb_ht_lock;
|
| 39 | DECLARE_BITMAP(sba_idx_mask, DIBS_LO_MAX_DMBS);
|
| 40 | DECLARE_HASHTABLE(dmb_ht, DIBS_LO_DMBS_HASH_BITS);
|
| 41 | wait_queue_head_t ldev_release;
|
| 42 | };
|
| 43 |
|
| 44 | int dibs_loopback_init(void);
|
| 45 | void dibs_loopback_exit(void);
|
| 46 | #else
|
| 47 | static inline int dibs_loopback_init(void)
|
| 48 | {
|
| 49 | return 0;
|
| 50 | }
|
| 51 |
|
| 52 | static inline void dibs_loopback_exit(void)
|
| 53 | {
|
| 54 | }
|
| 55 | #endif
|
| 56 |
|
| 57 | #endif
|