From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0067.outbound.protection.outlook.com [104.47.33.67]) by dpdk.org (Postfix) with ESMTP id CB57AD49C for ; Sat, 25 Mar 2017 07:27:35 +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=evuG2Aate67F/Vtm2wU2qYdvwFSshVXO0X0nq2CfIus=; b=l5EyC6scgsgCOqDasggFEedqaF6WGFkzuSKdOGddw0Baei41Wo+LpBvdePSvSUMf+HFUqzvrPAG959NurwzyLVKoUyKBmCyYL8GymF1j2N41BYOniRexvLqEVVO/PnlPM5jfjPITKKiqxZQFZlugYANvDGhKpylFd1QbTtGrOWE= 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:32 +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:24 +0530 Message-Id: <1490423097-6797-14-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: e407997c-c458-4f42-bf98-08d473480623 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:CY1PR07MB2280; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2280; 3:GLSq5k5gCSavdVoVkvJ6Vgbx5if7kKye353z4p6PQYOqMwWkMs+ZOVjz6+bGVreQIe7d+CpLvGb6XOGQczg8vMyeohHiMB0cFYLCPGEDjSlXUvYdwqWFl4f1ulvYAqw44SL2N2S4vSzI5AoIE+ffQqbdE14ukMuS2rBtMFNCtQob9XFTBkUd9FHHtitmjdocNTXtxdz/V/fbnRThslUJfJjLmF4pwHnO+1TfuC0rHaBS4hErc0aPk6M+QtXf5b/pOZz+eZsX4TSUhW0ky30BHg==; 25:HWdrdOyqgpCHIzODNVVx7UMsD4FCLOPlPJOas8A6IsLllrTDBfVe5XKH4XCtZ3uhM+FeSCj2asLa1Uia+OZ1qSJD5vRdsufuS0rgW4RqABsP2K8lD9ul0OWN16/roVf5sMURrS8kR+OdZuvf09i86IURyL9mX+/QcpB4lhVQ7r6+oidcYm7ZILUi0jKj45H8ANtvLWtuhxMAV445P/Frf38Y8EzjgEdPMlKU+pn5b3USl1zsS1OrDSHi+hvyOUmi2wXS1g74sasoqG3lcEDK9mpBbcAD0vwxPfRGZJ/va/o82CIEB/2O3vN+RM1HWju199cUNn9Qg76B6nad06Om+lCeUpCTJDN1XYy7qSAsb322r2ghzMhTz8G0Ntqhxn/GGFmeYH3IE4xr1aD9IILW2/gPnr3CYtnB0oZaCwl8BW8oQF7bpJLW1NWeWKsI/NPeb1/9VuEd+Z/Q9Kh9lJWrrA== X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2280; 31:985DGrCNQi/6LBA7czU7+WV9AWQRxdoCbZ78pqAj7yjs/PdFJ/n+3Us+5z0/5dkvmT7vE0OlUEgRMEV3YtLC6GJji0YHfcu4lEo0jtictafwZ1t0mnTgFBLiVQH6uDmsTFLfTeTgOkIOPrfXJddlVglgSSn18G08/Q7zMLKWQga5T8475jNKBTDY0qD8wm/ztNMf1Hfh9AItsazDzMh6juUfJc9k+3dpwrS46D9RaLU=; 20:b8p+zGFC6da34XSra+b3n7ROxD5AyfwAblfTM1/SkyUzzZ3Qe/RAT/fChI41U3In175EU5HTlZcvIk3uvfXCh+rRmTfkeEOkqujzfBokrErnT58Tn0wpLAHMV6/bD+LOdn6nWkKVLnK9lnh8JHMNpom+WezlyL9YJ147HzzIIvCdH1bRSN5Cu2sIWeCtdEo076ZcRWE9YLhqUJd1Dv48QvNAT4VeprW3azYJK7149mLcsOYiSn5J01C9FN0ORvDQ1xDsbAQ3tchXVXmsyqXRu7ZvsvNcz0MbajkyhKkUWEcoSHcNCl5rY+mYEOTpqKYGXS6qKVRO3/KpV8G9D9Nd8J8r2hQIZIR1Rbv2yxF9xzaSSx7Vr33IWpXwZGzA2B5NRLeWwb+SVRo5kpnWCDT8bKcj076abqtUxRoEMsybTb5PRuQSOiZDbAWVU0BAVgy6h622UgzSnJHDb5/9KcxkU3LJn/SSY68kIM8yfuB1zP10HtVeorfJZSYeyWjdcG0D780gS5Q9T2CBN+be2YPFqCREFCWJEawcJwhxmQ1SrLsjS0FxIQaC8xd1guPJPrrOmxFFXHy3Pq8Cx9fishSWl+ErlhhBs+RHJcXy9ciqn3A= 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:dVrNuAOFCtQaZ0YXRWNh5N2VJuqjNlTk3aBVGlCe2YpWIGnRsSlDUAg9LhdvndL+DzfO1RzgCwDmMQQHfz+kCj2yySKvmC3IVdtGuTnsHmAOspzkzyqjVRLIBORfw5wdSvUXVcko/yQeVrRBE8nqvQK1mrmVV4MTrx7n7H6Fs88mWbAK9kw/xKJqApbs/zNOTW3OtPWlCRWAGV63XEgWsvTa9j9/mZ+IaZysNZ5SHwUxMv1/mP9s4ek8/lZZP4Z1Q20YuvSqV5dZL3BVijNfehaEQDcEzXkBeRFxO7ocfoL7P/p7XuNj0PnQpC6gxJiXWof8jGSWCiae19cPxDOBLJi27xv/qf2W6prS4/ttxdpHM0H+cF60TzTRv4nudOwI6jot7aehsES3RyKzrPdjkUiaMgpdwzms3zx5hWssWgtw9oNV2IocrHcjx2S1lytnuX1doGmEsWM0Ebb/U2CaCGEM593Qd1P/7YVLPufpG9/tw9KaR5x1BCCmBK5h7s633zB0yn7U7PfXzjcPf7ClyV6AvFobawoToV3zSTmJzBBVLhaFrUSLXyrHcmagzhojpuK0uKibI2Z+wIz4n66L5LqUwCQulbcXyawbLrUfWXU= 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:NJhk2LJ7BzvBJwPJ038YUbXr19HFqridpex23fi4y?= =?us-ascii?Q?KYLo6RQWpRMLzwU+8BdEgBoacw///wMoFJukv8cenV17UAif0vGVhbwlwVCw?= =?us-ascii?Q?iUHoYx4HhjiwarSqYtwQyfcfc6YEiwS9HBuluO8vCATVg33DKxR94MVvljVH?= =?us-ascii?Q?pOXJzgGCeujsiAAgKsMgfktkNu7hUfyP1KIzkestO1XsY1js978qlKwFgtY/?= =?us-ascii?Q?cy2wexiXcSwLeHnm8AG5v8aSq9YluORCkzNUznFaBCAf6xvxo1DsuUqG14wT?= =?us-ascii?Q?HT9YFqlPDnWKCUZ+Be48gUzmzv1AC0/FbBzixWZ5yyYQsQgY4oOdQ8LF5QEL?= =?us-ascii?Q?JBWSHo0JFn6ontCPPOVxk1yMWdqi9E7yzW8evdc1Lk70XInqe7Xadff1AC9I?= =?us-ascii?Q?1CtNv8hF8/2CrNEcUd5m4UG7iPniJsKEbm8Di5wZQkKLipuv589nIhlE8bLA?= =?us-ascii?Q?e5kNtnRW1bj47Dt24iIZtjvkzY1Yq6RbDQkDhkY6UrwwCo2jVaLEHA2CE/sX?= =?us-ascii?Q?dIL2oXgl/nlYPwTDfp+e3/sLr94KmIuVVhzeTLY0XQAKufYmUwqiiVlWbIF7?= =?us-ascii?Q?83EJ/yW6qt59IDGPo7bovq67Qbar50/+P7szm8N7MiQUrlQsTeq7LBx95F8p?= =?us-ascii?Q?jeChLnGDNTbMOFlY+HMi0IyZNKcBz9THK3S4kbVcA3KJx2O/f4idFe8jMGxP?= =?us-ascii?Q?3U/rl/qBS+pjdLL2PFyFfBY/2HVbkszBdO4rEFvUTfaayp6+yOtrQnubrYnn?= =?us-ascii?Q?xeKHJQAYHxBQPb7ykz8dM7MCpMkU8qCfGySXOOfOL8KOYJ6uBqzx8l82j+dM?= =?us-ascii?Q?x66gj9WPnH89hvD9SkS1HkLc9l67AsqHvUSjkXwH2tAntrV+raclAA1B8rbS?= =?us-ascii?Q?haHb3OL3ho3xgjwo6X46ZMlnQNjXOOAR+auQu5dIYDg60chHF8gRcN2EnXdF?= =?us-ascii?Q?pv9jEdtR9PVvT4TcDadZLLR18ItzoWvMVCFaq6fwpspiB5vLU6HJcet6xEoD?= =?us-ascii?Q?ozP5Z1If+SsZyJGB8cwYpoOKrVzLM0hB62E4b+ebdhSksKbmCBnSAL7mSkpl?= =?us-ascii?Q?+cAsZ2jBT62HtWIZDk2aGKxdCEC?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2280; 6:ozKax4zVocHLepxr29QMMLrGMZxsq8fQTJeUDbxFx+jNFFRfGlcDkz/9VZueAncjB7rrUWQtxoPn1N4rH8YASV2hf0oDvJRZqATImkd/6bFebhqX1WfVXvO0WCSr8HUOYJ9DbTfB9/WKaaZ5uxp/0TkIf2kEaxnuAAxTSdMW7P6ae2MfPx56L1+Ikh2SZL0QCerYKIzJ+UrgkbCnVmOGcdV/2Jh/dRDASiKHsK1T3Kb3RttmdMP0MU6ktMVGrf17RyGQVlVIKHTCYdTqFtw8wpv5rbuFDRqnfLS79j2XSWq3BHisv4u06w/G3hH9tdQjqsHvpFOZZ+t8RsaivKskqSOVcle2+MW9DjqFppJR1aVSF/jwJAyq2MUx59NhBeY3WvcYgmPxAEpJYeGieR1yHQ==; 5:T3kCh1GOsKO+OaX7AY/kspG6BezMb3qV7lOyH2y7a9mmgKsUz+G0FPld6hd24MXvhK+dQAMk4bCWfPXbee/NSStM0NNttwQliRwu+eRxEGfI0o7mU2M/80ysQ+/Ul4yA485+8w4aSy9PlgUPGQaqIg==; 24:NJDpS8SzvqwkIFkhVHDUN9Kcedo857K9Ckg8za9b5FMY5nvhql547mluNFak1oQnpXcKBBidYzf4n4j1iQAJ54PnJPeu4xc3vS/SGhIIBlY= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2280; 7:qFxVa+bjjm4gBG7CYf6hOHBhXLahMs+HIuTGFiJcqMLs9DXmmMnu3qiHGa9aEuHUIEbnhmjKvuxXicsuSvVVj6OkJdYzKKiNHNkkl98pZIdaTt4IXjQ32otTBGLYDFSBs/5EDhxRMD1uyZdUogg8eiTpJ8Pv2zmYEHii/0hZGofmcaMsfjjC7YcUHA+m3B+TyVdqOx367h7FUHTcxVtEhr8yRXwEdaA9XHzkTVUrId0wE4roQSM+JixLkKgcqpzXm8Dj1dVhatSqlKHmUHuQIpIjHKSx50M8zIwUaqGrbkHzgq6mAnm/BxO2kpSRGdYhgxh8fuBweXUaInRy8l1l8Q== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Mar 2017 06:27:32.0009 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB2280 Subject: [dpdk-dev] [PATCH v3 13/46] net/liquidio: add APIs to allocate and free IQ 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:36 -0000 Instruction queue (IQ) is used to send control and data packets to device from host. IQ 0 is used to send device configuration commands during initialization and later re-allocated as per application requirement. 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_hw_defs.h | 12 ++ drivers/net/liquidio/lio_ethdev.c | 8 ++ drivers/net/liquidio/lio_rxtx.c | 206 ++++++++++++++++++++++++++++++++ drivers/net/liquidio/lio_rxtx.h | 57 +++++++++ drivers/net/liquidio/lio_struct.h | 112 ++++++++++++++++- 6 files changed, 395 insertions(+), 1 deletion(-) create mode 100644 drivers/net/liquidio/lio_rxtx.c create mode 100644 drivers/net/liquidio/lio_rxtx.h diff --git a/drivers/net/liquidio/Makefile b/drivers/net/liquidio/Makefile index 451f49d..de2ef9b 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_rxtx.c SRCS-$(CONFIG_RTE_LIBRTE_LIO_PMD) += lio_23xx_vf.c SRCS-$(CONFIG_RTE_LIBRTE_LIO_PMD) += lio_mbox.c diff --git a/drivers/net/liquidio/base/lio_hw_defs.h b/drivers/net/liquidio/base/lio_hw_defs.h index 9282068..726ce6b 100644 --- a/drivers/net/liquidio/base/lio_hw_defs.h +++ b/drivers/net/liquidio/base/lio_hw_defs.h @@ -76,6 +76,18 @@ enum lio_card_type { #define LIO_23XX_NAME "23xx" +#define LIO_NUM_DEF_TX_DESCS_CFG(cfg) \ + ((cfg)->default_config->num_def_tx_descs) + +#define LIO_IQ_INSTR_TYPE(cfg) ((cfg)->default_config->iq.instr_type) + +/* The following config values are fixed and should not be modified. */ + +/* Maximum number of Instruction queues */ +#define LIO_MAX_INSTR_QUEUES(lio_dev) CN23XX_MAX_RINGS_PER_VF + +#define LIO_MAX_POSSIBLE_INSTR_QUEUES CN23XX_MAX_INPUT_QUEUES + #define LIO_DEVICE_NAME_LEN 32 #define LIO_BASE_MAJOR_VERSION 1 #define LIO_BASE_MINOR_VERSION 5 diff --git a/drivers/net/liquidio/lio_ethdev.c b/drivers/net/liquidio/lio_ethdev.c index 5aae105..5d7d5a7 100644 --- a/drivers/net/liquidio/lio_ethdev.c +++ b/drivers/net/liquidio/lio_ethdev.c @@ -39,6 +39,7 @@ #include "lio_logs.h" #include "lio_23xx_vf.h" #include "lio_ethdev.h" +#include "lio_rxtx.h" static void lio_check_pf_hs_response(void *lio_dev) @@ -127,6 +128,11 @@ goto error; } + if (lio_setup_instr_queue0(lio_dev)) { + lio_dev_err(lio_dev, "Failed to setup instruction queue 0\n"); + goto error; + } + dpdk_queues = (int)lio_dev->sriov_info.rings_per_vf; lio_dev->max_tx_queues = dpdk_queues; @@ -137,6 +143,8 @@ error: if (lio_dev->mbox[0]) lio_dev->fn_list.free_mbox(lio_dev); + if (lio_dev->instr_queue[0]) + lio_free_instr_queue0(lio_dev); return -1; } diff --git a/drivers/net/liquidio/lio_rxtx.c b/drivers/net/liquidio/lio_rxtx.c new file mode 100644 index 0000000..de98fc6 --- /dev/null +++ b/drivers/net/liquidio/lio_rxtx.c @@ -0,0 +1,206 @@ +/* + * 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_struct.h" +#include "lio_ethdev.h" +#include "lio_rxtx.h" + +static void +lio_dma_zone_free(struct lio_device *lio_dev, const struct rte_memzone *mz) +{ + const struct rte_memzone *mz_tmp; + int ret = 0; + + if (mz == NULL) { + lio_dev_err(lio_dev, "Memzone NULL\n"); + return; + } + + mz_tmp = rte_memzone_lookup(mz->name); + if (mz_tmp == NULL) { + lio_dev_err(lio_dev, "Memzone %s Not Found\n", mz->name); + return; + } + + ret = rte_memzone_free(mz); + if (ret) + lio_dev_err(lio_dev, "Memzone free Failed ret %d\n", ret); +} + +/** + * lio_init_instr_queue() + * @param lio_dev - pointer to the lio device structure. + * @param txpciq - queue to be initialized. + * + * Called at driver init time for each input queue. iq_conf has the + * configuration parameters for the queue. + * + * @return Success: 0 Failure: -1 + */ +static int +lio_init_instr_queue(struct lio_device *lio_dev, + union octeon_txpciq txpciq, + uint32_t num_descs, unsigned int socket_id) +{ + uint32_t iq_no = (uint32_t)txpciq.s.q_no; + struct lio_instr_queue *iq; + uint32_t instr_type; + uint32_t q_size; + + instr_type = LIO_IQ_INSTR_TYPE(lio_dev); + + q_size = instr_type * num_descs; + iq = lio_dev->instr_queue[iq_no]; + iq->iq_mz = rte_eth_dma_zone_reserve(lio_dev->eth_dev, + "instr_queue", iq_no, q_size, + RTE_CACHE_LINE_SIZE, + socket_id); + if (iq->iq_mz == NULL) { + lio_dev_err(lio_dev, "Cannot allocate memory for instr queue %d\n", + iq_no); + return -1; + } + + iq->base_addr_dma = iq->iq_mz->phys_addr; + iq->base_addr = (uint8_t *)iq->iq_mz->addr; + + iq->max_count = num_descs; + + /* Initialize a list to holds requests that have been posted to Octeon + * but has yet to be fetched by octeon + */ + iq->request_list = rte_zmalloc_socket("request_list", + sizeof(*iq->request_list) * + num_descs, + RTE_CACHE_LINE_SIZE, + socket_id); + if (iq->request_list == NULL) { + lio_dev_err(lio_dev, "Alloc failed for IQ[%d] nr free list\n", + iq_no); + lio_dma_zone_free(lio_dev, iq->iq_mz); + return -1; + } + + lio_dev_dbg(lio_dev, "IQ[%d]: base: %p basedma: %lx count: %d\n", + iq_no, iq->base_addr, (unsigned long)iq->base_addr_dma, + iq->max_count); + + iq->lio_dev = lio_dev; + iq->txpciq.txpciq64 = txpciq.txpciq64; + iq->fill_cnt = 0; + iq->host_write_index = 0; + iq->lio_read_index = 0; + iq->flush_index = 0; + + rte_atomic64_set(&iq->instr_pending, 0); + + /* Initialize the spinlock for this instruction queue */ + rte_spinlock_init(&iq->lock); + rte_spinlock_init(&iq->post_lock); + + rte_atomic64_clear(&iq->iq_flush_running); + + lio_dev->io_qmask.iq |= (1ULL << iq_no); + + /* Set the 32B/64B mode for each input queue */ + lio_dev->io_qmask.iq64B |= ((instr_type == 64) << iq_no); + iq->iqcmd_64B = (instr_type == 64); + + return 0; +} + +int +lio_setup_instr_queue0(struct lio_device *lio_dev) +{ + union octeon_txpciq txpciq; + uint32_t num_descs = 0; + uint32_t iq_no = 0; + + num_descs = LIO_NUM_DEF_TX_DESCS_CFG(lio_dev); + + lio_dev->num_iqs = 0; + + lio_dev->instr_queue[0] = rte_zmalloc(NULL, + sizeof(struct lio_instr_queue), 0); + if (lio_dev->instr_queue[0] == NULL) + return -ENOMEM; + + lio_dev->instr_queue[0]->q_index = 0; + lio_dev->instr_queue[0]->app_ctx = (void *)(size_t)0; + txpciq.txpciq64 = 0; + txpciq.s.q_no = iq_no; + txpciq.s.pkind = lio_dev->pfvf_hsword.pkind; + txpciq.s.use_qpg = 0; + txpciq.s.qpg = 0; + if (lio_init_instr_queue(lio_dev, txpciq, num_descs, SOCKET_ID_ANY)) { + rte_free(lio_dev->instr_queue[0]); + lio_dev->instr_queue[0] = NULL; + return -1; + } + + lio_dev->num_iqs++; + + return 0; +} + +/** + * lio_delete_instr_queue() + * @param lio_dev - pointer to the lio device structure. + * @param iq_no - queue to be deleted. + * + * Called at driver unload time for each input queue. Deletes all + * allocated resources for the input queue. + */ +static void +lio_delete_instr_queue(struct lio_device *lio_dev, uint32_t iq_no) +{ + struct lio_instr_queue *iq = lio_dev->instr_queue[iq_no]; + + rte_free(iq->request_list); + iq->request_list = NULL; + lio_dma_zone_free(lio_dev, iq->iq_mz); +} + +void +lio_free_instr_queue0(struct lio_device *lio_dev) +{ + lio_delete_instr_queue(lio_dev, 0); + rte_free(lio_dev->instr_queue[0]); + lio_dev->instr_queue[0] = NULL; + lio_dev->num_iqs--; +} diff --git a/drivers/net/liquidio/lio_rxtx.h b/drivers/net/liquidio/lio_rxtx.h new file mode 100644 index 0000000..33f178b --- /dev/null +++ b/drivers/net/liquidio/lio_rxtx.h @@ -0,0 +1,57 @@ +/* + * 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_RXTX_H_ +#define _LIO_RXTX_H_ + +#include +#include + +#include +#include + +#include "lio_struct.h" + +struct lio_request_list { + uint32_t reqtype; + void *buf; +}; + +/** Setup instruction queue zero for the device + * @param lio_dev which lio device to setup + * + * @return 0 if success. -1 if fails + */ +int lio_setup_instr_queue0(struct lio_device *lio_dev); +void lio_free_instr_queue0(struct lio_device *lio_dev); +#endif /* _LIO_RXTX_H_ */ diff --git a/drivers/net/liquidio/lio_struct.h b/drivers/net/liquidio/lio_struct.h index e8b6e1d..29059a5 100644 --- a/drivers/net/liquidio/lio_struct.h +++ b/drivers/net/liquidio/lio_struct.h @@ -50,7 +50,110 @@ struct lio_version { uint16_t reserved; }; -struct lio_device; +/** The txpciq info passed to host from the firmware */ +union octeon_txpciq { + uint64_t txpciq64; + + struct { +#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN + uint64_t q_no : 8; + uint64_t port : 8; + uint64_t pkind : 6; + uint64_t use_qpg : 1; + uint64_t qpg : 11; + uint64_t aura_num : 10; + uint64_t reserved : 20; +#else + uint64_t reserved : 20; + uint64_t aura_num : 10; + uint64_t qpg : 11; + uint64_t use_qpg : 1; + uint64_t pkind : 6; + uint64_t port : 8; + uint64_t q_no : 8; +#endif + } s; +}; + +/** The instruction (input) queue. + * The input queue is used to post raw (instruction) mode data or packet + * data to Octeon device from the host. Each input queue for + * a LIO device has one such structure to represent it. + */ +struct lio_instr_queue { + /** A spinlock to protect access to the input ring. */ + rte_spinlock_t lock; + + rte_spinlock_t post_lock; + + struct lio_device *lio_dev; + + uint32_t pkt_in_done; + + rte_atomic64_t iq_flush_running; + + /** Flag that indicates if the queue uses 64 byte commands. */ + uint32_t iqcmd_64B:1; + + /** Queue info. */ + union octeon_txpciq txpciq; + + uint32_t rsvd:17; + + uint32_t status:8; + + /** Maximum no. of instructions in this queue. */ + uint32_t max_count; + + /** Index in input ring where the driver should write the next packet */ + uint32_t host_write_index; + + /** Index in input ring where Octeon is expected to read the next + * packet. + */ + uint32_t lio_read_index; + + /** This index aids in finding the window in the queue where Octeon + * has read the commands. + */ + uint32_t flush_index; + + /** This field keeps track of the instructions pending in this queue. */ + rte_atomic64_t instr_pending; + + /** Pointer to the Virtual Base addr of the input ring. */ + uint8_t *base_addr; + + struct lio_request_list *request_list; + + /** Octeon doorbell register for the ring. */ + void *doorbell_reg; + + /** Octeon instruction count register for this ring. */ + void *inst_cnt_reg; + + /** Number of instructions pending to be posted to Octeon. */ + uint32_t fill_cnt; + + /** DMA mapped base address of the input descriptor ring. */ + uint64_t base_addr_dma; + + /** Application context */ + void *app_ctx; + + /* network stack queue index */ + int q_index; + + /* Memory zone */ + const struct rte_memzone *iq_mz; +}; + +struct lio_io_enable { + uint64_t iq; + uint64_t oq; + uint64_t iq64B; +}; + struct lio_fn_list { int (*setup_mbox)(struct lio_device *); void (*free_mbox)(struct lio_device *); @@ -170,6 +273,13 @@ struct lio_device { struct lio_fn_list fn_list; + uint32_t num_iqs; + + /** The input instruction queues */ + struct lio_instr_queue *instr_queue[LIO_MAX_POSSIBLE_INSTR_QUEUES]; + + struct lio_io_enable io_qmask; + struct lio_sriov_info sriov_info; struct lio_pf_vf_hs_word pfvf_hsword; -- 1.8.3.1