qcow2: Helper for refcount array reallocation
[qemu/ar7.git] / hw / net / vmxnet_tx_pkt.h
blob57121a6fe5e9f39da983c305dc8133f1f715a009
1 /*
2 * QEMU VMWARE VMXNET* paravirtual NICs - TX 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_TX_PKT_H
19 #define VMXNET_TX_PKT_H
21 #include "stdint.h"
22 #include "stdbool.h"
23 #include "net/eth.h"
24 #include "exec/hwaddr.h"
26 /* define to enable packet dump functions */
27 /*#define VMXNET_TX_PKT_DEBUG*/
29 struct VmxnetTxPkt;
31 /**
32 * Init function for tx packet functionality
34 * @pkt: packet pointer
35 * @max_frags: max tx ip fragments
36 * @has_virt_hdr: device uses virtio header.
38 void vmxnet_tx_pkt_init(struct VmxnetTxPkt **pkt, uint32_t max_frags,
39 bool has_virt_hdr);
41 /**
42 * Clean all tx packet resources.
44 * @pkt: packet.
46 void vmxnet_tx_pkt_uninit(struct VmxnetTxPkt *pkt);
48 /**
49 * get virtio header
51 * @pkt: packet
52 * @ret: virtio header
54 struct virtio_net_hdr *vmxnet_tx_pkt_get_vhdr(struct VmxnetTxPkt *pkt);
56 /**
57 * build virtio header (will be stored in module context)
59 * @pkt: packet
60 * @tso_enable: TSO enabled
61 * @csum_enable: CSO enabled
62 * @gso_size: MSS size for TSO
65 void vmxnet_tx_pkt_build_vheader(struct VmxnetTxPkt *pkt, bool tso_enable,
66 bool csum_enable, uint32_t gso_size);
68 /**
69 * updates vlan tag, and adds vlan header in case it is missing
71 * @pkt: packet
72 * @vlan: VLAN tag
75 void vmxnet_tx_pkt_setup_vlan_header(struct VmxnetTxPkt *pkt, uint16_t vlan);
77 /**
78 * populate data fragment into pkt context.
80 * @pkt: packet
81 * @pa: physical address of fragment
82 * @len: length of fragment
85 bool vmxnet_tx_pkt_add_raw_fragment(struct VmxnetTxPkt *pkt, hwaddr pa,
86 size_t len);
88 /**
89 * fix ip header fields and calculate checksums needed.
91 * @pkt: packet
94 void vmxnet_tx_pkt_update_ip_checksums(struct VmxnetTxPkt *pkt);
96 /**
97 * get length of all populated data.
99 * @pkt: packet
100 * @ret: total data length
103 size_t vmxnet_tx_pkt_get_total_len(struct VmxnetTxPkt *pkt);
106 * get packet type
108 * @pkt: packet
109 * @ret: packet type
112 eth_pkt_types_e vmxnet_tx_pkt_get_packet_type(struct VmxnetTxPkt *pkt);
115 * prints packet data if debug is enabled
117 * @pkt: packet
120 void vmxnet_tx_pkt_dump(struct VmxnetTxPkt *pkt);
123 * reset tx packet private context (needed to be called between packets)
125 * @pkt: packet
128 void vmxnet_tx_pkt_reset(struct VmxnetTxPkt *pkt);
131 * Send packet to qemu. handles sw offloads if vhdr is not supported.
133 * @pkt: packet
134 * @nc: NetClientState
135 * @ret: operation result
138 bool vmxnet_tx_pkt_send(struct VmxnetTxPkt *pkt, NetClientState *nc);
141 * parse raw packet data and analyze offload requirements.
143 * @pkt: packet
146 bool vmxnet_tx_pkt_parse(struct VmxnetTxPkt *pkt);
148 #endif