block/vpc: update comments to be compliant w/coding guidelines
[qemu.git] / hw / net / vmxnet_tx_pkt.h
blobf51e98ad9526bc045f7f619c3135ba7ce50f5288
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 "net/eth.h"
22 #include "exec/hwaddr.h"
24 /* define to enable packet dump functions */
25 /*#define VMXNET_TX_PKT_DEBUG*/
27 struct VmxnetTxPkt;
29 /**
30 * Init function for tx packet functionality
32 * @pkt: packet pointer
33 * @max_frags: max tx ip fragments
34 * @has_virt_hdr: device uses virtio header.
36 void vmxnet_tx_pkt_init(struct VmxnetTxPkt **pkt, uint32_t max_frags,
37 bool has_virt_hdr);
39 /**
40 * Clean all tx packet resources.
42 * @pkt: packet.
44 void vmxnet_tx_pkt_uninit(struct VmxnetTxPkt *pkt);
46 /**
47 * get virtio header
49 * @pkt: packet
50 * @ret: virtio header
52 struct virtio_net_hdr *vmxnet_tx_pkt_get_vhdr(struct VmxnetTxPkt *pkt);
54 /**
55 * build virtio header (will be stored in module context)
57 * @pkt: packet
58 * @tso_enable: TSO enabled
59 * @csum_enable: CSO enabled
60 * @gso_size: MSS size for TSO
63 void vmxnet_tx_pkt_build_vheader(struct VmxnetTxPkt *pkt, bool tso_enable,
64 bool csum_enable, uint32_t gso_size);
66 /**
67 * updates vlan tag, and adds vlan header in case it is missing
69 * @pkt: packet
70 * @vlan: VLAN tag
73 void vmxnet_tx_pkt_setup_vlan_header(struct VmxnetTxPkt *pkt, uint16_t vlan);
75 /**
76 * populate data fragment into pkt context.
78 * @pkt: packet
79 * @pa: physical address of fragment
80 * @len: length of fragment
83 bool vmxnet_tx_pkt_add_raw_fragment(struct VmxnetTxPkt *pkt, hwaddr pa,
84 size_t len);
86 /**
87 * fix ip header fields and calculate checksums needed.
89 * @pkt: packet
92 void vmxnet_tx_pkt_update_ip_checksums(struct VmxnetTxPkt *pkt);
94 /**
95 * get length of all populated data.
97 * @pkt: packet
98 * @ret: total data length
101 size_t vmxnet_tx_pkt_get_total_len(struct VmxnetTxPkt *pkt);
104 * get packet type
106 * @pkt: packet
107 * @ret: packet type
110 eth_pkt_types_e vmxnet_tx_pkt_get_packet_type(struct VmxnetTxPkt *pkt);
113 * prints packet data if debug is enabled
115 * @pkt: packet
118 void vmxnet_tx_pkt_dump(struct VmxnetTxPkt *pkt);
121 * reset tx packet private context (needed to be called between packets)
123 * @pkt: packet
126 void vmxnet_tx_pkt_reset(struct VmxnetTxPkt *pkt);
129 * Send packet to qemu. handles sw offloads if vhdr is not supported.
131 * @pkt: packet
132 * @nc: NetClientState
133 * @ret: operation result
136 bool vmxnet_tx_pkt_send(struct VmxnetTxPkt *pkt, NetClientState *nc);
139 * parse raw packet data and analyze offload requirements.
141 * @pkt: packet
144 bool vmxnet_tx_pkt_parse(struct VmxnetTxPkt *pkt);
146 #endif