vmxnet3: Use common MAC address tracing macros
[qemu.git] / hw / net / net_tx_pkt.h
1 /*
2 * QEMU 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 NET_TX_PKT_H
19 #define NET_TX_PKT_H
20
21 #include "net/eth.h"
22 #include "exec/hwaddr.h"
23
24 /* define to enable packet dump functions */
25 /*#define NET_TX_PKT_DEBUG*/
26
27 struct NetTxPkt;
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 net_tx_pkt_init(struct NetTxPkt **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 net_tx_pkt_uninit(struct NetTxPkt *pkt);
45
46 /**
47 * get virtio header
48 *
49 * @pkt: packet
50 * @ret: virtio header
51 */
52 struct virtio_net_hdr *net_tx_pkt_get_vhdr(struct NetTxPkt *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 net_tx_pkt_build_vheader(struct NetTxPkt *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 net_tx_pkt_setup_vlan_header(struct NetTxPkt *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 net_tx_pkt_add_raw_fragment(struct NetTxPkt *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 net_tx_pkt_update_ip_checksums(struct NetTxPkt *pkt);
93
94 /**
95 * get length of all populated data.
96 *
97 * @pkt: packet
98 * @ret: total data length
99 *
100 */
101 size_t net_tx_pkt_get_total_len(struct NetTxPkt *pkt);
102
103 /**
104 * get packet type
105 *
106 * @pkt: packet
107 * @ret: packet type
108 *
109 */
110 eth_pkt_types_e net_tx_pkt_get_packet_type(struct NetTxPkt *pkt);
111
112 /**
113 * prints packet data if debug is enabled
114 *
115 * @pkt: packet
116 *
117 */
118 void net_tx_pkt_dump(struct NetTxPkt *pkt);
119
120 /**
121 * reset tx packet private context (needed to be called between packets)
122 *
123 * @pkt: packet
124 *
125 */
126 void net_tx_pkt_reset(struct NetTxPkt *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 net_tx_pkt_send(struct NetTxPkt *pkt, NetClientState *nc);
137
138 /**
139 * parse raw packet data and analyze offload requirements.
140 *
141 * @pkt: packet
142 *
143 */
144 bool net_tx_pkt_parse(struct NetTxPkt *pkt);
145
146 #endif