From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-sn1nam01on0042.outbound.protection.outlook.com [104.47.32.42]) by dpdk.org (Postfix) with ESMTP id 909B8F932 for ; Tue, 21 Feb 2017 10:28:33 +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=ohIrUppzs1mn35vhwzWPdy0D5wEyL6vFqaEypBEQ2go=; b=b9Mi3i8NlpnepgE0gj7wScS50ilMnwhYCy5cfiRXWeMQWeIXp/s5WN9fAqI5qn6YTvmDoTelYJ8tkNRwM+rQU8kXbHvRM+WDpimRbHI7PkXEaGte1TDukwgYPc85V+pkpCfjkq3gm2d8mTUQ6qNIZureeekRBwkrqGKE4ALZ5SQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Shijith.Thotton@cavium.com; Received: from lio357.in.caveonetworks.com (14.140.2.178) by SN1PR07MB2285.namprd07.prod.outlook.com (10.164.47.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.919.13; Tue, 21 Feb 2017 09:28:29 +0000 From: Shijith Thotton To: dev@dpdk.org Cc: Jerin Jacob , Derek Chickles , Venkat Koppula , Mallesham Jatharakonda Date: Tue, 21 Feb 2017 14:56:24 +0530 Message-Id: <1487669225-30091-10-git-send-email-shijith.thotton@caviumnetworks.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1487669225-30091-1-git-send-email-shijith.thotton@caviumnetworks.com> References: <1487669225-30091-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: MA1PR01CA0089.INDPRD01.PROD.OUTLOOK.COM (10.174.56.29) To SN1PR07MB2285.namprd07.prod.outlook.com (10.164.47.155) X-MS-Office365-Filtering-Correlation-Id: 7e1cc798-8079-48fe-d9df-08d45a3c009e X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:SN1PR07MB2285; X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB2285; 3:KEViEazM3vd3dYexvXUfzzAG6tZ/yHilFABrUmv/2h6tpIETA3QckPAxScXLDu4WKRV6vRnrjfoMVG0J1kmQsd7mtbgmzUBWFUYACj4RZatequNeQ7ZjsZePSrOtDEECa1LrIYylt4nNHjKhdqYlBIJasmDq2DcKfIJRuHOyP8SceOLCbigNO588/r36rdFTCsXTOgAkQVz/ZBHeyKtPmu2wCgRlbRMhttNjAxQV4ffO4H/0i0kYKxVjAhLXl8htVfuCcxpFER+YjeX+BGXs1g==; 25:sGnCfD5BSakXVQjKk30y4FuzU/wrGfkh4Amk7bU7ny2ruYQ27UbROVWU9qnhgiyoRzHVmSVAUSyodNVOFSBNTiX28knjmWXzFUJgcyT1WTu7yRRG/Y9cu2U0eSsCw4EtkdDKtsTcNVrLjMJHP/VGXXnh0JdITJQ5x3+It8AGQCbcQgWKCqFbt8rAIuMXEKqqd5AaaH+8Ki1zP5EY+gyrehrosmiyQ2ny5TsFbJAvZgFRUwn7xlfFE/N/7BMwAOdXAvLgOOC5QA0z755EVyPHRlAf96hswYulQd5XLFIboCcVWqSDcmbIOPi6mWOEhEZ1CfJxH0YGN84o4AMndsrlhG6izN1Wgf504HZcEHQsUU0xDO9zCeKwV3I7FvfYObHHOCbWUilQw1i0Q+n7t+Gk7B8J2wuE5hmH17sbIsL2olUSQBsUnGBWWEcPqh+Hplj2ASgogSy/iLtuvmyNLgMRtw== X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB2285; 31:DIHiQb/vOYh47K/LrdDd+OxhOCy8h3QrxDtDLOn4Ym5nAW/iEqtvosH+8GQKKwhjQShlzEU/yowUR5F11Yr9Nokt303D2BCilbwP/waECBkTa4VMaUU4PUdh/4CeoDPFxqrPk/MZCnjUIW8cs4EMQgVti1glFK55laUYKjfm7uRi4LezCuTzh74VohKpVjqX47YbdktOOKotMgknQZGvpP3Gb/E1byYFcdCWb77CITZNB9oVne13x2U+BE59JNlj; 20:Pchqgw4wDAQxBzyNWXppVasrUL3ui1lFts+sSrh30eBdsfBG6cL53dccx4/RcFtoQe21/OXNnNFsXW2hmH4XKborW1C9aQ4nrnemcoIYxL6RHRjxNzPgfQCoStHJRO9cx4OR9RMnyoMZ76K6OX+8BNMCDp/+fN0xAZLWFqD/b56a9cRbQBWMYbfatkNeaKpFguZg0dqprfxPBlo0+QEfv5pgSJdp1kJCLHUZDIpOdABNQpZb/E32vLyxL1388oN3ul+qxX7BmRPeiUMoV7wXoK4s23TevkLUk9zAZbvyPQHimdM6tvOOA6xPx+pFSiODt1XtCJjTgHHYuJ4IKvmhbKN6UC9ft59Zs6T/82GdM7wssWgO3H5TskIdijv4tj8w64WEnYk09uPGfH5M1SAP7aDLC7ud37Tj82v/6YHmxRnyFpsVwySk681aH+owcS9DxNNL9qeUyQMZvOqNvAOdnvJfrg4kru/6EcoUJFjkB5RutprFlo9EcUpPCaKnH3E1OOZ7X2USyixV2VHfNE93hMgPkoS01QFj/i5Wnkf8iMvD+ry/Pwr1N5j/VPnsMmknrMCJy5IVeL13xuJ3UHlb24UBfHxYFi5vWO+GdZrvZWA= 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)(3002001)(10201501046)(6041248)(20161123555025)(20161123564025)(20161123562025)(20161123560025)(20161123558025)(6072148); SRVR:SN1PR07MB2285; BCL:0; PCL:0; RULEID:; SRVR:SN1PR07MB2285; X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB2285; 4:5qHcPEG922NPBAPkHCHuG2LjrVKv417BXpUjGMF6oPQvNvfcALesXMMYEDpo0QzUAE2dzLauKFKUP2rYmX4japAuQQ6v9hkQb0ITMLhc/yxv3R4ZrHynwAC1b8Yr+OT6Mn8ZsMy6wSebg1ZNjbeL4qv78UX4f7V0Lh/CUmnz29GcN7HcsowTkjqiaCkRhv69Mbwyultf31y7my9mxJbion1mCRIUMb6OhRFbRYSbdGtBZMye3whHHcGuqOmeZT+VYw1vrNDqE2DgYsS55TN1ZySUuD8etHwTrT7l+5NsN5Ao9vK+dRYjsDaKEgtXzk4ztzWVdhwUEjqDkqvOml47nOaq64WaOUIkfUSTF5nugtpN7kKXd1gvxVKT/p60EK5OaydN0oYmrvOm1KteFzhM7qMcdjM1jwNLdWzo4aLtW99Ex4VQ66+tWSmu1pwfmOOgR9RPENvB7pYVAWpedKSEULZeMc35sacsy1UOjEfSCXKvi8LyZrWyrMbS3dh7FSlnYrSP5xqn7A4t3W6pBTzkI+tCVkmPuWu3WhKSM3M1ACos+SB83eiVFz+sHBOHZPHRi8ioaoT37+j8X7mUNIlc5d+HmZJhscjACOx5o/d9Oq0= X-Forefront-PRVS: 0225B0D5BC X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(7916002)(39450400003)(39410400002)(39830400002)(189002)(199003)(50226002)(81166006)(42186005)(2361001)(101416001)(81156014)(305945005)(3846002)(6116002)(5009440100003)(31430400001)(8676002)(105586002)(7736002)(53936002)(36756003)(110136004)(106356001)(6506006)(25786008)(38730400002)(2351001)(92566002)(48376002)(6486002)(97736004)(50466002)(5003940100001)(189998001)(68736007)(2906002)(4326007)(33646002)(76176999)(551984002)(54906002)(5660300001)(6666003)(6916009)(50986999)(2950100002)(6512007)(4720700003)(42882006)(66066001)(47776003)(7099028)(110426004); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR07MB2285; H:lio357.in.caveonetworks.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN1PR07MB2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FHjsGGE0Hw==; 5:p1oVU3AqVSE3t/JxUBD3le9wQxYgQTl5ejagWeVMDONhGggbVqxQ3lSdeYF0Bkw3hWsElIVvbcDSqwqFSW5u7CQk8I/4Ee020IAFUwyMD0tKwIxOsoYDae2p1MpnCEV7CRep1YPtLpuZ7B8v5QH+Jw==; 24:3fTNSrQUe9XTFdXKOREwlpM8O7aoj9giz/rFrg2HSK7BeSmO4CGSAfhWE7dc/tHb18uW/Nzf/plU4fd50uh+tmZnCjnS24quPE+GicoATeA= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB2285; 7:PkHEuij2zv/9XnsJva61Y5JZS2LmCs+0FYpPGfkk2K1z/2n12OyKb+jMugt/7uBpXV1sjPuOa4kQGuuWaoMlSJIzraGxvzSWC/ll5JBuUagRk30XVg8st8+WAK/Ew/7cqlD4cNz2A11MeOBxuiaw3aFglbZkR3/KOJna9I9Bk/Jjh1w9j0v/mNdTaCp82qSfnUbjWLTqDe7TJFO19EgGsMH4jWUloFd0HSzQLAebBjIzWP5U/ErajB09KDqBe4TNWyizMrJgs9Cqab6Gwbngrazv+KQJ5teL6wJqwbgMC/mUjv0LI4FFULPvVaK473JD5m53bUuAUjT73UfCB6Ckfw== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Feb 2017 09:28:29.9623 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR07MB2285 Subject: [dpdk-dev] [PATCH 09/50] net/liquidio: liquidio device init 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: Tue, 21 Feb 2017 09:28:34 -0000 Default device configuration and initialization code. Signed-off-by: Shijith Thotton Signed-off-by: Jerin Jacob Signed-off-by: Derek Chickles Signed-off-by: Venkat Koppula Signed-off-by: Mallesham Jatharakonda --- drivers/net/liquidio/Makefile | 1 + drivers/net/liquidio/base/lio_23xx_vf.c | 67 ++++++++++++++++++++++++++ drivers/net/liquidio/base/lio_23xx_vf.h | 84 +++++++++++++++++++++++++++++++++ drivers/net/liquidio/base/lio_hw_defs.h | 34 +++++++++++++ drivers/net/liquidio/lio_ethdev.c | 61 +++++++++++++++++++++++- drivers/net/liquidio/lio_struct.h | 70 +++++++++++++++++++++++++++ 6 files changed, 316 insertions(+), 1 deletion(-) create mode 100644 drivers/net/liquidio/base/lio_23xx_vf.c create mode 100644 drivers/net/liquidio/base/lio_23xx_vf.h diff --git a/drivers/net/liquidio/Makefile b/drivers/net/liquidio/Makefile index 25685a7..8880a10 100644 --- a/drivers/net/liquidio/Makefile +++ b/drivers/net/liquidio/Makefile @@ -51,6 +51,7 @@ VPATH += $(RTE_SDK)/drivers/net/liquidio/base # all source are stored in SRCS-y # SRCS-$(CONFIG_RTE_LIBRTE_LIO_PMD) += lio_ethdev.c +SRCS-$(CONFIG_RTE_LIBRTE_LIO_PMD) += lio_23xx_vf.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_23xx_vf.c b/drivers/net/liquidio/base/lio_23xx_vf.c new file mode 100644 index 0000000..dd5e3a6 --- /dev/null +++ b/drivers/net/liquidio/base/lio_23xx_vf.c @@ -0,0 +1,67 @@ +/* + * 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 "lio_logs.h" +#include "lio_23xx_vf.h" +#include "lio_23xx_reg.h" + +int +cn23xx_vf_setup_device(struct lio_device *lio_dev) +{ + uint64_t reg_val; + + PMD_INIT_FUNC_TRACE(); + + /* INPUT_CONTROL[RPVF] gives the VF IOq count */ + reg_val = lio_read_csr64(lio_dev, CN23XX_SLI_IQ_PKT_CONTROL64(0)); + + lio_dev->pf_num = (reg_val >> CN23XX_PKT_INPUT_CTL_PF_NUM_POS) & + CN23XX_PKT_INPUT_CTL_PF_NUM_MASK; + lio_dev->vf_num = (reg_val >> CN23XX_PKT_INPUT_CTL_VF_NUM_POS) & + CN23XX_PKT_INPUT_CTL_VF_NUM_MASK; + + reg_val = reg_val >> CN23XX_PKT_INPUT_CTL_RPVF_POS; + + lio_dev->sriov_info.rings_per_vf = + reg_val & CN23XX_PKT_INPUT_CTL_RPVF_MASK; + + lio_dev->default_config = lio_get_conf(lio_dev); + if (lio_dev->default_config == NULL) + return -1; + + return 0; +} diff --git a/drivers/net/liquidio/base/lio_23xx_vf.h b/drivers/net/liquidio/base/lio_23xx_vf.h new file mode 100644 index 0000000..1c234bf --- /dev/null +++ b/drivers/net/liquidio/base/lio_23xx_vf.h @@ -0,0 +1,84 @@ +/* + * 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_23XX_VF_H_ +#define _LIO_23XX_VF_H_ + +#include + +#include "lio_struct.h" + +static const struct lio_config default_cn23xx_conf = { + .card_type = LIO_23XX, + .card_name = LIO_23XX_NAME, + /** IQ attributes */ + .iq = { + .max_iqs = CN23XX_CFG_IO_QUEUES, + .pending_list_size = + (CN23XX_MAX_IQ_DESCRIPTORS * CN23XX_CFG_IO_QUEUES), + .instr_type = OCTEON_64BYTE_INSTR, + }, + + /** OQ attributes */ + .oq = { + .max_oqs = CN23XX_CFG_IO_QUEUES, + .info_ptr = OCTEON_OQ_INFOPTR_MODE, + .refill_threshold = CN23XX_OQ_REFIL_THRESHOLD, + }, + + .num_nic_ports = CN23XX_DEFAULT_NUM_PORTS, + .num_def_rx_descs = CN23XX_MAX_OQ_DESCRIPTORS, + .num_def_tx_descs = CN23XX_MAX_IQ_DESCRIPTORS, + .def_rx_buf_size = CN23XX_OQ_BUF_SIZE, +}; + +static inline const struct lio_config * +lio_get_conf(struct lio_device *lio_dev) +{ + const struct lio_config *default_lio_conf = NULL; + + /* check the LIO Device model & return the corresponding lio + * configuration + */ + default_lio_conf = &default_cn23xx_conf; + + if (default_lio_conf == NULL) { + lio_dev_err(lio_dev, "Configuration verification failed\n"); + return NULL; + } + + return default_lio_conf; +} + +int cn23xx_vf_setup_device(struct lio_device *lio_dev); +#endif /* _LIO_23XX_VF_H_ */ diff --git a/drivers/net/liquidio/base/lio_hw_defs.h b/drivers/net/liquidio/base/lio_hw_defs.h index 673c2d6..ba51d7a 100644 --- a/drivers/net/liquidio/base/lio_hw_defs.h +++ b/drivers/net/liquidio/base/lio_hw_defs.h @@ -42,6 +42,40 @@ #define LIO_CN23XX_VF_VID 0x9712 +/* --------------------------CONFIG VALUES------------------------ */ + +/* CN23xx IQ configuration macros */ +#define CN23XX_MAX_RINGS_PER_PF 64 +#define CN23XX_MAX_RINGS_PER_VF 8 + +#define CN23XX_MAX_INPUT_QUEUES CN23XX_MAX_RINGS_PER_PF +#define CN23XX_MAX_IQ_DESCRIPTORS 512 +#define CN23XX_MIN_IQ_DESCRIPTORS 128 + +#define CN23XX_MAX_OUTPUT_QUEUES CN23XX_MAX_RINGS_PER_PF +#define CN23XX_MAX_OQ_DESCRIPTORS 512 +#define CN23XX_MIN_OQ_DESCRIPTORS 128 +#define CN23XX_OQ_BUF_SIZE 1536 + +#define CN23XX_OQ_REFIL_THRESHOLD 16 + +#define CN23XX_DEFAULT_NUM_PORTS 1 + +#define CN23XX_CFG_IO_QUEUES CN23XX_MAX_RINGS_PER_PF + +/* common OCTEON configuration macros */ +#define OCTEON_64BYTE_INSTR 64 +#define OCTEON_OQ_INFOPTR_MODE 1 + +/* Max IOQs per LIO Link */ +#define LIO_MAX_IOQS_PER_IF 64 + +enum lio_card_type { + LIO_23XX /* 23xx */ +}; + +#define LIO_23XX_NAME "23xx" + #define LIO_DEVICE_NAME_LEN 32 /* Routines for reading and writing CSRs */ diff --git a/drivers/net/liquidio/lio_ethdev.c b/drivers/net/liquidio/lio_ethdev.c index b808a55..12061d6 100644 --- a/drivers/net/liquidio/lio_ethdev.c +++ b/drivers/net/liquidio/lio_ethdev.c @@ -37,9 +37,63 @@ #include #include "lio_logs.h" -#include "lio_struct.h" +#include "lio_23xx_vf.h" #include "lio_ethdev.h" +/** + * \brief Identify the LIO device and to map the BAR address space + * @param lio_dev lio device + */ +static int +lio_chip_specific_setup(struct lio_device *lio_dev) +{ + struct rte_pci_device *pdev = lio_dev->pci_dev; + uint32_t dev_id = pdev->id.device_id; + const char *s; + int ret = 1; + + switch (dev_id) { + case LIO_CN23XX_VF_VID: + lio_dev->chip_id = LIO_CN23XX_VF_VID; + ret = cn23xx_vf_setup_device(lio_dev); + s = "CN23XX VF"; + break; + default: + s = "?"; + lio_dev_err(lio_dev, "Unsupported Chip\n"); + } + + if (!ret) + lio_dev_info(lio_dev, "DEVICE : %s\n", s); + + return ret; +} + +static int +lio_first_time_init(struct lio_device *lio_dev, + struct rte_pci_device *pdev) +{ + int dpdk_queues; + + PMD_INIT_FUNC_TRACE(); + + /* set dpdk specific pci device pointer */ + lio_dev->pci_dev = pdev; + + /* Identify the LIO type and set device ops */ + if (lio_chip_specific_setup(lio_dev)) { + lio_dev_err(lio_dev, "Chip specific setup failed\n"); + return -1; + } + + dpdk_queues = (int)lio_dev->sriov_info.rings_per_vf; + + lio_dev->max_tx_queues = dpdk_queues; + lio_dev->max_rx_queues = dpdk_queues; + + return 0; +} + static int lio_eth_dev_uninit(struct rte_eth_dev *eth_dev) { @@ -85,6 +139,11 @@ lio_dev->port_id = eth_dev->data->port_id; + if (lio_first_time_init(lio_dev, pdev)) { + lio_dev_err(lio_dev, "Device init failed\n"); + return -EINVAL; + } + mac_addr_size = ETHER_ADDR_LEN; eth_dev->data->mac_addrs = rte_zmalloc("lio", mac_addr_size, 0); diff --git a/drivers/net/liquidio/lio_struct.h b/drivers/net/liquidio/lio_struct.h index dcf99ce..a1203e4 100644 --- a/drivers/net/liquidio/lio_struct.h +++ b/drivers/net/liquidio/lio_struct.h @@ -43,16 +43,86 @@ #include "lio_hw_defs.h" +struct lio_sriov_info { + /** Number of rings assigned to VF */ + uint32_t rings_per_vf; + + /** Number of VF devices enabled */ + uint32_t num_vfs; +}; + +/* Structure to define the configuration attributes for each Input queue. */ +struct lio_iq_config { + /* Max number of IQs available */ + uint8_t max_iqs; + + /** Pending list size (usually set to the sum of the size of all Input + * queues) + */ + uint32_t pending_list_size; + + /** Command size - 32 or 64 bytes */ + uint32_t instr_type; +}; + +/* Structure to define the configuration attributes for each Output queue. */ +struct lio_oq_config { + /* Max number of OQs available */ + uint8_t max_oqs; + + /** If set, the Output queue uses info-pointer mode. (Default: 1 ) */ + uint32_t info_ptr; + + /** The number of buffers that were consumed during packet processing by + * the driver on this Output queue before the driver attempts to + * replenish the descriptor ring with new buffers. + */ + uint32_t refill_threshold; +}; + +/* Structure to define the configuration. */ +struct lio_config { + uint16_t card_type; + const char *card_name; + + /** Input Queue attributes. */ + struct lio_iq_config iq; + + /** Output Queue attributes. */ + struct lio_oq_config oq; + + int num_nic_ports; + + int num_def_tx_descs; + + /* Num of desc for rx rings */ + int num_def_rx_descs; + + int def_rx_buf_size; +}; + /* ----------------------- THE LIO DEVICE --------------------------- */ /** The lio device. * Each lio device has this structure to represent all its * components. */ struct lio_device { + /** PCI device pointer */ + struct rte_pci_device *pci_dev; + + /** Octeon Chip type */ + uint16_t chip_id; + uint16_t pf_num; + uint16_t vf_num; + uint8_t *hw_addr; + struct lio_sriov_info sriov_info; + char dev_string[LIO_DEVICE_NAME_LEN]; /* Device print string */ + const struct lio_config *default_config; + struct rte_eth_dev *eth_dev; uint8_t max_rx_queues; -- 1.8.3.1