aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHal Rosenstock <halr@voltaire.com>2007-04-02 11:24:07 -0400
committerRoland Dreier <rolandd@cisco.com>2007-04-24 19:31:12 -0400
commitde493d47d8b4738827d8914a4dc94058c58f4249 (patch)
tree3da66e364fe8c1c51ad0a4cbbced337cce6a33d4
parentaeba84a9251968a51fc6faae846518aac4e77565 (diff)
IB/mad: Change SMI to use enums rather than magic return codes
Clarify code by changing return values from SMI functions to named enum values instead of magic 0/1 values. Signed-off-by: Hal Rosenstock <halr@voltaire.com> Signed-off-by: Roland Dreier <rolandd@cisco.com>
-rw-r--r--drivers/infiniband/core/mad.c34
-rw-r--r--drivers/infiniband/core/smi.c86
-rw-r--r--drivers/infiniband/core/smi.h34
3 files changed, 82 insertions, 72 deletions
diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c
index 13efd4170349..6edfecf1be72 100644
--- a/drivers/infiniband/core/mad.c
+++ b/drivers/infiniband/core/mad.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved. 2 * Copyright (c) 2004-2007 Voltaire, Inc. All rights reserved.
3 * Copyright (c) 2005 Intel Corporation. All rights reserved. 3 * Copyright (c) 2005 Intel Corporation. All rights reserved.
4 * Copyright (c) 2005 Mellanox Technologies Ltd. All rights reserved. 4 * Copyright (c) 2005 Mellanox Technologies Ltd. All rights reserved.
5 * 5 *
@@ -31,7 +31,6 @@
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE. 32 * SOFTWARE.
33 * 33 *
34 * $Id: mad.c 5596 2006-03-03 01:00:07Z sean.hefty $
35 */ 34 */
36#include <linux/dma-mapping.h> 35#include <linux/dma-mapping.h>
37#include <rdma/ib_cache.h> 36#include <rdma/ib_cache.h>
@@ -668,7 +667,7 @@ static void build_smp_wc(struct ib_qp *qp,
668static int handle_outgoing_dr_smp(struct ib_mad_agent_private *mad_agent_priv, 667static int handle_outgoing_dr_smp(struct ib_mad_agent_private *mad_agent_priv,
669 struct ib_mad_send_wr_private *mad_send_wr) 668 struct ib_mad_send_wr_private *mad_send_wr)
670{ 669{
671 int ret; 670 int ret = 0;
672 struct ib_smp *smp = mad_send_wr->send_buf.mad; 671 struct ib_smp *smp = mad_send_wr->send_buf.mad;
673 unsigned long flags; 672 unsigned long flags;
674 struct ib_mad_local_private *local; 673 struct ib_mad_local_private *local;
@@ -688,14 +687,15 @@ static int handle_outgoing_dr_smp(struct ib_mad_agent_private *mad_agent_priv,
688 */ 687 */
689 if ((ib_get_smp_direction(smp) ? smp->dr_dlid : smp->dr_slid) == 688 if ((ib_get_smp_direction(smp) ? smp->dr_dlid : smp->dr_slid) ==
690 IB_LID_PERMISSIVE && 689 IB_LID_PERMISSIVE &&
691 !smi_handle_dr_smp_send(smp, device->node_type, port_num)) { 690 smi_handle_dr_smp_send(smp, device->node_type, port_num) ==
691 IB_SMI_DISCARD) {
692 ret = -EINVAL; 692 ret = -EINVAL;
693 printk(KERN_ERR PFX "Invalid directed route\n"); 693 printk(KERN_ERR PFX "Invalid directed route\n");
694 goto out; 694 goto out;
695 } 695 }
696
696 /* Check to post send on QP or process locally */ 697 /* Check to post send on QP or process locally */
697 ret = smi_check_local_smp(smp, device); 698 if (smi_check_local_smp(smp, device) == IB_SMI_DISCARD)
698 if (!ret)
699 goto out; 699 goto out;
700 700
701 local = kmalloc(sizeof *local, GFP_ATOMIC); 701 local = kmalloc(sizeof *local, GFP_ATOMIC);
@@ -1874,18 +1874,22 @@ static void ib_mad_recv_done_handler(struct ib_mad_port_private *port_priv,
1874 1874
1875 if (recv->mad.mad.mad_hdr.mgmt_class == 1875 if (recv->mad.mad.mad_hdr.mgmt_class ==
1876 IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) { 1876 IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) {
1877 if (!smi_handle_dr_smp_recv(&recv->mad.smp, 1877 if (smi_handle_dr_smp_recv(&recv->mad.smp,
1878 port_priv->device->node_type, 1878 port_priv->device->node_type,
1879 port_priv->port_num, 1879 port_priv->port_num,
1880 port_priv->device->phys_port_cnt)) 1880 port_priv->device->phys_port_cnt) ==
1881 IB_SMI_DISCARD)
1881 goto out; 1882 goto out;
1882 if (!smi_check_forward_dr_smp(&recv->mad.smp)) 1883
1884 if (smi_check_forward_dr_smp(&recv->mad.smp) == IB_SMI_LOCAL)
1883 goto local; 1885 goto local;
1884 if (!smi_handle_dr_smp_send(&recv->mad.smp, 1886
1885 port_priv->device->node_type, 1887 if (smi_handle_dr_smp_send(&recv->mad.smp,
1886 port_priv->port_num)) 1888 port_priv->device->node_type,
1889 port_priv->port_num) == IB_SMI_DISCARD)
1887 goto out; 1890 goto out;
1888 if (!smi_check_local_smp(&recv->mad.smp, port_priv->device)) 1891
1892 if (smi_check_local_smp(&recv->mad.smp, port_priv->device) == IB_SMI_DISCARD)
1889 goto out; 1893 goto out;
1890 } 1894 }
1891 1895
diff --git a/drivers/infiniband/core/smi.c b/drivers/infiniband/core/smi.c
index 54b81e17ad50..2bca753eb622 100644
--- a/drivers/infiniband/core/smi.c
+++ b/drivers/infiniband/core/smi.c
@@ -3,7 +3,7 @@
3 * Copyright (c) 2004, 2005 Infinicon Corporation. All rights reserved. 3 * Copyright (c) 2004, 2005 Infinicon Corporation. All rights reserved.
4 * Copyright (c) 2004, 2005 Intel Corporation. All rights reserved. 4 * Copyright (c) 2004, 2005 Intel Corporation. All rights reserved.
5 * Copyright (c) 2004, 2005 Topspin Corporation. All rights reserved. 5 * Copyright (c) 2004, 2005 Topspin Corporation. All rights reserved.
6 * Copyright (c) 2004, 2005 Voltaire Corporation. All rights reserved. 6 * Copyright (c) 2004-2007 Voltaire Corporation. All rights reserved.
7 * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. 7 * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
8 * 8 *
9 * This software is available to you under a choice of one of two 9 * This software is available to you under a choice of one of two
@@ -34,7 +34,6 @@
34 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 34 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35 * SOFTWARE. 35 * SOFTWARE.
36 * 36 *
37 * $Id: smi.c 1389 2004-12-27 22:56:47Z roland $
38 */ 37 */
39 38
40#include <rdma/ib_smi.h> 39#include <rdma/ib_smi.h>
@@ -44,9 +43,8 @@
44 * Fixup a directed route SMP for sending 43 * Fixup a directed route SMP for sending
45 * Return 0 if the SMP should be discarded 44 * Return 0 if the SMP should be discarded
46 */ 45 */
47int smi_handle_dr_smp_send(struct ib_smp *smp, 46enum smi_action smi_handle_dr_smp_send(struct ib_smp *smp,
48 u8 node_type, 47 u8 node_type, int port_num)
49 int port_num)
50{ 48{
51 u8 hop_ptr, hop_cnt; 49 u8 hop_ptr, hop_cnt;
52 50
@@ -59,18 +57,18 @@ int smi_handle_dr_smp_send(struct ib_smp *smp,
59 if (hop_cnt && hop_ptr == 0) { 57 if (hop_cnt && hop_ptr == 0) {
60 smp->hop_ptr++; 58 smp->hop_ptr++;
61 return (smp->initial_path[smp->hop_ptr] == 59 return (smp->initial_path[smp->hop_ptr] ==
62 port_num); 60 port_num ? IB_SMI_HANDLE : IB_SMI_DISCARD);
63 } 61 }
64 62
65 /* C14-9:2 */ 63 /* C14-9:2 */
66 if (hop_ptr && hop_ptr < hop_cnt) { 64 if (hop_ptr && hop_ptr < hop_cnt) {
67 if (node_type != RDMA_NODE_IB_SWITCH) 65 if (node_type != RDMA_NODE_IB_SWITCH)
68 return 0; 66 return IB_SMI_DISCARD;
69 67
70 /* smp->return_path set when received */ 68 /* smp->return_path set when received */
71 smp->hop_ptr++; 69 smp->hop_ptr++;
72 return (smp->initial_path[smp->hop_ptr] == 70 return (smp->initial_path[smp->hop_ptr] ==
73 port_num); 71 port_num ? IB_SMI_HANDLE : IB_SMI_DISCARD);
74 } 72 }
75 73
76 /* C14-9:3 -- We're at the end of the DR segment of path */ 74 /* C14-9:3 -- We're at the end of the DR segment of path */
@@ -78,29 +76,30 @@ int smi_handle_dr_smp_send(struct ib_smp *smp,
78 /* smp->return_path set when received */ 76 /* smp->return_path set when received */
79 smp->hop_ptr++; 77 smp->hop_ptr++;
80 return (node_type == RDMA_NODE_IB_SWITCH || 78 return (node_type == RDMA_NODE_IB_SWITCH ||
81 smp->dr_dlid == IB_LID_PERMISSIVE); 79 smp->dr_dlid == IB_LID_PERMISSIVE ?
80 IB_SMI_HANDLE : IB_SMI_DISCARD);
82 } 81 }
83 82
84 /* C14-9:4 -- hop_ptr = hop_cnt + 1 -> give to SMA/SM */ 83 /* C14-9:4 -- hop_ptr = hop_cnt + 1 -> give to SMA/SM */
85 /* C14-9:5 -- Fail unreasonable hop pointer */ 84 /* C14-9:5 -- Fail unreasonable hop pointer */
86 return (hop_ptr == hop_cnt + 1); 85 return (hop_ptr == hop_cnt + 1 ? IB_SMI_HANDLE : IB_SMI_DISCARD);
87 86
88 } else { 87 } else {
89 /* C14-13:1 */ 88 /* C14-13:1 */
90 if (hop_cnt && hop_ptr == hop_cnt + 1) { 89 if (hop_cnt && hop_ptr == hop_cnt + 1) {
91 smp->hop_ptr--; 90 smp->hop_ptr--;
92 return (smp->return_path[smp->hop_ptr] == 91 return (smp->return_path[smp->hop_ptr] ==
93 port_num); 92 port_num ? IB_SMI_HANDLE : IB_SMI_DISCARD);
94 } 93 }
95 94
96 /* C14-13:2 */ 95 /* C14-13:2 */
97 if (2 <= hop_ptr && hop_ptr <= hop_cnt) { 96 if (2 <= hop_ptr && hop_ptr <= hop_cnt) {
98 if (node_type != RDMA_NODE_IB_SWITCH) 97 if (node_type != RDMA_NODE_IB_SWITCH)
99 return 0; 98 return IB_SMI_DISCARD;
100 99
101 smp->hop_ptr--; 100 smp->hop_ptr--;
102 return (smp->return_path[smp->hop_ptr] == 101 return (smp->return_path[smp->hop_ptr] ==
103 port_num); 102 port_num ? IB_SMI_HANDLE : IB_SMI_DISCARD);
104 } 103 }
105 104
106 /* C14-13:3 -- at the end of the DR segment of path */ 105 /* C14-13:3 -- at the end of the DR segment of path */
@@ -108,15 +107,16 @@ int smi_handle_dr_smp_send(struct ib_smp *smp,
108 smp->hop_ptr--; 107 smp->hop_ptr--;
109 /* C14-13:3 -- SMPs destined for SM shouldn't be here */ 108 /* C14-13:3 -- SMPs destined for SM shouldn't be here */
110 return (node_type == RDMA_NODE_IB_SWITCH || 109 return (node_type == RDMA_NODE_IB_SWITCH ||
111 smp->dr_slid == IB_LID_PERMISSIVE); 110 smp->dr_slid == IB_LID_PERMISSIVE ?
111 IB_SMI_HANDLE : IB_SMI_DISCARD);
112 } 112 }
113 113
114 /* C14-13:4 -- hop_ptr = 0 -> should have gone to SM */ 114 /* C14-13:4 -- hop_ptr = 0 -> should have gone to SM */
115 if (hop_ptr == 0) 115 if (hop_ptr == 0)
116 return 1; 116 return IB_SMI_HANDLE;
117 117
118 /* C14-13:5 -- Check for unreasonable hop pointer */ 118 /* C14-13:5 -- Check for unreasonable hop pointer */
119 return 0; 119 return IB_SMI_DISCARD;
120 } 120 }
121} 121}
122 122
@@ -124,10 +124,8 @@ int smi_handle_dr_smp_send(struct ib_smp *smp,
124 * Adjust information for a received SMP 124 * Adjust information for a received SMP
125 * Return 0 if the SMP should be dropped 125 * Return 0 if the SMP should be dropped
126 */ 126 */
127int smi_handle_dr_smp_recv(struct ib_smp *smp, 127enum smi_action smi_handle_dr_smp_recv(struct ib_smp *smp, u8 node_type,
128 u8 node_type, 128 int port_num, int phys_port_cnt)
129 int port_num,
130 int phys_port_cnt)
131{ 129{
132 u8 hop_ptr, hop_cnt; 130 u8 hop_ptr, hop_cnt;
133 131
@@ -138,16 +136,17 @@ int smi_handle_dr_smp_recv(struct ib_smp *smp,
138 if (!ib_get_smp_direction(smp)) { 136 if (!ib_get_smp_direction(smp)) {
139 /* C14-9:1 -- sender should have incremented hop_ptr */ 137 /* C14-9:1 -- sender should have incremented hop_ptr */
140 if (hop_cnt && hop_ptr == 0) 138 if (hop_cnt && hop_ptr == 0)
141 return 0; 139 return IB_SMI_DISCARD;
142 140
143 /* C14-9:2 -- intermediate hop */ 141 /* C14-9:2 -- intermediate hop */
144 if (hop_ptr && hop_ptr < hop_cnt) { 142 if (hop_ptr && hop_ptr < hop_cnt) {
145 if (node_type != RDMA_NODE_IB_SWITCH) 143 if (node_type != RDMA_NODE_IB_SWITCH)
146 return 0; 144 return IB_SMI_DISCARD;
147 145
148 smp->return_path[hop_ptr] = port_num; 146 smp->return_path[hop_ptr] = port_num;
149 /* smp->hop_ptr updated when sending */ 147 /* smp->hop_ptr updated when sending */
150 return (smp->initial_path[hop_ptr+1] <= phys_port_cnt); 148 return (smp->initial_path[hop_ptr+1] <= phys_port_cnt ?
149 IB_SMI_HANDLE : IB_SMI_DISCARD);
151 } 150 }
152 151
153 /* C14-9:3 -- We're at the end of the DR segment of path */ 152 /* C14-9:3 -- We're at the end of the DR segment of path */
@@ -157,12 +156,13 @@ int smi_handle_dr_smp_recv(struct ib_smp *smp,
157 /* smp->hop_ptr updated when sending */ 156 /* smp->hop_ptr updated when sending */
158 157
159 return (node_type == RDMA_NODE_IB_SWITCH || 158 return (node_type == RDMA_NODE_IB_SWITCH ||
160 smp->dr_dlid == IB_LID_PERMISSIVE); 159 smp->dr_dlid == IB_LID_PERMISSIVE ?
160 IB_SMI_HANDLE : IB_SMI_DISCARD);
161 } 161 }
162 162
163 /* C14-9:4 -- hop_ptr = hop_cnt + 1 -> give to SMA/SM */ 163 /* C14-9:4 -- hop_ptr = hop_cnt + 1 -> give to SMA/SM */
164 /* C14-9:5 -- fail unreasonable hop pointer */ 164 /* C14-9:5 -- fail unreasonable hop pointer */
165 return (hop_ptr == hop_cnt + 1); 165 return (hop_ptr == hop_cnt + 1 ? IB_SMI_HANDLE : IB_SMI_DISCARD);
166 166
167 } else { 167 } else {
168 168
@@ -170,16 +170,17 @@ int smi_handle_dr_smp_recv(struct ib_smp *smp,
170 if (hop_cnt && hop_ptr == hop_cnt + 1) { 170 if (hop_cnt && hop_ptr == hop_cnt + 1) {
171 smp->hop_ptr--; 171 smp->hop_ptr--;
172 return (smp->return_path[smp->hop_ptr] == 172 return (smp->return_path[smp->hop_ptr] ==
173 port_num); 173 port_num ? IB_SMI_HANDLE : IB_SMI_DISCARD);
174 } 174 }
175 175
176 /* C14-13:2 */ 176 /* C14-13:2 */
177 if (2 <= hop_ptr && hop_ptr <= hop_cnt) { 177 if (2 <= hop_ptr && hop_ptr <= hop_cnt) {
178 if (node_type != RDMA_NODE_IB_SWITCH) 178 if (node_type != RDMA_NODE_IB_SWITCH)
179 return 0; 179 return IB_SMI_DISCARD;
180 180
181 /* smp->hop_ptr updated when sending */ 181 /* smp->hop_ptr updated when sending */
182 return (smp->return_path[hop_ptr-1] <= phys_port_cnt); 182 return (smp->return_path[hop_ptr-1] <= phys_port_cnt ?
183 IB_SMI_HANDLE : IB_SMI_DISCARD);
183 } 184 }
184 185
185 /* C14-13:3 -- We're at the end of the DR segment of path */ 186 /* C14-13:3 -- We're at the end of the DR segment of path */
@@ -187,23 +188,20 @@ int smi_handle_dr_smp_recv(struct ib_smp *smp,
187 if (smp->dr_slid == IB_LID_PERMISSIVE) { 188 if (smp->dr_slid == IB_LID_PERMISSIVE) {
188 /* giving SMP to SM - update hop_ptr */ 189 /* giving SMP to SM - update hop_ptr */
189 smp->hop_ptr--; 190 smp->hop_ptr--;
190 return 1; 191 return IB_SMI_HANDLE;
191 } 192 }
192 /* smp->hop_ptr updated when sending */ 193 /* smp->hop_ptr updated when sending */
193 return (node_type == RDMA_NODE_IB_SWITCH); 194 return (node_type == RDMA_NODE_IB_SWITCH ?
195 IB_SMI_HANDLE: IB_SMI_DISCARD);
194 } 196 }
195 197
196 /* C14-13:4 -- hop_ptr = 0 -> give to SM */ 198 /* C14-13:4 -- hop_ptr = 0 -> give to SM */
197 /* C14-13:5 -- Check for unreasonable hop pointer */ 199 /* C14-13:5 -- Check for unreasonable hop pointer */
198 return (hop_ptr == 0); 200 return (hop_ptr == 0 ? IB_SMI_HANDLE : IB_SMI_DISCARD);
199 } 201 }
200} 202}
201 203
202/* 204enum smi_forward_action smi_check_forward_dr_smp(struct ib_smp *smp)
203 * Return 1 if the received DR SMP should be forwarded to the send queue
204 * Return 0 if the SMP should be completed up the stack
205 */
206int smi_check_forward_dr_smp(struct ib_smp *smp)
207{ 205{
208 u8 hop_ptr, hop_cnt; 206 u8 hop_ptr, hop_cnt;
209 207
@@ -213,23 +211,25 @@ int smi_check_forward_dr_smp(struct ib_smp *smp)
213 if (!ib_get_smp_direction(smp)) { 211 if (!ib_get_smp_direction(smp)) {
214 /* C14-9:2 -- intermediate hop */ 212 /* C14-9:2 -- intermediate hop */
215 if (hop_ptr && hop_ptr < hop_cnt) 213 if (hop_ptr && hop_ptr < hop_cnt)
216 return 1; 214 return IB_SMI_SEND;
217 215
218 /* C14-9:3 -- at the end of the DR segment of path */ 216 /* C14-9:3 -- at the end of the DR segment of path */
219 if (hop_ptr == hop_cnt) 217 if (hop_ptr == hop_cnt)
220 return (smp->dr_dlid == IB_LID_PERMISSIVE); 218 return (smp->dr_dlid == IB_LID_PERMISSIVE ?
219 IB_SMI_SEND : IB_SMI_LOCAL);
221 220
222 /* C14-9:4 -- hop_ptr = hop_cnt + 1 -> give to SMA/SM */ 221 /* C14-9:4 -- hop_ptr = hop_cnt + 1 -> give to SMA/SM */
223 if (hop_ptr == hop_cnt + 1) 222 if (hop_ptr == hop_cnt + 1)
224 return 1; 223 return IB_SMI_SEND;
225 } else { 224 } else {
226 /* C14-13:2 */ 225 /* C14-13:2 -- intermediate hop */
227 if (2 <= hop_ptr && hop_ptr <= hop_cnt) 226 if (2 <= hop_ptr && hop_ptr <= hop_cnt)
228 return 1; 227 return IB_SMI_SEND;
229 228
230 /* C14-13:3 -- at the end of the DR segment of path */ 229 /* C14-13:3 -- at the end of the DR segment of path */
231 if (hop_ptr == 1) 230 if (hop_ptr == 1)
232 return (smp->dr_slid != IB_LID_PERMISSIVE); 231 return (smp->dr_slid != IB_LID_PERMISSIVE ?
232 IB_SMI_SEND : IB_SMI_LOCAL);
233 } 233 }
234 return 0; 234 return IB_SMI_LOCAL;
235} 235}
diff --git a/drivers/infiniband/core/smi.h b/drivers/infiniband/core/smi.h
index 3011bfd86dc5..9a4b349efc30 100644
--- a/drivers/infiniband/core/smi.h
+++ b/drivers/infiniband/core/smi.h
@@ -3,7 +3,7 @@
3 * Copyright (c) 2004 Infinicon Corporation. All rights reserved. 3 * Copyright (c) 2004 Infinicon Corporation. All rights reserved.
4 * Copyright (c) 2004 Intel Corporation. All rights reserved. 4 * Copyright (c) 2004 Intel Corporation. All rights reserved.
5 * Copyright (c) 2004 Topspin Corporation. All rights reserved. 5 * Copyright (c) 2004 Topspin Corporation. All rights reserved.
6 * Copyright (c) 2004 Voltaire Corporation. All rights reserved. 6 * Copyright (c) 2004-2007 Voltaire Corporation. All rights reserved.
7 * 7 *
8 * This software is available to you under a choice of one of two 8 * This software is available to you under a choice of one of two
9 * licenses. You may choose to be licensed under the terms of the GNU 9 * licenses. You may choose to be licensed under the terms of the GNU
@@ -33,7 +33,6 @@
33 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 33 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
34 * SOFTWARE. 34 * SOFTWARE.
35 * 35 *
36 * $Id: smi.h 1389 2004-12-27 22:56:47Z roland $
37 */ 36 */
38 37
39#ifndef __SMI_H_ 38#ifndef __SMI_H_
@@ -41,26 +40,33 @@
41 40
42#include <rdma/ib_smi.h> 41#include <rdma/ib_smi.h>
43 42
44int smi_handle_dr_smp_recv(struct ib_smp *smp, 43enum smi_action {
45 u8 node_type, 44 IB_SMI_DISCARD,
46 int port_num, 45 IB_SMI_HANDLE
47 int phys_port_cnt); 46};
48extern int smi_check_forward_dr_smp(struct ib_smp *smp); 47
49extern int smi_handle_dr_smp_send(struct ib_smp *smp, 48enum smi_forward_action {
50 u8 node_type, 49 IB_SMI_LOCAL, /* SMP should be completed up the stack */
51 int port_num); 50 IB_SMI_SEND, /* received DR SMP should be forwarded to the send queue */
51};
52
53enum smi_action smi_handle_dr_smp_recv(struct ib_smp *smp, u8 node_type,
54 int port_num, int phys_port_cnt);
55extern enum smi_forward_action smi_check_forward_dr_smp(struct ib_smp *smp);
56extern enum smi_action smi_handle_dr_smp_send(struct ib_smp *smp,
57 u8 node_type, int port_num);
52 58
53/* 59/*
54 * Return 1 if the SMP should be handled by the local SMA/SM via process_mad 60 * Return 1 if the SMP should be handled by the local SMA/SM via process_mad
55 */ 61 */
56static inline int smi_check_local_smp(struct ib_smp *smp, 62static inline enum smi_action smi_check_local_smp(struct ib_smp *smp,
57 struct ib_device *device) 63 struct ib_device *device)
58{ 64{
59 /* C14-9:3 -- We're at the end of the DR segment of path */ 65 /* C14-9:3 -- We're at the end of the DR segment of path */
60 /* C14-9:4 -- Hop Pointer = Hop Count + 1 -> give to SMA/SM */ 66 /* C14-9:4 -- Hop Pointer = Hop Count + 1 -> give to SMA/SM */
61 return ((device->process_mad && 67 return ((device->process_mad &&
62 !ib_get_smp_direction(smp) && 68 !ib_get_smp_direction(smp) &&
63 (smp->hop_ptr == smp->hop_cnt + 1))); 69 (smp->hop_ptr == smp->hop_cnt + 1)) ?
70 IB_SMI_HANDLE : IB_SMI_DISCARD);
64} 71}
65
66#endif /* __SMI_H_ */ 72#endif /* __SMI_H_ */