add mtu information

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2011-07-08 18:49:35 +02:00
parent 5438143da6
commit 6a1af81a97
5 changed files with 31 additions and 8 deletions

View file

@ -136,6 +136,7 @@ grub_efinet_findcards (void)
card->driver = &efidriver; card->driver = &efidriver;
card->flags = 0; card->flags = 0;
card->default_address.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET; card->default_address.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET;
card->mtu = net->mode->max_packet_size;
grub_memcpy (card->default_address.mac, grub_memcpy (card->default_address.mac,
net->mode->current_address, net->mode->current_address,
sizeof (card->default_address.mac)); sizeof (card->default_address.mac));

View file

@ -1,3 +1,20 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2010,2011 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <grub/dl.h> #include <grub/dl.h>
#include <grub/net/netbuff.h> #include <grub/net/netbuff.h>
@ -52,6 +69,7 @@ static struct grub_net_card emucard =
{ {
.name = "emu0", .name = "emu0",
.driver = &emudriver, .driver = &emudriver,
.mtu = 1500,
.default_address = { .default_address = {
.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET, .type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET,
{.mac = {0, 1, 2, 3, 4, 5}} {.mac = {0, 1, 2, 3, 4, 5}}

View file

@ -345,6 +345,7 @@ GRUB_MOD_INIT(pxe)
if (i == sizeof (grub_pxe_card.default_address.mac)) if (i == sizeof (grub_pxe_card.default_address.mac))
grub_memcpy (grub_pxe_card.default_address.mac, ui->permanent_addr, grub_memcpy (grub_pxe_card.default_address.mac, ui->permanent_addr,
sizeof (grub_pxe_card.default_address.mac)); sizeof (grub_pxe_card.default_address.mac));
grub_pxe_card.mtu = ui->mtu;
grub_pxe_card.default_address.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET; grub_pxe_card.default_address.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET;

View file

@ -28,7 +28,6 @@ struct grub_ofnetcard_data
{ {
char *path; char *path;
grub_ieee1275_ihandle_t handle; grub_ieee1275_ihandle_t handle;
grub_uint32_t mtu;
}; };
static grub_err_t static grub_err_t
@ -85,7 +84,7 @@ get_card_packet (const struct grub_net_card *dev, struct grub_net_buff *nb)
grub_netbuff_clear (nb); grub_netbuff_clear (nb);
start_time = grub_get_time_ms (); start_time = grub_get_time_ms ();
do do
rc = grub_ieee1275_read (data->handle, nb->data, data->mtu, &actual); rc = grub_ieee1275_read (data->handle, nb->data, dev->mtu, &actual);
while ((actual <= 0 || rc < 0) && (grub_get_time_ms () - start_time < 200)); while ((actual <= 0 || rc < 0) && (grub_get_time_ms () - start_time < 200));
if (actual) if (actual)
{ {
@ -228,12 +227,15 @@ grub_ofnet_findcards (void)
grub_ieee1275_finddevice (ofdata->path, &devhandle); grub_ieee1275_finddevice (ofdata->path, &devhandle);
if (grub_ieee1275_get_integer_property {
(devhandle, "max-frame-size", &(ofdata->mtu), grub_uint32_t t;
sizeof (ofdata->mtu), 0)) if (grub_ieee1275_get_integer_property (devhandle,
{ "max-frame-size", &t,
ofdata->mtu = 1500; sizeof (t), 0))
} card->mtu = 1500;
else
card->mtu = t;
}
if (grub_ieee1275_get_property (devhandle, "mac-address", if (grub_ieee1275_get_property (devhandle, "mac-address",
&(lla.mac), 6, 0) &(lla.mac), 6, 0)

View file

@ -97,6 +97,7 @@ struct grub_net_card
int opened; int opened;
unsigned idle_poll_delay_ms; unsigned idle_poll_delay_ms;
grub_uint64_t last_poll; grub_uint64_t last_poll;
grub_size_t mtu;
union union
{ {
#ifdef GRUB_MACHINE_EFI #ifdef GRUB_MACHINE_EFI