vlib_sysfs.h
Go to the documentation of this file.
/*
* Copyright IBM Corp. 2010
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.ibm.com/developerworks/library/os-cpl.html
*
* Authors: Sven Schuetz <sven@de.ibm.com>
* contains code from vlib_aux.h
* by Andreas Herrmann and Stefan Voelkel
*
* File: vlib_sysfs.h
*
* Description:
* Function declarations and inline functions that use the sysfs.
*
*/
#ifndef _VLIB_SYSFS_H_
#define _VLIB_SYSFS_H_
#define ZFCP_SYSFS_PATH "/sys/bus/ccw/drivers/zfcp"
#define FC_HOST_PATH "/sys/class/fc_host"
#define ATTR_MAX 80 /* all attributes are only one line */
#define DEVNO_LENGTH 8 /* x.x.xxxx -> 8 chars */
HBA_STATUS sysfs_createAndReadConfigPorts(struct vlib_adapter *);
HBA_STATUS sysfs_createAndReadConfigAdapter();
HBA_STATUS sysfs_getDiscoveredPortAttributes(HBA_PORTATTRIBUTES **,
struct vlib_port *);
HBA_STATUS sysfs_getAdapterAttributes(HBA_ADAPTERATTRIBUTES **,
struct vlib_adapter *);
HBA_STATUS sysfs_getAdapterPortAttributes(HBA_PORTATTRIBUTES **,
struct vlib_adapter *);
HBA_STATUS sysfs_getPortStatistics(HBA_PORTSTATISTICS **,
struct vlib_adapter *);
int sysfs_getUnitsFromPort(struct vlib_port *);
void sysfs_waitForSgDev(char *);
static inline HBA_STATUS revalidateRepository(void)
{
if (!vlib_data.isLoaded)
return HBA_STATUS_ERROR;
if (!vlib_data.isValid) {
if (sysfs_createAndReadConfigAdapter() != HBA_STATUS_OK)
return HBA_STATUS_ERROR;
}
return HBA_STATUS_OK;
}
static inline int revalidatePorts(struct vlib_adapter *adapter)
{
if (0 == adapter->ports.allocated)
return sysfs_createAndReadConfigPorts(adapter);
return 0;
}
static inline int revalidateUnits(struct vlib_port *port)
{
if (0 == port->units.allocated)
return sysfs_getUnitsFromPort(port);
return 0;
}
#endif /*_VLIB_SYSFS_H_*/
block::allocated
size_t allocated
total number of elements in the array
Definition vlib.h:428
vlib_adapter
Represenation of an adapter in the library.
Definition vlib.h:474
vlib_adapter::ports
struct block ports
List of ports.
Definition vlib.h:478
vlib_data
Primary data structure used in the library.
Definition vlib.h:484
vlib_data::isValid
unsigned int isValid
Repositoy valid or not This flag is set for instance if a loss of events is detected.
Definition vlib.h:487
vlib_data::isLoaded
unsigned int isLoaded
Library loaded or not.
Definition vlib.h:485
vlib_port
Representation of a FC port in the library.
Definition vlib.h:443
vlib_port::units
struct block units
List of units.
Definition vlib.h:448
sysfs_getDiscoveredPortAttributes
HBA_STATUS sysfs_getDiscoveredPortAttributes(HBA_PORTATTRIBUTES **, struct vlib_port *)
Retrieve adapter attributes.
Definition vlib_sysfs.c:408
sysfs_createAndReadConfigPorts
HBA_STATUS sysfs_createAndReadConfigPorts(struct vlib_adapter *)
Read and store all discovered ports of an adapter.
Definition vlib_sysfs.c:226
sysfs_getUnitsFromPort
int sysfs_getUnitsFromPort(struct vlib_port *)
Get unit configuration information for a port.
Definition vlib_sysfs.c:310
sysfs_getPortStatistics
HBA_STATUS sysfs_getPortStatistics(HBA_PORTSTATISTICS **, struct vlib_adapter *)
Retrieve adapter port statistics.
Definition vlib_sysfs.c:595
sysfs_getAdapterAttributes
HBA_STATUS sysfs_getAdapterAttributes(HBA_ADAPTERATTRIBUTES **, struct vlib_adapter *)
Retrieve adapter attributes.
Definition vlib_sysfs.c:495
revalidateUnits
static int revalidateUnits(struct vlib_port *port)
Revalidate units of an adapter and port in the repository.
Definition vlib_sysfs.h:105
revalidateRepository
static HBA_STATUS revalidateRepository(void)
Check status of the repository, and possibly revalidate it.
Definition vlib_sysfs.h:59
revalidatePorts
static int revalidatePorts(struct vlib_adapter *adapter)
Revalidate ports of an adapter in the repository.
Definition vlib_sysfs.h:84
sysfs_getAdapterPortAttributes
HBA_STATUS sysfs_getAdapterPortAttributes(HBA_PORTATTRIBUTES **, struct vlib_adapter *)
Retrieve adapter attributes.
Definition vlib_sysfs.c:443
sysfs_createAndReadConfigAdapter
HBA_STATUS sysfs_createAndReadConfigAdapter()
Read all adapters from /sys/bus/ccw/drivers/zfcp and add them to the repository.
Definition vlib_sysfs.c:260