From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0080.outbound.protection.outlook.com [104.47.36.80]) by dpdk.org (Postfix) with ESMTP id 5C162D45E for ; Sat, 25 Mar 2017 07:27:13 +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=k/l4B+lqGWY2/toRithfqtrHGwiw3qzZjWDf8ZGzQvI=; b=LbBm6J1llc8C24ZSvI9gGZGXIB3lWN6KE6TeHT/zL0Zq7VRPAMXiFf70R1rzXi4K24PNODt9m7qvFw/Hk2/5kY8uynpqYyUjq/m3OwKGcQhr2yBck5djjTsLanNtgfawv8GatO9LBxjkC9tZ2FdMOG9A1j/XEyk5SKDS1cgrGxY= 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:08 +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:17 +0530 Message-Id: <1490423097-6797-7-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: 27a1c3fd-4f18-4ac8-e9ca-08d47347f870 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:CY1PR07MB2280; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2280; 3:EgQ1PSmzSp53ljBuFrYjS/axWEXtTYolm2rcsjzLMaA6CHlIGTuzfvTrfUnRe+grsGJSwH4mydQpgThRT+vwNXF6OSdRBA0EAu0rrIycv41ZYfJKkds9xtyPLLtLNiRMKIrVPrAxVzBlQ8ODNPrTavAQTzhbJ9nMoTFy0tMEmHitsqhEcJIodxhmoFBJZ9VEcIT1I93pqIRNLTsk2TudCLjS0l72HpjqQ95drA1eQY42qiDToAbXzTMhAHdxbQgZi5IHedWHytHMtlCcfMCxTg==; 25:DDgatBKvTzXuwIRpbAbnirlbFHlWaIkkMnyNnYWlgOc0gisLKNA59YYYZSe1InF7LOKAMBVIn8J4ywa9i8UdFKPnRDefrjQtJf/UVJypDFUxFVFqGZ3p5FzDAkRLhcOvqLteX6xNBOp8nZMBTRnD2GJOvJzw4QOsFI8gFlI/yQUmyYlDj6Lv3HbkuEmrCbdIPzhluPE2bA64xqk0ObaORih/8zkhV0664IglIn1V+a1nU0/BGXau44gqlrzFOS9J13xvy2PZ3gtM2DriYMrURSMaISX8nXgVwQa6X5YYor2JFWViilNzgil+kUGv62iTgr45PRT/9xkW3nDE/9LhjzQHLl9B5MnTPDmQUHX5AK1sJx6XkdckBJY4+jkcFJvH8G8/ch/l2Mu2huahO10AIZnNIPKBS873tfV93GfRdyceF1A+0r4fhxJMfJWMBNSbs9VmOyo0/5pXk0YfJ+3e6w== X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2280; 31:QIIIp/aH4zvhrmirsXNzt8FhmQu/sRLqTZ5Flr8kUiv7/Sps90hxZUUMs6Nsyqu1Su/VcHEZxKDuy0Aqfux9GU/sFFx4IuC39vB1LOmbD9dAqITbUdXrYysP0vDRMcnD/Fn+Q48T0PyF/tD6wOpAgezT1ir06W8O+vW/mwrXCHPGa8jgPStAqQm0jZv3V1/d+2vH0ZIBeBuXZBvFJRGnXL2Wr7Nfqn/NfBfMJpQoPL4=; 20:XJvce2YvWBf4IktruO2MUaYnkeOk7UpIsWTbHIgQFYzEPfvEvX63MkKxcXW1DiuISGLrdLFHtpObrkUuJzpg2O09jahmzJLz5xAhmjzLwcVjsntGPZwGxQ9XnkwSUN3WFIOhxmlRBPl761PvLotHJMdM2b35HpbETOxzUfDmIeEpItJFvj4T1akkVmpQaV7hDiU5PSurbvNVeqWGUJ1/clecFnF4oNWEvh3JzEPJ+XeAIEvYPGpbYGBYbBJBJe/xA07lmX/H+3RAQSuNfNCb+ej+cAjC2ScsR6XzgiGFePxMngkVyPYpw4hX7w6E2cudRw7JBixe43FFLSR2TWhk+Bzzw0ZXjV9oPj3+doQ5/AjXsccNzequbFNubuHDGeb07Gxm0o5MeXVI+qOWYsMSWKPuvAO3aqHEUZyn4Tc8u3IHkM9p6v8uauXH1CGZBwZWxagd+9izYO1Ewz0NpvmFPkOV0aql+/Dwa7b5uCq7EB1QEXOGs68vuy2XKsVQKzZ50kTWDVmJDp6goLDbKXrOloUMTPPm9qxdeFNgfrwYxLh+UoFYWxRLihC/u0AIiukHsVbvf+VpMP4ohpPhWKbaOUV80RMQK8xaQfjdAIzdflg= 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:zZw4CmFP0eNvhDVCXJtZX+Zv/r/XhxKNmqbGvyt4I8toch7+oQXyYz/WLMdr1UDH5A9NXncUtlLw4oq9whIbIjJI+Je1YlA9OkmML6OXcB8YpVry8DcCmhsDDoqAq+0h/3LzTYIxdBJr3TXrc6WZCuBBke9AcEHSmf0OzSo/QYCl/rmaXUpU/IXuXFPMjLZgWQdRZmkNhOAxfYkzuf2HMM36dpE37dY+V3lJgWDVWnYhyJ4BXkAYb3GMGlg0gjCiIyoRZyawFm1Io14davqRHhmUBhYYu2Yn1+5CfrBjVR4Olli4jDid4a5xZA7AInnt8fvzY24XmFtg1a1E46omIv/KjCLTuJH/DdvqbBPqOE0JD3KvrL70tIaVEVYj38UgTJ+3N6wEyrpNGlIU8s0NwGQympWI0xCQ4aB3XJoJyPDPfLliwoXMz+pdAOHdw8GJlJWH8qhmiaRD7MHUsHYU7NWPRafjkB+8S5GcIGngK6K1yypHIoPz1CKYGNXZtlg5y4mtkbqiF1qbErLgYBcIWctVGiuiJLX+QHae/m48gNLs/8zSF0Plx5Wqd+dSSTSa2fWbATuSonDNSvegLQQRmX/3/FEKOYCXl9jt7NRIP1E= 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)(551984002)(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:M1M4EdXWfSjaQ7dpaBCmxIZlWAgjKbz636wMJ2yI9?= =?us-ascii?Q?9FtzrJtSFrxcgSq6gzXQtXfjt5u2KpoO+Ida/zV8ToZpc4/rKqp5wZJ/CuR0?= =?us-ascii?Q?e9fKwEE1SmMXpLYQi+sM16bPTrVamxHlQAVXnXdEIICq7F6BxBmy6RUyERhj?= =?us-ascii?Q?T0BiWSG8ksFu5g8zew82QpGTimeTwLpjCYHcxRv7deHMq2bVXr9pXwOaiX/P?= =?us-ascii?Q?185GWrEKGKkBYlfe9t+p8GK1EMRALoPG98kgLgHyJExIVAiF5aUHb19X4xM5?= =?us-ascii?Q?7JwxtpEmkirrYJ/jdShV3vCmlgSmYpJG3NRghX61NHAnqSPM3zjNNFzjkOP6?= =?us-ascii?Q?tgVJIEHJMqaBPtji8wsueRIl2KXUHNRxpuyjpnuBLgJ1syZlAWILQmFbahl8?= =?us-ascii?Q?NbOeUcwno1tHgiMoU9ve3pbSbk14/08oOGa8YDrumpg6VCyqIvDYmLAJNAMI?= =?us-ascii?Q?JMKL5R2QCWEAxGDTvxIMKzlRVarZRuPkHNEK3cjZCkuiGm786yOOTSamzBWD?= =?us-ascii?Q?aZzrtxjGpURTKsXsiVMA8WZ7j7+meds7xupdtlvVAmob48+zqEJalAVEWC/L?= =?us-ascii?Q?33OIOPZFkOvDvxJNZhaIW3hXDfd70ZkVqJK4j+9p9qB1E3MK7B98FQCspJ5Y?= =?us-ascii?Q?byH2FKhDdBYxQrSn71HH+PSO2hpQBkYVsd21gUxt7fyd7mJcr8FACt0MWIVX?= =?us-ascii?Q?6xu/TicvtnX2jVINkxHwennYvQw/ChgdRu65jZs7DwflvUTUuNcm79SXHv4d?= =?us-ascii?Q?mTwFnJ3GywymYYhLZKNNVtaPrP1o4BovOwzvlFura6OndH2+IDCtuWLYJABN?= =?us-ascii?Q?++ADsyI1Sp0pz9m1HGy4eetB5Hlw+nLYcPWXeVt3L6xD090avqqplETZii8F?= =?us-ascii?Q?39okFRV263PVMJctY7K8Mh5t6MrI5we+bwz+Cvee49DMhFohWlyCF2w8Jacg?= =?us-ascii?Q?Z9mvTnIwU9vTMZbFnd1ZYmbT4uCa4sbhyalRnWcwgdInK98MSFGtw65Ycgmv?= =?us-ascii?Q?g/sEvGtJwBqfQ8F5uIDSm7mAcqOqKlORoxNuxv+/dP8MnxfMwFGiAdFvxXso?= =?us-ascii?Q?fjss7znALzJmsxBmazAUJVj9CcmBfttpMxMirKn8MHvuu5XGw=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2280; 6:hxsSYsN5Aa9wCFcw5ShAmFA4gSRU8mA45RazRFQleFtPu5Oyn80WnKjur2PjT7wLO3vJEHw06BNoZe/Vb1P/TifZIXpMsAy6BWZBeRv3AjP6IvDx50dVmNQ/kwhF2M0uexQelfgT4yCVws39blaEMpWyaGiYklqtkF0+Qc3f5HhZ3JVPNtPhqpHxykyMD3gS26mvbxGbxUHVZdqIAYWbEdOpAALmPSrw9+lgB1wHPM1JHAxVq7A3Ktbsvt1zihbuWfVbV4LmHqTnlHqbFfvzmNJUpgN+u759xNIanlg6yNV8RfCK9XIZLGhOh6ZmgsNLWZPkHIzAzl/KCnJws5RD/i/ogmavkWP6gX3SHRf+0C6OYBKsBzqWHxAyuB5oIO998OcRRG6aKlmcIu+I5wBoBw==; 5:fsJUXs5+0zVNet6+E01JaSgM0BMdtgqPh+SzNbM7smqr+Wsd5quUj4QJua4Zvn6pfrWeIO0ZYEbHD0znek0E95FlymKnj2CwZK7w6vDtYmxjy0hh0kkCjtnTTIaEZ2JXaeWx2pWluEte2OtIQ9PoFw==; 24:kiyP4cLM1qVdd/drsLw51znAAu5RylhjCh3DXuN+ABtTQHFgHfBg86l2Wv/Aqn85xRNiEYf/ZNw6YykIhhW9OYuBXNO6N8g6K4UFnCnGNu4= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2280; 7:z0bIMc2LArRmcof0n/nPWYO+VfWY7m14ZKB7ZZ1dJEvQMXUArG/0RVEa0jyB6sciXZaYGcdsuIUEPdpou6lq0HmwZyUU67L1NXkC93/R1y625yoH9SucPj4nvbyV1iStaS2q6hdkxndZZTEcxFMvsG23SVK9TQLUSQLpvZ3FK0ikJ1lO0Z2ILj4Uy6oB4KZQvdnkctPnJfEGwOKVrrJU+NAC7nIHOY1Pk7BZcMFBUE2ssehV0pIiROmdvqcheXmZ52KPAbnNHmpog7d3hx9GtAsTRqiQanMQ74Oz+mSc9iQKl4IFsYxccpZp5bVG6jypAMRxAtZLFusWnCa1Lw5ewg== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Mar 2017 06:27:08.7132 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB2280 Subject: [dpdk-dev] [PATCH v3 06/46] 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: Sat, 25 Mar 2017 06:27:14 -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: Srisivasubramanian S 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 9a7a894..a2654cd 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 49efede..734f6c4 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) { @@ -84,6 +138,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; + } + eth_dev->data->mac_addrs = rte_zmalloc("lio", ETHER_ADDR_LEN, 0); if (eth_dev->data->mac_addrs == NULL) { lio_dev_err(lio_dev, 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