Browse Source

[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>
tags/v1.20.1
Michael Brown 13 years ago
parent
commit
e01ec74601

+ 12
- 10
src/core/hw.c View File

@@ -26,15 +26,7 @@ static void hw_finished ( struct hw *hw, int rc ) {
26 26
 	process_del ( &hw->process );
27 27
 }
28 28
 
29
-static struct interface_operation hw_xfer_operations[] = {
30
-	INTF_OP ( intf_close, struct hw *, hw_finished ),
31
-};
32
-
33
-static struct interface_descriptor hw_xfer_desc =
34
-	INTF_DESC ( struct hw, xfer, hw_xfer_operations );
35
-
36
-static void hw_step ( struct process *process ) {
37
-	struct hw *hw = container_of ( process, struct hw, process );
29
+static void hw_step ( struct hw *hw ) {
38 30
 	int rc;
39 31
 
40 32
 	if ( xfer_window ( &hw->xfer ) ) {
@@ -43,6 +35,16 @@ static void hw_step ( struct process *process ) {
43 35
 	}
44 36
 }
45 37
 
38
+static struct interface_operation hw_xfer_operations[] = {
39
+	INTF_OP ( intf_close, struct hw *, hw_finished ),
40
+};
41
+
42
+static struct interface_descriptor hw_xfer_desc =
43
+	INTF_DESC ( struct hw, xfer, hw_xfer_operations );
44
+
45
+static struct process_descriptor hw_process_desc =
46
+	PROC_DESC ( struct hw, process, hw_step );
47
+
46 48
 static int hw_open ( struct interface *xfer, struct uri *uri __unused ) {
47 49
 	struct hw *hw;
48 50
 
@@ -52,7 +54,7 @@ static int hw_open ( struct interface *xfer, struct uri *uri __unused ) {
52 54
 		return -ENOMEM;
53 55
 	ref_init ( &hw->refcnt, NULL );
54 56
 	intf_init ( &hw->xfer, &hw_xfer_desc, &hw->refcnt );
55
-	process_init ( &hw->process, hw_step, &hw->refcnt );
57
+	process_init ( &hw->process, &hw_process_desc, &hw->refcnt );
56 58
 
57 59
 	/* Attach parent interface, mortalise self, and return */
58 60
 	intf_plug_plug ( &hw->xfer, xfer );

+ 28
- 14
src/core/process.c View File

@@ -33,6 +33,16 @@ FILE_LICENCE ( GPL2_OR_LATER );
33 33
 /** Process run queue */
34 34
 static LIST_HEAD ( run_queue );
35 35
 
36
+/**
37
+ * Get pointer to object containing process
38
+ *
39
+ * @v process		Process
40
+ * @ret object		Containing object
41
+ */
42
+void * process_object ( struct process *process ) {
43
+	return ( ( ( void * ) process ) - process->desc->offset );
44
+}
45
+
36 46
 /**
37 47
  * Add process to process list
38 48
  *
@@ -43,13 +53,13 @@ static LIST_HEAD ( run_queue );
43 53
  */
44 54
 void process_add ( struct process *process ) {
45 55
 	if ( ! process_running ( process ) ) {
46
-		DBGC ( process, "PROCESS %p (%p) starting\n",
47
-		       process, process->step );
56
+		DBGC ( PROC_COL ( process ), "PROCESS " PROC_FMT
57
+		       " starting\n", PROC_DBG ( process ) );
48 58
 		ref_get ( process->refcnt );
49 59
 		list_add_tail ( &process->list, &run_queue );
50 60
 	} else {
51
-		DBGC ( process, "PROCESS %p (%p) already started\n",
52
-		       process, process->step );
61
+		DBGC ( PROC_COL ( process ), "PROCESS " PROC_FMT
62
+		       " already started\n", PROC_DBG ( process ) );
53 63
 	}
54 64
 }
55 65
 
@@ -63,14 +73,14 @@ void process_add ( struct process *process ) {
63 73
  */
64 74
 void process_del ( struct process *process ) {
65 75
 	if ( process_running ( process ) ) {
66
-		DBGC ( process, "PROCESS %p (%p) stopping\n",
67
-		       process, process->step );
76
+		DBGC ( PROC_COL ( process ), "PROCESS " PROC_FMT
77
+		       " stopping\n", PROC_DBG ( process ) );
68 78
 		list_del ( &process->list );
69 79
 		INIT_LIST_HEAD ( &process->list );
70 80
 		ref_put ( process->refcnt );
71 81
 	} else {
72
-		DBGC ( process, "PROCESS %p (%p) already stopped\n",
73
-		       process, process->step );
82
+		DBGC ( PROC_COL ( process ), "PROCESS " PROC_FMT
83
+		       " already stopped\n", PROC_DBG ( process ) );
74 84
 	}
75 85
 }
76 86
 
@@ -82,17 +92,21 @@ void process_del ( struct process *process ) {
82 92
  */
83 93
 void step ( void ) {
84 94
 	struct process *process;
95
+	struct process_descriptor *desc;
96
+	void *object;
85 97
 
86 98
 	if ( ( process = list_first_entry ( &run_queue, struct process,
87 99
 					    list ) ) ) {
100
+		ref_get ( process->refcnt ); /* Inhibit destruction mid-step */
101
+		desc = process->desc;
102
+		object = process_object ( process );
88 103
 		list_del ( &process->list );
89 104
 		list_add_tail ( &process->list, &run_queue );
90
-		ref_get ( process->refcnt ); /* Inhibit destruction mid-step */
91
-		DBGC2 ( process, "PROCESS %p (%p) executing\n",
92
-			process, process->step );
93
-		process->step ( process );
94
-		DBGC2 ( process, "PROCESS %p (%p) finished executing\n",
95
-			process, process->step );
105
+		DBGC2 ( PROC_COL ( process ), "PROCESS " PROC_FMT
106
+			" executing\n", PROC_DBG ( process ) );
107
+		desc->step ( object );
108
+		DBGC2 ( PROC_COL ( process ), "PROCESS " PROC_FMT
109
+			" finished executing\n", PROC_DBG ( process ) );
96 110
 		ref_put ( process->refcnt ); /* Allow destruction */
97 111
 	}
98 112
 }

+ 7
- 5
src/core/resolv.c View File

@@ -86,16 +86,17 @@ struct numeric_resolv {
86 86
 	int rc;
87 87
 };
88 88
 
89
-static void numeric_step ( struct process *process ) {
90
-	struct numeric_resolv *numeric =
91
-		container_of ( process, struct numeric_resolv, process );
89
+static void numeric_step ( struct numeric_resolv *numeric ) {
92 90
 
93
-	process_del ( process );
91
+	process_del ( &numeric->process );
94 92
 	if ( numeric->rc == 0 )
95 93
 		resolv_done ( &numeric->resolv, &numeric->sa );
96 94
 	intf_shutdown ( &numeric->resolv, numeric->rc );
97 95
 }
98 96
 
97
+static struct process_descriptor numeric_process_desc =
98
+	PROC_DESC ( struct numeric_resolv, process, numeric_step );
99
+
99 100
 static int numeric_resolv ( struct interface *resolv,
100 101
 			    const char *name, struct sockaddr *sa ) {
101 102
 	struct numeric_resolv *numeric;
@@ -107,7 +108,8 @@ static int numeric_resolv ( struct interface *resolv,
107 108
 		return -ENOMEM;
108 109
 	ref_init ( &numeric->refcnt, NULL );
109 110
 	intf_init ( &numeric->resolv, &null_intf_desc, &numeric->refcnt );
110
-	process_init ( &numeric->process, numeric_step, &numeric->refcnt );
111
+	process_init ( &numeric->process, &numeric_process_desc,
112
+		       &numeric->refcnt );
111 113
 	memcpy ( &numeric->sa, sa, sizeof ( numeric->sa ) );
112 114
 
113 115
 	DBGC ( numeric, "NUMERIC %p attempting to resolve \"%s\"\n",

+ 8
- 5
src/drivers/block/scsi.c View File

@@ -892,11 +892,9 @@ static struct interface_descriptor scsidev_ready_desc =
892 892
 /**
893 893
  * SCSI TEST UNIT READY process
894 894
  *
895
- * @v process		Process
895
+ * @v scsidev		SCSI device
896 896
  */
897
-static void scsidev_step ( struct process *process ) {
898
-	struct scsi_device *scsidev =
899
-		container_of ( process, struct scsi_device, process );
897
+static void scsidev_step ( struct scsi_device *scsidev ) {
900 898
 	int rc;
901 899
 
902 900
 	/* Wait until underlying SCSI device is ready */
@@ -926,6 +924,10 @@ static struct interface_descriptor scsidev_scsi_desc =
926 924
 	INTF_DESC_PASSTHRU ( struct scsi_device, scsi,
927 925
 			     scsidev_scsi_op, block );
928 926
 
927
+/** SCSI device process descriptor */
928
+static struct process_descriptor scsidev_process_desc =
929
+	PROC_DESC ( struct scsi_device, process, scsidev_step );
930
+
929 931
 /**
930 932
  * Open SCSI device
931 933
  *
@@ -946,7 +948,8 @@ int scsi_open ( struct interface *block, struct interface *scsi,
946 948
 	intf_init ( &scsidev->block, &scsidev_block_desc, &scsidev->refcnt );
947 949
 	intf_init ( &scsidev->scsi, &scsidev_scsi_desc, &scsidev->refcnt );
948 950
 	intf_init ( &scsidev->ready, &scsidev_ready_desc, &scsidev->refcnt );
949
-	process_init ( &scsidev->process, scsidev_step, &scsidev->refcnt );
951
+	process_init ( &scsidev->process, &scsidev_process_desc,
952
+		       &scsidev->refcnt );
950 953
 	INIT_LIST_HEAD ( &scsidev->cmds );
951 954
 	memcpy ( &scsidev->lun, lun, sizeof ( scsidev->lun ) );
952 955
 	DBGC ( scsidev, "SCSI %p created for LUN " SCSI_LUN_FORMAT "\n",

+ 109
- 13
src/include/ipxe/process.h View File

@@ -17,6 +17,20 @@ FILE_LICENCE ( GPL2_OR_LATER );
17 17
 struct process {
18 18
 	/** List of processes */
19 19
 	struct list_head list;
20
+	/** Process descriptor */
21
+	struct process_descriptor *desc;
22
+	/** Reference counter
23
+	 *
24
+	 * If this process is not part of a reference-counted object,
25
+	 * this field may be NULL.
26
+	 */
27
+	struct refcnt *refcnt;
28
+};
29
+
30
+/** A process descriptor */
31
+struct process_descriptor {
32
+	/** Offset of process within containing object */
33
+	size_t offset;
20 34
 	/**
21 35
 	 * Single-step the process
22 36
 	 *
@@ -24,15 +38,63 @@ struct process {
24 38
 	 * Returning from this method is isomorphic to yielding the
25 39
 	 * CPU to another process.
26 40
 	 */
27
-	void ( * step ) ( struct process *process );
28
-	/** Reference counter
29
-	 *
30
-	 * If this interface is not part of a reference-counted
31
-	 * object, this field may be NULL.
32
-	 */
33
-	struct refcnt *refcnt;
41
+	void ( * step ) ( void *object );
34 42
 };
35 43
 
44
+/**
45
+ * Define a process step() method
46
+ *
47
+ * @v object_type	Implementing method's expected object type
48
+ * @v step		Implementing method
49
+ * @ret step		Process step method
50
+ */
51
+#define PROC_STEP( object_type, step )					      \
52
+	( ( ( ( typeof ( step ) * ) NULL ) ==				      \
53
+	    ( ( void ( * ) ( object_type *object ) ) NULL ) ) ?		      \
54
+	  ( void ( * ) ( void *object ) ) step :			      \
55
+	  ( void ( * ) ( void *object ) ) step )
56
+
57
+/**
58
+ * Calculate offset of process within containing object
59
+ *
60
+ * @v object_type	Containing object data type
61
+ * @v name		Process name (i.e. field within object data type)
62
+ * @ret offset		Offset of process within containing object
63
+ */
64
+#define process_offset( object_type, name )				      \
65
+	( ( ( ( typeof ( ( ( object_type * ) NULL )->name ) * ) NULL )	      \
66
+	    == ( ( struct process * ) NULL ) )			      	      \
67
+	  ? offsetof ( object_type, name )				      \
68
+	  : offsetof ( object_type, name ) )
69
+
70
+/**
71
+ * Define a process descriptor
72
+ *
73
+ * @v object_type	Containing object data type
74
+ * @v process		Process name (i.e. field within object data type)
75
+ * @v step		Process' step() method
76
+ * @ret desc		Object interface descriptor
77
+ */
78
+#define PROC_DESC( object_type, process, _step ) {			      \
79
+		.offset = process_offset ( object_type, process ),	      \
80
+		.step = PROC_STEP ( object_type, _step ),		      \
81
+	}
82
+
83
+/**
84
+ * Define a process descriptor for a pure process
85
+ *
86
+ * A pure process is a process that does not have a containing object.
87
+ *
88
+ * @v step		Process' step() method
89
+ * @ret desc		Object interface descriptor
90
+ */
91
+#define PROC_DESC_PURE( _step ) {					      \
92
+		.offset = 0,						      \
93
+		.step = PROC_STEP ( struct process, _step ),		      \
94
+	}
95
+
96
+extern void * __attribute__ (( pure ))
97
+process_object ( struct process *process );
36 98
 extern void process_add ( struct process *process );
37 99
 extern void process_del ( struct process *process );
38 100
 extern void step ( void );
@@ -41,14 +103,15 @@ extern void step ( void );
41 103
  * Initialise process without adding to process list
42 104
  *
43 105
  * @v process		Process
44
- * @v step		Process' step() method
106
+ * @v desc		Process descriptor
107
+ * @v refcnt		Containing object reference count, or NULL
45 108
  */
46 109
 static inline __attribute__ (( always_inline )) void
47 110
 process_init_stopped ( struct process *process,
48
-		       void ( * step ) ( struct process *process ),
111
+		       struct process_descriptor *desc,
49 112
 		       struct refcnt *refcnt ) {
50 113
 	INIT_LIST_HEAD ( &process->list );
51
-	process->step = step;
114
+	process->desc = desc;
52 115
 	process->refcnt = refcnt;
53 116
 }
54 117
 
@@ -56,13 +119,14 @@ process_init_stopped ( struct process *process,
56 119
  * Initialise process and add to process list
57 120
  *
58 121
  * @v process		Process
59
- * @v step		Process' step() method
122
+ * @v desc		Process descriptor
123
+ * @v refcnt		Containing object reference count, or NULL
60 124
  */
61 125
 static inline __attribute__ (( always_inline )) void
62 126
 process_init ( struct process *process,
63
-	       void ( * step ) ( struct process *process ),
127
+	       struct process_descriptor *desc,
64 128
 	       struct refcnt *refcnt ) {
65
-	process_init_stopped ( process, step, refcnt );
129
+	process_init_stopped ( process, desc, refcnt );
66 130
 	process_add ( process );
67 131
 }
68 132
 
@@ -88,4 +152,36 @@ process_running ( struct process *process ) {
88 152
  */
89 153
 #define __permanent_process __table_entry ( PERMANENT_PROCESSES, 01 )
90 154
 
155
+/** Define a permanent process
156
+ *
157
+ */
158
+#define PERMANENT_PROCESS( name, step )					      \
159
+struct process_descriptor name ## _desc = PROC_DESC_PURE ( step );	      \
160
+struct process name __permanent_process = {				      \
161
+	.list = LIST_HEAD_INIT ( name.list ),				      \
162
+	.desc = & name ## _desc,					      \
163
+	.refcnt = NULL,							      \
164
+};
165
+
166
+/**
167
+ * Find debugging colourisation for a process
168
+ *
169
+ * @v process		Process
170
+ * @ret col		Debugging colourisation
171
+ *
172
+ * Use as the first argument to DBGC() or equivalent macro.
173
+ */
174
+#define PROC_COL( process ) process_object ( process )
175
+
176
+/** printf() format string for PROC_DBG() */
177
+#define PROC_FMT "%p+%zx"
178
+
179
+/**
180
+ * printf() arguments for representing a process
181
+ *
182
+ * @v process		Process
183
+ * @ret args		printf() argument list corresponding to PROC_FMT
184
+ */
185
+#define PROC_DBG( process ) process_object ( process ), (process)->desc->offset
186
+
91 187
 #endif /* _IPXE_PROCESS_H */

+ 11
- 8
src/net/80211/net80211.c View File

@@ -159,7 +159,7 @@ net80211_marshal_request_info ( struct net80211_device *dev,
159 159
  * @defgroup net80211_assoc_ll 802.11 association handling functions
160 160
  * @{
161 161
  */
162
-static void net80211_step_associate ( struct process *proc );
162
+static void net80211_step_associate ( struct net80211_device *dev );
163 163
 static void net80211_handle_auth ( struct net80211_device *dev,
164 164
 				   struct io_buffer *iob );
165 165
 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],
729 729
 
730 730
 /* ---------- Driver API ---------- */
731 731
 
732
+/** 802.11 association process descriptor */
733
+static struct process_descriptor net80211_process_desc =
734
+	PROC_DESC ( struct net80211_device, proc_assoc,
735
+		    net80211_step_associate );
736
+
732 737
 /**
733 738
  * Allocate 802.11 device
734 739
  *
@@ -760,7 +765,7 @@ struct net80211_device * net80211_alloc ( size_t priv_size )
760 765
 	dev->priv = ( u8 * ) dev + sizeof ( *dev );
761 766
 	dev->op = &net80211_null_ops;
762 767
 
763
-	process_init_stopped ( &dev->proc_assoc, net80211_step_associate,
768
+	process_init_stopped ( &dev->proc_assoc, &net80211_process_desc,
764 769
 			       &netdev->refcnt );
765 770
 	INIT_LIST_HEAD ( &dev->mgmt_queue );
766 771
 	INIT_LIST_HEAD ( &dev->mgmt_info_queue );
@@ -1630,12 +1635,10 @@ void net80211_free_wlanlist ( struct list_head *list )
1630 1635
 /**
1631 1636
  * Step 802.11 association process
1632 1637
  *
1633
- * @v proc	Association process
1638
+ * @v dev	802.11 device
1634 1639
  */
1635
-static void net80211_step_associate ( struct process *proc )
1640
+static void net80211_step_associate ( struct net80211_device *dev )
1636 1641
 {
1637
-	struct net80211_device *dev =
1638
-	    container_of ( proc, struct net80211_device, proc_assoc );
1639 1642
 	int rc = 0;
1640 1643
 	int status = dev->state & NET80211_STATUS_MASK;
1641 1644
 
@@ -1836,7 +1839,7 @@ static void net80211_step_associate ( struct process *proc )
1836 1839
 
1837 1840
 	dev->rctl = rc80211_init ( dev );
1838 1841
 
1839
-	process_del ( proc );
1842
+	process_del ( &dev->proc_assoc );
1840 1843
 
1841 1844
 	DBGC ( dev, "802.11 %p associated with %s (%s)\n", dev,
1842 1845
 	       dev->essid, eth_ntoa ( dev->bssid ) );
@@ -1861,7 +1864,7 @@ static void net80211_step_associate ( struct process *proc )
1861 1864
 	net80211_free_wlan ( dev->associating );
1862 1865
 	dev->associating = NULL;
1863 1866
 
1864
-	process_del ( proc );
1867
+	process_del ( &dev->proc_assoc );
1865 1868
 
1866 1869
 	DBGC ( dev, "802.11 %p association failed (state=%04x): "
1867 1870
 	       "%s\n", dev, dev->state, strerror ( dev->assoc_rc ) );

+ 8
- 5
src/net/fcels.c View File

@@ -244,11 +244,9 @@ static struct interface_descriptor fc_els_job_desc =
244 244
 /**
245 245
  * Fibre Channel ELS process
246 246
  *
247
- * @v process		Process
247
+ * @v els		Fibre Channel ELS transaction
248 248
  */
249
-static void fc_els_step ( struct process *process ) {
250
-	struct fc_els *els =
251
-		container_of ( process, struct fc_els, process );
249
+static void fc_els_step ( struct fc_els *els ) {
252 250
 	int xchg_id;
253 251
 	int rc;
254 252
 
@@ -278,6 +276,10 @@ static void fc_els_step ( struct process *process ) {
278 276
 	}
279 277
 }
280 278
 
279
+/** Fibre Channel ELS process descriptor */
280
+static struct process_descriptor fc_els_process_desc =
281
+	PROC_DESC ( struct fc_els, process, fc_els_step );
282
+
281 283
 /**
282 284
  * Create ELS transaction
283 285
  *
@@ -298,7 +300,8 @@ static struct fc_els * fc_els_create ( struct fc_port *port,
298 300
 	ref_init ( &els->refcnt, fc_els_free );
299 301
 	intf_init ( &els->job, &fc_els_job_desc, &els->refcnt );
300 302
 	intf_init ( &els->xchg, &fc_els_xchg_desc, &els->refcnt );
301
-	process_init_stopped ( &els->process, fc_els_step, &els->refcnt );
303
+	process_init_stopped ( &els->process, &fc_els_process_desc,
304
+			       &els->refcnt );
302 305
 	els->port = fc_port_get ( port );
303 306
 	memcpy ( &els->port_id, port_id, sizeof ( els->port_id ) );
304 307
 	memcpy ( &els->peer_port_id, peer_port_id,

+ 8
- 5
src/net/fcns.c View File

@@ -153,11 +153,9 @@ static int fc_ns_query_deliver ( struct fc_ns_query *query,
153 153
 /**
154 154
  * Name server query process
155 155
  *
156
- * @v process		Process
156
+ * @v query		Name server query
157 157
  */
158
-static void fc_ns_query_step ( struct process *process ) {
159
-	struct fc_ns_query *query =
160
-		container_of ( process, struct fc_ns_query, process );
158
+static void fc_ns_query_step ( struct fc_ns_query *query ) {
161 159
 	struct xfer_metadata meta;
162 160
 	struct fc_ns_gid_pn_request gid_pn;
163 161
 	int xchg_id;
@@ -208,6 +206,10 @@ static struct interface_operation fc_ns_query_xchg_op[] = {
208 206
 static struct interface_descriptor fc_ns_query_xchg_desc =
209 207
 	INTF_DESC ( struct fc_ns_query, xchg, fc_ns_query_xchg_op );
210 208
 
209
+/** Name server process descriptor */
210
+static struct process_descriptor fc_ns_query_process_desc =
211
+	PROC_DESC ( struct fc_ns_query, process, fc_ns_query_step );
212
+
211 213
 /**
212 214
  * Issue Fibre Channel name server query
213 215
  *
@@ -226,7 +228,8 @@ int fc_ns_query ( struct fc_peer *peer, struct fc_port *port,
226 228
 		return -ENOMEM;
227 229
 	ref_init ( &query->refcnt, fc_ns_query_free );
228 230
 	intf_init ( &query->xchg, &fc_ns_query_xchg_desc, &query->refcnt );
229
-	process_init ( &query->process, fc_ns_query_step, &query->refcnt );
231
+	process_init ( &query->process, &fc_ns_query_process_desc,
232
+		       &query->refcnt );
230 233
 	query->peer = fc_peer_get ( peer );
231 234
 	query->port = fc_port_get ( port );
232 235
 	query->done = done;

+ 8
- 5
src/net/fcp.c View File

@@ -649,11 +649,9 @@ static int fcpcmd_recv_unknown ( struct fcp_command *fcpcmd,
649 649
 /**
650 650
  * Transmit FCP frame
651 651
  *
652
- * @v process		FCP command process
652
+ * @v fcpcmd		FCP command
653 653
  */
654
-static void fcpcmd_step ( struct process *process ) {
655
-	struct fcp_command *fcpcmd =
656
-		container_of ( process, struct fcp_command, process );
654
+static void fcpcmd_step ( struct fcp_command *fcpcmd ) {
657 655
 	int rc;
658 656
 
659 657
 	/* Send the current IU */
@@ -723,6 +721,10 @@ static struct interface_operation fcpcmd_xchg_op[] = {
723 721
 static struct interface_descriptor fcpcmd_xchg_desc =
724 722
 	INTF_DESC_PASSTHRU ( struct fcp_command, xchg, fcpcmd_xchg_op, scsi );
725 723
 
724
+/** FCP command process descriptor */
725
+static struct process_descriptor fcpcmd_process_desc =
726
+	PROC_DESC ( struct fcp_command, process, fcpcmd_step );
727
+
726 728
 /**
727 729
  * Issue FCP SCSI command
728 730
  *
@@ -765,7 +767,8 @@ static int fcpdev_scsi_command ( struct fcp_device *fcpdev,
765 767
 	ref_init ( &fcpcmd->refcnt, fcpcmd_free );
766 768
 	intf_init ( &fcpcmd->scsi, &fcpcmd_scsi_desc, &fcpcmd->refcnt );
767 769
 	intf_init ( &fcpcmd->xchg, &fcpcmd_xchg_desc, &fcpcmd->refcnt );
768
-	process_init_stopped ( &fcpcmd->process, fcpcmd_step, &fcpcmd->refcnt );
770
+	process_init_stopped ( &fcpcmd->process, &fcpcmd_process_desc,
771
+			       &fcpcmd->refcnt );
769 772
 	fcpcmd->fcpdev = fcpdev_get ( fcpdev );
770 773
 	list_add ( &fcpcmd->list, &fcpdev->fcpcmds );
771 774
 	memcpy ( &fcpcmd->command, command, sizeof ( fcpcmd->command ) );

+ 1
- 4
src/net/infiniband.c View File

@@ -866,10 +866,7 @@ static void ib_step ( struct process *process __unused ) {
866 866
 }
867 867
 
868 868
 /** Infiniband event queue process */
869
-struct process ib_process __permanent_process = {
870
-	.list = LIST_HEAD_INIT ( ib_process.list ),
871
-	.step = ib_step,
872
-};
869
+PERMANENT_PROCESS ( ib_process, ib_step );
873 870
 
874 871
 /***************************************************************************
875 872
  *

+ 7
- 5
src/net/infiniband/ib_cmrc.c View File

@@ -92,7 +92,7 @@ struct ib_cmrc_connection {
92 92
 /**
93 93
  * Shut down CMRC connection gracefully
94 94
  *
95
- * @v process		Process
95
+ * @v cmrc		Communication-Managed Reliable Connection
96 96
  *
97 97
  * The Infiniband data structures are not reference-counted or
98 98
  * guarded.  It is therefore unsafe to shut them down while we may be
@@ -107,9 +107,7 @@ struct ib_cmrc_connection {
107 107
  * connection, ensuring that the structure is not freed before the
108 108
  * shutdown process has run.
109 109
  */
110
-static void ib_cmrc_shutdown ( struct process *process ) {
111
-	struct ib_cmrc_connection *cmrc =
112
-		container_of ( process, struct ib_cmrc_connection, shutdown );
110
+static void ib_cmrc_shutdown ( struct ib_cmrc_connection *cmrc ) {
113 111
 
114 112
 	DBGC ( cmrc, "CMRC %p shutting down\n", cmrc );
115 113
 
@@ -363,6 +361,10 @@ static struct interface_operation ib_cmrc_xfer_operations[] = {
363 361
 static struct interface_descriptor ib_cmrc_xfer_desc =
364 362
 	INTF_DESC ( struct ib_cmrc_connection, xfer, ib_cmrc_xfer_operations );
365 363
 
364
+/** CMRC shutdown process descriptor */
365
+static struct process_descriptor ib_cmrc_shutdown_desc =
366
+	PROC_DESC ( struct ib_cmrc_connection, shutdown, ib_cmrc_shutdown );
367
+
366 368
 /**
367 369
  * Open CMRC connection
368 370
  *
@@ -388,7 +390,7 @@ int ib_cmrc_open ( struct interface *xfer, struct ib_device *ibdev,
388 390
 	cmrc->ibdev = ibdev;
389 391
 	memcpy ( &cmrc->dgid, dgid, sizeof ( cmrc->dgid ) );
390 392
 	memcpy ( &cmrc->service_id, service_id, sizeof ( cmrc->service_id ) );
391
-	process_init_stopped ( &cmrc->shutdown, ib_cmrc_shutdown,
393
+	process_init_stopped ( &cmrc->shutdown, &ib_cmrc_shutdown_desc,
392 394
 			       &cmrc->refcnt );
393 395
 
394 396
 	/* Open Infiniband device */

+ 1
- 4
src/net/netdevice.c View File

@@ -769,7 +769,4 @@ static void net_step ( struct process *process __unused ) {
769 769
 }
770 770
 
771 771
 /** Networking stack process */
772
-struct process net_process __permanent_process = {
773
-	.list = LIST_HEAD_INIT ( net_process.list ),
774
-	.step = net_step,
775
-};
772
+PERMANENT_PROCESS ( net_process, net_step );

+ 1
- 4
src/net/retry.c View File

@@ -198,7 +198,4 @@ static void retry_step ( struct process *process __unused ) {
198 198
 }
199 199
 
200 200
 /** Retry timer process */
201
-struct process retry_process __permanent_process = {
202
-	.list = LIST_HEAD_INIT ( retry_process.list ),
203
-	.step = retry_step,
204
-};
201
+PERMANENT_PROCESS ( retry_process, retry_step );

+ 7
- 5
src/net/tcp/http.c View File

@@ -483,11 +483,9 @@ static int http_socket_deliver ( struct http_request *http,
483 483
 /**
484 484
  * HTTP process
485 485
  *
486
- * @v process		Process
486
+ * @v http		HTTP request
487 487
  */
488
-static void http_step ( struct process *process ) {
489
-	struct http_request *http =
490
-		container_of ( process, struct http_request, process );
488
+static void http_step ( struct http_request *http ) {
491 489
 	const char *host = http->uri->host;
492 490
 	const char *user = http->uri->user;
493 491
 	const char *password =
@@ -561,6 +559,10 @@ static struct interface_descriptor http_xfer_desc =
561 559
 	INTF_DESC_PASSTHRU ( struct http_request, xfer,
562 560
 			     http_xfer_operations, socket );
563 561
 
562
+/** HTTP process descriptor */
563
+static struct process_descriptor http_process_desc =
564
+	PROC_DESC ( struct http_request, process, http_step );
565
+
564 566
 /**
565 567
  * Initiate an HTTP connection, with optional filter
566 568
  *
@@ -591,7 +593,7 @@ int http_open_filter ( struct interface *xfer, struct uri *uri,
591 593
 	intf_init ( &http->xfer, &http_xfer_desc, &http->refcnt );
592 594
        	http->uri = uri_get ( uri );
593 595
 	intf_init ( &http->socket, &http_socket_desc, &http->refcnt );
594
-	process_init ( &http->process, http_step, &http->refcnt );
596
+	process_init ( &http->process, &http_process_desc, &http->refcnt );
595 597
 
596 598
 	/* Open socket */
597 599
 	memset ( &server, 0, sizeof ( server ) );

+ 6
- 4
src/net/tcp/iscsi.c View File

@@ -1427,9 +1427,7 @@ static void iscsi_tx_done ( struct iscsi_session *iscsi ) {
1427 1427
  * 
1428 1428
  * Constructs data to be sent for the current TX state
1429 1429
  */
1430
-static void iscsi_tx_step ( struct process *process ) {
1431
-	struct iscsi_session *iscsi =
1432
-		container_of ( process, struct iscsi_session, process );
1430
+static void iscsi_tx_step ( struct iscsi_session *iscsi ) {
1433 1431
 	struct iscsi_bhs_common *common = &iscsi->tx_bhs.common;
1434 1432
 	int ( * tx ) ( struct iscsi_session *iscsi );
1435 1433
 	enum iscsi_tx_state next_state;
@@ -1488,6 +1486,10 @@ static void iscsi_tx_step ( struct process *process ) {
1488 1486
 	}
1489 1487
 }
1490 1488
 
1489
+/** iSCSI TX process descriptor */
1490
+static struct process_descriptor iscsi_process_desc =
1491
+	PROC_DESC ( struct iscsi_session, process, iscsi_tx_step );
1492
+
1491 1493
 /**
1492 1494
  * Receive basic header segment of an iSCSI PDU
1493 1495
  *
@@ -2034,7 +2036,7 @@ static int iscsi_open ( struct interface *parent, struct uri *uri ) {
2034 2036
 	intf_init ( &iscsi->control, &iscsi_control_desc, &iscsi->refcnt );
2035 2037
 	intf_init ( &iscsi->data, &iscsi_data_desc, &iscsi->refcnt );
2036 2038
 	intf_init ( &iscsi->socket, &iscsi_socket_desc, &iscsi->refcnt );
2037
-	process_init_stopped ( &iscsi->process, iscsi_tx_step,
2039
+	process_init_stopped ( &iscsi->process, &iscsi_process_desc,
2038 2040
 			       &iscsi->refcnt );
2039 2041
 
2040 2042
 	/* Parse root path */

+ 7
- 5
src/net/tls.c View File

@@ -1645,11 +1645,9 @@ static struct interface_descriptor tls_cipherstream_desc =
1645 1645
 /**
1646 1646
  * TLS TX state machine
1647 1647
  *
1648
- * @v process		TLS process
1648
+ * @v tls		TLS session
1649 1649
  */
1650
-static void tls_step ( struct process *process ) {
1651
-	struct tls_session *tls =
1652
-		container_of ( process, struct tls_session, process );
1650
+static void tls_step ( struct tls_session *tls ) {
1653 1651
 	int rc;
1654 1652
 
1655 1653
 	/* Wait for cipherstream to become ready */
@@ -1717,6 +1715,10 @@ static void tls_step ( struct process *process ) {
1717 1715
 	tls_close ( tls, rc );
1718 1716
 }
1719 1717
 
1718
+/** TLS TX process descriptor */
1719
+static struct process_descriptor tls_process_desc =
1720
+	PROC_DESC ( struct tls_session, process, tls_step );
1721
+
1720 1722
 /******************************************************************************
1721 1723
  *
1722 1724
  * Instantiator
@@ -1748,7 +1750,7 @@ int add_tls ( struct interface *xfer, struct interface **next ) {
1748 1750
 	digest_init ( &md5_algorithm, tls->handshake_md5_ctx );
1749 1751
 	digest_init ( &sha1_algorithm, tls->handshake_sha1_ctx );
1750 1752
 	tls->tx_state = TLS_TX_CLIENT_HELLO;
1751
-	process_init ( &tls->process, tls_step, &tls->refcnt );
1753
+	process_init ( &tls->process, &tls_process_desc, &tls->refcnt );
1752 1754
 
1753 1755
 	/* Attach to parent interface, mortalise self, and return */
1754 1756
 	intf_plug_plug ( &tls->plainstream, xfer );

Loading…
Cancel
Save