1
2
3
4
5
6#ifndef _PIO_H
7#define _PIO_H
8
9#define SC_KERNEL 0
10#define SC_VL15 1
11#define SC_ACK 2
12#define SC_USER 3
13#define SC_MAX 4
14
15
16#define INVALID_SCI 0xff
17
18
19typedef void (*pio_release_cb)(void *arg, int code);
20
21
22#define PRC_OK 0
23#define PRC_STATUS_ERR 0x01
24#define PRC_PBC 0x02
25#define PRC_THRESHOLD 0x04
26#define PRC_FILL_ERR 0x08
27#define PRC_FORCE 0x10
28#define PRC_SC_DISABLE 0x20
29
30
31union mix {
32 u64 val64;
33 u32 val32[2];
34 u8 val8[8];
35};
36
37
38struct pio_buf {
39 struct send_context *sc;
40 pio_release_cb cb;
41 void *arg;
42 void __iomem *start;
43 void __iomem *end;
44 unsigned long sent_at;
45 union mix carry;
46 u16 qw_written;
47 u8 carry_bytes;
48};
49
50
51union pio_shadow_ring {
52 struct pio_buf pbuf;
53} ____cacheline_aligned;
54
55
56struct send_context {
57
58 struct hfi1_devdata *dd;
59 union pio_shadow_ring *sr;
60 void __iomem *base_addr;
61 u32 __percpu *buffers_allocated;
62 u32 size;
63
64 int node;
65 u32 sr_size;
66 u16 flags;
67 u8 type;
68 u8 sw_index;
69 u8 hw_context;
70 u8 group;
71
72
73 spinlock_t alloc_lock ____cacheline_aligned_in_smp;
74 u32 sr_head;
75 unsigned long fill;
76 unsigned long alloc_free;
77 u32 fill_wrap;
78 u32 credits;
79
80
81
82 spinlock_t release_lock ____cacheline_aligned_in_smp;
83 u32 sr_tail;
84 unsigned long free;
85 volatile __le64 *hw_free;
86
87 struct list_head piowait ____cacheline_aligned_in_smp;
88 seqlock_t waitlock;
89
90 spinlock_t credit_ctrl_lock ____cacheline_aligned_in_smp;
91 u32 credit_intr_count;
92 u64 credit_ctrl;
93 wait_queue_head_t halt_wait;
94 struct work_struct halt_work;
95};
96
97
98#define SCF_ENABLED 0x01
99#define SCF_IN_FREE 0x02
100#define SCF_HALTED 0x04
101#define SCF_FROZEN 0x08
102#define SCF_LINK_DOWN 0x10
103
104struct send_context_info {
105 struct send_context *sc;
106 u16 allocated;
107 u16 type;
108 u16 base;
109 u16 credits;
110};
111
112
113struct credit_return {
114 volatile __le64 cr[8];
115};
116
117
118struct credit_return_base {
119 struct credit_return *va;
120 dma_addr_t dma;
121};
122
123
124struct sc_config_sizes {
125 short int size;
126 short int count;
127};
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191#define INIT_SC_PER_VL 2
192
193
194
195
196
197
198
199
200
201
202struct pio_map_elem {
203 u32 mask;
204 struct send_context *ksc[];
205};
206
207
208
209
210
211
212
213
214
215
216
217
218
219struct pio_vl_map {
220 struct rcu_head list;
221 u32 mask;
222 u8 actual_vls;
223 u8 vls;
224 struct pio_map_elem *map[];
225};
226
227int pio_map_init(struct hfi1_devdata *dd, u8 port, u8 num_vls,
228 u8 *vl_scontexts);
229void free_pio_map(struct hfi1_devdata *dd);
230struct send_context *pio_select_send_context_vl(struct hfi1_devdata *dd,
231 u32 selector, u8 vl);
232struct send_context *pio_select_send_context_sc(struct hfi1_devdata *dd,
233 u32 selector, u8 sc5);
234
235
236int init_credit_return(struct hfi1_devdata *dd);
237void free_credit_return(struct hfi1_devdata *dd);
238int init_sc_pools_and_sizes(struct hfi1_devdata *dd);
239int init_send_contexts(struct hfi1_devdata *dd);
240int init_pervl_scs(struct hfi1_devdata *dd);
241struct send_context *sc_alloc(struct hfi1_devdata *dd, int type,
242 uint hdrqentsize, int numa);
243void sc_free(struct send_context *sc);
244int sc_enable(struct send_context *sc);
245void sc_disable(struct send_context *sc);
246int sc_restart(struct send_context *sc);
247void sc_return_credits(struct send_context *sc);
248void sc_flush(struct send_context *sc);
249void sc_drop(struct send_context *sc);
250void sc_stop(struct send_context *sc, int bit);
251struct pio_buf *sc_buffer_alloc(struct send_context *sc, u32 dw_len,
252 pio_release_cb cb, void *arg);
253void sc_release_update(struct send_context *sc);
254void sc_group_release_update(struct hfi1_devdata *dd, u32 hw_context);
255void sc_add_credit_return_intr(struct send_context *sc);
256void sc_del_credit_return_intr(struct send_context *sc);
257void sc_set_cr_threshold(struct send_context *sc, u32 new_threshold);
258u32 sc_percent_to_threshold(struct send_context *sc, u32 percent);
259u32 sc_mtu_to_threshold(struct send_context *sc, u32 mtu, u32 hdrqentsize);
260void hfi1_sc_wantpiobuf_intr(struct send_context *sc, u32 needint);
261void sc_wait(struct hfi1_devdata *dd);
262void set_pio_integrity(struct send_context *sc);
263
264
265void pio_reset_all(struct hfi1_devdata *dd);
266void pio_freeze(struct hfi1_devdata *dd);
267void pio_kernel_unfreeze(struct hfi1_devdata *dd);
268void pio_kernel_linkup(struct hfi1_devdata *dd);
269
270
271#define PSC_GLOBAL_ENABLE 0
272#define PSC_GLOBAL_DISABLE 1
273#define PSC_GLOBAL_VLARB_ENABLE 2
274#define PSC_GLOBAL_VLARB_DISABLE 3
275#define PSC_CM_RESET 4
276#define PSC_DATA_VL_ENABLE 5
277#define PSC_DATA_VL_DISABLE 6
278
279void __cm_reset(struct hfi1_devdata *dd, u64 sendctrl);
280void pio_send_control(struct hfi1_devdata *dd, int op);
281
282
283void pio_copy(struct hfi1_devdata *dd, struct pio_buf *pbuf, u64 pbc,
284 const void *from, size_t count);
285void seg_pio_copy_start(struct pio_buf *pbuf, u64 pbc,
286 const void *from, size_t nbytes);
287void seg_pio_copy_mid(struct pio_buf *pbuf, const void *from, size_t nbytes);
288void seg_pio_copy_end(struct pio_buf *pbuf);
289
290void seqfile_dump_sci(struct seq_file *s, u32 i,
291 struct send_context_info *sci);
292
293#endif
294