ZFCP HBA API Library  1
vlib_sysfs.h
Go to the documentation of this file.
1 /*
2  * Copyright IBM Corp. 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: Sven Schuetz <sven@de.ibm.com>
9  * contains code from vlib_aux.h
10  * by Andreas Herrmann and Stefan Voelkel
11  *
12  * File: vlib_sysfs.h
13  *
14  * Description:
15  * Function declarations and inline functions that use the sysfs.
16  *
17  */
18 
19 #ifndef _VLIB_SYSFS_H_
20 #define _VLIB_SYSFS_H_
21 
22 
23 #define ZFCP_SYSFS_PATH "/sys/bus/ccw/drivers/zfcp"
24 #define FC_HOST_PATH "/sys/class/fc_host"
25 
26 #define ATTR_MAX 80 /* all attributes are only one line */
27 #define DEVNO_LENGTH 8 /* x.x.xxxx -> 8 chars */
28 
34 HBA_STATUS sysfs_createAndReadConfigPorts(struct vlib_adapter *);
36 HBA_STATUS sysfs_getDiscoveredPortAttributes(HBA_PORTATTRIBUTES **,
37  struct vlib_port *);
38 HBA_STATUS sysfs_getAdapterPortAttributes(HBA_PORTATTRIBUTES **,
39  struct vlib_adapter *);
40 HBA_STATUS sysfs_getPortStatistics(HBA_PORTSTATISTICS **,
41  struct vlib_adapter *);
42 int sysfs_getUnitsFromPort(struct vlib_port *);
43 void sysfs_waitForSgDev(char *);
44 
57 static inline HBA_STATUS revalidateRepository(void)
58 {
59  if (!vlib_data.isLoaded)
60  return HBA_STATUS_ERROR;
61 
62  if (!vlib_data.isValid) {
63  if (sysfs_createAndReadConfigAdapter() != HBA_STATUS_OK)
64  return HBA_STATUS_ERROR;
65  }
66 
67  return HBA_STATUS_OK;
68 }
69 
82 static inline int revalidatePorts(struct vlib_adapter *adapter)
83 {
84  if (0 == adapter->ports.allocated)
85  return sysfs_createAndReadConfigPorts(adapter);
86 
87  return 0;
88 }
89 
103 static inline int revalidateUnits(struct vlib_port *port)
104 {
105  if (0 == port->units.allocated)
106  return sysfs_getUnitsFromPort(port);
107 
108  return 0;
109 }
110 
111 #endif /*_VLIB_SYSFS_H_*/
size_t allocated
total number of elements in the array
Definition: vlib.h:428
Primary data structure used in the library.
Definition: vlib.h:484
struct block ports
List of ports.
Definition: vlib.h:478
static int revalidatePorts(struct vlib_adapter *adapter)
Revalidate ports of an adapter in the repository.
Definition: vlib_sysfs.h:82
int sysfs_getUnitsFromPort(struct vlib_port *)
Get unit configuration information for a port.
Definition: vlib_sysfs.c:310
unsigned int isValid
Repositoy valid or not This flag is set for instance if a loss of events is detected.
Definition: vlib.h:487
HBA_STATUS sysfs_createAndReadConfigPorts(struct vlib_adapter *)
Read and store all discovered ports of an adapter.
Definition: vlib_sysfs.c:226
HBA_STATUS sysfs_getDiscoveredPortAttributes(HBA_PORTATTRIBUTES **, struct vlib_port *)
Retrieve adapter attributes.
Definition: vlib_sysfs.c:408
HBA_STATUS sysfs_getAdapterPortAttributes(HBA_PORTATTRIBUTES **, struct vlib_adapter *)
Retrieve adapter attributes.
Definition: vlib_sysfs.c:443
struct block units
List of units.
Definition: vlib.h:448
Represenation of an adapter in the library.
Definition: vlib.h:474
static HBA_STATUS revalidateRepository(void)
Check status of the repository, and possibly revalidate it.
Definition: vlib_sysfs.h:57
static int revalidateUnits(struct vlib_port *port)
Revalidate units of an adapter and port in the repository.
Definition: vlib_sysfs.h:103
Representation of a FC port in the library.
Definition: vlib.h:443
HBA_STATUS sysfs_createAndReadConfigAdapter()
Read all adapters from /sys/bus/ccw/drivers/zfcp and add them to the repository.
Definition: vlib_sysfs.c:260
unsigned int isLoaded
Library loaded or not.
Definition: vlib.h:485
HBA_STATUS sysfs_getPortStatistics(HBA_PORTSTATISTICS **, struct vlib_adapter *)
Retrieve adapter port statistics.
Definition: vlib_sysfs.c:595