From mboxrd@z Thu Jan 1 00:00:00 1970 From: Santosh Shukla Subject: [PATCH v6 5/8] virtio: move io header and api from virtio_pci.h Date: Fri, 29 Jan 2016 23:51:54 +0530 Message-ID: <1454091717-32251-5-git-send-email-sshukla@mvista.com> References: <0000-cover-letter.patch> <1454091717-32251-1-git-send-email-sshukla@mvista.com> To: dev@dpdk.org Return-path: Received: from mail-pf0-f178.google.com (mail-pf0-f178.google.com [209.85.192.178]) by dpdk.org (Postfix) with ESMTP id 767F5C746 for ; Fri, 29 Jan 2016 19:23:32 +0100 (CET) Received: by mail-pf0-f178.google.com with SMTP id o185so41252516pfb.1 for ; Fri, 29 Jan 2016 10:23:32 -0800 (PST) In-Reply-To: <1454091717-32251-1-git-send-email-sshukla@mvista.com> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Moving io api and header file i.e. sys/io.h to separate file virtio_io.h Signed-off-by: Santosh Shukla --- v5-->v6: - included new file virtio_io.h, has in/out api and sys/io.h. drivers/net/virtio/virtio_io.h | 114 +++++++++++++++++++++++++++++++++++++++ drivers/net/virtio/virtio_pci.c | 1 + drivers/net/virtio/virtio_pci.h | 30 ----------- 3 files changed, 115 insertions(+), 30 deletions(-) create mode 100644 drivers/net/virtio/virtio_io.h diff --git a/drivers/net/virtio/virtio_io.h b/drivers/net/virtio/virtio_io.h new file mode 100644 index 0000000..bfa1341 --- /dev/null +++ b/drivers/net/virtio/virtio_io.h @@ -0,0 +1,114 @@ +/* + * BSD LICENSE + * + * Copyright(c) 2016 Cavium Networks. 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 + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * 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 + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef _VIRTIO_IO_H_ +#define _VIRTIO_IO_H_ + +#include +#include "virtio_logs.h" + +#if defined(RTE_ARCH_X86_64) || defined(RTE_ARCH_I686) + +#ifdef __FreeBSD__ +#include +#include + +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); +} + +#else +#include +#endif + +#else /* ! X86 */ + +static inline uint8_t +inb(unsigned long addr __rte_unused) +{ + PMD_INIT_LOG(ERR, "inb() not supported for this RTE_ARCH\n"); + return 0; +} + +static inline uint16_t +inw(unsigned long addr __rte_unused) +{ + PMD_INIT_LOG(ERR, "inw() not supported for this RTE_ARCH\n"); + return 0; +} + +static inline uint32_t +inl(unsigned long addr __rte_unused) +{ + PMD_INIT_LOG(ERR, "in() not supported for this RTE_ARCH\n"); + return 0; +} + +static inline void +outb_p(unsigned char data __rte_unused, unsigned int port __rte_unused) +{ + PMD_INIT_LOG(ERR, "outb_p() not supported for this RTE_ARCH\n"); + return; +} + +static inline void +outw_p(unsigned short data __rte_unused, unsigned int port __rte_unused) +{ + PMD_INIT_LOG(ERR, "outw_p() not supported for this RTE_ARCH\n"); + return; +} + +static inline void +outl_p(unsigned int data __rte_unused, unsigned int port __rte_unused) +{ + PMD_INIT_LOG(ERR, "outl_p() not supported for this RTE_ARCH\n"); + return; +} + +#endif /* X86 */ +#endif /* _VIRTIO_IO_H_ */ diff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c index a9f179f..064f234 100644 --- a/drivers/net/virtio/virtio_pci.c +++ b/drivers/net/virtio/virtio_pci.c @@ -37,6 +37,7 @@ #include #endif +#include "virtio_io.h" #include "virtio_pci.h" #include "virtio_logs.h" #include "virtqueue.h" diff --git a/drivers/net/virtio/virtio_pci.h b/drivers/net/virtio/virtio_pci.h index 99572a0..2fe5835 100644 --- a/drivers/net/virtio/virtio_pci.h +++ b/drivers/net/virtio/virtio_pci.h @@ -35,14 +35,6 @@ #define _VIRTIO_PCI_H_ #include - -#ifdef __FreeBSD__ -#include -#include -#else -#include -#endif - #include struct virtqueue; @@ -296,28 +288,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 - static inline int vtpci_with_feature(struct virtio_hw *hw, uint64_t bit) { -- 1.7.9.5