Debian Codegraph @

ptl_ips/ips_scb.h

raw
1 /*
2 * Copyright (c) 2013. Intel Corporation. All rights reserved.
3 * Copyright (c) 2006-2012. QLogic Corporation. All rights reserved.
4 * Copyright (c) 2003-2006, PathScale, Inc. All rights reserved.
5 *
6 * This software is available to you under a choice of one of two
7 * licenses. You may choose to be licensed under the terms of the GNU
8 * General Public License (GPL) Version 2, available from the file
9 * COPYING in the main directory of this source tree, or the
10 * OpenIB.org BSD license below:
11 *
12 * Redistribution and use in source and binary forms, with or
13 * without modification, are permitted provided that the following
14 * conditions are met:
15 *
16 * - Redistributions of source code must retain the above
17 * copyright notice, this list of conditions and the following
18 * disclaimer.
19 *
20 * - Redistributions in binary form must reproduce the above
21 * copyright notice, this list of conditions and the following
22 * disclaimer in the documentation and/or other materials
23 * provided with the distribution.
24 *
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE.
33 */
34
35 #ifndef _IPS_SCB_H
36 #define _IPS_SCB_H
37
38 #include "psm_user.h"
39 #include "ips_proto_header.h"
40
41 /* ips_alloc_scb flags */
42 #define IPS_SCB_FLAG_NONE 0x0
43 #define IPS_SCB_FLAG_ADD_BUFFER 0x1
44
45 /* macros to update scb */
46 #define ips_scb_mqhdr(scb) scb->ips_lrh.mqhdr
47 #define ips_scb_mqtag(scb) scb->ips_lrh.data[0].u64w0
48 #define ips_scb_mqparam(scb) scb->ips_lrh.data[1]
49 #define ips_scb_uwords(scb) scb->ips_lrh.data
50 #define ips_scb_subopcode(scb) scb->ips_lrh.sub_opcode
51 #define ips_scb_buffer(scb) scb->payload
52 #define ips_scb_length(scb) scb->payload_size
53 #define ips_scb_flags(scb) scb->flags
54 #define ips_scb_dma_ctr(scb) scb->dma_ctr
55 #define ips_scb_epaddr(scb) scb->epaddr
56 #define ips_scb_cb(scb) scb->callback
57 #define ips_scb_cb_param(scb) scb->cb_param
58 #define ips_scb_hdr_dlen(scb) scb->ips_lrh.hdr_dlen
59
60 struct ips_scbbuf;
61 struct ips_scb;
62 struct ips_scbctrl;
63 struct ips_tid_send_desc;
64
65 typedef void (*ips_scbctrl_avail_callback_fn_t)(struct ips_scbctrl *,
66 void *context);
67
68 STAILQ_HEAD(ips_scb_stailq, ips_scb);
69 SLIST_HEAD(ips_scb_slist, ips_scb);
70
71 struct ips_scbctrl {
72 //const psmi_context_t *context;
73
74 /* Send control blocks for each send */
75 uint32_t scb_num;
76 uint32_t scb_num_cur;
77 SLIST_HEAD(scb_free, ips_scb) scb_free;
78 void *scb_base;
79 ips_scbctrl_avail_callback_fn_t scb_avail_callback;
80 void *scb_avail_context;
81
82 /* Immediate data for send buffers */
83 uint32_t scb_imm_size;
84 void *scb_imm_buf;
85
86 /*
87 * Send buffers (or bounce buffers) to keep user data if we need to
88 * retransmit.
89 */
90 uint32_t sbuf_num;
91 uint32_t sbuf_num_cur;
92 SLIST_HEAD(sbuf_free, ips_scbbuf) sbuf_free;
93 void *sbuf_buf_alloc;
94 uint32_t sbuf_buf_size;
95 void *sbuf_buf_base;
96 void *sbuf_buf_last;
97 };
98
99 struct ips_scbbuf {
100 SLIST_ENTRY(ips_scbbuf) next;
101 };
102
103 typedef struct ips_scb ips_scb_t;
104
105 struct ips_scb {
106 union {
107 SLIST_ENTRY(ips_scb) next;
108 STAILQ_ENTRY(ips_scb) nextq;
109 };
110 union {
111 void *payload;
112 struct ips_scbbuf *sbuf;
113 };
114 uint64_t ack_timeout; /* in cycles */
115 uint64_t abs_timeout; /* in cycles */
116
117 /* Used when composing packet */
118 psmi_seqnum_t seq_num;
119 uint32_t payload_size;
120 uint32_t extra_bytes;
121 uint32_t cksum;
122 uint32_t flags;
123 uint32_t dma_ctr;
124 uint32_t payload_bytes;
125 uint16_t pkt_flags;
126 uint16_t tid;
127 uint16_t offset;
128 uint16_t nfrag;
129 uint16_t frag_size;
130
131 struct ips_flow *flow;
132 struct ptl_epaddr *epaddr;
133 struct ips_tid_send_desc *tidsendc;
134 void *tsess;
135 uint16_t tsess_length;
136
137
138 struct ips_scbctrl *scbc;
139 void *imm_payload;
140
141 union {
142 int (*callback) (void *, uint32_t);
143 psm_am_completion_fn_t completion_am;
144 };
145 void *cb_param;
146
147 struct {
148 union ipath_pbc pbc;
149 struct ips_message_header ips_lrh;
150 } PSMI_CACHEALIGN;
151 };
152
153 void ips_scbctrl_free(ips_scb_t *scb);
154 int ips_scbctrl_bufalloc(ips_scb_t *scb);
155 int ips_scbctrl_avail(struct ips_scbctrl *scbc);
156 ips_scb_t * ips_scbctrl_alloc(struct ips_scbctrl *scbc,
157 int scbnum, int len, uint32_t flags);
158 ips_scb_t * ips_scbctrl_alloc_tiny(struct ips_scbctrl *scbc);
159
160 psm_error_t ips_scbctrl_init(const psmi_context_t *context,
161 uint32_t numscb, uint32_t numbufs,
162 uint32_t imm_size, uint32_t bufsize,
163 ips_scbctrl_avail_callback_fn_t, void *avail_context,
164 struct ips_scbctrl *);
165 psm_error_t ips_scbctrl_fini(struct ips_scbctrl *);
166
167 psm_error_t ips_scbctrl_writev(struct ips_scb_slist *slist, int fd);
168
169 #endif /* _IPS_SCB_H */