Upinder Malhi | e3cf00d | 2013-09-10 03:38:16 +0000 | [diff] [blame] | 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 | |
| 19 | #ifndef USNIC_IB_QP_GRP_H_ |
| 20 | #define USNIC_IB_QP_GRP_H_ |
| 21 | |
| 22 | #include <rdma/ib_verbs.h> |
| 23 | |
| 24 | #include "usnic_ib.h" |
| 25 | #include "usnic_abi.h" |
| 26 | #include "usnic_fwd.h" |
| 27 | #include "usnic_vnic.h" |
| 28 | |
Upinder Malhi | e3cf00d | 2013-09-10 03:38:16 +0000 | [diff] [blame] | 29 | /* |
| 30 | * The qp group struct represents all the hw resources needed to present a ib_qp |
| 31 | */ |
| 32 | struct usnic_ib_qp_grp { |
| 33 | struct ib_qp ibqp; |
| 34 | enum ib_qp_state state; |
| 35 | int grp_id; |
| 36 | |
| 37 | struct usnic_fwd_dev *ufdev; |
Upinder Malhi | e3cf00d | 2013-09-10 03:38:16 +0000 | [diff] [blame] | 38 | struct usnic_ib_ucontext *ctx; |
Upinder Malhi | 256d6a6 | 2014-01-09 14:48:09 -0800 | [diff] [blame] | 39 | struct list_head flows_lst; |
Upinder Malhi | e3cf00d | 2013-09-10 03:38:16 +0000 | [diff] [blame] | 40 | |
| 41 | struct usnic_vnic_res_chunk **res_chunk_list; |
| 42 | |
| 43 | pid_t owner_pid; |
| 44 | struct usnic_ib_vf *vf; |
| 45 | struct list_head link; |
| 46 | |
| 47 | spinlock_t lock; |
| 48 | |
| 49 | struct kobject kobj; |
| 50 | }; |
| 51 | |
Upinder Malhi | 256d6a6 | 2014-01-09 14:48:09 -0800 | [diff] [blame] | 52 | struct usnic_ib_qp_grp_flow { |
| 53 | struct usnic_fwd_flow *flow; |
| 54 | enum usnic_transport_type trans_type; |
| 55 | union { |
| 56 | struct { |
| 57 | uint16_t port_num; |
| 58 | } usnic_roce; |
Upinder Malhi | e45e614 | 2014-01-09 14:48:18 -0800 | [diff] [blame^] | 59 | struct { |
| 60 | struct socket *sock; |
| 61 | } udp; |
Upinder Malhi | 256d6a6 | 2014-01-09 14:48:09 -0800 | [diff] [blame] | 62 | }; |
| 63 | struct usnic_ib_qp_grp *qp_grp; |
| 64 | struct list_head link; |
| 65 | }; |
| 66 | |
Upinder Malhi | e3cf00d | 2013-09-10 03:38:16 +0000 | [diff] [blame] | 67 | static const struct |
| 68 | usnic_vnic_res_spec min_transport_spec[USNIC_TRANSPORT_MAX] = { |
| 69 | { /*USNIC_TRANSPORT_UNKNOWN*/ |
| 70 | .resources = { |
| 71 | {.type = USNIC_VNIC_RES_TYPE_EOL, .cnt = 0,}, |
| 72 | }, |
| 73 | }, |
| 74 | { /*USNIC_TRANSPORT_ROCE_CUSTOM*/ |
| 75 | .resources = { |
| 76 | {.type = USNIC_VNIC_RES_TYPE_WQ, .cnt = 1,}, |
| 77 | {.type = USNIC_VNIC_RES_TYPE_RQ, .cnt = 1,}, |
| 78 | {.type = USNIC_VNIC_RES_TYPE_CQ, .cnt = 1,}, |
| 79 | {.type = USNIC_VNIC_RES_TYPE_EOL, .cnt = 0,}, |
| 80 | }, |
| 81 | }, |
Upinder Malhi | e45e614 | 2014-01-09 14:48:18 -0800 | [diff] [blame^] | 82 | { /*USNIC_TRANSPORT_IPV4_UDP*/ |
| 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 | }, |
Upinder Malhi | e3cf00d | 2013-09-10 03:38:16 +0000 | [diff] [blame] | 90 | }; |
| 91 | |
| 92 | const char *usnic_ib_qp_grp_state_to_string(enum ib_qp_state state); |
| 93 | int usnic_ib_qp_grp_dump_hdr(char *buf, int buf_sz); |
| 94 | int usnic_ib_qp_grp_dump_rows(void *obj, char *buf, int buf_sz); |
| 95 | struct usnic_ib_qp_grp * |
| 96 | usnic_ib_qp_grp_create(struct usnic_fwd_dev *ufdev, struct usnic_ib_vf *vf, |
| 97 | struct usnic_ib_pd *pd, |
| 98 | struct usnic_vnic_res_spec *res_spec, |
Upinder Malhi | 256d6a6 | 2014-01-09 14:48:09 -0800 | [diff] [blame] | 99 | struct usnic_transport_spec *trans_spec); |
Upinder Malhi | e3cf00d | 2013-09-10 03:38:16 +0000 | [diff] [blame] | 100 | void usnic_ib_qp_grp_destroy(struct usnic_ib_qp_grp *qp_grp); |
| 101 | int usnic_ib_qp_grp_modify(struct usnic_ib_qp_grp *qp_grp, |
| 102 | enum ib_qp_state new_state, |
Upinder Malhi | 256d6a6 | 2014-01-09 14:48:09 -0800 | [diff] [blame] | 103 | void *data); |
Upinder Malhi | e3cf00d | 2013-09-10 03:38:16 +0000 | [diff] [blame] | 104 | struct usnic_vnic_res_chunk |
| 105 | *usnic_ib_qp_grp_get_chunk(struct usnic_ib_qp_grp *qp_grp, |
| 106 | enum usnic_vnic_res_type type); |
| 107 | static inline |
| 108 | struct usnic_ib_qp_grp *to_uqp_grp(struct ib_qp *ibqp) |
| 109 | { |
| 110 | return container_of(ibqp, struct usnic_ib_qp_grp, ibqp); |
| 111 | } |
| 112 | #endif /* USNIC_IB_QP_GRP_H_ */ |