This file is indexed.

/usr/include/infiniband/opensm/osm_pkey.h is in libopensm-dev 3.3.15-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
/*
 * Copyright (c) 2010 Sun Microsystems, Inc. All rights reserved.
 * Copyright (c) 2004-2009 Voltaire, Inc. All rights reserved.
 * Copyright (c) 2002-2012 Mellanox Technologies LTD. All rights reserved.
 * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
 *
 * This software is available to you under a choice of one of two
 * licenses.  You may choose to be licensed under the terms of the GNU
 * General Public License (GPL) Version 2, available from the file
 * COPYING in the main directory of this source tree, or the
 * OpenIB.org BSD license below:
 *
 *     Redistribution and use in source and binary forms, with or
 *     without modification, are permitted provided that the following
 *     conditions are met:
 *
 *      - Redistributions of source code must retain the above
 *        copyright notice, this list of conditions and the following
 *        disclaimer.
 *
 *      - Redistributions in binary form must reproduce the above
 *        copyright notice, this list of conditions and the following
 *        disclaimer in the documentation and/or other materials
 *        provided with the distribution.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 *
 */

#ifndef _OSM_PKEY_H_
#define _OSM_PKEY_H_

#include <iba/ib_types.h>
#include <complib/cl_dispatcher.h>
#include <complib/cl_map.h>
#include <opensm/osm_base.h>
#include <opensm/osm_log.h>
#include <opensm/osm_msgdef.h>

#ifdef __cplusplus
#  define BEGIN_C_DECLS extern "C" {
#  define END_C_DECLS   }
#else				/* !__cplusplus */
#  define BEGIN_C_DECLS
#  define END_C_DECLS
#endif				/* __cplusplus */

BEGIN_C_DECLS
/*
   Forward references.
*/
struct osm_physp;
struct osm_port;
struct osm_subn;
struct osm_node;
struct osm_physp;

/*
 * Abstract:
 * 	Declaration of pkey manipulation functions.
 */

/****s* OpenSM: osm_pkey_tbl_t
* NAME
*	osm_pkey_tbl_t
*
* DESCRIPTION
*	This object represents a pkey table. The need for a special object
*  is required to optimize search performance of a PKey in the IB standard
*  non sorted table.
*
*	The osm_pkey_tbl_t object should be treated as opaque and should
*	be manipulated only through the provided functions.
*
* SYNOPSIS
*/
typedef struct osm_pkeybl {
	cl_ptr_vector_t accum_pkeys;
	cl_ptr_vector_t blocks;
	cl_ptr_vector_t new_blocks;
	cl_map_t keys;
	cl_qlist_t pending;
	uint16_t last_pkey_idx;
	uint16_t used_blocks;
	uint16_t max_blocks;
} osm_pkey_tbl_t;
/*
* FIELDS
*	accum_pkeys
*		Accumulated pkeys with pkey index. Used to
*		preserve pkey index.
*
*	blocks
*		The IBA defined blocks of pkey values, updated from the subnet
*
*	new_blocks
*		The blocks of pkey values, will be used for updates by SM
*
*	keys
*		A set holding all keys
*
*	pending
*		A list of osm_pending_pkey structs that is temporarily set by
*		the pkey mgr and used during pkey mgr algorithm only
*
*	used_blocks
*		Tracks the number of blocks having non-zero pkeys
*
*	max_blocks
*		The maximal number of blocks this partition table might hold
*		this value is based on node_info (for port 0 or CA) or
*		switch_info updated on receiving the node_info or switch_info
*		GetResp
*
* NOTES
* 'blocks' vector should be used to store pkey values obtained from
* the port and SM pkey manager should not change it directly, for this
* purpose 'new_blocks' should be used.
*
* The only pkey values stored in 'blocks' vector will be mapped with
* 'keys' map
*
*********/

/****s* OpenSM: osm_pending_pkey_t
* NAME
*	osm_pending_pkey_t
*
* DESCRIPTION
*	This objects stores temporary information on pkeys, their target block,
*  and index during the pkey manager operation
*
* SYNOPSIS
*/
typedef struct osm_pending_pkey {
	cl_list_item_t list_item;
	uint16_t pkey;
	uint16_t block;
	uint8_t index;
	boolean_t is_new;
} osm_pending_pkey_t;
/*
* FIELDS
*	pkey
*		The actual P_Key
*
*	block
*		The block index based on the previous table extracted from the
*		device
*
*	index
*		The index of the pkey within the block
*
*	is_new
*		TRUE for new P_Keys such that the block and index are invalid
*		in that case
*
*********/

/****f* OpenSM: osm_pkey_tbl_construct
* NAME
*  osm_pkey_tbl_construct
*
* DESCRIPTION
*  Constructs the PKey table object
*
* SYNOPSIS
*/
void osm_pkey_tbl_construct(IN osm_pkey_tbl_t * p_pkey_tbl);
/*
*  p_pkey_tbl
*     [in] Pointer to osm_pkey_tbl_t object.
*
* NOTES
*
*********/

/****f* OpenSM: osm_pkey_tbl_init
* NAME
*  osm_pkey_tbl_init
*
* DESCRIPTION
*  Inits the PKey table object
*
* SYNOPSIS
*/
ib_api_status_t osm_pkey_tbl_init(IN osm_pkey_tbl_t * p_pkey_tbl);
/*
*  p_pkey_tbl
*     [in] Pointer to osm_pkey_tbl_t object.
*
* NOTES
*
*********/

/****f* OpenSM: osm_pkey_tbl_destroy
* NAME
*  osm_pkey_tbl_destroy
*
* DESCRIPTION
*  Destroys the PKey table object
*
* SYNOPSIS
*/
void osm_pkey_tbl_destroy(IN osm_pkey_tbl_t * p_pkey_tbl);
/*
*  p_pkey_tbl
*     [in] Pointer to osm_pkey_tbl_t object.
*
* NOTES
*
*********/

/****f* OpenSM: osm_pkey_tbl_get_num_blocks
* NAME
*  osm_pkey_tbl_get_num_blocks
*
* DESCRIPTION
*  Obtain the number of blocks in IB PKey table
*
* SYNOPSIS
*/
static inline uint16_t
osm_pkey_tbl_get_num_blocks(IN const osm_pkey_tbl_t * p_pkey_tbl)
{
	return ((uint16_t) (cl_ptr_vector_get_size(&p_pkey_tbl->blocks)));
}

/*
*  p_pkey_tbl
*     [in] Pointer to osm_pkey_tbl_t object.
*
* RETURN VALUES
*  The IB pkey table of that pkey table element
*
* NOTES
*
*********/

/****f* OpenSM: osm_pkey_tbl_block_get
* NAME
*  osm_pkey_tbl_block_get
*
* DESCRIPTION
*  Obtain the pointer to the IB PKey table block stored in the object
*
* SYNOPSIS
*/
static inline ib_pkey_table_t *osm_pkey_tbl_block_get(const osm_pkey_tbl_t *
						      p_pkey_tbl,
						      uint16_t block)
{
	return ((block < cl_ptr_vector_get_size(&p_pkey_tbl->blocks)) ?
		(ib_pkey_table_t *)cl_ptr_vector_get(
		&p_pkey_tbl->blocks, block) : NULL);
};

/*
*  p_pkey_tbl
*     [in] Pointer to osm_pkey_tbl_t object.
*
*  block
*     [in] The block number to get
*
* RETURN VALUES
*  The IB pkey table of that pkey table element
*
* NOTES
*
*********/

/****f* OpenSM: osm_pkey_tbl_new_block_get
* NAME
*  osm_pkey_tbl_new_block_get
*
* DESCRIPTION
*  The same as above but for new block
*
* SYNOPSIS
*/
static inline ib_pkey_table_t *osm_pkey_tbl_new_block_get(const osm_pkey_tbl_t *
							  p_pkey_tbl,
							  uint16_t block)
{
	return ((block < cl_ptr_vector_get_size(&p_pkey_tbl->new_blocks)) ?
		(ib_pkey_table_t *)cl_ptr_vector_get(
		&p_pkey_tbl->new_blocks, block) : NULL);
};

/****f* OpenSM: osm_pkey_tbl_set_accum_pkeys
* NAME
*  osm_pkey_tbl_set_accum_pkeys
*
* DESCRIPTION
*   Stores the given pkey and pkey index in the "accum_pkeys" array
*
* SYNOPSIS
*/
cl_status_t
osm_pkey_tbl_set_accum_pkeys(IN osm_pkey_tbl_t * p_pkey_tbl,
			     IN uint16_t pkey, IN uint16_t pkey_idx);
/*
* p_pkey_tbl
*   [in] Pointer to the PKey table
*
* pkey
*   [in] PKey to store
*
* pkey_idx
*   [in] The overall index
*
* RETURN VALUES
*   CL_SUCCESS if OK
*   CL_INSUFFICIENT_MEMORY if failed
*
*********/

/****f* OpenSM: osm_pkey_tbl_clear_accum_pkeys
* NAME
*  osm_pkey_tbl_clear_accum_pkeys
*
* DESCRIPTION
*   Clears the given pkey in the "accum_pkeys" array
*
* SYNOPSIS
*/
void
osm_pkey_tbl_clear_accum_pkeys(IN osm_pkey_tbl_t * p_pkey_tbl,
			       IN uint16_t pkey);
/*
* p_pkey_tbl
*   [in] Pointer to the PKey table
*
* pkey
*   [in] PKey to clear
*
* NOTES
*
*********/

/****f* OpenSM: osm_pkey_tbl_set_new_entry
* NAME
*  osm_pkey_tbl_set_new_entry
*
* DESCRIPTION
*   Stores the given pkey in the "new" blocks array and update
*   the "map" to show that on the "old" blocks
*
* SYNOPSIS
*/
ib_api_status_t
osm_pkey_tbl_set_new_entry(IN osm_pkey_tbl_t * p_pkey_tbl,
			   IN uint16_t block_idx,
			   IN uint8_t pkey_idx, IN uint16_t pkey);
/*
* p_pkey_tbl
*   [in] Pointer to the PKey table
*
* block_idx
*   [in] The block index to use
*
* pkey_idx
*   [in] The index within the block
*
* pkey
*   [in] PKey to store
*
* RETURN VALUES
*   IB_SUCCESS if OK
*   IB_ERROR if failed
*
*********/

/****f* OpenSM: osm_pkey_find_next_free_entry
* NAME
*  osm_pkey_find_next_free_entry
*
* DESCRIPTION
*  Find the next free entry in the PKey table starting at the given
*  index and block number. The user should increment pkey_idx before
*  next call
*  Inspect the "new" blocks array for empty space.
*
* SYNOPSIS
*/
boolean_t
osm_pkey_find_next_free_entry(IN osm_pkey_tbl_t * p_pkey_tbl,
			      OUT uint16_t * p_block_idx,
			      OUT uint8_t * p_pkey_idx);
/*
* p_pkey_tbl
*   [in] Pointer to the PKey table
*
* p_block_idx
*   [out] The block index to use
*
* p_pkey_idx
*   [out] The index within the block to use
*
* RETURN VALUES
*   TRUE if found
*   FALSE if did not find
*
*********/

/****f* OpenSM: osm_pkey_tbl_init_new_blocks
* NAME
*  osm_pkey_tbl_init_new_blocks
*
* DESCRIPTION
*  Initializes new_blocks vector content (allocate and clear)
*
* SYNOPSIS
*/
void osm_pkey_tbl_init_new_blocks(const osm_pkey_tbl_t * p_pkey_tbl);
/*
*  p_pkey_tbl
*     [in] Pointer to osm_pkey_tbl_t object.
*
* NOTES
*
*********/

/****f* OpenSM: osm_pkey_tbl_get_block_and_idx
* NAME
*  osm_pkey_tbl_get_block_and_idx
*
* DESCRIPTION
*  Set the block index and pkey index the given
*  pkey is found in. Return IB_NOT_FOUND if could
*  not find it, IB_SUCCESS if OK
*
* SYNOPSIS
*/
ib_api_status_t
osm_pkey_tbl_get_block_and_idx(IN osm_pkey_tbl_t * p_pkey_tbl,
			       IN uint16_t * p_pkey,
			       OUT uint16_t * block_idx,
			       OUT uint8_t * pkey_index);
/*
*  p_pkey_tbl
*     [in] Pointer to osm_pkey_tbl_t object.
*
*  p_pkey
*     [in] Pointer to the P_Key entry searched
*
*  p_block_idx
*     [out] Pointer to the block index to be updated
*
*  p_pkey_idx
*     [out] Pointer to the pkey index (in the block) to be updated
*
* NOTES
*
*********/

/****f* OpenSM: osm_pkey_tbl_set
* NAME
*  osm_pkey_tbl_set
*
* DESCRIPTION
*  Set the PKey table block provided in the PKey object.
*
* SYNOPSIS
*/
ib_api_status_t
osm_pkey_tbl_set(IN osm_pkey_tbl_t * p_pkey_tbl,
		 IN uint16_t block, IN ib_pkey_table_t * p_tbl,
		 IN boolean_t allow_both_pkeys);
/*
*  p_pkey_tbl
*     [in] Pointer to osm_pkey_tbl_t object
*
*  block
*     [in] The block number to set
*
*  p_tbl
*     [in] The IB PKey block to copy to the object
*
*  allow_both_pkeys
*     [in] Whether both full and limited membership on same partition
*          are allowed
*
* RETURN VALUES
*  IB_SUCCESS or IB_ERROR
*
* NOTES
*
*********/

/****f* OpenSM: osm_physp_share_this_pkey
* NAME
*  osm_physp_share_this_pkey
*
* DESCRIPTION
*  Checks if the given physical ports share the specified pkey.
*
* SYNOPSIS
*/
boolean_t osm_physp_share_this_pkey(IN const struct osm_physp * p_physp1,
				    IN const struct osm_physp * p_physp2,
				    IN ib_net16_t pkey,
				    IN boolean_t allow_both_pkeys);
/*
* PARAMETERS
*
*  p_physp1
*     [in] Pointer to an osm_physp_t object.
*
*  p_physp2
*     [in] Pointer to an osm_physp_t object.
*
*  pkey
*     [in] value of P_Key to check.
*
*  allow_both_pkeys
*     [in] whether both pkeys allowed policy is being used.
*
* RETURN VALUES
*  Returns TRUE if the two ports are matching.
*  FALSE otherwise.
*
* NOTES
*
*********/

/****f* OpenSM: osm_physp_find_common_pkey
* NAME
*  osm_physp_find_common_pkey
*
* DESCRIPTION
*  Returns first matching P_Key values for specified physical ports.
*
* SYNOPSIS
*/
ib_net16_t osm_physp_find_common_pkey(IN const struct osm_physp *p_physp1,
				      IN const struct osm_physp *p_physp2,
				      IN boolean_t allow_both_pkeys);
/*
* PARAMETERS
*
*  p_physp1
*     [in] Pointer to an osm_physp_t object.
*
*  p_physp2
*     [in] Pointer to an osm_physp_t object.
*
*  allow_both_pkeys
*     [in] Whether both full and limited membership on same partition
*          are allowed
*
* RETURN VALUES
*  Returns value of first shared P_Key or INVALID P_Key (0x0) if not
*  found.
*
* NOTES
*
*********/

/****f* OpenSM: osm_physp_share_pkey
* NAME
*  osm_physp_share_pkey
*
* DESCRIPTION
*  Checks if the given physical ports share a pkey.
*  The meaning P_Key matching:
*  10.9.3 :
*   In the following, let M_P_Key(Message P_Key) be the P_Key in the incoming
*   packet and E_P_Key(Endnode P_Key) be the P_Key it is being compared against
*   in the packet's destination endnode.
*
*    If:
*    * neither M_P_Key nor E_P_Key are the invalid P_Key
*    * and the low-order 15 bits of the M_P_Key match the low order 15
*      bits of the E_P_Key
*    * and the high order bit(membership type) of both the M_P_Key and
*      E_P_Key are not both 0 (i.e., both are not Limited members of
*      the partition)
*
*    then the P_Keys are said to match.
*
* SYNOPSIS
*/
boolean_t osm_physp_share_pkey(IN osm_log_t * p_log,
			       IN const struct osm_physp * p_physp_1,
			       IN const struct osm_physp * p_physp_2,
			       IN boolean_t allow_both_pkeys);

/*
* PARAMETERS
*  p_log
*     [in] Pointer to a log object.
*
*  p_physp_1
*     [in] Pointer to an osm_physp_t object.
*
*  p_physp_2
*     [in] Pointer to an osm_physp_t object.
*
*  allow_both_pkeys
*     [in] Whether both full and limited membership on same partition
*          are allowed
*
* RETURN VALUES
*  Returns TRUE if the 2 physical ports are matching.
*  FALSE otherwise.
*
* NOTES
*
*********/

/****f* OpenSM: osm_port_share_pkey
* NAME
*  osm_port_share_pkey
*
* DESCRIPTION
*  Checks if the given ports (on their default physical port) share a pkey.
*  The meaning P_Key matching:
*  10.9.3 :
*   In the following, let M_P_Key(Message P_Key) be the P_Key in the incoming
*   packet and E_P_Key(Endnode P_Key) be the P_Key it is being compared against
*   in the packet's destination endnode.
*
*    If:
*    * neither M_P_Key nor E_P_Key are the invalid P_Key
*    * and the low-order 15 bits of the M_P_Key match the low order 15
*      bits of the E_P_Key
*    * and the high order bit(membership type) of both the M_P_Key and
*      E_P_Key are not both 0 (i.e., both are not Limited members of
*      the partition)
*
*    then the P_Keys are said to match.
*
* SYNOPSIS
*/
boolean_t osm_port_share_pkey(IN osm_log_t * p_log,
			      IN const struct osm_port * p_port_1,
			      IN const struct osm_port * p_port_2,
			      IN boolean_t allow_both_pkeys);

/*
* PARAMETERS
*  p_log
*     [in] Pointer to a log object.
*
*  p_port_1
*     [in] Pointer to an osm_port_t object.
*
*  p_port_2
*     [in] Pointer to an osm_port_t object.
*
* RETURN VALUES
*  Returns TRUE if the 2 ports are matching.
*  FALSE otherwise.
*
* NOTES
*
*********/

/****f* OpenSM: osm_physp_has_pkey
* NAME
*  osm_physp_has_pkey
*
* DESCRIPTION
*  Checks if the given lids and port_numbers share a pkey.
*  The meaning P_Key matching:
*  10.9.3 :
*   In the following, let M_P_Key(Message P_Key) be the P_Key in the incoming
*   packet and E_P_Key(Endnode P_Key) be the P_Key it is being compared against
*   in the packet's destination endnode.
*
*    If:
*    * neither M_P_Key nor E_P_Key are the invalid P_Key
*    * and the low-order 15 bits of the M_P_Key match the low order 15
*      bits of the E_P_Key
*    * and the high order bit(membership type) of both the M_P_Key and
*      E_P_Key are not both 0 (i.e., both are not Limited members of
*      the partition)
*
*    then the P_Keys are said to match.
*
* SYNOPSIS
*/
boolean_t osm_physp_has_pkey(IN osm_log_t * p_log, IN ib_net16_t pkey,
			     IN const struct osm_physp *p_physp);

/*
* PARAMETERS
*  p_log
*     [in] Pointer to a log object.
*
*  pkey
*     [in] pkey number to look for.
*
*  p_physp
*     [in] Pointer to osm_physp_t object.
*
* RETURN VALUES
*  Returns TRUE if the p_physp has the pkey given. False otherwise.
*
* NOTES
*
*********/

END_C_DECLS
#endif				/* _OSM_PKEY_H_ */