net/virtio-user: add new virtual PCI driver
[dpdk.git] / drivers / net / virtio / virtio_pci.h
index fcac660..dd7693f 100644 (file)
 
 #include <stdint.h>
 
-#ifdef __FreeBSD__
-#include <sys/types.h>
-#include <machine/cpufunc.h>
-#else
-#include <sys/io.h>
-#endif
-
+#include <rte_pci.h>
 #include <rte_ethdev.h>
 
 struct virtqueue;
+struct virtnet_ctl;
 
 /* VirtIO PCI vendor/device ID. */
 #define VIRTIO_PCI_VENDORID     0x1AF4
@@ -240,7 +235,7 @@ struct virtio_pci_ops {
        uint16_t (*set_config_irq)(struct virtio_hw *hw, uint16_t vec);
 
        uint16_t (*get_queue_num)(struct virtio_hw *hw, uint16_t queue_id);
-       void (*setup_queue)(struct virtio_hw *hw, struct virtqueue *vq);
+       int (*setup_queue)(struct virtio_hw *hw, struct virtqueue *vq);
        void (*del_queue)(struct virtio_hw *hw, struct virtqueue *vq);
        void (*notify_queue)(struct virtio_hw *hw, struct virtqueue *vq);
 };
@@ -248,8 +243,8 @@ struct virtio_pci_ops {
 struct virtio_net_config;
 
 struct virtio_hw {
-       struct virtqueue *cvq;
-       uint32_t    io_base;
+       struct virtnet_ctl *cvq;
+       struct rte_pci_ioport io;
        uint64_t    guest_features;
        uint32_t    max_tx_queues;
        uint32_t    max_rx_queues;
@@ -266,6 +261,7 @@ struct virtio_hw {
        struct virtio_pci_common_cfg *common_cfg;
        struct virtio_net_config *dev_cfg;
        const struct virtio_pci_ops *vtpci_ops;
+       void        *virtio_user_dev;
 };
 
 /*
@@ -281,12 +277,6 @@ struct virtio_net_config {
        uint16_t   max_virtqueue_pairs;
 } __attribute__((packed));
 
-/*
- * The remaining space is defined by each driver as the per-driver
- * configuration space.
- */
-#define VIRTIO_PCI_CONFIG(hw) (((hw)->use_msix) ? 24 : 20)
-
 /*
  * How many bits to shift physical queue address written to QUEUE_PFN.
  * 12 is historical, and due to x86 page size.
@@ -296,46 +286,6 @@ struct virtio_net_config {
 /* The alignment to use between consumer and producer parts of vring. */
 #define VIRTIO_PCI_VRING_ALIGN 4096
 
-#ifdef __FreeBSD__
-
-static inline void
-outb_p(unsigned char data, unsigned int port)
-{
-
-       outb(port, (u_char)data);
-}
-
-static inline void
-outw_p(unsigned short data, unsigned int port)
-{
-       outw(port, (u_short)data);
-}
-
-static inline void
-outl_p(unsigned int data, unsigned int port)
-{
-       outl(port, (u_int)data);
-}
-#endif
-
-#define VIRTIO_PCI_REG_ADDR(hw, reg) \
-       (unsigned short)((hw)->io_base + (reg))
-
-#define VIRTIO_READ_REG_1(hw, reg) \
-       inb((VIRTIO_PCI_REG_ADDR((hw), (reg))))
-#define VIRTIO_WRITE_REG_1(hw, reg, value) \
-       outb_p((unsigned char)(value), (VIRTIO_PCI_REG_ADDR((hw), (reg))))
-
-#define VIRTIO_READ_REG_2(hw, reg) \
-       inw((VIRTIO_PCI_REG_ADDR((hw), (reg))))
-#define VIRTIO_WRITE_REG_2(hw, reg, value) \
-       outw_p((unsigned short)(value), (VIRTIO_PCI_REG_ADDR((hw), (reg))))
-
-#define VIRTIO_READ_REG_4(hw, reg) \
-       inl((VIRTIO_PCI_REG_ADDR((hw), (reg))))
-#define VIRTIO_WRITE_REG_4(hw, reg, value) \
-       outl_p((unsigned int)(value), (VIRTIO_PCI_REG_ADDR((hw), (reg))))
-
 static inline int
 vtpci_with_feature(struct virtio_hw *hw, uint64_t bit)
 {
@@ -345,7 +295,8 @@ vtpci_with_feature(struct virtio_hw *hw, uint64_t bit)
 /*
  * Function declaration from virtio_pci.c
  */
-int vtpci_init(struct rte_pci_device *, struct virtio_hw *);
+int vtpci_init(struct rte_pci_device *, struct virtio_hw *,
+              uint32_t *dev_flags);
 void vtpci_reset(struct virtio_hw *);
 
 void vtpci_reinit_complete(struct virtio_hw *);