Browse Source

[fcoe] Disambiguate the various error cases and add a CRC failure message

It seems as though several drivers neglect to strip the Ethernet CRC,
which will cause the FCoE footer to be misplaced and result
(coincidentally) in an "invalid CRC" error from FCoE.

Add a human-visible message indicating this, to aid in diagnosis.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 14 years ago
parent
commit
6574c55e27
1 changed files with 29 additions and 4 deletions
  1. 29
    4
      src/net/fcoe.c

+ 29
- 4
src/net/fcoe.c View File

29
 #include <ipxe/xfer.h>
29
 #include <ipxe/xfer.h>
30
 #include <ipxe/netdevice.h>
30
 #include <ipxe/netdevice.h>
31
 #include <ipxe/features.h>
31
 #include <ipxe/features.h>
32
+#include <ipxe/errortab.h>
32
 #include <ipxe/crc32.h>
33
 #include <ipxe/crc32.h>
33
 #include <ipxe/fc.h>
34
 #include <ipxe/fc.h>
34
 #include <ipxe/fcoe.h>
35
 #include <ipxe/fcoe.h>
41
 
42
 
42
 FEATURE ( FEATURE_PROTOCOL, "FCoE", DHCP_EB_FEATURE_FCOE, 1 );
43
 FEATURE ( FEATURE_PROTOCOL, "FCoE", DHCP_EB_FEATURE_FCOE, 1 );
43
 
44
 
45
+/* Disambiguate the various error causes */
46
+#define EINVAL_UNDERLENGTH __einfo_error ( EINFO_EINVAL_UNDERLENGTH )
47
+#define EINFO_EINVAL_UNDERLENGTH \
48
+	__einfo_uniqify ( EINFO_EINVAL, 0x01, "Underlength packet" )
49
+#define EINVAL_SOF __einfo_error ( EINFO_EINVAL_SOF )
50
+#define EINFO_EINVAL_SOF \
51
+	__einfo_uniqify ( EINFO_EINVAL, 0x02, "Invalid SoF delimiter" )
52
+#define EINVAL_CRC __einfo_error ( EINFO_EINVAL_CRC )
53
+#define EINFO_EINVAL_CRC \
54
+	__einfo_uniqify ( EINFO_EINVAL, 0x03, "Invalid CRC (not stripped?)" )
55
+#define EINVAL_EOF __einfo_error ( EINFO_EINVAL_EOF )
56
+#define EINFO_EINVAL_EOF \
57
+	__einfo_uniqify ( EINFO_EINVAL, 0x04, "Invalid EoF delimiter" )
58
+
44
 /** An FCoE port */
59
 /** An FCoE port */
45
 struct fcoe_port {
60
 struct fcoe_port {
46
 	/** Reference count */
61
 	/** Reference count */
171
 	if ( iob_len ( iobuf ) < ( sizeof ( *fcoehdr ) + sizeof ( *fcoeftr ) )){
186
 	if ( iob_len ( iobuf ) < ( sizeof ( *fcoehdr ) + sizeof ( *fcoeftr ) )){
172
 		DBGC ( fcoe, "FCoE %s received under-length frame (%zd "
187
 		DBGC ( fcoe, "FCoE %s received under-length frame (%zd "
173
 		       "bytes)\n", fcoe->netdev->name, iob_len ( iobuf ) );
188
 		       "bytes)\n", fcoe->netdev->name, iob_len ( iobuf ) );
174
-		rc = -EINVAL;
189
+		rc = -EINVAL_UNDERLENGTH;
175
 		goto done;
190
 		goto done;
176
 	}
191
 	}
177
 
192
 
192
 		 ( fcoehdr->sof == FCOE_SOF_N3 ) ) ) {
207
 		 ( fcoehdr->sof == FCOE_SOF_N3 ) ) ) {
193
 		DBGC ( fcoe, "FCoE %s received unsupported start-of-frame "
208
 		DBGC ( fcoe, "FCoE %s received unsupported start-of-frame "
194
 		       "delimiter %02x\n", fcoe->netdev->name, fcoehdr->sof );
209
 		       "delimiter %02x\n", fcoe->netdev->name, fcoehdr->sof );
195
-		rc = -EINVAL;
210
+		rc = -EINVAL_SOF;
196
 		goto done;
211
 		goto done;
197
 	}
212
 	}
198
 	if ( ( le32_to_cpu ( fcoeftr->crc ) ^ ~((uint32_t)0) ) !=
213
 	if ( ( le32_to_cpu ( fcoeftr->crc ) ^ ~((uint32_t)0) ) !=
199
 	     crc32_le ( ~((uint32_t)0), iobuf->data, iob_len ( iobuf ) ) ) {
214
 	     crc32_le ( ~((uint32_t)0), iobuf->data, iob_len ( iobuf ) ) ) {
200
 		DBGC ( fcoe, "FCoE %s received invalid CRC\n",
215
 		DBGC ( fcoe, "FCoE %s received invalid CRC\n",
201
 		       fcoe->netdev->name );
216
 		       fcoe->netdev->name );
202
-		rc = -EINVAL;
217
+		rc = -EINVAL_CRC;
203
 		goto done;
218
 		goto done;
204
 	}
219
 	}
205
 	if ( ! ( ( fcoeftr->eof == FCOE_EOF_N ) ||
220
 	if ( ! ( ( fcoeftr->eof == FCOE_EOF_N ) ||
206
 		 ( fcoeftr->eof == FCOE_EOF_T ) ) ) {
221
 		 ( fcoeftr->eof == FCOE_EOF_T ) ) ) {
207
 		DBGC ( fcoe, "FCoE %s received unsupported end-of-frame "
222
 		DBGC ( fcoe, "FCoE %s received unsupported end-of-frame "
208
 		       "delimiter %02x\n", fcoe->netdev->name, fcoeftr->eof );
223
 		       "delimiter %02x\n", fcoe->netdev->name, fcoeftr->eof );
209
-		rc = -EINVAL;
224
+		rc = -EINVAL_EOF;
210
 		goto done;
225
 		goto done;
211
 	}
226
 	}
212
 
227
 
381
 	.net_proto = htons ( ETH_P_FCOE ),
396
 	.net_proto = htons ( ETH_P_FCOE ),
382
 	.rx = fcoe_rx,
397
 	.rx = fcoe_rx,
383
 };
398
 };
399
+
400
+/** Human-readable message for CRC errors
401
+ *
402
+ * It seems as though several drivers neglect to strip the Ethernet
403
+ * CRC, which will cause the FCoE footer to be misplaced and result
404
+ * (coincidentally) in an "invalid CRC" error from FCoE.
405
+ */
406
+struct errortab fcoe_errors[] __errortab = {
407
+	__einfo_errortab ( EINFO_EINVAL_CRC ),
408
+};

Loading…
Cancel
Save