From patchwork Tue Nov 25 14:11:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cunming Liang X-Patchwork-Id: 1545 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id D15DA530A; Tue, 25 Nov 2014 15:01:35 +0100 (CET) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id DE8BB3975 for ; Tue, 25 Nov 2014 15:01:28 +0100 (CET) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP; 25 Nov 2014 06:04:44 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,862,1389772800"; d="scan'208";a="421268788" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by FMSMGA003.fm.intel.com with ESMTP; 25 Nov 2014 06:02:03 -0800 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id sAPEBl4H023471; Tue, 25 Nov 2014 22:11:47 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id sAPEBjxp024221; Tue, 25 Nov 2014 22:11:47 +0800 Received: (from cliang18@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id sAPEBj7e024217; Tue, 25 Nov 2014 22:11:45 +0800 From: Cunming Liang To: dev@dpdk.org Date: Tue, 25 Nov 2014 22:11:17 +0800 Message-Id: <1416924682-24170-2-git-send-email-cunming.liang@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1416924682-24170-1-git-send-email-cunming.liang@intel.com> References: <1416924682-24170-1-git-send-email-cunming.liang@intel.com> Subject: [dpdk-dev] [RFC PATCH 1/6] eal: common direct ring access API X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list 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" Signed-off-by: Cunming Liang --- lib/librte_eal/common/Makefile | 5 + lib/librte_eal/common/include/rte_pci_bifurc.h | 186 +++++++++++++++++++++++++ 2 files changed, 191 insertions(+) create mode 100644 lib/librte_eal/common/include/rte_pci_bifurc.h diff --git a/lib/librte_eal/common/Makefile b/lib/librte_eal/common/Makefile index 499ba4d..6b2e231 100644 --- a/lib/librte_eal/common/Makefile +++ b/lib/librte_eal/common/Makefile @@ -52,6 +52,11 @@ GENERIC_INC += rte_spinlock.h rte_memcpy.h rte_cpuflags.h ARCH_DIR ?= $(RTE_ARCH) ARCH_INC := $(notdir $(wildcard $(RTE_SDK)/lib/librte_eal/common/include/arch/$(ARCH_DIR)/*.h)) +ifeq ($(CONFIG_RTE_LIBRTE_EAL_LINUXAPP),y) +INC += rte_pci_bifurc.h +endif + + SYMLINK-$(CONFIG_RTE_LIBRTE_EAL)-include := $(addprefix include/,$(INC)) SYMLINK-$(CONFIG_RTE_LIBRTE_EAL)-include += \ $(addprefix include/arch/$(ARCH_DIR)/,$(ARCH_INC)) diff --git a/lib/librte_eal/common/include/rte_pci_bifurc.h b/lib/librte_eal/common/include/rte_pci_bifurc.h new file mode 100644 index 0000000..ad93124 --- /dev/null +++ b/lib/librte_eal/common/include/rte_pci_bifurc.h @@ -0,0 +1,186 @@ +/*- + * BSD LICENSE + * + * 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 + * 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_PCI_BIFURC_H_ +#define _RTE_PCI_BIFURC_H_ + +/** + * @file + * + * RTE PCI BIFURC Interface + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + + +/** + * Open a socket for direct ring access. + * For those socket API support direct ring access, + * it opens a socket for such address family. + * + * @param sockfd + * A pinter to socket file descriptor to get the open sockfd. + * @return + * 0 on success, negative on error. + * + */ +int rte_eal_bifurc_open(int *sockfd); + +/** + * Bind a net interface to specific socket for direct ring access. + * + * @param sockfd + * The Socket file descriptor to bind the net interface with. + * @param if_index + * The net interface used for direct ring access. + * @return + * 0 on success, negative on error. + */ +int rte_eal_bifurc_bind(int sockfd, int if_index); + +/** + * Map ring specific register space for direct access. + * + * @param sockfd + * The socket file descriptor to get the ring address mapping from. + * @param addr + * The pointer to the virtual address got from mapping. + * @param size + * The pointer to the memory size. + * @return + * 0 on success, negative on error. + */ +int rte_eal_bifurc_map(int sockfd, void **addr, uint32_t *size); + +/** + * Unmap ring specific register space for direct access. + * + * @param sockfd + * The socket file descriptor to release the ring address mapping. + * @param addr + * The unmap virtual address. + */ +void rte_eal_bifurc_unmap(int sockfd, void *addr); + +/** + * Split the ring pairs from the net device. + * For those net device support direct ring access, + * will split the ring and exclusively reserve the resource. + * + * @param sockfd + * The socket fd owns the split ring resource. + * @param nb_qp + * Request number of queue pair. + * @param qp_start + * The first queue pair id. + * @return + * 0 on success, negative on error. + */ +int rte_eal_bifurc_split(int sockfd, uint32_t *nb_qp, uint32_t *qp_start); + +/** + * Retire the ring pairs to the net device. + * + * @param sockfd + * The socket fd owns the ring resource. + * @param nb_qp + * Request number of queue pair. + * @param qp_start + * The first queue pair id. + */ +void rte_eal_bifurc_retire(int sockfd, uint32_t nb_qp, uint32_t qp_start); + +/** + * Utility function to initial pci info in rte_pci_device by net device. + * + * @param sockfd + * The socket fd stands for the binding net device. + * @param pci_dev + * The pointer of pci device to hook with the net device. + * @return + * 0 on success, negative on error. + */ +int rte_eal_bifurc_set_pci(int sockfd, struct rte_pci_device *pci_dev); + +/** + * Utility function to get net interface info by iface name. + * + * @param sockfd + * The socket fd which already bind with the net device. + * @param iface_name + * The string for iface name. + * @param if_index + * The pointer to the index of such net interface/device. + * @param hwaddr + * The pointer to the MAC address of such net device. + * @param mtu + * The pointer to the MTU os such net device. + * @return + * 0 on success, negative on error. + */ +int rte_eal_bifurc_get_ifinfo(int sockfd, char *iface_name, + int *if_index, uint8_t *hwaddr, int *mtu); + +/** + * Utility function to get/alloc a devargs instance. + * + * @param drv_name + * The string of driver name in devargs. + * @param args + * The args in devargs. + * @return + * 0 on success, negative on error. + */ +struct rte_devargs * +rte_eal_bifurc_get_devargs(const char *drv_name, const char *args); + +/** + * Utility function to free the devargs instance. + * + * @param devargs + * The devargs instance to free. + * + */ +void rte_eal_bifurc_put_devargs(struct rte_devargs *devargs); + + +#ifdef __cplusplus +} +#endif + +#endif /* _RTE_PCI_BIFURC_H_ */