X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_pmd_virtio%2Fvirtio_pci.h;h=64d9c34642cd78f79350e294ac4fceffef7ea77f;hb=4bb4414040ffdc9f2676f22b540b8c77d2ba00fc;hp=da4351337b0fd26445d7febf4d4beda9bab30d4a;hpb=f72751f2c70a787787f499694d8c7a66247e5737;p=dpdk.git diff --git a/lib/librte_pmd_virtio/virtio_pci.h b/lib/librte_pmd_virtio/virtio_pci.h index da4351337b..64d9c34642 100644 --- a/lib/librte_pmd_virtio/virtio_pci.h +++ b/lib/librte_pmd_virtio/virtio_pci.h @@ -1,13 +1,13 @@ /*- * 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 @@ -17,7 +17,7 @@ * * 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 @@ -35,7 +35,13 @@ #define _VIRTIO_PCI_H_ #include + +#ifdef __FreeBSD__ +#include +#include +#else #include +#endif #include @@ -59,12 +65,12 @@ struct virtqueue; #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 @@ -156,24 +162,16 @@ struct virtqueue; #define VIRTIO_MAX_VIRTQUEUES 8 struct virtio_hw { + struct virtqueue *cvq; uint32_t io_base; - uint32_t host_features; uint32_t guest_features; - - struct virtqueue *cvq; - - uint16_t vtnet_hdr_size; - uint32_t max_tx_queues; uint32_t max_rx_queues; - uint16_t device_id; - uint16_t vendor_id; - uint16_t subsystem_device_id; - uint16_t subsystem_vendor_id; - uint8_t revision_id; + uint16_t vtnet_hdr_size; + uint8_t vlan_strip; + uint8_t use_msix; + uint8_t started; uint8_t mac_addr[ETHER_ADDR_LEN]; - int adapter_stopped; - struct rte_eth_stats eth_stats; }; /* @@ -186,14 +184,14 @@ struct virtio_net_config { 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. @@ -204,6 +202,28 @@ 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)) @@ -225,7 +245,7 @@ struct virtio_net_config { static inline int vtpci_with_feature(struct virtio_hw *hw, uint32_t feature) { - return ((hw->guest_features & feature) != 0); + return (hw->guest_features & feature) != 0; } /* @@ -235,8 +255,6 @@ void vtpci_reset(struct virtio_hw *); void vtpci_reinit_complete(struct virtio_hw *); -uint8_t vtpci_get_status(struct virtio_hw *); - void vtpci_set_status(struct virtio_hw *, uint8_t); uint32_t vtpci_negotiate_features(struct virtio_hw *, uint32_t); @@ -245,4 +263,8 @@ void vtpci_write_dev_config(struct virtio_hw *, uint64_t, void *, int); void vtpci_read_dev_config(struct virtio_hw *, uint64_t, void *, int); +uint8_t vtpci_isr(struct virtio_hw *); + +uint16_t vtpci_irq_config(struct virtio_hw *, uint16_t); + #endif /* _VIRTIO_PCI_H_ */