ofnet: implement the receive buffer
authorStanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
Mon, 12 Dec 2016 15:03:39 +0000 (18:03 +0300)
committerDaniel Kiper <daniel.kiper@oracle.com>
Wed, 14 Dec 2016 13:13:34 +0000 (14:13 +0100)
commit130234bc782e1b36a6c55fcac31ff3208cc8807b
tree78bb63800e4a1882feb11ceba0897aa66af2f9e2
parent7b4c54c4ad6a1c92228e1f05047bf820b3a6d36d
ofnet: implement the receive buffer

get_card_packet() from ofnet.c allocates a netbuff based on the device's MTU:

 nb = grub_netbuff_alloc (dev->mtu + 64 + 2);

In the case when the MTU is large, and the received packet is
relatively small, this leads to allocation of significantly more memory,
than it's required. An example could be transmission of TFTP packets
with 0x400 blksize via a network card with 0x10000 MTU.

This patch implements a per-card receive buffer in a way similar to efinet.c,
and makes get_card_packet() allocate a netbuff of the received data size.

Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/net/drivers/ieee1275/ofnet.c