iPXE
Data Structures | Macros | 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...
 

Macros

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

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. More...
 
int fc_id_aton (const char *id_text, struct fc_port_id *id)
 Parse Fibre Channel port ID. More...
 
const char * fc_ntoa (const struct fc_name *wwn)
 Format Fibre Channel WWN. More...
 
int fc_aton (const char *wwn_text, struct fc_name *wwn)
 Parse Fibre Channel WWN. More...
 
struct sockaddrfc_fill_sockaddr (struct sockaddr_fc *sa_fc, struct fc_port_id *id)
 Fill Fibre Channel socket address. More...
 
static int fc_link_ok (struct fc_link_state *link)
 Check Fibre Channel link state. More...
 
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. More...
 
static struct fc_portfc_port_get (struct fc_port *port)
 Get reference to Fibre Channel port. More...
 
static void fc_port_put (struct fc_port *port)
 Drop reference to Fibre Channel port. More...
 
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. More...
 
void fc_port_logout (struct fc_port *port, int rc)
 Log out Fibre Channel port. More...
 
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. More...
 
struct fc_portfc_port_find (const char *name)
 Find Fibre Channel port by name. More...
 
static struct fc_peerfc_peer_get (struct fc_peer *peer)
 Get reference to Fibre Channel peer. More...
 
static void fc_peer_put (struct fc_peer *peer)
 Drop reference to Fibre Channel peer. More...
 
struct fc_peerfc_peer_get_wwn (const struct fc_name *port_wwn)
 Get Fibre Channel peer by node name. More...
 
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. More...
 
int fc_peer_login (struct fc_peer *peer, struct fc_port *port, struct fc_port_id *port_id)
 Log in Fibre Channel peer. More...
 
void fc_peer_logout (struct fc_peer *peer, int rc)
 Log out Fibre Channel peer. More...
 
static struct fc_ulpfc_ulp_get (struct fc_ulp *ulp)
 Get reference to Fibre Channel upper-layer protocol. More...
 
static void fc_ulp_put (struct fc_ulp *ulp)
 Drop reference to Fibre Channel upper-layer protocol. More...
 
static struct fc_ulp_userfc_ulp_user_get (struct fc_ulp_user *user)
 Get reference to Fibre Channel upper-layer protocol user. More...
 
static void fc_ulp_user_put (struct fc_ulp_user *user)
 Drop reference to Fibre Channel upper-layer protocol user. More...
 
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. More...
 
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. More...
 
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. More...
 
void fc_ulp_attach (struct fc_ulp *ulp, struct fc_ulp_user *user)
 Attach Fibre Channel upper-layer protocol user. More...
 
void fc_ulp_detach (struct fc_ulp_user *user)
 Detach Fibre Channel upper-layer protocol user. More...
 
int fc_ulp_login (struct fc_ulp *ulp, const void *param, size_t param_len, int originated)
 Log in Fibre Channel upper-layer protocol. More...
 
void fc_ulp_logout (struct fc_ulp *ulp, int rc)
 Log out Fibre Channel upper-layer protocol. More...
 

Variables

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

Detailed Description

Fibre Channel.

Definition in file fc.h.

Macro Definition Documentation

◆ FC_NAME_STRLEN

#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.

◆ FC_PORT_ID_STRLEN

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

Length of Fibre Channel port identifier next.

Definition at line 42 of file fc.h.

◆ FC_LINK_RETRY_DELAY

#define FC_LINK_RETRY_DELAY   ( 2 * TICKS_PER_SEC )

Delay between failed link-up attempts.

Definition at line 86 of file fc.h.

◆ FC_R_CTL_ROUTING_MASK

#define FC_R_CTL_ROUTING_MASK   0xf0

Fibre Channel Routing Control Routing mask.

Definition at line 172 of file fc.h.

◆ FC_R_CTL_INFO_MASK

#define FC_R_CTL_INFO_MASK   0x07

Fibre Channel Routing Control Information mask.

Definition at line 187 of file fc.h.

◆ FC_RX_ID_UNKNOWN

#define FC_RX_ID_UNKNOWN   0xffff

Responder exchange identifier used before first response.

Definition at line 213 of file fc.h.

◆ FC_RESPONDERS

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

Fibre Channel responder table.

Definition at line 239 of file fc.h.

◆ __fc_responder

#define __fc_responder   __table_entry ( FC_RESPONDERS, 01 )

Declare a Fibre Channel responder.

Definition at line 242 of file fc.h.

Enumeration Type Documentation

◆ fc_r_ctl_routing

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.

160  {
161  FC_R_CTL_DATA = 0x00, /**< Device Data */
162  FC_R_CTL_ELS = 0x20, /**< Extended Link Services */
163  FC_R_CTL_FC4_LINK = 0x30, /**< FC-4 Link Data */
164  FC_R_CTL_VIDEO = 0x40, /**< Video Data */
165  FC_R_CTL_EH = 0x50, /**< Extended Headers */
166  FC_R_CTL_BLS = 0x80, /**< Basic Link Services */
167  FC_R_CTL_LINK_CTRL = 0xc0, /**< Link Control */
168  FC_R_CTL_EXT_ROUTE = 0xf0, /**< Extended Routing */
169 };
Link Control.
Definition: fc.h:167
Basic Link Services.
Definition: fc.h:166
Extended Routing.
Definition: fc.h:168
Extended Link Services.
Definition: fc.h:162
FC-4 Link Data.
Definition: fc.h:163
Device Data.
Definition: fc.h:161
Video Data.
Definition: fc.h:164
Extended Headers.
Definition: fc.h:165

◆ fc_r_ctl_info

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.

175  {
176  FC_R_CTL_UNCAT = 0x00, /**< Uncategorized */
177  FC_R_CTL_SOL_DATA = 0x01, /**< Solicited Data */
178  FC_R_CTL_UNSOL_CTRL = 0x02, /**< Unsolicited Control */
179  FC_R_CTL_SOL_CTRL = 0x03, /**< Solicited Control */
180  FC_R_CTL_UNSOL_DATA = 0x04, /**< Unsolicited Data */
181  FC_R_CTL_DATA_DESC = 0x05, /**< Data Descriptor */
182  FC_R_CTL_UNSOL_CMD = 0x06, /**< Unsolicited Command */
183  FC_R_CTL_CMD_STAT = 0x07, /**< Command Status */
184 };
Solicited Data.
Definition: fc.h:177
Unsolicited Control.
Definition: fc.h:178
Unsolicited Command.
Definition: fc.h:182
Command Status.
Definition: fc.h:183
Unsolicited Data.
Definition: fc.h:180
Solicited Control.
Definition: fc.h:179
Data Descriptor.
Definition: fc.h:181
Uncategorized.
Definition: fc.h:176

◆ fc_type

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.

190  {
191  FC_TYPE_BLS = 0x00, /**< Basic Link Service */
192  FC_TYPE_ELS = 0x01, /**< Extended Link Service */
193  FC_TYPE_FCP = 0x08, /**< Fibre Channel Protocol */
194  FC_TYPE_CT = 0x20, /**< Common Transport */
195 };
Fibre Channel Protocol.
Definition: fc.h:193
Extended Link Service.
Definition: fc.h:192
Common Transport.
Definition: fc.h:194
Basic Link Service.
Definition: fc.h:191

◆ fc_f_ctl_es

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.

198  {
199  FC_F_CTL_ES_RESPONDER = 0x80, /**< Responder of Exchange */
200  FC_F_CTL_ES_RECIPIENT = 0x40, /**< Sequence Recipient */
201  FC_F_CTL_ES_FIRST = 0x20, /**< First Sequence of Exchange */
202  FC_F_CTL_ES_LAST = 0x10, /**< Last Sequence of Exchange */
203  FC_F_CTL_ES_END = 0x08, /**< Last Data Frame of Sequence */
204  FC_F_CTL_ES_TRANSFER = 0x01, /**< Transfer Sequence Initiative */
205 };
Last Sequence of Exchange.
Definition: fc.h:202
Last Data Frame of Sequence.
Definition: fc.h:203
Transfer Sequence Initiative.
Definition: fc.h:204
Responder of Exchange.
Definition: fc.h:199
Sequence Recipient.
Definition: fc.h:200
First Sequence of Exchange.
Definition: fc.h:201

◆ fc_f_ctl_misc

Fibre Channel Frame Control - Miscellaneous.

Enumerator
FC_F_CTL_MISC_REL_OFF 

Relative Offset Present.

Definition at line 208 of file fc.h.

208  {
209  FC_F_CTL_MISC_REL_OFF = 0x08, /**< Relative Offset Present */
210 };
Relative Offset Present.
Definition: fc.h:209

◆ fc_port_flags

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.

290  {
291  /** Port is attached to a fabric */
292  FC_PORT_HAS_FABRIC = 0x0001,
293  /** Port is logged in to a name server */
294  FC_PORT_HAS_NS = 0x0002,
295 };
Port is attached to a fabric.
Definition: fc.h:292
Port is logged in to a name server.
Definition: fc.h:294

◆ fc_ulp_flags

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.

447  {
448  /** A login originated by us has succeeded */
450 };
A login originated by us has succeeded.
Definition: fc.h:449

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ fc_id_ntoa()

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.

92  {
93  static char id_text[ FC_PORT_ID_STRLEN + 1 /* NUL */ ];
94 
95  snprintf ( id_text, sizeof ( id_text ), "%02x.%02x.%02x",
96  id->bytes[0], id->bytes[1], id->bytes[2] );
97  return id_text;
98 }
#define FC_PORT_ID_STRLEN
Length of Fibre Channel port identifier next.
Definition: fc.h:42
uint8_t id
Request identifier.
Definition: ena.h:12
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
Definition: vsprintf.c:382

References FC_PORT_ID_STRLEN, id, 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().

◆ fc_id_aton()

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.

107  {
108  char *ptr = ( ( char * ) id_text );
109  unsigned int i = 0;
110 
111  while ( 1 ) {
112  id->bytes[i++] = strtoul ( ptr, &ptr, 16 );
113  if ( i == sizeof ( id->bytes ) )
114  return ( ( *ptr == '\0' ) ? 0 : -EINVAL );
115  if ( *ptr != '.' )
116  return -EINVAL;
117  ptr++;
118  }
119 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
unsigned long strtoul(const char *string, char **endp, int base)
Convert string to numeric value.
Definition: string.c:456
uint8_t id
Request identifier.
Definition: ena.h:12

References EINVAL, id, and strtoul().

Referenced by parse_fc_port_id().

◆ fc_ntoa()

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.

127  {
128  static char wwn_text[ FC_NAME_STRLEN + 1 /* NUL */ ];
129 
130  snprintf ( wwn_text, sizeof ( wwn_text ),
131  "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
132  wwn->bytes[0], wwn->bytes[1], wwn->bytes[2], wwn->bytes[3],
133  wwn->bytes[4], wwn->bytes[5], wwn->bytes[6], wwn->bytes[7] );
134  return wwn_text;
135 }
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
Definition: vsprintf.c:382
#define FC_NAME_STRLEN
Length of Fibre Channel name text.
Definition: fc.h:34
uint64_t wwn
WWN.
Definition: edd.h:30

References FC_NAME_STRLEN, snprintf(), and wwn.

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().

◆ fc_aton()

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.

144  {
145  char *ptr = ( ( char * ) wwn_text );
146  unsigned int i = 0;
147 
148  while ( 1 ) {
149  wwn->bytes[i++] = strtoul ( ptr, &ptr, 16 );
150  if ( i == sizeof ( wwn->bytes ) )
151  return ( ( *ptr == '\0' ) ? 0 : -EINVAL );
152  if ( *ptr != ':' )
153  return -EINVAL;
154  ptr++;
155  }
156 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
unsigned long strtoul(const char *string, char **endp, int base)
Convert string to numeric value.
Definition: string.c:456
uint64_t wwn
WWN.
Definition: edd.h:30

References EINVAL, strtoul(), and wwn.

Referenced by fcp_parse_uri().

◆ fc_fill_sockaddr()

struct sockaddr* fc_fill_sockaddr ( struct sockaddr_fc sa_fc,
struct fc_port_id id 
)

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.

166  {
167  union {
168  struct sockaddr sa;
169  struct sockaddr_fc fc;
170  } *u = container_of ( sa_fc, typeof ( *u ), fc );
171 
172  memset ( sa_fc, 0, sizeof ( *sa_fc ) );
173  sa_fc->sfc_family = AF_FC;
174  memcpy ( &sa_fc->sfc_port_id, id, sizeof ( sa_fc->sfc_port_id ) );
175  return &u->sa;
176 }
struct sockaddr sa
Definition: dns.c:68
u16 fc
802.11 Frame Control field
Definition: ieee80211.h:14
Fibre Channel socket address.
Definition: fc.h:47
struct fc_port_id sfc_port_id
Port ID.
Definition: fc.h:54
sa_family_t sfc_family
Socket address family (part of struct sockaddr)
Definition: fc.h:52
#define AF_FC
Fibre Channel addresses.
Definition: socket.h:65
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
Generalized socket address structure.
Definition: socket.h:96
union @16 u
void * memset(void *dest, int character, size_t len) __nonnull

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

Referenced by fc_els_tx(), and fc_xchg_rx().

◆ fc_link_ok()

static int fc_link_ok ( struct fc_link_state link)
inlinestatic

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.

108  {
109  return ( link->rc == 0 );
110 }
u32 link
Link to next descriptor.
Definition: ar9003_mac.h:68

References link.

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().

◆ fc_xchg_originate()

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.

729  {
730  struct fc_exchange *xchg;
731 
732  /* Allocate and initialise structure */
733  xchg = fc_xchg_create ( port, peer_port_id, type );
734  if ( ! xchg )
735  return -ENOMEM;
738 
739  DBGC2 ( port, "FCXCHG %s/%04x originating to %s (type %02x)\n",
740  port->name, xchg->xchg_id, fc_id_ntoa ( &xchg->peer_port_id ),
741  xchg->type );
742 
743  /* Attach to parent interface and return */
744  intf_plug_plug ( &xchg->ulp, parent );
745  return xchg->xchg_id;
746 }
struct interface ulp
Upper-layer protocol interface.
Definition: fc.c:314
unsigned int flags
Flags.
Definition: fc.c:300
const char * fc_id_ntoa(const struct fc_port_id *id)
Format Fibre Channel port ID.
Definition: fc.c:92
unsigned int type
Data structure type.
Definition: fc.c:298
uint8_t type
Type.
Definition: ena.h:16
void intf_plug_plug(struct interface *a, struct interface *b)
Plug two object interfaces together.
Definition: interface.c:102
We have the sequence initiative.
Definition: fc.c:322
uint16_t xchg_id
Local exchange ID.
Definition: fc.c:302
We are the exchange originator.
Definition: fc.c:320
#define ENOMEM
Not enough space.
Definition: errno.h:534
u8 port
Port number.
Definition: CIB_PRM.h:31
struct fc_port_id peer_port_id
Peer port ID.
Definition: fc.c:296
A Fibre Channel exchange.
Definition: fc.c:287
This is the first sequence of the exchange.
Definition: fc.c:324
#define DBGC2(...)
Definition: compiler.h:522
static struct fc_exchange * fc_xchg_create(struct fc_port *port, struct fc_port_id *peer_port_id, unsigned int type)
Create new Fibre Channel exchange.
Definition: fc.c:695

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_exchange::peer_port_id, port, type, fc_exchange::type, fc_exchange::ulp, and fc_exchange::xchg_id.

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

◆ fc_port_get()

static struct fc_port* fc_port_get ( struct fc_port port)
inlinestatic

Get reference to Fibre Channel port.

Parameters
portFibre Channel port
Return values
portFibre Channel port

Definition at line 304 of file fc.h.

304  {
305  ref_get ( &port->refcnt );
306  return port;
307 }
u8 port
Port number.
Definition: CIB_PRM.h:31
#define ref_get(refcnt)
Get additional reference to object.
Definition: refcnt.h:92

References port, and ref_get.

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

◆ fc_port_put()

static void fc_port_put ( struct fc_port port)
inlinestatic

Drop reference to Fibre Channel port.

Parameters
portFibre Channel port

Definition at line 315 of file fc.h.

315  {
316  ref_put ( &port->refcnt );
317 }
u8 port
Port number.
Definition: CIB_PRM.h:31
#define ref_put(refcnt)
Drop reference to object.
Definition: refcnt.h:106

References port, and ref_put.

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

◆ fc_port_login()

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.

943  {
944  struct fc_peer *peer;
945  struct fc_peer *tmp;
946  int rc;
947 
948  /* Perform implicit logout if logged in and details differ */
949  if ( fc_link_ok ( &port->link ) &&
950  ( ( ( !! ( port->flags & FC_PORT_HAS_FABRIC ) ) !=
951  ( !! has_fabric ) ) ||
952  ( memcmp ( &port->link_node_wwn, link_node_wwn,
953  sizeof ( port->link_node_wwn ) ) != 0 ) ||
954  ( memcmp ( &port->link_port_wwn, link_port_wwn,
955  sizeof ( port->link_port_wwn ) ) != 0 ) ||
956  ( has_fabric &&
957  ( memcmp ( &port->port_id, port_id,
958  sizeof ( port->port_id ) ) != 0 ) ) ) ) {
959  fc_port_logout ( port, 0 );
960  }
961 
962  /* Log in, if applicable */
963  if ( ! fc_link_ok ( &port->link ) ) {
964 
965  /* Record link port name */
966  memcpy ( &port->link_node_wwn, link_node_wwn,
967  sizeof ( port->link_node_wwn ) );
968  memcpy ( &port->link_port_wwn, link_port_wwn,
969  sizeof ( port->link_port_wwn ) );
970  DBGC ( port, "FCPORT %s logged in to %s",
971  port->name, fc_ntoa ( &port->link_node_wwn ) );
972  DBGC ( port, " port %s\n", fc_ntoa ( &port->link_port_wwn ) );
973 
974  /* Calculate local (and possibly remote) port IDs */
975  if ( has_fabric ) {
976  port->flags |= FC_PORT_HAS_FABRIC;
977  memcpy ( &port->port_id, port_id,
978  sizeof ( port->port_id ) );
979  } else {
980  port->flags &= ~FC_PORT_HAS_FABRIC;
981  if ( memcmp ( &port->port_wwn, link_port_wwn,
982  sizeof ( port->port_wwn ) ) > 0 ) {
983  memcpy ( &port->port_id, &fc_ptp_high_port_id,
984  sizeof ( port->port_id ) );
985  memcpy ( &port->ptp_link_port_id,
987  sizeof ( port->ptp_link_port_id ) );
988  } else {
989  memcpy ( &port->port_id, &fc_ptp_low_port_id,
990  sizeof ( port->port_id ) );
991  memcpy ( &port->ptp_link_port_id,
993  sizeof ( port->ptp_link_port_id ) );
994  }
995  }
996  DBGC ( port, "FCPORT %s logged in via a %s, with local ID "
997  "%s\n", port->name,
998  ( ( port->flags & FC_PORT_HAS_FABRIC ) ?
999  "fabric" : "point-to-point link" ),
1000  fc_id_ntoa ( &port->port_id ) );
1001  }
1002 
1003  /* Log in to name server, if attached to a fabric */
1004  if ( has_fabric && ! ( port->flags & FC_PORT_HAS_NS ) ) {
1005 
1006  DBGC ( port, "FCPORT %s attempting login to name server\n",
1007  port->name );
1008 
1009  intf_restart ( &port->ns_plogi, -ECANCELED );
1010  if ( ( rc = fc_els_plogi ( &port->ns_plogi, port,
1011  &fc_gs_port_id ) ) != 0 ) {
1012  DBGC ( port, "FCPORT %s could not initiate name "
1013  "server PLOGI: %s\n",
1014  port->name, strerror ( rc ) );
1015  fc_port_logout ( port, rc );
1016  return rc;
1017  }
1018  }
1019 
1020  /* Record login */
1021  fc_link_up ( &port->link );
1022 
1023  /* Notify peers of link state change */
1024  list_for_each_entry_safe ( peer, tmp, &fc_peers, list ) {
1025  fc_peer_get ( peer );
1026  fc_link_examine ( &peer->link );
1027  fc_peer_put ( peer );
1028  }
1029 
1030  return 0;
1031 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
void intf_restart(struct interface *intf, int rc)
Shut down and restart an object interface.
Definition: interface.c:337
struct fc_port_id fc_ptp_high_port_id
Point-to-point high port ID.
Definition: fc.c:77
struct list_head fc_peers
const char * fc_id_ntoa(const struct fc_port_id *id)
Format Fibre Channel port ID.
Definition: fc.c:92
static void fc_link_examine(struct fc_link_state *link)
Examine Fibre Channel link state.
Definition: fc.c:226
struct fc_port_id fc_ptp_low_port_id
Point-to-point low port ID.
Definition: fc.c:74
#define DBGC(...)
Definition: compiler.h:505
const char * fc_ntoa(const struct fc_name *wwn)
Format Fibre Channel WWN.
Definition: fc.c:127
int fc_els_plogi(struct interface *parent, struct fc_port *port, struct fc_port_id *peer_port_id)
Create PLOGI request.
Definition: fcels.c:733
#define ECANCELED
Operation canceled.
Definition: errno.h:343
void * memcpy(void *dest, const void *src, size_t len) __nonnull
u8 port
Port number.
Definition: CIB_PRM.h:31
Port is attached to a fabric.
Definition: fc.h:292
static int fc_link_ok(struct fc_link_state *link)
Check Fibre Channel link state.
Definition: fc.h:108
struct fc_link_state link
Link state monitor.
Definition: fc.h:350
struct list_head list
List of all peers.
Definition: fc.h:344
#define list_for_each_entry_safe(pos, tmp, head, member)
Iterate over entries in a list, safe against deletion of the current entry.
Definition: list.h:447
struct fc_port_id port_id
Peer port ID, if known.
Definition: fc.h:356
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static void fc_peer_put(struct fc_peer *peer)
Drop reference to Fibre Channel peer.
Definition: fc.h:390
Port is logged in to a name server.
Definition: fc.h:294
uint8_t * tmp
Definition: entropy.h:156
static struct fc_peer * fc_peer_get(struct fc_peer *peer)
Get reference to Fibre Channel peer.
Definition: fc.h:379
A Fibre Channel peer.
Definition: fc.h:340
static void fc_link_up(struct fc_link_state *link)
Mark Fibre Channel link as up.
Definition: fc.c:195
void fc_port_logout(struct fc_port *port, int rc)
Log out Fibre Channel port.
Definition: fc.c:1039
struct fc_port_id fc_gs_port_id
Generic services port ID.
Definition: fc.c:71
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:113

References DBGC, ECANCELED, fc_els_plogi(), fc_gs_port_id, 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_ptp_high_port_id, fc_ptp_low_port_id, intf_restart(), fc_peer::link, fc_peer::list, list_for_each_entry_safe, memcmp(), memcpy(), port, fc_peer::port_id, rc, strerror(), and tmp.

Referenced by fc_els_flogi_rx().

◆ fc_port_logout()

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.

1039  {
1040  struct fc_peer *peer;
1041  struct fc_peer *tmp;
1042 
1043  DBGC ( port, "FCPORT %s logged out: %s\n",
1044  port->name, strerror ( rc ) );
1045 
1046  /* Erase port details */
1047  memset ( &port->port_id, 0, sizeof ( port->port_id ) );
1048  port->flags = 0;
1049 
1050  /* Record logout */
1051  fc_link_err ( &port->link, rc );
1052 
1053  /* Notify peers of link state change */
1054  list_for_each_entry_safe ( peer, tmp, &fc_peers, list ) {
1055  fc_peer_get ( peer );
1056  fc_link_examine ( &peer->link );
1057  fc_peer_put ( peer );
1058  }
1059 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
struct list_head fc_peers
static void fc_link_examine(struct fc_link_state *link)
Examine Fibre Channel link state.
Definition: fc.c:226
#define DBGC(...)
Definition: compiler.h:505
static void fc_link_err(struct fc_link_state *link, int rc)
Mark Fibre Channel link as down.
Definition: fc.c:210
u8 port
Port number.
Definition: CIB_PRM.h:31
struct fc_link_state link
Link state monitor.
Definition: fc.h:350
struct list_head list
List of all peers.
Definition: fc.h:344
#define list_for_each_entry_safe(pos, tmp, head, member)
Iterate over entries in a list, safe against deletion of the current entry.
Definition: list.h:447
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static void fc_peer_put(struct fc_peer *peer)
Drop reference to Fibre Channel peer.
Definition: fc.h:390
uint8_t * tmp
Definition: entropy.h:156
static struct fc_peer * fc_peer_get(struct fc_peer *peer)
Get reference to Fibre Channel peer.
Definition: fc.h:379
A Fibre Channel peer.
Definition: fc.h:340
void * memset(void *dest, int character, size_t len) __nonnull

References DBGC, fc_link_err(), fc_link_examine(), fc_peer_get(), fc_peer_put(), fc_peers, fc_peer::link, fc_peer::list, list_for_each_entry_safe, memset(), port, rc, strerror(), and tmp.

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

◆ fc_port_open()

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.

1190  {
1191  struct fc_port *port;
1192 
1193  /* Allocate and initialise structure */
1194  port = zalloc ( sizeof ( *port ) );
1195  if ( ! port )
1196  return -ENOMEM;
1197  ref_init ( &port->refcnt, NULL );
1198  intf_init ( &port->transport, &fc_port_transport_desc, &port->refcnt );
1199  fc_link_init ( &port->link, fc_port_examine, &port->refcnt );
1200  intf_init ( &port->flogi, &fc_port_flogi_desc, &port->refcnt );
1201  intf_init ( &port->ns_plogi, &fc_port_ns_plogi_desc, &port->refcnt );
1202  list_add_tail ( &port->list, &fc_ports );
1203  INIT_LIST_HEAD ( &port->xchgs );
1204  memcpy ( &port->node_wwn, node_wwn, sizeof ( port->node_wwn ) );
1205  memcpy ( &port->port_wwn, port_wwn, sizeof ( port->port_wwn ) );
1206  snprintf ( port->name, sizeof ( port->name ), "%s", name );
1207 
1208  DBGC ( port, "FCPORT %s opened as %s",
1209  port->name, fc_ntoa ( &port->node_wwn ) );
1210  DBGC ( port, " port %s\n", fc_ntoa ( &port->port_wwn ) );
1211 
1212  /* Attach to transport layer, mortalise self, and return */
1213  intf_plug_plug ( &port->transport, transport );
1214  ref_put ( &port->refcnt );
1215  return 0;
1216 }
struct fc_name port_wwn
Port name.
Definition: fc.h:265
static void fc_port_examine(struct fc_link_state *link)
Examine Fibre Channel port link state.
Definition: fc.c:1101
const char * name
Definition: ath9k_hw.c:1984
#define ref_init(refcnt, free)
Initialise a reference counter.
Definition: refcnt.h:64
static void fc_link_init(struct fc_link_state *link, void(*examine)(struct fc_link_state *link), struct refcnt *refcnt)
Initialise Fibre Channel link state monitor.
Definition: fc.c:252
#define DBGC(...)
Definition: compiler.h:505
struct fc_name node_wwn
Node name.
Definition: fc.h:263
void intf_plug_plug(struct interface *a, struct interface *b)
Plug two object interfaces together.
Definition: interface.c:102
const char * fc_ntoa(const struct fc_name *wwn)
Format Fibre Channel WWN.
Definition: fc.c:127
struct list_head fc_ports
A Fibre Channel port.
Definition: fc.h:252
#define ENOMEM
Not enough space.
Definition: errno.h:534
void * memcpy(void *dest, const void *src, size_t len) __nonnull
u8 port
Port number.
Definition: CIB_PRM.h:31
static struct interface_descriptor fc_port_flogi_desc
Fibre Channel port FLOGI interface descriptor.
Definition: fc.c:1168
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
Definition: list.h:93
static struct interface_descriptor fc_port_ns_plogi_desc
Fibre Channel port name server PLOGI interface descriptor.
Definition: fc.c:1177
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
#define INIT_LIST_HEAD(list)
Initialise a list head.
Definition: list.h:45
struct interface transport
Transport interface.
Definition: fc.h:261
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
Definition: vsprintf.c:382
static void intf_init(struct interface *intf, struct interface_descriptor *desc, struct refcnt *refcnt)
Initialise an object interface.
Definition: interface.h:173
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
static struct interface_descriptor fc_port_transport_desc
Fibre Channel port transport interface descriptor.
Definition: fc.c:1159
#define ref_put(refcnt)
Drop reference to object.
Definition: refcnt.h:106

References DBGC, ENOMEM, fc_link_init(), fc_ntoa(), fc_port_examine(), fc_port_flogi_desc, fc_port_ns_plogi_desc, fc_port_transport_desc, fc_ports, INIT_LIST_HEAD, intf_init(), intf_plug_plug(), list_add_tail, memcpy(), name, fc_port::node_wwn, NULL, port, fc_port::port_wwn, ref_init, ref_put, snprintf(), fc_port::transport, and zalloc().

Referenced by fcoe_expired().

◆ fc_port_find()

struct fc_port* fc_port_find ( const char *  name)

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.

1224  {
1225  struct fc_port *port;
1226 
1228  if ( strcmp ( name, port->name ) == 0 )
1229  return port;
1230  }
1231  return NULL;
1232 }
const char * name
Definition: ath9k_hw.c:1984
struct list_head list
List of all ports.
Definition: fc.h:256
struct list_head fc_ports
A Fibre Channel port.
Definition: fc.h:252
u8 port
Port number.
Definition: CIB_PRM.h:31
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:420
int strcmp(const char *first, const char *second)
Compare strings.
Definition: string.c:172
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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

Referenced by parse_fc_port().

◆ fc_peer_get()

static struct fc_peer* fc_peer_get ( struct fc_peer peer)
inlinestatic

Get reference to Fibre Channel peer.

Parameters
peerFibre Channel peer
Return values
peerFibre Channel peer

Definition at line 379 of file fc.h.

379  {
380  ref_get ( &peer->refcnt );
381  return peer;
382 }
struct refcnt refcnt
Reference count.
Definition: fc.h:342
#define ref_get(refcnt)
Get additional reference to object.
Definition: refcnt.h:92

References ref_get, and fc_peer::refcnt.

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().

◆ fc_peer_put()

static void fc_peer_put ( struct fc_peer peer)
inlinestatic

Drop reference to Fibre Channel peer.

Parameters
peerFibre Channel peer

Definition at line 390 of file fc.h.

390  {
391  ref_put ( &peer->refcnt );
392 }
struct refcnt refcnt
Reference count.
Definition: fc.h:342
#define ref_put(refcnt)
Drop reference to object.
Definition: refcnt.h:106

References ref_put, and fc_peer::refcnt.

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().

◆ fc_peer_get_wwn()

struct fc_peer* fc_peer_get_wwn ( const struct fc_name port_wwn)

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.

1516  {
1517  struct fc_peer *peer;
1518 
1519  /* Look for an existing peer */
1520  list_for_each_entry ( peer, &fc_peers, list ) {
1521  if ( memcmp ( &peer->port_wwn, port_wwn,
1522  sizeof ( peer->port_wwn ) ) == 0 )
1523  return fc_peer_get ( peer );
1524  }
1525 
1526  /* Create a new peer */
1527  peer = fc_peer_create ( port_wwn );
1528  if ( ! peer )
1529  return NULL;
1530 
1531  return peer;
1532 }
struct list_head fc_peers
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:420
struct list_head list
List of all peers.
Definition: fc.h:344
static struct fc_peer * fc_peer_create(const struct fc_name *port_wwn)
Create Fibre Channel peer.
Definition: fc.c:1489
struct fc_name port_wwn
Port name.
Definition: fc.h:347
static struct fc_peer * fc_peer_get(struct fc_peer *peer)
Get reference to Fibre Channel peer.
Definition: fc.h:379
A Fibre Channel peer.
Definition: fc.h:340
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:113
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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().

◆ fc_peer_get_port_id()

struct fc_peer* fc_peer_get_port_id ( struct fc_port port,
const struct fc_port_id peer_port_id 
)

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.

1542  {
1543  struct fc_peer *peer;
1544 
1545  /* Look for an existing peer */
1546  list_for_each_entry ( peer, &fc_peers, list ) {
1547  if ( ( peer->port == port ) &&
1548  ( memcmp ( &peer->port_id, peer_port_id,
1549  sizeof ( peer->port_id ) ) == 0 ) )
1550  return fc_peer_get ( peer );
1551  }
1552 
1553  /* Cannot create a new peer, since we have no port name to use */
1554  return NULL;
1555 }
struct list_head fc_peers
struct fc_port * port
Fibre Channel port, if known.
Definition: fc.h:354
u8 port
Port number.
Definition: CIB_PRM.h:31
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:420
struct list_head list
List of all peers.
Definition: fc.h:344
struct fc_port_id port_id
Peer port ID, if known.
Definition: fc.h:356
static struct fc_peer * fc_peer_get(struct fc_peer *peer)
Get reference to Fibre Channel peer.
Definition: fc.h:379
A Fibre Channel peer.
Definition: fc.h:340
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:113
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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

Referenced by fc_els_logo_logout(), and fc_ulp_get_port_id_type().

◆ fc_peer_login()

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.

1301  {
1302  struct fc_ulp *ulp;
1303  struct fc_ulp *tmp;
1304 
1305  /* Perform implicit logout if logged in and details differ */
1306  if ( fc_link_ok ( &peer->link ) &&
1307  ( ( peer->port != port ) ||
1308  ( memcmp ( &peer->port_id, port_id,
1309  sizeof ( peer->port_id ) ) !=0 ) ) ) {
1310  fc_peer_logout ( peer, 0 );
1311  }
1312 
1313  /* Log in, if applicable */
1314  if ( ! fc_link_ok ( &peer->link ) ) {
1315 
1316  /* Record peer details */
1317  assert ( peer->port == NULL );
1318  peer->port = fc_port_get ( port );
1319  memcpy ( &peer->port_id, port_id, sizeof ( peer->port_id ) );
1320  DBGC ( peer, "FCPEER %s logged in via %s as %s\n",
1321  fc_ntoa ( &peer->port_wwn ), peer->port->name,
1322  fc_id_ntoa ( &peer->port_id ) );
1323 
1324  /* Add login reference */
1325  fc_peer_get ( peer );
1326  }
1327 
1328  /* Record login */
1329  fc_link_up ( &peer->link );
1330 
1331  /* Notify ULPs of link state change */
1332  list_for_each_entry_safe ( ulp, tmp, &peer->ulps, list ) {
1333  fc_ulp_get ( ulp );
1334  fc_link_examine ( &ulp->link );
1335  fc_ulp_put ( ulp );
1336  }
1337 
1338  return 0;
1339 }
char name[8]
Name of this port.
Definition: fc.h:258
const char * fc_id_ntoa(const struct fc_port_id *id)
Format Fibre Channel port ID.
Definition: fc.c:92
static void fc_link_examine(struct fc_link_state *link)
Examine Fibre Channel link state.
Definition: fc.c:226
#define DBGC(...)
Definition: compiler.h:505
struct list_head list
List of upper-layer protocols.
Definition: fc.h:419
const char * fc_ntoa(const struct fc_name *wwn)
Format Fibre Channel WWN.
Definition: fc.c:127
struct fc_peer * peer
Fibre Channel peer.
Definition: fc.h:417
struct fc_port * port
Fibre Channel port, if known.
Definition: fc.h:354
void * memcpy(void *dest, const void *src, size_t len) __nonnull
u8 port
Port number.
Definition: CIB_PRM.h:31
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
struct list_head ulps
List of upper-layer protocols.
Definition: fc.h:359
static int fc_link_ok(struct fc_link_state *link)
Check Fibre Channel link state.
Definition: fc.h:108
struct fc_link_state link
Link state monitor.
Definition: fc.h:350
#define list_for_each_entry_safe(pos, tmp, head, member)
Iterate over entries in a list, safe against deletion of the current entry.
Definition: list.h:447
struct fc_port_id port_id
Peer port ID, if known.
Definition: fc.h:356
static struct fc_ulp * fc_ulp_get(struct fc_ulp *ulp)
Get reference to Fibre Channel upper-layer protocol.
Definition: fc.h:474
uint8_t * tmp
Definition: entropy.h:156
struct fc_link_state link
Link state monitor.
Definition: fc.h:427
void fc_peer_logout(struct fc_peer *peer, int rc)
Log out Fibre Channel peer.
Definition: fc.c:1347
struct fc_name port_wwn
Port name.
Definition: fc.h:347
static struct fc_peer * fc_peer_get(struct fc_peer *peer)
Get reference to Fibre Channel peer.
Definition: fc.h:379
static struct fc_port * fc_port_get(struct fc_port *port)
Get reference to Fibre Channel port.
Definition: fc.h:304
static void fc_link_up(struct fc_link_state *link)
Mark Fibre Channel link as up.
Definition: fc.c:195
static void fc_ulp_put(struct fc_ulp *ulp)
Drop reference to Fibre Channel upper-layer protocol.
Definition: fc.h:485
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:113
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
A Fibre Channel upper-layer protocol.
Definition: fc.h:413

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_ulp::peer, port, fc_peer::port, fc_peer::port_id, fc_peer::port_wwn, tmp, and fc_peer::ulps.

Referenced by fc_els_plogi_rx().

◆ fc_peer_logout()

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.

1347  {
1348  struct fc_ulp *ulp;
1349  struct fc_ulp *tmp;
1350 
1351  DBGC ( peer, "FCPEER %s logged out: %s\n",
1352  fc_ntoa ( &peer->port_wwn ), strerror ( rc ) );
1353 
1354  /* Drop login reference, if applicable */
1355  if ( fc_link_ok ( &peer->link ) )
1356  fc_peer_put ( peer );
1357 
1358  /* Erase peer details */
1359  fc_port_put ( peer->port );
1360  peer->port = NULL;
1361 
1362  /* Record logout */
1363  fc_link_err ( &peer->link, rc );
1364 
1365  /* Notify ULPs of link state change */
1366  list_for_each_entry_safe ( ulp, tmp, &peer->ulps, list ) {
1367  fc_ulp_get ( ulp );
1368  fc_link_examine ( &ulp->link );
1369  fc_ulp_put ( ulp );
1370  }
1371 
1372  /* Close peer if there are no active users */
1373  if ( peer->usage == 0 )
1374  fc_peer_close ( peer, rc );
1375 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static void fc_link_examine(struct fc_link_state *link)
Examine Fibre Channel link state.
Definition: fc.c:226
#define DBGC(...)
Definition: compiler.h:505
struct list_head list
List of upper-layer protocols.
Definition: fc.h:419
static void fc_port_put(struct fc_port *port)
Drop reference to Fibre Channel port.
Definition: fc.h:315
const char * fc_ntoa(const struct fc_name *wwn)
Format Fibre Channel WWN.
Definition: fc.c:127
static void fc_link_err(struct fc_link_state *link, int rc)
Mark Fibre Channel link as down.
Definition: fc.c:210
struct fc_peer * peer
Fibre Channel peer.
Definition: fc.h:417
struct fc_port * port
Fibre Channel port, if known.
Definition: fc.h:354
struct list_head ulps
List of upper-layer protocols.
Definition: fc.h:359
static int fc_link_ok(struct fc_link_state *link)
Check Fibre Channel link state.
Definition: fc.h:108
struct fc_link_state link
Link state monitor.
Definition: fc.h:350
unsigned int usage
Active usage count.
Definition: fc.h:369
#define list_for_each_entry_safe(pos, tmp, head, member)
Iterate over entries in a list, safe against deletion of the current entry.
Definition: list.h:447
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static void fc_peer_put(struct fc_peer *peer)
Drop reference to Fibre Channel peer.
Definition: fc.h:390
static struct fc_ulp * fc_ulp_get(struct fc_ulp *ulp)
Get reference to Fibre Channel upper-layer protocol.
Definition: fc.h:474
uint8_t * tmp
Definition: entropy.h:156
struct fc_link_state link
Link state monitor.
Definition: fc.h:427
struct fc_name port_wwn
Port name.
Definition: fc.h:347
static void fc_peer_close(struct fc_peer *peer, int rc)
Close Fibre Channel peer.
Definition: fc.c:1247
static void fc_ulp_put(struct fc_ulp *ulp)
Drop reference to Fibre Channel upper-layer protocol.
Definition: fc.h:485
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
A Fibre Channel upper-layer protocol.
Definition: fc.h:413

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_ulp::peer, fc_peer::port, fc_peer::port_wwn, rc, strerror(), tmp, 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().

◆ fc_ulp_get()

static struct fc_ulp* fc_ulp_get ( struct fc_ulp ulp)
inlinestatic

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.

474  {
475  ref_get ( &ulp->refcnt );
476  return ulp;
477 }
#define ref_get(refcnt)
Get additional reference to object.
Definition: refcnt.h:92
struct refcnt refcnt
Reference count.
Definition: fc.h:415

References ref_get, and fc_ulp::refcnt.

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

◆ fc_ulp_put()

static void fc_ulp_put ( struct fc_ulp ulp)
inlinestatic

Drop reference to Fibre Channel upper-layer protocol.

Parameters
ulpFibre Channel upper-layer protocol

Definition at line 485 of file fc.h.

485  {
486  ref_put ( &ulp->refcnt );
487 }
struct refcnt refcnt
Reference count.
Definition: fc.h:415
#define ref_put(refcnt)
Drop reference to object.
Definition: refcnt.h:106

References ref_put, and fc_ulp::refcnt.

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().

◆ fc_ulp_user_get()

static struct fc_ulp_user* fc_ulp_user_get ( struct fc_ulp_user user)
inlinestatic

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.

496  {
497  ref_get ( user->refcnt );
498  return user;
499 }
struct ntlm_data user
User name.
Definition: ntlm.h:20
#define ref_get(refcnt)
Get additional reference to object.
Definition: refcnt.h:92

References ref_get, and user.

Referenced by fc_ulp_login(), and fc_ulp_logout().

◆ fc_ulp_user_put()

static void fc_ulp_user_put ( struct fc_ulp_user user)
inlinestatic

Drop reference to Fibre Channel upper-layer protocol user.

Parameters
userFibre Channel upper-layer protocol user

Definition at line 507 of file fc.h.

507  {
508  ref_put ( user->refcnt );
509 }
struct ntlm_data user
User name.
Definition: ntlm.h:20
#define ref_put(refcnt)
Drop reference to object.
Definition: refcnt.h:106

References ref_put, and user.

Referenced by fc_ulp_login(), and fc_ulp_logout().

◆ fc_ulp_user_init()

static void fc_ulp_user_init ( struct fc_ulp_user user,
void(*)(struct fc_ulp_user *user examine,
struct refcnt refcnt 
)
inlinestatic

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.

521  {
522  user->examine = examine;
523  user->refcnt = refcnt;
524 }
static void(*) struct refcnt refcnt)
Definition: pool.h:62
struct ntlm_data user
User name.
Definition: ntlm.h:20

References fc_ulp_user::examine, refcnt, and user.

Referenced by fcpdev_open().

◆ fc_ulp_get_wwn_type()

struct fc_ulp* fc_ulp_get_wwn_type ( const struct fc_name port_wwn,
unsigned int  type 
)

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.

1881  {
1882  struct fc_ulp *ulp;
1883  struct fc_peer *peer;
1884 
1885  /* Get peer */
1886  peer = fc_peer_get_wwn ( port_wwn );
1887  if ( ! peer )
1888  goto err_peer_get_wwn;
1889 
1890  /* Get ULP */
1891  ulp = fc_ulp_get_type ( peer, type );
1892  if ( ! ulp )
1893  goto err_ulp_get_type;
1894 
1895  /* Drop temporary reference to peer */
1896  fc_peer_put ( peer );
1897 
1898  return ulp;
1899 
1900  fc_ulp_put ( ulp );
1901  err_ulp_get_type:
1902  fc_peer_put ( peer );
1903  err_peer_get_wwn:
1904  return NULL;
1905 }
static struct fc_ulp * fc_ulp_get_type(struct fc_peer *peer, unsigned int type)
Get Fibre Channel upper-layer protocol by peer and type.
Definition: fc.c:1855
uint8_t type
Type.
Definition: ena.h:16
struct fc_peer * fc_peer_get_wwn(const struct fc_name *port_wwn)
Get Fibre Channel peer by node name.
Definition: fc.c:1516
static void fc_peer_put(struct fc_peer *peer)
Drop reference to Fibre Channel peer.
Definition: fc.h:390
struct fc_name port_wwn
Port name.
Definition: fc.h:347
A Fibre Channel peer.
Definition: fc.h:340
static void fc_ulp_put(struct fc_ulp *ulp)
Drop reference to Fibre Channel upper-layer protocol.
Definition: fc.h:485
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
A Fibre Channel upper-layer protocol.
Definition: fc.h:413

References fc_peer_get_wwn(), fc_peer_put(), fc_ulp_get_type(), fc_ulp_put(), NULL, fc_peer::port_wwn, and type.

Referenced by fcpdev_open().

◆ fc_ulp_get_port_id_type()

struct fc_ulp* fc_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.

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.

1917  {
1918  struct fc_ulp *ulp;
1919  struct fc_peer *peer;
1920 
1921  /* Get peer */
1922  peer = fc_peer_get_port_id ( port, peer_port_id );
1923  if ( ! peer )
1924  goto err_peer_get_wwn;
1925 
1926  /* Get ULP */
1927  ulp = fc_ulp_get_type ( peer, type );
1928  if ( ! ulp )
1929  goto err_ulp_get_type;
1930 
1931  /* Drop temporary reference to peer */
1932  fc_peer_put ( peer );
1933 
1934  return ulp;
1935 
1936  fc_ulp_put ( ulp );
1937  err_ulp_get_type:
1938  fc_peer_put ( peer );
1939  err_peer_get_wwn:
1940  return NULL;
1941 }
static struct fc_ulp * fc_ulp_get_type(struct fc_peer *peer, unsigned int type)
Get Fibre Channel upper-layer protocol by peer and type.
Definition: fc.c:1855
uint8_t type
Type.
Definition: ena.h:16
u8 port
Port number.
Definition: CIB_PRM.h:31
struct fc_peer * fc_peer_get_port_id(struct fc_port *port, const struct fc_port_id *peer_port_id)
Get Fibre Channel peer by port ID.
Definition: fc.c:1541
static void fc_peer_put(struct fc_peer *peer)
Drop reference to Fibre Channel peer.
Definition: fc.h:390
A Fibre Channel peer.
Definition: fc.h:340
static void fc_ulp_put(struct fc_ulp *ulp)
Drop reference to Fibre Channel upper-layer protocol.
Definition: fc.h:485
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
A Fibre Channel upper-layer protocol.
Definition: fc.h:413

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

Referenced by fc_els_prli_rx(), and fc_els_prli_tx().

◆ fc_ulp_attach()

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.

1607  {
1608 
1609  /* Sanity check */
1610  assert ( user->ulp == NULL );
1611 
1612  /* Increment peer's usage count */
1613  fc_peer_increment ( ulp->peer );
1614 
1615  /* Attach user */
1616  user->ulp = fc_ulp_get ( ulp );
1617  list_add ( &user->list, &ulp->users );
1618 }
#define list_add(new, head)
Add a new entry to the head of a list.
Definition: list.h:69
static void fc_peer_increment(struct fc_peer *peer)
Increment Fibre Channel peer active usage count.
Definition: fc.c:1271
struct fc_peer * peer
Fibre Channel peer.
Definition: fc.h:417
struct list_head users
Active users of this upper-layer protocol.
Definition: fc.h:443
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
struct ntlm_data user
User name.
Definition: ntlm.h:20
static struct fc_ulp * fc_ulp_get(struct fc_ulp *ulp)
Get reference to Fibre Channel upper-layer protocol.
Definition: fc.h:474
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

References assert(), fc_peer_increment(), fc_ulp_get(), list_add, NULL, fc_ulp::peer, user, and fc_ulp::users.

Referenced by fcpdev_open().

◆ fc_ulp_detach()

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.

1625  {
1626  struct fc_ulp *ulp = user->ulp;
1627 
1628  /* Do nothing if not attached */
1629  if ( ! ulp )
1630  return;
1631 
1632  /* Sanity checks */
1634 
1635  /* Detach user and log out if no users remain */
1636  list_del ( &user->list );
1637  if ( list_empty ( &ulp->users ) )
1638  fc_ulp_logout ( ulp, 0 );
1639 
1640  /* Decrement our peer's usage count */
1641  fc_peer_decrement ( ulp->peer );
1642 
1643  /* Drop reference */
1644  user->ulp = NULL;
1645  fc_ulp_put ( ulp );
1646 }
static void fc_peer_decrement(struct fc_peer *peer)
Decrement Fibre Channel peer active usage count.
Definition: fc.c:1282
struct list_head list
List of upper-layer protocols.
Definition: fc.h:419
struct fc_peer * peer
Fibre Channel peer.
Definition: fc.h:417
struct list_head users
Active users of this upper-layer protocol.
Definition: fc.h:443
#define list_empty(list)
Test whether a list is empty.
Definition: list.h:136
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
struct ntlm_data user
User name.
Definition: ntlm.h:20
void fc_ulp_logout(struct fc_ulp *ulp, int rc)
Log out Fibre Channel upper-layer protocol.
Definition: fc.c:1727
static void fc_ulp_put(struct fc_ulp *ulp)
Drop reference to Fibre Channel upper-layer protocol.
Definition: fc.h:485
#define list_check_contains_entry(entry, head, member)
Check list contains a specified entry.
Definition: list.h:522
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
A Fibre Channel upper-layer protocol.
Definition: fc.h:413

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

Referenced by fcpdev_close().

◆ fc_ulp_login()

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.

1658  {
1659  struct fc_ulp_user *user;
1660  struct fc_ulp_user *tmp;
1661 
1662  /* Perform implicit logout if logged in and service parameters differ */
1663  if ( fc_link_ok ( &ulp->link ) &&
1664  ( ( ulp->param_len != param_len ) ||
1665  ( memcmp ( ulp->param, param, ulp->param_len ) != 0 ) ) ) {
1666  fc_ulp_logout ( ulp, 0 );
1667  }
1668 
1669  /* Work around a bug in some versions of the Linux Fibre
1670  * Channel stack, which fail to fully initialise image pairs
1671  * established via a PRLI originated by the Linux stack
1672  * itself.
1673  */
1674  if ( originated )
1676  if ( ! ( ulp->flags & FC_ULP_ORIGINATED_LOGIN_OK ) ) {
1677  DBGC ( ulp, "FCULP %s/%02x sending extra PRLI to work around "
1678  "Linux bug\n",
1679  fc_ntoa ( &ulp->peer->port_wwn ), ulp->type );
1680  fc_link_stop ( &ulp->link );
1681  fc_link_start ( &ulp->link );
1682  return 0;
1683  }
1684 
1685  /* Log in, if applicable */
1686  if ( ! fc_link_ok ( &ulp->link ) ) {
1687 
1688  /* Record service parameters */
1689  assert ( ulp->param == NULL );
1690  assert ( ulp->param_len == 0 );
1691  ulp->param = malloc ( param_len );
1692  if ( ! ulp->param ) {
1693  DBGC ( ulp, "FCULP %s/%02x could not record "
1694  "parameters\n",
1695  fc_ntoa ( &ulp->peer->port_wwn ), ulp->type );
1696  return -ENOMEM;
1697  }
1698  memcpy ( ulp->param, param, param_len );
1699  ulp->param_len = param_len;
1700  DBGC ( ulp, "FCULP %s/%02x logged in with parameters:\n",
1701  fc_ntoa ( &ulp->peer->port_wwn ), ulp->type );
1702  DBGC_HDA ( ulp, 0, ulp->param, ulp->param_len );
1703 
1704  /* Add login reference */
1705  fc_ulp_get ( ulp );
1706  }
1707 
1708  /* Record login */
1709  fc_link_up ( &ulp->link );
1710 
1711  /* Notify users of link state change */
1713  fc_ulp_user_get ( user );
1714  user->examine ( user );
1715  fc_ulp_user_put ( user );
1716  }
1717 
1718  return 0;
1719 }
struct fc_ulp * ulp
Fibre Channel upper layer protocol.
Definition: fc.h:455
#define DBGC(...)
Definition: compiler.h:505
const char * fc_ntoa(const struct fc_name *wwn)
Format Fibre Channel WWN.
Definition: fc.c:127
struct fc_peer * peer
Fibre Channel peer.
Definition: fc.h:417
struct list_head users
Active users of this upper-layer protocol.
Definition: fc.h:443
struct list_head list
List of users.
Definition: fc.h:457
static struct fc_ulp_user * fc_ulp_user_get(struct fc_ulp_user *user)
Get reference to Fibre Channel upper-layer protocol user.
Definition: fc.h:496
#define ENOMEM
Not enough space.
Definition: errno.h:534
void * memcpy(void *dest, const void *src, size_t len) __nonnull
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
struct ntlm_data user
User name.
Definition: ntlm.h:20
size_t param_len
Service parameter length.
Definition: fc.h:433
#define DBGC_HDA(...)
Definition: compiler.h:506
static int fc_link_ok(struct fc_link_state *link)
Check Fibre Channel link state.
Definition: fc.h:108
A login originated by us has succeeded.
Definition: fc.h:449
#define list_for_each_entry_safe(pos, tmp, head, member)
Iterate over entries in a list, safe against deletion of the current entry.
Definition: list.h:447
unsigned int type
Type.
Definition: fc.h:422
void * param
Service parameters, if any.
Definition: fc.h:431
static struct fc_ulp * fc_ulp_get(struct fc_ulp *ulp)
Get reference to Fibre Channel upper-layer protocol.
Definition: fc.h:474
struct hv_monitor_parameter param[4][32]
Parameters.
Definition: hyperv.h:24
uint8_t * tmp
Definition: entropy.h:156
struct fc_link_state link
Link state monitor.
Definition: fc.h:427
struct fc_name port_wwn
Port name.
Definition: fc.h:347
static void fc_ulp_user_put(struct fc_ulp_user *user)
Drop reference to Fibre Channel upper-layer protocol user.
Definition: fc.h:507
A Fibre Channel upper-layer protocol user.
Definition: fc.h:453
void * malloc(size_t size)
Allocate memory.
Definition: malloc.c:583
static void fc_link_stop(struct fc_link_state *link)
Stop monitoring Fibre Channel link state.
Definition: fc.c:275
void fc_ulp_logout(struct fc_ulp *ulp, int rc)
Log out Fibre Channel upper-layer protocol.
Definition: fc.c:1727
static void fc_link_up(struct fc_link_state *link)
Mark Fibre Channel link as up.
Definition: fc.c:195
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:113
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
unsigned int flags
Flags.
Definition: fc.h:424
static void fc_link_start(struct fc_link_state *link)
Start monitoring Fibre Channel link state.
Definition: fc.c:266

References assert(), DBGC, DBGC_HDA, ENOMEM, 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, param, fc_ulp::param, fc_ulp::param_len, fc_ulp::peer, fc_peer::port_wwn, tmp, fc_ulp::type, fc_ulp_user::ulp, user, and fc_ulp::users.

Referenced by fc_els_prli_rx().

◆ fc_ulp_logout()

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.

1727  {
1728  struct fc_ulp_user *user;
1729  struct fc_ulp_user *tmp;
1730 
1731  DBGC ( ulp, "FCULP %s/%02x logged out: %s\n",
1732  fc_ntoa ( &ulp->peer->port_wwn ), ulp->type, strerror ( rc ) );
1733 
1734  /* Drop login reference, if applicable */
1735  if ( fc_link_ok ( &ulp->link ) )
1736  fc_ulp_put ( ulp );
1737 
1738  /* Discard service parameters */
1739  free ( ulp->param );
1740  ulp->param = NULL;
1741  ulp->param_len = 0;
1742  ulp->flags = 0;
1743 
1744  /* Record logout */
1745  fc_link_err ( &ulp->link, rc );
1746 
1747  /* Notify users of link state change */
1749  fc_ulp_user_get ( user );
1750  user->examine ( user );
1751  fc_ulp_user_put ( user );
1752  }
1753 
1754  /* Close ULP if there are no clients attached */
1755  if ( list_empty ( &ulp->users ) )
1756  fc_ulp_close ( ulp, rc );
1757 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
struct fc_ulp * ulp
Fibre Channel upper layer protocol.
Definition: fc.h:455
#define DBGC(...)
Definition: compiler.h:505
const char * fc_ntoa(const struct fc_name *wwn)
Format Fibre Channel WWN.
Definition: fc.c:127
static void fc_link_err(struct fc_link_state *link, int rc)
Mark Fibre Channel link as down.
Definition: fc.c:210
struct fc_peer * peer
Fibre Channel peer.
Definition: fc.h:417
struct list_head users
Active users of this upper-layer protocol.
Definition: fc.h:443
struct list_head list
List of users.
Definition: fc.h:457
#define list_empty(list)
Test whether a list is empty.
Definition: list.h:136
static struct fc_ulp_user * fc_ulp_user_get(struct fc_ulp_user *user)
Get reference to Fibre Channel upper-layer protocol user.
Definition: fc.h:496
struct ntlm_data user
User name.
Definition: ntlm.h:20
size_t param_len
Service parameter length.
Definition: fc.h:433
static int fc_link_ok(struct fc_link_state *link)
Check Fibre Channel link state.
Definition: fc.h:108
#define list_for_each_entry_safe(pos, tmp, head, member)
Iterate over entries in a list, safe against deletion of the current entry.
Definition: list.h:447
unsigned int type
Type.
Definition: fc.h:422
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
void * param
Service parameters, if any.
Definition: fc.h:431
uint8_t * tmp
Definition: entropy.h:156
struct fc_link_state link
Link state monitor.
Definition: fc.h:427
struct fc_name port_wwn
Port name.
Definition: fc.h:347
static void fc_ulp_user_put(struct fc_ulp_user *user)
Drop reference to Fibre Channel upper-layer protocol user.
Definition: fc.h:507
A Fibre Channel upper-layer protocol user.
Definition: fc.h:453
static void fc_ulp_put(struct fc_ulp *ulp)
Drop reference to Fibre Channel upper-layer protocol.
Definition: fc.h:485
static void fc_ulp_close(struct fc_ulp *ulp, int rc)
Close Fibre Channel upper-layer protocol.
Definition: fc.c:1582
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
unsigned int flags
Flags.
Definition: fc.h:424

References DBGC, 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, rc, strerror(), tmp, fc_ulp::type, fc_ulp_user::ulp, 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().

Variable Documentation

◆ fc_empty_port_id

struct fc_port_id fc_empty_port_id

Unassigned port ID.

Definition at line 65 of file fc.c.

Referenced by fc_port_deliver(), and fcels_exec().

◆ fc_f_port_id

struct fc_port_id fc_f_port_id

F_Port contoller port ID.

Definition at line 68 of file fc.c.

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

◆ fc_gs_port_id

struct fc_port_id fc_gs_port_id

Generic services port ID.

Definition at line 71 of file fc.c.

Referenced by fc_ns_query_step(), and fc_port_login().

◆ fc_ptp_low_port_id

struct fc_port_id fc_ptp_low_port_id

Point-to-point low port ID.

Definition at line 74 of file fc.c.

Referenced by fc_port_login().

◆ fc_ptp_high_port_id

struct fc_port_id fc_ptp_high_port_id

Point-to-point high port ID.

Definition at line 77 of file fc.c.

Referenced by fc_port_login().

◆ fc_ports

struct list_head fc_ports

◆ fc_peers

struct list_head fc_peers