a5bd9f6
From a9a4ba2857cae31eac34febe2d08e9d6849b119e Mon Sep 17 00:00:00 2001
a5bd9f6
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
a5bd9f6
Date: Sun, 17 Mar 2013 13:33:16 +0100
a5bd9f6
Subject: [PATCH 209/364] 	Resend a packet if we got the wrong buffer in
a5bd9f6
 status.
a5bd9f6
a5bd9f6
---
a5bd9f6
 ChangeLog                          |  4 ++++
a5bd9f6
 grub-core/net/drivers/efi/efinet.c | 22 +++++++++++++++-------
a5bd9f6
 include/grub/net.h                 |  1 +
a5bd9f6
 3 files changed, 20 insertions(+), 7 deletions(-)
a5bd9f6
a5bd9f6
diff --git a/ChangeLog b/ChangeLog
a5bd9f6
index 4f5a281..ad84d27 100644
a5bd9f6
--- a/ChangeLog
a5bd9f6
+++ b/ChangeLog
a5bd9f6
@@ -1,3 +1,7 @@
a5bd9f6
+2013-03-17  Vladimir Serbinenko  <phcoder@gmail.com>
a5bd9f6
+
a5bd9f6
+	Resend a packet if we got the wrong buffer in status.
a5bd9f6
+
a5bd9f6
 2013-03-10  Vladimir Serbinenko  <phcoder@gmail.com>
a5bd9f6
 
a5bd9f6
 	* grub-core/loader/i386/bsdXX.c (grub_openbsd_find_ramdisk): Use
a5bd9f6
diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c
a5bd9f6
index 28f2db2..2b344d6 100644
a5bd9f6
--- a/grub-core/net/drivers/efi/efinet.c
a5bd9f6
+++ b/grub-core/net/drivers/efi/efinet.c
a5bd9f6
@@ -37,7 +37,6 @@ send_card_buffer (struct grub_net_card *dev,
a5bd9f6
   grub_efi_status_t st;
a5bd9f6
   grub_efi_simple_network_t *net = dev->efi_net;
a5bd9f6
   grub_uint64_t limit_time = grub_get_time_ms () + 4000;
a5bd9f6
-  grub_size_t len;
a5bd9f6
 
a5bd9f6
   if (dev->txbusy)
a5bd9f6
     while (1)
a5bd9f6
@@ -52,17 +51,26 @@ send_card_buffer (struct grub_net_card *dev,
a5bd9f6
 	    dev->txbusy = 0;
a5bd9f6
 	    break;
a5bd9f6
 	  }
a5bd9f6
+	if (txbuf)
a5bd9f6
+	  {
a5bd9f6
+	    st = efi_call_7 (net->transmit, net, 0, dev->last_pkt_size,
a5bd9f6
+			     dev->txbuf, NULL, NULL, NULL);
a5bd9f6
+	    if (st != GRUB_EFI_SUCCESS)
a5bd9f6
+	      return grub_error (GRUB_ERR_IO,
a5bd9f6
+				 N_("couldn't send network packet"));
a5bd9f6
+	  }
a5bd9f6
 	if (limit_time < grub_get_time_ms ())
a5bd9f6
-	  return grub_error (GRUB_ERR_TIMEOUT, N_("couldn't send network packet"));
a5bd9f6
+	  return grub_error (GRUB_ERR_TIMEOUT,
a5bd9f6
+			     N_("couldn't send network packet"));
a5bd9f6
       }
a5bd9f6
 
a5bd9f6
-  len = (pack->tail - pack->data);
a5bd9f6
-  if (len > dev->mtu)
a5bd9f6
-    len = dev->mtu;
a5bd9f6
+  dev->last_pkt_size = (pack->tail - pack->data);
a5bd9f6
+  if (dev->last_pkt_size > dev->mtu)
a5bd9f6
+    dev->last_pkt_size = dev->mtu;
a5bd9f6
 
a5bd9f6
-  grub_memcpy (dev->txbuf, pack->data, len);
a5bd9f6
+  grub_memcpy (dev->txbuf, pack->data, dev->last_pkt_size);
a5bd9f6
 
a5bd9f6
-  st = efi_call_7 (net->transmit, net, 0, len,
a5bd9f6
+  st = efi_call_7 (net->transmit, net, 0, dev->last_pkt_size,
a5bd9f6
 		   dev->txbuf, NULL, NULL, NULL);
a5bd9f6
   if (st != GRUB_EFI_SUCCESS)
a5bd9f6
     return grub_error (GRUB_ERR_IO, N_("couldn't send network packet"));
a5bd9f6
diff --git a/include/grub/net.h b/include/grub/net.h
a5bd9f6
index 3877451..1bd7af2 100644
a5bd9f6
--- a/include/grub/net.h
a5bd9f6
+++ b/include/grub/net.h
a5bd9f6
@@ -139,6 +139,7 @@ struct grub_net_card
a5bd9f6
     {
a5bd9f6
       struct grub_efi_simple_network *efi_net;
a5bd9f6
       grub_efi_handle_t efi_handle;
a5bd9f6
+      grub_size_t last_pkt_size;
a5bd9f6
     };
a5bd9f6
 #endif
a5bd9f6
     void *data;
a5bd9f6
-- 
a5bd9f6
1.8.1.4
a5bd9f6