Debian Codegraph @

ptl_ips/ips_recvq.h

raw
1 /*
2 * Copyright (c) 2006-2012. QLogic Corporation. All rights reserved.
3 * Copyright (c) 2003-2006, PathScale, Inc. All rights reserved.
4 *
5 * This software is available to you under a choice of one of two
6 * licenses. You may choose to be licensed under the terms of the GNU
7 * General Public License (GPL) Version 2, available from the file
8 * COPYING in the main directory of this source tree, or the
9 * OpenIB.org BSD license below:
10 *
11 * Redistribution and use in source and binary forms, with or
12 * without modification, are permitted provided that the following
13 * conditions are met:
14 *
15 * - Redistributions of source code must retain the above
16 * copyright notice, this list of conditions and the following
17 * disclaimer.
18 *
19 * - Redistributions in binary form must reproduce the above
20 * copyright notice, this list of conditions and the following
21 * disclaimer in the documentation and/or other materials
22 * provided with the distribution.
23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
28 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE.
32 */
33
34 #ifndef _IPS_RECVQ_H
35 #define _IPS_RECVQ_H
36
37 #include "psm_user.h"
38
39 struct ips_recvq_params {
40 volatile __le32 *tail_register; /* location of tail */
41 volatile __le32 *head_register; /* location of head */
42 uint32_t *base_addr; /* base address of q */
43 uint32_t elemsz; /* size of q elements (in words) */
44 uint32_t elemcnt; /* num of q elements (in words) */
45 };
46
47 /*
48 * Tables to map eager indexes into their buffer addresses
49 *
50 * If function returns NULL, no memory has been allocated and the error handler
51 * has been executed on 'ep' and hence assume status PSM_NO_MEMORY.
52 */
53 void **ips_recvq_egrbuf_table_alloc(psm_ep_t ep,
54 void *base, uint32_t chunksize,
55 uint32_t bufnum, uint32_t bufsize);
56 void ips_recvq_egrbuf_table_free(void **buftable);
57
58 /*
59 * Accessor inlines for reading and writing to hdrq/egrq registers
60 */
61 PSMI_ALWAYS_INLINE(
62 void *ips_recvq_egr_index_2_ptr(void **egrq_buftable, int index))
63 {
64 return egrq_buftable[index];
65 }
66
67 PSMI_INLINE(
68 void ips_recvq_head_update(const struct ips_recvq_params *recvq, uint32_t newhead))
69 {
70 *recvq->head_register = __cpu_to_le32(newhead);
71 return;
72 }
73
74 PSMI_INLINE(
75 uint32_t ips_recvq_head_get(const struct ips_recvq_params *recvq))
76 {
77 uint32_t res = __le32_to_cpu(*recvq->head_register);
78 ips_rmb();
79 return res;
80 }
81
82 PSMI_INLINE(
83 void ips_recvq_tail_update(const struct ips_recvq_params *recvq, uint32_t newtail))
84 {
85 *recvq->tail_register = __cpu_to_le32(newtail);
86 return;
87 }
88
89 PSMI_INLINE(
90 uint32_t ips_recvq_tail_get(const struct ips_recvq_params *recvq))
91 {
92 uint32_t res = __le32_to_cpu(*recvq->tail_register);
93 ips_rmb();
94 return res;
95 }
96
97 #endif /* _IPS_RECVQ_H */