Browse Source

[ata] Make ATA command issuing partially asynchronous

Move the icky call to step() from aoe.c to ata.c; this takes it at
least one step further away from where it really doesn't belong.

Unfortunately, AoE has the ugly aoe_discover() mechanism which means
that we still have a step() loop in aoe.c for now; this needs to be
replaced at some future point.
tags/v0.9.8
Michael Brown 15 years ago
parent
commit
54ec3673cc
4 changed files with 29 additions and 9 deletions
  1. 24
    1
      src/drivers/block/ata.c
  2. 2
    0
      src/include/gpxe/ata.h
  3. 1
    0
      src/include/gpxe/errfile.h
  4. 2
    8
      src/net/aoe.c

+ 24
- 1
src/drivers/block/ata.c View File

21
 #include <stddef.h>
21
 #include <stddef.h>
22
 #include <string.h>
22
 #include <string.h>
23
 #include <assert.h>
23
 #include <assert.h>
24
+#include <errno.h>
24
 #include <byteswap.h>
25
 #include <byteswap.h>
25
 #include <gpxe/blockdev.h>
26
 #include <gpxe/blockdev.h>
27
+#include <gpxe/process.h>
26
 #include <gpxe/ata.h>
28
 #include <gpxe/ata.h>
27
 
29
 
28
 /** @file
30
 /** @file
45
  */
47
  */
46
 static inline __attribute__ (( always_inline )) int
48
 static inline __attribute__ (( always_inline )) int
47
 ata_command ( struct ata_device *ata, struct ata_command *command ) {
49
 ata_command ( struct ata_device *ata, struct ata_command *command ) {
50
+	int rc;
51
+
48
 	DBG ( "ATA cmd %02x dev %02x LBA%s %llx count %04x\n",
52
 	DBG ( "ATA cmd %02x dev %02x LBA%s %llx count %04x\n",
49
 	      command->cb.cmd_stat, command->cb.device,
53
 	      command->cb.cmd_stat, command->cb.device,
50
 	      ( command->cb.lba48 ? "48" : "" ),
54
 	      ( command->cb.lba48 ? "48" : "" ),
51
 	      ( unsigned long long ) command->cb.lba.native,
55
 	      ( unsigned long long ) command->cb.lba.native,
52
 	      command->cb.count.native );
56
 	      command->cb.count.native );
53
 
57
 
54
-	return ata->command ( ata, command );	
58
+	/* Flag command as in-progress */
59
+	command->rc = -EINPROGRESS;
60
+
61
+	/* Issue ATA command */
62
+	if ( ( rc = ata->command ( ata, command ) ) != 0 ) {
63
+		/* Something went wrong with the issuing mechanism */
64
+		DBG ( "ATA could not issue command: %s\n", strerror ( rc ) );
65
+		return rc;
66
+	}
67
+
68
+	/* Wait for command to complete */
69
+	while ( command->rc == -EINPROGRESS )
70
+		step();
71
+	if ( ( rc = command->rc ) != 0 ) {
72
+		/* Something went wrong with the command execution */
73
+		DBG ( "ATA command failed: %s\n", strerror ( rc ) );
74
+		return rc;
75
+	}
76
+
77
+	return 0;
55
 }
78
 }
56
 
79
 
57
 /**
80
 /**

+ 2
- 0
src/include/gpxe/ata.h View File

154
 	 * sectors in size.
154
 	 * sectors in size.
155
 	 */
155
 	 */
156
 	userptr_t data_in;
156
 	userptr_t data_in;
157
+	/** Command status code */
158
+	int rc;
157
 };
159
 };
158
 
160
 
159
 /**
161
 /**

+ 1
- 0
src/include/gpxe/errfile.h View File

115
 #define ERRFILE_arbel		     ( ERRFILE_DRIVER | 0x00710000 )
115
 #define ERRFILE_arbel		     ( ERRFILE_DRIVER | 0x00710000 )
116
 #define ERRFILE_hermon		     ( ERRFILE_DRIVER | 0x00720000 )
116
 #define ERRFILE_hermon		     ( ERRFILE_DRIVER | 0x00720000 )
117
 #define ERRFILE_linda		     ( ERRFILE_DRIVER | 0x00730000 )
117
 #define ERRFILE_linda		     ( ERRFILE_DRIVER | 0x00730000 )
118
+#define ERRFILE_ata		     ( ERRFILE_DRIVER | 0x00740000 )
118
 
119
 
119
 #define ERRFILE_aoe			( ERRFILE_NET | 0x00000000 )
120
 #define ERRFILE_aoe			( ERRFILE_NET | 0x00000000 )
120
 #define ERRFILE_arp			( ERRFILE_NET | 0x00010000 )
121
 #define ERRFILE_arp			( ERRFILE_NET | 0x00010000 )

+ 2
- 8
src/net/aoe.c View File

68
 	/* Record overall command status */
68
 	/* Record overall command status */
69
 	if ( aoe->command ) {
69
 	if ( aoe->command ) {
70
 		aoe->command->cb.cmd_stat = aoe->status;
70
 		aoe->command->cb.cmd_stat = aoe->status;
71
+		aoe->command->rc = rc;
71
 		aoe->command = NULL;
72
 		aoe->command = NULL;
72
 	}
73
 	}
73
 
74
 
356
 			 struct ata_command *command ) {
357
 			 struct ata_command *command ) {
357
 	struct aoe_session *aoe =
358
 	struct aoe_session *aoe =
358
 		container_of ( ata->backend, struct aoe_session, refcnt );
359
 		container_of ( ata->backend, struct aoe_session, refcnt );
359
-	int rc;
360
 
360
 
361
 	aoe->command = command;
361
 	aoe->command = command;
362
 	aoe->status = 0;
362
 	aoe->status = 0;
365
 
365
 
366
 	aoe_send_command ( aoe );
366
 	aoe_send_command ( aoe );
367
 
367
 
368
-	aoe->rc = -EINPROGRESS;
369
-	while ( aoe->rc == -EINPROGRESS )
370
-		step();
371
-	rc = aoe->rc;
372
-
373
-	return rc;
368
+	return 0;
374
 }
369
 }
375
 
370
 
376
-
377
 /**
371
 /**
378
  * Issue AoE config query for AoE target discovery
372
  * Issue AoE config query for AoE target discovery
379
  *
373
  *

Loading…
Cancel
Save