vmxnet3: Use common MAC address tracing macros
[qemu.git] / hw / net / vmxnet_rx_pkt.h
blob0a45c1ba009f6f2e499787fbf24d1d8be33862b5
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 "net/eth.h"
23 /* defines to enable packet dump functions */
24 /*#define VMXNET_RX_PKT_DEBUG*/
26 struct VmxnetRxPkt;
28 /**
29 * Clean all rx packet resources
31 * @pkt: packet
34 void vmxnet_rx_pkt_uninit(struct VmxnetRxPkt *pkt);
36 /**
37 * Init function for rx packet functionality
39 * @pkt: packet pointer
40 * @has_virt_hdr: device uses virtio header
43 void vmxnet_rx_pkt_init(struct VmxnetRxPkt **pkt, bool has_virt_hdr);
45 /**
46 * returns total length of data attached to rx context
48 * @pkt: packet
50 * Return: nothing
53 size_t vmxnet_rx_pkt_get_total_len(struct VmxnetRxPkt *pkt);
55 /**
56 * parse and set packet analysis results
58 * @pkt: packet
59 * @data: pointer to the data buffer to be parsed
60 * @len: data length
63 void vmxnet_rx_pkt_set_protocols(struct VmxnetRxPkt *pkt, const void *data,
64 size_t len);
66 /**
67 * fetches packet analysis results
69 * @pkt: packet
70 * @isip4: whether the packet given is IPv4
71 * @isip6: whether the packet given is IPv6
72 * @isudp: whether the packet given is UDP
73 * @istcp: whether the packet given is TCP
76 void vmxnet_rx_pkt_get_protocols(struct VmxnetRxPkt *pkt,
77 bool *isip4, bool *isip6,
78 bool *isudp, bool *istcp);
80 /**
81 * returns virtio header stored in rx context
83 * @pkt: packet
84 * @ret: virtio header
87 struct virtio_net_hdr *vmxnet_rx_pkt_get_vhdr(struct VmxnetRxPkt *pkt);
89 /**
90 * returns packet type
92 * @pkt: packet
93 * @ret: packet type
96 eth_pkt_types_e vmxnet_rx_pkt_get_packet_type(struct VmxnetRxPkt *pkt);
98 /**
99 * returns vlan tag
101 * @pkt: packet
102 * @ret: VLAN tag
105 uint16_t vmxnet_rx_pkt_get_vlan_tag(struct VmxnetRxPkt *pkt);
108 * tells whether vlan was stripped from the packet
110 * @pkt: packet
111 * @ret: VLAN stripped sign
114 bool vmxnet_rx_pkt_is_vlan_stripped(struct VmxnetRxPkt *pkt);
117 * notifies caller if the packet has virtio header
119 * @pkt: packet
120 * @ret: true if packet has virtio header, false otherwize
123 bool vmxnet_rx_pkt_has_virt_hdr(struct VmxnetRxPkt *pkt);
126 * attach data to rx packet
128 * @pkt: packet
129 * @data: pointer to the data buffer
130 * @len: data length
131 * @strip_vlan: should the module strip vlan from data
134 void vmxnet_rx_pkt_attach_data(struct VmxnetRxPkt *pkt, const void *data,
135 size_t len, bool strip_vlan);
138 * returns io vector that holds the attached data
140 * @pkt: packet
141 * @ret: pointer to IOVec
144 struct iovec *vmxnet_rx_pkt_get_iovec(struct VmxnetRxPkt *pkt);
147 * prints rx packet data if debug is enabled
149 * @pkt: packet
152 void vmxnet_rx_pkt_dump(struct VmxnetRxPkt *pkt);
155 * copy passed vhdr data to packet context
157 * @pkt: packet
158 * @vhdr: VHDR buffer
161 void vmxnet_rx_pkt_set_vhdr(struct VmxnetRxPkt *pkt,
162 struct virtio_net_hdr *vhdr);
165 * save packet type in packet context
167 * @pkt: packet
168 * @packet_type: the packet type
171 void vmxnet_rx_pkt_set_packet_type(struct VmxnetRxPkt *pkt,
172 eth_pkt_types_e packet_type);
174 #endif