/*-
* BSD LICENSE
- *
- * Copyright(c) 2010-2013 Intel Corporation. All rights reserved.
+ *
+ * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
#define _VIRTIO_PCI_H_
#include <stdint.h>
+
+#ifdef __FreeBSD__
+#include <sys/types.h>
+#include <machine/cpufunc.h>
+#else
#include <sys/io.h>
+#endif
#include <rte_ethdev.h>
#define VIRTIO_PCI_QUEUE_SEL 14 /* current VQ selection (16, RW) */
#define VIRTIO_PCI_QUEUE_NOTIFY 16 /* notify host regarding VQ (16, RW) */
#define VIRTIO_PCI_STATUS 18 /* device status register (8, RW) */
-#define VIRTIO_PCI_ISR 19 /* interrupt status register, reading
- * also clears the register (8, RO) */
+#define VIRTIO_PCI_ISR 19 /* interrupt status register, reading
+ * also clears the register (8, RO) */
/* Only if MSIX is enabled: */
#define VIRTIO_MSI_CONFIG_VECTOR 20 /* configuration change vector (16, RW) */
-#define VIRTIO_MSI_QUEUE_VECTOR 22 /* vector for selected VQ notifications
- (16, RW) */
+#define VIRTIO_MSI_QUEUE_VECTOR 22 /* vector for selected VQ notifications
+ (16, RW) */
/* The bit of the ISR which indicates a device has an interrupt. */
#define VIRTIO_PCI_ISR_INTR 0x1
uint32_t io_base;
uint32_t host_features;
uint32_t guest_features;
-
+
struct virtqueue *cvq;
uint16_t vtnet_hdr_size;
uint16_t subsystem_device_id;
uint16_t subsystem_vendor_id;
uint8_t revision_id;
+ uint8_t use_msix;
uint8_t mac_addr[ETHER_ADDR_LEN];
int adapter_stopped;
- struct rte_eth_stats eth_stats;
};
/*
uint8_t mac[ETHER_ADDR_LEN];
/* See VIRTIO_NET_F_STATUS and VIRTIO_NET_S_* above */
uint16_t status;
-};
-/* Value indicated in device config */
-#define VIRTIO_PCI_FLAG_MSIX 0x0020
+ 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)->guest_features & VIRTIO_PCI_FLAG_MSIX) ? 24 : 20)
+#define VIRTIO_PCI_CONFIG(hw) (((hw)->use_msix) ? 24 : 20)
/*
* How many bits to shift physical queue address written to QUEUE_PFN.
/* 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))
outl_p((unsigned int)(value), (VIRTIO_PCI_REG_ADDR((hw), (reg))))
static inline int
-vtpci_with_feature(struct virtio_hw *hw, uint64_t feature)
+vtpci_with_feature(struct virtio_hw *hw, uint32_t feature)
{
- return ((hw->guest_features & feature) != 0);
+ return (hw->guest_features & feature) != 0;
}
/*
void vtpci_set_status(struct virtio_hw *, uint8_t);
-int vtpci_with_feature(struct virtio_hw *, uint64_t);
-
-uint64_t vtpci_negotiate_features(struct virtio_hw *, uint64_t);
+uint32_t vtpci_negotiate_features(struct virtio_hw *, uint32_t);
void vtpci_write_dev_config(struct virtio_hw *, uint64_t, void *, int);