usnic_ib_qp_grp.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. * Copyright (c) 2013, Cisco Systems, Inc. All rights reserved.
  3. *
  4. * This software is available to you under a choice of one of two
  5. * licenses. You may choose to be licensed under the terms of the GNU
  6. * General Public License (GPL) Version 2, available from the file
  7. * COPYING in the main directory of this source tree, or the
  8. * BSD license below:
  9. *
  10. * Redistribution and use in source and binary forms, with or
  11. * without modification, are permitted provided that the following
  12. * conditions are met:
  13. *
  14. * - Redistributions of source code must retain the above
  15. * copyright notice, this list of conditions and the following
  16. * disclaimer.
  17. *
  18. * - Redistributions in binary form must reproduce the above
  19. * copyright notice, this list of conditions and the following
  20. * disclaimer in the documentation and/or other materials
  21. * provided with the distribution.
  22. *
  23. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  24. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  26. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  27. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  28. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  29. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  30. * SOFTWARE.
  31. *
  32. */
  33. #ifndef USNIC_IB_QP_GRP_H_
  34. #define USNIC_IB_QP_GRP_H_
  35. #include <linux/debugfs.h>
  36. #include <rdma/ib_verbs.h>
  37. #include "usnic_ib.h"
  38. #include "usnic_abi.h"
  39. #include "usnic_fwd.h"
  40. #include "usnic_vnic.h"
  41. /*
  42. * The qp group struct represents all the hw resources needed to present a ib_qp
  43. */
  44. struct usnic_ib_qp_grp {
  45. struct ib_qp ibqp;
  46. enum ib_qp_state state;
  47. int grp_id;
  48. struct usnic_fwd_dev *ufdev;
  49. struct usnic_ib_ucontext *ctx;
  50. struct list_head flows_lst;
  51. struct usnic_vnic_res_chunk **res_chunk_list;
  52. pid_t owner_pid;
  53. struct usnic_ib_vf *vf;
  54. struct list_head link;
  55. spinlock_t lock;
  56. struct kobject kobj;
  57. };
  58. struct usnic_ib_qp_grp_flow {
  59. struct usnic_fwd_flow *flow;
  60. enum usnic_transport_type trans_type;
  61. union {
  62. struct {
  63. uint16_t port_num;
  64. } usnic_roce;
  65. struct {
  66. struct socket *sock;
  67. } udp;
  68. };
  69. struct usnic_ib_qp_grp *qp_grp;
  70. struct list_head link;
  71. /* Debug FS */
  72. struct dentry *dbgfs_dentry;
  73. char dentry_name[32];
  74. };
  75. static const struct
  76. usnic_vnic_res_spec min_transport_spec[USNIC_TRANSPORT_MAX] = {
  77. { /*USNIC_TRANSPORT_UNKNOWN*/
  78. .resources = {
  79. {.type = USNIC_VNIC_RES_TYPE_EOL, .cnt = 0,},
  80. },
  81. },
  82. { /*USNIC_TRANSPORT_ROCE_CUSTOM*/
  83. .resources = {
  84. {.type = USNIC_VNIC_RES_TYPE_WQ, .cnt = 1,},
  85. {.type = USNIC_VNIC_RES_TYPE_RQ, .cnt = 1,},
  86. {.type = USNIC_VNIC_RES_TYPE_CQ, .cnt = 1,},
  87. {.type = USNIC_VNIC_RES_TYPE_EOL, .cnt = 0,},
  88. },
  89. },
  90. { /*USNIC_TRANSPORT_IPV4_UDP*/
  91. .resources = {
  92. {.type = USNIC_VNIC_RES_TYPE_WQ, .cnt = 1,},
  93. {.type = USNIC_VNIC_RES_TYPE_RQ, .cnt = 1,},
  94. {.type = USNIC_VNIC_RES_TYPE_CQ, .cnt = 1,},
  95. {.type = USNIC_VNIC_RES_TYPE_EOL, .cnt = 0,},
  96. },
  97. },
  98. };
  99. const char *usnic_ib_qp_grp_state_to_string(enum ib_qp_state state);
  100. int usnic_ib_qp_grp_dump_hdr(char *buf, int buf_sz);
  101. int usnic_ib_qp_grp_dump_rows(void *obj, char *buf, int buf_sz);
  102. struct usnic_ib_qp_grp *
  103. usnic_ib_qp_grp_create(struct usnic_fwd_dev *ufdev, struct usnic_ib_vf *vf,
  104. struct usnic_ib_pd *pd,
  105. struct usnic_vnic_res_spec *res_spec,
  106. struct usnic_transport_spec *trans_spec);
  107. void usnic_ib_qp_grp_destroy(struct usnic_ib_qp_grp *qp_grp);
  108. int usnic_ib_qp_grp_modify(struct usnic_ib_qp_grp *qp_grp,
  109. enum ib_qp_state new_state,
  110. void *data);
  111. struct usnic_vnic_res_chunk
  112. *usnic_ib_qp_grp_get_chunk(struct usnic_ib_qp_grp *qp_grp,
  113. enum usnic_vnic_res_type type);
  114. static inline
  115. struct usnic_ib_qp_grp *to_uqp_grp(struct ib_qp *ibqp)
  116. {
  117. return container_of(ibqp, struct usnic_ib_qp_grp, ibqp);
  118. }
  119. #endif /* USNIC_IB_QP_GRP_H_ */