ZFCP HBA API Library
1
Main Page
Modules
Data Structures
Files
File List
Globals
vlib_aux.h
Go to the documentation of this file.
1
/*
2
* Copyright IBM Corp. 2003,2010
3
* All rights reserved. This program and the accompanying materials
4
* are made available under the terms of the Common Public License v1.0
5
* which accompanies this distribution, and is available at
6
* http://www.ibm.com/developerworks/library/os-cpl.html
7
*
8
* Authors: Andreas Herrmann
9
* Stefan Voelkel
10
*
11
* File: vlib_aux.h
12
*
13
* Description:
14
* Auxiliary functions used in the library.
15
*
16
*/
17
18
#ifndef _VLIB_AUX_H_
19
#define _VLIB_AUX_H_
20
25
#include "
vlib.h
"
26
27
#define VLIB_GROW_UNITS 8
28
#define VLIB_GROW_PORTS 4
29
#define VLIB_GROW_ADAPTERS 2
30
31
#ifdef min
32
# undef min
33
#endif
34
#define min(a, b) (((a) < (b)) ? (a) : (b))
35
36
/*
37
* function declarations
38
*/
39
40
struct
vlib_adapter
*
getAdapterByIndex
(uint32_t);
41
struct
vlib_adapter
*
getAdapterByHandle
(HBA_HANDLE, HBA_STATUS *);
42
struct
vlib_adapter
*
getAdapterByDevid
(devid_t);
43
struct
vlib_adapter
*
getAdapterByHostNo
(
unsigned
short
);
44
struct
vlib_port
*
getPortByIndex
(
const
struct
vlib_adapter
*,
const
uint32_t);
45
struct
vlib_port
*
getPortByWWPN
(
const
struct
vlib_adapter
*,
const
wwn_t);
46
struct
vlib_unit
*
getUnitByIndex
(
const
struct
vlib_port
*,
const
uint32_t);
47
struct
vlib_unit
*
getUnitByFcLun
(
const
struct
vlib_port
*, uint64_t);
48
49
int
addAdapterToRepos
(
struct
vlib_adapter
*);
50
int
addPortToRepos
(
struct
vlib_adapter
*,
struct
vlib_port
*);
51
int
addUnitToRepos
(
struct
vlib_port
*,
struct
vlib_unit
*);
52
53
HBA_STATUS getAdapterConfig(
void
);
54
int
getUnitsFromPort(
struct
vlib_port
*);
55
56
int
findIndexByName
(
char
*);
57
HBA_HANDLE
openAdapterByIndex
(HBA_UINT32);
58
char
*
getSgDevFromPort
(
struct
vlib_port
*);
59
char
*
getAttachedWLUN
(
struct
vlib_adapter
*,
struct
vlib_port
*);
60
void
detachWLUN
(
struct
vlib_adapter
*,
struct
vlib_port
*);
61
62
int
revalidateAdapters
(
void
);
63
int
updateAdapter
(
struct
vlib_adapter
*adapter);
64
void
doCloseAdapter
(
struct
vlib_adapter
*);
65
void
closeAllAdapters
(
void
);
66
67
HBA_PORTTYPE
vlibCharToIntPortType
(
char
*);
68
HBA_PORTSTATE
vlibCharToIntPortState
(
char
*);
69
HBA_PORTSPEED
vlibCharToIntPortSpeed
(
char
*);
70
HBA_COS
vlibCharToIntCOS
(
char
*);
71
72
/*
73
* inline functions
74
*/
75
81
static
inline
void
vlib_wwn_to_HBA_WWN
(uint64_t wwn, HBA_WWN *hba)
82
{
83
*((uint64_t *)(&hba->wwn)) = wwn;
84
}
85
91
static
inline
void
vlib_HBA_WWN_to_wwn
(HBA_WWN *hba, uint64_t *wwn)
92
{
93
*wwn = *((uint64_t *)hba->wwn);
94
}
95
101
static
inline
uint32_t
vlib_FCID_to_hbaFCID
(uint32_t fcid)
102
{
103
return
fcid << 8;
104
}
105
111
static
inline
uint32_t
vlib_hbaFCID_to_FCID
(uint32_t fcid)
112
{
113
return
fcid >> 8;
114
}
115
116
122
static
inline
void
invalidateAllAdapters
(
void
)
123
{
124
unsigned
int
i;
125
struct
vlib_adapter
*adapter;
126
127
adapter =
getAdapterByIndex
(0);
128
for
(i = 0; i <
vlib_data
.
adapters
.
used
; ++i, ++adapter)
129
adapter->
isInvalid
= 1;
130
}
131
138
static
inline
void
markRepositoryInvalid
(
void
)
139
{
140
VLIB_MUTEX_LOCK
(&
vlib_data
.
mutex
);
141
142
vlib_data
.
isValid
= 0;
143
144
VLIB_MUTEX_UNLOCK
(&
vlib_data
.
mutex
);
145
}
146
147
#endif
/* _VLIB_AUX_H_ */
Generated by
1.8.3.1