From fcf0cdc362dd96cb8d2935b892d3dd9ab73ad393 Mon Sep 17 00:00:00 2001 From: Shmulik Ladkani Date: Tue, 14 Jul 2015 11:55:15 +0300 Subject: [PATCH] net/vmxnet3: Refactor 'vmxnet_rx_pkt_attach_data' Separate RX packet protocol parsing out of 'vmxnet_rx_pkt_attach_data'. Signed-off-by: Shmulik Ladkani Message-id: 1436864116-19154-2-git-send-email-shmulik.ladkani@ravellosystems.com Signed-off-by: Stefan Hajnoczi --- hw/net/vmxnet3.c | 1 + hw/net/vmxnet_rx_pkt.c | 12 +++++++++--- hw/net/vmxnet_rx_pkt.h | 11 +++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c index 706e0606a9..dd22a0a8cd 100644 --- a/hw/net/vmxnet3.c +++ b/hw/net/vmxnet3.c @@ -1897,6 +1897,7 @@ vmxnet3_receive(NetClientState *nc, const uint8_t *buf, size_t size) get_eth_packet_type(PKT_GET_ETH_HDR(buf))); if (vmxnet3_rx_filter_may_indicate(s, buf, size)) { + vmxnet_rx_pkt_set_protocols(s->rx_pkt, buf, size); vmxnet_rx_pkt_attach_data(s->rx_pkt, buf, size, s->rx_vlan_stripping); bytes_indicated = vmxnet3_indicate_packet(s) ? size : -1; if (bytes_indicated < size) { diff --git a/hw/net/vmxnet_rx_pkt.c b/hw/net/vmxnet_rx_pkt.c index acbca6a3db..aa5462931e 100644 --- a/hw/net/vmxnet_rx_pkt.c +++ b/hw/net/vmxnet_rx_pkt.c @@ -92,9 +92,6 @@ void vmxnet_rx_pkt_attach_data(struct VmxnetRxPkt *pkt, const void *data, } pkt->tci = tci; - - eth_get_protocols(data, len, &pkt->isip4, &pkt->isip6, - &pkt->isudp, &pkt->istcp); } void vmxnet_rx_pkt_dump(struct VmxnetRxPkt *pkt) @@ -131,6 +128,15 @@ size_t vmxnet_rx_pkt_get_total_len(struct VmxnetRxPkt *pkt) return pkt->tot_len; } +void vmxnet_rx_pkt_set_protocols(struct VmxnetRxPkt *pkt, const void *data, + size_t len) +{ + assert(pkt); + + eth_get_protocols(data, len, &pkt->isip4, &pkt->isip6, + &pkt->isudp, &pkt->istcp); +} + void vmxnet_rx_pkt_get_protocols(struct VmxnetRxPkt *pkt, bool *isip4, bool *isip6, bool *isudp, bool *istcp) diff --git a/hw/net/vmxnet_rx_pkt.h b/hw/net/vmxnet_rx_pkt.h index 5f8352a468..a425846b52 100644 --- a/hw/net/vmxnet_rx_pkt.h +++ b/hw/net/vmxnet_rx_pkt.h @@ -54,6 +54,17 @@ void vmxnet_rx_pkt_init(struct VmxnetRxPkt **pkt, bool has_virt_hdr); */ size_t vmxnet_rx_pkt_get_total_len(struct VmxnetRxPkt *pkt); +/** + * parse and set packet analysis results + * + * @pkt: packet + * @data: pointer to the data buffer to be parsed + * @len: data length + * + */ +void vmxnet_rx_pkt_set_protocols(struct VmxnetRxPkt *pkt, const void *data, + size_t len); + /** * fetches packet analysis results *