These changes are the raw update to qemu-2.6.
[kvmfornfv.git] / qemu / hw / net / vmxnet_tx_pkt.h
1 /*
2  * QEMU VMWARE VMXNET* paravirtual NICs - TX packets abstraction
3  *
4  * Copyright (c) 2012 Ravello Systems LTD (http://ravellosystems.com)
5  *
6  * Developed by Daynix Computing LTD (http://www.daynix.com)
7  *
8  * Authors:
9  * Dmitry Fleytman <dmitry@daynix.com>
10  * Tamir Shomer <tamirs@daynix.com>
11  * Yan Vugenfirer <yan@daynix.com>
12  *
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.
15  *
16  */
17
18 #ifndef VMXNET_TX_PKT_H
19 #define VMXNET_TX_PKT_H
20
21 #include "net/eth.h"
22 #include "exec/hwaddr.h"
23
24 /* define to enable packet dump functions */
25 /*#define VMXNET_TX_PKT_DEBUG*/
26
27 struct VmxnetTxPkt;
28
29 /**
30  * Init function for tx packet functionality
31  *
32  * @pkt:            packet pointer
33  * @max_frags:      max tx ip fragments
34  * @has_virt_hdr:   device uses virtio header.
35  */
36 void vmxnet_tx_pkt_init(struct VmxnetTxPkt **pkt, uint32_t max_frags,
37     bool has_virt_hdr);
38
39 /**
40  * Clean all tx packet resources.
41  *
42  * @pkt:            packet.
43  */
44 void vmxnet_tx_pkt_uninit(struct VmxnetTxPkt *pkt);
45
46 /**
47  * get virtio header
48  *
49  * @pkt:            packet
50  * @ret:            virtio header
51  */
52 struct virtio_net_hdr *vmxnet_tx_pkt_get_vhdr(struct VmxnetTxPkt *pkt);
53
54 /**
55  * build virtio header (will be stored in module context)
56  *
57  * @pkt:            packet
58  * @tso_enable:     TSO enabled
59  * @csum_enable:    CSO enabled
60  * @gso_size:       MSS size for TSO
61  *
62  */
63 void vmxnet_tx_pkt_build_vheader(struct VmxnetTxPkt *pkt, bool tso_enable,
64     bool csum_enable, uint32_t gso_size);
65
66 /**
67  * updates vlan tag, and adds vlan header in case it is missing
68  *
69  * @pkt:            packet
70  * @vlan:           VLAN tag
71  *
72  */
73 void vmxnet_tx_pkt_setup_vlan_header(struct VmxnetTxPkt *pkt, uint16_t vlan);
74
75 /**
76  * populate data fragment into pkt context.
77  *
78  * @pkt:            packet
79  * @pa:             physical address of fragment
80  * @len:            length of fragment
81  *
82  */
83 bool vmxnet_tx_pkt_add_raw_fragment(struct VmxnetTxPkt *pkt, hwaddr pa,
84     size_t len);
85
86 /**
87  * fix ip header fields and calculate checksums needed.
88  *
89  * @pkt:            packet
90  *
91  */
92 void vmxnet_tx_pkt_update_ip_checksums(struct VmxnetTxPkt *pkt);
93
94 /**
95  * get length of all populated data.
96  *
97  * @pkt:            packet
98  * @ret:            total data length
99  *
100  */
101 size_t vmxnet_tx_pkt_get_total_len(struct VmxnetTxPkt *pkt);
102
103 /**
104  * get packet type
105  *
106  * @pkt:            packet
107  * @ret:            packet type
108  *
109  */
110 eth_pkt_types_e vmxnet_tx_pkt_get_packet_type(struct VmxnetTxPkt *pkt);
111
112 /**
113  * prints packet data if debug is enabled
114  *
115  * @pkt:            packet
116  *
117  */
118 void vmxnet_tx_pkt_dump(struct VmxnetTxPkt *pkt);
119
120 /**
121  * reset tx packet private context (needed to be called between packets)
122  *
123  * @pkt:            packet
124  *
125  */
126 void vmxnet_tx_pkt_reset(struct VmxnetTxPkt *pkt);
127
128 /**
129  * Send packet to qemu. handles sw offloads if vhdr is not supported.
130  *
131  * @pkt:            packet
132  * @nc:             NetClientState
133  * @ret:            operation result
134  *
135  */
136 bool vmxnet_tx_pkt_send(struct VmxnetTxPkt *pkt, NetClientState *nc);
137
138 /**
139  * parse raw packet data and analyze offload requirements.
140  *
141  * @pkt:            packet
142  *
143  */
144 bool vmxnet_tx_pkt_parse(struct VmxnetTxPkt *pkt);
145
146 #endif