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