Browse Source

[pxe] Improve pxe_preboot debugging messages

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 12 years ago
parent
commit
caf98cf624
1 changed files with 48 additions and 23 deletions
  1. 48
    23
      src/arch/i386/interface/pxe/pxe_preboot.c

+ 48
- 23
src/arch/i386/interface/pxe/pxe_preboot.c View File

89
 	[CACHED_INFO_BINL] = { create_fakepxebsack },
89
 	[CACHED_INFO_BINL] = { create_fakepxebsack },
90
 };
90
 };
91
 
91
 
92
+/**
93
+ * Name PXENV_GET_CACHED_INFO packet type
94
+ *
95
+ * @v packet_type	Packet type
96
+ * @ret name		Name of packet type
97
+ */
98
+static inline __attribute__ (( always_inline )) const char *
99
+pxenv_get_cached_info_name ( int packet_type ) {
100
+	switch ( packet_type ) {
101
+	case PXENV_PACKET_TYPE_DHCP_DISCOVER:
102
+		return "DHCPDISCOVER";
103
+	case PXENV_PACKET_TYPE_DHCP_ACK:
104
+		return "DHCPACK";
105
+	case PXENV_PACKET_TYPE_CACHED_REPLY:
106
+		return "BINL";
107
+	default:
108
+		return "<INVALID>";
109
+	}
110
+}
111
+
92
 /* The case in which the caller doesn't supply a buffer is really
112
 /* The case in which the caller doesn't supply a buffer is really
93
  * awkward to support given that we have multiple sources of options,
113
  * awkward to support given that we have multiple sources of options,
94
  * and that we don't actually store the DHCP packets.  (We may not
114
  * and that we don't actually store the DHCP packets.  (We may not
111
  *
131
  *
112
  */
132
  */
113
 PXENV_EXIT_t pxenv_unload_stack ( struct s_PXENV_UNLOAD_STACK *unload_stack ) {
133
 PXENV_EXIT_t pxenv_unload_stack ( struct s_PXENV_UNLOAD_STACK *unload_stack ) {
114
-	DBG ( "PXENV_UNLOAD_STACK" );
134
+	DBGC ( &pxe_netdev, "PXENV_UNLOAD_STACK\n" );
115
 
135
 
116
 	unload_stack->Status = PXENV_STATUS_SUCCESS;
136
 	unload_stack->Status = PXENV_STATUS_SUCCESS;
117
 	return PXENV_EXIT_SUCCESS;
137
 	return PXENV_EXIT_SUCCESS;
130
 	userptr_t buffer;
150
 	userptr_t buffer;
131
 	int rc;
151
 	int rc;
132
 
152
 
133
-	DBG ( "PXENV_GET_CACHED_INFO %d", get_cached_info->PacketType );
134
-
135
-	DBG ( " to %04x:%04x+%x", get_cached_info->Buffer.segment,
136
-	      get_cached_info->Buffer.offset, get_cached_info->BufferSize );
153
+	DBGC ( &pxe_netdev, "PXENV_GET_CACHED_INFO %s to %04x:%04x+%x",
154
+	       pxenv_get_cached_info_name ( get_cached_info->PacketType ),
155
+	       get_cached_info->Buffer.segment,
156
+	       get_cached_info->Buffer.offset, get_cached_info->BufferSize );
137
 
157
 
138
 	/* Sanity check */
158
 	/* Sanity check */
139
         idx = ( get_cached_info->PacketType - 1 );
159
         idx = ( get_cached_info->PacketType - 1 );
140
 	if ( idx >= NUM_CACHED_INFOS ) {
160
 	if ( idx >= NUM_CACHED_INFOS ) {
141
-		DBG ( " bad PacketType" );
161
+		DBGC ( &pxe_netdev, " bad PacketType %d\n",
162
+		       get_cached_info->PacketType );
142
 		goto err;
163
 		goto err;
143
 	}
164
 	}
144
 	info = &cached_info[idx];
165
 	info = &cached_info[idx];
149
 		creator = &pxe_dhcp_packet_creators[idx];
170
 		creator = &pxe_dhcp_packet_creators[idx];
150
 		if ( ( rc = creator->create ( pxe_netdev, info,
171
 		if ( ( rc = creator->create ( pxe_netdev, info,
151
 					      sizeof ( *info ) ) ) != 0 ) {
172
 					      sizeof ( *info ) ) ) != 0 ) {
152
-			DBG ( " failed to build packet" );
173
+			DBGC ( &pxe_netdev, " failed to build packet: %s\n",
174
+			       strerror ( rc ) );
153
 			goto err;
175
 			goto err;
154
 		}
176
 		}
155
 	}
177
 	}
184
 		get_cached_info->Buffer.segment = rm_ds;
206
 		get_cached_info->Buffer.segment = rm_ds;
185
 		get_cached_info->Buffer.offset = __from_data16 ( info );
207
 		get_cached_info->Buffer.offset = __from_data16 ( info );
186
 		get_cached_info->BufferSize = sizeof ( *info );
208
 		get_cached_info->BufferSize = sizeof ( *info );
187
-		DBG ( " returning %04x:%04x+%04x['%x']",
188
-		      get_cached_info->Buffer.segment,
189
-		      get_cached_info->Buffer.offset,
190
-		      get_cached_info->BufferSize,
191
-		      get_cached_info->BufferLimit );
209
+		DBGC ( &pxe_netdev, " using %04x:%04x+%04x['%x']",
210
+		       get_cached_info->Buffer.segment,
211
+		       get_cached_info->Buffer.offset,
212
+		       get_cached_info->BufferSize,
213
+		       get_cached_info->BufferLimit );
192
 	} else {
214
 	} else {
193
 		/* Copy packet to client buffer */
215
 		/* Copy packet to client buffer */
194
 		if ( len > sizeof ( *info ) )
216
 		if ( len > sizeof ( *info ) )
195
 			len = sizeof ( *info );
217
 			len = sizeof ( *info );
196
 		if ( len < sizeof ( *info ) )
218
 		if ( len < sizeof ( *info ) )
197
-			DBG ( " buffer may be too short" );
219
+			DBGC ( &pxe_netdev, " buffer may be too short" );
198
 		buffer = real_to_user ( get_cached_info->Buffer.segment,
220
 		buffer = real_to_user ( get_cached_info->Buffer.segment,
199
 					get_cached_info->Buffer.offset );
221
 					get_cached_info->Buffer.offset );
200
 		copy_to_user ( buffer, 0, info, len );
222
 		copy_to_user ( buffer, 0, info, len );
201
 		get_cached_info->BufferSize = len;
223
 		get_cached_info->BufferSize = len;
202
 	}
224
 	}
203
 
225
 
226
+	DBGC ( &pxe_netdev, "\n" );
204
 	get_cached_info->Status = PXENV_STATUS_SUCCESS;
227
 	get_cached_info->Status = PXENV_STATUS_SUCCESS;
205
 	return PXENV_EXIT_SUCCESS;
228
 	return PXENV_EXIT_SUCCESS;
206
 
229
 
217
 				  *restart_tftp ) {
240
 				  *restart_tftp ) {
218
 	PXENV_EXIT_t tftp_exit;
241
 	PXENV_EXIT_t tftp_exit;
219
 
242
 
220
-	DBG ( "PXENV_RESTART_TFTP " );
243
+	DBGC ( &pxe_netdev, "PXENV_RESTART_TFTP\n" );
221
 
244
 
222
 	/* Words cannot describe the complete mismatch between the PXE
245
 	/* Words cannot describe the complete mismatch between the PXE
223
 	 * specification and any possible version of reality...
246
 	 * specification and any possible version of reality...
241
 	unsigned int location;
264
 	unsigned int location;
242
 	struct net_device *netdev;
265
 	struct net_device *netdev;
243
 
266
 
244
-	DBG ( "PXENV_START_UNDI %04x:%04x:%04x",
245
-	      start_undi->AX, start_undi->BX, start_undi->DX );
267
+	DBGC ( &pxe_netdev, "PXENV_START_UNDI %04x:%04x:%04x\n",
268
+	       start_undi->AX, start_undi->BX, start_undi->DX );
246
 
269
 
247
 	/* Determine bus type and location.  Use a heuristic to decide
270
 	/* Determine bus type and location.  Use a heuristic to decide
248
 	 * whether we are PCI or ISAPnP
271
 	 * whether we are PCI or ISAPnP
266
 	/* Look for a matching net device */
289
 	/* Look for a matching net device */
267
 	netdev = find_netdev_by_location ( bus_type, location );
290
 	netdev = find_netdev_by_location ( bus_type, location );
268
 	if ( ! netdev ) {
291
 	if ( ! netdev ) {
269
-		DBG ( " no net device found" );
292
+		DBGC ( &pxe_netdev, "PXENV_START_UNDI could not find matching "
293
+		       "net device\n" );
270
 		start_undi->Status = PXENV_STATUS_UNDI_CANNOT_INITIALIZE_NIC;
294
 		start_undi->Status = PXENV_STATUS_UNDI_CANNOT_INITIALIZE_NIC;
271
 		return PXENV_EXIT_FAILURE;
295
 		return PXENV_EXIT_FAILURE;
272
 	}
296
 	}
273
-	DBG ( " using netdev %s", netdev->name );
297
+	DBGC ( &pxe_netdev, "PXENV_START_UNDI found net device %s\n",
298
+	       netdev->name );
274
 
299
 
275
 	/* Activate PXE */
300
 	/* Activate PXE */
276
 	pxe_activate ( netdev );
301
 	pxe_activate ( netdev );
284
  * Status: working
309
  * Status: working
285
  */
310
  */
286
 PXENV_EXIT_t pxenv_stop_undi ( struct s_PXENV_STOP_UNDI *stop_undi ) {
311
 PXENV_EXIT_t pxenv_stop_undi ( struct s_PXENV_STOP_UNDI *stop_undi ) {
287
-	DBG ( "PXENV_STOP_UNDI" );
312
+	DBGC ( &pxe_netdev, "PXENV_STOP_UNDI\n" );
288
 
313
 
289
 	/* Deactivate PXE */
314
 	/* Deactivate PXE */
290
 	pxe_deactivate();
315
 	pxe_deactivate();
294
 
319
 
295
 	/* Check to see if we still have any hooked interrupts */
320
 	/* Check to see if we still have any hooked interrupts */
296
 	if ( hooked_bios_interrupts != 0 ) {
321
 	if ( hooked_bios_interrupts != 0 ) {
297
-		DBG ( "PXENV_STOP_UNDI failed: %d interrupts still hooked\n",
298
-		      hooked_bios_interrupts );
322
+		DBGC ( &pxe_netdev, "PXENV_STOP_UNDI failed: %d interrupts "
323
+		       "still hooked\n", hooked_bios_interrupts );
299
 		stop_undi->Status = PXENV_STATUS_KEEP_UNDI;
324
 		stop_undi->Status = PXENV_STATUS_KEEP_UNDI;
300
 		return PXENV_EXIT_FAILURE;
325
 		return PXENV_EXIT_FAILURE;
301
 	}
326
 	}
309
  * Status: won't implement (requires major structural changes)
334
  * Status: won't implement (requires major structural changes)
310
  */
335
  */
311
 PXENV_EXIT_t pxenv_start_base ( struct s_PXENV_START_BASE *start_base ) {
336
 PXENV_EXIT_t pxenv_start_base ( struct s_PXENV_START_BASE *start_base ) {
312
-	DBG ( "PXENV_START_BASE" );
337
+	DBGC ( &pxe_netdev, "PXENV_START_BASE\n" );
313
 
338
 
314
 	start_base->Status = PXENV_STATUS_UNSUPPORTED;
339
 	start_base->Status = PXENV_STATUS_UNSUPPORTED;
315
 	return PXENV_EXIT_FAILURE;
340
 	return PXENV_EXIT_FAILURE;
320
  * Status: working
345
  * Status: working
321
  */
346
  */
322
 PXENV_EXIT_t pxenv_stop_base ( struct s_PXENV_STOP_BASE *stop_base ) {
347
 PXENV_EXIT_t pxenv_stop_base ( struct s_PXENV_STOP_BASE *stop_base ) {
323
-	DBG ( "PXENV_STOP_BASE" );
348
+	DBGC ( &pxe_netdev, "PXENV_STOP_BASE\n" );
324
 
349
 
325
 	/* The only time we will be called is when the NBP is trying
350
 	/* The only time we will be called is when the NBP is trying
326
 	 * to shut down the PXE stack.  There's nothing we need to do
351
 	 * to shut down the PXE stack.  There's nothing we need to do

Loading…
Cancel
Save