Leon Romanovsky | 6bf9d8f | 2020-07-19 10:25:21 +0300 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ |
| 2 | /* |
| 3 | * Copyright(c) 2016 - 2018 Intel Corporation. |
| 4 | */ |
| 5 | |
Dennis Dalessandro | 6f6387a | 2016-01-22 13:00:15 -0800 | [diff] [blame] | 6 | #ifndef DEF_RDMAVT_INCCQ_H |
| 7 | #define DEF_RDMAVT_INCCQ_H |
| 8 | |
Dennis Dalessandro | 6f6387a | 2016-01-22 13:00:15 -0800 | [diff] [blame] | 9 | #include <linux/kthread.h> |
| 10 | #include <rdma/ib_user_verbs.h> |
Jason Gunthorpe | 39289bf | 2019-07-22 17:01:30 +0000 | [diff] [blame] | 11 | #include <rdma/ib_verbs.h> |
Dennis Dalessandro | 6f6387a | 2016-01-22 13:00:15 -0800 | [diff] [blame] | 12 | |
| 13 | /* |
| 14 | * Define an ib_cq_notify value that is not valid so we know when CQ |
| 15 | * notifications are armed. |
| 16 | */ |
| 17 | #define RVT_CQ_NONE (IB_CQ_NEXT_COMP + 1) |
| 18 | |
| 19 | /* |
Kamenee Arumugam | 239b0e5 | 2019-06-28 14:04:17 -0400 | [diff] [blame] | 20 | * Define read macro that apply smp_load_acquire memory barrier |
| 21 | * when reading indice of circular buffer that mmaped to user space. |
| 22 | */ |
| 23 | #define RDMA_READ_UAPI_ATOMIC(member) smp_load_acquire(&(member).val) |
| 24 | |
| 25 | /* |
| 26 | * Define write macro that uses smp_store_release memory barrier |
| 27 | * when writing indice of circular buffer that mmaped to user space. |
| 28 | */ |
| 29 | #define RDMA_WRITE_UAPI_ATOMIC(member, x) smp_store_release(&(member).val, x) |
| 30 | #include <rdma/rvt-abi.h> |
| 31 | |
| 32 | /* |
Dennis Dalessandro | 6f6387a | 2016-01-22 13:00:15 -0800 | [diff] [blame] | 33 | * This structure is used to contain the head pointer, tail pointer, |
| 34 | * and completion queue entries as a single memory allocation so |
| 35 | * it can be mmap'ed into user space. |
| 36 | */ |
Kamenee Arumugam | 239b0e5 | 2019-06-28 14:04:17 -0400 | [diff] [blame] | 37 | struct rvt_k_cq_wc { |
Dennis Dalessandro | 6f6387a | 2016-01-22 13:00:15 -0800 | [diff] [blame] | 38 | u32 head; /* index of next entry to fill */ |
| 39 | u32 tail; /* index of next ib_poll_cq() entry */ |
Kamenee Arumugam | 239b0e5 | 2019-06-28 14:04:17 -0400 | [diff] [blame] | 40 | struct ib_wc kqueue[]; |
Dennis Dalessandro | 6f6387a | 2016-01-22 13:00:15 -0800 | [diff] [blame] | 41 | }; |
| 42 | |
| 43 | /* |
| 44 | * The completion queue structure. |
| 45 | */ |
| 46 | struct rvt_cq { |
| 47 | struct ib_cq ibcq; |
Sebastian Sanchez | 5d18ee6 | 2018-05-02 06:43:55 -0700 | [diff] [blame] | 48 | struct work_struct comptask; |
Dennis Dalessandro | 6f6387a | 2016-01-22 13:00:15 -0800 | [diff] [blame] | 49 | spinlock_t lock; /* protect changes in this struct */ |
| 50 | u8 notify; |
| 51 | u8 triggered; |
Kamenee Arumugam | 5136bfe | 2019-06-28 14:21:52 -0400 | [diff] [blame] | 52 | u8 cq_full; |
Sebastian Sanchez | 5d18ee6 | 2018-05-02 06:43:55 -0700 | [diff] [blame] | 53 | int comp_vector_cpu; |
Dennis Dalessandro | 6f6387a | 2016-01-22 13:00:15 -0800 | [diff] [blame] | 54 | struct rvt_dev_info *rdi; |
| 55 | struct rvt_cq_wc *queue; |
| 56 | struct rvt_mmap_info *ip; |
Kamenee Arumugam | 239b0e5 | 2019-06-28 14:04:17 -0400 | [diff] [blame] | 57 | struct rvt_k_cq_wc *kqueue; |
Dennis Dalessandro | 6f6387a | 2016-01-22 13:00:15 -0800 | [diff] [blame] | 58 | }; |
| 59 | |
| 60 | static inline struct rvt_cq *ibcq_to_rvtcq(struct ib_cq *ibcq) |
| 61 | { |
| 62 | return container_of(ibcq, struct rvt_cq, ibcq); |
| 63 | } |
| 64 | |
Kamenee Arumugam | 5136bfe | 2019-06-28 14:21:52 -0400 | [diff] [blame] | 65 | bool rvt_cq_enter(struct rvt_cq *cq, struct ib_wc *entry, bool solicited); |
Dennis Dalessandro | 6f6387a | 2016-01-22 13:00:15 -0800 | [diff] [blame] | 66 | |
| 67 | #endif /* DEF_RDMAVT_INCCQH */ |