Resend a packet if we got the wrong buffer in status.

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2013-03-17 13:33:16 +01:00
parent 46ecfc49b6
commit 2f1071d57e
3 changed files with 20 additions and 7 deletions

View file

@ -1,3 +1,7 @@
2013-03-17 Vladimir Serbinenko <phcoder@gmail.com>
Resend a packet if we got the wrong buffer in status.
2013-03-10 Vladimir Serbinenko <phcoder@gmail.com> 2013-03-10 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/loader/i386/bsdXX.c (grub_openbsd_find_ramdisk): Use * grub-core/loader/i386/bsdXX.c (grub_openbsd_find_ramdisk): Use

View file

@ -37,7 +37,6 @@ send_card_buffer (struct grub_net_card *dev,
grub_efi_status_t st; grub_efi_status_t st;
grub_efi_simple_network_t *net = dev->efi_net; grub_efi_simple_network_t *net = dev->efi_net;
grub_uint64_t limit_time = grub_get_time_ms () + 4000; grub_uint64_t limit_time = grub_get_time_ms () + 4000;
grub_size_t len;
if (dev->txbusy) if (dev->txbusy)
while (1) while (1)
@ -52,17 +51,26 @@ send_card_buffer (struct grub_net_card *dev,
dev->txbusy = 0; dev->txbusy = 0;
break; 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 ()) 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); dev->last_pkt_size = (pack->tail - pack->data);
if (len > dev->mtu) if (dev->last_pkt_size > dev->mtu)
len = 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); dev->txbuf, NULL, NULL, NULL);
if (st != GRUB_EFI_SUCCESS) if (st != GRUB_EFI_SUCCESS)
return grub_error (GRUB_ERR_IO, N_("couldn't send network packet")); return grub_error (GRUB_ERR_IO, N_("couldn't send network packet"));

View file

@ -139,6 +139,7 @@ struct grub_net_card
{ {
struct grub_efi_simple_network *efi_net; struct grub_efi_simple_network *efi_net;
grub_efi_handle_t efi_handle; grub_efi_handle_t efi_handle;
grub_size_t last_pkt_size;
}; };
#endif #endif
void *data; void *data;