Browse Source

[infiniband] Include the SRP login rejection reason in the error number

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 14 years ago
parent
commit
29ad8a922b
2 changed files with 54 additions and 5 deletions
  1. 50
    5
      src/drivers/block/srp.c
  2. 4
    0
      src/include/ipxe/srp.h

+ 50
- 5
src/drivers/block/srp.c View File

@@ -54,6 +54,50 @@ FEATURE ( FEATURE_PROTOCOL, "SRP", DHCP_EB_FEATURE_SRP, 1 );
54 54
  */
55 55
 #define SRP_MAX_I_T_IU_LEN 80
56 56
 
57
+/* Error numbers generated by SRP login rejection */
58
+#define EINFO_SRP_LOGIN_REJ( reason, desc )				      \
59
+	__einfo_uniqify ( EINFO_EPERM, ( (reason) & 0x0f ), desc )
60
+#define EPERM_UNKNOWN							      \
61
+	__einfo_error ( EINFO_EPERM_UNKNOWN )
62
+#define EINFO_EPERM_UNKNOWN EINFO_SRP_LOGIN_REJ (			      \
63
+	SRP_LOGIN_REJ_REASON_UNKNOWN,					      \
64
+	"Unable to establish RDMA channel, no reason specified" )
65
+#define EPERM_INSUFFICIENT_RESOURCES					      \
66
+	__einfo_error ( EINFO_EPERM_INSUFFICIENT_RESOURCES )
67
+#define EINFO_EPERM_INSUFFICIENT_RESOURCES EINFO_SRP_LOGIN_REJ (	      \
68
+	SRP_LOGIN_REJ_REASON_INSUFFICIENT_RESOURCES,			      \
69
+	"Insufficient RDMA channel resources" )
70
+#define EPERM_BAD_MAX_I_T_IU_LEN					      \
71
+	__einfo_error ( EINFO_EPERM_BAD_MAX_I_T_IU_LEN )
72
+#define EINFO_EPERM_BAD_MAX_I_T_IU_LEN EINFO_SRP_LOGIN_REJ (		      \
73
+	SRP_LOGIN_REJ_REASON_BAD_MAX_I_T_IU_LEN,			      \
74
+	"Requested maximum initiator to target IU length value too large" )
75
+#define EPERM_CANNOT_ASSOCIATE						      \
76
+	__einfo_error ( EINFO_EPERM_CANNOT_ASSOCIATE )
77
+#define EINFO_EPERM_CANNOT_ASSOCIATE EINFO_SRP_LOGIN_REJ (		      \
78
+	SRP_LOGIN_REJ_REASON_CANNOT_ASSOCIATE,				      \
79
+	"Unable to associate RDMA channel with specified I_T nexus" )
80
+#define EPERM_UNSUPPORTED_BUFFER_FORMAT					      \
81
+	__einfo_error ( EINFO_EPERM_UNSUPPORTED_BUFFER_FORMAT )
82
+#define EINFO_EPERM_UNSUPPORTED_BUFFER_FORMAT EINFO_SRP_LOGIN_REJ (	      \
83
+	SRP_LOGIN_REJ_REASON_UNSUPPORTED_BUFFER_FORMAT,			      \
84
+	"One or more requested data buffer descriptor formats not supported" )
85
+#define EPERM_NO_MULTIPLE_CHANNELS					      \
86
+	__einfo_error ( EINFO_EPERM_NO_MULTIPLE_CHANNELS )
87
+#define EINFO_EPERM_NO_MULTIPLE_CHANNELS EINFO_SRP_LOGIN_REJ (		      \
88
+	SRP_LOGIN_REJ_REASON_NO_MULTIPLE_CHANNELS,			      \
89
+	"SRP target does not support multiple RDMA channels per I_T nexus" )
90
+#define EPERM_NO_MORE_CHANNELS						      \
91
+	__einfo_error ( EINFO_EPERM_NO_MORE_CHANNELS )
92
+#define EINFO_EPERM_NO_MORE_CHANNELS EINFO_SRP_LOGIN_REJ (		      \
93
+	SRP_LOGIN_REJ_REASON_NO_MORE_CHANNELS,				      \
94
+	"RDMA channel limit reached for this initiator" )
95
+#define EPERM_LOGIN_REJ( reason_nibble )				      \
96
+	EUNIQ ( EPERM, (reason_nibble), EPERM_UNKNOWN,			      \
97
+		EPERM_INSUFFICIENT_RESOURCES, EPERM_BAD_MAX_I_T_IU_LEN,	      \
98
+		EPERM_CANNOT_ASSOCIATE, EPERM_UNSUPPORTED_BUFFER_FORMAT,      \
99
+		EPERM_NO_MULTIPLE_CHANNELS, EPERM_NO_MORE_CHANNELS )
100
+
57 101
 /** An SRP device */
58 102
 struct srp_device {
59 103
 	/** Reference count */
@@ -330,6 +374,7 @@ static int srp_login_rsp ( struct srp_device *srpdev,
330 374
 static int srp_login_rej ( struct srp_device *srpdev,
331 375
 			   const void *data, size_t len ) {
332 376
 	const struct srp_login_rej *login_rej = data;
377
+	uint32_t reason;
333 378
 
334 379
 	/* Sanity check */
335 380
 	if ( len < sizeof ( *login_rej ) ) {
@@ -337,14 +382,14 @@ static int srp_login_rej ( struct srp_device *srpdev,
337 382
 		       srpdev, len );
338 383
 		return -EINVAL;
339 384
 	}
340
-	DBGC ( srpdev, "SRP %p tag %08x LOGIN_REJ:\n",
341
-	       srpdev, ntohl ( login_rej->tag.dwords[1] ) );
385
+	reason = ntohl ( login_rej->reason );
386
+	DBGC ( srpdev, "SRP %p tag %08x LOGIN_REJ reason %08x:\n",
387
+	       srpdev, ntohl ( login_rej->tag.dwords[1] ), reason );
342 388
 	DBGC_HDA ( srpdev, 0, data, len );
343 389
 
344 390
 	/* Login rejection always indicates an error */
345
-	DBGC ( srpdev, "SRP %p login rejected (reason %08x)\n",
346
-	       srpdev, ntohl ( login_rej->reason ) );
347
-	return -EPERM;
391
+	return ( SRP_LOGIN_REJ_REASON_DEFINED ( reason ) ?
392
+		 -EPERM_LOGIN_REJ ( reason ) : -EACCES );
348 393
 }
349 394
 
350 395
 /**

+ 4
- 0
src/include/ipxe/srp.h View File

@@ -242,6 +242,10 @@ struct srp_login_rej {
242 242
 /** RDMA channel limit reached for this initiator */
243 243
 #define SRP_LOGIN_REJ_REASON_NO_MORE_CHANNELS 0x00010006UL
244 244
 
245
+/** SRP login rejection reason is defined */
246
+#define SRP_LOGIN_REJ_REASON_DEFINED( reason ) \
247
+	( ( (reason) & 0xfffffff0UL ) == 0x00010000UL )
248
+
245 249
 /** Indirect data buffer descriptor format supported */
246 250
 #define SRP_LOGIN_REJ_FMT_IDBD 0x04
247 251
 

Loading…
Cancel
Save