verbs_txreq.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /* SPDX-License-Identifier: GPL-2.0 or BSD-3-Clause */
  2. /*
  3. * Copyright(c) 2016 - 2018 Intel Corporation.
  4. */
  5. #ifndef HFI1_VERBS_TXREQ_H
  6. #define HFI1_VERBS_TXREQ_H
  7. #include <linux/types.h>
  8. #include <linux/slab.h>
  9. #include "verbs.h"
  10. #include "sdma_txreq.h"
  11. #include "iowait.h"
  12. struct verbs_txreq {
  13. struct hfi1_sdma_header phdr;
  14. struct sdma_txreq txreq;
  15. struct rvt_qp *qp;
  16. struct rvt_swqe *wqe;
  17. struct rvt_mregion *mr;
  18. struct rvt_sge_state *ss;
  19. struct sdma_engine *sde;
  20. struct send_context *psc;
  21. u16 hdr_dwords;
  22. u16 s_cur_size;
  23. };
  24. struct hfi1_ibdev;
  25. struct verbs_txreq *__get_txreq(struct hfi1_ibdev *dev,
  26. struct rvt_qp *qp);
  27. #define VERBS_TXREQ_GFP (GFP_ATOMIC | __GFP_NOWARN)
  28. static inline struct verbs_txreq *get_txreq(struct hfi1_ibdev *dev,
  29. struct rvt_qp *qp)
  30. __must_hold(&qp->slock)
  31. {
  32. struct verbs_txreq *tx;
  33. struct hfi1_qp_priv *priv = qp->priv;
  34. tx = kmem_cache_alloc(dev->verbs_txreq_cache, VERBS_TXREQ_GFP);
  35. if (unlikely(!tx)) {
  36. /* call slow path to get the lock */
  37. tx = __get_txreq(dev, qp);
  38. if (!tx)
  39. return tx;
  40. }
  41. tx->qp = qp;
  42. tx->mr = NULL;
  43. tx->sde = priv->s_sde;
  44. tx->psc = priv->s_sendcontext;
  45. /* so that we can test if the sdma descriptors are there */
  46. tx->txreq.num_desc = 0;
  47. /* Set the header type */
  48. tx->phdr.hdr.hdr_type = priv->hdr_type;
  49. tx->txreq.flags = 0;
  50. return tx;
  51. }
  52. static inline struct verbs_txreq *get_waiting_verbs_txreq(struct iowait_work *w)
  53. {
  54. struct sdma_txreq *stx;
  55. stx = iowait_get_txhead(w);
  56. if (stx)
  57. return container_of(stx, struct verbs_txreq, txreq);
  58. return NULL;
  59. }
  60. static inline bool verbs_txreq_queued(struct iowait_work *w)
  61. {
  62. return iowait_packet_queued(w);
  63. }
  64. void hfi1_put_txreq(struct verbs_txreq *tx);
  65. int verbs_txreq_init(struct hfi1_ibdev *dev);
  66. void verbs_txreq_exit(struct hfi1_ibdev *dev);
  67. #endif /* HFI1_VERBS_TXREQ_H */