DPDK patches and discussions
 help / color / mirror / Atom feed
From: Allain Legacy <allain.legacy@windriver.com>
To: <ferruh.yigit@intel.com>
Cc: <dev@dpdk.org>
Subject: [dpdk-dev] [PATCH v2 02/15] net/avp: public header files
Date: Sun, 26 Feb 2017 14:08:50 -0500	[thread overview]
Message-ID: <1488136143-116389-3-git-send-email-allain.legacy@windriver.com> (raw)
In-Reply-To: <1488136143-116389-1-git-send-email-allain.legacy@windriver.com>

Adds public/exported header files for the AVP PMD.  The AVP device is a
shared memory based device.  The structures and constants that define the
method of operation of the device must be visible by both the PMD and the
host DPDK application.  They must not change without proper version
controls and updates to both the hypervisor DPDK application and the PMD.

The hypervisor DPDK application is a Wind River Systems proprietary
virtual switch.

Signed-off-by: Allain Legacy <allain.legacy@windriver.com>
Signed-off-by: Matt Peters <matt.peters@windriver.com>
---
 drivers/net/avp/rte_avp_common.h | 424 +++++++++++++++++++++++++++++++++++++++
 drivers/net/avp/rte_avp_fifo.h   | 157 +++++++++++++++
 2 files changed, 581 insertions(+)
 create mode 100644 drivers/net/avp/rte_avp_common.h
 create mode 100644 drivers/net/avp/rte_avp_fifo.h

diff --git a/drivers/net/avp/rte_avp_common.h b/drivers/net/avp/rte_avp_common.h
new file mode 100644
index 0000000..579d5ac
--- /dev/null
+++ b/drivers/net/avp/rte_avp_common.h
@@ -0,0 +1,424 @@
+/*-
+ *   This file is provided under a dual BSD/LGPLv2 license.  When using or
+ *   redistributing this file, you may do so under either license.
+ *
+ *   GNU LESSER GENERAL PUBLIC LICENSE
+ *
+ *   Copyright(c) 2010-2013 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2014-2015 Wind River Systems, Inc. All rights reserved.
+ *
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of version 2.1 of the GNU Lesser General Public License
+ *   as published by the Free Software Foundation.
+ *
+ *   This program is distributed in the hope that it will be useful, but
+ *   WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *   Lesser General Public License for more details.
+ *
+ *   Contact Information:
+ *   Wind River Systems, Inc.
+ *
+ *
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2010-2013 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2014-2016 Wind River Systems, Inc. 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 _RTE_AVP_COMMON_H_
+#define _RTE_AVP_COMMON_H_
+
+#ifdef __KERNEL__
+#include <linux/if.h>
+#endif
+
+/**
+ * AVP name is part of network device name.
+ */
+#define RTE_AVP_NAMESIZE 32
+
+/**
+ * AVP alias is a user-defined value used for lookups from secondary
+ * processes.  Typically, this is a UUID.
+ */
+#define RTE_AVP_ALIASSIZE 128
+
+/**
+ * Memory aligment (cache aligned)
+ */
+#ifndef RTE_AVP_ALIGNMENT
+#define RTE_AVP_ALIGNMENT 64
+#endif
+
+/*
+ * Request id.
+ */
+enum rte_avp_req_id {
+	RTE_AVP_REQ_UNKNOWN = 0,
+	RTE_AVP_REQ_CHANGE_MTU,
+	RTE_AVP_REQ_CFG_NETWORK_IF,
+	RTE_AVP_REQ_CFG_DEVICE,
+	RTE_AVP_REQ_SHUTDOWN_DEVICE,
+	RTE_AVP_REQ_MAX,
+};
+
+/**@{ AVP device driver types */
+#define RTE_AVP_DRIVER_TYPE_UNKNOWN 0
+#define RTE_AVP_DRIVER_TYPE_DPDK 1
+#define RTE_AVP_DRIVER_TYPE_KERNEL 2
+#define RTE_AVP_DRIVER_TYPE_QEMU 3
+/**@} */
+
+/**@{ AVP device operational modes */
+#define RTE_AVP_MODE_HOST 0 /**< AVP interface created in host */
+#define RTE_AVP_MODE_GUEST 1 /**< AVP interface created for export to guest */
+#define RTE_AVP_MODE_TRACE 2 /**< AVP interface created for packet tracing */
+/**@} */
+
+/*
+ * Structure for AVP queue configuration query request/result
+ */
+struct rte_avp_device_config {
+	uint64_t device_id;	/**< Unique system identifier */
+	uint32_t driver_type; /**< Device Driver type */
+	uint32_t driver_version; /**< Device Driver version */
+	uint32_t features; /**< Negotiated features */
+	uint16_t num_tx_queues;	/**< Number of active transmit queues */
+	uint16_t num_rx_queues;	/**< Number of active receive queues */
+	uint8_t if_up; /**< 1: interface up, 0: interface down */
+} __attribute__ ((__packed__));
+
+/*
+ * Structure for AVP request.
+ */
+struct rte_avp_request {
+	uint32_t req_id; /**< Request id */
+	union {
+		uint32_t new_mtu; /**< New MTU */
+		uint8_t if_up;	/**< 1: interface up, 0: interface down */
+	struct rte_avp_device_config config; /**< Queue configuration */
+	};
+	int32_t result;	/**< Result for processing request */
+} __attribute__ ((__packed__));
+
+/*
+ * FIFO struct mapped in a shared memory. It describes a circular buffer FIFO
+ * Write and read should wrap around. FIFO is empty when write == read
+ * Writing should never overwrite the read position
+ */
+struct rte_avp_fifo {
+	volatile unsigned int write; /**< Next position to be written*/
+	volatile unsigned int read; /**< Next position to be read */
+	unsigned int len; /**< Circular buffer length */
+	unsigned int elem_size; /**< Pointer size - for 32/64 bit OS */
+	void *volatile buffer[0]; /**< The buffer contains mbuf pointers */
+};
+
+
+/*
+ * AVP packet buffer header used to define the exchange of packet data.
+ */
+struct rte_avp_desc {
+	uint64_t pad0;
+	void *pkt_mbuf; /**< Reference to packet mbuf */
+	uint8_t pad1[14];
+	uint16_t ol_flags; /**< Offload features. */
+	void *next;	/**< Reference to next buffer in chain */
+	void *data;	/**< Start address of data in segment buffer. */
+	uint16_t data_len; /**< Amount of data in segment buffer. */
+	uint8_t nb_segs; /**< Number of segments */
+	uint8_t pad2;
+	uint16_t pkt_len; /**< Total pkt len: sum of all segment data_len. */
+	uint32_t pad3;
+	uint16_t vlan_tci; /**< VLAN Tag Control Identifier (CPU order). */
+	uint32_t pad4;
+} __attribute__ ((__aligned__(RTE_AVP_ALIGNMENT), __packed__));
+
+
+/**{ AVP device features */
+#define RTE_AVP_FEATURE_VLAN_OFFLOAD (1 << 0) /**< Emulated HW VLAN offload */
+/**@} */
+
+
+/**@{ Offload feature flags */
+#define RTE_AVP_TX_VLAN_PKT 0x0001 /**< TX packet is a 802.1q VLAN packet. */
+#define RTE_AVP_RX_VLAN_PKT 0x0800 /**< RX packet is a 802.1q VLAN packet. */
+/**@} */
+
+
+/**@{ AVP PCI identifiers */
+#define RTE_AVP_PCI_VENDOR_ID   0x1af4
+#define RTE_AVP_PCI_DEVICE_ID   0x1110
+/**@} */
+
+/**@{ AVP PCI subsystem identifiers */
+#define RTE_AVP_PCI_SUB_VENDOR_ID RTE_AVP_PCI_VENDOR_ID
+#define RTE_AVP_PCI_SUB_DEVICE_ID 0x1104
+/**@} */
+
+/**@{ AVP PCI BAR definitions */
+#define RTE_AVP_PCI_MMIO_BAR   0
+#define RTE_AVP_PCI_MSIX_BAR   1
+#define RTE_AVP_PCI_MEMORY_BAR 2
+#define RTE_AVP_PCI_MEMMAP_BAR 4
+#define RTE_AVP_PCI_DEVICE_BAR 5
+#define RTE_AVP_PCI_MAX_BAR    6
+/**@} */
+
+/**@{ AVP PCI BAR name definitions */
+#define RTE_AVP_MMIO_BAR_NAME   "avp-mmio"
+#define RTE_AVP_MSIX_BAR_NAME   "avp-msix"
+#define RTE_AVP_MEMORY_BAR_NAME "avp-memory"
+#define RTE_AVP_MEMMAP_BAR_NAME "avp-memmap"
+#define RTE_AVP_DEVICE_BAR_NAME "avp-device"
+/**@} */
+
+/**@{ AVP PCI MSI-X vectors */
+#define RTE_AVP_MIGRATION_MSIX_VECTOR 0	/**< Migration interrupts */
+#define RTE_AVP_MAX_MSIX_VECTORS 1
+/**@} */
+
+/**@} AVP Migration status/ack register values */
+#define RTE_AVP_MIGRATION_NONE      0 /**< Migration never executed */
+#define RTE_AVP_MIGRATION_DETACHED  1 /**< Device attached during migration */
+#define RTE_AVP_MIGRATION_ATTACHED  2 /**< Device reattached during migration */
+#define RTE_AVP_MIGRATION_ERROR     3 /**< Device failed to attach/detach */
+/**@} */
+
+/**@} AVP MMIO Register Offsets */
+#define RTE_AVP_REGISTER_BASE 0
+#define RTE_AVP_INTERRUPT_MASK_OFFSET (RTE_AVP_REGISTER_BASE + 0)
+#define RTE_AVP_INTERRUPT_STATUS_OFFSET (RTE_AVP_REGISTER_BASE + 4)
+#define RTE_AVP_MIGRATION_STATUS_OFFSET (RTE_AVP_REGISTER_BASE + 8)
+#define RTE_AVP_MIGRATION_ACK_OFFSET (RTE_AVP_REGISTER_BASE + 12)
+/**@} */
+
+/**@} AVP Interrupt Status Mask */
+#define RTE_AVP_MIGRATION_INTERRUPT_MASK (1 << 1)
+#define RTE_AVP_APP_INTERRUPTS_MASK      (0xFFFFFFFF)
+#define RTE_AVP_NO_INTERRUPTS_MASK       (0)
+/**@} */
+
+/*
+ * Maximum number of memory regions to export
+ */
+#define RTE_AVP_MAX_MAPS  2048
+
+/*
+ * Description of a single memory region
+ */
+struct rte_avp_memmap {
+	void *addr;
+	phys_addr_t phys_addr;
+	uint64_t length;
+};
+
+/*
+ * AVP memory mapping validation marker
+ */
+#define RTE_AVP_MEMMAP_MAGIC (0x20131969)
+
+/**@{  AVP memory map versions */
+#define RTE_AVP_MEMMAP_VERSION_1 1
+#define RTE_AVP_MEMMAP_VERSION RTE_AVP_MEMMAP_VERSION_1
+/**@} */
+
+/*
+ * Defines a list of memory regions exported from the host to the guest
+ */
+struct rte_avp_memmap_info {
+	uint32_t magic; /**< Memory validation marker */
+	uint32_t version; /**< Data format version */
+	uint32_t nb_maps;
+	struct rte_avp_memmap maps[RTE_AVP_MAX_MAPS];
+};
+
+/*
+ * AVP device memory validation marker
+ */
+#define RTE_AVP_DEVICE_MAGIC (0x20131975)
+
+/**@{  AVP device map versions
+ * WARNING:  do not change the format or names of these variables.  They are
+ * automatically parsed from the build system to generate the SDK package
+ * name.
+ **/
+#define RTE_AVP_RELEASE_VERSION_1 1
+#define RTE_AVP_RELEASE_VERSION RTE_AVP_RELEASE_VERSION_1
+#define RTE_AVP_MAJOR_VERSION_0 0
+#define RTE_AVP_MAJOR_VERSION_1 1
+#define RTE_AVP_MAJOR_VERSION_2 2
+#define RTE_AVP_MAJOR_VERSION RTE_AVP_MAJOR_VERSION_2
+#define RTE_AVP_MINOR_VERSION_0 0
+#define RTE_AVP_MINOR_VERSION_1 1
+#define RTE_AVP_MINOR_VERSION_13 13
+#define RTE_AVP_MINOR_VERSION RTE_AVP_MINOR_VERSION_13
+/**@} */
+
+
+/**
+ * Generates a 32-bit version number from the specified version number
+ * components
+ */
+#define RTE_AVP_MAKE_VERSION(_release, _major, _minor) \
+((((_release) & 0xffff) << 16) | (((_major) & 0xff) << 8) | ((_minor) & 0xff))
+
+
+/**
+ * Represents the current version of the AVP host driver
+ * WARNING:  in the current development branch the host and guest driver
+ * version should always be the same.  When patching guest features back to
+ * GA releases the host version number should not be updated unless there was
+ * an actual change made to the host driver.
+ */
+#define RTE_AVP_CURRENT_HOST_VERSION \
+RTE_AVP_MAKE_VERSION(RTE_AVP_RELEASE_VERSION_1, \
+		     RTE_AVP_MAJOR_VERSION_0, \
+		     RTE_AVP_MINOR_VERSION_1)
+
+
+/**
+ * Represents the current version of the AVP guest drivers
+ */
+#define RTE_AVP_CURRENT_GUEST_VERSION \
+RTE_AVP_MAKE_VERSION(RTE_AVP_RELEASE_VERSION_1, \
+		     RTE_AVP_MAJOR_VERSION_2, \
+		     RTE_AVP_MINOR_VERSION_13)
+
+/**
+ * Access AVP device version values
+ */
+#define RTE_AVP_GET_RELEASE_VERSION(_version) (((_version) >> 16) & 0xffff)
+#define RTE_AVP_GET_MAJOR_VERSION(_version) (((_version) >> 8) & 0xff)
+#define RTE_AVP_GET_MINOR_VERSION(_version) ((_version) & 0xff)
+/**@}*/
+
+
+/**
+ * Remove the minor version number so that only the release and major versions
+ * are used for comparisons.
+ */
+#define RTE_AVP_STRIP_MINOR_VERSION(_version) ((_version) >> 8)
+
+
+/**
+ * Defines the number of mbuf pools supported per device (1 per socket)
+ * @note This value should be equal to RTE_MAX_NUMA_NODES
+ */
+#define RTE_AVP_MAX_MEMPOOLS (8)
+
+/*
+ * Defines address translation parameters for each support mbuf pool
+ */
+struct rte_avp_mempool_info {
+	void *addr;
+	phys_addr_t phys_addr;
+	uint64_t length;
+};
+
+/*
+ * Struct used to create a AVP device. Passed to the kernel in IOCTL call or
+ * via inter-VM shared memory when used in a guest.
+ */
+struct rte_avp_device_info {
+	uint32_t magic;	/**< Memory validation marker */
+	uint32_t version; /**< Data format version */
+
+	char ifname[RTE_AVP_NAMESIZE];	/**< Network device name for AVP */
+
+	phys_addr_t tx_phys;
+	phys_addr_t rx_phys;
+	phys_addr_t alloc_phys;
+	phys_addr_t free_phys;
+
+	uint32_t features; /**< Supported feature bitmap */
+	uint8_t min_rx_queues; /**< Minimum supported receive/free queues */
+	uint8_t num_rx_queues; /**< Recommended number of receive/free queues */
+	uint8_t max_rx_queues; /**< Maximum supported receive/free queues */
+	uint8_t min_tx_queues; /**< Minimum supported transmit/alloc queues */
+	uint8_t num_tx_queues;
+	/**< Recommended number of transmit/alloc queues */
+	uint8_t max_tx_queues; /**< Maximum supported transmit/alloc queues */
+
+	uint32_t tx_size; /**< Size of each transmit queue */
+	uint32_t rx_size; /**< Size of each receive queue */
+	uint32_t alloc_size; /**< Size of each alloc queue */
+	uint32_t free_size;	/**< Size of each free queue */
+
+	/* Used by Ethtool */
+	phys_addr_t req_phys;
+	phys_addr_t resp_phys;
+	phys_addr_t sync_phys;
+	void *sync_va;
+
+	/* mbuf mempool (used when a single memory area is supported) */
+	void *mbuf_va;
+	phys_addr_t mbuf_phys;
+
+	/* mbuf mempools */
+	struct rte_avp_mempool_info pool[RTE_AVP_MAX_MEMPOOLS];
+
+#ifdef __KERNEL__
+	/* Ethernet info */
+	char ethaddr[ETH_ALEN];
+#else
+	char ethaddr[ETHER_ADDR_LEN];
+#endif
+
+	uint8_t mode; /**< device mode, i.e guest, host, trace */
+
+	/* mbuf size */
+	unsigned int mbuf_size;
+
+	/*
+	 * unique id to differentiate between two instantiations of the same
+	 * AVP device (i.e., the guest needs to know if the device has been
+	 * deleted and recreated).
+	 */
+	uint64_t device_id;
+
+	uint32_t max_rx_pkt_len; /**< Maximum receive unit size */
+};
+
+#define RTE_AVP_MAX_QUEUES (8) /**< Maximum number of queues per device */
+
+/** Maximum number of chained mbufs in a packet */
+#define RTE_AVP_MAX_MBUF_SEGMENTS (5)
+
+#define RTE_AVP_DEVICE "avp"
+
+#define RTE_AVP_IOCTL_TEST    _IOWR(0, 1, int)
+#define RTE_AVP_IOCTL_CREATE  _IOWR(0, 2, struct rte_avp_device_info)
+#define RTE_AVP_IOCTL_RELEASE _IOWR(0, 3, struct rte_avp_device_info)
+#define RTE_AVP_IOCTL_QUERY   _IOWR(0, 4, struct rte_avp_device_config)
+
+#endif /* _RTE_AVP_COMMON_H_ */
diff --git a/drivers/net/avp/rte_avp_fifo.h b/drivers/net/avp/rte_avp_fifo.h
new file mode 100644
index 0000000..1a475de
--- /dev/null
+++ b/drivers/net/avp/rte_avp_fifo.h
@@ -0,0 +1,157 @@
+/*-
+ *   This file is provided under a dual BSD/LGPLv2 license.  When using or
+ *   redistributing this file, you may do so under either license.
+ *
+ *   GNU LESSER GENERAL PUBLIC LICENSE
+ *
+ *   Copyright(c) 2010-2013 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2014 Wind River Systems, Inc. All rights reserved.
+ *
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of version 2.1 of the GNU Lesser General Public License
+ *   as published by the Free Software Foundation.
+ *
+ *   This program is distributed in the hope that it will be useful, but
+ *   WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *   Lesser General Public License for more details.
+ *
+ *   Contact Information:
+ *   Wind River Systems, Inc.
+ *
+ *
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2010-2013 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2014 Wind River Systems, Inc. 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 _RTE_AVP_FIFO_H_
+#define _RTE_AVP_FIFO_H_
+
+#ifdef __KERNEL__
+/* Write memory barrier for kernel compiles */
+#define AVP_WMB() smp_wmb()
+/* Read memory barrier for kernel compiles */
+#define AVP_RMB() smp_rmb()
+#else
+/* Write memory barrier for userspace compiles */
+#define AVP_WMB() rte_wmb()
+/* Read memory barrier for userspace compiles */
+#define AVP_RMB() rte_rmb()
+#endif
+
+#ifndef __KERNEL__
+/**
+ * Initializes the avp fifo structure
+ */
+static inline void
+avp_fifo_init(struct rte_avp_fifo *fifo, unsigned int size)
+{
+	/* Ensure size is power of 2 */
+	if (size & (size - 1))
+		rte_panic("AVP fifo size must be power of 2\n");
+
+	fifo->write = 0;
+	fifo->read = 0;
+	fifo->len = size;
+	fifo->elem_size = sizeof(void *);
+}
+#endif
+
+/**
+ * Adds num elements into the fifo. Return the number actually written
+ */
+static inline unsigned
+avp_fifo_put(struct rte_avp_fifo *fifo, void **data, unsigned int num)
+{
+	unsigned int i = 0;
+	unsigned int fifo_write = fifo->write;
+	unsigned int fifo_read = fifo->read;
+	unsigned int new_write = fifo_write;
+
+	for (i = 0; i < num; i++) {
+		new_write = (new_write + 1) & (fifo->len - 1);
+
+		if (new_write == fifo_read)
+			break;
+		fifo->buffer[fifo_write] = data[i];
+		fifo_write = new_write;
+	}
+	AVP_WMB();
+	fifo->write = fifo_write;
+	return i;
+}
+
+/**
+ * Get up to num elements from the fifo. Return the number actually read
+ */
+static inline unsigned int
+avp_fifo_get(struct rte_avp_fifo *fifo, void **data, unsigned int num)
+{
+	unsigned int i = 0;
+	unsigned int new_read = fifo->read;
+	unsigned int fifo_write = fifo->write;
+
+	if (new_read == fifo_write)
+		return 0; /* empty */
+
+	for (i = 0; i < num; i++) {
+		if (new_read == fifo_write)
+			break;
+
+		data[i] = fifo->buffer[new_read];
+		new_read = (new_read + 1) & (fifo->len - 1);
+	}
+	AVP_RMB();
+	fifo->read = new_read;
+	return i;
+}
+
+/**
+ * Get the num of elements in the fifo
+ */
+static inline unsigned int
+avp_fifo_count(struct rte_avp_fifo *fifo)
+{
+	return (fifo->len + fifo->write - fifo->read) & (fifo->len - 1);
+}
+
+/**
+ * Get the num of available elements in the fifo
+ */
+static inline unsigned int
+avp_fifo_free_count(struct rte_avp_fifo *fifo)
+{
+	return (fifo->read - fifo->write - 1) & (fifo->len - 1);
+}
+
+#endif /* _RTE_AVP_FIFO_H_ */
-- 
1.8.3.1

  parent reply	other threads:[~2017-02-26 19:09 UTC|newest]

Thread overview: 172+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-25  1:22 [dpdk-dev] [PATCH 00/16] Wind River Systems AVP PMD Allain Legacy
2017-02-25  1:23 ` [dpdk-dev] [PATCH 01/16] config: adds attributes for the " Allain Legacy
2017-02-25  1:23 ` [dpdk-dev] [PATCH 02/16] net/avp: public header files Allain Legacy
2017-02-25  1:23 ` [dpdk-dev] [PATCH 03/16] maintainers: claim responsibility for AVP PMD Allain Legacy
2017-02-25  1:23 ` [dpdk-dev] [PATCH 04/16] net/avp: add PMD version map file Allain Legacy
2017-02-25  1:23 ` [dpdk-dev] [PATCH 05/16] net/avp: debug log macros Allain Legacy
2017-02-25  1:23 ` [dpdk-dev] [PATCH 06/16] drivers/net: adds driver makefiles for AVP PMD Allain Legacy
2017-02-25  1:23 ` [dpdk-dev] [PATCH 07/16] net/avp: driver registration Allain Legacy
2017-02-25  1:23 ` [dpdk-dev] [PATCH 08/16] net/avp: device initialization Allain Legacy
2017-02-25  1:23 ` [dpdk-dev] [PATCH 09/16] net/avp: device configuration Allain Legacy
2017-02-25  1:23 ` [dpdk-dev] [PATCH 10/16] net/avp: queue setup and release Allain Legacy
2017-02-25  1:23 ` [dpdk-dev] [PATCH 11/16] net/avp: packet receive functions Allain Legacy
2017-02-25  1:23 ` [dpdk-dev] [PATCH 12/16] net/avp: packet transmit functions Allain Legacy
2017-02-25  1:23 ` [dpdk-dev] [PATCH 13/16] net/avp: device statistics operations Allain Legacy
2017-02-25  1:23 ` [dpdk-dev] [PATCH 14/16] net/avp: device promiscuous functions Allain Legacy
2017-02-25  1:23 ` [dpdk-dev] [PATCH 15/16] net/avp: device start and stop operations Allain Legacy
2017-02-25  1:23 ` [dpdk-dev] [PATCH 16/16] doc: adds information related to the AVP PMD Allain Legacy
2017-02-26 19:08 ` [dpdk-dev] [PATCH v2 00/16] Wind River Systems " Allain Legacy
2017-02-26 19:08   ` [dpdk-dev] [PATCH v2 01/15] config: adds attributes for the " Allain Legacy
2017-02-26 19:08   ` Allain Legacy [this message]
2017-02-28 11:49     ` [dpdk-dev] [PATCH v2 02/15] net/avp: public header files Jerin Jacob
2017-03-01 13:25       ` Legacy, Allain
2017-02-26 19:08   ` [dpdk-dev] [PATCH v2 03/15] maintainers: claim responsibility for AVP PMD Allain Legacy
2017-02-26 19:08   ` [dpdk-dev] [PATCH v2 04/15] net/avp: add PMD version map file Allain Legacy
2017-02-26 19:08   ` [dpdk-dev] [PATCH v2 05/15] net/avp: debug log macros Allain Legacy
2017-02-26 19:08   ` [dpdk-dev] [PATCH v2 06/15] drivers/net: adds driver makefiles for AVP PMD Allain Legacy
2017-02-26 19:08   ` [dpdk-dev] [PATCH v2 07/15] net/avp: driver registration Allain Legacy
2017-02-27 16:47     ` Stephen Hemminger
2017-02-27 17:10       ` Legacy, Allain
2017-02-27 16:53     ` Stephen Hemminger
2017-02-27 17:09       ` Legacy, Allain
2017-02-26 19:08   ` [dpdk-dev] [PATCH v2 08/15] net/avp: device initialization Allain Legacy
2017-02-28 11:57     ` Jerin Jacob
2017-03-01 13:29       ` Legacy, Allain
2017-02-26 19:08   ` [dpdk-dev] [PATCH v2 09/15] net/avp: device configuration Allain Legacy
2017-02-26 19:08   ` [dpdk-dev] [PATCH v2 10/15] net/avp: queue setup and release Allain Legacy
2017-02-26 19:08   ` [dpdk-dev] [PATCH v2 11/15] net/avp: packet receive functions Allain Legacy
2017-02-27 16:46     ` Stephen Hemminger
2017-02-27 17:06       ` Legacy, Allain
2017-02-28 10:27         ` Bruce Richardson
2017-03-01 13:23           ` Legacy, Allain
2017-03-01 14:14             ` Thomas Monjalon
2017-03-01 14:54               ` Legacy, Allain
2017-03-01 15:10               ` Stephen Hemminger
2017-03-01 15:40                 ` Legacy, Allain
2017-02-26 19:09   ` [dpdk-dev] [PATCH v2 12/15] net/avp: packet transmit functions Allain Legacy
2017-02-26 22:18     ` Legacy, Allain
2017-02-26 19:09   ` [dpdk-dev] [PATCH v2 13/15] net/avp: device promiscuous functions Allain Legacy
2017-02-26 19:09   ` [dpdk-dev] [PATCH v2 14/15] net/avp: device start and stop operations Allain Legacy
2017-02-26 19:09   ` [dpdk-dev] [PATCH v2 15/15] doc: adds information related to the AVP PMD Allain Legacy
2017-02-27 17:04     ` Mcnamara, John
2017-02-27 17:07       ` Legacy, Allain
2017-02-27  8:54   ` [dpdk-dev] [PATCH v2 00/16] Wind River Systems " Vincent JARDIN
2017-02-27 12:15     ` Legacy, Allain
2017-02-27 15:17       ` Wiles, Keith
2017-03-02  0:19   ` [dpdk-dev] [PATCH v3 " Allain Legacy
2017-03-02  0:19     ` [dpdk-dev] [PATCH v3 01/16] config: adds attributes for the " Allain Legacy
2017-03-02  0:19     ` [dpdk-dev] [PATCH v3 02/16] net/avp: public header files Allain Legacy
2017-03-03 14:37       ` Chas Williams
2017-03-03 15:35         ` Legacy, Allain
2017-03-02  0:19     ` [dpdk-dev] [PATCH v3 03/16] maintainers: claim responsibility for AVP PMD Allain Legacy
2017-03-02  0:19     ` [dpdk-dev] [PATCH v3 04/16] net/avp: add PMD version map file Allain Legacy
2017-03-02  0:19     ` [dpdk-dev] [PATCH v3 05/16] net/avp: debug log macros Allain Legacy
2017-03-02  0:19     ` [dpdk-dev] [PATCH v3 06/16] drivers/net: adds driver makefiles for AVP PMD Allain Legacy
2017-03-02  0:19     ` [dpdk-dev] [PATCH v3 07/16] net/avp: driver registration Allain Legacy
2017-03-02  0:20     ` [dpdk-dev] [PATCH v3 08/16] net/avp: device initialization Allain Legacy
2017-03-03 15:04       ` Chas Williams
2017-03-09 14:03         ` Legacy, Allain
2017-03-09 14:48         ` Legacy, Allain
2017-03-02  0:20     ` [dpdk-dev] [PATCH v3 09/16] net/avp: device configuration Allain Legacy
2017-03-02  0:20     ` [dpdk-dev] [PATCH v3 10/16] net/avp: queue setup and release Allain Legacy
2017-03-02  0:20     ` [dpdk-dev] [PATCH v3 11/16] net/avp: packet receive functions Allain Legacy
2017-03-02  0:20     ` [dpdk-dev] [PATCH v3 12/16] net/avp: packet transmit functions Allain Legacy
2017-03-02  0:20     ` [dpdk-dev] [PATCH v3 13/16] net/avp: device statistics operations Allain Legacy
2017-03-02  0:35       ` Stephen Hemminger
2017-03-09 13:48         ` Legacy, Allain
2017-03-02  0:20     ` [dpdk-dev] [PATCH v3 14/16] net/avp: device promiscuous functions Allain Legacy
2017-03-02  0:20     ` [dpdk-dev] [PATCH v3 15/16] net/avp: device start and stop operations Allain Legacy
2017-03-02  0:37       ` Stephen Hemminger
2017-03-09 13:49         ` Legacy, Allain
2017-03-02  0:20     ` [dpdk-dev] [PATCH v3 16/16] doc: adds information related to the AVP PMD Allain Legacy
2017-03-03 16:21       ` Vincent JARDIN
2017-03-13 19:17         ` Legacy, Allain
2017-03-13 19:16     ` [dpdk-dev] [PATCH v4 00/17] Wind River Systems " Allain Legacy
2017-03-13 19:16       ` [dpdk-dev] [PATCH v4 01/17] config: adds attributes for the " Allain Legacy
2017-03-13 19:16       ` [dpdk-dev] [PATCH v4 02/17] net/avp: public header files Allain Legacy
2017-03-13 19:16       ` [dpdk-dev] [PATCH v4 03/17] maintainers: claim responsibility for AVP PMD Allain Legacy
2017-03-13 19:16       ` [dpdk-dev] [PATCH v4 04/17] net/avp: add PMD version map file Allain Legacy
2017-03-16 14:52         ` Ferruh Yigit
2017-03-16 15:33           ` Legacy, Allain
2017-03-13 19:16       ` [dpdk-dev] [PATCH v4 05/17] net/avp: debug log macros Allain Legacy
2017-03-13 19:16       ` [dpdk-dev] [PATCH v4 06/17] drivers/net: adds driver makefiles for AVP PMD Allain Legacy
2017-03-13 19:16       ` [dpdk-dev] [PATCH v4 07/17] net/avp: driver registration Allain Legacy
2017-03-16 14:53         ` Ferruh Yigit
2017-03-16 15:37           ` Legacy, Allain
2017-03-13 19:16       ` [dpdk-dev] [PATCH v4 08/17] net/avp: device initialization Allain Legacy
2017-03-13 19:16       ` [dpdk-dev] [PATCH v4 09/17] net/avp: device configuration Allain Legacy
2017-03-13 19:16       ` [dpdk-dev] [PATCH v4 10/17] net/avp: queue setup and release Allain Legacy
2017-03-13 19:16       ` [dpdk-dev] [PATCH v4 11/17] net/avp: packet receive functions Allain Legacy
2017-03-13 19:16       ` [dpdk-dev] [PATCH v4 12/17] net/avp: packet transmit functions Allain Legacy
2017-03-13 19:16       ` [dpdk-dev] [PATCH v4 13/17] net/avp: device statistics operations Allain Legacy
2017-03-13 19:16       ` [dpdk-dev] [PATCH v4 14/17] net/avp: device promiscuous functions Allain Legacy
2017-03-13 19:16       ` [dpdk-dev] [PATCH v4 15/17] net/avp: device start and stop operations Allain Legacy
2017-03-13 19:16       ` [dpdk-dev] [PATCH v4 16/17] net/avp: migration interrupt handling Allain Legacy
2017-03-13 19:16       ` [dpdk-dev] [PATCH v4 17/17] doc: adds information related to the AVP PMD Allain Legacy
2017-03-16 14:53         ` Ferruh Yigit
2017-03-16 15:37           ` Legacy, Allain
2017-03-14 17:37       ` [dpdk-dev] [PATCH v4 00/17] Wind River Systems AVP PMD vs virtio? Vincent JARDIN
2017-03-15  4:10         ` O'Driscoll, Tim
2017-03-15 10:55           ` Thomas Monjalon
2017-03-15 14:02             ` Vincent JARDIN
2017-03-16  3:18               ` O'Driscoll, Tim
2017-03-16  8:52                 ` Francois Ozog
2017-03-16  9:51                   ` Wiles, Keith
2017-03-16 10:32                 ` Chas Williams
2017-03-16 18:09                   ` Francois Ozog
2017-03-15 11:29           ` Ferruh Yigit
2017-03-15 14:08             ` Vincent JARDIN
2017-03-15 18:18               ` Ferruh Yigit
2017-03-15 14:02           ` Vincent JARDIN
2017-03-15 14:02           ` Vincent JARDIN
2017-03-15 20:19             ` Wiles, Keith
2017-03-16 23:17           ` Stephen Hemminger
2017-03-16 23:41             ` [dpdk-dev] [PATCH v4 00/17] Wind River Systems AVP PMD vs virtio? - ivshmem is back Vincent JARDIN
2017-03-17  0:08               ` Wiles, Keith
2017-03-17  0:15                 ` O'Driscoll, Tim
2017-03-17  0:11               ` Wiles, Keith
2017-03-17  0:14                 ` Stephen Hemminger
2017-03-17  0:31                 ` Vincent JARDIN
2017-03-17  0:53                   ` Wiles, Keith
2017-03-17  8:48                     ` Thomas Monjalon
2017-03-17 10:15                       ` Legacy, Allain
2017-03-17 13:52                       ` Michael S. Tsirkin
2017-03-20 22:30                         ` Hobywan Kenoby
2017-03-21 11:06                           ` Thomas Monjalon
     [not found]                       ` <20170317093320.GA11116@stefanha-x1.localdomain>
2017-03-30  8:55                         ` Markus Armbruster
2017-03-23 11:23       ` [dpdk-dev] [PATCH v5 00/14] Wind River Systems AVP PMD Allain Legacy
2017-03-23 11:24         ` [dpdk-dev] [PATCH v5 01/14] drivers/net: adds AVP PMD base files Allain Legacy
2017-03-23 11:24         ` [dpdk-dev] [PATCH v5 02/14] net/avp: public header files Allain Legacy
2017-03-23 11:24         ` [dpdk-dev] [PATCH v5 03/14] net/avp: debug log macros Allain Legacy
2017-03-23 11:24         ` [dpdk-dev] [PATCH v5 04/14] net/avp: driver registration Allain Legacy
2017-03-23 11:24         ` [dpdk-dev] [PATCH v5 05/14] net/avp: device initialization Allain Legacy
2017-03-23 11:24         ` [dpdk-dev] [PATCH v5 06/14] net/avp: device configuration Allain Legacy
2017-03-23 11:24         ` [dpdk-dev] [PATCH v5 07/14] net/avp: queue setup and release Allain Legacy
2017-03-23 11:24         ` [dpdk-dev] [PATCH v5 08/14] net/avp: packet receive functions Allain Legacy
2017-03-23 11:24         ` [dpdk-dev] [PATCH v5 09/14] net/avp: packet transmit functions Allain Legacy
2017-03-23 11:24         ` [dpdk-dev] [PATCH v5 10/14] net/avp: device statistics operations Allain Legacy
2017-03-23 11:24         ` [dpdk-dev] [PATCH v5 11/14] net/avp: device promiscuous functions Allain Legacy
2017-03-23 11:24         ` [dpdk-dev] [PATCH v5 12/14] net/avp: device start and stop operations Allain Legacy
2017-03-23 11:24         ` [dpdk-dev] [PATCH v5 13/14] net/avp: migration interrupt handling Allain Legacy
2017-03-23 11:24         ` [dpdk-dev] [PATCH v5 14/14] doc: adds information related to the AVP PMD Allain Legacy
2017-03-23 14:18         ` [dpdk-dev] [PATCH v5 00/14] Wind River Systems " Ferruh Yigit
2017-03-23 18:28           ` Legacy, Allain
2017-03-23 20:35             ` Vincent Jardin
2017-03-28 11:53         ` [dpdk-dev] [PATCH v6 " Allain Legacy
2017-03-28 11:53           ` [dpdk-dev] [PATCH v6 01/14] drivers/net: adds AVP PMD base files Allain Legacy
2017-03-28 11:53           ` [dpdk-dev] [PATCH v6 02/14] net/avp: public header files Allain Legacy
2017-03-28 11:53           ` [dpdk-dev] [PATCH v6 03/14] net/avp: debug log macros Allain Legacy
2017-03-28 11:53           ` [dpdk-dev] [PATCH v6 04/14] net/avp: driver registration Allain Legacy
2017-03-28 11:54           ` [dpdk-dev] [PATCH v6 05/14] net/avp: device initialization Allain Legacy
2017-03-28 11:54           ` [dpdk-dev] [PATCH v6 06/14] net/avp: device configuration Allain Legacy
2017-03-29 10:28             ` Ferruh Yigit
2017-03-28 11:54           ` [dpdk-dev] [PATCH v6 07/14] net/avp: queue setup and release Allain Legacy
2017-03-28 11:54           ` [dpdk-dev] [PATCH v6 08/14] net/avp: packet receive functions Allain Legacy
2017-03-28 11:54           ` [dpdk-dev] [PATCH v6 09/14] net/avp: packet transmit functions Allain Legacy
2017-03-28 11:54           ` [dpdk-dev] [PATCH v6 10/14] net/avp: device statistics operations Allain Legacy
2017-03-28 11:54           ` [dpdk-dev] [PATCH v6 11/14] net/avp: device promiscuous functions Allain Legacy
2017-03-28 11:54           ` [dpdk-dev] [PATCH v6 12/14] net/avp: device start and stop operations Allain Legacy
2017-03-28 11:54           ` [dpdk-dev] [PATCH v6 13/14] net/avp: migration interrupt handling Allain Legacy
2017-03-28 11:54           ` [dpdk-dev] [PATCH v6 14/14] doc: adds information related to the AVP PMD Allain Legacy
2017-03-29 10:44           ` [dpdk-dev] [PATCH v6 00/14] Wind River Systems " Vincent JARDIN
2017-03-29 11:05             ` Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1488136143-116389-3-git-send-email-allain.legacy@windriver.com \
    --to=allain.legacy@windriver.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).