virtio: combine the read of a descriptor
[qemu.git] / hw / net / vmxnet_rx_pkt.h
bloba425846b52e4a4ed100bbe602258f5d0380d475d
1 /*
2 * QEMU VMWARE VMXNET* paravirtual NICs - RX packets abstraction
4 * Copyright (c) 2012 Ravello Systems LTD (http://ravellosystems.com)
6 * Developed by Daynix Computing LTD (http://www.daynix.com)
8 * Authors:
9 * Dmitry Fleytman <dmitry@daynix.com>
10 * Tamir Shomer <tamirs@daynix.com>
11 * Yan Vugenfirer <yan@daynix.com>
13 * This work is licensed under the terms of the GNU GPL, version 2 or later.
14 * See the COPYING file in the top-level directory.
18 #ifndef VMXNET_RX_PKT_H
19 #define VMXNET_RX_PKT_H
21 #include "stdint.h"
22 #include "stdbool.h"
23 #include "net/eth.h"
25 /* defines to enable packet dump functions */
26 /*#define VMXNET_RX_PKT_DEBUG*/
28 struct VmxnetRxPkt;
30 /**
31 * Clean all rx packet resources
33 * @pkt: packet
36 void vmxnet_rx_pkt_uninit(struct VmxnetRxPkt *pkt);
38 /**
39 * Init function for rx packet functionality
41 * @pkt: packet pointer
42 * @has_virt_hdr: device uses virtio header
45 void vmxnet_rx_pkt_init(struct VmxnetRxPkt **pkt, bool has_virt_hdr);
47 /**
48 * returns total length of data attached to rx context
50 * @pkt: packet
52 * Return: nothing
55 size_t vmxnet_rx_pkt_get_total_len(struct VmxnetRxPkt *pkt);
57 /**
58 * parse and set packet analysis results
60 * @pkt: packet
61 * @data: pointer to the data buffer to be parsed
62 * @len: data length
65 void vmxnet_rx_pkt_set_protocols(struct VmxnetRxPkt *pkt, const void *data,
66 size_t len);
68 /**
69 * fetches packet analysis results
71 * @pkt: packet
72 * @isip4: whether the packet given is IPv4
73 * @isip6: whether the packet given is IPv6
74 * @isudp: whether the packet given is UDP
75 * @istcp: whether the packet given is TCP
78 void vmxnet_rx_pkt_get_protocols(struct VmxnetRxPkt *pkt,
79 bool *isip4, bool *isip6,
80 bool *isudp, bool *istcp);
82 /**
83 * returns virtio header stored in rx context
85 * @pkt: packet
86 * @ret: virtio header
89 struct virtio_net_hdr *vmxnet_rx_pkt_get_vhdr(struct VmxnetRxPkt *pkt);
91 /**
92 * returns packet type
94 * @pkt: packet
95 * @ret: packet type
98 eth_pkt_types_e vmxnet_rx_pkt_get_packet_type(struct VmxnetRxPkt *pkt);
101 * returns vlan tag
103 * @pkt: packet
104 * @ret: VLAN tag
107 uint16_t vmxnet_rx_pkt_get_vlan_tag(struct VmxnetRxPkt *pkt);
110 * tells whether vlan was stripped from the packet
112 * @pkt: packet
113 * @ret: VLAN stripped sign
116 bool vmxnet_rx_pkt_is_vlan_stripped(struct VmxnetRxPkt *pkt);
119 * notifies caller if the packet has virtio header
121 * @pkt: packet
122 * @ret: true if packet has virtio header, false otherwize
125 bool vmxnet_rx_pkt_has_virt_hdr(struct VmxnetRxPkt *pkt);
128 * attach data to rx packet
130 * @pkt: packet
131 * @data: pointer to the data buffer
132 * @len: data length
133 * @strip_vlan: should the module strip vlan from data
136 void vmxnet_rx_pkt_attach_data(struct VmxnetRxPkt *pkt, const void *data,
137 size_t len, bool strip_vlan);
140 * returns io vector that holds the attached data
142 * @pkt: packet
143 * @ret: pointer to IOVec
146 struct iovec *vmxnet_rx_pkt_get_iovec(struct VmxnetRxPkt *pkt);
149 * prints rx packet data if debug is enabled
151 * @pkt: packet
154 void vmxnet_rx_pkt_dump(struct VmxnetRxPkt *pkt);
157 * copy passed vhdr data to packet context
159 * @pkt: packet
160 * @vhdr: VHDR buffer
163 void vmxnet_rx_pkt_set_vhdr(struct VmxnetRxPkt *pkt,
164 struct virtio_net_hdr *vhdr);
167 * save packet type in packet context
169 * @pkt: packet
170 * @packet_type: the packet type
173 void vmxnet_rx_pkt_set_packet_type(struct VmxnetRxPkt *pkt,
174 eth_pkt_types_e packet_type);
176 #endif