nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

Blame SOURCES/0183-efinet-retransmit-if-our-device-is-busy.patch

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