1 /*
2  * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
3  * Copyright (c) 2002-2011 Mellanox Technologies LTD. All rights reserved.
4  * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
5  *
6  * This software is available to you under a choice of one of two
7  * licenses.  You may choose to be licensed under the terms of the GNU
8  * General Public License (GPL) Version 2, available from the file
9  * COPYING in the main directory of this source tree, or the
10  * OpenIB.org BSD license below:
11  *
12  *     Redistribution and use in source and binary forms, with or
13  *     without modification, are permitted provided that the following
14  *     conditions are met:
15  *
16  *      - Redistributions of source code must retain the above
17  *        copyright notice, this list of conditions and the following
18  *        disclaimer.
19  *
20  *      - Redistributions in binary form must reproduce the above
21  *        copyright notice, this list of conditions and the following
22  *        disclaimer in the documentation and/or other materials
23  *        provided with the distribution.
24  *
25  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32  * SOFTWARE.
33  *
34  */
35 
36 /*
37  * Abstract:
38  * 	Declaration of port related objects.
39  *	These objects comprise an IBA port.
40  *	These objects are part of the OpenSM family of objects.
41  */
42 
43 #ifndef _OSM_PORT_H_
44 #define _OSM_PORT_H_
45 
46 #include <complib/cl_qmap.h>
47 #include <iba/ib_types.h>
48 #include <opensm/osm_base.h>
49 #include <opensm/osm_subnet.h>
50 #include <opensm/osm_madw.h>
51 #include <opensm/osm_path.h>
52 #include <opensm/osm_pkey.h>
53 
54 #ifdef __cplusplus
55 #  define BEGIN_C_DECLS extern "C" {
56 #  define END_C_DECLS   }
57 #else				/* !__cplusplus */
58 #  define BEGIN_C_DECLS
59 #  define END_C_DECLS
60 #endif				/* __cplusplus */
61 
62 BEGIN_C_DECLS
63 /*
64 	Forward references.
65 */
66 struct osm_port;
67 struct osm_node;
68 struct osm_mgrp;
69 struct osm_sm;
70 
71 /****h* OpenSM/Physical Port
72 * NAME
73 *	Physical Port
74 *
75 * DESCRIPTION
76 *	The Physical Port object encapsulates the information needed by the
77 *	OpenSM to manage physical ports.  The OpenSM allocates one Physical Port
78 *	per physical port in the IBA subnet.
79 *
80 *	In a switch, one multiple Physical Port objects share the same port GUID.
81 *	In an end-point, Physical Ports do not share GUID values.
82 *
83 *	The Physical Port is not thread safe, thus callers must provide
84 *	serialization.
85 *
86 *	These objects should be treated as opaque and should be
87 *	manipulated only through the provided functions.
88 *
89 * AUTHOR
90 *	Steve King, Intel
91 *
92 *********/
93 
94 /****s* OpenSM: Physical Port/osm_physp_t
95 * NAME
96 *	osm_physp_t
97 *
98 * DESCRIPTION
99 *	This object represents a physical port on a switch, router or end-point.
100 *
101 *	The osm_physp_t object should be treated as opaque and should
102 *	be manipulated only through the provided functions.
103 *
104 * SYNOPSIS
105 */
106 typedef struct osm_physp {
107 	ib_port_info_t port_info;
108 	ib_mlnx_ext_port_info_t ext_port_info;
109 	ib_net64_t port_guid;
110 	ib_net64_t (*p_guids)[];
111 	uint8_t port_num;
112 	struct osm_node *p_node;
113 	struct osm_physp *p_remote_physp;
114 	boolean_t healthy;
115 	uint8_t vl_high_limit;
116 	unsigned need_update;
117 	unsigned is_prof_ignored;
118 	osm_dr_path_t dr_path;
119 	osm_pkey_tbl_t pkeys;
120 	ib_vl_arb_table_t vl_arb[4];
121 	cl_ptr_vector_t slvl_by_port;
122 	uint8_t hop_wf;
123 	union {
124 		struct {
125 			ib_sw_cong_setting_t sw_cong_setting;
126 		} sw;
127 		struct {
128 			ib_ca_cong_setting_t ca_cong_setting;
129 			ib_cc_tbl_t cc_tbl[OSM_CCT_ENTRY_MAD_BLOCKS];
130 		} ca;
131 	} cc;
132 } osm_physp_t;
133 /*
134 * FIELDS
135 *	port_info
136 *		The IBA defined PortInfo data for this port.
137 *
138 *	ext_port_info
139 *		Mellanox vendor specific ExtendedPortInfo data for this port.
140 *
141 *	port_guid
142 *		Port GUID value of this port.  For switches,
143 *		all ports share the same GUID value.
144 *
145 *	p_guids
146 *		Pointer to array of GUIDs obtained from GUIDInfo.
147 *		This pointer is null for switch physical/external ports
148 *		(used for endports only).
149 *
150 *	port_num
151 *		The port number of this port.  The PortInfo also
152 *		contains a port_number, but that number is not
153 *		the port number of this port, but rather the number
154 *		of the port that received the SMP during discovery.
155 *		Therefore, we must keep a separate record for this
156 *		port's port number.
157 *
158 *	p_node
159 *		Pointer to the parent Node object of this Physical Port.
160 *
161 *	p_remote_physp
162 *		Pointer to the Physical Port on the other side of the wire.
163 *		If this pointer is NULL no link exists at this port.
164 *
165 *	healthy
166 *		Tracks the health of the port. Normally should be TRUE but
167 *		might change as a result of incoming traps indicating the port
168 *		healthy is questionable.
169 *
170 *	vl_high_limit
171 *		PortInfo:VLHighLimit value which installed by QoS manager
172 *		and should be uploaded to port's PortInfo
173 *
174 *	need_update
175 *		When set indicates that port was probably reset and port
176 *		related tables (PKey, SL2VL, VLArb) require refreshing.
177 *
178 *	is_prof_ignored
179 *		When set indicates that switch port will be ignored by
180 *		the link load equalization algorithm.
181 *
182 *	dr_path
183 *		The directed route path to this port.
184 *
185 *	pkeys
186 *		osm_pkey_tbl_t object holding the port PKeys.
187 *
188 *	vl_arb[]
189 *		Each Physical Port has 4 sections of VL Arbitration table.
190 *
191 *	slvl_by_port
192 *		A vector of pointers to the sl2vl tables (ordered by input port).
193 *		Switches have an entry for every other input port (inc SMA=0).
194 *		On CAs only one per port.
195 *
196 *	hop_wf
197 *		Hop weighting factor to be used in the routing.
198 *
199 *	sw_cong_setting
200 *		Physical port switch congestion settings (switches only)
201 *
202 *	ca_cong_setting
203 *		Physical port ca congestion settings (cas only)
204 *
205 *	cc_tbl
206 *		Physical port ca congestion control table (cas only)
207 *
208 * SEE ALSO
209 *	Port
210 *********/
211 
212 /****f* OpenSM: Physical Port/osm_physp_construct
213 * NAME
214 *	osm_physp_construct
215 *
216 * DESCRIPTION
217 *	Constructs a Physical Port.
218 *
219 * SYNOPSIS
220 */
221 void osm_physp_construct(IN osm_physp_t * p_physp);
222 /*
223 * PARAMETERS
224 *	p_physp
225 *		[in] Pointer to an osm_physp_t object to initialize.
226 *
227 * RETURN VALUES
228 *	This function does not return a value.
229 *
230 * NOTES
231 *
232 * SEE ALSO
233 *	Port, Physical Port
234 *********/
235 
236 /****f* OpenSM: Physical Port/osm_physp_init
237 * NAME
238 *	osm_physp_init
239 *
240 * DESCRIPTION
241 *	Initializes a Physical Port for use.
242 *
243 * SYNOPSIS
244 */
245 void osm_physp_init(IN osm_physp_t * p_physp, IN ib_net64_t port_guid,
246 		    IN uint8_t port_num, IN const struct osm_node *p_node,
247 		    IN osm_bind_handle_t h_bind, IN uint8_t hop_count,
248 		    IN const uint8_t * p_initial_path);
249 /*
250 * PARAMETERS
251 *	p_physp
252 *		[in] Pointer to an osm_physp_t object to initialize.
253 *
254 *	port_guid
255 *		[in] GUID value of this port.  Switch ports all share
256 *		the same value.
257 *		Caller should use 0 if the guid is unknown.
258 *
259 *	port_num
260 *		[in] The port number of this port.
261 *
262 *	p_node
263 *		[in] Pointer to the parent Node object of this Physical Port.
264 *
265 *	h_bind
266 *		[in] Bind handle on which this port is accessed.
267 *		Caller should use OSM_BIND_INVALID_HANDLE if the bind
268 *		handle to this port is unknown.
269 *
270 *	hop_count
271 *		[in] Directed route hop count to reach this port.
272 *		Caller should use 0 if the hop count is unknown.
273 *
274 *	p_initial_path
275 *		[in] Pointer to the directed route path to reach this node.
276 *		Caller should use NULL if the path is unknown.
277 *
278 * RETURN VALUES
279 *	This function does not return a value.
280 *
281 * NOTES
282 *
283 * SEE ALSO
284 *	Port, Physical Port
285 *********/
286 
287 /****f* OpenSM: Port/void osm_physp_destroy
288 * NAME
289 *	osm_physp_destroy
290 *
291 * DESCRIPTION
292 *	This function destroys a Port object.
293 *
294 * SYNOPSIS
295 */
296 void osm_physp_destroy(IN osm_physp_t * p_physp);
297 /*
298 * PARAMETERS
299 *	p_port
300 *		[in] Pointer to a PhysPort object to destroy.
301 *
302 * RETURN VALUE
303 *	This function does not return a value.
304 *
305 * NOTES
306 *	Performs any necessary cleanup of the specified PhysPort object.
307 *	Further operations should not be attempted on the destroyed object.
308 *	This function should only be called after a call to osm_physp_construct or
309 *	osm_physp_init.
310 *
311 * SEE ALSO
312 *	Port
313 *********/
314 
315 /****f* OpenSM: Physical Port/osm_physp_is_valid
316 * NAME
317 *	osm_physp_is_valid
318 *
319 * DESCRIPTION
320 *	Returns TRUE if the Physical Port has been successfully initialized.
321 *	FALSE otherwise.
322 *
323 * SYNOPSIS
324 */
osm_physp_is_valid(IN const osm_physp_t * p_physp)325 static inline boolean_t osm_physp_is_valid(IN const osm_physp_t * p_physp)
326 {
327 	CL_ASSERT(p_physp);
328 	return (p_physp->port_guid != 0);
329 }
330 
331 /*
332 * PARAMETERS
333 *	p_physp
334 *		[in] Pointer to an osm_physp_t object.
335 *
336 * RETURN VALUES
337 *	Returns TRUE if the Physical Port has been successfully initialized.
338 *	FALSE otherwise.
339 *
340 * NOTES
341 *
342 * SEE ALSO
343 *	Port, Physical Port
344 *********/
345 
346 /****f* OpenSM: Physical Port/osm_physp_is_healthy
347 * NAME
348 *	osm_physp_is_healthy
349 *
350 * DESCRIPTION
351 *	Returns TRUE if the Physical Port has been maked as healthy
352 *	FALSE otherwise.
353 *
354 * SYNOPSIS
355 */
osm_physp_is_healthy(IN const osm_physp_t * p_physp)356 static inline boolean_t osm_physp_is_healthy(IN const osm_physp_t * p_physp)
357 {
358 	CL_ASSERT(p_physp);
359 	return p_physp->healthy;
360 }
361 
362 /*
363 * PARAMETERS
364 *	p_physp
365 *		[in] Pointer to an osm_physp_t object.
366 *
367 * RETURN VALUES
368 *	Returns TRUE if the Physical Port has been maked as healthy
369 *	FALSE otherwise.
370 *  All physical ports are initialized as "healthy" but may be marked
371 *  otherwise if a received trap claims otherwise.
372 *
373 * NOTES
374 *
375 * SEE ALSO
376 *	Port, Physical Port
377 *********/
378 
379 /****f* OpenSM: Physical Port/osm_link_is_healthy
380 * NAME
381 *	osm_link_is_healthy
382 *
383 * DESCRIPTION
384 *	Returns TRUE if the link given by the physical port is health,
385 *  and FALSE otherwise. Link is healthy if both its physical ports are
386 *  healthy
387 *
388 * SYNOPSIS
389 */
390 boolean_t osm_link_is_healthy(IN const osm_physp_t * p_physp);
391 /*
392 * PARAMETERS
393 *	p_physp
394 *		[in] Pointer to an osm_physp_t object.
395 *
396 * RETURN VALUES
397 *	TRUE if both physical ports on the link are healthy, and FALSE otherwise.
398 *  All physical ports are initialized as "healthy" but may be marked
399 *  otherwise if a received trap claiming otherwise.
400 *
401 * NOTES
402 *
403 * SEE ALSO
404 *	Port, Physical Port
405 *********/
406 
407 /****f* OpenSM: Physical Port/osm_physp_set_health
408 * NAME
409 *	osm_physp_set_health
410 *
411 * DESCRIPTION
412 *	Sets the port health flag. TRUE means the port is healthy and
413 *  should be used for packet routing. FALSE means it should be avoided.
414 *
415 * SYNOPSIS
416 */
osm_physp_set_health(IN osm_physp_t * p_physp,IN boolean_t is_healthy)417 static inline void osm_physp_set_health(IN osm_physp_t * p_physp,
418 					IN boolean_t is_healthy)
419 {
420 	CL_ASSERT(p_physp);
421 	p_physp->healthy = is_healthy;
422 }
423 
424 /*
425 * PARAMETERS
426 *	p_physp
427 *		[in] Pointer to an osm_physp_t object.
428 *
429 *	is_healthy
430 *		[in] The health value to be assigned to the port.
431 *		     TRUE if the Physical Port should been maked as healthy
432 *		     FALSE otherwise.
433 *
434 * RETURN VALUES
435 *  NONE
436 *
437 * NOTES
438 *
439 * SEE ALSO
440 *	Port, Physical Port
441 *********/
442 
443 /****f* OpenSM: Physical Port/osm_physp_set_port_info
444 * NAME
445 *	osm_physp_set_port_info
446 *
447 * DESCRIPTION
448 *	Copies the PortInfo attribute into the Physical Port object
449 *	based on the PortState.
450 *
451 * SYNOPSIS
452 */
453 void osm_physp_set_port_info(IN osm_physp_t * p_physp,
454 					   IN const ib_port_info_t * p_pi,
455 					   IN const struct osm_sm * p_sm);
456 
457 /*
458 * PARAMETERS
459 *	p_physp
460 *		[in] Pointer to an osm_physp_t object.
461 *
462 *	p_pi
463 *		[in] Pointer to the IBA defined PortInfo at this port number.
464 *
465 *	p_sm
466 *		[in] Pointer to an osm_sm_t object.
467 *
468 * RETURN VALUES
469 *	This function does not return a value.
470 *
471 * NOTES
472 *
473 * SEE ALSO
474 *	Port, Physical Port
475 *********/
476 
477 /****f* OpenSM: Physical Port/osm_physp_set_base_lid
478 * NAME
479 *	osm_physp_set_base_lid
480 *
481 * DESCRIPTION
482 *	Sets the base lid for this Physical Port.
483 *
484 * SYNOPSIS
485 */
osm_physp_set_base_lid(IN osm_physp_t * p_physp,IN ib_net16_t base_lid)486 static inline void osm_physp_set_base_lid(IN osm_physp_t * p_physp,
487 					  IN ib_net16_t base_lid)
488 {
489 	CL_ASSERT(p_physp);
490 	CL_ASSERT(osm_physp_is_valid(p_physp));
491 	p_physp->port_info.base_lid = base_lid;
492 }
493 
494 /*
495 * PARAMETERS
496 *	p_physp
497 *		[in] Pointer to an osm_physp_t object.
498 *
499 *	base_lid
500 *		[in] Lid to set.
501 *
502 * NOTES
503 *
504 * SEE ALSO
505 *********/
506 
507 /****f* OpenSM: Physical Port/osm_physp_set_pkey_tbl
508 * NAME
509 *  osm_physp_set_pkey_tbl
510 *
511 * DESCRIPTION
512 *  Copies the P_Key table into the Physical Port object.
513 *
514 * SYNOPSIS
515 */
516 void osm_physp_set_pkey_tbl(IN osm_log_t * p_log, IN const osm_subn_t * p_subn,
517 			    IN osm_physp_t * p_physp,
518 			    IN ib_pkey_table_t * p_pkey_tbl,
519 			    IN uint16_t block_num,
520 			    IN boolean_t is_set);
521 /*
522 * PARAMETERS
523 *	p_log
524 *		[in] Pointer to a log object.
525 *
526 *	p_subn
527 *		[in] Pointer to the subnet data structure.
528 *
529 *	p_physp
530 *		[in] Pointer to an osm_physp_t object.
531 *
532 *	p_pkey_tbl
533 *		[in] Pointer to the IBA defined P_Key table for this port
534 *		     number.
535 *
536 *	block_num
537 *		[in] The part of the P_Key table as defined in the IBA
538 *		     (valid values 0-2047, and is further limited by the
539 *		     partitionCap).
540 *
541 * RETURN VALUES
542 *  This function does not return a value.
543 *
544 * NOTES
545 *
546 * SEE ALSO
547 *  Port, Physical Port
548 *********/
549 
550 /****f* OpenSM: Physical Port/osm_physp_get_pkey_tbl
551 * NAME
552 *  osm_physp_get_pkey_tbl
553 *
554 * DESCRIPTION
555 *  Returns a pointer to the P_Key table object of the Physical Port object.
556 *
557 * SYNOPSIS
558 */
osm_physp_get_pkey_tbl(IN const osm_physp_t * p_physp)559 static inline const osm_pkey_tbl_t *osm_physp_get_pkey_tbl(IN const osm_physp_t
560 							   * p_physp)
561 {
562 	CL_ASSERT(osm_physp_is_valid(p_physp));
563 	/*
564 	   (14.2.5.7) - the block number valid values are 0-2047, and are
565 	   further limited by the size of the P_Key table specified by the
566 	   PartitionCap on the node.
567 	 */
568 	return &p_physp->pkeys;
569 };
570 
571 /*
572 * PARAMETERS
573 *	p_physp
574 *		[in] Pointer to an osm_physp_t object.
575 *
576 * RETURN VALUES
577 *  The pointer to the P_Key table object.
578 *
579 * NOTES
580 *
581 * SEE ALSO
582 *  Port, Physical Port
583 *********/
584 
585 /****f* OpenSM: Physical Port/osm_physp_set_slvl_tbl
586 * NAME
587 *	osm_physp_set_slvl_tbl
588 *
589 * DESCRIPTION
590 *	Copies the SLtoVL attribute into the Physical Port object.
591 *
592 * SYNOPSIS
593 */
osm_physp_set_slvl_tbl(IN osm_physp_t * p_physp,IN ib_slvl_table_t * p_slvl_tbl,IN uint8_t in_port_num)594 static inline void osm_physp_set_slvl_tbl(IN osm_physp_t * p_physp,
595 					  IN ib_slvl_table_t * p_slvl_tbl,
596 					  IN uint8_t in_port_num)
597 {
598 	ib_slvl_table_t *p_tbl;
599 
600 	CL_ASSERT(p_slvl_tbl);
601 	CL_ASSERT(osm_physp_is_valid(p_physp));
602 	p_tbl = (ib_slvl_table_t *)cl_ptr_vector_get(&p_physp->slvl_by_port, in_port_num);
603 	*p_tbl = *p_slvl_tbl;
604 }
605 
606 /*
607 * PARAMETERS
608 *	p_physp
609 *		[in] Pointer to an osm_physp_t object.
610 *
611 *	p_slvl_tbl
612 *		[in] Pointer to the IBA defined SLtoVL map table for this
613 *		     port number.
614 *
615 *	in_port_num
616 *		[in] Input Port Number for this SLtoVL.
617 *
618 * RETURN VALUES
619 *	This function does not return a value.
620 *
621 * NOTES
622 *
623 * SEE ALSO
624 *	Port, Physical Port
625 *********/
626 
627 /****f* OpenSM: Physical Port/osm_physp_get_slvl_tbl
628 * NAME
629 *	osm_physp_get_slvl_tbl
630 *
631 * DESCRIPTION
632 *	Returns a pointer to the SLtoVL attribute of the Physical Port object.
633 *
634 * SYNOPSIS
635 */
osm_physp_get_slvl_tbl(IN const osm_physp_t * p_physp,IN uint8_t in_port_num)636 static inline ib_slvl_table_t *osm_physp_get_slvl_tbl(IN const osm_physp_t *
637 						      p_physp,
638 						      IN uint8_t in_port_num)
639 {
640 	ib_slvl_table_t *p_tbl;
641 
642 	CL_ASSERT(osm_physp_is_valid(p_physp));
643 	p_tbl = (ib_slvl_table_t *)cl_ptr_vector_get(&p_physp->slvl_by_port, in_port_num);
644 	return p_tbl;
645 }
646 
647 /*
648 * PARAMETERS
649 *	p_physp
650 *		[in] Pointer to an osm_physp_t object.
651 *
652 *	in_port_num
653 *		[in] Input Port Number for this SLtoVL.
654 *
655 * RETURN VALUES
656 *	The pointer to the slvl table
657 *
658 * NOTES
659 *
660 * SEE ALSO
661 *	Port, Physical Port
662 *********/
663 
664 /****f* OpenSM: Physical Port/osm_physp_set_vla_tbl
665 * NAME
666 *	osm_physp_set_vla_tbl
667 *
668 * DESCRIPTION
669 *	Copies the VL Arbitration attribute into the Physical Port object.
670 *
671 * SYNOPSIS
672 */
osm_physp_set_vla_tbl(IN osm_physp_t * p_physp,IN ib_vl_arb_table_t * p_vla_tbl,IN uint8_t block_num)673 static inline void osm_physp_set_vla_tbl(IN osm_physp_t * p_physp,
674 					 IN ib_vl_arb_table_t * p_vla_tbl,
675 					 IN uint8_t block_num)
676 {
677 	CL_ASSERT(p_vla_tbl);
678 	CL_ASSERT(osm_physp_is_valid(p_physp));
679 	CL_ASSERT((1 <= block_num) && (block_num <= 4));
680 	p_physp->vl_arb[block_num - 1] = *p_vla_tbl;
681 }
682 
683 /*
684 * PARAMETERS
685 *	p_physp
686 *		[in] Pointer to an osm_physp_t object.
687 *
688 *	p_vla_tbl
689 *		[in] Pointer to the IBA defined VL Arbitration table for this
690 *		     port number.
691 *
692 *	block_num
693 *		[in] The part of the VL arbitration as defined in the IBA
694 *		     (valid values 1-4)
695 *
696 * RETURN VALUES
697 *	This function does not return a value.
698 *
699 * NOTES
700 *
701 * SEE ALSO
702 *	Port, Physical Port
703 *********/
704 
705 /****f* OpenSM: Physical Port/osm_physp_get_vla_tbl
706 * NAME
707 *	osm_physp_get_vla_tbl
708 *
709 * DESCRIPTION
710 *	Returns a pointer to the VL Arbitration table of the Physical Port object.
711 *
712 * SYNOPSIS
713 */
osm_physp_get_vla_tbl(IN osm_physp_t * p_physp,IN uint8_t block_num)714 static inline ib_vl_arb_table_t *osm_physp_get_vla_tbl(IN osm_physp_t * p_physp,
715 						       IN uint8_t block_num)
716 {
717 	CL_ASSERT(osm_physp_is_valid(p_physp));
718 	CL_ASSERT((1 <= block_num) && (block_num <= 4));
719 	return &(p_physp->vl_arb[block_num - 1]);
720 }
721 
722 /*
723 * PARAMETERS
724 *	p_physp
725 *		[in] Pointer to an osm_physp_t object.
726 *
727 *	block_num
728 *		[in] The part of the VL arbitration as defined in the IBA
729 *		     (valid values 1-4)
730 *
731 * RETURN VALUES
732 *  The pointer to the VL Arbitration table
733 *
734 * NOTES
735 *
736 * SEE ALSO
737 *	Port, Physical Port
738 *********/
739 
740 /****f* OpenSM: Physical Port/osm_physp_get_remote
741 * NAME
742 *	osm_physp_get_remote
743 *
744 * DESCRIPTION
745 *	Returns a pointer to the Physical Port on the other side the wire.
746 *
747 * SYNOPSIS
748 */
osm_physp_get_remote(IN const osm_physp_t * p_physp)749 static inline osm_physp_t *osm_physp_get_remote(IN const osm_physp_t * p_physp)
750 {
751 	CL_ASSERT(osm_physp_is_valid(p_physp));
752 	return p_physp->p_remote_physp;
753 }
754 
755 /*
756 * PARAMETERS
757 *	p_physp
758 *		[in] Pointer to an osm_physp_t object.
759 *
760 * RETURN VALUES
761 *	Returns a pointer to the Physical Port on the other side of
762 *	the wire.  A return value of NULL means there is no link at this port.
763 *
764 * NOTES
765 *
766 * SEE ALSO
767 *	Port, Physical Port
768 *********/
769 
770 /****f* OpenSM: Physical Port/osm_physp_get_port_guid
771 * NAME
772 *	osm_physp_get_port_guid
773 *
774 * DESCRIPTION
775 *	Returns the port guid of this physical port.
776 *
777 * SYNOPSIS
778 */
osm_physp_get_port_guid(IN const osm_physp_t * p_physp)779 static inline ib_net64_t osm_physp_get_port_guid(IN const osm_physp_t * p_physp)
780 {
781 	CL_ASSERT(osm_physp_is_valid(p_physp));
782 	return p_physp->port_guid;
783 }
784 
785 /*
786 * PARAMETERS
787 *	p_physp
788 *		[in] Pointer to an osm_physp_t object.
789 *
790 * RETURN VALUES
791 *	Returns the port guid of this physical port.
792 *
793 * NOTES
794 *
795 * SEE ALSO
796 *	Port, Physical Port
797 *********/
798 
799 /****f* OpenSM: Physical Port/osm_physp_get_subnet_prefix
800 * NAME
801 *	osm_physp_get_subnet_prefix
802 *
803 * DESCRIPTION
804 *	Returns the subnet prefix for this physical port.
805 *
806 * SYNOPSIS
807 */
808 static inline ib_net64_t
osm_physp_get_subnet_prefix(IN const osm_physp_t * p_physp)809 osm_physp_get_subnet_prefix(IN const osm_physp_t * p_physp)
810 {
811 	CL_ASSERT(osm_physp_is_valid(p_physp));
812 	return p_physp->port_info.subnet_prefix;
813 }
814 
815 /*
816 * PARAMETERS
817 *	p_physp
818 *		[in] Pointer to an osm_physp_t object.
819 *
820 * RETURN VALUES
821 *	Returns the subnet prefix for this physical port.
822 *
823 * NOTES
824 *
825 * SEE ALSO
826 *	Port, Physical Port
827 *********/
828 
829 /****f* OpenSM: Physical Port/osm_physp_link_exists
830 * NAME
831 *	osm_physp_link_exists
832 *
833 * DESCRIPTION
834 *	Returns TRUE if the Physical Port has a link to the specified port.
835 *	FALSE otherwise.
836 *
837 * SYNOPSIS
838 */
osm_physp_link_exists(IN const osm_physp_t * p_physp,IN const osm_physp_t * p_remote_physp)839 static inline boolean_t osm_physp_link_exists(IN const osm_physp_t * p_physp,
840 					      IN const osm_physp_t * p_remote_physp)
841 {
842 	CL_ASSERT(p_physp);
843 	CL_ASSERT(osm_physp_is_valid(p_physp));
844 	CL_ASSERT(p_remote_physp);
845 	CL_ASSERT(osm_physp_is_valid(p_remote_physp));
846 	return ((p_physp->p_remote_physp == p_remote_physp) &&
847 		(p_remote_physp->p_remote_physp == p_physp));
848 }
849 
850 /*
851 * PARAMETERS
852 *	p_physp
853 *		[in] Pointer to an osm_physp_t object.
854 *
855 *	p_remote_physp
856 *		[in] Pointer to an osm_physp_t object.
857 *
858 * RETURN VALUES
859 *	Returns TRUE if the Physical Port has a link to another port.
860 *	FALSE otherwise.
861 *
862 * NOTES
863 *
864 * SEE ALSO
865 *	Port, Physical Port
866 *********/
867 
868 /****f* OpenSM: Physical Port/osm_physp_link
869 * NAME
870 *	osm_physp_link
871 *
872 * DESCRIPTION
873 *	Sets the pointers to the Physical Ports on the other side the wire.
874 *
875 * SYNOPSIS
876 */
osm_physp_link(IN osm_physp_t * p_physp,IN osm_physp_t * p_remote_physp)877 static inline void osm_physp_link(IN osm_physp_t * p_physp,
878 				  IN osm_physp_t * p_remote_physp)
879 {
880 	CL_ASSERT(p_physp);
881 	CL_ASSERT(p_remote_physp);
882 	p_physp->p_remote_physp = p_remote_physp;
883 	p_remote_physp->p_remote_physp = p_physp;
884 }
885 
886 /*
887 * PARAMETERS
888 *	p_physp
889 *		[in] Pointer to an osm_physp_t object to link.
890 *
891 *	p_remote_physp
892 *		[in] Pointer to the adjacent osm_physp_t object to link.
893 *
894 * RETURN VALUES
895 *	None.
896 *
897 * NOTES
898 *
899 * SEE ALSO
900 *	Port, Physical Port
901 *********/
902 
903 /****f* OpenSM: Physical Port/osm_physp_unlink
904 * NAME
905 *	osm_physp_unlink
906 *
907 * DESCRIPTION
908 *	Clears the pointers to the Physical Port on the other side the wire.
909 *
910 * SYNOPSIS
911 */
osm_physp_unlink(IN osm_physp_t * p_physp,IN osm_physp_t * p_remote_physp)912 static inline void osm_physp_unlink(IN osm_physp_t * p_physp,
913 				    IN osm_physp_t * p_remote_physp)
914 {
915 	CL_ASSERT(p_physp);
916 	CL_ASSERT(p_remote_physp);
917 	CL_ASSERT(osm_physp_link_exists(p_physp, p_remote_physp));
918 	p_physp->p_remote_physp = NULL;
919 	p_remote_physp->p_remote_physp = NULL;
920 }
921 
922 /*
923 * PARAMETERS
924 *	p_physp
925 *		[in] Pointer to an osm_physp_t object to link.
926 *
927 *	p_remote_physp
928 *		[in] Pointer to the adjacent osm_physp_t object to link.
929 *
930 * RETURN VALUES
931 *	None.
932 *
933 * NOTES
934 *
935 * SEE ALSO
936 *	Port, Physical Port
937 *********/
938 
939 /****f* OpenSM: Physical Port/osm_physp_has_any_link
940 * NAME
941 *	osm_physp_has_any_link
942 *
943 * DESCRIPTION
944 *	Returns TRUE if the Physical Port has a link to another port.
945 *	FALSE otherwise.
946 *
947 * SYNOPSIS
948 */
osm_physp_has_any_link(IN const osm_physp_t * p_physp)949 static inline boolean_t osm_physp_has_any_link(IN const osm_physp_t * p_physp)
950 {
951 	CL_ASSERT(p_physp);
952 	if (osm_physp_is_valid(p_physp))
953 		return (p_physp->p_remote_physp != NULL);
954 	else
955 		return FALSE;
956 }
957 
958 /*
959 * PARAMETERS
960 *	p_physp
961 *		[in] Pointer to an osm_physp_t object.
962 *
963 * RETURN VALUES
964 *	Returns TRUE if the Physical Port has a link to another port.
965 *	FALSE otherwise.
966 *
967 * NOTES
968 *
969 * SEE ALSO
970 *	Port, Physical Port
971 *********/
972 
973 /****f* OpenSM: Physical Port/osm_physp_get_port_num
974 * NAME
975 *	osm_physp_get_port_num
976 *
977 * DESCRIPTION
978 *	Returns the local port number of this Physical Port.
979 *
980 * SYNOPSIS
981 */
osm_physp_get_port_num(IN const osm_physp_t * p_physp)982 static inline uint8_t osm_physp_get_port_num(IN const osm_physp_t * p_physp)
983 {
984 	CL_ASSERT(p_physp);
985 	CL_ASSERT(osm_physp_is_valid(p_physp));
986 	return p_physp->port_num;
987 }
988 
989 /*
990 * PARAMETERS
991 *	p_physp
992 *		[in] Pointer to an osm_physp_t object.
993 *
994 * RETURN VALUES
995 *	Returns the local port number of this Physical Port.
996 *
997 * NOTES
998 *
999 * SEE ALSO
1000 *********/
1001 
1002 /****f* OpenSM: Physical Port/osm_physp_get_node_ptr
1003 * NAME
1004 *	osm_physp_get_node_ptr
1005 *
1006 * DESCRIPTION
1007 *	Returns a pointer to the parent Node object for this port.
1008 *
1009 * SYNOPSIS
1010 */
osm_physp_get_node_ptr(IN const osm_physp_t * p_physp)1011 static inline struct osm_node *osm_physp_get_node_ptr(IN const osm_physp_t *
1012 						       p_physp)
1013 {
1014 	CL_ASSERT(p_physp);
1015 	CL_ASSERT(osm_physp_is_valid(p_physp));
1016 	return p_physp->p_node;
1017 }
1018 
1019 /*
1020 * PARAMETERS
1021 *	p_physp
1022 *		[in] Pointer to an osm_physp_t object.
1023 *
1024 * RETURN VALUES
1025 *	Returns a pointer to the parent Node object for this port.
1026 *
1027 * NOTES
1028 *
1029 * SEE ALSO
1030 *********/
1031 
1032 /****f* OpenSM: Physical Port/osm_physp_get_port_state
1033 * NAME
1034 *	osm_physp_get_port_state
1035 *
1036 * DESCRIPTION
1037 *	Returns the port state of this Physical Port.
1038 *
1039 * SYNOPSIS
1040 */
osm_physp_get_port_state(IN const osm_physp_t * p_physp)1041 static inline uint8_t osm_physp_get_port_state(IN const osm_physp_t * p_physp)
1042 {
1043 	CL_ASSERT(p_physp);
1044 	CL_ASSERT(osm_physp_is_valid(p_physp));
1045 	return ib_port_info_get_port_state(&p_physp->port_info);
1046 }
1047 
1048 /*
1049 * PARAMETERS
1050 *	p_physp
1051 *		[in] Pointer to an osm_physp_t object.
1052 *
1053 * RETURN VALUES
1054 *	Returns the local port number of this Physical Port.
1055 *
1056 * NOTES
1057 *
1058 * SEE ALSO
1059 *********/
1060 
1061 /****f* OpenSM: Physical Port/osm_physp_get_base_lid
1062 * NAME
1063 *	osm_physp_get_base_lid
1064 *
1065 * DESCRIPTION
1066 *	Returns the base lid of this Physical Port.
1067 *
1068 * SYNOPSIS
1069 */
osm_physp_get_base_lid(IN const osm_physp_t * p_physp)1070 static inline ib_net16_t osm_physp_get_base_lid(IN const osm_physp_t * p_physp)
1071 {
1072 	CL_ASSERT(p_physp);
1073 	CL_ASSERT(osm_physp_is_valid(p_physp));
1074 	return p_physp->port_info.base_lid;
1075 }
1076 
1077 /*
1078 * PARAMETERS
1079 *	p_physp
1080 *		[in] Pointer to an osm_physp_t object.
1081 *
1082 * RETURN VALUES
1083 *	Returns the base lid of this Physical Port.
1084 *
1085 * NOTES
1086 *
1087 * SEE ALSO
1088 *********/
1089 
1090 /****f* OpenSM: Physical Port/osm_physp_get_lmc
1091 * NAME
1092 *	osm_physp_get_lmc
1093 *
1094 * DESCRIPTION
1095 *	Returns the LMC value of this Physical Port.
1096 *
1097 * SYNOPSIS
1098 */
osm_physp_get_lmc(IN const osm_physp_t * p_physp)1099 static inline uint8_t osm_physp_get_lmc(IN const osm_physp_t * p_physp)
1100 {
1101 	CL_ASSERT(p_physp);
1102 	CL_ASSERT(osm_physp_is_valid(p_physp));
1103 	return ib_port_info_get_lmc(&p_physp->port_info);
1104 }
1105 
1106 /*
1107 * PARAMETERS
1108 *	p_physp
1109 *		[in] Pointer to an osm_physp_t object.
1110 *
1111 * RETURN VALUES
1112 *	Returns the LMC value of this Physical Port.
1113 *
1114 * NOTES
1115 *
1116 * SEE ALSO
1117 *********/
1118 
1119 /****f* OpenSM: Physical Port/osm_physp_get_dr_path_ptr
1120 * NAME
1121 *	osm_physp_get_dr_path_ptr
1122 *
1123 * DESCRIPTION
1124 *	Returns a pointer to the directed route path for this port.
1125 *
1126 * SYNOPSIS
1127 */
osm_physp_get_dr_path_ptr(IN const osm_physp_t * p_physp)1128 static inline osm_dr_path_t *osm_physp_get_dr_path_ptr(IN const osm_physp_t *
1129 							p_physp)
1130 {
1131 	CL_ASSERT(p_physp);
1132 	CL_ASSERT(osm_physp_is_valid(p_physp));
1133 	return (osm_dr_path_t *) & p_physp->dr_path;
1134 }
1135 
1136 /*
1137 * PARAMETERS
1138 *	p_physp
1139 *		[in] Pointer to a Physical Port object.
1140 *
1141 * RETURN VALUES
1142 *	Returns a pointer to the directed route path for this port.
1143 *
1144 * NOTES
1145 *
1146 * SEE ALSO
1147 *	Physical Port object
1148 *********/
1149 
1150 /****h* OpenSM/Port
1151 * NAME
1152 *	Port
1153 *
1154 * DESCRIPTION
1155 *	The Port object encapsulates the information needed by the
1156 *	OpenSM to manage ports.  The OpenSM allocates one Port object
1157 *	per port in the IBA subnet.
1158 *
1159 *	Each Port object is associated with a single port GUID.  A Port object
1160 *	contains 1 or more Physical Port objects.  An end point node has
1161 *	one Physical Port per Port.  A switch node has more than
1162 *	one Physical Port per Port.
1163 *
1164 *	The Port object is not thread safe, thus callers must provide
1165 *	serialization.
1166 *
1167 *	These objects should be treated as opaque and should be
1168 *	manipulated only through the provided functions.
1169 *
1170 * AUTHOR
1171 *	Steve King, Intel
1172 *
1173 *********/
1174 
1175 /****s* OpenSM: Port/osm_port_t
1176 * NAME
1177 *	osm_port_t
1178 *
1179 * DESCRIPTION
1180 *	This object represents a logical port on a switch, router, or CA.
1181 *
1182 *	The osm_port_t object should be treated as opaque and should
1183 *	be manipulated only through the provided functions.
1184 *
1185 * SYNOPSIS
1186 */
1187 typedef struct osm_port {
1188 	cl_map_item_t map_item;
1189 	cl_list_item_t list_item;
1190 	struct osm_node *p_node;
1191 	ib_net64_t guid;
1192 	uint32_t discovery_count;
1193 	unsigned is_new;
1194 	osm_physp_t *p_physp;
1195 	cl_qlist_t mcm_list;
1196 	int flag;
1197 	int use_scatter;
1198 	unsigned int cc_timeout_count;
1199 	int cc_unavailable_flag;
1200 	void *priv;
1201 	ib_net16_t lid;
1202 } osm_port_t;
1203 /*
1204 * FIELDS
1205 *	map_item
1206 *		Linkage structure for cl_qmap.  MUST BE FIRST MEMBER!
1207 *
1208 *	list_item
1209 *		Linkage structure for cl_qlist. Used by ucast mgr during
1210 *		LFT calculation.
1211 *
1212 *	p_node
1213 *		Points to the Node object that owns this port.
1214 *
1215 *	guid
1216 *		Manufacturer assigned GUID for this port.
1217 *
1218 *	discovery_count
1219 *		The number of times this port has been discovered
1220 *		during the current fabric sweep.  This number is reset
1221 *		to zero at the start of a sweep.
1222 *
1223 *	p_physp
1224 *		The pointer to physical port used when physical
1225 *		characteristics contained in the Physical Port are needed.
1226 *
1227 *	mcm_list
1228 *		Multicast member list
1229 *
1230 *	flag
1231 *		Utility flag for port management
1232 *
1233 *	cc_timeout_count
1234 *		Count number of times congestion control config times out.
1235 *
1236 *	cc_unavailable_flag
1237 *		Flag indicating if congestion control is not supported.
1238 *
1239 * SEE ALSO
1240 *	Port, Physical Port, Physical Port Table
1241 *********/
1242 
1243 /****f* OpenSM: Port/osm_port_delete
1244 * NAME
1245 *	osm_port_delete
1246 *
1247 * DESCRIPTION
1248 *	This function destroys and deallocates a Port object.
1249 *
1250 * SYNOPSIS
1251 */
1252 void osm_port_delete(IN OUT osm_port_t ** pp_port);
1253 /*
1254 * PARAMETERS
1255 *	pp_port
1256 *		[in][out] Pointer to a pointer to a Port object to delete.
1257 *		On return, this pointer is NULL.
1258 *
1259 * RETURN VALUE
1260 *	This function does not return a value.
1261 *
1262 * NOTES
1263 *	Performs any necessary cleanup of the specified Port object.
1264 *
1265 * SEE ALSO
1266 *	Port
1267 *********/
1268 
1269 /****f* OpenSM: Port/osm_port_new
1270 * NAME
1271 *	osm_port_new
1272 *
1273 * DESCRIPTION
1274 *	This function allocates and initializes a Port object.
1275 *
1276 * SYNOPSIS
1277 */
1278 osm_port_t *osm_port_new(IN const ib_node_info_t * p_ni,
1279 			 IN struct osm_node *p_parent_node);
1280 /*
1281 * PARAMETERS
1282 *	p_ni
1283 *		[in] Pointer to the NodeInfo attribute relevant for this port.
1284 *
1285 *	p_parent_node
1286 *		[in] Pointer to the initialized parent osm_node_t object
1287 *		that owns this port.
1288 *
1289 * RETURN VALUE
1290 *	Pointer to the initialize Port object.
1291 *
1292 * NOTES
1293 *	Allows calling other port methods.
1294 *
1295 * SEE ALSO
1296 *	Port
1297 *********/
1298 
1299 /****f* OpenSM: Port/osm_port_get_base_lid
1300 * NAME
1301 *	osm_port_get_base_lid
1302 *
1303 * DESCRIPTION
1304 *	Gets the base LID of a port.
1305 *
1306 * SYNOPSIS
1307 */
osm_port_get_base_lid(IN const osm_port_t * p_port)1308 static inline ib_net16_t osm_port_get_base_lid(IN const osm_port_t * p_port)
1309 {
1310 	CL_ASSERT(p_port->p_physp && osm_physp_is_valid(p_port->p_physp));
1311 	return osm_physp_get_base_lid(p_port->p_physp);
1312 }
1313 
1314 /*
1315 * PARAMETERS
1316 *	p_port
1317 *		[in] Pointer to a Port object.
1318 *
1319 * RETURN VALUE
1320 *	Base LID of the port.
1321 *	If the return value is 0, then this port has no assigned LID.
1322 *
1323 * NOTES
1324 *
1325 * SEE ALSO
1326 *	Port
1327 *********/
1328 
1329 /****f* OpenSM: Port/osm_port_get_lmc
1330 * NAME
1331 *	osm_port_get_lmc
1332 *
1333 * DESCRIPTION
1334 *	Gets the LMC value of a port.
1335 *
1336 * SYNOPSIS
1337 */
osm_port_get_lmc(IN const osm_port_t * p_port)1338 static inline uint8_t osm_port_get_lmc(IN const osm_port_t * p_port)
1339 {
1340 	CL_ASSERT(p_port->p_physp && osm_physp_is_valid(p_port->p_physp));
1341 	return osm_physp_get_lmc(p_port->p_physp);
1342 }
1343 
1344 /*
1345 * PARAMETERS
1346 *	p_port
1347 *		[in] Pointer to a Port object.
1348 *
1349 * RETURN VALUE
1350 *	Gets the LMC value of a port.
1351 *
1352 * NOTES
1353 *
1354 * SEE ALSO
1355 *	Port
1356 *********/
1357 
1358 /****f* OpenSM: Port/osm_port_get_guid
1359 * NAME
1360 *	osm_port_get_guid
1361 *
1362 * DESCRIPTION
1363 *	Gets the GUID of a port.
1364 *
1365 * SYNOPSIS
1366 */
osm_port_get_guid(IN const osm_port_t * p_port)1367 static inline ib_net64_t osm_port_get_guid(IN const osm_port_t * p_port)
1368 {
1369 	return p_port->guid;
1370 }
1371 
1372 /*
1373 * PARAMETERS
1374 *	p_port
1375 *		[in] Pointer to a Port object.
1376 *
1377 * RETURN VALUE
1378 *	Manufacturer assigned GUID of the port.
1379 *
1380 * NOTES
1381 *
1382 * SEE ALSO
1383 *	Port
1384 *********/
1385 
1386 /****f* OpenSM: Port/osm_port_get_lid_range_ho
1387 * NAME
1388 *	osm_port_get_lid_range_ho
1389 *
1390 * DESCRIPTION
1391 *	Returns the HOST ORDER lid min and max values for this port,
1392 *	based on the lmc value.
1393 *
1394 * SYNOPSIS
1395 */
1396 void osm_port_get_lid_range_ho(IN const osm_port_t * p_port,
1397 			       OUT uint16_t * p_min_lid,
1398 			       OUT uint16_t * p_max_lid);
1399 /*
1400 * PARAMETERS
1401 *	p_port
1402 *		[in] Pointer to a Port object.
1403 *
1404 *	p_min_lid
1405 *		[out] Pointer to the minimum LID value occupied by this port.
1406 *
1407 *	p_max_lid
1408 *		[out] Pointer to the maximum LID value occupied by this port.
1409 *
1410 * RETURN VALUE
1411 *	None.
1412 *
1413 * NOTES
1414 *
1415 * SEE ALSO
1416 *	Port
1417 *********/
1418 
1419 /****f* OpenSM: Physical Port/osm_physp_calc_link_mtu
1420 * NAME
1421 *	osm_physp_calc_link_mtu
1422 *
1423 * DESCRIPTION
1424 *	Calculate the Port MTU based on current and remote
1425 *  physical ports MTU CAP values.
1426 *
1427 * SYNOPSIS
1428 */
1429 uint8_t osm_physp_calc_link_mtu(IN osm_log_t * p_log,
1430 				IN const osm_physp_t * p_physp,
1431 				IN uint8_t current_mtu);
1432 /*
1433 * PARAMETERS
1434 *	p_log
1435 *		[in] Pointer to a log object.
1436 *
1437 *	p_physp
1438 *		[in] Pointer to an osm_physp_t object.
1439 *
1440 *	current_mtu
1441 *		[in] Current neighbor mtu on this port
1442 *
1443 * RETURN VALUES
1444 *	The MTU of the link to be used.
1445 *
1446 * NOTES
1447 *
1448 * SEE ALSO
1449 *	PhysPort object
1450 *********/
1451 
1452 /****f* OpenSM: Physical Port/osm_physp_calc_link_op_vls
1453 * NAME
1454 *	osm_physp_calc_link_op_vls
1455 *
1456 * DESCRIPTION
1457 *	Calculate the Port OP_VLS based on current and remote
1458 *  physical ports VL CAP values. Allowing user option for a max limit.
1459 *
1460 * SYNOPSIS
1461 */
1462 uint8_t osm_physp_calc_link_op_vls(IN osm_log_t * p_log,
1463 				   IN const osm_subn_t * p_subn,
1464 				   IN const osm_physp_t * p_physp,
1465 				   IN uint8_t current_op_vls);
1466 /*
1467 * PARAMETERS
1468 *	p_log
1469 *		[in] Pointer to a log object.
1470 *
1471 *	p_subn
1472 *		[in] Pointer to the subnet object for accessing of the options.
1473 *
1474 *	p_physp
1475 *		[in] Pointer to an osm_physp_t object.
1476 *
1477 *	current_op_vls
1478 *		[in] Current operational VL on the port
1479 *
1480 * RETURN VALUES
1481 *	The OP_VLS of the link to be used.
1482 *
1483 * NOTES
1484 *
1485 * SEE ALSO
1486 *  PhysPort object
1487 *********/
1488 
1489 /****f* OpenSM: Physical Port/osm_physp_replace_dr_path_with_alternate_dr_path
1490 * NAME
1491 *	osm_physp_replace_dr_path_with_alternate_dr_path
1492 *
1493 * DESCRIPTION
1494 *	Replace the direct route path for the given phys port with an
1495 *  alternate path going through forien set of phys port.
1496 *
1497 * SYNOPSIS
1498 */
1499 void
1500 osm_physp_replace_dr_path_with_alternate_dr_path(IN osm_log_t * p_log,
1501 						 IN osm_subn_t const *p_subn,
1502 						 IN osm_physp_t const *p_physp,
1503 						 IN osm_bind_handle_t * h_bind);
1504 /*
1505 * PARAMETERS
1506 *	p_log
1507 *		[in] Pointer to a log object.
1508 *
1509 *	p_subn
1510 *		[in] Pointer to the subnet object for accessing of the options.
1511 *
1512 *	p_physp
1513 *		[in] Pointer to an osm_physp_t object.
1514 *
1515 *	h_bind
1516 *		[in] Pointer to osm_bind_handle_t object.
1517 *
1518 * RETURN VALUES
1519 *	NONE
1520 *
1521 * NOTES
1522 *
1523 * SEE ALSO
1524 *	PhysPort object
1525 *********/
1526 
1527 /****s* OpenSM: Port/osm_alias_guid_t
1528 * NAME
1529 *	osm_alias_guid_t
1530 *
1531 * DESCRIPTION
1532 *	This object represents an alias guid for an endport.
1533 *
1534 *	The osm_alias_guid_t object should be treated as opaque and should
1535 *	be manipulated only through the provided functions.
1536 *
1537 * SYNOPSIS
1538 */
1539 typedef struct osm_alias_guid {
1540 	cl_map_item_t map_item;
1541 	ib_net64_t alias_guid;
1542 	osm_port_t *p_base_port;
1543 } osm_alias_guid_t;
1544 /*
1545 * FIELDS
1546 *	map_item
1547 *		Linkage structure for cl_qmap.  MUST BE FIRST MEMBER!
1548 *
1549 *	alias_guid
1550 *		Alias GUID for port obtained from SM GUIDInfo attribute
1551 *
1552 *	p_base_port
1553 *		Pointer to osm_port_t for base port GUID
1554 *
1555 * SEE ALSO
1556 *	Port, Physical Port, Physical Port Table
1557 */
1558 
1559 /****f* OpenSM: Port/osm_alias_guid_new
1560 * NAME
1561 *	osm_alias_guid_new
1562 *
1563 * DESCRIPTION
1564 *	This function allocates and initializes an alias guid object.
1565 *
1566 * SYNOPSIS
1567 */
1568 osm_alias_guid_t *osm_alias_guid_new(IN const ib_net64_t alias_guid,
1569 				     IN osm_port_t *p_base_port);
1570 /*
1571 * PARAMETERS
1572 *	alias_guid
1573 *		[in] Alias GUID in network order
1574 *
1575 *	p_base_port
1576 *		[in] Pointer to the port for this base GUID
1577 *
1578 * RETURN VALUE
1579 *	Pointer to the initialized alias guid object.
1580 *
1581 * NOTES
1582 *	Allows calling other alias guid methods.
1583 *
1584 * SEE ALSO
1585 *	Port
1586 *********/
1587 
1588 /****f* OpenSM: Port/osm_alias_guid_delete
1589 * NAME
1590 *	osm_alias_guid_delete
1591 *
1592 * DESCRIPTION
1593 *	This function destroys and deallocates an alias guid object.
1594 *
1595 * SYNOPSIS
1596 */
1597 void osm_alias_guid_delete(IN OUT osm_alias_guid_t ** pp_alias_guid);
1598 /*
1599 * PARAMETERS
1600 *	pp_alias_guid
1601 *		[in][out] Pointer to a pointer to an alias guid object to delete.
1602 *		On return, this pointer is NULL.
1603 *
1604 * RETURN VALUE
1605 *	This function does not return a value.
1606 *
1607 * NOTES
1608 *	Performs any necessary cleanup of the specified alias guid object.
1609 *
1610 * SEE ALSO
1611 *	Port
1612 *********/
1613 
1614 /****f* OpenSM: Port/osm_alias_guid_get_alias_guid
1615 * NAME
1616 *	osm_alias_guid_get_alias_guid
1617 *
1618 * DESCRIPTION
1619 *	This function retrieves alias guid from alias guid object.
1620 *
1621 * SYNOPSIS
1622 */
osm_alias_guid_get_alias_guid(IN osm_alias_guid_t * p_alias_guid)1623 static inline ib_net64_t osm_alias_guid_get_alias_guid(IN osm_alias_guid_t *p_alias_guid)
1624 {
1625 	CL_ASSERT(p_alias_guid);
1626 	return p_alias_guid->alias_guid;
1627 }
1628 /*
1629 * PARAMETERS
1630 *	p_alias_guid
1631 *		[in] Pointer to a pointer to an alias guid object.
1632 *
1633 * RETURN VALUE
1634 *	This function returns the alias guid or NULL if fails.
1635 *
1636 * NOTES
1637 *
1638 * SEE ALSO
1639 *	Port
1640 *********/
1641 
1642 /****f* OpenSM: Port/osm_alias_guid_get_base_guid
1643 * NAME
1644 *	osm_alias_guid_get_base_guid
1645 *
1646 * DESCRIPTION
1647 *	This function retrieves base guid from alias guid object.
1648 *
1649 * SYNOPSIS
1650 */
osm_alias_guid_get_base_guid(IN osm_alias_guid_t * p_alias_guid)1651 static inline ib_net64_t osm_alias_guid_get_base_guid(IN osm_alias_guid_t *p_alias_guid)
1652 {
1653 	CL_ASSERT(p_alias_guid);
1654 	return osm_port_get_guid(p_alias_guid->p_base_port);
1655 }
1656 /*
1657 * PARAMETERS
1658 *	p_alias_guid
1659 *		[in] Pointer to a pointer to an alias guid object.
1660 *
1661 * RETURN VALUE
1662 *	This function returns the base guid or NULL if fails.
1663 *
1664 * NOTES
1665 *
1666 * SEE ALSO
1667 *	Port
1668 *********/
1669 
1670 /****f* OpenSM: Port/osm_port_clear_base_lid
1671 * NAME
1672 *	osm_port_clear_base_lid
1673 *
1674 * DESCRIPTION
1675 *	Clear the base lid of a given port.
1676 *
1677 * SYNOPSIS
1678 */
osm_port_clear_base_lid(OUT osm_port_t * p_port)1679 static inline void osm_port_clear_base_lid(OUT osm_port_t * p_port)
1680 {
1681 	CL_ASSERT(p_port);
1682 	p_port->lid = 0;
1683 	osm_physp_set_base_lid(p_port->p_physp, 0);
1684 }
1685 
1686 /*
1687 * PARAMETERS
1688 *	p_port
1689 *		[out] Pointer to a Port object.
1690 *
1691 * RETURN VALUE
1692 *	None
1693 *
1694 * NOTES
1695 *
1696 * SEE ALSO
1697 *	Port
1698 *********/
1699 
1700 END_C_DECLS
1701 #endif				/* _OSM_PORT_H_ */
1702