Debian Codegraph @

prov/usnic/src/usnic_direct/cq_desc.h

raw symbols SCIP
1 /*
2 * Copyright 2008-2010 Cisco Systems, Inc. All rights reserved.
3 * Copyright 2007 Nuova Systems, Inc. All rights reserved.
4 *
5 * LICENSE_BEGIN
6 *
7 * This software is available to you under a choice of one of two
8 * licenses. You may choose to be licensed under the terms of the GNU
9 * General Public License (GPL) Version 2, available from the file
10 * COPYING in the main directory of this source tree, or the
11 * BSD license below:
12 *
13 * Redistribution and use in source and binary forms, with or
14 * without modification, are permitted provided that the following
15 * conditions are met:
16 *
17 * - Redistributions of source code must retain the above
18 * copyright notice, this list of conditions and the following
19 * disclaimer.
20 *
21 * - Redistributions in binary form must reproduce the above
22 * copyright notice, this list of conditions and the following
23 * disclaimer in the documentation and/or other materials
24 * provided with the distribution.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
29 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
30 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
31 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
32 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
33 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
34 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
36 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGE.
38 *
39 * LICENSE_END
40 *
41 *
42 */
43
44 #ifndef _CQ_DESC_H_
45 #define _CQ_DESC_H_cxx . . $ `prov/usnic/src/usnic_direct/cq_desc.h:45:9`!
46
47 /*
48 * Completion queue descriptor types
49 */
50 enum cq_desc_typescxx . . $ cq_desc_types# {
51 CQ_DESC_TYPE_WQ_ENETcxx . . $ CQ_DESC_TYPE_WQ_ENET. = 0,
52 CQ_DESC_TYPE_DESC_COPYcxx . . $ CQ_DESC_TYPE_DESC_COPY. = 1,
53 CQ_DESC_TYPE_WQ_EXCHcxx . . $ CQ_DESC_TYPE_WQ_EXCH. = 2,
54 CQ_DESC_TYPE_RQ_ENETcxx . . $ CQ_DESC_TYPE_RQ_ENET. = 3,
55 CQ_DESC_TYPE_RQ_FCPcxx . . $ CQ_DESC_TYPE_RQ_FCP. = 4,
56 CQ_DESC_TYPE_IOMMU_MISScxx . . $ CQ_DESC_TYPE_IOMMU_MISS. = 5,
57 CQ_DESC_TYPE_SGLcxx . . $ CQ_DESC_TYPE_SGL. = 6,
58 CQ_DESC_TYPE_CLASSIFIERcxx . . $ CQ_DESC_TYPE_CLASSIFIER. = 7,
59 CQ_DESC_TYPE_TESTcxx . . $ CQ_DESC_TYPE_TEST. = 127,
60 };
61
62 /* Completion queue descriptor: 16B
63 *
64 * All completion queues have this basic layout. The
65 * type_specfic area is unique for each completion
66 * queue type.
67 */
68 struct cq_desccxx . . $ cq_desc# {
69 __le16cxx . . $ __le16# completed_indexcxx . . $ cq_desc#completed_index.;
70 __le16cxx . . $ __le16# q_numbercxx . . $ cq_desc#q_number.;
71 u8cxx . . $ u8# type_specficcxx . . $ cq_desc#type_specfic.[11];
72 u8cxx . . $ u8# type_colorcxx . . $ cq_desc#type_color.;
73 };
74
75 #define CQ_DESC_TYPE_BITScxx . . $ `prov/usnic/src/usnic_direct/cq_desc.h:75:9`! 4
76 #define CQ_DESC_TYPE_MASKcxx . . $ `prov/usnic/src/usnic_direct/cq_desc.h:76:9`! ((1 << CQ_DESC_TYPE_BITScxx . . $ `prov/usnic/src/usnic_direct/cq_desc.h:75:9`!) - 1)
77 #define CQ_DESC_COLOR_MASKcxx . . $ `prov/usnic/src/usnic_direct/cq_desc.h:77:9`! 1
78 #define CQ_DESC_COLOR_SHIFTcxx . . $ `prov/usnic/src/usnic_direct/cq_desc.h:78:9`! 7
79 #define CQ_DESC_Q_NUM_BITScxx . . $ `prov/usnic/src/usnic_direct/cq_desc.h:79:9`! 10
80 #define CQ_DESC_Q_NUM_MASKcxx . . $ `prov/usnic/src/usnic_direct/cq_desc.h:80:9`! ((1 << CQ_DESC_Q_NUM_BITScxx . . $ `prov/usnic/src/usnic_direct/cq_desc.h:79:9`!) - 1)
81 #define CQ_DESC_COMP_NDX_BITScxx . . $ `prov/usnic/src/usnic_direct/cq_desc.h:81:9`! 12
82 #define CQ_DESC_COMP_NDX_MASKcxx . . $ `prov/usnic/src/usnic_direct/cq_desc.h:82:9`! ((1 << CQ_DESC_COMP_NDX_BITScxx . . $ `prov/usnic/src/usnic_direct/cq_desc.h:81:9`!) - 1)
83
84 static inline void cq_color_enccxx . . $ cq_color_enc(e166e520c2286f14).(struct cq_desccxx . . $ cq_desc# *desc, const u8cxx . . $ u8# color)
85 {
86 if (color)
87 desc->type_colorcxx . . $ cq_desc#type_color. |= (1 << CQ_DESC_COLOR_SHIFTcxx . . $ `prov/usnic/src/usnic_direct/cq_desc.h:78:9`!);
88 else
89 desc->type_colorcxx . . $ cq_desc#type_color. &= ~(1 << CQ_DESC_COLOR_SHIFTcxx . . $ `prov/usnic/src/usnic_direct/cq_desc.h:78:9`!);
90 }
91
92 static inline void cq_desc_enccxx . . $ cq_desc_enc(6012dae6ec292c5e).(struct cq_desccxx . . $ cq_desc# *desc,
93 const u8cxx . . $ u8# type, const u8cxx . . $ u8# color, const u16cxx . . $ u16# q_number,
94 const u16cxx . . $ u16# completed_index)
95 {
96 desc->type_colorcxx . . $ cq_desc#type_color. = (type & CQ_DESC_TYPE_MASKcxx . . $ `prov/usnic/src/usnic_direct/cq_desc.h:76:9`!) |
97 ((color & CQ_DESC_COLOR_MASKcxx . . $ `prov/usnic/src/usnic_direct/cq_desc.h:77:9`!) << CQ_DESC_COLOR_SHIFTcxx . . $ `prov/usnic/src/usnic_direct/cq_desc.h:78:9`!);
98 desc->q_numbercxx . . $ cq_desc#q_number. = cpu_to_le16cxx . . $ `prov/usnic/src/usnic_direct/linux_types.h:59:9`!(q_number & CQ_DESC_Q_NUM_MASKcxx . . $ `prov/usnic/src/usnic_direct/cq_desc.h:80:9`!);
99 desc->completed_indexcxx . . $ cq_desc#completed_index. = cpu_to_le16cxx . . $ `prov/usnic/src/usnic_direct/linux_types.h:59:9`!(completed_index &
100 CQ_DESC_COMP_NDX_MASKcxx . . $ `prov/usnic/src/usnic_direct/cq_desc.h:82:9`!);
101 }
102
103 static inline void cq_desc_deccxx . . $ cq_desc_dec(a9604f0b428be5b4).(const struct cq_desccxx . . $ cq_desc# *desc_arg,
104 u8cxx . . $ u8# *type, u8cxx . . $ u8# *color, u16cxx . . $ u16# *q_number, u16cxx . . $ u16# *completed_index)
105 {
106 const struct cq_desccxx . . $ cq_desc# *desc = desc_arg;
107 const u8cxx . . $ u8# type_color = desc->type_colorcxx . . $ cq_desc#type_color.;
108
109 *color = (type_color >> CQ_DESC_COLOR_SHIFTcxx . . $ `prov/usnic/src/usnic_direct/cq_desc.h:78:9`!) & CQ_DESC_COLOR_MASKcxx . . $ `prov/usnic/src/usnic_direct/cq_desc.h:77:9`!;
110
111 #if !defined(__LIBUSNIC__cxx . . $ `<built-in>:418:9`!)
112 /*
113 * Make sure color bit is read from desc *before* other fields
114 * are read from desc. Hardware guarantees color bit is last
115 * bit (byte) written. Adding the rmb() prevents the compiler
116 * and/or CPU from reordering the reads which would potentially
117 * result in reading stale values.
118 */
119
120 rmb();
121 #endif
122
123 *type = type_color & CQ_DESC_TYPE_MASKcxx . . $ `prov/usnic/src/usnic_direct/cq_desc.h:76:9`!;
124 *q_number = le16_to_cpucxx . . $ `prov/usnic/src/usnic_direct/linux_types.h:56:9`!(desc->q_numbercxx . . $ cq_desc#q_number.) & CQ_DESC_Q_NUM_MASKcxx . . $ `prov/usnic/src/usnic_direct/cq_desc.h:80:9`!;
125 *completed_index = le16_to_cpucxx . . $ `prov/usnic/src/usnic_direct/linux_types.h:56:9`!(desc->completed_indexcxx . . $ cq_desc#completed_index.) &
126 CQ_DESC_COMP_NDX_MASKcxx . . $ `prov/usnic/src/usnic_direct/cq_desc.h:82:9`!;
127 }
128
129 static inline void cq_color_deccxx . . $ cq_color_dec(fb742d0986cc36fc).(const struct cq_desccxx . . $ cq_desc# *desc_arg, u8cxx . . $ u8# *color)
130 {
131 volatile const struct cq_desccxx . . $ cq_desc# *desc = desc_arg;
132
133 *color = (desc->type_colorcxx . . $ cq_desc#type_color. >> CQ_DESC_COLOR_SHIFTcxx . . $ `prov/usnic/src/usnic_direct/cq_desc.h:78:9`!) & CQ_DESC_COLOR_MASKcxx . . $ `prov/usnic/src/usnic_direct/cq_desc.h:77:9`!;
134 }
135
136 #endif /* _CQ_DESC_H_ */