00001 /* 00002 * Copyright IBM Corp. 2008 00003 * All rights reserved. This program and the accompanying materials 00004 * are made available under the terms of the Common Public License v1.0 00005 * which accompanies this distribution, and is available at 00006 * http://www.ibm.com/developerworks/library/os-cpl.html 00007 * 00008 * Authors: Sven Schuetz <sven@de.ibm.com> 00009 * contains code from vlib_aux.h 00010 * by Andreas Herrmann and Stefan Voelkel 00011 * 00012 * File: vlib_sysfs.h 00013 * 00014 * Description: 00015 * Function declarations and inline functions that use the sysfs and call into 00016 * libsysfs. 00017 * 00018 */ 00019 00020 #ifndef _VLIB_SYSFS_H_ 00021 #define _VLIB_SYSFS_H_ 00022 00028 HBA_STATUS sysfs_createAndReadConfigPorts(struct vlib_adapter *); 00029 HBA_STATUS sysfs_createAndReadConfigAdapter(); 00030 HBA_STATUS sysfs_getDiscoveredPortAttributes(HBA_PORTATTRIBUTES **, 00031 struct vlib_port *); 00032 HBA_STATUS sysfs_getAdapterPortAttributes(HBA_PORTATTRIBUTES **, 00033 struct vlib_adapter *); 00034 HBA_STATUS sysfs_getPortStatistics(HBA_PORTSTATISTICS **, 00035 struct vlib_adapter *); 00036 int sysfs_getUnitsFromPort(struct vlib_port *); 00037 void sysfs_waitForSgDev(char *); 00038 00051 static inline HBA_STATUS revalidateRepository(void) 00052 { 00053 if (!vlib_data.isLoaded) { 00054 return HBA_STATUS_ERROR; 00055 } 00056 00057 if (!vlib_data.isValid) { 00058 if (sysfs_createAndReadConfigAdapter() != HBA_STATUS_OK) { 00059 return HBA_STATUS_ERROR; 00060 } 00061 } 00062 00063 return HBA_STATUS_OK; 00064 } 00065 00078 static inline int revalidatePorts(struct vlib_adapter *adapter) 00079 { 00080 if (0 == adapter->ports.allocated) { 00081 return sysfs_createAndReadConfigPorts(adapter); 00082 } 00083 00084 return 0; 00085 } 00086 00100 static inline int revalidateUnits(struct vlib_port *port) 00101 { 00102 if (0 == port->units.allocated) { 00103 return sysfs_getUnitsFromPort(port); 00104 } 00105 00106 return 0; 00107 } 00108 00109 #endif /*_VLIB_SYSFS_H_*/