|
@@ -194,16 +194,17 @@ int netdev_tx ( struct net_device *netdev, struct io_buffer *iobuf ) {
|
194
|
194
|
}
|
195
|
195
|
|
196
|
196
|
/**
|
197
|
|
- * Complete network transmission
|
|
197
|
+ * Discard transmitted packet
|
198
|
198
|
*
|
199
|
199
|
* @v netdev Network device
|
200
|
|
- * @v iobuf I/O buffer
|
|
200
|
+ * @v iobuf I/O buffer, or NULL
|
201
|
201
|
* @v rc Packet status code
|
202
|
202
|
*
|
203
|
|
- * The packet must currently be in the network device's TX queue.
|
|
203
|
+ * The packet is discarded and a TX error is recorded. This function
|
|
204
|
+ * takes ownership of the I/O buffer.
|
204
|
205
|
*/
|
205
|
|
-void netdev_tx_complete_err ( struct net_device *netdev,
|
206
|
|
- struct io_buffer *iobuf, int rc ) {
|
|
206
|
+void netdev_tx_err ( struct net_device *netdev,
|
|
207
|
+ struct io_buffer *iobuf, int rc ) {
|
207
|
208
|
|
208
|
209
|
/* Update statistics counter */
|
209
|
210
|
netdev_record_stat ( &netdev->tx_stats, rc );
|
|
@@ -215,12 +216,28 @@ void netdev_tx_complete_err ( struct net_device *netdev,
|
215
|
216
|
netdev->name, iobuf, strerror ( rc ) );
|
216
|
217
|
}
|
217
|
218
|
|
|
219
|
+ /* Discard packet */
|
|
220
|
+ free_iob ( iobuf );
|
|
221
|
+}
|
|
222
|
+
|
|
223
|
+/**
|
|
224
|
+ * Complete network transmission
|
|
225
|
+ *
|
|
226
|
+ * @v netdev Network device
|
|
227
|
+ * @v iobuf I/O buffer
|
|
228
|
+ * @v rc Packet status code
|
|
229
|
+ *
|
|
230
|
+ * The packet must currently be in the network device's TX queue.
|
|
231
|
+ */
|
|
232
|
+void netdev_tx_complete_err ( struct net_device *netdev,
|
|
233
|
+ struct io_buffer *iobuf, int rc ) {
|
|
234
|
+
|
218
|
235
|
/* Catch data corruption as early as possible */
|
219
|
236
|
list_check_contains ( iobuf, &netdev->tx_queue, list );
|
220
|
237
|
|
221
|
238
|
/* Dequeue and free I/O buffer */
|
222
|
239
|
list_del ( &iobuf->list );
|
223
|
|
- free_iob ( iobuf );
|
|
240
|
+ netdev_tx_err ( netdev, iobuf, rc );
|
224
|
241
|
}
|
225
|
242
|
|
226
|
243
|
/**
|
|
@@ -644,7 +661,8 @@ int net_tx ( struct io_buffer *iobuf, struct net_device *netdev,
|
644
|
661
|
/* Add link-layer header */
|
645
|
662
|
if ( ( rc = ll_protocol->push ( netdev, iobuf, ll_dest, ll_source,
|
646
|
663
|
net_protocol->net_proto ) ) != 0 ) {
|
647
|
|
- free_iob ( iobuf );
|
|
664
|
+ /* Record error for diagnosis */
|
|
665
|
+ netdev_tx_err ( netdev, iobuf, rc );
|
648
|
666
|
return rc;
|
649
|
667
|
}
|
650
|
668
|
|