rdmavt_cq.h 1.7 KB

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