xref: /freebsd/contrib/ofed/libibverbs/opcode.h (revision 87181516ef48be852d5e5fee53c6e0dbfc62f21e)
1 /*
2  * Copyright (c) 2005 Topspin Communications.  All rights reserved.
3  *
4  * This software is available to you under a choice of one of two
5  * licenses.  You may choose to be licensed under the terms of the GNU
6  * General Public License (GPL) Version 2, available from the file
7  * COPYING in the main directory of this source tree, or the
8  * OpenIB.org BSD license below:
9  *
10  *     Redistribution and use in source and binary forms, with or
11  *     without modification, are permitted provided that the following
12  *     conditions are met:
13  *
14  *      - Redistributions of source code must retain the above
15  *        copyright notice, this list of conditions and the following
16  *        disclaimer.
17  *
18  *      - Redistributions in binary form must reproduce the above
19  *        copyright notice, this list of conditions and the following
20  *        disclaimer in the documentation and/or other materials
21  *        provided with the distribution.
22  *
23  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30  * SOFTWARE.
31  */
32 
33 #ifndef INFINIBAND_OPCODE_H
34 #define INFINIBAND_OPCODE_H
35 
36 /*
37  * This macro cleans up the definitions of constants for BTH opcodes.
38  * It is used to define constants such as IBV_OPCODE_UD_SEND_ONLY,
39  * which becomes IBV_OPCODE_UD + IBV_OPCODE_SEND_ONLY, and this gives
40  * the correct value.
41  *
42  * In short, user code should use the constants defined using the
43  * macro rather than worrying about adding together other constants.
44 */
45 #define IBV_OPCODE(transport, op) \
46 	IBV_OPCODE_ ## transport ## _ ## op = \
47 		IBV_OPCODE_ ## transport + IBV_OPCODE_ ## op
48 
49 enum {
50 	/* transport types -- just used to define real constants */
51 	IBV_OPCODE_RC                                = 0x00,
52 	IBV_OPCODE_UC                                = 0x20,
53 	IBV_OPCODE_RD                                = 0x40,
54 	IBV_OPCODE_UD                                = 0x60,
55 
56 	/* operations -- just used to define real constants */
57 	IBV_OPCODE_SEND_FIRST                        = 0x00,
58 	IBV_OPCODE_SEND_MIDDLE                       = 0x01,
59 	IBV_OPCODE_SEND_LAST                         = 0x02,
60 	IBV_OPCODE_SEND_LAST_WITH_IMMEDIATE          = 0x03,
61 	IBV_OPCODE_SEND_ONLY                         = 0x04,
62 	IBV_OPCODE_SEND_ONLY_WITH_IMMEDIATE          = 0x05,
63 	IBV_OPCODE_RDMA_WRITE_FIRST                  = 0x06,
64 	IBV_OPCODE_RDMA_WRITE_MIDDLE                 = 0x07,
65 	IBV_OPCODE_RDMA_WRITE_LAST                   = 0x08,
66 	IBV_OPCODE_RDMA_WRITE_LAST_WITH_IMMEDIATE    = 0x09,
67 	IBV_OPCODE_RDMA_WRITE_ONLY                   = 0x0a,
68 	IBV_OPCODE_RDMA_WRITE_ONLY_WITH_IMMEDIATE    = 0x0b,
69 	IBV_OPCODE_RDMA_READ_REQUEST                 = 0x0c,
70 	IBV_OPCODE_RDMA_READ_RESPONSE_FIRST          = 0x0d,
71 	IBV_OPCODE_RDMA_READ_RESPONSE_MIDDLE         = 0x0e,
72 	IBV_OPCODE_RDMA_READ_RESPONSE_LAST           = 0x0f,
73 	IBV_OPCODE_RDMA_READ_RESPONSE_ONLY           = 0x10,
74 	IBV_OPCODE_ACKNOWLEDGE                       = 0x11,
75 	IBV_OPCODE_ATOMIC_ACKNOWLEDGE                = 0x12,
76 	IBV_OPCODE_COMPARE_SWAP                      = 0x13,
77 	IBV_OPCODE_FETCH_ADD                         = 0x14,
78 
79 	/* real constants follow -- see comment about above IBV_OPCODE()
80 	   macro for more details */
81 
82 	/* RC */
83 	IBV_OPCODE(RC, SEND_FIRST),
84 	IBV_OPCODE(RC, SEND_MIDDLE),
85 	IBV_OPCODE(RC, SEND_LAST),
86 	IBV_OPCODE(RC, SEND_LAST_WITH_IMMEDIATE),
87 	IBV_OPCODE(RC, SEND_ONLY),
88 	IBV_OPCODE(RC, SEND_ONLY_WITH_IMMEDIATE),
89 	IBV_OPCODE(RC, RDMA_WRITE_FIRST),
90 	IBV_OPCODE(RC, RDMA_WRITE_MIDDLE),
91 	IBV_OPCODE(RC, RDMA_WRITE_LAST),
92 	IBV_OPCODE(RC, RDMA_WRITE_LAST_WITH_IMMEDIATE),
93 	IBV_OPCODE(RC, RDMA_WRITE_ONLY),
94 	IBV_OPCODE(RC, RDMA_WRITE_ONLY_WITH_IMMEDIATE),
95 	IBV_OPCODE(RC, RDMA_READ_REQUEST),
96 	IBV_OPCODE(RC, RDMA_READ_RESPONSE_FIRST),
97 	IBV_OPCODE(RC, RDMA_READ_RESPONSE_MIDDLE),
98 	IBV_OPCODE(RC, RDMA_READ_RESPONSE_LAST),
99 	IBV_OPCODE(RC, RDMA_READ_RESPONSE_ONLY),
100 	IBV_OPCODE(RC, ACKNOWLEDGE),
101 	IBV_OPCODE(RC, ATOMIC_ACKNOWLEDGE),
102 	IBV_OPCODE(RC, COMPARE_SWAP),
103 	IBV_OPCODE(RC, FETCH_ADD),
104 
105 	/* UC */
106 	IBV_OPCODE(UC, SEND_FIRST),
107 	IBV_OPCODE(UC, SEND_MIDDLE),
108 	IBV_OPCODE(UC, SEND_LAST),
109 	IBV_OPCODE(UC, SEND_LAST_WITH_IMMEDIATE),
110 	IBV_OPCODE(UC, SEND_ONLY),
111 	IBV_OPCODE(UC, SEND_ONLY_WITH_IMMEDIATE),
112 	IBV_OPCODE(UC, RDMA_WRITE_FIRST),
113 	IBV_OPCODE(UC, RDMA_WRITE_MIDDLE),
114 	IBV_OPCODE(UC, RDMA_WRITE_LAST),
115 	IBV_OPCODE(UC, RDMA_WRITE_LAST_WITH_IMMEDIATE),
116 	IBV_OPCODE(UC, RDMA_WRITE_ONLY),
117 	IBV_OPCODE(UC, RDMA_WRITE_ONLY_WITH_IMMEDIATE),
118 
119 	/* RD */
120 	IBV_OPCODE(RD, SEND_FIRST),
121 	IBV_OPCODE(RD, SEND_MIDDLE),
122 	IBV_OPCODE(RD, SEND_LAST),
123 	IBV_OPCODE(RD, SEND_LAST_WITH_IMMEDIATE),
124 	IBV_OPCODE(RD, SEND_ONLY),
125 	IBV_OPCODE(RD, SEND_ONLY_WITH_IMMEDIATE),
126 	IBV_OPCODE(RD, RDMA_WRITE_FIRST),
127 	IBV_OPCODE(RD, RDMA_WRITE_MIDDLE),
128 	IBV_OPCODE(RD, RDMA_WRITE_LAST),
129 	IBV_OPCODE(RD, RDMA_WRITE_LAST_WITH_IMMEDIATE),
130 	IBV_OPCODE(RD, RDMA_WRITE_ONLY),
131 	IBV_OPCODE(RD, RDMA_WRITE_ONLY_WITH_IMMEDIATE),
132 	IBV_OPCODE(RD, RDMA_READ_REQUEST),
133 	IBV_OPCODE(RD, RDMA_READ_RESPONSE_FIRST),
134 	IBV_OPCODE(RD, RDMA_READ_RESPONSE_MIDDLE),
135 	IBV_OPCODE(RD, RDMA_READ_RESPONSE_LAST),
136 	IBV_OPCODE(RD, RDMA_READ_RESPONSE_ONLY),
137 	IBV_OPCODE(RD, ACKNOWLEDGE),
138 	IBV_OPCODE(RD, ATOMIC_ACKNOWLEDGE),
139 	IBV_OPCODE(RD, COMPARE_SWAP),
140 	IBV_OPCODE(RD, FETCH_ADD),
141 
142 	/* UD */
143 	IBV_OPCODE(UD, SEND_ONLY),
144 	IBV_OPCODE(UD, SEND_ONLY_WITH_IMMEDIATE)
145 };
146 
147 #endif /* INFINIBAND_OPCODE_H */
148