From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0063.outbound.protection.outlook.com [104.47.33.63]) by dpdk.org (Postfix) with ESMTP id 86937D45E for ; Sat, 25 Mar 2017 07:27:06 +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=ySEOEVRpS/iFl0siLf3If3fAAy2cu8Q6wnCVELU4QqA=; b=CIaTuf/EqvPd6pntH9/9YxlSAGTCx38ygNkraApSgOM+kWRpbOTOzBqjXOFF4dkpK9uDXShc5pp3JtVPfmlgAyxXCsE8ly1+U68D8IADtrPrT54V+SFYTB3Tn6Vyjtz2jSPREg4ysqtsuAtcCepCcgNt7OZzLqtRvFP3c8jY3Do= 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 CY1PR07MB2280.namprd07.prod.outlook.com (10.164.112.158) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.977.11; Sat, 25 Mar 2017 06:27:01 +0000 From: Shijith Thotton To: Ferruh Yigit Cc: dev@dpdk.org, Jerin Jacob , Derek Chickles , Venkat Koppula , Srisivasubramanian S , Mallesham Jatharakonda Date: Sat, 25 Mar 2017 11:54:15 +0530 Message-Id: <1490423097-6797-5-git-send-email-shijith.thotton@caviumnetworks.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1490423097-6797-1-git-send-email-shijith.thotton@caviumnetworks.com> References: <1488454371-3342-1-git-send-email-shijith.thotton@caviumnetworks.com> <1490423097-6797-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: BM1PR01CA0117.INDPRD01.PROD.OUTLOOK.COM (10.174.208.33) To CY1PR07MB2280.namprd07.prod.outlook.com (10.164.112.158) X-MS-Office365-Filtering-Correlation-Id: 2c0e1dbe-0662-4d7e-9545-08d47347f47e X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:CY1PR07MB2280; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2280; 3:l2QEdC1v2oKr8HMU/dvYuOqbC5z19WLFX0r7C97zK2rh0/eNgK4NvuKkN13oK3rlfvM4csPk4Y7VIy4SWQD50krBGqPTXSna7I6M0IF7MX4EdMiYCF4O+QXaPAaXEZwtX5cM/HiMZlUvl/FEF7ye8vQWLrhXqXm+HuwlzL1f6eAb+i0e4Yq8aSKfJOQ5T0MpcgfN7SEcj2Kqv2j99+wdku+OBvGC5A+EQaLIWoNsHY+RXEGHKWMQvDjBFib/ZJjeXHb1r3fOOOJMsGy5YoJDBA==; 25:81KVcAz6EcYY9oS4k8koa/1Y/eSi/sPDFlmtGEnTqOnvIGPW8nKiPQ8kaA55sy8r/FVnc+nXmFCZxWTjEcVGnK/KnS305q5I8wqugVjMUdDeVAeYW4xVj4Ix4Y9pVlmrdIHUTVq4m0EUY6yJlCZjGKHwMlPZJleWEcnfSdI2axhZArEmv1FL7B/GvKYQ6EX0e3tXpEXisRgk82h4buWU0osahT9IF+RYbFQ19tg2SHIc4+Mnx9OK8CTeHtGuSvSXQh09mbXEsYblp+nifh5O3Uld5ltFqX2OiAaDqUvuC39vD99QKYoH3a0bWy7E0SiPWpVUfR8bIT3sk1etoGZkmfp2rNCkwzDCoFObNeg/39tj1EI7ZwHHWzQsu/Wt45izJjcGau4z/yZ1LPv0ibwkLhZ9BIhHzNEHKshcXbDtjANilXADdzsFMuV0IYfMgMvwP8twrNalsqVT7pNcL0WXzQ== X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2280; 31:9Wvs0gXxY2IYBuWZSmGwo89XB9NUcNMJCKNjCoqgN6CUfTFq7SLhjdBKDBI+OST5BuX7df/95/YbJXTj10K1klFd/ATSzZsIf3LfjiI7J2TDEM/OIHfL/FJcrqkOK4q6da5OJ9+TTgxTIdPJRP5AelNQlz/SRxobjYNdNw+tAeP8ESBg1bHFbP7z5WLI1SqDv0S1cdvPRmzoYIJ9zAjHY1QX0qnOf7KNYqUEph5P0ec=; 20:6k29q8k693Cvm1vpm5Daj4vShJ5pdyv3KLhDPDIKMv8XI4nOTLSdU0Ag9XFTPRhcA8uVXtJedVcOzHRx+ygwzoYY7UDcZi/KmMnPLe4pOcDvQZfxue90/dp8XOSpTl1IrGsGrM+Ai6rC8ZWR88HeWh7WsxaXx3qmCxZvs/B60khCQ2ie/c3JbJj49UqaRrP1JKUIY1WxCQUzHV3d+Qx3/NsE8yhDYjjHyjyx/QMFMtu22gQ/FxPEUmNQ7CeGGRfj56tV4eKHhKawz4xNszqks8CNcxnXnxXEzJ18dmVkbdjMl3JCg6e/8B6qtOCB4bquBRFxDEd6hkCijnmUXumgAOukd93jP8TUtsbjzISSb0xjrjiRntYc51XsvNG1LGjQMQzhYqY6vyJh6hg8m8JBrYiOc+xTdtDiZHKaCUpfTXSxjTYYaOuR539y80FUWrSbW4pe2e2hpY0ug/s/rE/qy6pBWf4hVhJnlkNo3so9VymGWa91yZBBgzPuSoyNWKdUfEXzPwDGsTlgJPumW4SGVjxSf2wt7rfJkNCfKiuDkTYW036/+Frg68SHWQFrSOW6MsWeLqriJoL4ftwJ2qOhW26pdK9swEh5gnh4+B8Oo28= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6041248)(20161123564025)(20161123560025)(20161123562025)(20161123558025)(20161123555025)(6072148); SRVR:CY1PR07MB2280; BCL:0; PCL:0; RULEID:; SRVR:CY1PR07MB2280; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2280; 4:vO7Erm2wkRB215ggevFnCyfr68jNk7buTU2/lBmFqT0xaWy7NTQu4IRO73C9fvwJLebetMTZvdkkavheQoiMRo1lxACarkxkVOekgbGSakj+RMc4lDxHOC9AZKBvNNXkB4y4qUMDonohrCgFUPmyWtVqc0y4WAabeKvWrwAgxrtMxDj6LaoDw5Gunjg5rtOFuJIJeXAas93Bjs2wU1vWx2L7ew7yD0X39yFo7YjNnp7igf0v5otLbU0w8i50PURmRwGS79IJA+yNz82t+HWRhKke5k2XDEKB80L5kjn4Im9Ql6jmKE7l58YWhFq9fnmyajlxCTTY2IhZmb7Jfu6uXJzcT4kHktMhua+DQ71bQPO1EIozjfu3o9YZJ4begjxDeEzrja3yhrbzLPnX6AzG0UmDwzfK0+CaBVsX5heqg2IYFPfS0NzbcJ0m/Z98tVwH+LDlobVUPfPJVjRszKQCmw/htDLYuzedR4aX0z8vgtRvSqeN0MPsyZJXIA5hDqei1iDeQEWnP846/cZgLWBQRBkvl2bpF9z1PdKOkcyJnoayRIYgPc1/FvnIEFC2KgeiBQZunFKItXpeUnj4Tr4Wu0HYlcdRLepy89Kj2KSdk5U= X-Forefront-PRVS: 025796F161 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(39450400003)(39410400002)(39830400002)(2906002)(2950100002)(5003940100001)(66066001)(42882006)(6916009)(50466002)(48376002)(47776003)(42186005)(53936002)(6512007)(68736007)(5009440100003)(54906002)(50226002)(38730400002)(6486002)(6666003)(25786009)(305945005)(81166006)(7736002)(6116002)(3846002)(4326008)(8676002)(6506006)(189998001)(36756003)(50986999)(76176999)(33646002)(4720700003)(5660300001)(110136004)(110426004); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR07MB2280; H:lio357.in.caveonetworks.com; FPR:; SPF:None; MLV:nov; PTR:InfoNoRecords; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR07MB2280; 23:4/gI9nslxZpTRYWegzRdY9bUw647UlVa6fB9BiZRI?= =?us-ascii?Q?UgJN2hZW/P+bQG+1zNrtReQMT7EyUpVxhfCVCg54IsSzrQYjHgrF6nj2GcmE?= =?us-ascii?Q?GQEnkmfMj+CQ8Cy1K9/p9HaQzIXSPtq1swgvMX1hd0Ngp8YyGD7h4dIoIxSu?= =?us-ascii?Q?+adzLzOHPOuo2C1lQI+WZrRe6keivwuSjb4/JW83fyRC8H4On9D/AKp/OSzN?= =?us-ascii?Q?yxmXS/5zQBmpji7ZZTCcgbHgxchpTFjF629L9euCXQWUy2uLI9nl0QhBv637?= =?us-ascii?Q?2NfSYrrMyBb91Y1/mxkftkDX7CVjqg6/0vWYoS/jJ9apAdNuquNpP/fXmNkh?= =?us-ascii?Q?PEXjJ+bmd7kcLmRJQse4eEAn/bw3vZOhyF+iBU5Do3N08Ba6ucDt1tfw5kAv?= =?us-ascii?Q?EBuv3A+Ff0E8RKNrwMlHupKUXiXwG9abwldpA4JfvFiEDnNt6/KGFW0KaUET?= =?us-ascii?Q?y/sweX8ED3cJ1ANBMtpWz1Ek1yqr2fz3hOmqDEpWeUlRgzomyM+H5fX2EDUB?= =?us-ascii?Q?T0+P8j/xW2zIta8ORBJXQppWf2KVAD4v4tMyJPCKS8R22YDki4Zul8S6CKVg?= =?us-ascii?Q?U2+EvOEXpzQ7eNhklscP+rlIuhgxZNldxVNVA2rUif229ydZZYMRC6nXcMGz?= =?us-ascii?Q?Ncee9JxKx8NLKzNNUH0/QPLIyYca7QrgRCTmHltFpqpumF8JM8jizES/TpxT?= =?us-ascii?Q?Z6cpbCmXbgiMaPlEC498QbUxynr+NxtVVv6TzXY9kLVHH0yPsqnpFyh3Abws?= =?us-ascii?Q?mDNJuDzjUzIUbk0MyZMfMgIweB0zE8ixYMWGcVk5f8sZz0IfXzXuy/LQV8QB?= =?us-ascii?Q?oe74puQd8gWeBCz/KP7PxpYXG3aoEy/aVq+jDtttuwK33oQCROSZeMshlC60?= =?us-ascii?Q?vxjf7pDam6wRVtTDdVzfncCEin7ELTI37Ed313usTc5hUpmt0+LaToqHrQp6?= =?us-ascii?Q?gg+nqN1KY0ZCp+5sOkJU2CPFFF6BaDyeDTG5xoVvwI355zsUzmsy4+xYE5fK?= =?us-ascii?Q?A1m43zvQjQWdptMvDmgeFbftajg2EW/5CvH7J3/yUhcp8Aq/1Px4SkZbrIz6?= =?us-ascii?Q?ueRD+m07EZDumRmGGvcdF1GG++O?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2280; 6:QEJtHpL3SGIzHYjgSOidlAqkGnPUJwvHdHlBPv6BfJmo0GApknjeyS/lWc9JNb63z+Qx1y9EACXfdmACWxqgO+RCzqWUqC+U+r0YkzbnD8LLifH7VmzsVq26HL+Dk4M1Aoq3vj2VO3aQXJEIHl2+8UhWQe0h43nN+lf114sbrCzmm5uVV9x/clFQ7UG/ltSRyGrZJTHzHwggM0257b2A53vesQq2WsED3VNRL43bX12bqZkIeLBiUEvMUSmDoHiIhqCLJbKN2So/9p+IRubXc6sKsTGG+iixvzpl1ds234YMqHaj9b7hGe7y1hn918uv6nnN1A6Kr15M6ibsJL4Af8tRrqGiHA0oNSogYX7iC1FLcTYkimJVoCsKdz3vO3jPdwH+ofxzDahYrdqi9wUtEw==; 5:uJRDLOSBLMVGMVJhmyXdyXYNJQ/tkR0xJscuscJ+SXe6USBu04kgud+Yvp4biHC6g5lsEjUz13AnrSHnJStlmHQv1wq+bnVApcf0OIhK4Vc0Q78R/0SavEYUKiuZJ2bEbIg9a2kVEuroQiyUf35b4g==; 24:plsttRSkmw8k/04M/xquz0EIyFcUWeHoywqZe34SxM4YIV3zMIZonbPIt5w3yWt+RpYI5I3vGFhBy8GLeQuYHFC/yJvx0sGHjopmvLUnHVg= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2280; 7:/zpcXajD9PZar1LsdG+07tBBO5wCACGxZSWk1ZcwxO/7zY9XiW7YVryUC0EOJXyqXYwhxcU3LjuLhDU/Lw/uOsfiYykbU5HTaEyibjBg7K3bM9oq3rnZRgZ2jhbZU0WFmXnrlhsGxEJyHfgIVel9jRZ0ZGWqrirGPojid1NutT/RE/0Fg803CkBLFPA19cw3SyPt84AxLejFZj5/A8fVNC7qkSGLWRVbYhzQq77g2i3vvww0wTXnJ6FeEG/JWo9tA+plP8CrM6t1mu835BxYGAT30i3p8gLHQt/ZbpWxGvKmyUpiA9FH8DIfjILGEQh4WwSruZiwxOtFKJndHnxMNw== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Mar 2017 06:27:01.3423 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB2280 Subject: [dpdk-dev] [PATCH v3 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: Sat, 25 Mar 2017 06:27:07 -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 --- doc/guides/nics/features/liquidio.ini | 3 + 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 ++++++++++++++++++ 6 files changed, 270 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/doc/guides/nics/features/liquidio.ini b/doc/guides/nics/features/liquidio.ini index 3422661..6c5d8d1 100644 --- a/doc/guides/nics/features/liquidio.ini +++ b/doc/guides/nics/features/liquidio.ini @@ -4,4 +4,7 @@ ; Refer to default.ini for the full list of available PMD features. ; [Features] +Multiprocess aware = Y +Linux UIO = Y +Linux VFIO = Y x86-64 = Y 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