"Fossies" - the Fresh Open Source Software Archive

Member "open-fcoe-3.19/libhbalinux/adapt_impl.h" (15 Apr 2015, 6168 Bytes) of package /linux/misc/open-fcoe-3.19.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "adapt_impl.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2  * Copyright (c) 2008, Intel Corporation.
    3  *
    4  * This program is free software; you can redistribute it and/or modify it
    5  * under the terms and conditions of the GNU Lesser General Public License,
    6  * version 2.1, as published by the Free Software Foundation.
    7  *
    8  * This program is distributed in the hope it will be useful, but WITHOUT
    9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
   11  * for more details.
   12  *
   13  * You should have received a copy of the GNU Lesser General Public License
   14  * along with this program; if not, write to the Free Software Foundation, Inc.,
   15  * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
   16  *
   17  */
   18 
   19 #ifndef _ADAPT_IMPL_H_
   20 #define _ADAPT_IMPL_H_
   21 
   22 #define SYSFS_HOST_DIR     "/sys/class/fc_host"
   23 #define SYSFS_HBA_DIR      "/sys/class/net"
   24 #define SYSFS_LUN_DIR      "/sys/class/scsi_device"
   25 #define SYSFS_MODULE       "/driver/module"
   26 #define SYSFS_MODULE_VER   "driver/module/version"
   27 #define SYSFS_RPORT_ROOT       "/sys/class/fc_remote_ports"
   28 #define SYSFS_RPORT_DIR        "rport-%u:%u-%u" /* host, chan, rport */
   29 
   30 struct hba_info {
   31     u_int32_t   domain;
   32     u_int32_t   bus;
   33     u_int32_t   dev;
   34     u_int32_t   func;
   35     u_int32_t   vendor_id;
   36     u_int32_t   subsystem_vendor_id;
   37     u_int32_t   subsystem_device_id;
   38     u_int32_t   device_id;
   39     u_int32_t   device_class;
   40     u_int32_t   irq;
   41     char        Manufacturer[64];
   42     char        SerialNumber[64];
   43     char        Model[256];
   44     char        ModelDescription[256];
   45     char        HardwareVersion[256];
   46     char        OptionROMVersion[256];
   47     char        FirmwareVersion[256];
   48     u_int32_t   VendorSpecificID;
   49     u_int32_t   NumberOfPorts;
   50 };
   51 
   52 #define MAX_DRIVER_NAME_LEN 20
   53 #define ARRAY_SIZE(a)       (sizeof(a)/sizeof((a)[0]))
   54 
   55 HBA_STATUS sysfs_get_port_stats(char *dir, HBA_PORTSTATISTICS *sp);
   56 HBA_STATUS sysfs_get_port_fc4stats(char *dir, HBA_FC4STATISTICS *fc4sp);
   57 
   58 extern struct sa_nameval port_states_table[];
   59 extern struct sa_nameval port_speeds_table[];
   60 extern void adapter_scan(void);
   61 extern int sys_read_wwn(const char *, const char *, HBA_WWN *);
   62 extern HBA_STATUS find_pci_device(struct hba_info *);
   63 
   64 /*
   65  * per-adapter interface.
   66  */
   67 
   68 /*
   69  * Information about a particular adapter.
   70  */
   71 struct adapter_info {
   72     u_int32_t               ad_index;       /* adapter's library index */
   73     u_int32_t               ad_kern_index;  /* adapter's kernel index */
   74     const char              *ad_name;       /* adapter driver name */
   75     struct sa_table         ad_ports;       /* table of ports */
   76     u_int32_t               ad_port_count;  /* adapter's number of ports */
   77     HBA_ADAPTERATTRIBUTES   ad_attr;        /* HBA-API attributes */
   78 };
   79 
   80 /*
   81  * Information about a port on an adapter or a discovered remote port.
   82  */
   83 struct port_info {
   84     struct adapter_info     *ap_adapt;
   85     u_int32_t               ap_index;
   86     u_int32_t               ap_disc_index;  /* discovered port index */
   87     u_int32_t               ap_scsi_target; /* SCSI target index (rports) */
   88     u_int32_t               ap_kern_hba;    /* kernel HBA index (rports) */
   89     struct sa_table         ap_rports;      /* discovered ports */
   90     HBA_PORTATTRIBUTES      ap_attr;        /* HBA-API port attributes */
   91     char                    host_dir[80];   /* sysfs directory save area */
   92 };
   93 
   94 /*
   95  * Internal functions.
   96  */
   97 HBA_UINT32 adapter_get_count(void);
   98 HBA_STATUS adapter_get_name(HBA_UINT32 index, char *);
   99 struct port_info *adapter_get_port_by_wwn(HBA_HANDLE, HBA_WWN, int *countp);
  100 HBA_STATUS adapter_create(struct adapter_info *);
  101 void adapter_destroy(struct adapter_info *);
  102 void adapter_destroy_all(void);
  103 struct adapter_info *adapter_open_handle(HBA_HANDLE);
  104 struct port_info *adapter_get_port(HBA_HANDLE, HBA_UINT32 port);
  105 struct port_info *adapter_get_rport(HBA_HANDLE, HBA_UINT32, HBA_UINT32);
  106 struct port_info *adapter_get_rport_n(HBA_HANDLE, HBA_UINT32, HBA_UINT32);
  107 struct port_info *adapter_get_rport_target(HBA_HANDLE, HBA_UINT32, HBA_UINT32);
  108 struct port_info *adapter_get_rport_by_wwn(struct port_info *, HBA_WWN);
  109 struct port_info *adapter_get_rport_by_fcid(struct port_info *, fc_fid_t);
  110 void get_rport_info(struct port_info *);
  111 void sg_get_dev_id(const char *name, char *buf, size_t result_len);
  112 void copy_wwn(HBA_WWN *dest, fc_wwn_t src);
  113 int is_wwn_nonzero(HBA_WWN *wwn);
  114 HBA_STATUS sg_issue_read_capacity(const char *, void *, HBA_UINT32 *,
  115             HBA_UINT8 *, void *, HBA_UINT32 *);
  116 HBA_STATUS sg_issue_report_luns(const char *, void *, HBA_UINT32 *,
  117             HBA_UINT8 *, void *, HBA_UINT32 *);
  118 
  119 /*
  120  * Library functions.
  121  */
  122 HBA_HANDLE adapter_open(char *name);
  123 HBA_STATUS adapter_open_by_wwn(HBA_HANDLE *, HBA_WWN);
  124 void adapter_close(HBA_HANDLE);
  125 HBA_STATUS adapter_get_attr(HBA_HANDLE, HBA_ADAPTERATTRIBUTES *);
  126 HBA_STATUS adapter_get_port_attr(HBA_HANDLE, HBA_UINT32 port,
  127                 HBA_PORTATTRIBUTES *);
  128 HBA_STATUS adapter_get_port_attr_by_wwn(HBA_HANDLE, HBA_WWN,
  129                 HBA_PORTATTRIBUTES *);
  130 HBA_STATUS adapter_get_rport_attr(HBA_HANDLE, HBA_UINT32 port,
  131                 HBA_UINT32 rport, HBA_PORTATTRIBUTES *);
  132 HBA_STATUS get_port_statistics(HBA_HANDLE, HBA_UINT32 port,
  133                 HBA_PORTSTATISTICS *);
  134 HBA_STATUS get_port_fc4_statistics(HBA_HANDLE, HBA_WWN,
  135                 HBA_UINT8 fc4_type, HBA_FC4STATISTICS *);
  136 HBA_STATUS scsi_read_capacity_v1(HBA_HANDLE, HBA_WWN, HBA_UINT64,
  137                 void *, HBA_UINT32, void *, HBA_UINT32);
  138 HBA_STATUS scsi_read_capacity_v2(HBA_HANDLE, HBA_WWN, HBA_WWN,
  139             HBA_UINT64, void *, HBA_UINT32 *, HBA_UINT8 *,
  140             void *, HBA_UINT32 *);
  141 HBA_STATUS scsi_inquiry_v1(HBA_HANDLE, HBA_WWN, HBA_UINT64, HBA_UINT8,
  142             HBA_UINT32, void *, HBA_UINT32, void *, HBA_UINT32);
  143 HBA_STATUS scsi_inquiry_v2(HBA_HANDLE, HBA_WWN, HBA_WWN, HBA_UINT64,
  144             HBA_UINT8, HBA_UINT8, void *, HBA_UINT32 *,
  145             HBA_UINT8 *, void *, HBA_UINT32 *);
  146 HBA_STATUS scsi_report_luns_v1(HBA_HANDLE, HBA_WWN,
  147             void *, HBA_UINT32, void *, HBA_UINT32);
  148 HBA_STATUS scsi_report_luns_v2(HBA_HANDLE, HBA_WWN, HBA_WWN,
  149             void *, HBA_UINT32 *, HBA_UINT8 *,
  150             void *, HBA_UINT32 *);
  151 HBA_STATUS sg_issue_inquiry(const char *, HBA_UINT8, HBA_UINT8,
  152         void *, HBA_UINT32 *, HBA_UINT8 *, void *, HBA_UINT32 *);
  153 
  154 void adapter_init(void);
  155 void adapter_shutdown(void);
  156 
  157 /* struct port_stats; */
  158 
  159 #endif /* _ADAPT_IMPL_H_ */