summaryrefslogtreecommitdiffstats
path: root/src/drivers/block
diff options
context:
space:
mode:
authorMichael Brown2010-06-16 02:31:29 +0200
committerMichael Brown2010-06-22 16:50:31 +0200
commit4327d5d39f101f1df0ace6c03f3b3ada5f6a6213 (patch)
treeccf92bdfd23046b6c7f64f87b57350f02f63ad6f /src/drivers/block
parent[interface] Convert all name-resolution interfaces to generic interfaces (diff)
downloadipxe-4327d5d39f101f1df0ace6c03f3b3ada5f6a6213.tar.gz
ipxe-4327d5d39f101f1df0ace6c03f3b3ada5f6a6213.tar.xz
ipxe-4327d5d39f101f1df0ace6c03f3b3ada5f6a6213.zip
[interface] Convert all data-xfer interfaces to generic interfaces
Remove data-xfer as an interface type, and replace data-xfer interfaces with generic interfaces supporting the data-xfer methods. Filter interfaces (as used by the TLS layer) are handled using the generic pass-through interface capability. A side-effect of this is that deliver_raw() no longer exists as a data-xfer method. (In practice this doesn't lose any efficiency, since there are no instances within the current codebase where xfer_deliver_raw() is used to pass data to an interface supporting the deliver_raw() method.) Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/drivers/block')
-rw-r--r--src/drivers/block/srp.c46
1 files changed, 14 insertions, 32 deletions
diff --git a/src/drivers/block/srp.c b/src/drivers/block/srp.c
index 49fb214e..a8deab15 100644
--- a/src/drivers/block/srp.c
+++ b/src/drivers/block/srp.c
@@ -75,7 +75,7 @@ static void srp_scsi_done ( struct srp_device *srp, int rc ) {
static void srp_fail ( struct srp_device *srp, int rc ) {
/* Close underlying socket */
- xfer_close ( &srp->socket, rc );
+ intf_restart ( &srp->socket, rc );
/* Clear session state */
srp->state = 0;
@@ -364,16 +364,14 @@ static int srp_unrecognised ( struct srp_device *srp,
/**
* Receive data from underlying socket
*
- * @v xfer Data transfer interface
+ * @v srp SRP device
* @v iobuf Datagram I/O buffer
* @v meta Data transfer metadata
* @ret rc Return status code
*/
-static int srp_xfer_deliver_iob ( struct xfer_interface *xfer,
- struct io_buffer *iobuf,
- struct xfer_metadata *meta __unused ) {
- struct srp_device *srp =
- container_of ( xfer, struct srp_device, socket );
+static int srp_xfer_deliver ( struct srp_device *srp,
+ struct io_buffer *iobuf,
+ struct xfer_metadata *meta __unused ) {
struct srp_common *common = iobuf->data;
int ( * type ) ( struct srp_device *srp, struct io_buffer *iobuf );
int rc;
@@ -405,31 +403,16 @@ static int srp_xfer_deliver_iob ( struct xfer_interface *xfer,
return rc;
}
-/**
- * Underlying socket closed
- *
- * @v xfer Data transfer interface
- * @v rc Reason for close
- */
-static void srp_xfer_close ( struct xfer_interface *xfer, int rc ) {
- struct srp_device *srp =
- container_of ( xfer, struct srp_device, socket );
-
- DBGC ( srp, "SRP %p socket closed: %s\n", srp, strerror ( rc ) );
-
- srp_fail ( srp, rc );
-}
-
/** SRP data transfer interface operations */
-static struct xfer_interface_operations srp_xfer_operations = {
- .close = srp_xfer_close,
- .vredirect = ignore_xfer_vredirect,
- .window = unlimited_xfer_window,
- .alloc_iob = default_xfer_alloc_iob,
- .deliver_iob = srp_xfer_deliver_iob,
- .deliver_raw = xfer_deliver_as_iob,
+static struct interface_operation srp_xfer_operations[] = {
+ INTF_OP ( xfer_deliver, struct srp_device *, srp_xfer_deliver ),
+ INTF_OP ( intf_close, struct srp_device *, srp_fail ),
};
+/** SRP data transfer interface descriptor */
+static struct interface_descriptor srp_xfer_desc =
+ INTF_DESC ( struct srp_device, socket, srp_xfer_operations );
+
/**
* Issue SCSI command via SRP
*
@@ -483,7 +466,7 @@ int srp_attach ( struct scsi_device *scsi, const char *root_path ) {
goto err_alloc;
}
ref_init ( &srp->refcnt, NULL );
- xfer_init ( &srp->socket, &srp_xfer_operations, &srp->refcnt );
+ intf_init ( &srp->socket, &srp_xfer_desc, &srp->refcnt );
srp->transport = transport;
DBGC ( srp, "SRP %p using %s\n", srp, root_path );
@@ -516,8 +499,7 @@ void srp_detach ( struct scsi_device *scsi ) {
container_of ( scsi->backend, struct srp_device, refcnt );
/* Close socket */
- xfer_nullify ( &srp->socket );
- xfer_close ( &srp->socket, 0 );
+ intf_shutdown ( &srp->socket, 0 );
scsi->command = scsi_detached_command;
ref_put ( scsi->backend );
scsi->backend = NULL;