usnic_ib_qp_grp.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * Copyright (c) 2013, Cisco Systems, Inc. All rights reserved.
  3. *
  4. * This program is free software; you may redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; version 2 of the License.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  9. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  10. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  11. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  12. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  13. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  14. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  15. * SOFTWARE.
  16. *
  17. */
  18. #ifndef USNIC_IB_QP_GRP_H_
  19. #define USNIC_IB_QP_GRP_H_
  20. #include <linux/debugfs.h>
  21. #include <rdma/ib_verbs.h>
  22. #include "usnic_ib.h"
  23. #include "usnic_abi.h"
  24. #include "usnic_fwd.h"
  25. #include "usnic_vnic.h"
  26. /*
  27. * The qp group struct represents all the hw resources needed to present a ib_qp
  28. */
  29. struct usnic_ib_qp_grp {
  30. struct ib_qp ibqp;
  31. enum ib_qp_state state;
  32. int grp_id;
  33. struct usnic_fwd_dev *ufdev;
  34. struct usnic_ib_ucontext *ctx;
  35. struct list_head flows_lst;
  36. struct usnic_vnic_res_chunk **res_chunk_list;
  37. pid_t owner_pid;
  38. struct usnic_ib_vf *vf;
  39. struct list_head link;
  40. spinlock_t lock;
  41. struct kobject kobj;
  42. };
  43. struct usnic_ib_qp_grp_flow {
  44. struct usnic_fwd_flow *flow;
  45. enum usnic_transport_type trans_type;
  46. union {
  47. struct {
  48. uint16_t port_num;
  49. } usnic_roce;
  50. struct {
  51. struct socket *sock;
  52. } udp;
  53. };
  54. struct usnic_ib_qp_grp *qp_grp;
  55. struct list_head link;
  56. /* Debug FS */
  57. struct dentry *dbgfs_dentry;
  58. char dentry_name[32];
  59. };
  60. static const struct
  61. usnic_vnic_res_spec min_transport_spec[USNIC_TRANSPORT_MAX] = {
  62. { /*USNIC_TRANSPORT_UNKNOWN*/
  63. .resources = {
  64. {.type = USNIC_VNIC_RES_TYPE_EOL, .cnt = 0,},
  65. },
  66. },
  67. { /*USNIC_TRANSPORT_ROCE_CUSTOM*/
  68. .resources = {
  69. {.type = USNIC_VNIC_RES_TYPE_WQ, .cnt = 1,},
  70. {.type = USNIC_VNIC_RES_TYPE_RQ, .cnt = 1,},
  71. {.type = USNIC_VNIC_RES_TYPE_CQ, .cnt = 1,},
  72. {.type = USNIC_VNIC_RES_TYPE_EOL, .cnt = 0,},
  73. },
  74. },
  75. { /*USNIC_TRANSPORT_IPV4_UDP*/
  76. .resources = {
  77. {.type = USNIC_VNIC_RES_TYPE_WQ, .cnt = 1,},
  78. {.type = USNIC_VNIC_RES_TYPE_RQ, .cnt = 1,},
  79. {.type = USNIC_VNIC_RES_TYPE_CQ, .cnt = 1,},
  80. {.type = USNIC_VNIC_RES_TYPE_EOL, .cnt = 0,},
  81. },
  82. },
  83. };
  84. const char *usnic_ib_qp_grp_state_to_string(enum ib_qp_state state);
  85. int usnic_ib_qp_grp_dump_hdr(char *buf, int buf_sz);
  86. int usnic_ib_qp_grp_dump_rows(void *obj, char *buf, int buf_sz);
  87. struct usnic_ib_qp_grp *
  88. usnic_ib_qp_grp_create(struct usnic_fwd_dev *ufdev, struct usnic_ib_vf *vf,
  89. struct usnic_ib_pd *pd,
  90. struct usnic_vnic_res_spec *res_spec,
  91. struct usnic_transport_spec *trans_spec);
  92. void usnic_ib_qp_grp_destroy(struct usnic_ib_qp_grp *qp_grp);
  93. int usnic_ib_qp_grp_modify(struct usnic_ib_qp_grp *qp_grp,
  94. enum ib_qp_state new_state,
  95. void *data);
  96. struct usnic_vnic_res_chunk
  97. *usnic_ib_qp_grp_get_chunk(struct usnic_ib_qp_grp *qp_grp,
  98. enum usnic_vnic_res_type type);
  99. static inline
  100. struct usnic_ib_qp_grp *to_uqp_grp(struct ib_qp *ibqp)
  101. {
  102. return container_of(ibqp, struct usnic_ib_qp_grp, ibqp);
  103. }
  104. #endif /* USNIC_IB_QP_GRP_H_ */