Browse Source

[pxe] Improve pxe_preboot debugging messages

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 13 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,6 +89,26 @@ static struct pxe_dhcp_packet_creator pxe_dhcp_packet_creators[] = {
89 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 112
 /* The case in which the caller doesn't supply a buffer is really
93 113
  * awkward to support given that we have multiple sources of options,
94 114
  * and that we don't actually store the DHCP packets.  (We may not
@@ -111,7 +131,7 @@ static union pxe_cached_info __bss16_array ( cached_info, [NUM_CACHED_INFOS] );
111 131
  *
112 132
  */
113 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 136
 	unload_stack->Status = PXENV_STATUS_SUCCESS;
117 137
 	return PXENV_EXIT_SUCCESS;
@@ -130,15 +150,16 @@ PXENV_EXIT_t pxenv_get_cached_info ( struct s_PXENV_GET_CACHED_INFO
130 150
 	userptr_t buffer;
131 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 158
 	/* Sanity check */
139 159
         idx = ( get_cached_info->PacketType - 1 );
140 160
 	if ( idx >= NUM_CACHED_INFOS ) {
141
-		DBG ( " bad PacketType" );
161
+		DBGC ( &pxe_netdev, " bad PacketType %d\n",
162
+		       get_cached_info->PacketType );
142 163
 		goto err;
143 164
 	}
144 165
 	info = &cached_info[idx];
@@ -149,7 +170,8 @@ PXENV_EXIT_t pxenv_get_cached_info ( struct s_PXENV_GET_CACHED_INFO
149 170
 		creator = &pxe_dhcp_packet_creators[idx];
150 171
 		if ( ( rc = creator->create ( pxe_netdev, info,
151 172
 					      sizeof ( *info ) ) ) != 0 ) {
152
-			DBG ( " failed to build packet" );
173
+			DBGC ( &pxe_netdev, " failed to build packet: %s\n",
174
+			       strerror ( rc ) );
153 175
 			goto err;
154 176
 		}
155 177
 	}
@@ -184,23 +206,24 @@ PXENV_EXIT_t pxenv_get_cached_info ( struct s_PXENV_GET_CACHED_INFO
184 206
 		get_cached_info->Buffer.segment = rm_ds;
185 207
 		get_cached_info->Buffer.offset = __from_data16 ( info );
186 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 214
 	} else {
193 215
 		/* Copy packet to client buffer */
194 216
 		if ( len > sizeof ( *info ) )
195 217
 			len = sizeof ( *info );
196 218
 		if ( len < sizeof ( *info ) )
197
-			DBG ( " buffer may be too short" );
219
+			DBGC ( &pxe_netdev, " buffer may be too short" );
198 220
 		buffer = real_to_user ( get_cached_info->Buffer.segment,
199 221
 					get_cached_info->Buffer.offset );
200 222
 		copy_to_user ( buffer, 0, info, len );
201 223
 		get_cached_info->BufferSize = len;
202 224
 	}
203 225
 
226
+	DBGC ( &pxe_netdev, "\n" );
204 227
 	get_cached_info->Status = PXENV_STATUS_SUCCESS;
205 228
 	return PXENV_EXIT_SUCCESS;
206 229
 
@@ -217,7 +240,7 @@ PXENV_EXIT_t pxenv_restart_tftp ( struct s_PXENV_TFTP_READ_FILE
217 240
 				  *restart_tftp ) {
218 241
 	PXENV_EXIT_t tftp_exit;
219 242
 
220
-	DBG ( "PXENV_RESTART_TFTP " );
243
+	DBGC ( &pxe_netdev, "PXENV_RESTART_TFTP\n" );
221 244
 
222 245
 	/* Words cannot describe the complete mismatch between the PXE
223 246
 	 * specification and any possible version of reality...
@@ -241,8 +264,8 @@ PXENV_EXIT_t pxenv_start_undi ( struct s_PXENV_START_UNDI *start_undi ) {
241 264
 	unsigned int location;
242 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 270
 	/* Determine bus type and location.  Use a heuristic to decide
248 271
 	 * whether we are PCI or ISAPnP
@@ -266,11 +289,13 @@ PXENV_EXIT_t pxenv_start_undi ( struct s_PXENV_START_UNDI *start_undi ) {
266 289
 	/* Look for a matching net device */
267 290
 	netdev = find_netdev_by_location ( bus_type, location );
268 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 294
 		start_undi->Status = PXENV_STATUS_UNDI_CANNOT_INITIALIZE_NIC;
271 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 300
 	/* Activate PXE */
276 301
 	pxe_activate ( netdev );
@@ -284,7 +309,7 @@ PXENV_EXIT_t pxenv_start_undi ( struct s_PXENV_START_UNDI *start_undi ) {
284 309
  * Status: working
285 310
  */
286 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 314
 	/* Deactivate PXE */
290 315
 	pxe_deactivate();
@@ -294,8 +319,8 @@ PXENV_EXIT_t pxenv_stop_undi ( struct s_PXENV_STOP_UNDI *stop_undi ) {
294 319
 
295 320
 	/* Check to see if we still have any hooked interrupts */
296 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 324
 		stop_undi->Status = PXENV_STATUS_KEEP_UNDI;
300 325
 		return PXENV_EXIT_FAILURE;
301 326
 	}
@@ -309,7 +334,7 @@ PXENV_EXIT_t pxenv_stop_undi ( struct s_PXENV_STOP_UNDI *stop_undi ) {
309 334
  * Status: won't implement (requires major structural changes)
310 335
  */
311 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 339
 	start_base->Status = PXENV_STATUS_UNSUPPORTED;
315 340
 	return PXENV_EXIT_FAILURE;
@@ -320,7 +345,7 @@ PXENV_EXIT_t pxenv_start_base ( struct s_PXENV_START_BASE *start_base ) {
320 345
  * Status: working
321 346
  */
322 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 350
 	/* The only time we will be called is when the NBP is trying
326 351
 	 * to shut down the PXE stack.  There's nothing we need to do

Loading…
Cancel
Save