aboutsummaryrefslogtreecommitdiff
path: root/hw/net/net_tx_pkt.c
diff options
context:
space:
mode:
authorDmitry Fleytman <dmitry.fleytman@ravellosystems.com>2016-06-01 11:23:42 +0300
committerJason Wang <jasowang@redhat.com>2016-06-02 10:42:28 +0800
commit111710107dc6041de871af437214d32d1db088d1 (patch)
tree9d0c78152a21eed1ed26ef566d391cdce4dac2e7 /hw/net/net_tx_pkt.c
parenteb700029c7836798046191d62d595363d92c84d4 (diff)
vmxnet3: Use pci_dma_* API instead of cpu_physical_memory_*
To make this device and network packets abstractions ready for IOMMU. Signed-off-by: Dmitry Fleytman <dmitry.fleytman@ravellosystems.com> Signed-off-by: Leonid Bloch <leonid.bloch@ravellosystems.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Jason Wang <jasowang@redhat.com>
Diffstat (limited to 'hw/net/net_tx_pkt.c')
-rw-r--r--hw/net/net_tx_pkt.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/hw/net/net_tx_pkt.c b/hw/net/net_tx_pkt.c
index a64f51cbef..e4478bead8 100644
--- a/hw/net/net_tx_pkt.c
+++ b/hw/net/net_tx_pkt.c
@@ -20,6 +20,7 @@
#include "net/checksum.h"
#include "net/tap.h"
#include "net/net.h"
+#include "hw/pci/pci.h"
enum {
NET_TX_PKT_VHDR_FRAG = 0,
@@ -30,6 +31,8 @@ enum {
/* TX packet private context */
struct NetTxPkt {
+ PCIDevice *pci_dev;
+
struct virtio_net_hdr virt_hdr;
bool has_virt_hdr;
@@ -54,11 +57,13 @@ struct NetTxPkt {
bool is_loopback;
};
-void net_tx_pkt_init(struct NetTxPkt **pkt, uint32_t max_frags,
- bool has_virt_hdr)
+void net_tx_pkt_init(struct NetTxPkt **pkt, PCIDevice *pci_dev,
+ uint32_t max_frags, bool has_virt_hdr)
{
struct NetTxPkt *p = g_malloc0(sizeof *p);
+ p->pci_dev = pci_dev;
+
p->vec = g_malloc((sizeof *p->vec) *
(max_frags + NET_TX_PKT_PL_START_FRAG));
@@ -383,7 +388,8 @@ bool net_tx_pkt_add_raw_fragment(struct NetTxPkt *pkt, hwaddr pa,
ventry = &pkt->raw[pkt->raw_frags];
mapped_len = len;
- ventry->iov_base = cpu_physical_memory_map(pa, &mapped_len, false);
+ ventry->iov_base = pci_dma_map(pkt->pci_dev, pa,
+ &mapped_len, DMA_DIRECTION_TO_DEVICE);
if ((ventry->iov_base != NULL) && (len == mapped_len)) {
ventry->iov_len = mapped_len;
@@ -444,8 +450,8 @@ void net_tx_pkt_reset(struct NetTxPkt *pkt)
assert(pkt->raw);
for (i = 0; i < pkt->raw_frags; i++) {
assert(pkt->raw[i].iov_base);
- cpu_physical_memory_unmap(pkt->raw[i].iov_base, pkt->raw[i].iov_len,
- false, pkt->raw[i].iov_len);
+ pci_dma_unmap(pkt->pci_dev, pkt->raw[i].iov_base, pkt->raw[i].iov_len,
+ DMA_DIRECTION_TO_DEVICE, 0);
}
pkt->raw_frags = 0;