iPXE
Data Structures | Defines | Enumerations | Functions | Variables
fc.h File Reference

Fibre Channel. More...

#include <stdint.h>
#include <ipxe/refcnt.h>
#include <ipxe/list.h>
#include <ipxe/tables.h>
#include <ipxe/interface.h>
#include <ipxe/retry.h>
#include <ipxe/socket.h>

Go to the source code of this file.

Data Structures

struct  fc_name
 A Fibre Channel name. More...
struct  fc_port_id
 A Fibre Channel port identifier. More...
struct  sockaddr_fc
 Fibre Channel socket address. More...
struct  fc_link_state
 A Fibre Channel link state nonitor. More...
struct  fc_frame_header
 A Fibre Channel Frame Header. More...
struct  fc_responder
 A Fibre Channel responder. More...
struct  fc_port
 A Fibre Channel port. More...
struct  fc_peer
 A Fibre Channel peer. More...
struct  fc_ulp
 A Fibre Channel upper-layer protocol. More...
struct  fc_ulp_user
 A Fibre Channel upper-layer protocol user. More...

Defines

#define FC_NAME_STRLEN   23 /* "xx:xx:xx:xx:xx:xx:xx:xx" */
 Length of Fibre Channel name text.
#define FC_PORT_ID_STRLEN   9 /* "xx.xx.xx" */
 Length of Fibre Channel port identifier next.
#define FC_LINK_RETRY_DELAY   ( 2 * TICKS_PER_SEC )
 Delay between failed link-up attempts.
#define FC_R_CTL_ROUTING_MASK   0xf0
 Fibre Channel Routing Control Routing mask.
#define FC_R_CTL_INFO_MASK   0x07
 Fibre Channel Routing Control Information mask.
#define FC_RX_ID_UNKNOWN   0xffff
 Responder exchange identifier used before first response.
#define FC_RESPONDERS   __table ( struct fc_responder, "fc_responders" )
 Fibre Channel responder table.
#define __fc_responder   __table_entry ( FC_RESPONDERS, 01 )
 Declare a Fibre Channel responder.

Enumerations

enum  fc_r_ctl_routing {
  FC_R_CTL_DATA = 0x00, FC_R_CTL_ELS = 0x20, FC_R_CTL_FC4_LINK = 0x30, FC_R_CTL_VIDEO = 0x40,
  FC_R_CTL_EH = 0x50, FC_R_CTL_BLS = 0x80, FC_R_CTL_LINK_CTRL = 0xc0, FC_R_CTL_EXT_ROUTE = 0xf0
}
 Fibre Channel Routing Control Routing. More...
enum  fc_r_ctl_info {
  FC_R_CTL_UNCAT = 0x00, FC_R_CTL_SOL_DATA = 0x01, FC_R_CTL_UNSOL_CTRL = 0x02, FC_R_CTL_SOL_CTRL = 0x03,
  FC_R_CTL_UNSOL_DATA = 0x04, FC_R_CTL_DATA_DESC = 0x05, FC_R_CTL_UNSOL_CMD = 0x06, FC_R_CTL_CMD_STAT = 0x07
}
 Fibre Channel Routing Control Information. More...
enum  fc_type { FC_TYPE_BLS = 0x00, FC_TYPE_ELS = 0x01, FC_TYPE_FCP = 0x08, FC_TYPE_CT = 0x20 }
 Fibre Channel Data Structure Type. More...
enum  fc_f_ctl_es {
  FC_F_CTL_ES_RESPONDER = 0x80, FC_F_CTL_ES_RECIPIENT = 0x40, FC_F_CTL_ES_FIRST = 0x20, FC_F_CTL_ES_LAST = 0x10,
  FC_F_CTL_ES_END = 0x08, FC_F_CTL_ES_TRANSFER = 0x01
}
 Fibre Channel Frame Control - Exchange and Sequence. More...
enum  fc_f_ctl_misc { FC_F_CTL_MISC_REL_OFF = 0x08 }
 Fibre Channel Frame Control - Miscellaneous. More...
enum  fc_port_flags { FC_PORT_HAS_FABRIC = 0x0001, FC_PORT_HAS_NS = 0x0002 }
 Fibre Channel port flags. More...
enum  fc_ulp_flags { FC_ULP_ORIGINATED_LOGIN_OK = 0x0001 }
 Fibre Channel upper-layer protocol flags. More...

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
const char * fc_id_ntoa (const struct fc_port_id *id)
 Format Fibre Channel port ID.
int fc_id_aton (const char *id_text, struct fc_port_id *id)
 Parse Fibre Channel port ID.
const char * fc_ntoa (const struct fc_name *wwn)
 Format Fibre Channel WWN.
int fc_aton (const char *wwn_text, struct fc_name *wwn)
 Parse Fibre Channel WWN.
struct sockaddrfc_fill_sockaddr (struct sockaddr_fc *sa_fc, struct fc_port_id *id)
 Fill Fibre Channel socket address.
static int fc_link_ok (struct fc_link_state *link)
 Check Fibre Channel link state.
int fc_xchg_originate (struct interface *parent, struct fc_port *port, struct fc_port_id *peer_port_id, unsigned int type)
 Originate a new Fibre Channel exchange.
static struct fc_portfc_port_get (struct fc_port *port)
 Get reference to Fibre Channel port.
static void fc_port_put (struct fc_port *port)
 Drop reference to Fibre Channel port.
int fc_port_login (struct fc_port *port, struct fc_port_id *port_id, const struct fc_name *link_node_wwn, const struct fc_name *link_port_wwn, int has_fabric)
 Log in Fibre Channel port.
void fc_port_logout (struct fc_port *port, int rc)
 Log out Fibre Channel port.
int fc_port_open (struct interface *transport, const struct fc_name *node_wwn, const struct fc_name *port_wwn, const char *name)
 Create Fibre Channel port.
struct fc_portfc_port_find (const char *name)
 Find Fibre Channel port by name.
static struct fc_peerfc_peer_get (struct fc_peer *peer)
 Get reference to Fibre Channel peer.
static void fc_peer_put (struct fc_peer *peer)
 Drop reference to Fibre Channel peer.
struct fc_peerfc_peer_get_wwn (const struct fc_name *port_wwn)
 Get Fibre Channel peer by node name.
struct fc_peerfc_peer_get_port_id (struct fc_port *port, const struct fc_port_id *peer_port_id)
 Get Fibre Channel peer by port ID.
int fc_peer_login (struct fc_peer *peer, struct fc_port *port, struct fc_port_id *port_id)
 Log in Fibre Channel peer.
void fc_peer_logout (struct fc_peer *peer, int rc)
 Log out Fibre Channel peer.
static struct fc_ulpfc_ulp_get (struct fc_ulp *ulp)
 Get reference to Fibre Channel upper-layer protocol.
static void fc_ulp_put (struct fc_ulp *ulp)
 Drop reference to Fibre Channel upper-layer protocol.
static struct fc_ulp_userfc_ulp_user_get (struct fc_ulp_user *user)
 Get reference to Fibre Channel upper-layer protocol user.
static void fc_ulp_user_put (struct fc_ulp_user *user)
 Drop reference to Fibre Channel upper-layer protocol user.
static void fc_ulp_user_init (struct fc_ulp_user *user, void(*examine)(struct fc_ulp_user *user), struct refcnt *refcnt)
 Initialise Fibre Channel upper-layer protocol user.
struct fc_ulpfc_ulp_get_wwn_type (const struct fc_name *port_wwn, unsigned int type)
 Get Fibre Channel upper-layer protocol by port name and type.
struct fc_ulpfc_ulp_get_port_id_type (struct fc_port *port, const struct fc_port_id *peer_port_id, unsigned int type)
 Get Fibre Channel upper-layer protocol by port ID and type.
void fc_ulp_attach (struct fc_ulp *ulp, struct fc_ulp_user *user)
 Attach Fibre Channel upper-layer protocol user.
void fc_ulp_detach (struct fc_ulp_user *user)
 Detach Fibre Channel upper-layer protocol user.
int fc_ulp_login (struct fc_ulp *ulp, const void *param, size_t param_len, int originated)
 Log in Fibre Channel upper-layer protocol.
void fc_ulp_logout (struct fc_ulp *ulp, int rc)
 Log out Fibre Channel upper-layer protocol.

Variables

struct fc_port_id fc_empty_port_id
 Unassigned port ID.
struct fc_port_id fc_f_port_id
 F_Port contoller port ID.
struct fc_port_id fc_gs_port_id
 Generic services port ID.
struct fc_port_id fc_ptp_low_port_id
 Point-to-point low port ID.
struct fc_port_id fc_ptp_high_port_id
 Point-to-point high port ID.
struct list_head fc_ports
struct list_head fc_peers

Detailed Description

Fibre Channel.

Definition in file fc.h.


Define Documentation

#define FC_NAME_STRLEN   23 /* "xx:xx:xx:xx:xx:xx:xx:xx" */

Length of Fibre Channel name text.

Definition at line 34 of file fc.h.

Referenced by fc_ntoa(), and fcp_parse_uri().

#define FC_PORT_ID_STRLEN   9 /* "xx.xx.xx" */

Length of Fibre Channel port identifier next.

Definition at line 42 of file fc.h.

Referenced by fc_id_ntoa().

#define FC_LINK_RETRY_DELAY   ( 2 * TICKS_PER_SEC )

Delay between failed link-up attempts.

Definition at line 86 of file fc.h.

Referenced by fc_link_err(), and fc_link_expired().

#define FC_R_CTL_ROUTING_MASK   0xf0

Fibre Channel Routing Control Routing mask.

Definition at line 172 of file fc.h.

#define FC_R_CTL_INFO_MASK   0x07

Fibre Channel Routing Control Information mask.

Definition at line 187 of file fc.h.

Referenced by fc_xchg_rx().

#define FC_RX_ID_UNKNOWN   0xffff

Responder exchange identifier used before first response.

Definition at line 213 of file fc.h.

Referenced by fc_xchg_create().

#define FC_RESPONDERS   __table ( struct fc_responder, "fc_responders" )

Fibre Channel responder table.

Definition at line 239 of file fc.h.

Referenced by fc_xchg_respond().

Declare a Fibre Channel responder.

Definition at line 242 of file fc.h.


Enumeration Type Documentation

Fibre Channel Routing Control Routing.

Enumerator:
FC_R_CTL_DATA 

Device Data.

FC_R_CTL_ELS 

Extended Link Services.

FC_R_CTL_FC4_LINK 

FC-4 Link Data.

FC_R_CTL_VIDEO 

Video Data.

FC_R_CTL_EH 

Extended Headers.

FC_R_CTL_BLS 

Basic Link Services.

FC_R_CTL_LINK_CTRL 

Link Control.

FC_R_CTL_EXT_ROUTE 

Extended Routing.

Definition at line 160 of file fc.h.

                      {
        FC_R_CTL_DATA = 0x00,           /**< Device Data */
        FC_R_CTL_ELS = 0x20,            /**< Extended Link Services */
        FC_R_CTL_FC4_LINK = 0x30,       /**< FC-4 Link Data */
        FC_R_CTL_VIDEO = 0x40,          /**< Video Data */
        FC_R_CTL_EH = 0x50,             /**< Extended Headers */
        FC_R_CTL_BLS = 0x80,            /**< Basic Link Services */
        FC_R_CTL_LINK_CTRL = 0xc0,      /**< Link Control */
        FC_R_CTL_EXT_ROUTE = 0xf0,      /**< Extended Routing */
};

Fibre Channel Routing Control Information.

Enumerator:
FC_R_CTL_UNCAT 

Uncategorized.

FC_R_CTL_SOL_DATA 

Solicited Data.

FC_R_CTL_UNSOL_CTRL 

Unsolicited Control.

FC_R_CTL_SOL_CTRL 

Solicited Control.

FC_R_CTL_UNSOL_DATA 

Unsolicited Data.

FC_R_CTL_DATA_DESC 

Data Descriptor.

FC_R_CTL_UNSOL_CMD 

Unsolicited Command.

FC_R_CTL_CMD_STAT 

Command Status.

Definition at line 175 of file fc.h.

                   {
        FC_R_CTL_UNCAT = 0x00,          /**< Uncategorized */
        FC_R_CTL_SOL_DATA = 0x01,       /**< Solicited Data */
        FC_R_CTL_UNSOL_CTRL = 0x02,     /**< Unsolicited Control */
        FC_R_CTL_SOL_CTRL = 0x03,       /**< Solicited Control */
        FC_R_CTL_UNSOL_DATA = 0x04,     /**< Unsolicited Data */
        FC_R_CTL_DATA_DESC = 0x05,      /**< Data Descriptor */
        FC_R_CTL_UNSOL_CMD = 0x06,      /**< Unsolicited Command */
        FC_R_CTL_CMD_STAT = 0x07,       /**< Command Status */
};
enum fc_type

Fibre Channel Data Structure Type.

Enumerator:
FC_TYPE_BLS 

Basic Link Service.

FC_TYPE_ELS 

Extended Link Service.

FC_TYPE_FCP 

Fibre Channel Protocol.

FC_TYPE_CT 

Common Transport.

Definition at line 190 of file fc.h.

             {
        FC_TYPE_BLS = 0x00,             /**< Basic Link Service */
        FC_TYPE_ELS = 0x01,             /**< Extended Link Service */
        FC_TYPE_FCP = 0x08,             /**< Fibre Channel Protocol */
        FC_TYPE_CT  = 0x20,             /**< Common Transport */
};

Fibre Channel Frame Control - Exchange and Sequence.

Enumerator:
FC_F_CTL_ES_RESPONDER 

Responder of Exchange.

FC_F_CTL_ES_RECIPIENT 

Sequence Recipient.

FC_F_CTL_ES_FIRST 

First Sequence of Exchange.

FC_F_CTL_ES_LAST 

Last Sequence of Exchange.

FC_F_CTL_ES_END 

Last Data Frame of Sequence.

FC_F_CTL_ES_TRANSFER 

Transfer Sequence Initiative.

Definition at line 198 of file fc.h.

                 {
        FC_F_CTL_ES_RESPONDER = 0x80,   /**< Responder of Exchange */
        FC_F_CTL_ES_RECIPIENT = 0x40,   /**< Sequence Recipient */
        FC_F_CTL_ES_FIRST = 0x20,       /**< First Sequence of Exchange */
        FC_F_CTL_ES_LAST = 0x10,        /**< Last Sequence of Exchange */
        FC_F_CTL_ES_END = 0x08,         /**< Last Data Frame of Sequence */
        FC_F_CTL_ES_TRANSFER = 0x01,    /**< Transfer Sequence Initiative */
};

Fibre Channel Frame Control - Miscellaneous.

Enumerator:
FC_F_CTL_MISC_REL_OFF 

Relative Offset Present.

Definition at line 208 of file fc.h.

                   {
        FC_F_CTL_MISC_REL_OFF = 0x08,   /**< Relative Offset Present */
};

Fibre Channel port flags.

Enumerator:
FC_PORT_HAS_FABRIC 

Port is attached to a fabric.

FC_PORT_HAS_NS 

Port is logged in to a name server.

Definition at line 290 of file fc.h.

                   {
        /** Port is attached to a fabric */
        FC_PORT_HAS_FABRIC = 0x0001,
        /** Port is logged in to a name server */
        FC_PORT_HAS_NS = 0x0002,
};

Fibre Channel upper-layer protocol flags.

Enumerator:
FC_ULP_ORIGINATED_LOGIN_OK 

A login originated by us has succeeded.

Definition at line 447 of file fc.h.

                  {
        /** A login originated by us has succeeded */
        FC_ULP_ORIGINATED_LOGIN_OK = 0x0001,
};

Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
const char* fc_id_ntoa ( const struct fc_port_id id)

Format Fibre Channel port ID.

Parameters:
idFibre Channel port ID
Return values:
id_textPort ID text

Definition at line 92 of file fc.c.

References fc_port_id::bytes, FC_PORT_ID_STRLEN, and snprintf().

Referenced by fc_els_flogi_rx(), fc_els_logo_rx_request(), fc_els_plogi_rx(), fc_ns_query_deliver(), fc_peer_login(), fc_port_deliver(), fc_port_login(), fc_xchg_originate(), fc_xchg_respond(), fcels(), fcpeerstat(), and fcportstat().

                                                        {
        static char id_text[ FC_PORT_ID_STRLEN + 1 /* NUL */ ];

        snprintf ( id_text, sizeof ( id_text ), "%02x.%02x.%02x",
                   id->bytes[0], id->bytes[1], id->bytes[2] );
        return id_text;
}
int fc_id_aton ( const char *  id_text,
struct fc_port_id id 
)

Parse Fibre Channel port ID.

Parameters:
id_textPort ID text
Return values:
idFibre Channel port ID
rcReturn status code

Definition at line 107 of file fc.c.

References fc_port_id::bytes, EINVAL, and strtoul().

Referenced by parse_fc_port_id().

                                                              {
        char *ptr = ( ( char * ) id_text );
        unsigned int i = 0;

        while ( 1 ) {
                id->bytes[i++] = strtoul ( ptr, &ptr, 16 );
                if ( i == sizeof ( id->bytes ) )
                        return ( ( *ptr == '\0' ) ? 0 : -EINVAL );
                if ( *ptr != '.' )
                        return -EINVAL;
                ptr++;
        }
}
const char* fc_ntoa ( const struct fc_name wwn)

Format Fibre Channel WWN.

Parameters:
wwnFibre Channel WWN
Return values:
wwn_textWWN text

Definition at line 127 of file fc.c.

References fc_name::bytes, FC_NAME_STRLEN, and snprintf().

Referenced by fc_els_flogi_rx(), fc_els_logo_rx_request(), fc_els_plogi_rx(), fc_ns_query(), fc_ns_query_deliver(), fc_peer_close(), fc_peer_create(), fc_peer_examine(), fc_peer_login(), fc_peer_logout(), fc_peer_plogi(), fc_port_login(), fc_port_open(), fc_ulp_close(), fc_ulp_create(), fc_ulp_examine(), fc_ulp_login(), fc_ulp_logout(), fcoe_probe(), fcpdev_open(), fcpeerstat(), and fcportstat().

                                                   {
        static char wwn_text[ FC_NAME_STRLEN + 1 /* NUL */ ];

        snprintf ( wwn_text, sizeof ( wwn_text ),
                   "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
                   wwn->bytes[0], wwn->bytes[1], wwn->bytes[2], wwn->bytes[3],
                   wwn->bytes[4], wwn->bytes[5], wwn->bytes[6], wwn->bytes[7] );
        return wwn_text;
}
int fc_aton ( const char *  wwn_text,
struct fc_name wwn 
)

Parse Fibre Channel WWN.

Parameters:
wwn_textWWN text
Return values:
wwnFibre Channel WWN
rcReturn status code

Definition at line 144 of file fc.c.

References fc_name::bytes, EINVAL, and strtoul().

Referenced by fcp_parse_uri().

                                                          {
        char *ptr = ( ( char * ) wwn_text );
        unsigned int i = 0;

        while ( 1 ) {
                wwn->bytes[i++] = strtoul ( ptr, &ptr, 16 );
                if ( i == sizeof ( wwn->bytes ) )
                        return ( ( *ptr == '\0' ) ? 0 : -EINVAL );
                if ( *ptr != ':' )
                        return -EINVAL;
                ptr++;
        }
}
struct sockaddr* fc_fill_sockaddr ( struct sockaddr_fc sa_fc,
struct fc_port_id id 
) [read]

Fill Fibre Channel socket address.

Parameters:
sa_fcFibre Channel socket address to fill in
idFibre Channel port ID
Return values:
saSocket address

Definition at line 165 of file fc.c.

References AF_FC, container_of, fc, memcpy(), memset(), sockaddr_fc::sfc_family, sockaddr_fc::sfc_port_id, and u.

Referenced by fc_els_tx(), and fc_xchg_rx().

                                                             {
        union {
                struct sockaddr sa;
                struct sockaddr_fc fc;
        } *u = container_of ( sa_fc, typeof ( *u ), fc );

        memset ( sa_fc, 0, sizeof ( *sa_fc ) );
        sa_fc->sfc_family = AF_FC;
        memcpy ( &sa_fc->sfc_port_id, id, sizeof ( sa_fc->sfc_port_id ) );
        return &u->sa;
}
static int fc_link_ok ( struct fc_link_state link) [inline, static]

Check Fibre Channel link state.

Parameters:
linkFibre Channel link state monitor
Return values:
link_upLink is up

Definition at line 108 of file fc.h.

Referenced by fc_els_plogi_rx(), fc_els_prli_rx(), fc_els_prli_tx(), fc_peer_examine(), fc_peer_login(), fc_peer_logout(), fc_port_close(), fc_port_examine(), fc_port_login(), fc_port_window_changed(), fc_ulp_examine(), fc_ulp_login(), fc_ulp_logout(), fcels_exec(), fcpdev_examine(), fcpdev_identify_device(), fcpdev_window(), fcpeerstat(), and fcportstat().

                                          {
        return ( link->rc == 0 );
}
int fc_xchg_originate ( struct interface parent,
struct fc_port port,
struct fc_port_id peer_port_id,
unsigned int  type 
)

Originate a new Fibre Channel exchange.

Parameters:
parentInterface to which to attach
portFibre Channel port
peer_port_idPeer port ID
Return values:
xchg_idExchange ID, or negative error

Definition at line 728 of file fc.c.

References DBGC2, ENOMEM, fc_id_ntoa(), fc_xchg_create(), FC_XCHG_ORIGINATOR, FC_XCHG_SEQ_FIRST, FC_XCHG_SEQ_INITIATIVE, fc_exchange::flags, intf_plug_plug(), fc_port::name, fc_exchange::peer_port_id, fc_exchange::type, fc_exchange::ulp, and fc_exchange::xchg_id.

Referenced by fc_els_step(), fc_ns_query_step(), and fcpdev_scsi_command().

                                                                             {
        struct fc_exchange *xchg;

        /* Allocate and initialise structure */
        xchg = fc_xchg_create ( port, peer_port_id, type );
        if ( ! xchg )
                return -ENOMEM;
        xchg->flags = ( FC_XCHG_ORIGINATOR | FC_XCHG_SEQ_INITIATIVE |
                        FC_XCHG_SEQ_FIRST );

        DBGC2 ( port, "FCXCHG %s/%04x originating to %s (type %02x)\n",
                port->name, xchg->xchg_id, fc_id_ntoa ( &xchg->peer_port_id ),
                xchg->type );

        /* Attach to parent interface and return */
        intf_plug_plug ( &xchg->ulp, parent );
        return xchg->xchg_id;
}
static struct fc_port* fc_port_get ( struct fc_port port) [static, read]

Get reference to Fibre Channel port.

Parameters:
portFibre Channel port
Return values:
portFibre Channel port

Definition at line 304 of file fc.h.

References port, and ref_get.

Referenced by fc_els_create(), fc_ns_query(), fc_peer_login(), and fc_xchg_create().

                                     {
        ref_get ( &port->refcnt );
        return port;
}
static void fc_port_put ( struct fc_port port) [inline, static]

Drop reference to Fibre Channel port.

Parameters:
portFibre Channel port

Definition at line 315 of file fc.h.

References ref_put.

Referenced by fc_els_free(), fc_ns_query_free(), fc_peer_logout(), and fc_xchg_free().

                                     {
        ref_put ( &port->refcnt );
}
int fc_port_login ( struct fc_port port,
struct fc_port_id port_id,
const struct fc_name link_node_wwn,
const struct fc_name link_port_wwn,
int  has_fabric 
)

Log in Fibre Channel port.

Parameters:
portFibre Channel port
port_idLocal port ID
link_node_wwnLink node name
link_port_wwnLink port name
has_fabricLink is to a fabric
Return values:
rcReturn status code

Definition at line 941 of file fc.c.

References DBGC, ECANCELED, fc_els_plogi(), fc_id_ntoa(), fc_link_examine(), fc_link_ok(), fc_link_up(), fc_ntoa(), fc_peer_get(), fc_peer_put(), fc_peers, FC_PORT_HAS_FABRIC, FC_PORT_HAS_NS, fc_port_logout(), fc_port::flags, intf_restart(), fc_port::link, fc_peer::link, fc_port::link_node_wwn, fc_port::link_port_wwn, fc_peer::list, list_for_each_entry_safe, memcmp(), memcpy(), fc_port::name, fc_port::ns_plogi, fc_port::port_id, fc_port::port_wwn, fc_port::ptp_link_port_id, rc, and strerror().

Referenced by fc_els_flogi_rx().

                                                                          {
        struct fc_peer *peer;
        struct fc_peer *tmp;
        int rc;

        /* Perform implicit logout if logged in and details differ */
        if ( fc_link_ok ( &port->link ) &&
             ( ( ( !! ( port->flags & FC_PORT_HAS_FABRIC ) ) !=
                 ( !! has_fabric ) ) ||
               ( memcmp ( &port->link_node_wwn, link_node_wwn,
                          sizeof ( port->link_node_wwn ) ) != 0 ) ||
               ( memcmp ( &port->link_port_wwn, link_port_wwn,
                          sizeof ( port->link_port_wwn ) ) != 0 ) ||
               ( has_fabric &&
                 ( memcmp ( &port->port_id, port_id,
                            sizeof ( port->port_id ) ) != 0 ) ) ) ) {
                fc_port_logout ( port, 0 );
        }

        /* Log in, if applicable */
        if ( ! fc_link_ok ( &port->link ) ) {

                /* Record link port name */
                memcpy ( &port->link_node_wwn, link_node_wwn,
                         sizeof ( port->link_node_wwn ) );
                memcpy ( &port->link_port_wwn, link_port_wwn,
                         sizeof ( port->link_port_wwn ) );
                DBGC ( port, "FCPORT %s logged in to %s",
                       port->name, fc_ntoa ( &port->link_node_wwn ) );
                DBGC ( port, " port %s\n", fc_ntoa ( &port->link_port_wwn ) );

                /* Calculate local (and possibly remote) port IDs */
                if ( has_fabric ) {
                        port->flags |= FC_PORT_HAS_FABRIC;
                        memcpy ( &port->port_id, port_id,
                                 sizeof ( port->port_id ) );
                } else {
                        port->flags &= ~FC_PORT_HAS_FABRIC;
                        if ( memcmp ( &port->port_wwn, link_port_wwn,
                                      sizeof ( port->port_wwn ) ) > 0 ) {
                                memcpy ( &port->port_id, &fc_ptp_high_port_id,
                                         sizeof ( port->port_id ) );
                                memcpy ( &port->ptp_link_port_id,
                                         &fc_ptp_low_port_id,
                                         sizeof ( port->ptp_link_port_id ) );
                        } else {
                                memcpy ( &port->port_id, &fc_ptp_low_port_id,
                                         sizeof ( port->port_id ) );
                                memcpy ( &port->ptp_link_port_id,
                                         &fc_ptp_high_port_id,
                                         sizeof ( port->ptp_link_port_id ) );
                        }
                }
                DBGC ( port, "FCPORT %s logged in via a %s, with local ID "
                       "%s\n", port->name,
                       ( ( port->flags & FC_PORT_HAS_FABRIC ) ?
                         "fabric" : "point-to-point link" ),
                       fc_id_ntoa ( &port->port_id ) );
        }

        /* Log in to name server, if attached to a fabric */
        if ( has_fabric && ! ( port->flags & FC_PORT_HAS_NS ) ) {

                DBGC ( port, "FCPORT %s attempting login to name server\n",
                       port->name );

                intf_restart ( &port->ns_plogi, -ECANCELED );
                if ( ( rc = fc_els_plogi ( &port->ns_plogi, port,
                                           &fc_gs_port_id ) ) != 0 ) {
                        DBGC ( port, "FCPORT %s could not initiate name "
                               "server PLOGI: %s\n",
                               port->name, strerror ( rc ) );
                        fc_port_logout ( port, rc );
                        return rc;
                }
        }

        /* Record login */
        fc_link_up ( &port->link );

        /* Notify peers of link state change */
        list_for_each_entry_safe ( peer, tmp, &fc_peers, list ) {
                fc_peer_get ( peer );
                fc_link_examine ( &peer->link );
                fc_peer_put ( peer );
        }

        return 0;
}
void fc_port_logout ( struct fc_port port,
int  rc 
)

Log out Fibre Channel port.

Parameters:
portFibre Channel port
rcReason for logout

Definition at line 1039 of file fc.c.

References DBGC, fc_link_err(), fc_link_examine(), fc_peer_get(), fc_peer_put(), fc_peers, fc_port::flags, fc_port::link, fc_peer::link, fc_peer::list, list_for_each_entry_safe, memset(), fc_port::name, fc_port::port_id, and strerror().

Referenced by fc_els_logo_logout(), fc_port_close(), fc_port_examine(), fc_port_flogi_done(), fc_port_login(), and fc_port_window_changed().

                                                     {
        struct fc_peer *peer;
        struct fc_peer *tmp;

        DBGC ( port, "FCPORT %s logged out: %s\n",
               port->name, strerror ( rc ) );

        /* Erase port details */
        memset ( &port->port_id, 0, sizeof ( port->port_id ) );
        port->flags = 0;

        /* Record logout */
        fc_link_err ( &port->link, rc );

        /* Notify peers of link state change */
        list_for_each_entry_safe ( peer, tmp, &fc_peers, list ) {
                fc_peer_get ( peer );
                fc_link_examine ( &peer->link );
                fc_peer_put ( peer );
        }
}
int fc_port_open ( struct interface transport,
const struct fc_name node_wwn,
const struct fc_name port_wwn,
const char *  name 
)

Create Fibre Channel port.

Parameters:
transportTransport interface
nodeFibre Channel node name
portFibre Channel port name
nameSymbolic port name
Return values:
rcReturn status code

Definition at line 1189 of file fc.c.

References DBGC, ENOMEM, fc_link_init(), fc_ntoa(), fc_port_examine(), fc_ports, fc_port::flogi, INIT_LIST_HEAD, intf_init(), intf_plug_plug(), fc_port::link, fc_port::list, list_add_tail, memcpy(), fc_port::name, fc_port::node_wwn, fc_port::ns_plogi, NULL, port, fc_port::port_wwn, ref_init, ref_put, fc_port::refcnt, snprintf(), fc_port::transport, fc_port::xchgs, and zalloc().

Referenced by fcoe_expired().

                                                                      {
        struct fc_port *port;

        /* Allocate and initialise structure */
        port = zalloc ( sizeof ( *port ) );
        if ( ! port )
                return -ENOMEM;
        ref_init ( &port->refcnt, NULL );
        intf_init ( &port->transport, &fc_port_transport_desc, &port->refcnt );
        fc_link_init ( &port->link, fc_port_examine, &port->refcnt );
        intf_init ( &port->flogi, &fc_port_flogi_desc, &port->refcnt );
        intf_init ( &port->ns_plogi, &fc_port_ns_plogi_desc, &port->refcnt );
        list_add_tail ( &port->list, &fc_ports );
        INIT_LIST_HEAD ( &port->xchgs );
        memcpy ( &port->node_wwn, node_wwn, sizeof ( port->node_wwn ) );
        memcpy ( &port->port_wwn, port_wwn, sizeof ( port->port_wwn ) );
        snprintf ( port->name, sizeof ( port->name ), "%s", name );

        DBGC ( port, "FCPORT %s opened as %s",
               port->name, fc_ntoa ( &port->node_wwn ) );
        DBGC ( port, " port %s\n", fc_ntoa ( &port->port_wwn ) );

        /* Attach to transport layer, mortalise self, and return */
        intf_plug_plug ( &port->transport, transport );
        ref_put ( &port->refcnt );
        return 0;
}
struct fc_port* fc_port_find ( const char *  name) [read]

Find Fibre Channel port by name.

Parameters:
nameFibre Channel port name
Return values:
portFibre Channel port, or NULL

Definition at line 1224 of file fc.c.

References fc_ports, fc_port::list, list_for_each_entry, fc_port::name, NULL, port, and strcmp().

Referenced by parse_fc_port().

                                                   {
        struct fc_port *port;

        list_for_each_entry ( port, &fc_ports, list ) {
                if ( strcmp ( name, port->name ) == 0 )
                        return port;
        }
        return NULL;
}
static struct fc_peer* fc_peer_get ( struct fc_peer peer) [static, read]

Get reference to Fibre Channel peer.

Parameters:
peerFibre Channel peer
Return values:
peerFibre Channel peer

Definition at line 379 of file fc.h.

References ref_get.

Referenced by fc_ns_query(), fc_peer_get_port_id(), fc_peer_get_wwn(), fc_peer_login(), fc_port_login(), fc_port_logout(), and fc_ulp_create().

                                     {
        ref_get ( &peer->refcnt );
        return peer;
}
static void fc_peer_put ( struct fc_peer peer) [inline, static]

Drop reference to Fibre Channel peer.

Parameters:
peerFibre Channel peer

Definition at line 390 of file fc.h.

References ref_put.

Referenced by fc_els_logo_logout(), fc_els_plogi_rx(), fc_ns_query_free(), fc_peer_logout(), fc_port_login(), fc_port_logout(), fc_ulp_free(), fc_ulp_get_port_id_type(), and fc_ulp_get_wwn_type().

                                     {
        ref_put ( &peer->refcnt );
}
struct fc_peer* fc_peer_get_wwn ( const struct fc_name port_wwn) [read]

Get Fibre Channel peer by node name.

Parameters:
port_wwnNode name
Return values:
peerFibre Channel peer, or NULL

Definition at line 1516 of file fc.c.

References fc_peer_create(), fc_peer_get(), fc_peers, fc_peer::list, list_for_each_entry, memcmp(), NULL, and fc_peer::port_wwn.

Referenced by fc_els_plogi_rx(), and fc_ulp_get_wwn_type().

                                                                    {
        struct fc_peer *peer;

        /* Look for an existing peer */
        list_for_each_entry ( peer, &fc_peers, list ) {
                if ( memcmp ( &peer->port_wwn, port_wwn,
                              sizeof ( peer->port_wwn ) ) == 0 )
                        return fc_peer_get ( peer );
        }

        /* Create a new peer */
        peer = fc_peer_create ( port_wwn );
        if ( ! peer )
                return NULL;

        return peer;
}
struct fc_peer* fc_peer_get_port_id ( struct fc_port port,
const struct fc_port_id peer_port_id 
) [read]

Get Fibre Channel peer by port ID.

Parameters:
portFibre Channel port
peer_port_idPeer port ID
Return values:
peerFibre Channel peer, or NULL

Definition at line 1541 of file fc.c.

References fc_peer_get(), fc_peers, fc_peer::list, list_for_each_entry, memcmp(), NULL, fc_peer::port, and fc_peer::port_id.

Referenced by fc_els_logo_logout(), and fc_ulp_get_port_id_type().

                                                                              {
        struct fc_peer *peer;

        /* Look for an existing peer */
        list_for_each_entry ( peer, &fc_peers, list ) {
                if ( ( peer->port == port ) &&
                     ( memcmp ( &peer->port_id, peer_port_id,
                                sizeof ( peer->port_id ) ) == 0 ) )
                        return fc_peer_get ( peer );
        }

        /* Cannot create a new peer, since we have no port name to use */
        return NULL;
}
int fc_peer_login ( struct fc_peer peer,
struct fc_port port,
struct fc_port_id port_id 
)

Log in Fibre Channel peer.

Parameters:
peerFibre Channel peer
portFibre Channel port
port_idPort ID
Return values:
rcReturn status code

Definition at line 1300 of file fc.c.

References assert, DBGC, fc_id_ntoa(), fc_link_examine(), fc_link_ok(), fc_link_up(), fc_ntoa(), fc_peer_get(), fc_peer_logout(), fc_port_get(), fc_ulp_get(), fc_ulp_put(), fc_peer::link, fc_ulp::link, fc_ulp::list, list_for_each_entry_safe, memcmp(), memcpy(), fc_port::name, NULL, fc_peer::port, fc_peer::port_id, fc_peer::port_wwn, and fc_peer::ulps.

Referenced by fc_els_plogi_rx().

                                                 {
        struct fc_ulp *ulp;
        struct fc_ulp *tmp;

        /* Perform implicit logout if logged in and details differ */
        if ( fc_link_ok ( &peer->link ) &&
             ( ( peer->port != port ) ||
               ( memcmp ( &peer->port_id, port_id,
                          sizeof ( peer->port_id ) ) !=0 ) ) ) {
                fc_peer_logout ( peer, 0 );
        }

        /* Log in, if applicable */
        if ( ! fc_link_ok ( &peer->link ) ) {

                /* Record peer details */
                assert ( peer->port == NULL );
                peer->port = fc_port_get ( port );
                memcpy ( &peer->port_id, port_id, sizeof ( peer->port_id ) );
                DBGC ( peer, "FCPEER %s logged in via %s as %s\n",
                       fc_ntoa ( &peer->port_wwn ), peer->port->name,
                       fc_id_ntoa ( &peer->port_id ) );

                /* Add login reference */
                fc_peer_get ( peer );
        }

        /* Record login */
        fc_link_up ( &peer->link );

        /* Notify ULPs of link state change */
        list_for_each_entry_safe ( ulp, tmp, &peer->ulps, list ) {
                fc_ulp_get ( ulp );
                fc_link_examine ( &ulp->link );
                fc_ulp_put ( ulp );
        }

        return 0;
}
void fc_peer_logout ( struct fc_peer peer,
int  rc 
)

Log out Fibre Channel peer.

Parameters:
peerFibre Channel peer
rcReason for logout

Definition at line 1347 of file fc.c.

References DBGC, fc_link_err(), fc_link_examine(), fc_link_ok(), fc_ntoa(), fc_peer_close(), fc_peer_put(), fc_port_put(), fc_ulp_get(), fc_ulp_put(), fc_peer::link, fc_ulp::link, fc_ulp::list, list_for_each_entry_safe, NULL, fc_peer::port, fc_peer::port_wwn, strerror(), fc_peer::ulps, and fc_peer::usage.

Referenced by fc_els_logo_logout(), fc_peer_decrement(), fc_peer_examine(), fc_peer_login(), fc_peer_plogi(), and fc_peer_plogi_done().

                                                     {
        struct fc_ulp *ulp;
        struct fc_ulp *tmp;

        DBGC ( peer, "FCPEER %s logged out: %s\n",
               fc_ntoa ( &peer->port_wwn ), strerror ( rc ) );

        /* Drop login reference, if applicable */
        if ( fc_link_ok ( &peer->link ) )
                fc_peer_put ( peer );

        /* Erase peer details */
        fc_port_put ( peer->port );
        peer->port = NULL;

        /* Record logout */
        fc_link_err ( &peer->link, rc );

        /* Notify ULPs of link state change */
        list_for_each_entry_safe ( ulp, tmp, &peer->ulps, list ) {
                fc_ulp_get ( ulp );
                fc_link_examine ( &ulp->link );
                fc_ulp_put ( ulp );
        }

        /* Close peer if there are no active users */
        if ( peer->usage == 0 )
                fc_peer_close ( peer, rc );
}
static struct fc_ulp* fc_ulp_get ( struct fc_ulp ulp) [static, read]

Get reference to Fibre Channel upper-layer protocol.

Parameters:
ulpFibre Channel upper-layer protocol
Return values:
ulpFibre Channel upper-layer protocol

Definition at line 474 of file fc.h.

References ref_get, and fc_ulp_user::ulp.

Referenced by fc_peer_login(), fc_peer_logout(), fc_ulp_attach(), fc_ulp_get_type(), and fc_ulp_login().

                                  {
        ref_get ( &ulp->refcnt );
        return ulp;
}
static void fc_ulp_put ( struct fc_ulp ulp) [inline, static]

Drop reference to Fibre Channel upper-layer protocol.

Parameters:
ulpFibre Channel upper-layer protocol

Definition at line 485 of file fc.h.

References ref_put.

Referenced by fc_els_prli_rx(), fc_els_prli_tx(), fc_peer_login(), fc_peer_logout(), fc_ulp_detach(), fc_ulp_get_port_id_type(), fc_ulp_get_wwn_type(), fc_ulp_logout(), and fcpdev_open().

                                  {
        ref_put ( &ulp->refcnt );
}
static struct fc_ulp_user* fc_ulp_user_get ( struct fc_ulp_user user) [static, read]

Get reference to Fibre Channel upper-layer protocol user.

Parameters:
userFibre Channel upper-layer protocol user
Return values:
userFibre Channel upper-layer protocol user

Definition at line 496 of file fc.h.

References ref_get, and user.

Referenced by fc_ulp_login(), and fc_ulp_logout().

                                             {
        ref_get ( user->refcnt );
        return user;
}
static void fc_ulp_user_put ( struct fc_ulp_user user) [inline, static]

Drop reference to Fibre Channel upper-layer protocol user.

Parameters:
userFibre Channel upper-layer protocol user

Definition at line 507 of file fc.h.

References ref_put.

Referenced by fc_ulp_login(), and fc_ulp_logout().

                                             {
        ref_put ( user->refcnt );
}
static void fc_ulp_user_init ( struct fc_ulp_user user,
void(*)(struct fc_ulp_user *user examine,
struct refcnt refcnt 
) [inline, static]

Initialise Fibre Channel upper-layer protocol user.

Parameters:
userFibre Channel upper-layer protocol user
examineExamine link state method
refcntContaining object reference count, or NULL

Definition at line 519 of file fc.h.

References fc_ulp_user::examine, and fc_ulp_user::refcnt.

Referenced by fcpdev_open().

                                           {
        user->examine = examine;
        user->refcnt = refcnt;
}
struct fc_ulp* fc_ulp_get_wwn_type ( const struct fc_name port_wwn,
unsigned int  type 
) [read]

Get Fibre Channel upper-layer protocol by port name and type.

Parameters:
port_wwnPort name
typeType
Return values:
ulpFibre Channel upper-layer protocol, or NULL

Definition at line 1880 of file fc.c.

References fc_peer_get_wwn(), fc_peer_put(), fc_ulp_get_type(), fc_ulp_put(), and NULL.

Referenced by fcpdev_open().

                                                          {
        struct fc_ulp *ulp;
        struct fc_peer *peer;

        /* Get peer */
        peer = fc_peer_get_wwn ( port_wwn );
        if ( ! peer )
                goto err_peer_get_wwn;

        /* Get ULP */
        ulp = fc_ulp_get_type ( peer, type );
        if ( ! ulp )
                goto err_ulp_get_type;

        /* Drop temporary reference to peer */
        fc_peer_put ( peer );

        return ulp;

        fc_ulp_put ( ulp );
 err_ulp_get_type:
        fc_peer_put ( peer );
 err_peer_get_wwn:
        return NULL;
}
struct fc_ulp* fc_ulp_get_port_id_type ( struct fc_port port,
const struct fc_port_id peer_port_id,
unsigned int  type 
) [read]

Get Fibre Channel upper-layer protocol by port ID and type.

Parameters:
portFibre Channel port
peer_port_idPeer port ID
typeType
Return values:
ulpFibre Channel upper-layer protocol, or NULL

Definition at line 1915 of file fc.c.

References fc_peer_get_port_id(), fc_peer_put(), fc_ulp_get_type(), fc_ulp_put(), and NULL.

Referenced by fc_els_prli_rx(), and fc_els_prli_tx().

                                                              {
        struct fc_ulp *ulp;
        struct fc_peer *peer;

        /* Get peer */
        peer = fc_peer_get_port_id ( port, peer_port_id );
        if ( ! peer )
                goto err_peer_get_wwn;

        /* Get ULP */
        ulp = fc_ulp_get_type ( peer, type );
        if ( ! ulp )
                goto err_ulp_get_type;

        /* Drop temporary reference to peer */
        fc_peer_put ( peer );

        return ulp;

        fc_ulp_put ( ulp );
 err_ulp_get_type:
        fc_peer_put ( peer );
 err_peer_get_wwn:
        return NULL;
}
void fc_ulp_attach ( struct fc_ulp ulp,
struct fc_ulp_user user 
)

Attach Fibre Channel upper-layer protocol user.

Parameters:
ulpFibre Channel upper-layer protocol
userFibre Channel upper-layer protocol user

Definition at line 1607 of file fc.c.

References assert, fc_peer_increment(), fc_ulp_get(), fc_ulp_user::list, list_add, NULL, fc_ulp::peer, fc_ulp_user::ulp, and fc_ulp::users.

Referenced by fcpdev_open().

                                                                    {

        /* Sanity check */
        assert ( user->ulp == NULL );

        /* Increment peer's usage count */
        fc_peer_increment ( ulp->peer );

        /* Attach user */
        user->ulp = fc_ulp_get ( ulp );
        list_add ( &user->list, &ulp->users );
}
void fc_ulp_detach ( struct fc_ulp_user user)

Detach Fibre Channel upper-layer protocol user.

Parameters:
userFibre Channel upper-layer protocol user

Definition at line 1625 of file fc.c.

References fc_peer_decrement(), fc_ulp_logout(), fc_ulp_put(), fc_ulp::list, fc_ulp_user::list, list_check_contains_entry, list_del, list_empty, NULL, fc_ulp::peer, fc_ulp_user::ulp, and fc_ulp::users.

Referenced by fcpdev_close().

                                                {
        struct fc_ulp *ulp = user->ulp;

        /* Do nothing if not attached */
        if ( ! ulp )
                return;

        /* Sanity checks */
        list_check_contains_entry ( user, &ulp->users, list );

        /* Detach user and log out if no users remain */
        list_del ( &user->list );
        if ( list_empty ( &ulp->users ) )
                fc_ulp_logout ( ulp, 0 );

        /* Decrement our peer's usage count */
        fc_peer_decrement ( ulp->peer );

        /* Drop reference */
        user->ulp = NULL;
        fc_ulp_put ( ulp );
}
int fc_ulp_login ( struct fc_ulp ulp,
const void *  param,
size_t  param_len,
int  originated 
)

Log in Fibre Channel upper-layer protocol.

Parameters:
ulpFibre Channel upper-layer protocol
paramService parameters
param_lenLength of service parameters
originatedLogin was originated by us
Return values:
rcReturn status code

Definition at line 1657 of file fc.c.

References assert, DBGC, DBGC_HDA, ENOMEM, fc_ulp_user::examine, fc_link_ok(), fc_link_start(), fc_link_stop(), fc_link_up(), fc_ntoa(), fc_ulp_get(), fc_ulp_logout(), FC_ULP_ORIGINATED_LOGIN_OK, fc_ulp_user_get(), fc_ulp_user_put(), fc_ulp::flags, fc_ulp::link, fc_ulp_user::list, list_for_each_entry_safe, malloc(), memcmp(), memcpy(), NULL, fc_ulp::param, fc_ulp::param_len, fc_ulp::peer, fc_peer::port_wwn, fc_ulp::type, user, and fc_ulp::users.

Referenced by fc_els_prli_rx().

                                    {
        struct fc_ulp_user *user;
        struct fc_ulp_user *tmp;

        /* Perform implicit logout if logged in and service parameters differ */
        if ( fc_link_ok ( &ulp->link ) &&
             ( ( ulp->param_len != param_len ) ||
               ( memcmp ( ulp->param, param, ulp->param_len ) != 0 ) ) ) {
                fc_ulp_logout ( ulp, 0 );
        }

        /* Work around a bug in some versions of the Linux Fibre
         * Channel stack, which fail to fully initialise image pairs
         * established via a PRLI originated by the Linux stack
         * itself.
         */
        if ( originated )
                ulp->flags |= FC_ULP_ORIGINATED_LOGIN_OK;
        if ( ! ( ulp->flags & FC_ULP_ORIGINATED_LOGIN_OK ) ) {
                DBGC ( ulp, "FCULP %s/%02x sending extra PRLI to work around "
                       "Linux bug\n",
                       fc_ntoa ( &ulp->peer->port_wwn ), ulp->type );
                fc_link_stop ( &ulp->link );
                fc_link_start ( &ulp->link );
                return 0;
        }

        /* Log in, if applicable */
        if ( ! fc_link_ok ( &ulp->link ) ) {

                /* Record service parameters */
                assert ( ulp->param == NULL );
                assert ( ulp->param_len == 0 );
                ulp->param = malloc ( param_len );
                if ( ! ulp->param ) {
                        DBGC ( ulp, "FCULP %s/%02x could not record "
                               "parameters\n",
                               fc_ntoa ( &ulp->peer->port_wwn ), ulp->type );
                        return -ENOMEM;
                }
                memcpy ( ulp->param, param, param_len );
                ulp->param_len = param_len;
                DBGC ( ulp, "FCULP %s/%02x logged in with parameters:\n",
                       fc_ntoa ( &ulp->peer->port_wwn ), ulp->type );
                DBGC_HDA ( ulp, 0, ulp->param, ulp->param_len );

                /* Add login reference */
                fc_ulp_get ( ulp );
        }

        /* Record login */
        fc_link_up ( &ulp->link );

        /* Notify users of link state change */
        list_for_each_entry_safe ( user, tmp, &ulp->users, list ) {
                fc_ulp_user_get ( user );
                user->examine ( user );
                fc_ulp_user_put ( user );
        }

        return 0;
}
void fc_ulp_logout ( struct fc_ulp ulp,
int  rc 
)

Log out Fibre Channel upper-layer protocol.

Parameters:
ulpFibre Channel upper-layer protocol
rcReason for logout

Definition at line 1727 of file fc.c.

References DBGC, fc_ulp_user::examine, fc_link_err(), fc_link_ok(), fc_ntoa(), fc_ulp_close(), fc_ulp_put(), fc_ulp_user_get(), fc_ulp_user_put(), fc_ulp::flags, free, fc_ulp::link, fc_ulp_user::list, list_empty, list_for_each_entry_safe, NULL, fc_ulp::param, fc_ulp::param_len, fc_ulp::peer, fc_peer::port_wwn, strerror(), fc_ulp::type, user, and fc_ulp::users.

Referenced by fc_els_prli_rx(), fc_ulp_detach(), fc_ulp_examine(), fc_ulp_login(), and fc_ulp_prli_done().

                                                  {
        struct fc_ulp_user *user;
        struct fc_ulp_user *tmp;

        DBGC ( ulp, "FCULP %s/%02x logged out: %s\n",
               fc_ntoa ( &ulp->peer->port_wwn ), ulp->type, strerror ( rc ) );

        /* Drop login reference, if applicable */
        if ( fc_link_ok ( &ulp->link ) )
                fc_ulp_put ( ulp );

        /* Discard service parameters */
        free ( ulp->param );
        ulp->param = NULL;
        ulp->param_len = 0;
        ulp->flags = 0;

        /* Record logout */
        fc_link_err ( &ulp->link, rc );

        /* Notify users of link state change */
        list_for_each_entry_safe ( user, tmp, &ulp->users, list ) {
                fc_ulp_user_get ( user );
                user->examine ( user );
                fc_ulp_user_put ( user );
        }

        /* Close ULP if there are no clients attached */
        if ( list_empty ( &ulp->users ) )
                fc_ulp_close ( ulp, rc );
}

Variable Documentation

Unassigned port ID.

Definition at line 65 of file fc.c.

Referenced by fcels_exec().

F_Port contoller port ID.

Definition at line 68 of file fc.c.

Referenced by fc_els_flogi(), fc_els_logo_logout(), and fcels_exec().

Generic services port ID.

Definition at line 71 of file fc.c.

Referenced by fc_ns_query_step().

Point-to-point low port ID.

Definition at line 74 of file fc.c.

Point-to-point high port ID.

Definition at line 77 of file fc.c.