xref: /openbmc/linux/drivers/infiniband/hw/hfi1/pio.h (revision e8ea95af879e1c2bdf160e9bfd1c8db013454421)
1f48ad614SDennis Dalessandro #ifndef _PIO_H
2f48ad614SDennis Dalessandro #define _PIO_H
3f48ad614SDennis Dalessandro /*
42280740fSVishwanathapura, Niranjana  * Copyright(c) 2015-2017 Intel Corporation.
5f48ad614SDennis Dalessandro  *
6f48ad614SDennis Dalessandro  * This file is provided under a dual BSD/GPLv2 license.  When using or
7f48ad614SDennis Dalessandro  * redistributing this file, you may do so under either license.
8f48ad614SDennis Dalessandro  *
9f48ad614SDennis Dalessandro  * GPL LICENSE SUMMARY
10f48ad614SDennis Dalessandro  *
11f48ad614SDennis Dalessandro  * This program is free software; you can redistribute it and/or modify
12f48ad614SDennis Dalessandro  * it under the terms of version 2 of the GNU General Public License as
13f48ad614SDennis Dalessandro  * published by the Free Software Foundation.
14f48ad614SDennis Dalessandro  *
15f48ad614SDennis Dalessandro  * This program is distributed in the hope that it will be useful, but
16f48ad614SDennis Dalessandro  * WITHOUT ANY WARRANTY; without even the implied warranty of
17f48ad614SDennis Dalessandro  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18f48ad614SDennis Dalessandro  * General Public License for more details.
19f48ad614SDennis Dalessandro  *
20f48ad614SDennis Dalessandro  * BSD LICENSE
21f48ad614SDennis Dalessandro  *
22f48ad614SDennis Dalessandro  * Redistribution and use in source and binary forms, with or without
23f48ad614SDennis Dalessandro  * modification, are permitted provided that the following conditions
24f48ad614SDennis Dalessandro  * are met:
25f48ad614SDennis Dalessandro  *
26f48ad614SDennis Dalessandro  *  - Redistributions of source code must retain the above copyright
27f48ad614SDennis Dalessandro  *    notice, this list of conditions and the following disclaimer.
28f48ad614SDennis Dalessandro  *  - Redistributions in binary form must reproduce the above copyright
29f48ad614SDennis Dalessandro  *    notice, this list of conditions and the following disclaimer in
30f48ad614SDennis Dalessandro  *    the documentation and/or other materials provided with the
31f48ad614SDennis Dalessandro  *    distribution.
32f48ad614SDennis Dalessandro  *  - Neither the name of Intel Corporation nor the names of its
33f48ad614SDennis Dalessandro  *    contributors may be used to endorse or promote products derived
34f48ad614SDennis Dalessandro  *    from this software without specific prior written permission.
35f48ad614SDennis Dalessandro  *
36f48ad614SDennis Dalessandro  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
37f48ad614SDennis Dalessandro  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
38f48ad614SDennis Dalessandro  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
39f48ad614SDennis Dalessandro  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
40f48ad614SDennis Dalessandro  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41f48ad614SDennis Dalessandro  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42f48ad614SDennis Dalessandro  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
43f48ad614SDennis Dalessandro  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
44f48ad614SDennis Dalessandro  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
45f48ad614SDennis Dalessandro  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
46f48ad614SDennis Dalessandro  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
47f48ad614SDennis Dalessandro  *
48f48ad614SDennis Dalessandro  */
49f48ad614SDennis Dalessandro 
50f48ad614SDennis Dalessandro /* send context types */
51f48ad614SDennis Dalessandro #define SC_KERNEL 0
52f48ad614SDennis Dalessandro #define SC_VL15   1
53f48ad614SDennis Dalessandro #define SC_ACK    2
54f48ad614SDennis Dalessandro #define SC_USER   3	/* must be the last one: it may take all left */
55f48ad614SDennis Dalessandro #define SC_MAX    4	/* count of send context types */
56f48ad614SDennis Dalessandro 
572280740fSVishwanathapura, Niranjana /*
582280740fSVishwanathapura, Niranjana  * SC_VNIC types are allocated (dynamically) from the user context pool,
592280740fSVishwanathapura, Niranjana  * (SC_USER) and used by kernel driver as kernel contexts (SC_KERNEL).
602280740fSVishwanathapura, Niranjana  */
612280740fSVishwanathapura, Niranjana #define SC_VNIC   SC_MAX
622280740fSVishwanathapura, Niranjana 
63f48ad614SDennis Dalessandro /* invalid send context index */
64f48ad614SDennis Dalessandro #define INVALID_SCI 0xff
65f48ad614SDennis Dalessandro 
66f48ad614SDennis Dalessandro /* PIO buffer release callback function */
67f48ad614SDennis Dalessandro typedef void (*pio_release_cb)(void *arg, int code);
68f48ad614SDennis Dalessandro 
69f48ad614SDennis Dalessandro /* PIO release codes - in bits, as there could more than one that apply */
70f48ad614SDennis Dalessandro #define PRC_OK		0	/* no known error */
71f48ad614SDennis Dalessandro #define PRC_STATUS_ERR	0x01	/* credit return due to status error */
72f48ad614SDennis Dalessandro #define PRC_PBC		0x02	/* credit return due to PBC */
73f48ad614SDennis Dalessandro #define PRC_THRESHOLD	0x04	/* credit return due to threshold */
74f48ad614SDennis Dalessandro #define PRC_FILL_ERR	0x08	/* credit return due fill error */
75f48ad614SDennis Dalessandro #define PRC_FORCE	0x10	/* credit return due credit force */
76f48ad614SDennis Dalessandro #define PRC_SC_DISABLE	0x20	/* clean-up after a context disable */
77f48ad614SDennis Dalessandro 
78f48ad614SDennis Dalessandro /* byte helper */
79f48ad614SDennis Dalessandro union mix {
80f48ad614SDennis Dalessandro 	u64 val64;
81f48ad614SDennis Dalessandro 	u32 val32[2];
82f48ad614SDennis Dalessandro 	u8  val8[8];
83f48ad614SDennis Dalessandro };
84f48ad614SDennis Dalessandro 
85f48ad614SDennis Dalessandro /* an allocated PIO buffer */
86f48ad614SDennis Dalessandro struct pio_buf {
87f48ad614SDennis Dalessandro 	struct send_context *sc;/* back pointer to owning send context */
88f48ad614SDennis Dalessandro 	pio_release_cb cb;	/* called when the buffer is released */
89f48ad614SDennis Dalessandro 	void *arg;		/* argument for cb */
90f48ad614SDennis Dalessandro 	void __iomem *start;	/* buffer start address */
91f48ad614SDennis Dalessandro 	void __iomem *end;	/* context end address */
92f48ad614SDennis Dalessandro 	unsigned long sent_at;	/* buffer is sent when <= free */
93f48ad614SDennis Dalessandro 	union mix carry;	/* pending unwritten bytes */
948af8d297SSebastian Sanchez 	u16 qw_written;		/* QW written so far */
958af8d297SSebastian Sanchez 	u8 carry_bytes;	/* number of valid bytes in carry */
96f48ad614SDennis Dalessandro };
97f48ad614SDennis Dalessandro 
98f48ad614SDennis Dalessandro /* cache line aligned pio buffer array */
99f48ad614SDennis Dalessandro union pio_shadow_ring {
100f48ad614SDennis Dalessandro 	struct pio_buf pbuf;
101f48ad614SDennis Dalessandro } ____cacheline_aligned;
102f48ad614SDennis Dalessandro 
103f48ad614SDennis Dalessandro /* per-NUMA send context */
104f48ad614SDennis Dalessandro struct send_context {
105f48ad614SDennis Dalessandro 	/* read-only after init */
106f48ad614SDennis Dalessandro 	struct hfi1_devdata *dd;		/* device */
107f48ad614SDennis Dalessandro 	union pio_shadow_ring *sr;	/* shadow ring */
1088af8d297SSebastian Sanchez 	void __iomem *base_addr;	/* start of PIO memory */
1098af8d297SSebastian Sanchez 	u32 __percpu *buffers_allocated;/* count of buffers allocated */
1108af8d297SSebastian Sanchez 	u32 size;			/* context size, in bytes */
111f48ad614SDennis Dalessandro 
112f48ad614SDennis Dalessandro 	int node;			/* context home node */
113f48ad614SDennis Dalessandro 	u32 sr_size;			/* size of the shadow ring */
1148af8d297SSebastian Sanchez 	u16 flags;			/* flags */
1158af8d297SSebastian Sanchez 	u8  type;			/* context type */
1168af8d297SSebastian Sanchez 	u8  sw_index;			/* software index number */
1178af8d297SSebastian Sanchez 	u8  hw_context;			/* hardware context number */
1188af8d297SSebastian Sanchez 	u8  group;			/* credit return group */
1198af8d297SSebastian Sanchez 
120f48ad614SDennis Dalessandro 	/* allocator fields */
121f48ad614SDennis Dalessandro 	spinlock_t alloc_lock ____cacheline_aligned_in_smp;
12299c7abfbSMike Marciniszyn 	u32 sr_head;			/* shadow ring head */
123f48ad614SDennis Dalessandro 	unsigned long fill;		/* official alloc count */
124f48ad614SDennis Dalessandro 	unsigned long alloc_free;	/* copy of free (less cache thrash) */
1252474d775SSebastian Sanchez 	u32 fill_wrap;			/* tracks fill within ring */
1268af8d297SSebastian Sanchez 	u32 credits;			/* number of blocks in context */
1278af8d297SSebastian Sanchez 	/* adding a new field here would make it part of this cacheline */
1288af8d297SSebastian Sanchez 
129f48ad614SDennis Dalessandro 	/* releaser fields */
130f48ad614SDennis Dalessandro 	spinlock_t release_lock ____cacheline_aligned_in_smp;
131f48ad614SDennis Dalessandro 	u32 sr_tail;			/* shadow ring tail */
13299c7abfbSMike Marciniszyn 	unsigned long free;		/* official free count */
13399c7abfbSMike Marciniszyn 	volatile __le64 *hw_free;	/* HW free counter */
134f48ad614SDennis Dalessandro 	/* list for PIO waiters */
135f48ad614SDennis Dalessandro 	struct list_head piowait  ____cacheline_aligned_in_smp;
136f48ad614SDennis Dalessandro 	spinlock_t credit_ctrl_lock ____cacheline_aligned_in_smp;
137f48ad614SDennis Dalessandro 	u32 credit_intr_count;		/* count of credit intr users */
13899c7abfbSMike Marciniszyn 	u64 credit_ctrl;		/* cache for credit control */
139f48ad614SDennis Dalessandro 	wait_queue_head_t halt_wait;    /* wait until kernel sees interrupt */
1408af8d297SSebastian Sanchez 	struct work_struct halt_work;	/* halted context work queue entry */
141f48ad614SDennis Dalessandro };
142f48ad614SDennis Dalessandro 
143f48ad614SDennis Dalessandro /* send context flags */
144f48ad614SDennis Dalessandro #define SCF_ENABLED 0x01
145f48ad614SDennis Dalessandro #define SCF_IN_FREE 0x02
146f48ad614SDennis Dalessandro #define SCF_HALTED  0x04
147f48ad614SDennis Dalessandro #define SCF_FROZEN  0x08
148f48ad614SDennis Dalessandro 
149f48ad614SDennis Dalessandro struct send_context_info {
150f48ad614SDennis Dalessandro 	struct send_context *sc;	/* allocated working context */
151f48ad614SDennis Dalessandro 	u16 allocated;			/* has this been allocated? */
152f48ad614SDennis Dalessandro 	u16 type;			/* context type */
153f48ad614SDennis Dalessandro 	u16 base;			/* base in PIO array */
154f48ad614SDennis Dalessandro 	u16 credits;			/* size in PIO array */
155f48ad614SDennis Dalessandro };
156f48ad614SDennis Dalessandro 
157f48ad614SDennis Dalessandro /* DMA credit return, index is always (context & 0x7) */
158f48ad614SDennis Dalessandro struct credit_return {
159f48ad614SDennis Dalessandro 	volatile __le64 cr[8];
160f48ad614SDennis Dalessandro };
161f48ad614SDennis Dalessandro 
162f48ad614SDennis Dalessandro /* NUMA indexed credit return array */
163f48ad614SDennis Dalessandro struct credit_return_base {
164f48ad614SDennis Dalessandro 	struct credit_return *va;
16560368186STymoteusz Kielan 	dma_addr_t dma;
166f48ad614SDennis Dalessandro };
167f48ad614SDennis Dalessandro 
168f48ad614SDennis Dalessandro /* send context configuration sizes (one per type) */
169f48ad614SDennis Dalessandro struct sc_config_sizes {
170f48ad614SDennis Dalessandro 	short int size;
171f48ad614SDennis Dalessandro 	short int count;
172f48ad614SDennis Dalessandro };
173f48ad614SDennis Dalessandro 
174f48ad614SDennis Dalessandro /*
175f48ad614SDennis Dalessandro  * The diagram below details the relationship of the mapping structures
176f48ad614SDennis Dalessandro  *
177f48ad614SDennis Dalessandro  * Since the mapping now allows for non-uniform send contexts per vl, the
178f48ad614SDennis Dalessandro  * number of send contexts for a vl is either the vl_scontexts[vl] or
179f48ad614SDennis Dalessandro  * a computation based on num_kernel_send_contexts/num_vls:
180f48ad614SDennis Dalessandro  *
181f48ad614SDennis Dalessandro  * For example:
182f48ad614SDennis Dalessandro  * nactual = vl_scontexts ? vl_scontexts[vl] : num_kernel_send_contexts/num_vls
183f48ad614SDennis Dalessandro  *
184f48ad614SDennis Dalessandro  * n = roundup to next highest power of 2 using nactual
185f48ad614SDennis Dalessandro  *
186f48ad614SDennis Dalessandro  * In the case where there are num_kernel_send_contexts/num_vls doesn't divide
187f48ad614SDennis Dalessandro  * evenly, the extras are added from the last vl downward.
188f48ad614SDennis Dalessandro  *
189f48ad614SDennis Dalessandro  * For the case where n > nactual, the send contexts are assigned
190f48ad614SDennis Dalessandro  * in a round robin fashion wrapping back to the first send context
191f48ad614SDennis Dalessandro  * for a particular vl.
192f48ad614SDennis Dalessandro  *
193f48ad614SDennis Dalessandro  *               dd->pio_map
194f48ad614SDennis Dalessandro  *                    |                                   pio_map_elem[0]
195f48ad614SDennis Dalessandro  *                    |                                +--------------------+
196f48ad614SDennis Dalessandro  *                    v                                |       mask         |
197f48ad614SDennis Dalessandro  *               pio_vl_map                            |--------------------|
198f48ad614SDennis Dalessandro  *      +--------------------------+                   | ksc[0] -> sc 1     |
199f48ad614SDennis Dalessandro  *      |    list (RCU)            |                   |--------------------|
200f48ad614SDennis Dalessandro  *      |--------------------------|                 ->| ksc[1] -> sc 2     |
201f48ad614SDennis Dalessandro  *      |    mask                  |              --/  |--------------------|
202f48ad614SDennis Dalessandro  *      |--------------------------|            -/     |        *           |
203f48ad614SDennis Dalessandro  *      |    actual_vls (max 8)    |          -/       |--------------------|
204*e8ea95afSIra Weiny  *      |--------------------------|       --/         | ksc[n-1] -> sc n   |
205f48ad614SDennis Dalessandro  *      |    vls (max 8)           |     -/            +--------------------+
206f48ad614SDennis Dalessandro  *      |--------------------------|  --/
207f48ad614SDennis Dalessandro  *      |    map[0]                |-/
208f48ad614SDennis Dalessandro  *      |--------------------------|                   +--------------------+
209f48ad614SDennis Dalessandro  *      |    map[1]                |---                |       mask         |
210f48ad614SDennis Dalessandro  *      |--------------------------|   \----           |--------------------|
211f48ad614SDennis Dalessandro  *      |           *              |        \--        | ksc[0] -> sc 1+n   |
212f48ad614SDennis Dalessandro  *      |           *              |           \----   |--------------------|
213f48ad614SDennis Dalessandro  *      |           *              |                \->| ksc[1] -> sc 2+n   |
214f48ad614SDennis Dalessandro  *      |--------------------------|                   |--------------------|
215f48ad614SDennis Dalessandro  *      |   map[vls - 1]           |-                  |         *          |
216f48ad614SDennis Dalessandro  *      +--------------------------+ \-                |--------------------|
217*e8ea95afSIra Weiny  *                                     \-              | ksc[m-1] -> sc m+n |
218f48ad614SDennis Dalessandro  *                                       \             +--------------------+
219f48ad614SDennis Dalessandro  *                                        \-
220f48ad614SDennis Dalessandro  *                                          \
221*e8ea95afSIra Weiny  *                                           \-        +----------------------+
222f48ad614SDennis Dalessandro  *                                             \-      |       mask           |
223*e8ea95afSIra Weiny  *                                               \     |----------------------|
224f48ad614SDennis Dalessandro  *                                                \-   | ksc[0] -> sc 1+m+n   |
225*e8ea95afSIra Weiny  *                                                  \- |----------------------|
226f48ad614SDennis Dalessandro  *                                                    >| ksc[1] -> sc 2+m+n   |
227*e8ea95afSIra Weiny  *                                                     |----------------------|
228f48ad614SDennis Dalessandro  *                                                     |         *            |
229*e8ea95afSIra Weiny  *                                                     |----------------------|
230*e8ea95afSIra Weiny  *                                                     | ksc[o-1] -> sc o+m+n |
231*e8ea95afSIra Weiny  *                                                     +----------------------+
232f48ad614SDennis Dalessandro  *
233f48ad614SDennis Dalessandro  */
234f48ad614SDennis Dalessandro 
235f48ad614SDennis Dalessandro /* Initial number of send contexts per VL */
236f48ad614SDennis Dalessandro #define INIT_SC_PER_VL 2
237f48ad614SDennis Dalessandro 
238f48ad614SDennis Dalessandro /*
239f48ad614SDennis Dalessandro  * struct pio_map_elem - mapping for a vl
240f48ad614SDennis Dalessandro  * @mask - selector mask
241f48ad614SDennis Dalessandro  * @ksc - array of kernel send contexts for this vl
242f48ad614SDennis Dalessandro  *
243f48ad614SDennis Dalessandro  * The mask is used to "mod" the selector to
244f48ad614SDennis Dalessandro  * produce index into the trailing array of
245f48ad614SDennis Dalessandro  * kscs
246f48ad614SDennis Dalessandro  */
247f48ad614SDennis Dalessandro struct pio_map_elem {
248f48ad614SDennis Dalessandro 	u32 mask;
249f48ad614SDennis Dalessandro 	struct send_context *ksc[0];
250f48ad614SDennis Dalessandro };
251f48ad614SDennis Dalessandro 
252f48ad614SDennis Dalessandro /*
253f48ad614SDennis Dalessandro  * struct pio_vl_map - mapping for a vl
254f48ad614SDennis Dalessandro  * @list - rcu head for free callback
255f48ad614SDennis Dalessandro  * @mask - vl mask to "mod" the vl to produce an index to map array
256f48ad614SDennis Dalessandro  * @actual_vls - number of vls
257f48ad614SDennis Dalessandro  * @vls - numbers of vls rounded to next power of 2
258f48ad614SDennis Dalessandro  * @map - array of pio_map_elem entries
259f48ad614SDennis Dalessandro  *
260f48ad614SDennis Dalessandro  * This is the parent mapping structure. The trailing members of the
261f48ad614SDennis Dalessandro  * struct point to pio_map_elem entries, which in turn point to an
262f48ad614SDennis Dalessandro  * array of kscs for that vl.
263f48ad614SDennis Dalessandro  */
264f48ad614SDennis Dalessandro struct pio_vl_map {
265f48ad614SDennis Dalessandro 	struct rcu_head list;
266f48ad614SDennis Dalessandro 	u32 mask;
267f48ad614SDennis Dalessandro 	u8 actual_vls;
268f48ad614SDennis Dalessandro 	u8 vls;
269f48ad614SDennis Dalessandro 	struct pio_map_elem *map[0];
270f48ad614SDennis Dalessandro };
271f48ad614SDennis Dalessandro 
272f48ad614SDennis Dalessandro int pio_map_init(struct hfi1_devdata *dd, u8 port, u8 num_vls,
273f48ad614SDennis Dalessandro 		 u8 *vl_scontexts);
274f48ad614SDennis Dalessandro void free_pio_map(struct hfi1_devdata *dd);
275f48ad614SDennis Dalessandro struct send_context *pio_select_send_context_vl(struct hfi1_devdata *dd,
276f48ad614SDennis Dalessandro 						u32 selector, u8 vl);
277f48ad614SDennis Dalessandro struct send_context *pio_select_send_context_sc(struct hfi1_devdata *dd,
278f48ad614SDennis Dalessandro 						u32 selector, u8 sc5);
279f48ad614SDennis Dalessandro 
280f48ad614SDennis Dalessandro /* send context functions */
281f48ad614SDennis Dalessandro int init_credit_return(struct hfi1_devdata *dd);
282f48ad614SDennis Dalessandro void free_credit_return(struct hfi1_devdata *dd);
283f48ad614SDennis Dalessandro int init_sc_pools_and_sizes(struct hfi1_devdata *dd);
284f48ad614SDennis Dalessandro int init_send_contexts(struct hfi1_devdata *dd);
285f48ad614SDennis Dalessandro int init_credit_return(struct hfi1_devdata *dd);
286f48ad614SDennis Dalessandro int init_pervl_scs(struct hfi1_devdata *dd);
287f48ad614SDennis Dalessandro struct send_context *sc_alloc(struct hfi1_devdata *dd, int type,
288f48ad614SDennis Dalessandro 			      uint hdrqentsize, int numa);
289f48ad614SDennis Dalessandro void sc_free(struct send_context *sc);
290f48ad614SDennis Dalessandro int sc_enable(struct send_context *sc);
291f48ad614SDennis Dalessandro void sc_disable(struct send_context *sc);
292f48ad614SDennis Dalessandro int sc_restart(struct send_context *sc);
293f48ad614SDennis Dalessandro void sc_return_credits(struct send_context *sc);
294f48ad614SDennis Dalessandro void sc_flush(struct send_context *sc);
295f48ad614SDennis Dalessandro void sc_drop(struct send_context *sc);
296f48ad614SDennis Dalessandro void sc_stop(struct send_context *sc, int bit);
297f48ad614SDennis Dalessandro struct pio_buf *sc_buffer_alloc(struct send_context *sc, u32 dw_len,
298f48ad614SDennis Dalessandro 				pio_release_cb cb, void *arg);
299f48ad614SDennis Dalessandro void sc_release_update(struct send_context *sc);
300f48ad614SDennis Dalessandro void sc_return_credits(struct send_context *sc);
301f48ad614SDennis Dalessandro void sc_group_release_update(struct hfi1_devdata *dd, u32 hw_context);
302f48ad614SDennis Dalessandro void sc_add_credit_return_intr(struct send_context *sc);
303f48ad614SDennis Dalessandro void sc_del_credit_return_intr(struct send_context *sc);
304f48ad614SDennis Dalessandro void sc_set_cr_threshold(struct send_context *sc, u32 new_threshold);
305f48ad614SDennis Dalessandro u32 sc_percent_to_threshold(struct send_context *sc, u32 percent);
306f48ad614SDennis Dalessandro u32 sc_mtu_to_threshold(struct send_context *sc, u32 mtu, u32 hdrqentsize);
307f48ad614SDennis Dalessandro void hfi1_sc_wantpiobuf_intr(struct send_context *sc, u32 needint);
308f48ad614SDennis Dalessandro void sc_wait(struct hfi1_devdata *dd);
309f48ad614SDennis Dalessandro void set_pio_integrity(struct send_context *sc);
310f48ad614SDennis Dalessandro 
311f48ad614SDennis Dalessandro /* support functions */
312f48ad614SDennis Dalessandro void pio_reset_all(struct hfi1_devdata *dd);
313f48ad614SDennis Dalessandro void pio_freeze(struct hfi1_devdata *dd);
314f48ad614SDennis Dalessandro void pio_kernel_unfreeze(struct hfi1_devdata *dd);
315f48ad614SDennis Dalessandro 
316f48ad614SDennis Dalessandro /* global PIO send control operations */
317f48ad614SDennis Dalessandro #define PSC_GLOBAL_ENABLE 0
318f48ad614SDennis Dalessandro #define PSC_GLOBAL_DISABLE 1
319f48ad614SDennis Dalessandro #define PSC_GLOBAL_VLARB_ENABLE 2
320f48ad614SDennis Dalessandro #define PSC_GLOBAL_VLARB_DISABLE 3
321f48ad614SDennis Dalessandro #define PSC_CM_RESET 4
322f48ad614SDennis Dalessandro #define PSC_DATA_VL_ENABLE 5
323f48ad614SDennis Dalessandro #define PSC_DATA_VL_DISABLE 6
324f48ad614SDennis Dalessandro 
325f48ad614SDennis Dalessandro void __cm_reset(struct hfi1_devdata *dd, u64 sendctrl);
326f48ad614SDennis Dalessandro void pio_send_control(struct hfi1_devdata *dd, int op);
327f48ad614SDennis Dalessandro 
328f48ad614SDennis Dalessandro /* PIO copy routines */
329f48ad614SDennis Dalessandro void pio_copy(struct hfi1_devdata *dd, struct pio_buf *pbuf, u64 pbc,
330f48ad614SDennis Dalessandro 	      const void *from, size_t count);
331f48ad614SDennis Dalessandro void seg_pio_copy_start(struct pio_buf *pbuf, u64 pbc,
332f48ad614SDennis Dalessandro 			const void *from, size_t nbytes);
333f48ad614SDennis Dalessandro void seg_pio_copy_mid(struct pio_buf *pbuf, const void *from, size_t nbytes);
334f48ad614SDennis Dalessandro void seg_pio_copy_end(struct pio_buf *pbuf);
335f48ad614SDennis Dalessandro 
336f48ad614SDennis Dalessandro #endif /* _PIO_H */
337