From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0042.outbound.protection.outlook.com [104.47.40.42]) by dpdk.org (Postfix) with ESMTP id 652BD6CB5 for ; Thu, 2 Mar 2017 12:37:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=LMsGNRaMwcbpnkCef6jwzDuCwwraN6B1E8dYKrNRm7c=; b=j5t5bi/E7PorJ9I7csfP3SrAlA0PV/Panhhrss32Ia2zTEpd1MPQ8cPdx3Bnj9Q83p5SCp+q6RnnnuIjNJbKovMgjLFfTRDqBZBdma/QyKU2Xs/LSo8nFG9G5a7NxkMs847iISGo9nygUNG8KCy4kvtxhmuYwY7Wunh1HXjhMGI= Authentication-Results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=caviumnetworks.com; Received: from lio357.in.caveonetworks.com (14.140.2.178) by CY1PR07MB2277.namprd07.prod.outlook.com (10.164.112.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.947.12; Thu, 2 Mar 2017 11:37:53 +0000 From: Shijith Thotton To: ferruh.yigit@intel.com Cc: dev@dpdk.org, Jerin Jacob , Derek Chickles , Venkat Koppula , Srisivasubramanian S , Mallesham Jatharakonda Date: Thu, 2 Mar 2017 17:02:09 +0530 Message-Id: <1488454371-3342-5-git-send-email-shijith.thotton@caviumnetworks.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1488454371-3342-1-git-send-email-shijith.thotton@caviumnetworks.com> References: <1487669225-30091-1-git-send-email-shijith.thotton@caviumnetworks.com> <1488454371-3342-1-git-send-email-shijith.thotton@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [14.140.2.178] X-ClientProxiedBy: BM1PR01CA0021.INDPRD01.PROD.OUTLOOK.COM (10.163.198.156) To CY1PR07MB2277.namprd07.prod.outlook.com (10.164.112.155) X-MS-Office365-Filtering-Correlation-Id: 906428d2-13c8-481a-c48c-08d461609282 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:CY1PR07MB2277; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2277; 3:7yLcStZA516Mjpr3KNSLazLmX8eweSXsfGhrdQXZCiEzu2+hLDYYkpd9srJN4eTgGgA3GPOaF6a32UWTtjaQhaxxU3mxb1+D2MpwirnK/ZURbsKi89YrE4hbSOONlGpMw2WGvKTjBj4k8cLUHjVe5h1whqFo+zd4SnW+DtjN+aL5xdt/svH/Qb+x5i48ERG5N1dVrFyCzEOc39D9oNhmPXElUeDfEPZYgUYp+jgM3+mLttw44PVahS6J0m79NtXPv6dGkWXOvmkNBvsm3yl6Iw==; 25:FP05dyOru7D934JXimRu/PBbyWVg+eznAwiNeyjEs4nlEwgfpPsl2BLI/y8zleXh+25N9eIQA0sbNYKrW8tkCYxBizJ0UUKfeHkbO6G5SxRy94OAVCVf9/5e+ZTGGBjT4DUgk38x+2/BynCRFTsWAHac3uj9YLm9jn8Nw7+jH3ObWdmm4f6Q5O5xJ1LW5aS7fJLllwlDWHFZcK6SpftKPVRhF+3oiUpRArX8N5vwgrtmJe89zLZVovj841RvD91+GIxstNYbYXpYk+dp5942uu1rwSlIxMyq5qP2hpYnA7VzgYLfgLNaOaQfPwgPUPrnKAhULSz2R+oWxa08CBa0th3i9LAQb6ryPPmZ8tU0GSqy2sOkmLi6zez58ks9ifNARIYDA6AuphPpGehJSukEA33q/47EFfyeye97ivmKG2weHkm1EWTeLh668GNP9d49d5c6FaH4wEl7jwrE9K0IsQ== X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2277; 31:Id0R9YocTc5vyBYrkX9P9owsUe4zRWmMvr+b7KarjufjLBGG2U47hC7KHNQDBYt/J4Z0TsBkSWnj2VUXiyW3bOTBWsP7DAhxhs8gv2IrQ0ijaNitBkJYWIOkbypScm8SWErBpneBAaku9cGYJA+lTadFxzZaKYq7t/7NftL4svJRHbhQHHEzsqYu2PVcc5wd2HQZFV+GlONgJjPJwulpg0U9oJfxmavActq/7ttOz4U=; 20:2pLepGqs2/y9Ynmivt5pwc0G8SCBHah8yJEq31qSR05ow1B1z1DrbXr1bR6ZYo+vcSLOn1rKcXOKBC0JR0bQ31b2zmYiqhCRQdwK+Vrepr6W9yCoWBZna2PKkhXJt8cueXuMoHz03tj5qvZoj5KLFQ5W1B+eX6OjlZ7PYPVEdFKeCIC3ZVcUUsgUymu9aZr9d4Ha71iWOVePplDCKE1GLgBm7YwKPDFDXlZdeX0dbiCetPOuEVaXiGsOewuUXrmgdLi3rMBaFOff4Hfjmv48rZ/v98wVCmNfMBcIe3KkBE+BGbGJgYzDl61tdW7Iim/FCMjMVgGeHtqqEuH3Rl1lyNw2BIJ5s4/2qz//oqsg6SwhNVHm2vNr/sswuOIOC0jgMiSm81h8GGLNRmbFg4zljl2i5+7WlnD7UBumfd1yNJc1HGYV7mjSIk1BN4qWYBNmXZeYe5RJ5gsoQsiTlS9cyD8lWziXNTf07MCm+PxWToTpkHrLNCuComH1dklRGb33YAJj9ls4cSiloA4LGiQZewu2kU9B8J1r0K028CjtsAERe+R/tHHbsGYZIw1sXvcQn1L6QUZ4XzbAK+BgL3w2NwLXGjb/V9ks0SzPkg29Phw= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(6041248)(20161123558025)(20161123555025)(20161123560025)(20161123564025)(20161123562025)(6072148); SRVR:CY1PR07MB2277; BCL:0; PCL:0; RULEID:; SRVR:CY1PR07MB2277; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2277; 4:bWxAWDW06MfZLmyvuj3Xgg6pMDm9eCsp2S7rXs4sCsgaMRY4vpG4qPBdfQbGdsR8JuSzlggE28nU2XFAFv0uN+WRn1tIs3sHEV8uU+VQL8XR7YHKRQR7t4rJaXQa7E5+4uiHajJpcjshlmDkD8fHA9XqnePA8NEu7yKjWhIdLBBN/L/I9iLCdAG6C1/CWKdjnYSt88p0yHBtnlQOOoToLqta38h3NLzUIQ+rR7RvYkiVZCGIHVyxaaMDd0RQJ66K79JCbvLv59JOOs7t3+h4riZhq92bNpV0STXMxwJ7O90tuNo5lwRHIH8OikjkilmlMm4w+DH2r7AY102Zfh7bwWvyVlSfo0CGhRMwlJ1T4GWE39dt6BsXq4FkmVDXEi2QA4NEwhluJIC1+KT0VExoXe0Te6P/bgfxW5mixgWVoHl/0WLIFoQRKp1hS7bjR6gTA3AsBDF8A5P8Ur8p6P0wB954i7lbx05mjv7f5g2dxexTmHtbi2KD9q7EAVXTR7nCqKWbyGLjjk7Q1QD7Uxwd+0sqCxc4G5DDejgBqGoFiuJl2Qv4ia2VwG7mrVZSVEPL7JCJF+H4nT7D8sPbTETuhbKtZNQVqrOgka2WwUlhkSk= X-Forefront-PRVS: 023495660C X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(7916002)(39450400003)(31430400001)(2950100002)(6916009)(42882006)(5660300001)(92566002)(4720700003)(33646002)(48376002)(50226002)(6666003)(2906002)(5003940100001)(36756003)(8676002)(50466002)(81166006)(110136004)(38730400002)(4326008)(305945005)(2361001)(53936002)(2351001)(25786008)(6512007)(189998001)(54906002)(47776003)(6506006)(6486002)(66066001)(6116002)(3846002)(50986999)(76176999)(5009440100003)(42186005)(7736002)(7099028)(110426004); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR07MB2277; H:lio357.in.caveonetworks.com; FPR:; SPF:None; MLV:nov; PTR:InfoNoRecords; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR07MB2277; 23:bEYAobwVQsR3T2Yk1S7V0R3ASvhN4zTr5hUmJoL4g?= =?us-ascii?Q?ChaHQRucR0pdRYMZah0EwvakqqvAr8JDObWNvbXZ08QwzOfQOp+dKNuw4TaH?= =?us-ascii?Q?6yapSM92MVmK+F9D2rRSVL9Mq4O6Dh8us11AZhQ8j8PmzADKqQBLxAobxVAl?= =?us-ascii?Q?uV5mxxUvghhg//iz1oT+MXNhBmTMvPWTBrLLh1LVpUGzRBolgLSHYH8fap6b?= =?us-ascii?Q?xLAD3/g+MvoTToDJGXPV2gRf9GWCrpVJ2aXSHZXXHf8SRUnom0J1Ch0r16M3?= =?us-ascii?Q?TomEZCqzFuPaz+ByfJevmxe9KM1OYME6VdsSLBO12j8f3QqDX2iOXt68Kh1R?= =?us-ascii?Q?0M106bHuMqsk62sV9C3qkLdTeJIW+3T4QO6HfIXYQ2lT2iKHAibDFTDKl/NP?= =?us-ascii?Q?x8iljEY/kPIRMwB/chPrL6Hqokqcunh0i7p7ism+bIb5Kz0OrptmJx0EsTd9?= =?us-ascii?Q?DBALglyowsIof6CmJ7WuGPGzBgYQkOESmYtpNEcsn7IlszMc4/YnmSYQznb1?= =?us-ascii?Q?E9DdZfnJsuNzw5Wvo6UKCYMBRZj2WlP4LIZoKOjeg6gPIhHnBW10GIiMmjzq?= =?us-ascii?Q?6qEuaTaTxcVCR1jaKJO888Ch6nKV3zMSY8aZuMRaOoYFWyME1D6fj+XgOXeO?= =?us-ascii?Q?BiJ/W828MdICr+ua4DzYanv2g9znuSr0g0fqT0Z0qYQm4aZh0XmNhAtFseH5?= =?us-ascii?Q?sx1FWlt66L+CjNW6HzLbOfHk66oS73ppwZHyNKg/y0nFdb7GSjkCYgwdgmms?= =?us-ascii?Q?Z4ayNzssAqetB356UVhyrGRD3XP/1+G+qXH+s+XL4CTRWCuG8rAy0SwUlmIS?= =?us-ascii?Q?Y7OsjoMh8pZIB7V2AxHGUF/xxZ9qqnPMrD/iZgIr7bd4MR3eIE5YMPqDkiNr?= =?us-ascii?Q?gNZvAppATCUbEYvJ9iYOxImdX0tasajLCG3uK+vnWv0IbKLDZ2WLV1GQZAQj?= =?us-ascii?Q?xhDPlLicLB1ziow+DCE0crBblBaKu3NXs5zxpCaq7v6RAGru0VaC4VSBUClE?= =?us-ascii?Q?iARf/2b9oFAoEhFOtJFZRmx89DKE3fbRkA9xWLzzj3RsBkao1n5tTIkdZhf0?= =?us-ascii?Q?+Pcvg0rALbxUmLgd/fNF0bDUAc8eHs7uj2GgV6mwyIu38xrO9a7GILWbNCQn?= =?us-ascii?Q?NKF9ciSUwY=3D?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2277; 6:okqYCOyBJPALWv263juwWWJlUtA52hKFuEo7Y6IZ1H59LoJJxN2hcQDy0JCN9b35TdjckorKsxsKJY3OGNMfFMAW70LD7m6lvakmPhUjPjydI1zEvauBRbw0unv5xByfgkgIYJP0+pOx5XgY0w2j24e8ZKeueU5Wi4XmVPHgbss1QI25Pfe1rHWykIe1570DGd3TopuBoBG0zPVjR0hVaPxMNCIbPB2zwRP89QltklQT6DlL89YkQtxhoxNGxBlTu/p1hQsiVcfh7ePE4+rBJkof67EBYic4FvTb51t1+LGpgZs7Yvpxc3wrxIExLqeiNnPqVIKz62i1JQUZHN4iV/gdJaoc86BYaxQeBV/nScRLKzqOgfNxhgG1BiiqcOCt3tWDYD32Dl8xK0feTTsNjg==; 5:u2sSKU+5bExp5iXhbu9ZKnILxot4nGiT4uyPzNFphcfOZrzjNtvVNHnem2h/A/gfm4AujZtTjdZLRFstq5JXYYZDCfIV8wItsXglLkFeqS35vaNtKx05z2xwHzC9zkJ6H9o7vj3ymAdJdWmRAPKwgg==; 24:1n4hTumnm6HgN+cZaEBARPjuQlltE0XVPDsouWqMuFRrA6IErxq3/cutCtAk9bql/wS7Vqdkdlbb7y4CyI3I+sTigubnjlPm9pk9o+u0+TQ= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2277; 7:Pdk4cStJMLJkjm9Guxsss1ysb9B/v9XH21RGPVh9fPeM9KxM87Eyw4W07UslA3vWUkUdjuCSRX8WDkqNd/KNuZjyzGss46B3sZDDaPe0/LCO1DcKSNIIdnoLkZ0P+6eQlfhId9S17H8RtEvjgYjNxkrkNREgBOqTNXTkFMS8K+4yJPXUZthG3MdmVQX61/oO3irwQbwYatFjlrhd8EzXfHaDPwMossdHs+o1cMx8nferkwZ4vKub8UvihAggyVGOY+fNPz9ofqAWtPgwYhJ7j06t1HKczIsAMbgKereOaASaRRYhLGW4U2tP6G+Y7NWLUwItnu3wCzY9MSFdX7NDdA== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Mar 2017 11:37:53.6848 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB2277 Subject: [dpdk-dev] [PATCH v2 04/46] net/liquidio: liquidio VF PMD driver registration X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Mar 2017 11:37:59 -0000 Register LiquidIO PMD (net_liovf) and define APIs to init and uninit. Signed-off-by: Shijith Thotton Signed-off-by: Jerin Jacob Signed-off-by: Derek Chickles Signed-off-by: Venkat Koppula Signed-off-by: Srisivasubramanian S Signed-off-by: Mallesham Jatharakonda --- drivers/net/liquidio/Makefile | 2 +- drivers/net/liquidio/base/lio_hw_defs.h | 44 ++++++++++++ drivers/net/liquidio/lio_ethdev.c | 117 ++++++++++++++++++++++++++++++++ drivers/net/liquidio/lio_ethdev.h | 40 +++++++++++ drivers/net/liquidio/lio_struct.h | 65 ++++++++++++++++++ 5 files changed, 267 insertions(+), 1 deletion(-) create mode 100644 drivers/net/liquidio/base/lio_hw_defs.h create mode 100644 drivers/net/liquidio/lio_ethdev.c create mode 100644 drivers/net/liquidio/lio_ethdev.h create mode 100644 drivers/net/liquidio/lio_struct.h diff --git a/drivers/net/liquidio/Makefile b/drivers/net/liquidio/Makefile index ce2b7fc..25685a7 100644 --- a/drivers/net/liquidio/Makefile +++ b/drivers/net/liquidio/Makefile @@ -50,7 +50,7 @@ VPATH += $(RTE_SDK)/drivers/net/liquidio/base # # all source are stored in SRCS-y # -SRCS-$(CONFIG_RTE_LIBRTE_LIO_PMD) += +SRCS-$(CONFIG_RTE_LIBRTE_LIO_PMD) += lio_ethdev.c # this lib depends upon: DEPDIRS-$(CONFIG_RTE_LIBRTE_LIO_PMD) += lib/librte_eal lib/librte_ether diff --git a/drivers/net/liquidio/base/lio_hw_defs.h b/drivers/net/liquidio/base/lio_hw_defs.h new file mode 100644 index 0000000..db42f3e --- /dev/null +++ b/drivers/net/liquidio/base/lio_hw_defs.h @@ -0,0 +1,44 @@ +/* + * BSD LICENSE + * + * Copyright(c) 2017 Cavium, 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 Cavium, Inc. 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(S) 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 _LIO_HW_DEFS_H_ +#define _LIO_HW_DEFS_H_ + +#ifndef PCI_VENDOR_ID_CAVIUM +#define PCI_VENDOR_ID_CAVIUM 0x177D +#endif + +#define LIO_CN23XX_VF_VID 0x9712 + +#define LIO_DEVICE_NAME_LEN 32 +#endif /* _LIO_HW_DEFS_H_ */ diff --git a/drivers/net/liquidio/lio_ethdev.c b/drivers/net/liquidio/lio_ethdev.c new file mode 100644 index 0000000..49efede --- /dev/null +++ b/drivers/net/liquidio/lio_ethdev.c @@ -0,0 +1,117 @@ +/* + * BSD LICENSE + * + * Copyright(c) 2017 Cavium, 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 Cavium, Inc. 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(S) 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. + */ + +#include +#include +#include +#include + +#include "lio_logs.h" +#include "lio_struct.h" +#include "lio_ethdev.h" + +static int +lio_eth_dev_uninit(struct rte_eth_dev *eth_dev) +{ + PMD_INIT_FUNC_TRACE(); + + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return -EPERM; + + rte_free(eth_dev->data->mac_addrs); + eth_dev->data->mac_addrs = NULL; + + return 0; +} + +static int +lio_eth_dev_init(struct rte_eth_dev *eth_dev) +{ + struct rte_pci_device *pdev = RTE_DEV_TO_PCI(eth_dev->device); + struct lio_device *lio_dev = LIO_DEV(eth_dev); + + PMD_INIT_FUNC_TRACE(); + + /* Primary does the initialization. */ + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return 0; + + rte_eth_copy_pci_info(eth_dev, pdev); + eth_dev->data->dev_flags |= RTE_ETH_DEV_DETACHABLE; + + if (pdev->mem_resource[0].addr) { + lio_dev->hw_addr = pdev->mem_resource[0].addr; + } else { + PMD_INIT_LOG(ERR, "ERROR: Failed to map BAR0\n"); + return -ENODEV; + } + + lio_dev->eth_dev = eth_dev; + /* set lio device print string */ + snprintf(lio_dev->dev_string, sizeof(lio_dev->dev_string), + "%s[%02x:%02x.%x]", pdev->driver->driver.name, + pdev->addr.bus, pdev->addr.devid, pdev->addr.function); + + lio_dev->port_id = eth_dev->data->port_id; + + eth_dev->data->mac_addrs = rte_zmalloc("lio", ETHER_ADDR_LEN, 0); + if (eth_dev->data->mac_addrs == NULL) { + lio_dev_err(lio_dev, + "MAC addresses memory allocation failed\n"); + return -ENOMEM; + } + + return 0; +} + +/* Set of PCI devices this driver supports */ +static const struct rte_pci_id pci_id_liovf_map[] = { + { RTE_PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, LIO_CN23XX_VF_VID) }, + { .vendor_id = 0, /* sentinel */ } +}; + +static struct eth_driver rte_liovf_pmd = { + .pci_drv = { + .id_table = pci_id_liovf_map, + .drv_flags = RTE_PCI_DRV_NEED_MAPPING, + .probe = rte_eth_dev_pci_probe, + .remove = rte_eth_dev_pci_remove, + }, + .eth_dev_init = lio_eth_dev_init, + .eth_dev_uninit = lio_eth_dev_uninit, + .dev_private_size = sizeof(struct lio_device), +}; + +RTE_PMD_REGISTER_PCI(net_liovf, rte_liovf_pmd.pci_drv); +RTE_PMD_REGISTER_PCI_TABLE(net_liovf, pci_id_liovf_map); +RTE_PMD_REGISTER_KMOD_DEP(net_liovf, "* igb_uio | vfio"); diff --git a/drivers/net/liquidio/lio_ethdev.h b/drivers/net/liquidio/lio_ethdev.h new file mode 100644 index 0000000..76c9072 --- /dev/null +++ b/drivers/net/liquidio/lio_ethdev.h @@ -0,0 +1,40 @@ +/* + * BSD LICENSE + * + * Copyright(c) 2017 Cavium, 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 Cavium, Inc. 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(S) 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 _LIO_ETHDEV_H_ +#define _LIO_ETHDEV_H_ + +#include + +#define LIO_DEV(_eth_dev) ((_eth_dev)->data->dev_private) +#endif /* _LIO_ETHDEV_H_ */ diff --git a/drivers/net/liquidio/lio_struct.h b/drivers/net/liquidio/lio_struct.h new file mode 100644 index 0000000..dcf99ce --- /dev/null +++ b/drivers/net/liquidio/lio_struct.h @@ -0,0 +1,65 @@ +/* + * BSD LICENSE + * + * Copyright(c) 2017 Cavium, 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 Cavium, Inc. 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(S) 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 _LIO_STRUCT_H_ +#define _LIO_STRUCT_H_ + +#include +#include +#include + +#include +#include + +#include "lio_hw_defs.h" + +/* ----------------------- THE LIO DEVICE --------------------------- */ +/** The lio device. + * Each lio device has this structure to represent all its + * components. + */ +struct lio_device { + uint8_t *hw_addr; + + char dev_string[LIO_DEVICE_NAME_LEN]; /* Device print string */ + + struct rte_eth_dev *eth_dev; + + uint8_t max_rx_queues; + uint8_t max_tx_queues; + uint8_t nb_rx_queues; + uint8_t nb_tx_queues; + uint8_t port_configured; + uint8_t port_id; +}; +#endif /* _LIO_STRUCT_H_ */ -- 1.8.3.1