mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 16:23:55 -06:00
net/eth: Introduce EthL4HdrProto
igb, a new network device emulation, will need SCTP checksum offloading. Currently eth_get_protocols() has a bool parameter for each protocol currently it supports, but there will be a bit too many parameters if we add yet another protocol. Introduce an enum type, EthL4HdrProto to represent all L4 protocols eth_get_protocols() support with one parameter. Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> Signed-off-by: Jason Wang <jasowang@redhat.com>
This commit is contained in:
parent
5fb7d14995
commit
65f474bbae
8 changed files with 147 additions and 99 deletions
|
@ -847,7 +847,8 @@ static void vmxnet3_rx_need_csum_calculate(struct NetRxPkt *pkt,
|
|||
size_t pkt_len)
|
||||
{
|
||||
struct virtio_net_hdr *vhdr;
|
||||
bool hasip4, hasip6, hastcp, hasudp;
|
||||
bool hasip4, hasip6;
|
||||
EthL4HdrProto l4hdr_proto;
|
||||
uint8_t *data;
|
||||
int len;
|
||||
|
||||
|
@ -856,8 +857,10 @@ static void vmxnet3_rx_need_csum_calculate(struct NetRxPkt *pkt,
|
|||
return;
|
||||
}
|
||||
|
||||
net_rx_pkt_get_protocols(pkt, &hasip4, &hasip6, &hasudp, &hastcp);
|
||||
if (!(hasip4 || hasip6) || !(hastcp || hasudp)) {
|
||||
net_rx_pkt_get_protocols(pkt, &hasip4, &hasip6, &l4hdr_proto);
|
||||
if (!(hasip4 || hasip6) ||
|
||||
(l4hdr_proto != ETH_L4_HDR_PROTO_TCP &&
|
||||
l4hdr_proto != ETH_L4_HDR_PROTO_UDP)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -885,7 +888,8 @@ static void vmxnet3_rx_update_descr(struct NetRxPkt *pkt,
|
|||
struct Vmxnet3_RxCompDesc *rxcd)
|
||||
{
|
||||
int csum_ok, is_gso;
|
||||
bool hasip4, hasip6, hastcp, hasudp;
|
||||
bool hasip4, hasip6;
|
||||
EthL4HdrProto l4hdr_proto;
|
||||
struct virtio_net_hdr *vhdr;
|
||||
uint8_t offload_type;
|
||||
|
||||
|
@ -911,16 +915,18 @@ static void vmxnet3_rx_update_descr(struct NetRxPkt *pkt,
|
|||
goto nocsum;
|
||||
}
|
||||
|
||||
net_rx_pkt_get_protocols(pkt, &hasip4, &hasip6, &hasudp, &hastcp);
|
||||
if ((!hastcp && !hasudp) || (!hasip4 && !hasip6)) {
|
||||
net_rx_pkt_get_protocols(pkt, &hasip4, &hasip6, &l4hdr_proto);
|
||||
if ((l4hdr_proto != ETH_L4_HDR_PROTO_TCP &&
|
||||
l4hdr_proto != ETH_L4_HDR_PROTO_UDP) ||
|
||||
(!hasip4 && !hasip6)) {
|
||||
goto nocsum;
|
||||
}
|
||||
|
||||
rxcd->cnc = 0;
|
||||
rxcd->v4 = hasip4 ? 1 : 0;
|
||||
rxcd->v6 = hasip6 ? 1 : 0;
|
||||
rxcd->tcp = hastcp ? 1 : 0;
|
||||
rxcd->udp = hasudp ? 1 : 0;
|
||||
rxcd->tcp = l4hdr_proto == ETH_L4_HDR_PROTO_TCP;
|
||||
rxcd->udp = l4hdr_proto == ETH_L4_HDR_PROTO_UDP;
|
||||
rxcd->fcs = rxcd->tuc = rxcd->ipc = 1;
|
||||
return;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue