1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun * Copyright (c) 2004, 2005 Mellanox Technologies Ltd. All rights reserved.
3*4882a593Smuzhiyun * Copyright (c) 2004, 2005 Infinicon Corporation. All rights reserved.
4*4882a593Smuzhiyun * Copyright (c) 2004, 2005 Intel Corporation. All rights reserved.
5*4882a593Smuzhiyun * Copyright (c) 2004, 2005 Topspin Corporation. All rights reserved.
6*4882a593Smuzhiyun * Copyright (c) 2004-2007 Voltaire Corporation. All rights reserved.
7*4882a593Smuzhiyun * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
8*4882a593Smuzhiyun * Copyright (c) 2014 Intel Corporation. All rights reserved.
9*4882a593Smuzhiyun *
10*4882a593Smuzhiyun * This software is available to you under a choice of one of two
11*4882a593Smuzhiyun * licenses. You may choose to be licensed under the terms of the GNU
12*4882a593Smuzhiyun * General Public License (GPL) Version 2, available from the file
13*4882a593Smuzhiyun * COPYING in the main directory of this source tree, or the
14*4882a593Smuzhiyun * OpenIB.org BSD license below:
15*4882a593Smuzhiyun *
16*4882a593Smuzhiyun * Redistribution and use in source and binary forms, with or
17*4882a593Smuzhiyun * without modification, are permitted provided that the following
18*4882a593Smuzhiyun * conditions are met:
19*4882a593Smuzhiyun *
20*4882a593Smuzhiyun * - Redistributions of source code must retain the above
21*4882a593Smuzhiyun * copyright notice, this list of conditions and the following
22*4882a593Smuzhiyun * disclaimer.
23*4882a593Smuzhiyun *
24*4882a593Smuzhiyun * - Redistributions in binary form must reproduce the above
25*4882a593Smuzhiyun * copyright notice, this list of conditions and the following
26*4882a593Smuzhiyun * disclaimer in the documentation and/or other materials
27*4882a593Smuzhiyun * provided with the distribution.
28*4882a593Smuzhiyun *
29*4882a593Smuzhiyun * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
30*4882a593Smuzhiyun * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
31*4882a593Smuzhiyun * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
32*4882a593Smuzhiyun * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
33*4882a593Smuzhiyun * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
34*4882a593Smuzhiyun * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
35*4882a593Smuzhiyun * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
36*4882a593Smuzhiyun * SOFTWARE.
37*4882a593Smuzhiyun *
38*4882a593Smuzhiyun */
39*4882a593Smuzhiyun
40*4882a593Smuzhiyun #include <rdma/ib_smi.h>
41*4882a593Smuzhiyun #include "smi.h"
42*4882a593Smuzhiyun #include "opa_smi.h"
43*4882a593Smuzhiyun
__smi_handle_dr_smp_send(bool is_switch,int port_num,u8 * hop_ptr,u8 hop_cnt,const u8 * initial_path,const u8 * return_path,u8 direction,bool dr_dlid_is_permissive,bool dr_slid_is_permissive)44*4882a593Smuzhiyun static enum smi_action __smi_handle_dr_smp_send(bool is_switch, int port_num,
45*4882a593Smuzhiyun u8 *hop_ptr, u8 hop_cnt,
46*4882a593Smuzhiyun const u8 *initial_path,
47*4882a593Smuzhiyun const u8 *return_path,
48*4882a593Smuzhiyun u8 direction,
49*4882a593Smuzhiyun bool dr_dlid_is_permissive,
50*4882a593Smuzhiyun bool dr_slid_is_permissive)
51*4882a593Smuzhiyun {
52*4882a593Smuzhiyun /* See section 14.2.2.2, Vol 1 IB spec */
53*4882a593Smuzhiyun /* C14-6 -- valid hop_cnt values are from 0 to 63 */
54*4882a593Smuzhiyun if (hop_cnt >= IB_SMP_MAX_PATH_HOPS)
55*4882a593Smuzhiyun return IB_SMI_DISCARD;
56*4882a593Smuzhiyun
57*4882a593Smuzhiyun if (!direction) {
58*4882a593Smuzhiyun /* C14-9:1 */
59*4882a593Smuzhiyun if (hop_cnt && *hop_ptr == 0) {
60*4882a593Smuzhiyun (*hop_ptr)++;
61*4882a593Smuzhiyun return (initial_path[*hop_ptr] ==
62*4882a593Smuzhiyun port_num ? IB_SMI_HANDLE : IB_SMI_DISCARD);
63*4882a593Smuzhiyun }
64*4882a593Smuzhiyun
65*4882a593Smuzhiyun /* C14-9:2 */
66*4882a593Smuzhiyun if (*hop_ptr && *hop_ptr < hop_cnt) {
67*4882a593Smuzhiyun if (!is_switch)
68*4882a593Smuzhiyun return IB_SMI_DISCARD;
69*4882a593Smuzhiyun
70*4882a593Smuzhiyun /* return_path set when received */
71*4882a593Smuzhiyun (*hop_ptr)++;
72*4882a593Smuzhiyun return (initial_path[*hop_ptr] ==
73*4882a593Smuzhiyun port_num ? IB_SMI_HANDLE : IB_SMI_DISCARD);
74*4882a593Smuzhiyun }
75*4882a593Smuzhiyun
76*4882a593Smuzhiyun /* C14-9:3 -- We're at the end of the DR segment of path */
77*4882a593Smuzhiyun if (*hop_ptr == hop_cnt) {
78*4882a593Smuzhiyun /* return_path set when received */
79*4882a593Smuzhiyun (*hop_ptr)++;
80*4882a593Smuzhiyun return (is_switch ||
81*4882a593Smuzhiyun dr_dlid_is_permissive ?
82*4882a593Smuzhiyun IB_SMI_HANDLE : IB_SMI_DISCARD);
83*4882a593Smuzhiyun }
84*4882a593Smuzhiyun
85*4882a593Smuzhiyun /* C14-9:4 -- hop_ptr = hop_cnt + 1 -> give to SMA/SM */
86*4882a593Smuzhiyun /* C14-9:5 -- Fail unreasonable hop pointer */
87*4882a593Smuzhiyun return (*hop_ptr == hop_cnt + 1 ? IB_SMI_HANDLE : IB_SMI_DISCARD);
88*4882a593Smuzhiyun
89*4882a593Smuzhiyun } else {
90*4882a593Smuzhiyun /* C14-13:1 */
91*4882a593Smuzhiyun if (hop_cnt && *hop_ptr == hop_cnt + 1) {
92*4882a593Smuzhiyun (*hop_ptr)--;
93*4882a593Smuzhiyun return (return_path[*hop_ptr] ==
94*4882a593Smuzhiyun port_num ? IB_SMI_HANDLE : IB_SMI_DISCARD);
95*4882a593Smuzhiyun }
96*4882a593Smuzhiyun
97*4882a593Smuzhiyun /* C14-13:2 */
98*4882a593Smuzhiyun if (2 <= *hop_ptr && *hop_ptr <= hop_cnt) {
99*4882a593Smuzhiyun if (!is_switch)
100*4882a593Smuzhiyun return IB_SMI_DISCARD;
101*4882a593Smuzhiyun
102*4882a593Smuzhiyun (*hop_ptr)--;
103*4882a593Smuzhiyun return (return_path[*hop_ptr] ==
104*4882a593Smuzhiyun port_num ? IB_SMI_HANDLE : IB_SMI_DISCARD);
105*4882a593Smuzhiyun }
106*4882a593Smuzhiyun
107*4882a593Smuzhiyun /* C14-13:3 -- at the end of the DR segment of path */
108*4882a593Smuzhiyun if (*hop_ptr == 1) {
109*4882a593Smuzhiyun (*hop_ptr)--;
110*4882a593Smuzhiyun /* C14-13:3 -- SMPs destined for SM shouldn't be here */
111*4882a593Smuzhiyun return (is_switch ||
112*4882a593Smuzhiyun dr_slid_is_permissive ?
113*4882a593Smuzhiyun IB_SMI_HANDLE : IB_SMI_DISCARD);
114*4882a593Smuzhiyun }
115*4882a593Smuzhiyun
116*4882a593Smuzhiyun /* C14-13:4 -- hop_ptr = 0 -> should have gone to SM */
117*4882a593Smuzhiyun if (*hop_ptr == 0)
118*4882a593Smuzhiyun return IB_SMI_HANDLE;
119*4882a593Smuzhiyun
120*4882a593Smuzhiyun /* C14-13:5 -- Check for unreasonable hop pointer */
121*4882a593Smuzhiyun return IB_SMI_DISCARD;
122*4882a593Smuzhiyun }
123*4882a593Smuzhiyun }
124*4882a593Smuzhiyun
125*4882a593Smuzhiyun /*
126*4882a593Smuzhiyun * Fixup a directed route SMP for sending
127*4882a593Smuzhiyun * Return IB_SMI_DISCARD if the SMP should be discarded
128*4882a593Smuzhiyun */
smi_handle_dr_smp_send(struct ib_smp * smp,bool is_switch,int port_num)129*4882a593Smuzhiyun enum smi_action smi_handle_dr_smp_send(struct ib_smp *smp,
130*4882a593Smuzhiyun bool is_switch, int port_num)
131*4882a593Smuzhiyun {
132*4882a593Smuzhiyun return __smi_handle_dr_smp_send(is_switch, port_num,
133*4882a593Smuzhiyun &smp->hop_ptr, smp->hop_cnt,
134*4882a593Smuzhiyun smp->initial_path,
135*4882a593Smuzhiyun smp->return_path,
136*4882a593Smuzhiyun ib_get_smp_direction(smp),
137*4882a593Smuzhiyun smp->dr_dlid == IB_LID_PERMISSIVE,
138*4882a593Smuzhiyun smp->dr_slid == IB_LID_PERMISSIVE);
139*4882a593Smuzhiyun }
140*4882a593Smuzhiyun
opa_smi_handle_dr_smp_send(struct opa_smp * smp,bool is_switch,int port_num)141*4882a593Smuzhiyun enum smi_action opa_smi_handle_dr_smp_send(struct opa_smp *smp,
142*4882a593Smuzhiyun bool is_switch, int port_num)
143*4882a593Smuzhiyun {
144*4882a593Smuzhiyun return __smi_handle_dr_smp_send(is_switch, port_num,
145*4882a593Smuzhiyun &smp->hop_ptr, smp->hop_cnt,
146*4882a593Smuzhiyun smp->route.dr.initial_path,
147*4882a593Smuzhiyun smp->route.dr.return_path,
148*4882a593Smuzhiyun opa_get_smp_direction(smp),
149*4882a593Smuzhiyun smp->route.dr.dr_dlid ==
150*4882a593Smuzhiyun OPA_LID_PERMISSIVE,
151*4882a593Smuzhiyun smp->route.dr.dr_slid ==
152*4882a593Smuzhiyun OPA_LID_PERMISSIVE);
153*4882a593Smuzhiyun }
154*4882a593Smuzhiyun
__smi_handle_dr_smp_recv(bool is_switch,int port_num,int phys_port_cnt,u8 * hop_ptr,u8 hop_cnt,const u8 * initial_path,u8 * return_path,u8 direction,bool dr_dlid_is_permissive,bool dr_slid_is_permissive)155*4882a593Smuzhiyun static enum smi_action __smi_handle_dr_smp_recv(bool is_switch, int port_num,
156*4882a593Smuzhiyun int phys_port_cnt,
157*4882a593Smuzhiyun u8 *hop_ptr, u8 hop_cnt,
158*4882a593Smuzhiyun const u8 *initial_path,
159*4882a593Smuzhiyun u8 *return_path,
160*4882a593Smuzhiyun u8 direction,
161*4882a593Smuzhiyun bool dr_dlid_is_permissive,
162*4882a593Smuzhiyun bool dr_slid_is_permissive)
163*4882a593Smuzhiyun {
164*4882a593Smuzhiyun /* See section 14.2.2.2, Vol 1 IB spec */
165*4882a593Smuzhiyun /* C14-6 -- valid hop_cnt values are from 0 to 63 */
166*4882a593Smuzhiyun if (hop_cnt >= IB_SMP_MAX_PATH_HOPS)
167*4882a593Smuzhiyun return IB_SMI_DISCARD;
168*4882a593Smuzhiyun
169*4882a593Smuzhiyun if (!direction) {
170*4882a593Smuzhiyun /* C14-9:1 -- sender should have incremented hop_ptr */
171*4882a593Smuzhiyun if (hop_cnt && *hop_ptr == 0)
172*4882a593Smuzhiyun return IB_SMI_DISCARD;
173*4882a593Smuzhiyun
174*4882a593Smuzhiyun /* C14-9:2 -- intermediate hop */
175*4882a593Smuzhiyun if (*hop_ptr && *hop_ptr < hop_cnt) {
176*4882a593Smuzhiyun if (!is_switch)
177*4882a593Smuzhiyun return IB_SMI_DISCARD;
178*4882a593Smuzhiyun
179*4882a593Smuzhiyun return_path[*hop_ptr] = port_num;
180*4882a593Smuzhiyun /* hop_ptr updated when sending */
181*4882a593Smuzhiyun return (initial_path[*hop_ptr+1] <= phys_port_cnt ?
182*4882a593Smuzhiyun IB_SMI_HANDLE : IB_SMI_DISCARD);
183*4882a593Smuzhiyun }
184*4882a593Smuzhiyun
185*4882a593Smuzhiyun /* C14-9:3 -- We're at the end of the DR segment of path */
186*4882a593Smuzhiyun if (*hop_ptr == hop_cnt) {
187*4882a593Smuzhiyun if (hop_cnt)
188*4882a593Smuzhiyun return_path[*hop_ptr] = port_num;
189*4882a593Smuzhiyun /* hop_ptr updated when sending */
190*4882a593Smuzhiyun
191*4882a593Smuzhiyun return (is_switch ||
192*4882a593Smuzhiyun dr_dlid_is_permissive ?
193*4882a593Smuzhiyun IB_SMI_HANDLE : IB_SMI_DISCARD);
194*4882a593Smuzhiyun }
195*4882a593Smuzhiyun
196*4882a593Smuzhiyun /* C14-9:4 -- hop_ptr = hop_cnt + 1 -> give to SMA/SM */
197*4882a593Smuzhiyun /* C14-9:5 -- fail unreasonable hop pointer */
198*4882a593Smuzhiyun return (*hop_ptr == hop_cnt + 1 ? IB_SMI_HANDLE : IB_SMI_DISCARD);
199*4882a593Smuzhiyun
200*4882a593Smuzhiyun } else {
201*4882a593Smuzhiyun
202*4882a593Smuzhiyun /* C14-13:1 */
203*4882a593Smuzhiyun if (hop_cnt && *hop_ptr == hop_cnt + 1) {
204*4882a593Smuzhiyun (*hop_ptr)--;
205*4882a593Smuzhiyun return (return_path[*hop_ptr] ==
206*4882a593Smuzhiyun port_num ? IB_SMI_HANDLE : IB_SMI_DISCARD);
207*4882a593Smuzhiyun }
208*4882a593Smuzhiyun
209*4882a593Smuzhiyun /* C14-13:2 */
210*4882a593Smuzhiyun if (2 <= *hop_ptr && *hop_ptr <= hop_cnt) {
211*4882a593Smuzhiyun if (!is_switch)
212*4882a593Smuzhiyun return IB_SMI_DISCARD;
213*4882a593Smuzhiyun
214*4882a593Smuzhiyun /* hop_ptr updated when sending */
215*4882a593Smuzhiyun return (return_path[*hop_ptr-1] <= phys_port_cnt ?
216*4882a593Smuzhiyun IB_SMI_HANDLE : IB_SMI_DISCARD);
217*4882a593Smuzhiyun }
218*4882a593Smuzhiyun
219*4882a593Smuzhiyun /* C14-13:3 -- We're at the end of the DR segment of path */
220*4882a593Smuzhiyun if (*hop_ptr == 1) {
221*4882a593Smuzhiyun if (dr_slid_is_permissive) {
222*4882a593Smuzhiyun /* giving SMP to SM - update hop_ptr */
223*4882a593Smuzhiyun (*hop_ptr)--;
224*4882a593Smuzhiyun return IB_SMI_HANDLE;
225*4882a593Smuzhiyun }
226*4882a593Smuzhiyun /* hop_ptr updated when sending */
227*4882a593Smuzhiyun return (is_switch ? IB_SMI_HANDLE : IB_SMI_DISCARD);
228*4882a593Smuzhiyun }
229*4882a593Smuzhiyun
230*4882a593Smuzhiyun /* C14-13:4 -- hop_ptr = 0 -> give to SM */
231*4882a593Smuzhiyun /* C14-13:5 -- Check for unreasonable hop pointer */
232*4882a593Smuzhiyun return (*hop_ptr == 0 ? IB_SMI_HANDLE : IB_SMI_DISCARD);
233*4882a593Smuzhiyun }
234*4882a593Smuzhiyun }
235*4882a593Smuzhiyun
236*4882a593Smuzhiyun /*
237*4882a593Smuzhiyun * Adjust information for a received SMP
238*4882a593Smuzhiyun * Return IB_SMI_DISCARD if the SMP should be dropped
239*4882a593Smuzhiyun */
smi_handle_dr_smp_recv(struct ib_smp * smp,bool is_switch,int port_num,int phys_port_cnt)240*4882a593Smuzhiyun enum smi_action smi_handle_dr_smp_recv(struct ib_smp *smp, bool is_switch,
241*4882a593Smuzhiyun int port_num, int phys_port_cnt)
242*4882a593Smuzhiyun {
243*4882a593Smuzhiyun return __smi_handle_dr_smp_recv(is_switch, port_num, phys_port_cnt,
244*4882a593Smuzhiyun &smp->hop_ptr, smp->hop_cnt,
245*4882a593Smuzhiyun smp->initial_path,
246*4882a593Smuzhiyun smp->return_path,
247*4882a593Smuzhiyun ib_get_smp_direction(smp),
248*4882a593Smuzhiyun smp->dr_dlid == IB_LID_PERMISSIVE,
249*4882a593Smuzhiyun smp->dr_slid == IB_LID_PERMISSIVE);
250*4882a593Smuzhiyun }
251*4882a593Smuzhiyun
252*4882a593Smuzhiyun /*
253*4882a593Smuzhiyun * Adjust information for a received SMP
254*4882a593Smuzhiyun * Return IB_SMI_DISCARD if the SMP should be dropped
255*4882a593Smuzhiyun */
opa_smi_handle_dr_smp_recv(struct opa_smp * smp,bool is_switch,int port_num,int phys_port_cnt)256*4882a593Smuzhiyun enum smi_action opa_smi_handle_dr_smp_recv(struct opa_smp *smp, bool is_switch,
257*4882a593Smuzhiyun int port_num, int phys_port_cnt)
258*4882a593Smuzhiyun {
259*4882a593Smuzhiyun return __smi_handle_dr_smp_recv(is_switch, port_num, phys_port_cnt,
260*4882a593Smuzhiyun &smp->hop_ptr, smp->hop_cnt,
261*4882a593Smuzhiyun smp->route.dr.initial_path,
262*4882a593Smuzhiyun smp->route.dr.return_path,
263*4882a593Smuzhiyun opa_get_smp_direction(smp),
264*4882a593Smuzhiyun smp->route.dr.dr_dlid ==
265*4882a593Smuzhiyun OPA_LID_PERMISSIVE,
266*4882a593Smuzhiyun smp->route.dr.dr_slid ==
267*4882a593Smuzhiyun OPA_LID_PERMISSIVE);
268*4882a593Smuzhiyun }
269*4882a593Smuzhiyun
__smi_check_forward_dr_smp(u8 hop_ptr,u8 hop_cnt,u8 direction,bool dr_dlid_is_permissive,bool dr_slid_is_permissive)270*4882a593Smuzhiyun static enum smi_forward_action __smi_check_forward_dr_smp(u8 hop_ptr, u8 hop_cnt,
271*4882a593Smuzhiyun u8 direction,
272*4882a593Smuzhiyun bool dr_dlid_is_permissive,
273*4882a593Smuzhiyun bool dr_slid_is_permissive)
274*4882a593Smuzhiyun {
275*4882a593Smuzhiyun if (!direction) {
276*4882a593Smuzhiyun /* C14-9:2 -- intermediate hop */
277*4882a593Smuzhiyun if (hop_ptr && hop_ptr < hop_cnt)
278*4882a593Smuzhiyun return IB_SMI_FORWARD;
279*4882a593Smuzhiyun
280*4882a593Smuzhiyun /* C14-9:3 -- at the end of the DR segment of path */
281*4882a593Smuzhiyun if (hop_ptr == hop_cnt)
282*4882a593Smuzhiyun return (dr_dlid_is_permissive ?
283*4882a593Smuzhiyun IB_SMI_SEND : IB_SMI_LOCAL);
284*4882a593Smuzhiyun
285*4882a593Smuzhiyun /* C14-9:4 -- hop_ptr = hop_cnt + 1 -> give to SMA/SM */
286*4882a593Smuzhiyun if (hop_ptr == hop_cnt + 1)
287*4882a593Smuzhiyun return IB_SMI_SEND;
288*4882a593Smuzhiyun } else {
289*4882a593Smuzhiyun /* C14-13:2 -- intermediate hop */
290*4882a593Smuzhiyun if (2 <= hop_ptr && hop_ptr <= hop_cnt)
291*4882a593Smuzhiyun return IB_SMI_FORWARD;
292*4882a593Smuzhiyun
293*4882a593Smuzhiyun /* C14-13:3 -- at the end of the DR segment of path */
294*4882a593Smuzhiyun if (hop_ptr == 1)
295*4882a593Smuzhiyun return (!dr_slid_is_permissive ?
296*4882a593Smuzhiyun IB_SMI_SEND : IB_SMI_LOCAL);
297*4882a593Smuzhiyun }
298*4882a593Smuzhiyun return IB_SMI_LOCAL;
299*4882a593Smuzhiyun
300*4882a593Smuzhiyun }
301*4882a593Smuzhiyun
smi_check_forward_dr_smp(struct ib_smp * smp)302*4882a593Smuzhiyun enum smi_forward_action smi_check_forward_dr_smp(struct ib_smp *smp)
303*4882a593Smuzhiyun {
304*4882a593Smuzhiyun return __smi_check_forward_dr_smp(smp->hop_ptr, smp->hop_cnt,
305*4882a593Smuzhiyun ib_get_smp_direction(smp),
306*4882a593Smuzhiyun smp->dr_dlid == IB_LID_PERMISSIVE,
307*4882a593Smuzhiyun smp->dr_slid == IB_LID_PERMISSIVE);
308*4882a593Smuzhiyun }
309*4882a593Smuzhiyun
opa_smi_check_forward_dr_smp(struct opa_smp * smp)310*4882a593Smuzhiyun enum smi_forward_action opa_smi_check_forward_dr_smp(struct opa_smp *smp)
311*4882a593Smuzhiyun {
312*4882a593Smuzhiyun return __smi_check_forward_dr_smp(smp->hop_ptr, smp->hop_cnt,
313*4882a593Smuzhiyun opa_get_smp_direction(smp),
314*4882a593Smuzhiyun smp->route.dr.dr_dlid ==
315*4882a593Smuzhiyun OPA_LID_PERMISSIVE,
316*4882a593Smuzhiyun smp->route.dr.dr_slid ==
317*4882a593Smuzhiyun OPA_LID_PERMISSIVE);
318*4882a593Smuzhiyun }
319*4882a593Smuzhiyun
320*4882a593Smuzhiyun /*
321*4882a593Smuzhiyun * Return the forwarding port number from initial_path for outgoing SMP and
322*4882a593Smuzhiyun * from return_path for returning SMP
323*4882a593Smuzhiyun */
smi_get_fwd_port(struct ib_smp * smp)324*4882a593Smuzhiyun int smi_get_fwd_port(struct ib_smp *smp)
325*4882a593Smuzhiyun {
326*4882a593Smuzhiyun return (!ib_get_smp_direction(smp) ? smp->initial_path[smp->hop_ptr+1] :
327*4882a593Smuzhiyun smp->return_path[smp->hop_ptr-1]);
328*4882a593Smuzhiyun }
329*4882a593Smuzhiyun
330*4882a593Smuzhiyun /*
331*4882a593Smuzhiyun * Return the forwarding port number from initial_path for outgoing SMP and
332*4882a593Smuzhiyun * from return_path for returning SMP
333*4882a593Smuzhiyun */
opa_smi_get_fwd_port(struct opa_smp * smp)334*4882a593Smuzhiyun int opa_smi_get_fwd_port(struct opa_smp *smp)
335*4882a593Smuzhiyun {
336*4882a593Smuzhiyun return !opa_get_smp_direction(smp) ? smp->route.dr.initial_path[smp->hop_ptr+1] :
337*4882a593Smuzhiyun smp->route.dr.return_path[smp->hop_ptr-1];
338*4882a593Smuzhiyun }
339