summaryrefslogtreecommitdiffstats
path: root/src/net/fcp.c
diff options
context:
space:
mode:
authorMichael Brown2011-06-24 23:49:10 +0200
committerMichael Brown2011-06-28 15:45:01 +0200
commitbf8bfa23e2364793ccdfc32627d8094a74ae87aa (patch)
tree53d20e95786d13330f92b1d1df539d608bcd7bf1 /src/net/fcp.c
parent[ftp] Remove redundant ftp_data_deliver() method (diff)
downloadipxe-bf8bfa23e2364793ccdfc32627d8094a74ae87aa.tar.gz
ipxe-bf8bfa23e2364793ccdfc32627d8094a74ae87aa.tar.xz
ipxe-bf8bfa23e2364793ccdfc32627d8094a74ae87aa.zip
[fc] Maintain a list of Fibre Channel upper-layer protocol users
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/net/fcp.c')
-rw-r--r--src/net/fcp.c32
1 files changed, 14 insertions, 18 deletions
diff --git a/src/net/fcp.c b/src/net/fcp.c
index 40cd057e..28d2095d 100644
--- a/src/net/fcp.c
+++ b/src/net/fcp.c
@@ -146,8 +146,8 @@ struct fc_els_prli_descriptor fcp_prli_descriptor __fc_els_prli_descriptor = {
struct fcp_device {
/** Reference count */
struct refcnt refcnt;
- /** Fibre Channel upper-layer protocol */
- struct fc_ulp *ulp;
+ /** Fibre Channel upper-layer protocol user */
+ struct fc_ulp_user user;
/** SCSI command issuing interface */
struct interface scsi;
/** List of active commands */
@@ -734,13 +734,13 @@ static struct interface_descriptor fcpcmd_xchg_desc =
static int fcpdev_scsi_command ( struct fcp_device *fcpdev,
struct interface *parent,
struct scsi_cmd *command ) {
- struct fcp_prli_service_parameters *param = fcpdev->ulp->param;
+ struct fcp_prli_service_parameters *param = fcpdev->user.ulp->param;
struct fcp_command *fcpcmd;
int xchg_id;
int rc;
/* Check link */
- if ( ( rc = fcpdev->ulp->link.rc ) != 0 ) {
+ if ( ( rc = fcpdev->user.ulp->link.rc ) != 0 ) {
DBGC ( fcpdev, "FCP %p could not issue command while link is "
"down: %s\n", fcpdev, strerror ( rc ) );
goto err_link;
@@ -748,7 +748,7 @@ static int fcpdev_scsi_command ( struct fcp_device *fcpdev,
/* Check target capability */
assert ( param != NULL );
- assert ( fcpdev->ulp->param_len >= sizeof ( *param ) );
+ assert ( fcpdev->user.ulp->param_len >= sizeof ( *param ) );
if ( ! ( param->flags & htonl ( FCP_PRLI_TARGET ) ) ) {
DBGC ( fcpdev, "FCP %p could not issue command: not a target\n",
fcpdev );
@@ -772,8 +772,8 @@ static int fcpdev_scsi_command ( struct fcp_device *fcpdev,
/* Create new exchange */
if ( ( xchg_id = fc_xchg_originate ( &fcpcmd->xchg,
- fcpdev->ulp->peer->port,
- &fcpdev->ulp->peer->port_id,
+ fcpdev->user.ulp->peer->port,
+ &fcpdev->user.ulp->peer->port_id,
FC_TYPE_FCP ) ) < 0 ) {
rc = xchg_id;
DBGC ( fcpdev, "FCP %p could not create exchange: %s\n",
@@ -822,11 +822,7 @@ static void fcpdev_close ( struct fcp_device *fcpdev, int rc ) {
}
/* Drop reference to ULP */
- if ( fcpdev->ulp ) {
- fc_ulp_decrement ( fcpdev->ulp );
- fc_ulp_put ( fcpdev->ulp );
- fcpdev->ulp = NULL;
- }
+ fc_ulp_detach ( &fcpdev->user );
}
/**
@@ -836,7 +832,8 @@ static void fcpdev_close ( struct fcp_device *fcpdev, int rc ) {
* @ret len Length of window
*/
static size_t fcpdev_window ( struct fcp_device *fcpdev ) {
- return ( fc_link_ok ( &fcpdev->ulp->link ) ? ~( ( size_t ) 0 ) : 0 );
+ return ( fc_link_ok ( &fcpdev->user.ulp->link ) ?
+ ~( ( size_t ) 0 ) : 0 );
}
/**
@@ -897,15 +894,15 @@ static struct device * fcpdev_identify_device ( struct fcp_device *fcpdev ) {
/* We know the underlying device only if the link is up;
* otherwise we don't have a port to examine.
*/
- if ( ! fc_link_ok ( &fcpdev->ulp->link ) ) {
+ if ( ! fc_link_ok ( &fcpdev->user.ulp->link ) ) {
DBGC ( fcpdev, "FCP %p doesn't know underlying device "
"until link is up\n", fcpdev );
return NULL;
}
/* Hand off to port's transport interface */
- assert ( fcpdev->ulp->peer->port != NULL );
- return identify_device ( &fcpdev->ulp->peer->port->transport );
+ assert ( fcpdev->user.ulp->peer->port != NULL );
+ return identify_device ( &fcpdev->user.ulp->peer->port->transport );
}
/** FCP device SCSI interface operations */
@@ -953,8 +950,7 @@ static int fcpdev_open ( struct interface *parent, struct fc_name *wwn,
ref_init ( &fcpdev->refcnt, NULL );
intf_init ( &fcpdev->scsi, &fcpdev_scsi_desc, &fcpdev->refcnt );
INIT_LIST_HEAD ( &fcpdev->fcpcmds );
- fcpdev->ulp = fc_ulp_get ( ulp );
- fc_ulp_increment ( fcpdev->ulp );
+ fc_ulp_attach ( ulp, &fcpdev->user );
DBGC ( fcpdev, "FCP %p opened for %s\n", fcpdev, fc_ntoa ( wwn ) );