| 1 |
/* |
| 2 |
* Copyright (c) 2006-2012. QLogic Corporation. All rights reserved. |
| 3 |
* Copyright (c) 2003-2006, PathScale, Inc. All rights reserved. |
| 4 |
* |
| 5 |
* This software is available to you under a choice of one of two |
| 6 |
* licenses. You may choose to be licensed under the terms of the GNU |
| 7 |
* General Public License (GPL) Version 2, available from the file |
| 8 |
* COPYING in the main directory of this source tree, or the |
| 9 |
* OpenIB.org BSD license below: |
| 10 |
* |
| 11 |
* Redistribution and use in source and binary forms, with or |
| 12 |
* without modification, are permitted provided that the following |
| 13 |
* conditions are met: |
| 14 |
* |
| 15 |
* - Redistributions of source code must retain the above |
| 16 |
* copyright notice, this list of conditions and the following |
| 17 |
* disclaimer. |
| 18 |
* |
| 19 |
* - Redistributions in binary form must reproduce the above |
| 20 |
* copyright notice, this list of conditions and the following |
| 21 |
* disclaimer in the documentation and/or other materials |
| 22 |
* provided with the distribution. |
| 23 |
* |
| 24 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 25 |
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 26 |
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 27 |
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS |
| 28 |
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
| 29 |
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 30 |
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 31 |
* SOFTWARE. |
| 32 |
*/ |
| 33 |
|
| 34 |
#ifndef _IPS_EPSTATE_H |
| 35 |
#define _IPS_EPSTATE_H |
| 36 |
|
| 37 |
#include "psm_user.h" |
| 38 |
|
| 39 |
typedef uint32_t ips_epstate_idx; |
| 40 |
#define IPS_EPSTATE_COMMIDX_MAX (1<<20) |
| 41 |
#define IPS_EPSTATE_COMMIDX_MASK 0xF0000 |
| 42 |
#define IPS_EPSTATE_COMMIDX_SHIFT 14 |
| 43 |
#define IPS_EPSTATE_COMMIDX_PACK(ipscommidx) \ |
| 44 |
((ipscommidx & IPS_EPSTATE_COMMIDX_MASK) \ |
| 45 |
>> IPS_EPSTATE_COMMIDX_SHIFT) |
| 46 |
|
| 47 |
struct ptl_epaddr; |
| 48 |
|
| 49 |
struct ips_epstate_entry { |
| 50 |
uint64_t epid; |
| 51 |
struct ptl_epaddr *ipsaddr; |
| 52 |
}; |
| 53 |
|
| 54 |
struct ips_epstate { |
| 55 |
const psmi_context_t *context; |
| 56 |
ips_epstate_idx eps_base_idx; |
| 57 |
int eps_tabsize; |
| 58 |
int eps_tabsizeused; |
| 59 |
int eps_tab_nextidx; |
| 60 |
|
| 61 |
struct ips_epstate_entry *eps_tab; |
| 62 |
}; |
| 63 |
|
| 64 |
psm_error_t ips_epstate_init(struct ips_epstate *eps, const psmi_context_t *contextj); |
| 65 |
psm_error_t ips_epstate_fini(struct ips_epstate *eps); |
| 66 |
|
| 67 |
psm_error_t ips_epstate_add(struct ips_epstate *eps, |
| 68 |
struct ptl_epaddr *ipsaddr, |
| 69 |
ips_epstate_idx *commidx); |
| 70 |
psm_error_t ips_epstate_del(struct ips_epstate *eps, ips_epstate_idx commidx); |
| 71 |
|
| 72 |
PSMI_INLINE( |
| 73 |
struct ips_epstate_entry * |
| 74 |
ips_epstate_lookup(const struct ips_epstate *eps, ips_epstate_idx idx)) |
| 75 |
{ |
| 76 |
idx = (idx + eps->eps_base_idx) & (IPS_EPSTATE_COMMIDX_MAX-1); |
| 77 |
if (idx < eps->eps_tabsize) |
| 78 |
return &eps->eps_tab[idx]; |
| 79 |
else |
| 80 |
return NULL; |
| 81 |
} |
| 82 |
|
| 83 |
#endif /* _IPS_EPSTATE_H */ |