"Fossies" - the Fresh Open Source Software Archive

Member "open-fcoe-3.19/libhbalinux/lib.c" (15 Apr 2015, 6245 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 "lib.c" 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 #define _XOPEN_SOURCE 500        /* for strptime() */
   20 #include "utils.h"
   21 #include "api_lib.h"
   22 #include "adapt_impl.h"
   23 #include "bind_impl.h"
   24 
   25 /**
   26  * Return the version of the SNIA HBA-API supported by this library.
   27  */
   28 static HBA_UINT32 get_library_version()
   29 {
   30     return HBA_LIBVERSION;
   31 }
   32 
   33 /*
   34  * When HBA_GetVendorLibraryAttributes() is called,
   35  * it does not dispatch to the library entry point at
   36  * .GetVendorLibraryAttributesHandler. Thus this
   37  * routine can never be entered. -[sma]
   38  */
   39 #if 0
   40 /**
   41  * Get the library attributes.
   42  * @param ap library attributes pointer.
   43  * @returns 0 or error code.
   44  */
   45 static HBA_STATUS get_vendor_lib_attrs(HBA_LIBRARYATTRIBUTES *ap)
   46 {
   47     memset(ap, 0, sizeof(*ap));
   48     if (strptime(BUILD_DATE, "%Y/%m/%d %T %Z", &ap->build_date) == NULL)
   49         memset(&ap->build_date, 0, sizeof(ap->build_date));
   50     strcpy(ap->VName, HBA_API_VENDOR);
   51     strcpy(ap->VVersion, HBA_API_VERSION);
   52     return HBA_STATUS_OK;
   53 }
   54 #endif
   55 
   56 /*
   57  * initialize the library after load.
   58  */
   59 static HBA_STATUS load_library(void)
   60 {
   61     adapter_init();
   62     return HBA_STATUS_OK;
   63 }
   64 
   65 static HBA_STATUS free_library(void)
   66 {
   67     adapter_shutdown();
   68     adapter_destroy_all();
   69     return HBA_STATUS_OK;
   70 }
   71 
   72 static HBA_ENTRYPOINTSV2 vendor_lib_entrypoints = {
   73     .GetVersionHandler =                       get_library_version,
   74     .LoadLibraryHandler =                      load_library,
   75     .FreeLibraryHandler =                      free_library,
   76     .GetNumberOfAdaptersHandler =              adapter_get_count,
   77     .GetAdapterNameHandler =                   adapter_get_name,
   78     .OpenAdapterHandler =                      adapter_open,
   79     .CloseAdapterHandler =                     adapter_close,
   80     .GetAdapterAttributesHandler =             adapter_get_attr,
   81     .GetAdapterPortAttributesHandler =         adapter_get_port_attr,
   82     .GetPortStatisticsHandler =                get_port_statistics,
   83     .GetDiscoveredPortAttributesHandler =      adapter_get_rport_attr,
   84 
   85     .GetPortAttributesByWWNHandler =           NULL,
   86                     /* adapter_get_port_attr_by_wwn, */
   87     /* Next function deprecated but still supported */
   88     .SendCTPassThruHandler =                   NULL,
   89     .RefreshInformationHandler =               NULL,
   90     .ResetStatisticsHandler =                  NULL,
   91     /* Next function deprecated but still supported */
   92     .GetFcpTargetMappingHandler =              get_binding_target_mapping_v1,
   93     /* Next function depricated but still supported */
   94     .GetFcpPersistentBindingHandler =          NULL,
   95     .GetEventBufferHandler =                   NULL,
   96     .SetRNIDMgmtInfoHandler =                  NULL,
   97     .GetRNIDMgmtInfoHandler =                  NULL,
   98     /* Next function deprecated but still supported */
   99     .SendRNIDHandler =                         NULL,
  100     .ScsiInquiryHandler =                      scsi_inquiry_v1,
  101     .ReportLUNsHandler =                       scsi_report_luns_v1,
  102     .ReadCapacityHandler =                     scsi_read_capacity_v1,
  103 
  104     /* V2 handlers */
  105     .OpenAdapterByWWNHandler =                 NULL,
  106                     /* adapter_open_by_wwn, */
  107     .GetFcpTargetMappingV2Handler =            get_binding_target_mapping_v2,
  108     .SendCTPassThruV2Handler =                 NULL,
  109     .RefreshAdapterConfigurationHandler =      NULL,
  110     .GetBindingCapabilityHandler =             NULL,
  111                     /* get_binding_capability, */
  112     .GetBindingSupportHandler =                NULL,
  113                     /* get_binding_support, */
  114     .SetBindingSupportHandler =                NULL,
  115                     /* set_binding_support, */
  116     .SetPersistentBindingV2Handler =           NULL,
  117     .GetPersistentBindingV2Handler =           NULL,
  118     .RemovePersistentBindingHandler =          NULL,
  119     .RemoveAllPersistentBindingsHandler =      NULL,
  120     .SendRNIDV2Handler =                       NULL,
  121     .ScsiInquiryV2Handler =                    scsi_inquiry_v2,
  122     .ScsiReportLUNsV2Handler =                 scsi_report_luns_v2,
  123     .ScsiReadCapacityV2Handler =               scsi_read_capacity_v2,
  124     .GetVendorLibraryAttributesHandler =       NULL,
  125                     /* get_vendor_lib_attrs, */
  126     .RemoveCallbackHandler =                   NULL,
  127     .RegisterForAdapterAddEventsHandler =      NULL,
  128     .RegisterForAdapterEventsHandler =         NULL,
  129     .RegisterForAdapterPortEventsHandler =     NULL,
  130     .RegisterForAdapterPortStatEventsHandler = NULL,
  131     .RegisterForTargetEventsHandler =          NULL,
  132     .RegisterForLinkEventsHandler =            NULL,
  133     .SendRPLHandler =                          NULL,
  134     .SendRPSHandler =                          NULL,
  135     .SendSRLHandler =                          NULL,
  136     .SendLIRRHandler =                         NULL,
  137     .GetFC4StatisticsHandler =                 get_port_fc4_statistics,
  138     .GetFCPStatisticsHandler =                 NULL,
  139     .SendRLSHandler =                          NULL,
  140 };
  141 
  142 /**
  143  * Function called by a version 1 common HBAAPI library to get our entry points.
  144  *
  145  * @arg ep pointer to entrypoints structure where we store our
  146  *  function pointers.
  147  * @returns HBA_STATUS.
  148  */
  149 HBA_STATUS HBA_RegisterLibrary(HBA_ENTRYPOINTS *ep)
  150 {
  151     memcpy(ep, &vendor_lib_entrypoints, sizeof(HBA_ENTRYPOINTS));
  152     return HBA_STATUS_OK;
  153 }
  154 
  155 /**
  156  * Function called by the common HBAAPI library to get our entry points.
  157  *
  158  * @arg ep pointer to entrypoints structure where we store our
  159  *  function pointers.
  160  * @returns HBA_STATUS.
  161  */
  162 HBA_STATUS HBA_RegisterLibraryV2(HBA_ENTRYPOINTSV2 *ep)
  163 {
  164     *ep = vendor_lib_entrypoints;  /* structure copy */
  165     return HBA_STATUS_OK;
  166 }
  167