1219820Sjeff/*
2219820Sjeff * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
3219820Sjeff * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
4219820Sjeff * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
5219820Sjeff *
6219820Sjeff * This software is available to you under a choice of one of two
7219820Sjeff * licenses.  You may choose to be licensed under the terms of the GNU
8219820Sjeff * General Public License (GPL) Version 2, available from the file
9219820Sjeff * COPYING in the main directory of this source tree, or the
10219820Sjeff * OpenIB.org BSD license below:
11219820Sjeff *
12219820Sjeff *     Redistribution and use in source and binary forms, with or
13219820Sjeff *     without modification, are permitted provided that the following
14219820Sjeff *     conditions are met:
15219820Sjeff *
16219820Sjeff *      - Redistributions of source code must retain the above
17219820Sjeff *        copyright notice, this list of conditions and the following
18219820Sjeff *        disclaimer.
19219820Sjeff *
20219820Sjeff *      - Redistributions in binary form must reproduce the above
21219820Sjeff *        copyright notice, this list of conditions and the following
22219820Sjeff *        disclaimer in the documentation and/or other materials
23219820Sjeff *        provided with the distribution.
24219820Sjeff *
25219820Sjeff * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26219820Sjeff * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27219820Sjeff * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28219820Sjeff * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29219820Sjeff * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30219820Sjeff * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31219820Sjeff * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32219820Sjeff * SOFTWARE.
33219820Sjeff *
34219820Sjeff */
35219820Sjeff
36219820Sjeff/*
37219820Sjeff * Abstract:
38219820Sjeff * 	Declaration of port related objects.
39219820Sjeff *	These objects comprise an IBA port.
40219820Sjeff *	These objects are part of the OpenSM family of objects.
41219820Sjeff */
42219820Sjeff
43219820Sjeff#ifndef _OSM_PORT_H_
44219820Sjeff#define _OSM_PORT_H_
45219820Sjeff
46219820Sjeff#include <complib/cl_qmap.h>
47219820Sjeff#include <iba/ib_types.h>
48219820Sjeff#include <opensm/osm_base.h>
49219820Sjeff#include <opensm/osm_subnet.h>
50219820Sjeff#include <opensm/osm_madw.h>
51219820Sjeff#include <opensm/osm_path.h>
52219820Sjeff#include <opensm/osm_pkey.h>
53219820Sjeff
54219820Sjeff#ifdef __cplusplus
55219820Sjeff#  define BEGIN_C_DECLS extern "C" {
56219820Sjeff#  define END_C_DECLS   }
57219820Sjeff#else				/* !__cplusplus */
58219820Sjeff#  define BEGIN_C_DECLS
59219820Sjeff#  define END_C_DECLS
60219820Sjeff#endif				/* __cplusplus */
61219820Sjeff
62219820SjeffBEGIN_C_DECLS
63219820Sjeff/*
64219820Sjeff	Forward references.
65219820Sjeff*/
66219820Sjeffstruct osm_port;
67219820Sjeffstruct osm_node;
68219820Sjeff
69219820Sjeff/****h* OpenSM/Physical Port
70219820Sjeff* NAME
71219820Sjeff*	Physical Port
72219820Sjeff*
73219820Sjeff* DESCRIPTION
74219820Sjeff*	The Physical Port object encapsulates the information needed by the
75219820Sjeff*	OpenSM to manage physical ports.  The OpenSM allocates one Physical Port
76219820Sjeff*	per physical port in the IBA subnet.
77219820Sjeff*
78219820Sjeff*	In a switch, one multiple Physical Port objects share the same port GUID.
79219820Sjeff*	In an end-point, Physical Ports do not share GUID values.
80219820Sjeff*
81219820Sjeff*	The Physical Port is not thread safe, thus callers must provide
82219820Sjeff*	serialization.
83219820Sjeff*
84219820Sjeff*	These objects should be treated as opaque and should be
85219820Sjeff*	manipulated only through the provided functions.
86219820Sjeff*
87219820Sjeff* AUTHOR
88219820Sjeff*	Steve King, Intel
89219820Sjeff*
90219820Sjeff*********/
91219820Sjeff
92219820Sjeff/****s* OpenSM: Physical Port/osm_physp_t
93219820Sjeff* NAME
94219820Sjeff*	osm_physp_t
95219820Sjeff*
96219820Sjeff* DESCRIPTION
97219820Sjeff*	This object represents a physical port on a switch, router or end-point.
98219820Sjeff*
99219820Sjeff*	The osm_physp_t object should be treated as opaque and should
100219820Sjeff*	be manipulated only through the provided functions.
101219820Sjeff*
102219820Sjeff* SYNOPSIS
103219820Sjeff*/
104219820Sjefftypedef struct osm_physp {
105219820Sjeff	ib_port_info_t port_info;
106219820Sjeff	ib_net64_t port_guid;
107219820Sjeff	uint8_t port_num;
108219820Sjeff	struct osm_node *p_node;
109219820Sjeff	struct osm_physp *p_remote_physp;
110219820Sjeff	boolean_t healthy;
111219820Sjeff	uint8_t vl_high_limit;
112219820Sjeff	unsigned need_update;
113219820Sjeff	unsigned is_prof_ignored;
114219820Sjeff	osm_dr_path_t dr_path;
115219820Sjeff	osm_pkey_tbl_t pkeys;
116219820Sjeff	ib_vl_arb_table_t vl_arb[4];
117219820Sjeff	cl_ptr_vector_t slvl_by_port;
118219820Sjeff} osm_physp_t;
119219820Sjeff/*
120219820Sjeff* FIELDS
121219820Sjeff*	port_info
122219820Sjeff*		The IBA defined PortInfo data for this port.
123219820Sjeff*
124219820Sjeff*	port_guid
125219820Sjeff*		Port GUID value of this port.  For switches,
126219820Sjeff*		all ports share the same GUID value.
127219820Sjeff*
128219820Sjeff*	port_num
129219820Sjeff*		The port number of this port.  The PortInfo also
130219820Sjeff*		contains a port_number, but that number is not
131219820Sjeff*		the port number of this port, but rather the number
132219820Sjeff*		of the port that received the SMP during discovery.
133219820Sjeff*		Therefore, we must keep a separate record for this
134219820Sjeff*		port's port number.
135219820Sjeff*
136219820Sjeff*	p_node
137219820Sjeff*		Pointer to the parent Node object of this Physical Port.
138219820Sjeff*
139219820Sjeff*	p_remote_physp
140219820Sjeff*		Pointer to the Physical Port on the other side of the wire.
141219820Sjeff*		If this pointer is NULL no link exists at this port.
142219820Sjeff*
143219820Sjeff*	healthy
144219820Sjeff*		Tracks the health of the port. Normally should be TRUE but
145219820Sjeff*		might change as a result of incoming traps indicating the port
146219820Sjeff*		healthy is questionable.
147219820Sjeff*
148219820Sjeff*	vl_high_limit
149219820Sjeff*		PortInfo:VLHighLimit value which installed by QoS manager
150219820Sjeff*		and should be uploaded to port's PortInfo
151219820Sjeff*
152219820Sjeff*	need_update
153219820Sjeff*		When set indicates that port was probably reset and port
154219820Sjeff*		related tables (PKey, SL2VL, VLArb) require refreshing.
155219820Sjeff*
156219820Sjeff*	is_prof_ignored
157219820Sjeff*		When set indicates that switch port will be ignored by
158219820Sjeff*		the link load equalization algorithm.
159219820Sjeff*
160219820Sjeff*	dr_path
161219820Sjeff*		The directed route path to this port.
162219820Sjeff*
163219820Sjeff*	pkeys
164219820Sjeff*		osm_pkey_tbl_t object holding the port PKeys.
165219820Sjeff*
166219820Sjeff*	vl_arb[]
167219820Sjeff*		Each Physical Port has 4 sections of VL Arbitration table.
168219820Sjeff*
169219820Sjeff*	slvl_by_port
170219820Sjeff*		A vector of pointers to the sl2vl tables (ordered by input port).
171219820Sjeff*		Switches have an entry for every other input port (inc SMA=0).
172219820Sjeff*		On CAs only one per port.
173219820Sjeff*
174219820Sjeff* SEE ALSO
175219820Sjeff*	Port
176219820Sjeff*********/
177219820Sjeff
178219820Sjeff/****f* OpenSM: Physical Port/osm_physp_construct
179219820Sjeff* NAME
180219820Sjeff*	osm_physp_construct
181219820Sjeff*
182219820Sjeff* DESCRIPTION
183219820Sjeff*	Constructs a Physical Port.
184219820Sjeff*
185219820Sjeff* SYNOPSIS
186219820Sjeff*/
187219820Sjeffvoid osm_physp_construct(IN osm_physp_t * const p_physp);
188219820Sjeff/*
189219820Sjeff* PARAMETERS
190219820Sjeff*	p_physp
191219820Sjeff*		[in] Pointer to an osm_physp_t object to initialize.
192219820Sjeff*
193219820Sjeff* RETURN VALUES
194219820Sjeff*	This function does not return a value.
195219820Sjeff*
196219820Sjeff* NOTES
197219820Sjeff*
198219820Sjeff* SEE ALSO
199219820Sjeff*	Port, Physical Port
200219820Sjeff*********/
201219820Sjeff
202219820Sjeff/****f* OpenSM: Physical Port/osm_physp_init
203219820Sjeff* NAME
204219820Sjeff*	osm_physp_init
205219820Sjeff*
206219820Sjeff* DESCRIPTION
207219820Sjeff*	Initializes a Physical Port for use.
208219820Sjeff*
209219820Sjeff* SYNOPSIS
210219820Sjeff*/
211219820Sjeffvoid
212219820Sjeffosm_physp_init(IN osm_physp_t * const p_physp,
213219820Sjeff	       IN const ib_net64_t port_guid,
214219820Sjeff	       IN const uint8_t port_num,
215219820Sjeff	       IN const struct osm_node *const p_node,
216219820Sjeff	       IN const osm_bind_handle_t h_bind,
217219820Sjeff	       IN const uint8_t hop_count,
218219820Sjeff	       IN const uint8_t * const p_initial_path);
219219820Sjeff/*
220219820Sjeff* PARAMETERS
221219820Sjeff*	p_physp
222219820Sjeff*		[in] Pointer to an osm_physp_t object to initialize.
223219820Sjeff*
224219820Sjeff*	port_guid
225219820Sjeff*		[in] GUID value of this port.  Switch ports all share
226219820Sjeff*		the same value.
227219820Sjeff*		Caller should use 0 if the guid is unknown.
228219820Sjeff*
229219820Sjeff*	port_num
230219820Sjeff*		[in] The port number of this port.
231219820Sjeff*
232219820Sjeff*	p_node
233219820Sjeff*		[in] Pointer to the parent Node object of this Physical Port.
234219820Sjeff*
235219820Sjeff*	h_bind
236219820Sjeff*		[in] Bind handle on which this port is accessed.
237219820Sjeff*		Caller should use OSM_INVALID_BIND_HANDLE if the bind
238219820Sjeff*		handle to this port is unknown.
239219820Sjeff*
240219820Sjeff*	hop_count
241219820Sjeff*		[in] Directed route hop count to reach this port.
242219820Sjeff*		Caller should use 0 if the hop count is unknown.
243219820Sjeff*
244219820Sjeff*	p_initial_path
245219820Sjeff*		[in] Pointer to the directed route path to reach this node.
246219820Sjeff*		Caller should use NULL if the path is unknown.
247219820Sjeff*
248219820Sjeff* RETURN VALUES
249219820Sjeff*	This function does not return a value.
250219820Sjeff*
251219820Sjeff* NOTES
252219820Sjeff*
253219820Sjeff* SEE ALSO
254219820Sjeff*	Port, Physical Port
255219820Sjeff*********/
256219820Sjeff
257219820Sjeff/****f* OpenSM: Port/void osm_physp_destroy
258219820Sjeff* NAME
259219820Sjeff*	osm_physp_destroy
260219820Sjeff*
261219820Sjeff* DESCRIPTION
262219820Sjeff*	This function destroys a Port object.
263219820Sjeff*
264219820Sjeff* SYNOPSIS
265219820Sjeff*/
266219820Sjeffvoid osm_physp_destroy(IN osm_physp_t * const p_physp);
267219820Sjeff/*
268219820Sjeff* PARAMETERS
269219820Sjeff*	p_port
270219820Sjeff*		[in] Pointer to a PhysPort object to destroy.
271219820Sjeff*
272219820Sjeff* RETURN VALUE
273219820Sjeff*	This function does not return a value.
274219820Sjeff*
275219820Sjeff* NOTES
276219820Sjeff*	Performs any necessary cleanup of the specified PhysPort object.
277219820Sjeff*	Further operations should not be attempted on the destroyed object.
278219820Sjeff*	This function should only be called after a call to osm_physp_construct or
279219820Sjeff*	osm_physp_init.
280219820Sjeff*
281219820Sjeff* SEE ALSO
282219820Sjeff*	Port
283219820Sjeff*********/
284219820Sjeff
285219820Sjeff/****f* OpenSM: Physical Port/osm_physp_is_valid
286219820Sjeff* NAME
287219820Sjeff*	osm_physp_is_valid
288219820Sjeff*
289219820Sjeff* DESCRIPTION
290219820Sjeff*	Returns TRUE if the Physical Port has been successfully initialized.
291219820Sjeff*	FALSE otherwise.
292219820Sjeff*
293219820Sjeff* SYNOPSIS
294219820Sjeff*/
295219820Sjeffstatic inline boolean_t osm_physp_is_valid(IN const osm_physp_t * const p_physp)
296219820Sjeff{
297219820Sjeff	CL_ASSERT(p_physp);
298219820Sjeff	return (p_physp->port_guid != 0);
299219820Sjeff}
300219820Sjeff
301219820Sjeff/*
302219820Sjeff* PARAMETERS
303219820Sjeff*	p_physp
304219820Sjeff*		[in] Pointer to an osm_physp_t object.
305219820Sjeff*
306219820Sjeff* RETURN VALUES
307219820Sjeff*	Returns TRUE if the Physical Port has been successfully initialized.
308219820Sjeff*	FALSE otherwise.
309219820Sjeff*
310219820Sjeff* NOTES
311219820Sjeff*
312219820Sjeff* SEE ALSO
313219820Sjeff*	Port, Physical Port
314219820Sjeff*********/
315219820Sjeff
316219820Sjeff/****f* OpenSM: Physical Port/osm_physp_is_healthy
317219820Sjeff* NAME
318219820Sjeff*	osm_physp_is_healthy
319219820Sjeff*
320219820Sjeff* DESCRIPTION
321219820Sjeff*	Returns TRUE if the Physical Port has been maked as healthy
322219820Sjeff*	FALSE otherwise.
323219820Sjeff*
324219820Sjeff* SYNOPSIS
325219820Sjeff*/
326219820Sjeffstatic inline boolean_t
327219820Sjeffosm_physp_is_healthy(IN const osm_physp_t * const p_physp)
328219820Sjeff{
329219820Sjeff	CL_ASSERT(p_physp);
330219820Sjeff	return (p_physp->healthy);
331219820Sjeff}
332219820Sjeff
333219820Sjeff/*
334219820Sjeff* PARAMETERS
335219820Sjeff*	p_physp
336219820Sjeff*		[in] Pointer to an osm_physp_t object.
337219820Sjeff*
338219820Sjeff* RETURN VALUES
339219820Sjeff*	Returns TRUE if the Physical Port has been maked as healthy
340219820Sjeff*	FALSE otherwise.
341219820Sjeff*  All physical ports are initialized as "healthy" but may be marked
342219820Sjeff*  otherwise if a received trap claims otherwise.
343219820Sjeff*
344219820Sjeff* NOTES
345219820Sjeff*
346219820Sjeff* SEE ALSO
347219820Sjeff*	Port, Physical Port
348219820Sjeff*********/
349219820Sjeff
350219820Sjeff/****f* OpenSM: Physical Port/osm_link_is_healthy
351219820Sjeff* NAME
352219820Sjeff*	osm_link_is_healthy
353219820Sjeff*
354219820Sjeff* DESCRIPTION
355219820Sjeff*	Returns TRUE if the link given by the physical port is health,
356219820Sjeff*  and FALSE otherwise. Link is healthy if both its physical ports are
357219820Sjeff*  healthy
358219820Sjeff*
359219820Sjeff* SYNOPSIS
360219820Sjeff*/
361219820Sjeffboolean_t osm_link_is_healthy(IN const osm_physp_t * const p_physp);
362219820Sjeff/*
363219820Sjeff* PARAMETERS
364219820Sjeff*	p_physp
365219820Sjeff*		[in] Pointer to an osm_physp_t object.
366219820Sjeff*
367219820Sjeff* RETURN VALUES
368219820Sjeff*	TRUE if both physical ports on the link are healthy, and FALSE otherwise.
369219820Sjeff*  All physical ports are initialized as "healthy" but may be marked
370219820Sjeff*  otherwise if a received trap claiming otherwise.
371219820Sjeff*
372219820Sjeff* NOTES
373219820Sjeff*
374219820Sjeff* SEE ALSO
375219820Sjeff*	Port, Physical Port
376219820Sjeff*********/
377219820Sjeff
378219820Sjeff/****f* OpenSM: Physical Port/osm_physp_set_health
379219820Sjeff* NAME
380219820Sjeff*	osm_physp_set_health
381219820Sjeff*
382219820Sjeff* DESCRIPTION
383219820Sjeff*	Sets the port health flag. TRUE means the port is healthy and
384219820Sjeff*  should be used for packet routing. FALSE means it should be avoided.
385219820Sjeff*
386219820Sjeff* SYNOPSIS
387219820Sjeff*/
388219820Sjeffstatic inline void
389219820Sjeffosm_physp_set_health(IN osm_physp_t * const p_physp, IN boolean_t is_healthy)
390219820Sjeff{
391219820Sjeff	CL_ASSERT(p_physp);
392219820Sjeff	p_physp->healthy = is_healthy;
393219820Sjeff}
394219820Sjeff
395219820Sjeff/*
396219820Sjeff* PARAMETERS
397219820Sjeff*	p_physp
398219820Sjeff*		[in] Pointer to an osm_physp_t object.
399219820Sjeff*
400219820Sjeff*	is_healthy
401219820Sjeff*		[in] The health value to be assigned to the port.
402219820Sjeff*		     TRUE if the Physical Port should been maked as healthy
403219820Sjeff*		     FALSE otherwise.
404219820Sjeff*
405219820Sjeff* RETURN VALUES
406219820Sjeff*  NONE
407219820Sjeff*
408219820Sjeff* NOTES
409219820Sjeff*
410219820Sjeff* SEE ALSO
411219820Sjeff*	Port, Physical Port
412219820Sjeff*********/
413219820Sjeff
414219820Sjeff/****f* OpenSM: Physical Port/osm_physp_set_port_info
415219820Sjeff* NAME
416219820Sjeff*	osm_physp_set_port_info
417219820Sjeff*
418219820Sjeff* DESCRIPTION
419219820Sjeff*	Copies the PortInfo attribute into the Physical Port object
420219820Sjeff*	based on the PortState.
421219820Sjeff*
422219820Sjeff* SYNOPSIS
423219820Sjeff*/
424219820Sjeffstatic inline void
425219820Sjeffosm_physp_set_port_info(IN osm_physp_t * const p_physp,
426219820Sjeff			IN const ib_port_info_t * const p_pi)
427219820Sjeff{
428219820Sjeff	CL_ASSERT(p_pi);
429219820Sjeff	CL_ASSERT(osm_physp_is_valid(p_physp));
430219820Sjeff
431219820Sjeff	if (ib_port_info_get_port_state(p_pi) == IB_LINK_DOWN) {
432219820Sjeff		/* If PortState is down, only copy PortState */
433219820Sjeff		/* and PortPhysicalState per C14-24-2.1 */
434219820Sjeff		ib_port_info_set_port_state(&p_physp->port_info, IB_LINK_DOWN);
435219820Sjeff		ib_port_info_set_port_phys_state
436219820Sjeff		    (ib_port_info_get_port_phys_state(p_pi),
437219820Sjeff		     &p_physp->port_info);
438219820Sjeff	} else {
439219820Sjeff		p_physp->port_info = *p_pi;
440219820Sjeff	}
441219820Sjeff}
442219820Sjeff
443219820Sjeff/*
444219820Sjeff* PARAMETERS
445219820Sjeff*	p_physp
446219820Sjeff*		[in] Pointer to an osm_physp_t object.
447219820Sjeff*
448219820Sjeff*	p_pi
449219820Sjeff*		[in] Pointer to the IBA defined PortInfo at this port number.
450219820Sjeff*
451219820Sjeff* RETURN VALUES
452219820Sjeff*	This function does not return a value.
453219820Sjeff*
454219820Sjeff* NOTES
455219820Sjeff*
456219820Sjeff* SEE ALSO
457219820Sjeff*	Port, Physical Port
458219820Sjeff*********/
459219820Sjeff
460219820Sjeff/****f* OpenSM: Physical Port/osm_physp_set_pkey_tbl
461219820Sjeff* NAME
462219820Sjeff*  osm_physp_set_pkey_tbl
463219820Sjeff*
464219820Sjeff* DESCRIPTION
465219820Sjeff*  Copies the P_Key table into the Physical Port object.
466219820Sjeff*
467219820Sjeff* SYNOPSIS
468219820Sjeff*/
469219820Sjeffvoid
470219820Sjeffosm_physp_set_pkey_tbl(IN osm_log_t * p_log,
471219820Sjeff		       IN const osm_subn_t * p_subn,
472219820Sjeff		       IN osm_physp_t * const p_physp,
473219820Sjeff		       IN ib_pkey_table_t * p_pkey_tbl, IN uint16_t block_num);
474219820Sjeff/*
475219820Sjeff* PARAMETERS
476219820Sjeff*	p_log
477219820Sjeff*		[in] Pointer to a log object.
478219820Sjeff*
479219820Sjeff*	p_subn
480219820Sjeff*		[in] Pointer to the subnet data structure.
481219820Sjeff*
482219820Sjeff*	p_physp
483219820Sjeff*		[in] Pointer to an osm_physp_t object.
484219820Sjeff*
485219820Sjeff*	p_pkey_tbl
486219820Sjeff*		[in] Pointer to the IBA defined P_Key table for this port
487219820Sjeff*		     number.
488219820Sjeff*
489219820Sjeff*	block_num
490219820Sjeff*		[in] The part of the P_Key table as defined in the IBA
491219820Sjeff*		     (valid values 0-2047, and is further limited by the
492219820Sjeff*		     partitionCap).
493219820Sjeff*
494219820Sjeff* RETURN VALUES
495219820Sjeff*  This function does not return a value.
496219820Sjeff*
497219820Sjeff* NOTES
498219820Sjeff*
499219820Sjeff* SEE ALSO
500219820Sjeff*  Port, Physical Port
501219820Sjeff*********/
502219820Sjeff
503219820Sjeff/****f* OpenSM: Physical Port/osm_physp_get_pkey_tbl
504219820Sjeff* NAME
505219820Sjeff*  osm_physp_get_pkey_tbl
506219820Sjeff*
507219820Sjeff* DESCRIPTION
508219820Sjeff*  Returns a pointer to the P_Key table object of the Physical Port object.
509219820Sjeff*
510219820Sjeff* SYNOPSIS
511219820Sjeff*/
512219820Sjeffstatic inline const osm_pkey_tbl_t *osm_physp_get_pkey_tbl(IN const osm_physp_t
513219820Sjeff							   * const p_physp)
514219820Sjeff{
515219820Sjeff	CL_ASSERT(osm_physp_is_valid(p_physp));
516219820Sjeff	/*
517219820Sjeff	   (14.2.5.7) - the block number valid values are 0-2047, and are
518219820Sjeff	   further limited by the size of the P_Key table specified by the
519219820Sjeff	   PartitionCap on the node.
520219820Sjeff	 */
521219820Sjeff	return (&p_physp->pkeys);
522219820Sjeff};
523219820Sjeff
524219820Sjeff/*
525219820Sjeff* PARAMETERS
526219820Sjeff*	p_physp
527219820Sjeff*		[in] Pointer to an osm_physp_t object.
528219820Sjeff*
529219820Sjeff* RETURN VALUES
530219820Sjeff*  The pointer to the P_Key table object.
531219820Sjeff*
532219820Sjeff* NOTES
533219820Sjeff*
534219820Sjeff* SEE ALSO
535219820Sjeff*  Port, Physical Port
536219820Sjeff*********/
537219820Sjeff
538219820Sjeff/****f* OpenSM: Physical Port/osm_physp_set_slvl_tbl
539219820Sjeff* NAME
540219820Sjeff*	osm_physp_set_slvl_tbl
541219820Sjeff*
542219820Sjeff* DESCRIPTION
543219820Sjeff*	Copies the SLtoVL attribute into the Physical Port object.
544219820Sjeff*
545219820Sjeff* SYNOPSIS
546219820Sjeff*/
547219820Sjeffstatic inline void
548219820Sjeffosm_physp_set_slvl_tbl(IN osm_physp_t * const p_physp,
549219820Sjeff		       IN ib_slvl_table_t * p_slvl_tbl, IN uint8_t in_port_num)
550219820Sjeff{
551219820Sjeff	ib_slvl_table_t *p_tbl;
552219820Sjeff
553219820Sjeff	CL_ASSERT(p_slvl_tbl);
554219820Sjeff	CL_ASSERT(osm_physp_is_valid(p_physp));
555219820Sjeff	p_tbl = cl_ptr_vector_get(&p_physp->slvl_by_port, in_port_num);
556219820Sjeff	*p_tbl = *p_slvl_tbl;
557219820Sjeff}
558219820Sjeff
559219820Sjeff/*
560219820Sjeff* PARAMETERS
561219820Sjeff*	p_physp
562219820Sjeff*		[in] Pointer to an osm_physp_t object.
563219820Sjeff*
564219820Sjeff*	p_slvl_tbl
565219820Sjeff*		[in] Pointer to the IBA defined SLtoVL map table for this
566219820Sjeff*		     port number.
567219820Sjeff*
568219820Sjeff*	in_port_num
569219820Sjeff*		[in] Input Port Number for this SLtoVL.
570219820Sjeff*
571219820Sjeff* RETURN VALUES
572219820Sjeff*	This function does not return a value.
573219820Sjeff*
574219820Sjeff* NOTES
575219820Sjeff*
576219820Sjeff* SEE ALSO
577219820Sjeff*	Port, Physical Port
578219820Sjeff*********/
579219820Sjeff
580219820Sjeff/****f* OpenSM: Physical Port/osm_physp_get_slvl_tbl
581219820Sjeff* NAME
582219820Sjeff*	osm_physp_get_slvl_tbl
583219820Sjeff*
584219820Sjeff* DESCRIPTION
585219820Sjeff*	Returns a pointer to the SLtoVL attribute of the Physical Port object.
586219820Sjeff*
587219820Sjeff* SYNOPSIS
588219820Sjeff*/
589219820Sjeffstatic inline ib_slvl_table_t *osm_physp_get_slvl_tbl(IN const osm_physp_t *
590219820Sjeff						      const p_physp,
591219820Sjeff						      IN uint8_t in_port_num)
592219820Sjeff{
593219820Sjeff	ib_slvl_table_t *p_tbl;
594219820Sjeff
595219820Sjeff	CL_ASSERT(osm_physp_is_valid(p_physp));
596219820Sjeff	p_tbl = cl_ptr_vector_get(&p_physp->slvl_by_port, in_port_num);
597219820Sjeff	return (p_tbl);
598219820Sjeff}
599219820Sjeff
600219820Sjeff/*
601219820Sjeff* PARAMETERS
602219820Sjeff*	p_physp
603219820Sjeff*		[in] Pointer to an osm_physp_t object.
604219820Sjeff*
605219820Sjeff*	in_port_num
606219820Sjeff*		[in] Input Port Number for this SLtoVL.
607219820Sjeff*
608219820Sjeff* RETURN VALUES
609219820Sjeff*	The pointer to the slvl table
610219820Sjeff*
611219820Sjeff* NOTES
612219820Sjeff*
613219820Sjeff* SEE ALSO
614219820Sjeff*	Port, Physical Port
615219820Sjeff*********/
616219820Sjeff
617219820Sjeff/****f* OpenSM: Physical Port/osm_physp_set_vla_tbl
618219820Sjeff* NAME
619219820Sjeff*	osm_physp_set_vla_tbl
620219820Sjeff*
621219820Sjeff* DESCRIPTION
622219820Sjeff*	Copies the VL Arbitration attribute into the Physical Port object.
623219820Sjeff*
624219820Sjeff* SYNOPSIS
625219820Sjeff*/
626219820Sjeffstatic inline void
627219820Sjeffosm_physp_set_vla_tbl(IN osm_physp_t * const p_physp,
628219820Sjeff		      IN ib_vl_arb_table_t * p_vla_tbl, IN uint8_t block_num)
629219820Sjeff{
630219820Sjeff	CL_ASSERT(p_vla_tbl);
631219820Sjeff	CL_ASSERT(osm_physp_is_valid(p_physp));
632219820Sjeff	CL_ASSERT((1 <= block_num) && (block_num <= 4));
633219820Sjeff	p_physp->vl_arb[block_num - 1] = *p_vla_tbl;
634219820Sjeff}
635219820Sjeff
636219820Sjeff/*
637219820Sjeff* PARAMETERS
638219820Sjeff*	p_physp
639219820Sjeff*		[in] Pointer to an osm_physp_t object.
640219820Sjeff*
641219820Sjeff*	p_vla_tbl
642219820Sjeff*		[in] Pointer to the IBA defined VL Arbitration table for this
643219820Sjeff*		     port number.
644219820Sjeff*
645219820Sjeff*	block_num
646219820Sjeff*		[in] The part of the VL arbitration as defined in the IBA
647219820Sjeff*		     (valid values 1-4)
648219820Sjeff*
649219820Sjeff* RETURN VALUES
650219820Sjeff*	This function does not return a value.
651219820Sjeff*
652219820Sjeff* NOTES
653219820Sjeff*
654219820Sjeff* SEE ALSO
655219820Sjeff*	Port, Physical Port
656219820Sjeff*********/
657219820Sjeff
658219820Sjeff/****f* OpenSM: Physical Port/osm_physp_get_vla_tbl
659219820Sjeff* NAME
660219820Sjeff*	osm_physp_get_vla_tbl
661219820Sjeff*
662219820Sjeff* DESCRIPTION
663219820Sjeff*	Returns a pointer to the VL Arbitration table of the Physical Port object.
664219820Sjeff*
665219820Sjeff* SYNOPSIS
666219820Sjeff*/
667219820Sjeffstatic inline ib_vl_arb_table_t *osm_physp_get_vla_tbl(IN osm_physp_t *
668219820Sjeff						       const p_physp,
669219820Sjeff						       IN uint8_t block_num)
670219820Sjeff{
671219820Sjeff	CL_ASSERT(osm_physp_is_valid(p_physp));
672219820Sjeff	CL_ASSERT((1 <= block_num) && (block_num <= 4));
673219820Sjeff	return (&(p_physp->vl_arb[block_num - 1]));
674219820Sjeff}
675219820Sjeff
676219820Sjeff/*
677219820Sjeff* PARAMETERS
678219820Sjeff*	p_physp
679219820Sjeff*		[in] Pointer to an osm_physp_t object.
680219820Sjeff*
681219820Sjeff*	block_num
682219820Sjeff*		[in] The part of the VL arbitration as defined in the IBA
683219820Sjeff*		     (valid values 1-4)
684219820Sjeff*
685219820Sjeff* RETURN VALUES
686219820Sjeff*  The pointer to the VL Arbitration table
687219820Sjeff*
688219820Sjeff* NOTES
689219820Sjeff*
690219820Sjeff* SEE ALSO
691219820Sjeff*	Port, Physical Port
692219820Sjeff*********/
693219820Sjeff
694219820Sjeff/****f* OpenSM: Physical Port/osm_physp_get_remote
695219820Sjeff* NAME
696219820Sjeff*	osm_physp_get_remote
697219820Sjeff*
698219820Sjeff* DESCRIPTION
699219820Sjeff*	Returns a pointer to the Physical Port on the other side the wire.
700219820Sjeff*
701219820Sjeff* SYNOPSIS
702219820Sjeff*/
703219820Sjeffstatic inline osm_physp_t *osm_physp_get_remote(IN const osm_physp_t *
704219820Sjeff						const p_physp)
705219820Sjeff{
706219820Sjeff	CL_ASSERT(osm_physp_is_valid(p_physp));
707219820Sjeff	return (p_physp->p_remote_physp);
708219820Sjeff}
709219820Sjeff
710219820Sjeff/*
711219820Sjeff* PARAMETERS
712219820Sjeff*	p_physp
713219820Sjeff*		[in] Pointer to an osm_physp_t object.
714219820Sjeff*
715219820Sjeff* RETURN VALUES
716219820Sjeff*	Returns a pointer to the Physical Port on the other side of
717219820Sjeff*	the wire.  A return value of NULL means there is no link at this port.
718219820Sjeff*
719219820Sjeff* NOTES
720219820Sjeff*
721219820Sjeff* SEE ALSO
722219820Sjeff*	Port, Physical Port
723219820Sjeff*********/
724219820Sjeff
725219820Sjeff/****f* OpenSM: Physical Port/osm_physp_get_port_guid
726219820Sjeff* NAME
727219820Sjeff*	osm_physp_get_port_guid
728219820Sjeff*
729219820Sjeff* DESCRIPTION
730219820Sjeff*	Returns the port guid of this physical port.
731219820Sjeff*
732219820Sjeff* SYNOPSIS
733219820Sjeff*/
734219820Sjeffstatic inline ib_net64_t
735219820Sjeffosm_physp_get_port_guid(IN const osm_physp_t * const p_physp)
736219820Sjeff{
737219820Sjeff	CL_ASSERT(osm_physp_is_valid(p_physp));
738219820Sjeff	return (p_physp->port_guid);
739219820Sjeff}
740219820Sjeff
741219820Sjeff/*
742219820Sjeff* PARAMETERS
743219820Sjeff*	p_physp
744219820Sjeff*		[in] Pointer to an osm_physp_t object.
745219820Sjeff*
746219820Sjeff* RETURN VALUES
747219820Sjeff*	Returns the port guid of this physical port.
748219820Sjeff*
749219820Sjeff* NOTES
750219820Sjeff*
751219820Sjeff* SEE ALSO
752219820Sjeff*	Port, Physical Port
753219820Sjeff*********/
754219820Sjeff
755219820Sjeff/****f* OpenSM: Physical Port/osm_physp_get_subnet_prefix
756219820Sjeff* NAME
757219820Sjeff*	osm_physp_get_subnet_prefix
758219820Sjeff*
759219820Sjeff* DESCRIPTION
760219820Sjeff*	Returns the subnet prefix for this physical port.
761219820Sjeff*
762219820Sjeff* SYNOPSIS
763219820Sjeff*/
764219820Sjeffstatic inline ib_net64_t
765219820Sjeffosm_physp_get_subnet_prefix(IN const osm_physp_t * const p_physp)
766219820Sjeff{
767219820Sjeff	CL_ASSERT(osm_physp_is_valid(p_physp));
768219820Sjeff	return (p_physp->port_info.subnet_prefix);
769219820Sjeff}
770219820Sjeff
771219820Sjeff/*
772219820Sjeff* PARAMETERS
773219820Sjeff*	p_physp
774219820Sjeff*		[in] Pointer to an osm_physp_t object.
775219820Sjeff*
776219820Sjeff* RETURN VALUES
777219820Sjeff*	Returns the subnet prefix for this physical port.
778219820Sjeff*
779219820Sjeff* NOTES
780219820Sjeff*
781219820Sjeff* SEE ALSO
782219820Sjeff*	Port, Physical Port
783219820Sjeff*********/
784219820Sjeff
785219820Sjeff/****f* OpenSM: Physical Port/osm_physp_link_exists
786219820Sjeff* NAME
787219820Sjeff*	osm_physp_link_exists
788219820Sjeff*
789219820Sjeff* DESCRIPTION
790219820Sjeff*	Returns TRUE if the Physical Port has a link to the specified port.
791219820Sjeff*	FALSE otherwise.
792219820Sjeff*
793219820Sjeff* SYNOPSIS
794219820Sjeff*/
795219820Sjeffstatic inline boolean_t
796219820Sjeffosm_physp_link_exists(IN const osm_physp_t * const p_physp,
797219820Sjeff		      IN const osm_physp_t * const p_remote_physp)
798219820Sjeff{
799219820Sjeff	CL_ASSERT(p_physp);
800219820Sjeff	CL_ASSERT(osm_physp_is_valid(p_physp));
801219820Sjeff	CL_ASSERT(p_remote_physp);
802219820Sjeff	CL_ASSERT(osm_physp_is_valid(p_remote_physp));
803219820Sjeff	return ((p_physp->p_remote_physp == p_remote_physp) &&
804219820Sjeff		(p_remote_physp->p_remote_physp == p_physp));
805219820Sjeff}
806219820Sjeff
807219820Sjeff/*
808219820Sjeff* PARAMETERS
809219820Sjeff*	p_physp
810219820Sjeff*		[in] Pointer to an osm_physp_t object.
811219820Sjeff*
812219820Sjeff*	p_remote_physp
813219820Sjeff*		[in] Pointer to an osm_physp_t object.
814219820Sjeff*
815219820Sjeff* RETURN VALUES
816219820Sjeff*	Returns TRUE if the Physical Port has a link to another port.
817219820Sjeff*	FALSE otherwise.
818219820Sjeff*
819219820Sjeff* NOTES
820219820Sjeff*
821219820Sjeff* SEE ALSO
822219820Sjeff*	Port, Physical Port
823219820Sjeff*********/
824219820Sjeff
825219820Sjeff/****f* OpenSM: Physical Port/osm_physp_link
826219820Sjeff* NAME
827219820Sjeff*	osm_physp_link
828219820Sjeff*
829219820Sjeff* DESCRIPTION
830219820Sjeff*	Sets the pointers to the Physical Ports on the other side the wire.
831219820Sjeff*
832219820Sjeff* SYNOPSIS
833219820Sjeff*/
834219820Sjeffstatic inline void
835219820Sjeffosm_physp_link(IN osm_physp_t * const p_physp,
836219820Sjeff	       IN osm_physp_t * const p_remote_physp)
837219820Sjeff{
838219820Sjeff	CL_ASSERT(p_physp);
839219820Sjeff	CL_ASSERT(p_remote_physp);
840219820Sjeff	p_physp->p_remote_physp = p_remote_physp;
841219820Sjeff	p_remote_physp->p_remote_physp = p_physp;
842219820Sjeff}
843219820Sjeff
844219820Sjeff/*
845219820Sjeff* PARAMETERS
846219820Sjeff*	p_physp
847219820Sjeff*		[in] Pointer to an osm_physp_t object to link.
848219820Sjeff*
849219820Sjeff*	p_remote_physp
850219820Sjeff*		[in] Pointer to the adjacent osm_physp_t object to link.
851219820Sjeff*
852219820Sjeff* RETURN VALUES
853219820Sjeff*	None.
854219820Sjeff*
855219820Sjeff* NOTES
856219820Sjeff*
857219820Sjeff* SEE ALSO
858219820Sjeff*	Port, Physical Port
859219820Sjeff*********/
860219820Sjeff
861219820Sjeff/****f* OpenSM: Physical Port/osm_physp_unlink
862219820Sjeff* NAME
863219820Sjeff*	osm_physp_unlink
864219820Sjeff*
865219820Sjeff* DESCRIPTION
866219820Sjeff*	Clears the pointers to the Physical Port on the other side the wire.
867219820Sjeff*
868219820Sjeff* SYNOPSIS
869219820Sjeff*/
870219820Sjeffstatic inline void
871219820Sjeffosm_physp_unlink(IN osm_physp_t * const p_physp,
872219820Sjeff		 IN osm_physp_t * const p_remote_physp)
873219820Sjeff{
874219820Sjeff	CL_ASSERT(p_physp);
875219820Sjeff	CL_ASSERT(p_remote_physp);
876219820Sjeff	CL_ASSERT(osm_physp_link_exists(p_physp, p_remote_physp));
877219820Sjeff	p_physp->p_remote_physp = NULL;
878219820Sjeff	p_remote_physp->p_remote_physp = NULL;
879219820Sjeff}
880219820Sjeff
881219820Sjeff/*
882219820Sjeff* PARAMETERS
883219820Sjeff*	p_physp
884219820Sjeff*		[in] Pointer to an osm_physp_t object to link.
885219820Sjeff*
886219820Sjeff*	p_remote_physp
887219820Sjeff*		[in] Pointer to the adjacent osm_physp_t object to link.
888219820Sjeff*
889219820Sjeff* RETURN VALUES
890219820Sjeff*	None.
891219820Sjeff*
892219820Sjeff* NOTES
893219820Sjeff*
894219820Sjeff* SEE ALSO
895219820Sjeff*	Port, Physical Port
896219820Sjeff*********/
897219820Sjeff
898219820Sjeff/****f* OpenSM: Physical Port/osm_physp_has_any_link
899219820Sjeff* NAME
900219820Sjeff*	osm_physp_has_any_link
901219820Sjeff*
902219820Sjeff* DESCRIPTION
903219820Sjeff*	Returns TRUE if the Physical Port has a link to another port.
904219820Sjeff*	FALSE otherwise.
905219820Sjeff*
906219820Sjeff* SYNOPSIS
907219820Sjeff*/
908219820Sjeffstatic inline boolean_t
909219820Sjeffosm_physp_has_any_link(IN const osm_physp_t * const p_physp)
910219820Sjeff{
911219820Sjeff	CL_ASSERT(p_physp);
912219820Sjeff	if (osm_physp_is_valid(p_physp))
913219820Sjeff		return (p_physp->p_remote_physp != NULL);
914219820Sjeff	else
915219820Sjeff		return (FALSE);
916219820Sjeff}
917219820Sjeff
918219820Sjeff/*
919219820Sjeff* PARAMETERS
920219820Sjeff*	p_physp
921219820Sjeff*		[in] Pointer to an osm_physp_t object.
922219820Sjeff*
923219820Sjeff* RETURN VALUES
924219820Sjeff*	Returns TRUE if the Physical Port has a link to another port.
925219820Sjeff*	FALSE otherwise.
926219820Sjeff*
927219820Sjeff* NOTES
928219820Sjeff*
929219820Sjeff* SEE ALSO
930219820Sjeff*	Port, Physical Port
931219820Sjeff*********/
932219820Sjeff
933219820Sjeff/****f* OpenSM: Physical Port/osm_physp_get_port_num
934219820Sjeff* NAME
935219820Sjeff*	osm_physp_get_port_num
936219820Sjeff*
937219820Sjeff* DESCRIPTION
938219820Sjeff*	Returns the local port number of this Physical Port.
939219820Sjeff*
940219820Sjeff* SYNOPSIS
941219820Sjeff*/
942219820Sjeffstatic inline uint8_t
943219820Sjeffosm_physp_get_port_num(IN const osm_physp_t * const p_physp)
944219820Sjeff{
945219820Sjeff	CL_ASSERT(p_physp);
946219820Sjeff	CL_ASSERT(osm_physp_is_valid(p_physp));
947219820Sjeff	return (p_physp->port_num);
948219820Sjeff}
949219820Sjeff
950219820Sjeff/*
951219820Sjeff* PARAMETERS
952219820Sjeff*	p_physp
953219820Sjeff*		[in] Pointer to an osm_physp_t object.
954219820Sjeff*
955219820Sjeff* RETURN VALUES
956219820Sjeff*	Returns the local port number of this Physical Port.
957219820Sjeff*
958219820Sjeff* NOTES
959219820Sjeff*
960219820Sjeff* SEE ALSO
961219820Sjeff*********/
962219820Sjeff
963219820Sjeff/****f* OpenSM: Physical Port/osm_physp_get_node_ptr
964219820Sjeff* NAME
965219820Sjeff*	osm_physp_get_node_ptr
966219820Sjeff*
967219820Sjeff* DESCRIPTION
968219820Sjeff*	Returns a pointer to the parent Node object for this port.
969219820Sjeff*
970219820Sjeff* SYNOPSIS
971219820Sjeff*/
972219820Sjeffstatic inline struct osm_node *osm_physp_get_node_ptr(IN const osm_physp_t *
973219820Sjeff						       const p_physp)
974219820Sjeff{
975219820Sjeff	CL_ASSERT(p_physp);
976219820Sjeff	CL_ASSERT(osm_physp_is_valid(p_physp));
977219820Sjeff	return ((struct osm_node *)p_physp->p_node);
978219820Sjeff}
979219820Sjeff
980219820Sjeff/*
981219820Sjeff* PARAMETERS
982219820Sjeff*	p_physp
983219820Sjeff*		[in] Pointer to an osm_physp_t object.
984219820Sjeff*
985219820Sjeff* RETURN VALUES
986219820Sjeff*	Returns a pointer to the parent Node object for this port.
987219820Sjeff*
988219820Sjeff* NOTES
989219820Sjeff*
990219820Sjeff* SEE ALSO
991219820Sjeff*********/
992219820Sjeff
993219820Sjeff/****f* OpenSM: Physical Port/osm_physp_get_port_state
994219820Sjeff* NAME
995219820Sjeff*	osm_physp_get_port_state
996219820Sjeff*
997219820Sjeff* DESCRIPTION
998219820Sjeff*	Returns the port state of this Physical Port.
999219820Sjeff*
1000219820Sjeff* SYNOPSIS
1001219820Sjeff*/
1002219820Sjeffstatic inline uint8_t
1003219820Sjeffosm_physp_get_port_state(IN const osm_physp_t * const p_physp)
1004219820Sjeff{
1005219820Sjeff	CL_ASSERT(p_physp);
1006219820Sjeff	CL_ASSERT(osm_physp_is_valid(p_physp));
1007219820Sjeff	return (ib_port_info_get_port_state(&p_physp->port_info));
1008219820Sjeff}
1009219820Sjeff
1010219820Sjeff/*
1011219820Sjeff* PARAMETERS
1012219820Sjeff*	p_physp
1013219820Sjeff*		[in] Pointer to an osm_physp_t object.
1014219820Sjeff*
1015219820Sjeff* RETURN VALUES
1016219820Sjeff*	Returns the local port number of this Physical Port.
1017219820Sjeff*
1018219820Sjeff* NOTES
1019219820Sjeff*
1020219820Sjeff* SEE ALSO
1021219820Sjeff*********/
1022219820Sjeff
1023219820Sjeff/****f* OpenSM: Physical Port/osm_physp_get_base_lid
1024219820Sjeff* NAME
1025219820Sjeff*	osm_physp_get_base_lid
1026219820Sjeff*
1027219820Sjeff* DESCRIPTION
1028219820Sjeff*	Returns the base lid of this Physical Port.
1029219820Sjeff*
1030219820Sjeff* SYNOPSIS
1031219820Sjeff*/
1032219820Sjeffstatic inline ib_net16_t
1033219820Sjeffosm_physp_get_base_lid(IN const osm_physp_t * const p_physp)
1034219820Sjeff{
1035219820Sjeff	CL_ASSERT(p_physp);
1036219820Sjeff	CL_ASSERT(osm_physp_is_valid(p_physp));
1037219820Sjeff	return (p_physp->port_info.base_lid);
1038219820Sjeff}
1039219820Sjeff
1040219820Sjeff/*
1041219820Sjeff* PARAMETERS
1042219820Sjeff*	p_physp
1043219820Sjeff*		[in] Pointer to an osm_physp_t object.
1044219820Sjeff*
1045219820Sjeff* RETURN VALUES
1046219820Sjeff*	Returns the base lid of this Physical Port.
1047219820Sjeff*
1048219820Sjeff* NOTES
1049219820Sjeff*
1050219820Sjeff* SEE ALSO
1051219820Sjeff*********/
1052219820Sjeff
1053219820Sjeff/****f* OpenSM: Physical Port/osm_physp_get_lmc
1054219820Sjeff* NAME
1055219820Sjeff*	osm_physp_get_lmc
1056219820Sjeff*
1057219820Sjeff* DESCRIPTION
1058219820Sjeff*	Returns the LMC value of this Physical Port.
1059219820Sjeff*
1060219820Sjeff* SYNOPSIS
1061219820Sjeff*/
1062219820Sjeffstatic inline uint8_t osm_physp_get_lmc(IN const osm_physp_t * const p_physp)
1063219820Sjeff{
1064219820Sjeff	CL_ASSERT(p_physp);
1065219820Sjeff	CL_ASSERT(osm_physp_is_valid(p_physp));
1066219820Sjeff	return (ib_port_info_get_lmc(&p_physp->port_info));
1067219820Sjeff}
1068219820Sjeff
1069219820Sjeff/*
1070219820Sjeff* PARAMETERS
1071219820Sjeff*	p_physp
1072219820Sjeff*		[in] Pointer to an osm_physp_t object.
1073219820Sjeff*
1074219820Sjeff* RETURN VALUES
1075219820Sjeff*	Returns the LMC value of this Physical Port.
1076219820Sjeff*
1077219820Sjeff* NOTES
1078219820Sjeff*
1079219820Sjeff* SEE ALSO
1080219820Sjeff*********/
1081219820Sjeff
1082219820Sjeff/****f* OpenSM: Physical Port/osm_physp_get_dr_path_ptr
1083219820Sjeff* NAME
1084219820Sjeff*	osm_physp_get_dr_path_ptr
1085219820Sjeff*
1086219820Sjeff* DESCRIPTION
1087219820Sjeff*	Returns a pointer to the directed route path for this port.
1088219820Sjeff*
1089219820Sjeff* SYNOPSIS
1090219820Sjeff*/
1091219820Sjeffstatic inline osm_dr_path_t *osm_physp_get_dr_path_ptr(IN const osm_physp_t *
1092219820Sjeff						       const p_physp)
1093219820Sjeff{
1094219820Sjeff	CL_ASSERT(p_physp);
1095219820Sjeff	CL_ASSERT(osm_physp_is_valid(p_physp));
1096219820Sjeff	return ((osm_dr_path_t *) & p_physp->dr_path);
1097219820Sjeff}
1098219820Sjeff
1099219820Sjeff/*
1100219820Sjeff* PARAMETERS
1101219820Sjeff*	p_physp
1102219820Sjeff*		[in] Pointer to a Physical Port object.
1103219820Sjeff*
1104219820Sjeff* RETURN VALUES
1105219820Sjeff*	Returns a pointer to the directed route path for this port.
1106219820Sjeff*
1107219820Sjeff* NOTES
1108219820Sjeff*
1109219820Sjeff* SEE ALSO
1110219820Sjeff*	Physical Port object
1111219820Sjeff*********/
1112219820Sjeff
1113219820Sjeff/****h* OpenSM/Port
1114219820Sjeff* NAME
1115219820Sjeff*	Port
1116219820Sjeff*
1117219820Sjeff* DESCRIPTION
1118219820Sjeff*	The Port object encapsulates the information needed by the
1119219820Sjeff*	OpenSM to manage ports.  The OpenSM allocates one Port object
1120219820Sjeff*	per port in the IBA subnet.
1121219820Sjeff*
1122219820Sjeff*	Each Port object is associated with a single port GUID.  A Port object
1123219820Sjeff*	contains 1 or more Physical Port objects.  An end point node has
1124219820Sjeff*	one Physical Port per Port.  A switch node has more than
1125219820Sjeff*	one Physical Port per Port.
1126219820Sjeff*
1127219820Sjeff*	The Port object is not thread safe, thus callers must provide
1128219820Sjeff*	serialization.
1129219820Sjeff*
1130219820Sjeff*	These objects should be treated as opaque and should be
1131219820Sjeff*	manipulated only through the provided functions.
1132219820Sjeff*
1133219820Sjeff* AUTHOR
1134219820Sjeff*	Steve King, Intel
1135219820Sjeff*
1136219820Sjeff*********/
1137219820Sjeff
1138219820Sjeff/****s* OpenSM: Port/osm_port_t
1139219820Sjeff* NAME
1140219820Sjeff*	osm_port_t
1141219820Sjeff*
1142219820Sjeff* DESCRIPTION
1143219820Sjeff*	This object represents a logical port on a switch, router or end-point.
1144219820Sjeff*
1145219820Sjeff*	The osm_port_t object should be treated as opaque and should
1146219820Sjeff*	be manipulated only through the provided functions.
1147219820Sjeff*
1148219820Sjeff* SYNOPSIS
1149219820Sjeff*/
1150219820Sjefftypedef struct osm_port {
1151219820Sjeff	cl_map_item_t map_item;
1152219820Sjeff	cl_list_item_t list_item;
1153219820Sjeff	struct osm_node *p_node;
1154219820Sjeff	ib_net64_t guid;
1155219820Sjeff	uint32_t discovery_count;
1156219820Sjeff	unsigned is_new;
1157219820Sjeff	osm_physp_t *p_physp;
1158219820Sjeff	cl_qlist_t mcm_list;
1159219820Sjeff	int flag;
1160219820Sjeff	void *priv;
1161219820Sjeff} osm_port_t;
1162219820Sjeff/*
1163219820Sjeff* FIELDS
1164219820Sjeff*	map_item
1165219820Sjeff*		Linkage structure for cl_qmap.  MUST BE FIRST MEMBER!
1166219820Sjeff*
1167219820Sjeff*	list_item
1168219820Sjeff*		Linkage structure for cl_qlist. Used by ucast mgr during LFT calculation.
1169219820Sjeff*
1170219820Sjeff*	p_node
1171219820Sjeff*		Points to the Node object that owns this port.
1172219820Sjeff*
1173219820Sjeff*	guid
1174219820Sjeff*		Manufacturer assigned GUID for this port.
1175219820Sjeff*
1176219820Sjeff*	discovery_count
1177219820Sjeff*		The number of times this port has been discovered
1178219820Sjeff*		during the current fabric sweep.  This number is reset
1179219820Sjeff*		to zero at the start of a sweep.
1180219820Sjeff*
1181219820Sjeff*	p_physp
1182219820Sjeff*		The pointer to physical port used when physical
1183219820Sjeff*		characteristics contained in the Physical Port are needed.
1184219820Sjeff*
1185219820Sjeff*	mcm_list
1186219820Sjeff*		Multicast member list
1187219820Sjeff*
1188219820Sjeff*	flag
1189219820Sjeff*		Utility flag for port management
1190219820Sjeff*
1191219820Sjeff* SEE ALSO
1192219820Sjeff*	Port, Physical Port, Physical Port Table
1193219820Sjeff*********/
1194219820Sjeff
1195219820Sjeff/****f* OpenSM: Port/osm_port_delete
1196219820Sjeff* NAME
1197219820Sjeff*	osm_port_delete
1198219820Sjeff*
1199219820Sjeff* DESCRIPTION
1200219820Sjeff*	This function destroys and deallocates a Port object.
1201219820Sjeff*
1202219820Sjeff* SYNOPSIS
1203219820Sjeff*/
1204219820Sjeffvoid osm_port_delete(IN OUT osm_port_t ** const pp_port);
1205219820Sjeff/*
1206219820Sjeff* PARAMETERS
1207219820Sjeff*	pp_port
1208219820Sjeff*		[in][out] Pointer to a pointer to a Port object to delete.
1209219820Sjeff*		On return, this pointer is NULL.
1210219820Sjeff*
1211219820Sjeff* RETURN VALUE
1212219820Sjeff*	This function does not return a value.
1213219820Sjeff*
1214219820Sjeff* NOTES
1215219820Sjeff*	Performs any necessary cleanup of the specified Port object.
1216219820Sjeff*
1217219820Sjeff* SEE ALSO
1218219820Sjeff*	Port
1219219820Sjeff*********/
1220219820Sjeff
1221219820Sjeff/****f* OpenSM: Port/osm_port_new
1222219820Sjeff* NAME
1223219820Sjeff*	osm_port_new
1224219820Sjeff*
1225219820Sjeff* DESCRIPTION
1226219820Sjeff*	This function allocates and initializes a Port object.
1227219820Sjeff*
1228219820Sjeff* SYNOPSIS
1229219820Sjeff*/
1230219820Sjeffosm_port_t *osm_port_new(IN const ib_node_info_t * p_ni,
1231219820Sjeff			 IN struct osm_node *const p_parent_node);
1232219820Sjeff/*
1233219820Sjeff* PARAMETERS
1234219820Sjeff*	p_ni
1235219820Sjeff*		[in] Pointer to the NodeInfo attribute relavent for this port.
1236219820Sjeff*
1237219820Sjeff*	p_parent_node
1238219820Sjeff*		[in] Pointer to the initialized parent osm_node_t object
1239219820Sjeff*		that owns this port.
1240219820Sjeff*
1241219820Sjeff* RETURN VALUE
1242219820Sjeff*	Pointer to the initialize Port object.
1243219820Sjeff*
1244219820Sjeff* NOTES
1245219820Sjeff*	Allows calling other port methods.
1246219820Sjeff*
1247219820Sjeff* SEE ALSO
1248219820Sjeff*	Port
1249219820Sjeff*********/
1250219820Sjeff
1251219820Sjeff/****f* OpenSM: Port/osm_port_get_base_lid
1252219820Sjeff* NAME
1253219820Sjeff*	osm_port_get_base_lid
1254219820Sjeff*
1255219820Sjeff* DESCRIPTION
1256219820Sjeff*	Gets the base LID of a port.
1257219820Sjeff*
1258219820Sjeff* SYNOPSIS
1259219820Sjeff*/
1260219820Sjeffstatic inline ib_net16_t
1261219820Sjeffosm_port_get_base_lid(IN const osm_port_t * const p_port)
1262219820Sjeff{
1263219820Sjeff	CL_ASSERT(p_port->p_physp && osm_physp_is_valid(p_port->p_physp));
1264219820Sjeff	return (osm_physp_get_base_lid(p_port->p_physp));
1265219820Sjeff}
1266219820Sjeff
1267219820Sjeff/*
1268219820Sjeff* PARAMETERS
1269219820Sjeff*	p_port
1270219820Sjeff*		[in] Pointer to a Port object.
1271219820Sjeff*
1272219820Sjeff* RETURN VALUE
1273219820Sjeff*	Base LID of the port.
1274219820Sjeff*	If the return value is 0, then this port has no assigned LID.
1275219820Sjeff*
1276219820Sjeff* NOTES
1277219820Sjeff*
1278219820Sjeff* SEE ALSO
1279219820Sjeff*	Port
1280219820Sjeff*********/
1281219820Sjeff
1282219820Sjeff/****f* OpenSM: Port/osm_port_get_lmc
1283219820Sjeff* NAME
1284219820Sjeff*	osm_port_get_lmc
1285219820Sjeff*
1286219820Sjeff* DESCRIPTION
1287219820Sjeff*	Gets the LMC value of a port.
1288219820Sjeff*
1289219820Sjeff* SYNOPSIS
1290219820Sjeff*/
1291219820Sjeffstatic inline uint8_t osm_port_get_lmc(IN const osm_port_t * const p_port)
1292219820Sjeff{
1293219820Sjeff	CL_ASSERT(p_port->p_physp && osm_physp_is_valid(p_port->p_physp));
1294219820Sjeff	return (osm_physp_get_lmc(p_port->p_physp));
1295219820Sjeff}
1296219820Sjeff
1297219820Sjeff/*
1298219820Sjeff* PARAMETERS
1299219820Sjeff*	p_port
1300219820Sjeff*		[in] Pointer to a Port object.
1301219820Sjeff*
1302219820Sjeff* RETURN VALUE
1303219820Sjeff*	Gets the LMC value of a port.
1304219820Sjeff*
1305219820Sjeff* NOTES
1306219820Sjeff*
1307219820Sjeff* SEE ALSO
1308219820Sjeff*	Port
1309219820Sjeff*********/
1310219820Sjeff
1311219820Sjeff/****f* OpenSM: Port/osm_port_get_guid
1312219820Sjeff* NAME
1313219820Sjeff*	osm_port_get_guid
1314219820Sjeff*
1315219820Sjeff* DESCRIPTION
1316219820Sjeff*	Gets the GUID of a port.
1317219820Sjeff*
1318219820Sjeff* SYNOPSIS
1319219820Sjeff*/
1320219820Sjeffstatic inline ib_net64_t osm_port_get_guid(IN const osm_port_t * const p_port)
1321219820Sjeff{
1322219820Sjeff	return (p_port->guid);
1323219820Sjeff}
1324219820Sjeff
1325219820Sjeff/*
1326219820Sjeff* PARAMETERS
1327219820Sjeff*	p_port
1328219820Sjeff*		[in] Pointer to a Port object.
1329219820Sjeff*
1330219820Sjeff* RETURN VALUE
1331219820Sjeff*	Manufacturer assigned GUID of the port.
1332219820Sjeff*
1333219820Sjeff* NOTES
1334219820Sjeff*
1335219820Sjeff* SEE ALSO
1336219820Sjeff*	Port
1337219820Sjeff*********/
1338219820Sjeff
1339219820Sjeff/****f* OpenSM: Port/osm_port_get_lid_range_ho
1340219820Sjeff* NAME
1341219820Sjeff*	osm_port_get_lid_range_ho
1342219820Sjeff*
1343219820Sjeff* DESCRIPTION
1344219820Sjeff*	Returns the HOST ORDER lid min and max values for this port,
1345219820Sjeff*	based on the lmc value.
1346219820Sjeff*
1347219820Sjeff* SYNOPSIS
1348219820Sjeff*/
1349219820Sjeffvoid
1350219820Sjeffosm_port_get_lid_range_ho(IN const osm_port_t * const p_port,
1351219820Sjeff			  OUT uint16_t * const p_min_lid,
1352219820Sjeff			  OUT uint16_t * const p_max_lid);
1353219820Sjeff/*
1354219820Sjeff* PARAMETERS
1355219820Sjeff*	p_port
1356219820Sjeff*		[in] Pointer to a Port object.
1357219820Sjeff*
1358219820Sjeff*	p_min_lid
1359219820Sjeff*		[out] Pointer to the minimum LID value occupied by this port.
1360219820Sjeff*
1361219820Sjeff*	p_max_lid
1362219820Sjeff*		[out] Pointer to the maximum LID value occupied by this port.
1363219820Sjeff*
1364219820Sjeff* RETURN VALUE
1365219820Sjeff*	None.
1366219820Sjeff*
1367219820Sjeff* NOTES
1368219820Sjeff*
1369219820Sjeff* SEE ALSO
1370219820Sjeff*	Port
1371219820Sjeff*********/
1372219820Sjeff
1373219820Sjeff/****f* OpenSM: Port/osm_get_port_by_base_lid
1374219820Sjeff* NAME
1375219820Sjeff*	osm_get_port_by_base_lid
1376219820Sjeff*
1377219820Sjeff* DESCRIPTION
1378219820Sjeff*	Returns a status on whether a Port was able to be
1379219820Sjeff*	determined based on the LID supplied and if so, return the Port.
1380219820Sjeff*
1381219820Sjeff* SYNOPSIS
1382219820Sjeff*/
1383219820Sjeffib_api_status_t
1384219820Sjeffosm_get_port_by_base_lid(IN const osm_subn_t * const p_subn,
1385219820Sjeff			 IN const ib_net16_t lid,
1386219820Sjeff			 IN OUT const osm_port_t ** const pp_port);
1387219820Sjeff/*
1388219820Sjeff* PARAMETERS
1389219820Sjeff*	p_subn
1390219820Sjeff*		[in] Pointer to the subnet data structure.
1391219820Sjeff*
1392219820Sjeff*	lid
1393219820Sjeff*		[in] LID requested.
1394219820Sjeff*
1395219820Sjeff*	pp_port
1396219820Sjeff*		[in][out] Pointer to pointer to Port object.
1397219820Sjeff*
1398219820Sjeff* RETURN VALUES
1399219820Sjeff*	IB_SUCCESS
1400219820Sjeff*	IB_NOT_FOUND
1401219820Sjeff*
1402219820Sjeff* NOTES
1403219820Sjeff*
1404219820Sjeff* SEE ALSO
1405219820Sjeff*       Port
1406219820Sjeff*********/
1407219820Sjeff
1408219820Sjeff/****f* OpenSM: Port/osm_port_add_mgrp
1409219820Sjeff* NAME
1410219820Sjeff*	osm_port_add_mgrp
1411219820Sjeff*
1412219820Sjeff* DESCRIPTION
1413219820Sjeff*	Logically connects a port to a multicast group.
1414219820Sjeff*
1415219820Sjeff* SYNOPSIS
1416219820Sjeff*/
1417219820Sjeffib_api_status_t
1418219820Sjeffosm_port_add_mgrp(IN osm_port_t * const p_port, IN const ib_net16_t mlid);
1419219820Sjeff/*
1420219820Sjeff* PARAMETERS
1421219820Sjeff*	p_port
1422219820Sjeff*		[in] Pointer to an osm_port_t object.
1423219820Sjeff*
1424219820Sjeff*	mlid
1425219820Sjeff*		[in] MLID of the multicast group.
1426219820Sjeff*
1427219820Sjeff* RETURN VALUES
1428219820Sjeff*	IB_SUCCESS
1429219820Sjeff*	IB_INSUFFICIENT_MEMORY
1430219820Sjeff*
1431219820Sjeff* NOTES
1432219820Sjeff*
1433219820Sjeff* SEE ALSO
1434219820Sjeff*	Port object
1435219820Sjeff*********/
1436219820Sjeff
1437219820Sjeff/****f* OpenSM: Port/osm_port_remove_mgrp
1438219820Sjeff* NAME
1439219820Sjeff*	osm_port_remove_mgrp
1440219820Sjeff*
1441219820Sjeff* DESCRIPTION
1442219820Sjeff*	Logically disconnects a port from a multicast group.
1443219820Sjeff*
1444219820Sjeff* SYNOPSIS
1445219820Sjeff*/
1446219820Sjeffvoid
1447219820Sjeffosm_port_remove_mgrp(IN osm_port_t * const p_port, IN const ib_net16_t mlid);
1448219820Sjeff/*
1449219820Sjeff* PARAMETERS
1450219820Sjeff*	p_port
1451219820Sjeff*		[in] Pointer to an osm_port_t object.
1452219820Sjeff*
1453219820Sjeff*	mlid
1454219820Sjeff*		[in] MLID of the multicast group.
1455219820Sjeff*
1456219820Sjeff* RETURN VALUES
1457219820Sjeff*	None.
1458219820Sjeff*
1459219820Sjeff* NOTES
1460219820Sjeff*
1461219820Sjeff* SEE ALSO
1462219820Sjeff*	Port object
1463219820Sjeff*********/
1464219820Sjeff
1465219820Sjeff/****f* OpenSM: Port/osm_port_remove_all_mgrp
1466219820Sjeff* NAME
1467219820Sjeff*	osm_port_remove_all_mgrp
1468219820Sjeff*
1469219820Sjeff* DESCRIPTION
1470219820Sjeff*	Logically disconnects a port from all its multicast groups.
1471219820Sjeff*
1472219820Sjeff* SYNOPSIS
1473219820Sjeff*/
1474219820Sjeffvoid osm_port_remove_all_mgrp(IN osm_port_t * const p_port);
1475219820Sjeff/*
1476219820Sjeff* PARAMETERS
1477219820Sjeff*	p_port
1478219820Sjeff*		[in] Pointer to an osm_port_t object.
1479219820Sjeff*
1480219820Sjeff* RETURN VALUES
1481219820Sjeff*	None.
1482219820Sjeff*
1483219820Sjeff* NOTES
1484219820Sjeff*
1485219820Sjeff* SEE ALSO
1486219820Sjeff*	Port object
1487219820Sjeff*********/
1488219820Sjeff
1489219820Sjeff/****f* OpenSM: Physical Port/osm_physp_calc_link_mtu
1490219820Sjeff* NAME
1491219820Sjeff*	osm_physp_calc_link_mtu
1492219820Sjeff*
1493219820Sjeff* DESCRIPTION
1494219820Sjeff*	Calculate the Port MTU based on current and remote
1495219820Sjeff*  physical ports MTU CAP values.
1496219820Sjeff*
1497219820Sjeff* SYNOPSIS
1498219820Sjeff*/
1499219820Sjeffuint8_t
1500219820Sjeffosm_physp_calc_link_mtu(IN osm_log_t * p_log, IN const osm_physp_t * p_physp);
1501219820Sjeff/*
1502219820Sjeff* PARAMETERS
1503219820Sjeff*	p_log
1504219820Sjeff*		[in] Pointer to a log object.
1505219820Sjeff*
1506219820Sjeff*	p_physp
1507219820Sjeff*		[in] Pointer to an osm_physp_t object.
1508219820Sjeff*
1509219820Sjeff* RETURN VALUES
1510219820Sjeff*	The MTU of the link to be used.
1511219820Sjeff*
1512219820Sjeff* NOTES
1513219820Sjeff*
1514219820Sjeff* SEE ALSO
1515219820Sjeff*	PhysPort object
1516219820Sjeff*********/
1517219820Sjeff
1518219820Sjeff/****f* OpenSM: Physical Port/osm_physp_calc_link_op_vls
1519219820Sjeff* NAME
1520219820Sjeff*	osm_physp_calc_link_op_vls
1521219820Sjeff*
1522219820Sjeff* DESCRIPTION
1523219820Sjeff*	Calculate the Port OP_VLS based on current and remote
1524219820Sjeff*  physical ports VL CAP values. Allowing user option for a max limit.
1525219820Sjeff*
1526219820Sjeff* SYNOPSIS
1527219820Sjeff*/
1528219820Sjeffuint8_t
1529219820Sjeffosm_physp_calc_link_op_vls(IN osm_log_t * p_log,
1530219820Sjeff			   IN const osm_subn_t * p_subn,
1531219820Sjeff			   IN const osm_physp_t * p_physp);
1532219820Sjeff/*
1533219820Sjeff* PARAMETERS
1534219820Sjeff*	p_log
1535219820Sjeff*		[in] Pointer to a log object.
1536219820Sjeff*
1537219820Sjeff*	p_subn
1538219820Sjeff*		[in] Pointer to the subnet object for accessing of the options.
1539219820Sjeff*
1540219820Sjeff*	p_physp
1541219820Sjeff*		[in] Pointer to an osm_physp_t object.
1542219820Sjeff*
1543219820Sjeff* RETURN VALUES
1544219820Sjeff*	The OP_VLS of the link to be used.
1545219820Sjeff*
1546219820Sjeff* NOTES
1547219820Sjeff*
1548219820Sjeff* SEE ALSO
1549219820Sjeff*  PhysPort object
1550219820Sjeff*********/
1551219820Sjeff
1552219820Sjeff/****f* OpenSM: Physical Port/osm_physp_replace_dr_path_with_alternate_dr_path
1553219820Sjeff* NAME
1554219820Sjeff*	osm_physp_replace_dr_path_with_alternate_dr_path
1555219820Sjeff*
1556219820Sjeff* DESCRIPTION
1557219820Sjeff*	Replace the direct route path for the given phys port with an
1558219820Sjeff*  alternate path going through forien set of phys port.
1559219820Sjeff*
1560219820Sjeff* SYNOPSIS
1561219820Sjeff*/
1562219820Sjeffvoid
1563219820Sjeffosm_physp_replace_dr_path_with_alternate_dr_path(IN osm_log_t * p_log,
1564219820Sjeff						 IN osm_subn_t const *p_subn,
1565219820Sjeff						 IN osm_physp_t const *p_physp,
1566219820Sjeff						 IN osm_bind_handle_t * h_bind);
1567219820Sjeff/*
1568219820Sjeff* PARAMETERS
1569219820Sjeff*	p_log
1570219820Sjeff*		[in] Pointer to a log object.
1571219820Sjeff*
1572219820Sjeff*	p_subn
1573219820Sjeff*		[in] Pointer to the subnet object for accessing of the options.
1574219820Sjeff*
1575219820Sjeff*	p_physp
1576219820Sjeff*		[in] Pointer to an osm_physp_t object.
1577219820Sjeff*
1578219820Sjeff*	h_bind
1579219820Sjeff*		[in] Pointer to osm_bind_handle_t object.
1580219820Sjeff*
1581219820Sjeff* RETURN VALUES
1582219820Sjeff*	NONE
1583219820Sjeff*
1584219820Sjeff* NOTES
1585219820Sjeff*
1586219820Sjeff* SEE ALSO
1587219820Sjeff*	PhysPort object
1588219820Sjeff*********/
1589219820Sjeff
1590219820SjeffEND_C_DECLS
1591219820Sjeff#endif				/* _OSM_PORT_H_ */
1592