summaryrefslogtreecommitdiffstats
path: root/src/net
diff options
context:
space:
mode:
authorMichael Brown2011-06-24 15:14:41 +0200
committerMichael Brown2011-06-28 15:45:08 +0200
commite01ec74601b58f54a5e2ae7b9fd1196972034114 (patch)
tree54f2d2202274523e2365584502dee7db8deca43b /src/net
parent[xfer] Send xfer_window_changed() after xfer_vredirect() (diff)
downloadipxe-e01ec74601b58f54a5e2ae7b9fd1196972034114.tar.gz
ipxe-e01ec74601b58f54a5e2ae7b9fd1196972034114.tar.xz
ipxe-e01ec74601b58f54a5e2ae7b9fd1196972034114.zip
[process] Pass containing object pointer to process step() methods
Give the step() method a pointer to the containing object, rather than a pointer to the process. This is consistent with the operation of interface methods, and allows a single function to serve as both an interface method and a process step() method. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/net')
-rw-r--r--src/net/80211/net80211.c19
-rw-r--r--src/net/fcels.c13
-rw-r--r--src/net/fcns.c13
-rw-r--r--src/net/fcp.c13
-rw-r--r--src/net/infiniband.c5
-rw-r--r--src/net/infiniband/ib_cmrc.c12
-rw-r--r--src/net/netdevice.c5
-rw-r--r--src/net/retry.c5
-rw-r--r--src/net/tcp/http.c12
-rw-r--r--src/net/tcp/iscsi.c10
-rw-r--r--src/net/tls.c12
11 files changed, 65 insertions, 54 deletions
diff --git a/src/net/80211/net80211.c b/src/net/80211/net80211.c
index f5ab65f04..466d1243e 100644
--- a/src/net/80211/net80211.c
+++ b/src/net/80211/net80211.c
@@ -159,7 +159,7 @@ net80211_marshal_request_info ( struct net80211_device *dev,
* @defgroup net80211_assoc_ll 802.11 association handling functions
* @{
*/
-static void net80211_step_associate ( struct process *proc );
+static void net80211_step_associate ( struct net80211_device *dev );
static void net80211_handle_auth ( struct net80211_device *dev,
struct io_buffer *iob );
static void net80211_handle_assoc_reply ( struct net80211_device *dev,
@@ -729,6 +729,11 @@ int net80211_tx_mgmt ( struct net80211_device *dev, u16 fc, u8 dest[6],
/* ---------- Driver API ---------- */
+/** 802.11 association process descriptor */
+static struct process_descriptor net80211_process_desc =
+ PROC_DESC ( struct net80211_device, proc_assoc,
+ net80211_step_associate );
+
/**
* Allocate 802.11 device
*
@@ -760,7 +765,7 @@ struct net80211_device * net80211_alloc ( size_t priv_size )
dev->priv = ( u8 * ) dev + sizeof ( *dev );
dev->op = &net80211_null_ops;
- process_init_stopped ( &dev->proc_assoc, net80211_step_associate,
+ process_init_stopped ( &dev->proc_assoc, &net80211_process_desc,
&netdev->refcnt );
INIT_LIST_HEAD ( &dev->mgmt_queue );
INIT_LIST_HEAD ( &dev->mgmt_info_queue );
@@ -1630,12 +1635,10 @@ void net80211_free_wlanlist ( struct list_head *list )
/**
* Step 802.11 association process
*
- * @v proc Association process
+ * @v dev 802.11 device
*/
-static void net80211_step_associate ( struct process *proc )
+static void net80211_step_associate ( struct net80211_device *dev )
{
- struct net80211_device *dev =
- container_of ( proc, struct net80211_device, proc_assoc );
int rc = 0;
int status = dev->state & NET80211_STATUS_MASK;
@@ -1836,7 +1839,7 @@ static void net80211_step_associate ( struct process *proc )
dev->rctl = rc80211_init ( dev );
- process_del ( proc );
+ process_del ( &dev->proc_assoc );
DBGC ( dev, "802.11 %p associated with %s (%s)\n", dev,
dev->essid, eth_ntoa ( dev->bssid ) );
@@ -1861,7 +1864,7 @@ static void net80211_step_associate ( struct process *proc )
net80211_free_wlan ( dev->associating );
dev->associating = NULL;
- process_del ( proc );
+ process_del ( &dev->proc_assoc );
DBGC ( dev, "802.11 %p association failed (state=%04x): "
"%s\n", dev, dev->state, strerror ( dev->assoc_rc ) );
diff --git a/src/net/fcels.c b/src/net/fcels.c
index f8bcb865f..656b4f672 100644
--- a/src/net/fcels.c
+++ b/src/net/fcels.c
@@ -244,11 +244,9 @@ static struct interface_descriptor fc_els_job_desc =
/**
* Fibre Channel ELS process
*
- * @v process Process
+ * @v els Fibre Channel ELS transaction
*/
-static void fc_els_step ( struct process *process ) {
- struct fc_els *els =
- container_of ( process, struct fc_els, process );
+static void fc_els_step ( struct fc_els *els ) {
int xchg_id;
int rc;
@@ -278,6 +276,10 @@ static void fc_els_step ( struct process *process ) {
}
}
+/** Fibre Channel ELS process descriptor */
+static struct process_descriptor fc_els_process_desc =
+ PROC_DESC ( struct fc_els, process, fc_els_step );
+
/**
* Create ELS transaction
*
@@ -298,7 +300,8 @@ static struct fc_els * fc_els_create ( struct fc_port *port,
ref_init ( &els->refcnt, fc_els_free );
intf_init ( &els->job, &fc_els_job_desc, &els->refcnt );
intf_init ( &els->xchg, &fc_els_xchg_desc, &els->refcnt );
- process_init_stopped ( &els->process, fc_els_step, &els->refcnt );
+ process_init_stopped ( &els->process, &fc_els_process_desc,
+ &els->refcnt );
els->port = fc_port_get ( port );
memcpy ( &els->port_id, port_id, sizeof ( els->port_id ) );
memcpy ( &els->peer_port_id, peer_port_id,
diff --git a/src/net/fcns.c b/src/net/fcns.c
index 7769e255e..afb57cfe9 100644
--- a/src/net/fcns.c
+++ b/src/net/fcns.c
@@ -153,11 +153,9 @@ static int fc_ns_query_deliver ( struct fc_ns_query *query,
/**
* Name server query process
*
- * @v process Process
+ * @v query Name server query
*/
-static void fc_ns_query_step ( struct process *process ) {
- struct fc_ns_query *query =
- container_of ( process, struct fc_ns_query, process );
+static void fc_ns_query_step ( struct fc_ns_query *query ) {
struct xfer_metadata meta;
struct fc_ns_gid_pn_request gid_pn;
int xchg_id;
@@ -208,6 +206,10 @@ static struct interface_operation fc_ns_query_xchg_op[] = {
static struct interface_descriptor fc_ns_query_xchg_desc =
INTF_DESC ( struct fc_ns_query, xchg, fc_ns_query_xchg_op );
+/** Name server process descriptor */
+static struct process_descriptor fc_ns_query_process_desc =
+ PROC_DESC ( struct fc_ns_query, process, fc_ns_query_step );
+
/**
* Issue Fibre Channel name server query
*
@@ -226,7 +228,8 @@ int fc_ns_query ( struct fc_peer *peer, struct fc_port *port,
return -ENOMEM;
ref_init ( &query->refcnt, fc_ns_query_free );
intf_init ( &query->xchg, &fc_ns_query_xchg_desc, &query->refcnt );
- process_init ( &query->process, fc_ns_query_step, &query->refcnt );
+ process_init ( &query->process, &fc_ns_query_process_desc,
+ &query->refcnt );
query->peer = fc_peer_get ( peer );
query->port = fc_port_get ( port );
query->done = done;
diff --git a/src/net/fcp.c b/src/net/fcp.c
index 419fea3ec..bd1a09009 100644
--- a/src/net/fcp.c
+++ b/src/net/fcp.c
@@ -649,11 +649,9 @@ static int fcpcmd_recv_unknown ( struct fcp_command *fcpcmd,
/**
* Transmit FCP frame
*
- * @v process FCP command process
+ * @v fcpcmd FCP command
*/
-static void fcpcmd_step ( struct process *process ) {
- struct fcp_command *fcpcmd =
- container_of ( process, struct fcp_command, process );
+static void fcpcmd_step ( struct fcp_command *fcpcmd ) {
int rc;
/* Send the current IU */
@@ -723,6 +721,10 @@ static struct interface_operation fcpcmd_xchg_op[] = {
static struct interface_descriptor fcpcmd_xchg_desc =
INTF_DESC_PASSTHRU ( struct fcp_command, xchg, fcpcmd_xchg_op, scsi );
+/** FCP command process descriptor */
+static struct process_descriptor fcpcmd_process_desc =
+ PROC_DESC ( struct fcp_command, process, fcpcmd_step );
+
/**
* Issue FCP SCSI command
*
@@ -765,7 +767,8 @@ static int fcpdev_scsi_command ( struct fcp_device *fcpdev,
ref_init ( &fcpcmd->refcnt, fcpcmd_free );
intf_init ( &fcpcmd->scsi, &fcpcmd_scsi_desc, &fcpcmd->refcnt );
intf_init ( &fcpcmd->xchg, &fcpcmd_xchg_desc, &fcpcmd->refcnt );
- process_init_stopped ( &fcpcmd->process, fcpcmd_step, &fcpcmd->refcnt );
+ process_init_stopped ( &fcpcmd->process, &fcpcmd_process_desc,
+ &fcpcmd->refcnt );
fcpcmd->fcpdev = fcpdev_get ( fcpdev );
list_add ( &fcpcmd->list, &fcpdev->fcpcmds );
memcpy ( &fcpcmd->command, command, sizeof ( fcpcmd->command ) );
diff --git a/src/net/infiniband.c b/src/net/infiniband.c
index c2cb834df..c88da73e6 100644
--- a/src/net/infiniband.c
+++ b/src/net/infiniband.c
@@ -866,10 +866,7 @@ static void ib_step ( struct process *process __unused ) {
}
/** Infiniband event queue process */
-struct process ib_process __permanent_process = {
- .list = LIST_HEAD_INIT ( ib_process.list ),
- .step = ib_step,
-};
+PERMANENT_PROCESS ( ib_process, ib_step );
/***************************************************************************
*
diff --git a/src/net/infiniband/ib_cmrc.c b/src/net/infiniband/ib_cmrc.c
index 4b15314e5..972a60cf9 100644
--- a/src/net/infiniband/ib_cmrc.c
+++ b/src/net/infiniband/ib_cmrc.c
@@ -92,7 +92,7 @@ struct ib_cmrc_connection {
/**
* Shut down CMRC connection gracefully
*
- * @v process Process
+ * @v cmrc Communication-Managed Reliable Connection
*
* The Infiniband data structures are not reference-counted or
* guarded. It is therefore unsafe to shut them down while we may be
@@ -107,9 +107,7 @@ struct ib_cmrc_connection {
* connection, ensuring that the structure is not freed before the
* shutdown process has run.
*/
-static void ib_cmrc_shutdown ( struct process *process ) {
- struct ib_cmrc_connection *cmrc =
- container_of ( process, struct ib_cmrc_connection, shutdown );
+static void ib_cmrc_shutdown ( struct ib_cmrc_connection *cmrc ) {
DBGC ( cmrc, "CMRC %p shutting down\n", cmrc );
@@ -363,6 +361,10 @@ static struct interface_operation ib_cmrc_xfer_operations[] = {
static struct interface_descriptor ib_cmrc_xfer_desc =
INTF_DESC ( struct ib_cmrc_connection, xfer, ib_cmrc_xfer_operations );
+/** CMRC shutdown process descriptor */
+static struct process_descriptor ib_cmrc_shutdown_desc =
+ PROC_DESC ( struct ib_cmrc_connection, shutdown, ib_cmrc_shutdown );
+
/**
* Open CMRC connection
*
@@ -388,7 +390,7 @@ int ib_cmrc_open ( struct interface *xfer, struct ib_device *ibdev,
cmrc->ibdev = ibdev;
memcpy ( &cmrc->dgid, dgid, sizeof ( cmrc->dgid ) );
memcpy ( &cmrc->service_id, service_id, sizeof ( cmrc->service_id ) );
- process_init_stopped ( &cmrc->shutdown, ib_cmrc_shutdown,
+ process_init_stopped ( &cmrc->shutdown, &ib_cmrc_shutdown_desc,
&cmrc->refcnt );
/* Open Infiniband device */
diff --git a/src/net/netdevice.c b/src/net/netdevice.c
index 54b41b3f1..52ad82925 100644
--- a/src/net/netdevice.c
+++ b/src/net/netdevice.c
@@ -769,7 +769,4 @@ static void net_step ( struct process *process __unused ) {
}
/** Networking stack process */
-struct process net_process __permanent_process = {
- .list = LIST_HEAD_INIT ( net_process.list ),
- .step = net_step,
-};
+PERMANENT_PROCESS ( net_process, net_step );
diff --git a/src/net/retry.c b/src/net/retry.c
index 082be39bb..0aa165abb 100644
--- a/src/net/retry.c
+++ b/src/net/retry.c
@@ -198,7 +198,4 @@ static void retry_step ( struct process *process __unused ) {
}
/** Retry timer process */
-struct process retry_process __permanent_process = {
- .list = LIST_HEAD_INIT ( retry_process.list ),
- .step = retry_step,
-};
+PERMANENT_PROCESS ( retry_process, retry_step );
diff --git a/src/net/tcp/http.c b/src/net/tcp/http.c
index 598f28931..15f88b319 100644
--- a/src/net/tcp/http.c
+++ b/src/net/tcp/http.c
@@ -483,11 +483,9 @@ static int http_socket_deliver ( struct http_request *http,
/**
* HTTP process
*
- * @v process Process
+ * @v http HTTP request
*/
-static void http_step ( struct process *process ) {
- struct http_request *http =
- container_of ( process, struct http_request, process );
+static void http_step ( struct http_request *http ) {
const char *host = http->uri->host;
const char *user = http->uri->user;
const char *password =
@@ -561,6 +559,10 @@ static struct interface_descriptor http_xfer_desc =
INTF_DESC_PASSTHRU ( struct http_request, xfer,
http_xfer_operations, socket );
+/** HTTP process descriptor */
+static struct process_descriptor http_process_desc =
+ PROC_DESC ( struct http_request, process, http_step );
+
/**
* Initiate an HTTP connection, with optional filter
*
@@ -591,7 +593,7 @@ int http_open_filter ( struct interface *xfer, struct uri *uri,
intf_init ( &http->xfer, &http_xfer_desc, &http->refcnt );
http->uri = uri_get ( uri );
intf_init ( &http->socket, &http_socket_desc, &http->refcnt );
- process_init ( &http->process, http_step, &http->refcnt );
+ process_init ( &http->process, &http_process_desc, &http->refcnt );
/* Open socket */
memset ( &server, 0, sizeof ( server ) );
diff --git a/src/net/tcp/iscsi.c b/src/net/tcp/iscsi.c
index cde3ed6db..34d06ce3a 100644
--- a/src/net/tcp/iscsi.c
+++ b/src/net/tcp/iscsi.c
@@ -1427,9 +1427,7 @@ static void iscsi_tx_done ( struct iscsi_session *iscsi ) {
*
* Constructs data to be sent for the current TX state
*/
-static void iscsi_tx_step ( struct process *process ) {
- struct iscsi_session *iscsi =
- container_of ( process, struct iscsi_session, process );
+static void iscsi_tx_step ( struct iscsi_session *iscsi ) {
struct iscsi_bhs_common *common = &iscsi->tx_bhs.common;
int ( * tx ) ( struct iscsi_session *iscsi );
enum iscsi_tx_state next_state;
@@ -1488,6 +1486,10 @@ static void iscsi_tx_step ( struct process *process ) {
}
}
+/** iSCSI TX process descriptor */
+static struct process_descriptor iscsi_process_desc =
+ PROC_DESC ( struct iscsi_session, process, iscsi_tx_step );
+
/**
* Receive basic header segment of an iSCSI PDU
*
@@ -2034,7 +2036,7 @@ static int iscsi_open ( struct interface *parent, struct uri *uri ) {
intf_init ( &iscsi->control, &iscsi_control_desc, &iscsi->refcnt );
intf_init ( &iscsi->data, &iscsi_data_desc, &iscsi->refcnt );
intf_init ( &iscsi->socket, &iscsi_socket_desc, &iscsi->refcnt );
- process_init_stopped ( &iscsi->process, iscsi_tx_step,
+ process_init_stopped ( &iscsi->process, &iscsi_process_desc,
&iscsi->refcnt );
/* Parse root path */
diff --git a/src/net/tls.c b/src/net/tls.c
index fba5160d2..d80648ccc 100644
--- a/src/net/tls.c
+++ b/src/net/tls.c
@@ -1645,11 +1645,9 @@ static struct interface_descriptor tls_cipherstream_desc =
/**
* TLS TX state machine
*
- * @v process TLS process
+ * @v tls TLS session
*/
-static void tls_step ( struct process *process ) {
- struct tls_session *tls =
- container_of ( process, struct tls_session, process );
+static void tls_step ( struct tls_session *tls ) {
int rc;
/* Wait for cipherstream to become ready */
@@ -1717,6 +1715,10 @@ static void tls_step ( struct process *process ) {
tls_close ( tls, rc );
}
+/** TLS TX process descriptor */
+static struct process_descriptor tls_process_desc =
+ PROC_DESC ( struct tls_session, process, tls_step );
+
/******************************************************************************
*
* Instantiator
@@ -1748,7 +1750,7 @@ int add_tls ( struct interface *xfer, struct interface **next ) {
digest_init ( &md5_algorithm, tls->handshake_md5_ctx );
digest_init ( &sha1_algorithm, tls->handshake_sha1_ctx );
tls->tx_state = TLS_TX_CLIENT_HELLO;
- process_init ( &tls->process, tls_step, &tls->refcnt );
+ process_init ( &tls->process, &tls_process_desc, &tls->refcnt );
/* Attach to parent interface, mortalise self, and return */
intf_plug_plug ( &tls->plainstream, xfer );