15a207
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
15a207
From: Josef Bacik <jbacik@fb.com>
15a207
Date: Mon, 31 Aug 2015 13:34:35 -0400
15a207
Subject: [PATCH] efinet: retransmit if our device is busy
15a207
15a207
When I fixed the txbuf handling I ripped out the retransmission code since it
15a207
was flooding our network when we had the buggy behavior.  Turns out this was too
15a207
heavy handed as we can still have transient tx timeouts.  So instead make sure
15a207
we retry our transmission once per timeout.  This way we can deal with transient
15a207
transmission problems without flooding the box.  This fixes an issue we were
15a207
seeing in production.  Thanks,
15a207
15a207
Signed-off-by: Josef Bacik <jbacik@fb.com>
15a207
---
15a207
 grub-core/net/drivers/efi/efinet.c | 10 ++++++++++
15a207
 1 file changed, 10 insertions(+)
15a207
15a207
diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c
15a207
index 5388f952ba9..3f112438a93 100644
15a207
--- a/grub-core/net/drivers/efi/efinet.c
15a207
+++ b/grub-core/net/drivers/efi/efinet.c
15a207
@@ -38,6 +38,7 @@ send_card_buffer (struct grub_net_card *dev,
15a207
   grub_efi_simple_network_t *net = dev->efi_net;
15a207
   grub_uint64_t limit_time = grub_get_time_ms () + 4000;
15a207
   void *txbuf;
15a207
+  int retry = 0;
15a207
 
15a207
   if (dev->txbusy)
15a207
     while (1)
15a207
@@ -60,6 +61,15 @@ send_card_buffer (struct grub_net_card *dev,
15a207
 	    dev->txbusy = 0;
15a207
 	    break;
15a207
 	  }
15a207
+	if (!retry)
15a207
+	  {
15a207
+	    st = efi_call_7 (net->transmit, net, 0, dev->last_pkt_size,
15a207
+			     dev->txbuf, NULL, NULL, NULL);
15a207
+	    if (st != GRUB_EFI_SUCCESS)
15a207
+	      return grub_error (GRUB_ERR_IO,
15a207
+				 N_("couldn't send network packet"));
15a207
+	    retry = 1;
15a207
+	  }
15a207
 	if (limit_time < grub_get_time_ms ())
15a207
 	  return grub_error (GRUB_ERR_TIMEOUT,
15a207
 			     N_("couldn't send network packet"));