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 14 years ago
parent
commit
e01ec74601

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

26
 	process_del ( &hw->process );
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
 	int rc;
30
 	int rc;
39
 
31
 
40
 	if ( xfer_window ( &hw->xfer ) ) {
32
 	if ( xfer_window ( &hw->xfer ) ) {
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
 static int hw_open ( struct interface *xfer, struct uri *uri __unused ) {
48
 static int hw_open ( struct interface *xfer, struct uri *uri __unused ) {
47
 	struct hw *hw;
49
 	struct hw *hw;
48
 
50
 
52
 		return -ENOMEM;
54
 		return -ENOMEM;
53
 	ref_init ( &hw->refcnt, NULL );
55
 	ref_init ( &hw->refcnt, NULL );
54
 	intf_init ( &hw->xfer, &hw_xfer_desc, &hw->refcnt );
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
 	/* Attach parent interface, mortalise self, and return */
59
 	/* Attach parent interface, mortalise self, and return */
58
 	intf_plug_plug ( &hw->xfer, xfer );
60
 	intf_plug_plug ( &hw->xfer, xfer );

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

33
 /** Process run queue */
33
 /** Process run queue */
34
 static LIST_HEAD ( run_queue );
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
  * Add process to process list
47
  * Add process to process list
38
  *
48
  *
43
  */
53
  */
44
 void process_add ( struct process *process ) {
54
 void process_add ( struct process *process ) {
45
 	if ( ! process_running ( process ) ) {
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
 		ref_get ( process->refcnt );
58
 		ref_get ( process->refcnt );
49
 		list_add_tail ( &process->list, &run_queue );
59
 		list_add_tail ( &process->list, &run_queue );
50
 	} else {
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
  */
73
  */
64
 void process_del ( struct process *process ) {
74
 void process_del ( struct process *process ) {
65
 	if ( process_running ( process ) ) {
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
 		list_del ( &process->list );
78
 		list_del ( &process->list );
69
 		INIT_LIST_HEAD ( &process->list );
79
 		INIT_LIST_HEAD ( &process->list );
70
 		ref_put ( process->refcnt );
80
 		ref_put ( process->refcnt );
71
 	} else {
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
  */
92
  */
83
 void step ( void ) {
93
 void step ( void ) {
84
 	struct process *process;
94
 	struct process *process;
95
+	struct process_descriptor *desc;
96
+	void *object;
85
 
97
 
86
 	if ( ( process = list_first_entry ( &run_queue, struct process,
98
 	if ( ( process = list_first_entry ( &run_queue, struct process,
87
 					    list ) ) ) {
99
 					    list ) ) ) {
100
+		ref_get ( process->refcnt ); /* Inhibit destruction mid-step */
101
+		desc = process->desc;
102
+		object = process_object ( process );
88
 		list_del ( &process->list );
103
 		list_del ( &process->list );
89
 		list_add_tail ( &process->list, &run_queue );
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
 		ref_put ( process->refcnt ); /* Allow destruction */
110
 		ref_put ( process->refcnt ); /* Allow destruction */
97
 	}
111
 	}
98
 }
112
 }

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

86
 	int rc;
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
 	if ( numeric->rc == 0 )
92
 	if ( numeric->rc == 0 )
95
 		resolv_done ( &numeric->resolv, &numeric->sa );
93
 		resolv_done ( &numeric->resolv, &numeric->sa );
96
 	intf_shutdown ( &numeric->resolv, numeric->rc );
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
 static int numeric_resolv ( struct interface *resolv,
100
 static int numeric_resolv ( struct interface *resolv,
100
 			    const char *name, struct sockaddr *sa ) {
101
 			    const char *name, struct sockaddr *sa ) {
101
 	struct numeric_resolv *numeric;
102
 	struct numeric_resolv *numeric;
107
 		return -ENOMEM;
108
 		return -ENOMEM;
108
 	ref_init ( &numeric->refcnt, NULL );
109
 	ref_init ( &numeric->refcnt, NULL );
109
 	intf_init ( &numeric->resolv, &null_intf_desc, &numeric->refcnt );
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
 	memcpy ( &numeric->sa, sa, sizeof ( numeric->sa ) );
113
 	memcpy ( &numeric->sa, sa, sizeof ( numeric->sa ) );
112
 
114
 
113
 	DBGC ( numeric, "NUMERIC %p attempting to resolve \"%s\"\n",
115
 	DBGC ( numeric, "NUMERIC %p attempting to resolve \"%s\"\n",

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

892
 /**
892
 /**
893
  * SCSI TEST UNIT READY process
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
 	int rc;
898
 	int rc;
901
 
899
 
902
 	/* Wait until underlying SCSI device is ready */
900
 	/* Wait until underlying SCSI device is ready */
926
 	INTF_DESC_PASSTHRU ( struct scsi_device, scsi,
924
 	INTF_DESC_PASSTHRU ( struct scsi_device, scsi,
927
 			     scsidev_scsi_op, block );
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
  * Open SCSI device
932
  * Open SCSI device
931
  *
933
  *
946
 	intf_init ( &scsidev->block, &scsidev_block_desc, &scsidev->refcnt );
948
 	intf_init ( &scsidev->block, &scsidev_block_desc, &scsidev->refcnt );
947
 	intf_init ( &scsidev->scsi, &scsidev_scsi_desc, &scsidev->refcnt );
949
 	intf_init ( &scsidev->scsi, &scsidev_scsi_desc, &scsidev->refcnt );
948
 	intf_init ( &scsidev->ready, &scsidev_ready_desc, &scsidev->refcnt );
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
 	INIT_LIST_HEAD ( &scsidev->cmds );
953
 	INIT_LIST_HEAD ( &scsidev->cmds );
951
 	memcpy ( &scsidev->lun, lun, sizeof ( scsidev->lun ) );
954
 	memcpy ( &scsidev->lun, lun, sizeof ( scsidev->lun ) );
952
 	DBGC ( scsidev, "SCSI %p created for LUN " SCSI_LUN_FORMAT "\n",
955
 	DBGC ( scsidev, "SCSI %p created for LUN " SCSI_LUN_FORMAT "\n",

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

17
 struct process {
17
 struct process {
18
 	/** List of processes */
18
 	/** List of processes */
19
 	struct list_head list;
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
 	 * Single-step the process
35
 	 * Single-step the process
22
 	 *
36
 	 *
24
 	 * Returning from this method is isomorphic to yielding the
38
 	 * Returning from this method is isomorphic to yielding the
25
 	 * CPU to another process.
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
 extern void process_add ( struct process *process );
98
 extern void process_add ( struct process *process );
37
 extern void process_del ( struct process *process );
99
 extern void process_del ( struct process *process );
38
 extern void step ( void );
100
 extern void step ( void );
41
  * Initialise process without adding to process list
103
  * Initialise process without adding to process list
42
  *
104
  *
43
  * @v process		Process
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
 static inline __attribute__ (( always_inline )) void
109
 static inline __attribute__ (( always_inline )) void
47
 process_init_stopped ( struct process *process,
110
 process_init_stopped ( struct process *process,
48
-		       void ( * step ) ( struct process *process ),
111
+		       struct process_descriptor *desc,
49
 		       struct refcnt *refcnt ) {
112
 		       struct refcnt *refcnt ) {
50
 	INIT_LIST_HEAD ( &process->list );
113
 	INIT_LIST_HEAD ( &process->list );
51
-	process->step = step;
114
+	process->desc = desc;
52
 	process->refcnt = refcnt;
115
 	process->refcnt = refcnt;
53
 }
116
 }
54
 
117
 
56
  * Initialise process and add to process list
119
  * Initialise process and add to process list
57
  *
120
  *
58
  * @v process		Process
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
 static inline __attribute__ (( always_inline )) void
125
 static inline __attribute__ (( always_inline )) void
62
 process_init ( struct process *process,
126
 process_init ( struct process *process,
63
-	       void ( * step ) ( struct process *process ),
127
+	       struct process_descriptor *desc,
64
 	       struct refcnt *refcnt ) {
128
 	       struct refcnt *refcnt ) {
65
-	process_init_stopped ( process, step, refcnt );
129
+	process_init_stopped ( process, desc, refcnt );
66
 	process_add ( process );
130
 	process_add ( process );
67
 }
131
 }
68
 
132
 
88
  */
152
  */
89
 #define __permanent_process __table_entry ( PERMANENT_PROCESSES, 01 )
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
 #endif /* _IPXE_PROCESS_H */
187
 #endif /* _IPXE_PROCESS_H */

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

159
  * @defgroup net80211_assoc_ll 802.11 association handling functions
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
 static void net80211_handle_auth ( struct net80211_device *dev,
163
 static void net80211_handle_auth ( struct net80211_device *dev,
164
 				   struct io_buffer *iob );
164
 				   struct io_buffer *iob );
165
 static void net80211_handle_assoc_reply ( struct net80211_device *dev,
165
 static void net80211_handle_assoc_reply ( struct net80211_device *dev,
729
 
729
 
730
 /* ---------- Driver API ---------- */
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
  * Allocate 802.11 device
738
  * Allocate 802.11 device
734
  *
739
  *
760
 	dev->priv = ( u8 * ) dev + sizeof ( *dev );
765
 	dev->priv = ( u8 * ) dev + sizeof ( *dev );
761
 	dev->op = &net80211_null_ops;
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
 			       &netdev->refcnt );
769
 			       &netdev->refcnt );
765
 	INIT_LIST_HEAD ( &dev->mgmt_queue );
770
 	INIT_LIST_HEAD ( &dev->mgmt_queue );
766
 	INIT_LIST_HEAD ( &dev->mgmt_info_queue );
771
 	INIT_LIST_HEAD ( &dev->mgmt_info_queue );
1630
 /**
1635
 /**
1631
  * Step 802.11 association process
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
 	int rc = 0;
1642
 	int rc = 0;
1640
 	int status = dev->state & NET80211_STATUS_MASK;
1643
 	int status = dev->state & NET80211_STATUS_MASK;
1641
 
1644
 
1836
 
1839
 
1837
 	dev->rctl = rc80211_init ( dev );
1840
 	dev->rctl = rc80211_init ( dev );
1838
 
1841
 
1839
-	process_del ( proc );
1842
+	process_del ( &dev->proc_assoc );
1840
 
1843
 
1841
 	DBGC ( dev, "802.11 %p associated with %s (%s)\n", dev,
1844
 	DBGC ( dev, "802.11 %p associated with %s (%s)\n", dev,
1842
 	       dev->essid, eth_ntoa ( dev->bssid ) );
1845
 	       dev->essid, eth_ntoa ( dev->bssid ) );
1861
 	net80211_free_wlan ( dev->associating );
1864
 	net80211_free_wlan ( dev->associating );
1862
 	dev->associating = NULL;
1865
 	dev->associating = NULL;
1863
 
1866
 
1864
-	process_del ( proc );
1867
+	process_del ( &dev->proc_assoc );
1865
 
1868
 
1866
 	DBGC ( dev, "802.11 %p association failed (state=%04x): "
1869
 	DBGC ( dev, "802.11 %p association failed (state=%04x): "
1867
 	       "%s\n", dev, dev->state, strerror ( dev->assoc_rc ) );
1870
 	       "%s\n", dev, dev->state, strerror ( dev->assoc_rc ) );

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

244
 /**
244
 /**
245
  * Fibre Channel ELS process
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
 	int xchg_id;
250
 	int xchg_id;
253
 	int rc;
251
 	int rc;
254
 
252
 
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
  * Create ELS transaction
284
  * Create ELS transaction
283
  *
285
  *
298
 	ref_init ( &els->refcnt, fc_els_free );
300
 	ref_init ( &els->refcnt, fc_els_free );
299
 	intf_init ( &els->job, &fc_els_job_desc, &els->refcnt );
301
 	intf_init ( &els->job, &fc_els_job_desc, &els->refcnt );
300
 	intf_init ( &els->xchg, &fc_els_xchg_desc, &els->refcnt );
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
 	els->port = fc_port_get ( port );
305
 	els->port = fc_port_get ( port );
303
 	memcpy ( &els->port_id, port_id, sizeof ( els->port_id ) );
306
 	memcpy ( &els->port_id, port_id, sizeof ( els->port_id ) );
304
 	memcpy ( &els->peer_port_id, peer_port_id,
307
 	memcpy ( &els->peer_port_id, peer_port_id,

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

153
 /**
153
 /**
154
  * Name server query process
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
 	struct xfer_metadata meta;
159
 	struct xfer_metadata meta;
162
 	struct fc_ns_gid_pn_request gid_pn;
160
 	struct fc_ns_gid_pn_request gid_pn;
163
 	int xchg_id;
161
 	int xchg_id;
208
 static struct interface_descriptor fc_ns_query_xchg_desc =
206
 static struct interface_descriptor fc_ns_query_xchg_desc =
209
 	INTF_DESC ( struct fc_ns_query, xchg, fc_ns_query_xchg_op );
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
  * Issue Fibre Channel name server query
214
  * Issue Fibre Channel name server query
213
  *
215
  *
226
 		return -ENOMEM;
228
 		return -ENOMEM;
227
 	ref_init ( &query->refcnt, fc_ns_query_free );
229
 	ref_init ( &query->refcnt, fc_ns_query_free );
228
 	intf_init ( &query->xchg, &fc_ns_query_xchg_desc, &query->refcnt );
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
 	query->peer = fc_peer_get ( peer );
233
 	query->peer = fc_peer_get ( peer );
231
 	query->port = fc_port_get ( port );
234
 	query->port = fc_port_get ( port );
232
 	query->done = done;
235
 	query->done = done;

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

649
 /**
649
 /**
650
  * Transmit FCP frame
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
 	int rc;
655
 	int rc;
658
 
656
 
659
 	/* Send the current IU */
657
 	/* Send the current IU */
723
 static struct interface_descriptor fcpcmd_xchg_desc =
721
 static struct interface_descriptor fcpcmd_xchg_desc =
724
 	INTF_DESC_PASSTHRU ( struct fcp_command, xchg, fcpcmd_xchg_op, scsi );
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
  * Issue FCP SCSI command
729
  * Issue FCP SCSI command
728
  *
730
  *
765
 	ref_init ( &fcpcmd->refcnt, fcpcmd_free );
767
 	ref_init ( &fcpcmd->refcnt, fcpcmd_free );
766
 	intf_init ( &fcpcmd->scsi, &fcpcmd_scsi_desc, &fcpcmd->refcnt );
768
 	intf_init ( &fcpcmd->scsi, &fcpcmd_scsi_desc, &fcpcmd->refcnt );
767
 	intf_init ( &fcpcmd->xchg, &fcpcmd_xchg_desc, &fcpcmd->refcnt );
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
 	fcpcmd->fcpdev = fcpdev_get ( fcpdev );
772
 	fcpcmd->fcpdev = fcpdev_get ( fcpdev );
770
 	list_add ( &fcpcmd->list, &fcpdev->fcpcmds );
773
 	list_add ( &fcpcmd->list, &fcpdev->fcpcmds );
771
 	memcpy ( &fcpcmd->command, command, sizeof ( fcpcmd->command ) );
774
 	memcpy ( &fcpcmd->command, command, sizeof ( fcpcmd->command ) );

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

866
 }
866
 }
867
 
867
 
868
 /** Infiniband event queue process */
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
 /**
92
 /**
93
  * Shut down CMRC connection gracefully
93
  * Shut down CMRC connection gracefully
94
  *
94
  *
95
- * @v process		Process
95
+ * @v cmrc		Communication-Managed Reliable Connection
96
  *
96
  *
97
  * The Infiniband data structures are not reference-counted or
97
  * The Infiniband data structures are not reference-counted or
98
  * guarded.  It is therefore unsafe to shut them down while we may be
98
  * guarded.  It is therefore unsafe to shut them down while we may be
107
  * connection, ensuring that the structure is not freed before the
107
  * connection, ensuring that the structure is not freed before the
108
  * shutdown process has run.
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
 	DBGC ( cmrc, "CMRC %p shutting down\n", cmrc );
112
 	DBGC ( cmrc, "CMRC %p shutting down\n", cmrc );
115
 
113
 
363
 static struct interface_descriptor ib_cmrc_xfer_desc =
361
 static struct interface_descriptor ib_cmrc_xfer_desc =
364
 	INTF_DESC ( struct ib_cmrc_connection, xfer, ib_cmrc_xfer_operations );
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
  * Open CMRC connection
369
  * Open CMRC connection
368
  *
370
  *
388
 	cmrc->ibdev = ibdev;
390
 	cmrc->ibdev = ibdev;
389
 	memcpy ( &cmrc->dgid, dgid, sizeof ( cmrc->dgid ) );
391
 	memcpy ( &cmrc->dgid, dgid, sizeof ( cmrc->dgid ) );
390
 	memcpy ( &cmrc->service_id, service_id, sizeof ( cmrc->service_id ) );
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
 			       &cmrc->refcnt );
394
 			       &cmrc->refcnt );
393
 
395
 
394
 	/* Open Infiniband device */
396
 	/* Open Infiniband device */

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

769
 }
769
 }
770
 
770
 
771
 /** Networking stack process */
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
 }
198
 }
199
 
199
 
200
 /** Retry timer process */
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
 /**
483
 /**
484
  * HTTP process
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
 	const char *host = http->uri->host;
489
 	const char *host = http->uri->host;
492
 	const char *user = http->uri->user;
490
 	const char *user = http->uri->user;
493
 	const char *password =
491
 	const char *password =
561
 	INTF_DESC_PASSTHRU ( struct http_request, xfer,
559
 	INTF_DESC_PASSTHRU ( struct http_request, xfer,
562
 			     http_xfer_operations, socket );
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
  * Initiate an HTTP connection, with optional filter
567
  * Initiate an HTTP connection, with optional filter
566
  *
568
  *
591
 	intf_init ( &http->xfer, &http_xfer_desc, &http->refcnt );
593
 	intf_init ( &http->xfer, &http_xfer_desc, &http->refcnt );
592
        	http->uri = uri_get ( uri );
594
        	http->uri = uri_get ( uri );
593
 	intf_init ( &http->socket, &http_socket_desc, &http->refcnt );
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
 	/* Open socket */
598
 	/* Open socket */
597
 	memset ( &server, 0, sizeof ( server ) );
599
 	memset ( &server, 0, sizeof ( server ) );

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

1427
  * 
1427
  * 
1428
  * Constructs data to be sent for the current TX state
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
 	struct iscsi_bhs_common *common = &iscsi->tx_bhs.common;
1431
 	struct iscsi_bhs_common *common = &iscsi->tx_bhs.common;
1434
 	int ( * tx ) ( struct iscsi_session *iscsi );
1432
 	int ( * tx ) ( struct iscsi_session *iscsi );
1435
 	enum iscsi_tx_state next_state;
1433
 	enum iscsi_tx_state next_state;
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
  * Receive basic header segment of an iSCSI PDU
1494
  * Receive basic header segment of an iSCSI PDU
1493
  *
1495
  *
2034
 	intf_init ( &iscsi->control, &iscsi_control_desc, &iscsi->refcnt );
2036
 	intf_init ( &iscsi->control, &iscsi_control_desc, &iscsi->refcnt );
2035
 	intf_init ( &iscsi->data, &iscsi_data_desc, &iscsi->refcnt );
2037
 	intf_init ( &iscsi->data, &iscsi_data_desc, &iscsi->refcnt );
2036
 	intf_init ( &iscsi->socket, &iscsi_socket_desc, &iscsi->refcnt );
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
 			       &iscsi->refcnt );
2040
 			       &iscsi->refcnt );
2039
 
2041
 
2040
 	/* Parse root path */
2042
 	/* Parse root path */

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

1645
 /**
1645
 /**
1646
  * TLS TX state machine
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
 	int rc;
1651
 	int rc;
1654
 
1652
 
1655
 	/* Wait for cipherstream to become ready */
1653
 	/* Wait for cipherstream to become ready */
1717
 	tls_close ( tls, rc );
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
  * Instantiator
1724
  * Instantiator
1748
 	digest_init ( &md5_algorithm, tls->handshake_md5_ctx );
1750
 	digest_init ( &md5_algorithm, tls->handshake_md5_ctx );
1749
 	digest_init ( &sha1_algorithm, tls->handshake_sha1_ctx );
1751
 	digest_init ( &sha1_algorithm, tls->handshake_sha1_ctx );
1750
 	tls->tx_state = TLS_TX_CLIENT_HELLO;
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
 	/* Attach to parent interface, mortalise self, and return */
1755
 	/* Attach to parent interface, mortalise self, and return */
1754
 	intf_plug_plug ( &tls->plainstream, xfer );
1756
 	intf_plug_plug ( &tls->plainstream, xfer );

Loading…
Cancel
Save