From patchwork Wed Jun 21 13:22:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kalderon, Michal" X-Patchwork-Id: 9801827 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1DFF760234 for ; Wed, 21 Jun 2017 13:24:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0417F2855A for ; Wed, 21 Jun 2017 13:24:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EBD34285C5; Wed, 21 Jun 2017 13:23:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 54CA92855A for ; Wed, 21 Jun 2017 13:23:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751940AbdFUNXx (ORCPT ); Wed, 21 Jun 2017 09:23:53 -0400 Received: from mail-cys01nam02on0060.outbound.protection.outlook.com ([104.47.37.60]:54432 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751098AbdFUNX2 (ORCPT ); Wed, 21 Jun 2017 09:23:28 -0400 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=qxSRbdMfQSIrIhlbiXW4IPAIMG9iSELSk71ygOR1zzI=; b=Li++K+Oqr31K1QIMJoUTXdJSW/MKw3cfRsbe3uONnEy/wVN9LIgJyam5Q7Cv1383qopJ2aP5uWOBNVBF56dPEHXCKEKXoPUYim/mEKaeohafx0uHOBODh8miP7i9v3y9KVk3QolNGbYJfNiqU72zIqTLIm9MS3/pdUFnMNVmMek= Received: from SN1PR0701CA0028.namprd07.prod.outlook.com (2a01:111:e400:5173::38) by DM2PR07MB429.namprd07.prod.outlook.com (2a01:111:e400:243a::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1178.14; Wed, 21 Jun 2017 13:23:24 +0000 Received: from BY2FFO11FD010.protection.gbl (2a01:111:f400:7c0c::171) by SN1PR0701CA0028.outlook.office365.com (2a01:111:e400:5173::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1199.15 via Frontend Transport; Wed, 21 Jun 2017 13:23:23 +0000 Authentication-Results: spf=none (sender IP is 50.232.66.26) smtp.mailfrom=cavium.com; vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=cavium.com; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) Received: from CAEXCH02.caveonetworks.com (50.232.66.26) by BY2FFO11FD010.mail.protection.outlook.com (10.1.14.74) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.1178.14 via Frontend Transport; Wed, 21 Jun 2017 13:23:23 +0000 Received: from lb-tlvb-michal.il.qlogic.com.com (10.185.6.89) by CAEXCH02.caveonetworks.com (10.17.4.29) with Microsoft SMTP Server id 14.2.347.0; Wed, 21 Jun 2017 06:23:20 -0700 From: Michal Kalderon To: , CC: , , , Michal Kalderon , Yuval Mintz Subject: [PATCH net-next 3/4] qed: Split rdma content between qed_rdma and qed_roce Date: Wed, 21 Jun 2017 16:22:45 +0300 Message-ID: <1498051366-22988-4-git-send-email-Michal.Kalderon@cavium.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1498051366-22988-1-git-send-email-Michal.Kalderon@cavium.com> References: <1498051366-22988-1-git-send-email-Michal.Kalderon@cavium.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:50.232.66.26; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(39400400002)(39450400003)(39410400002)(39840400002)(39850400002)(2980300002)(428002)(189002)(199003)(9170700003)(8936002)(50986999)(76176999)(81166006)(106466001)(5660300001)(5003940100001)(105586002)(189998001)(305945005)(356003)(50226002)(101416001)(36756003)(38730400002)(107886003)(4326008)(53946003)(54906002)(2950100002)(6666003)(77096006)(478600001)(72206003)(47776003)(8676002)(48376002)(104016004)(575784001)(86362001)(50466002)(2906002)(579004)(559001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR07MB429; H:CAEXCH02.caveonetworks.com; FPR:; SPF:None; MLV:sfv; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD010; 1:2jSo5MCO5/q/Zm6i5x2IG+Wa+RTPUcxWH4D+2zKczEC8Ysqk+1cJatoBZgzu1lQ7yENbw79gDxLRS02zPe6KV656ZDdnxKbrNC5riWILpR3f7VFYbbwWXcerthapKCs5e/6cIAEyzQOWcKNzQb1IDF913hqWCC8xfg5X5a4WrRhhKMwMUi0ee5+JokkL9um9SBsdTJqHMuuXpVPaVThq0PKprEH4Ts3dpOKY+vNbhChLJBPyEnmCy2+Ekt4T8nzfyD5oyqH6HM7VvJRksReQ8q/uRpXDHTHdryJw/qinKu2Zl5He314jTqqMcoLzgjVJB4gGc8qVjSN9tr5X/7vYpluCRp6V+NaMaRjwDmEakVoHz8k3ObqBxaIUrdD35taNxLgDdegukPpR2uwY6AFfC2oTNt1ukz/hIr/hbsQJqNfFjAoOzh4PHZ/ybiA6NGq31ZvbFeueavQPEOhSCOet9g5UeUhPM5DA/i7uLVx5y36Jx9EjoUcGiEGowbSwq5BvQuesnZsuidDAaAf2vOBcQxqw7hHNhU+xSW0jDGaZJt0rZ2V+1NIvNrlijKvdp7YTKqgZNJHjIIxLQhm1c1TmKkSSz4hXedYEfIRGr+6HuwF/+0P5+CnIB4bkHXCTk6r3NEfgOIJMo7+moXcg7nQLOLhR6Ry/1Os7Q1uN3+o/2QFOcLHZM98fPj1ByBekHVaVvwltsxgSsuY3eqwIQTlPPA== X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7c98f742-3b87-4cdb-547a-08d4b8a8b15d X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017030254075)(201703131423075)(201703031133081)(201702281549075); SRVR:DM2PR07MB429; X-Microsoft-Exchange-Diagnostics: 1; DM2PR07MB429; 3:H2YaWzCPrTIod3gE1ipH8cnsqjnqQC5hqb8ncEAUjxuMqLrTUhESE6zfUmy59QZUYDNDUtflBOWQEvqYHSv7bkuaisFPJ9lFLa5LLnCUh93VBiwRjRHOEbGvAofGIeuVOwvs2dNDN7MXuWGfrGYYEVBLl2cSQyX2ybUpLckUY3kE0G90W/F7s8+BNrGFLvKeQUR+kxK9fvc3HytjaAbwXH/sRrl11x/fUsI9CnG6Gjs2+6IyfTsRnPLW+TlHdl0iwG5A4rzcQoy/jG5er1JUrK0BWme3pMYedCAMIxC3KllhvdIpb4MEG6wD6uss8Fpy3ayzFKRdMOjC6CtdgI+paK5YO921USK1f1SvNNLh5sJR205/BZrfkC+GBmPWlK+CX/7wCYfltM9c1v39D837Husls10oA+4bfqcmSOAajksfjN76FCaZxUNmqVNzW0kyxl9PM51K1N/HPyUOg7Z+jmQa4fLDTnV1BvAxa7D7UlElIsQSIXou+LjCkcUvy3Io X-MS-TrafficTypeDiagnostic: DM2PR07MB429: X-Microsoft-Exchange-Diagnostics: 1; DM2PR07MB429; 25:eH3ENyeRfhxqclUL4k91xBf64Rp9kIH/hu5qUnD6aHeAnQT6lYr+94Z2Cy+gB0BtlWEQAK0c51sPdLTx/HNtqJRnJ2+LBYcq4dBhknKSMHRnRt4oGn79sc9XZiUg8ctBrIPwM/XKnyeQDEEUK2J7XJq5azLpvuw064fR9Lnw9fvKC/4pRygjtVXrZd3s2NUpD8lcCn0FDf7KuAQ5u4/3Cg+WHEtX9E+KqVvHzTCBAU3LhrJoX9MPNfh9Y69yxxpliFwzFr+CfT6PRDNivuv3SlCF6/6iktsfOJE6h8UQ06UfITivPzz9AetxgCkajnk7yxXAtBauFsxl0BrmnZuAYfp4dyEBwDBT2SeZb9J0vmzklaJjkDxVyaHROtyYuRvL5rrFuedSqSkoKz93SheTvwvsLB4i2hh2Qj8KdbFYRITDUuNyg0Urhyh1cgzLdEvZsDniBxdT8Md7VAi5tFWteNWMEwLsRIW9U4vtfwpVmRDEVKWJpWeavLQ9JK6bwRxh2xYbba9FNvPVglLLrXeQet+LrEkm1kImti/lk87CK5555mq38sg8PM6ROV2KMibq6teJLBdvzQMkmy18jppRGK18fhywvcaZtWXgcvV9YSw9DcZukLAPbL5bLUcwncceWpKOo6eBijNtgiDNkVX8sMOOTfoQ2SDsl7HkE8GjVMt4CpKruSgLnqYo8LCyW+gR/LHLV+P373oti1NJHeYCnc4MhPpQJmqFNPQDRD0ZyvD/P6UCwh8MZqMaGRAkjNjq+o+1XkHS1KlJtXJc+AAOCZlVFv4d6sQYEKPSolhdul83lH1B0v8yPBrOIk/AgjvdHJLd4HKAlABJh6kUv1kDrGnx2s3pCjdQEPUhbsCi2MJ/9x4W5d7iZHtZWXfASiqwPPHv/W2JG5AhLGsSINYWpxqrcMejPZnmtrX5fu7Xwy o= X-Microsoft-Exchange-Diagnostics: 1; DM2PR07MB429; 31:WrLigV8t/QKPbioGPYUuoEBEuxjMzbDgzuqZv8lfNCzyWHkLG3hwPSkLZ/WieMjD8aN6wk5BW8YjUy7JeZeT8T1DMQ3Y7i3LmSbATaX7MM99gArUf+oTcWp2hEtaxvcciUwwKQpDizZSU5KnpErW33bH9z3ivJGlVtHE0yiD5DLI6NkgzWMKK+vBnHxQmJUIYgYEUG+ysCEzsIEDSO30pbS4qpbvTRCu/VrfC3gYyJ9ckl/eoitQA9PNtxQ2oZTqwmWXFUjR0vW1DdzBLtWqCvZvRxaVPEPMC5OyWA6mX/Jjpydy4V9y1LZYyb6rhj3gYdnU8j9MX9t7KJjOB/j2XAUpwTG7LPtpGdRwwyrzBsJObusf470PAnIBHLfQiOzLC4lfimFCrMi+1bHNu12x1EDF2L2ab4h5Ro1d1m/HJCwkv3d5DEi6YaFqlP0r5sW3X4E41xqX+W9bK+XqgD9mKzFlFKi9iKsI2BbFFyasPSTwtk8sPY+VEVLvgolgqpYq3kTmoqxsP50HPM2GnC3It0vPtRgi3WzvKcp4Gw/C0AC15EhOb8keuEPgVzBzae9U4wOvXFwYHOti2Y3Muu0GNMXEjjPi4tS78H8DJfWih+zJSVoyWYS963FUCLm5Hn6HytgNkx195x6yMyWFTEAjc17KwGO6I5/0urgXNqGREhQ1RX93/dYO0be7lpWhMZqbYtzHzoCuIh7yAopBN+CqwA== X-Microsoft-Exchange-Diagnostics: 1; DM2PR07MB429; 20:l0P4qY1tXy2XcWBINu0IbeZV3/fGDUwaVv/bA8YeRJa7QFVFx9zmhpnvk2lnuk/p6xKBvE0oeLeY+SkdjfQEDgZ+9B1fxU9atYfKqqPe8g50dx0tKHAsHGtu2DfpdbY7JahDuomlUAAyBCVdAeEazM5j/dCvjuW/Vk7NZYAfvZYFPB7Z2ye8bVK0gBsINDwhS7IVL6jIL7+PIZ0TQ7M4EgYvnNjYxshlXefnm7kb6oihtetskWgmrY82ZGnL/bo9pTxADIfW+jFAGe4/1OnsJJxs9TzzSFsA+P/SWzZPS4kCJ4F6MbHyHNzuuSIp04yllHMKIK1BhMWT2JwmWocbq3c2+kVIV3KNyc34apSiiKEqGIGFnBadkppYpZAyFsRYZXVxTdRfTFxADKt2wLvyT0hdwYc7zUmNRinJPB48UcIBeilBt5NYy/GXypeSstXta0aP00uI37a67cG/ftV/wHS4Ws/8+DGDj89gXUV7pp2MjYQ9XgAGaBHKNzIT/SAk X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(13016025)(13018025)(3002001)(93006095)(93001095)(100000703101)(100105400095)(10201501046)(6041248)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123555025)(20161123562025)(20161123560025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DM2PR07MB429; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DM2PR07MB429; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR07MB429; 4:YTIU6paIeVq9y/8mVqQJ8ek12+7W3G7eOx4zdrfVwcc?= =?us-ascii?Q?jRkej/AtMaKFDrQQrbzoSIg4UAvA6eok7+ajNCOdf+a9we2NOa1t+dDCUJy6?= =?us-ascii?Q?mupRsUnhBXn6I/1gUX4UESwIDlhfzf2cV9v2/EoNNdE/jpLO913jxqH6D1XI?= =?us-ascii?Q?EFgwbD0FeN6EvfShA9FPSbtjoemc3OBXpxhfNAhRy3ensIyMjOVS0htU/yVZ?= =?us-ascii?Q?gKHZGIO6vIcrW/ohVaSiJeco/TLm5bv8nNQPI/u/Ys7Ax1+XPvkNcsg98/bi?= =?us-ascii?Q?kCV4tdAKyjCT+lis79R4ZNSwbRZUGpvg78vA3aKnaoAganSsxuh4uke25Nmk?= =?us-ascii?Q?f9c5Ny6qVajxeUDyRMRkkebMEPlYLckiJqoaxgN57MekaKR4ioswMe7IMkcU?= =?us-ascii?Q?K17PvBnJCHxtrjt2zAfD/TNLiygVWglx+N94QggcyTEfW8WN8CRjLsRFWnHy?= =?us-ascii?Q?FZBMttMneq2UPaX8G4xkdCEFh88Q7PO9+r/lsdUfa2g152myL36zVLLahUGi?= =?us-ascii?Q?urVM0WzvJFTsIuph34uCDVETorZrJGOtfkrEOhGK5y0Y9naIz4l9Tq2QvkyW?= =?us-ascii?Q?BL0+JzD0HWXLxmucHFyzk3wOO2S7lcWHIDeOD2hk/i/8w5rPOK+cU9PJ5S2D?= =?us-ascii?Q?OnBp5/GY7P+EdpA6zoSB1y5w0A0X2WJB1FbI6cY7YOvA17RkIbWitA0yC3N9?= =?us-ascii?Q?drq/kelX2yNlICoga7fsexVoseYNe2vAKQaW2ZHptQ2+x/UTtTLFG+iLjmcF?= =?us-ascii?Q?PldvLax8L4JsMqfS8/T/n6EtQWtAhFFZ80QWxUcNlVEjtNFFVnZuPNSQnp0m?= =?us-ascii?Q?cD8Ohxiu2sOmJJctGaIfiw3BL+kt1E8Us9HQFFaN1DLT4PGN1ed8CFUbd1r8?= =?us-ascii?Q?ueY3c/X+Nd0rExIMsICPfONDbsdKQtLEzDWnTy3iS+3ThdVzcS3GMJCk/feI?= =?us-ascii?Q?Vht5irM1J4YXJgb7Bk3eRd3Q1E7XysPg/OBbGXRrkbPDd2GscB6ucnrXtVjf?= =?us-ascii?Q?K88Wa28hVOcBmU9iXwl3mJnQqAQJAEzs/5cj0ViIeK7Of95ME7r6acap2SxQ?= =?us-ascii?Q?IvVtB0lA6oZNE5X/TL3eRfygWSJQ/qa5pU6zSn8Yj/UzyXi4yMbH4gKMhs4N?= =?us-ascii?Q?+3xwYvHrMCT7yTs3ZAi4puzrLsRXSypSqV47kq2sPOV/OnAjPYlRtAfog1gk?= =?us-ascii?Q?mLcov+UfwnV8=3D?= X-Forefront-PRVS: 0345CFD558 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR07MB429; 23:4EKmqbAuLo84oNvXwRUeCRLmXV2Okv++JqyVtdsjOS?= =?us-ascii?Q?RRnhDnATbPULZ0TCUDQjg22yhvQx7fIfGkZziiDceH7P0Mhv9rMUN81nKjQz?= =?us-ascii?Q?P4ZvUuWiM9fILPJrwoFUCPbDb61Tr8AL4HqX1yEPR0Uh7rhDOzIaJdlvT4VH?= =?us-ascii?Q?hdlMOMxUmVbunuB3bk2ML/62N0dF3quCvhmiV+TfrRxn/8KULxXiyj6aNJdR?= =?us-ascii?Q?ljlafmmnwWYtJCC9SbkU/JzPvRm0aWewjx00JAufAkVr2+/bDdWKBF9KxIMn?= =?us-ascii?Q?6YvfBKo1dDLhoVi3GKwJ3rvkAMYgoq8QDJns9HMx9mVS7NYI4L3d55smre1b?= =?us-ascii?Q?eluH7qZyGjamUFJZv47x5WZZkK1w1rrJyXZURfRs7gZc06/WmecfuYYjFkLU?= =?us-ascii?Q?9ThDTuutQNN7VzKs4O+sk84WCacMcIKQwwZGunaJTtZfiLO9XUJqcMUL4dtx?= =?us-ascii?Q?+9Fik5hk5OSsSKOFTml/sJvN8/BTmDwqY2aTxTdVUKLvuJp3r6iYV1JtPWq1?= =?us-ascii?Q?9q/fRY+EFxs+MNyFm/9yyRNhsRITo4qQeYjCQtitiiabEhnT+l8pHgJ3vW8O?= =?us-ascii?Q?EoEfX22DgDrfZieQGoN3O0RfwFx4Tbkrx0ShL/X9/8SIvXG/NwpDFZeNPQNF?= =?us-ascii?Q?/geH6xDORJbhEZO2uSZvO8zrApY6G7a9813ZlLz6W8hr5W7eGc4GM8noF/pY?= =?us-ascii?Q?i2z4uByxPIggnTj6CapcfHc516WueKqeumNAsbPyVRxztvsxwo8uEKywtXZo?= =?us-ascii?Q?UpP7j4iSRgv7VGDtBI9rAnrL5xBoA4LM1dev/wlcBzVW+j+Q2pXgfXZD97VA?= =?us-ascii?Q?zf9kM6dtfcH8etLORIVwycG+CmlizRHuxXIs11UZqhpUB/bDVrGdiVs5CSRC?= =?us-ascii?Q?GKF4zx6pI17mYkwtZYAEQeZrAZpyu1CJ/9ZtZkEouTUM7oW53d/4VEqQ/Mh7?= =?us-ascii?Q?f++ZwF3G+4P74+ULwfPwKyfg8v+oFYzaGUsZMdXNG/krukm6w/K9otLimjwG?= =?us-ascii?Q?OKi7gtJ4ltF8+IS4bDVoJBd4lJyiPN2XhlXUHtyQYxm23h1tQ6HmUAtdyEFW?= =?us-ascii?Q?AKoZO/Ojy0UYs3/xfLLOnDE5ppOeGUL7GKX3NRxHoBjYBUwU6TOxKfSkqJrl?= =?us-ascii?Q?ZAIwlPYRs=3D?= X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR07MB429; 6:gZNzQgTyy3plG4XWLKua0+AXswOsyoGtGggbREMA9MU?= =?us-ascii?Q?qiPILpiemCvQFbET4rAbcjnHJkm2QvOXV/R4sOyZaIMGIh9XYYW/HACw5Dnq?= =?us-ascii?Q?Iz0h6BkD4z71vf5ArS44JRM6oqlcrfYkiF6KQrW2S0uL7gkVzq5VTLXfrAsi?= =?us-ascii?Q?l/c4jnPktJYH12lDy4R/cZpnuaXVE9HjSg77260iiaul8xeaCkcZg/aADS9y?= =?us-ascii?Q?nRuPFl8BH2tUb8GL8vniNYBdMS+924rfJiwLrQg1pflBZgyGY0P4QNL8D7JH?= =?us-ascii?Q?41sUZsspqf/izdYEYPwzEUtOAkuJz8pW+v0E0LOqSg4o4ECI7iy0Ztr+WY0H?= =?us-ascii?Q?fRgPbCTBSGDqzVxrpm8C34NiY6loP6hnsBNBMS7ZF6KZDA9XHBHaLxlAQWOe?= =?us-ascii?Q?umocziqkX5oc5cAa2hl9p0GIWDPuZCQDGE3/SE/qNCSydU+R6oZI7nuQrf2w?= =?us-ascii?Q?HvXjTTTI7Sim1wJPSVl47BCUSxXHFJARC0+NxRv8AJ8lGmQ75zOtNqa80nGU?= =?us-ascii?Q?GqC8I0rmCMkNfClHTki9TSw5dRtS/TqcGFPV5sGmdwsVRUvgq++KF0tJhZoL?= =?us-ascii?Q?+xF0zZ0OepaLmMaz8xtfkzvquQi1QU7KBJybSKKEWka9HPyG5mPC7TR4xRqM?= =?us-ascii?Q?1cBji4fBK9sl7o5snXmqgQGTsR2ax0+vxxzQbBVWi6urrHz0C8TeNAmI1GWM?= =?us-ascii?Q?KOtB1LMOE2wAynpJQ6IPBQIMkuvp38mMNbDirQ2hZv0xW1hQqqR3lkdV/thl?= =?us-ascii?Q?+HjV8OoWWiKcscAm6vnrYp4qBh4lvIKEpgw2hvcDKOg9nZY+e2ZdPqhl5rF+?= =?us-ascii?Q?5OtNIhTRbzuMLuHtAvotuMLDoommkeAxYKxdZKpO+EhGxonTU6DhnUkxStiw?= =?us-ascii?Q?9WPHr1oo6t86H3P5kOKD9AB7DFkmQsoaCQMwZZw5UwKFO6AyFd6vbDm8T1RS?= =?us-ascii?Q?iDwOa75BOxCIRCPju0kwynrXorpJRnZ8hNHwNymPnuGgVwioh3RWO5YA9wPk?= =?us-ascii?Q?=3D?= X-Microsoft-Exchange-Diagnostics: 1; DM2PR07MB429; 5:RBo+CgWYzYgNBxLECkWouMKfmfoPOfDJ6SST8vQ7WWev1cvCLBKqU7L6JTsQL6DU2rGrL44fHvJKOWRMSXflP60YBkIumTFQMftQgtI8TOJ6uz1RVTWZJbecakmU35TPcwX4AwqV06fcH7jmAjdMlR3IxTi08/2ETQlNglPWcX9oklFYXr2S2wicJGVDhlMXM2IiakrGy3HpNqUXiQ2y5Yy1jwJV/W7ZrvY1k6uTyBZQpcIG2tpvJrZdT7lfGDJ7bvfqTzzwljnm0/la92Xuq6hAhl0Ng0N2rLnSvgoxfJx1ukADm+HUR45eKL7KZnNrhvFmr59oBf3PS1fYSHpzg2AhXglFsRaHkM+wd2E6OLnq6frmOX2NX1XvMoCPSZcthzEeskPoVgl69XYBEb+2LX7LI8DZud1aZ5Q4PeGORwi9eSxvcJea29RSCHnIhljXmyLuXj+rTKE1a3+2TVdVBHV3QEseE3DEovpIBjG3Fi3qkqHm254HQMBFcKgnWyX+; 24:tObuOXcKLe5Tkvl4fAVyx6LJyjleJaHoeM94Z7zQ1Z17rv7ldF2GZ79Edlw4e+PvfueRvF24chxyuJcSFvw9l14KRM2DhdUzchnZJDZdjig= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR07MB429; 7:7WxiK5Wtg6ykoKmBOE3r44dXGfnpMBVmzxSw0AcnjKNkIEzF3s2Cz2a0xaInRCNuTJLqhHM3FLqpFjXX19lcFO65jEitFWxfha0mOPMNN/JSiFp4IohVPoqSpgEpM3VqCZBEdOXcAqQtYXVVkseb+IfqWLHo/JAMIp84JXCC8OX8UWU388OR6CG/79pVqjRnuz46E/HMbF1ZeM1B50NNPDHlkbHOqF/at+5/zJrBLYRVnJii6P5FqrvGgtF+bp1yK3DLVLXdvYwhUNt/H9eBjlhVMatGq0QYOGeu20SJAKNjSevvkdlZ2o++n7I6vF+xf4wrAsuWrAwLp5lN0E9DjBgk09r9f4K8tZry4UGKgEewFLscfQoTGa3OEVwB7Gd3hLLalYl3afI6kNnGYQ3UwC7jmdGUrRi+4lOLlyWBOw1ZPzrWmrkXtDkb3S/ckQu06mqocb9dIGY5M9BjHncvYdUiYZZjLgL7kOv9VUbx98VNGiT/62bE/U94kSAT1mti8x0Oq9UAEIB2LnewehgNLJMoJAvbNfC5e9QpuzUmOJghx4w+JFFCT1gOdam0Ap+gfU07HDkuAVOydqBVmIcLkQUewxc8w+jj2pIiG53pdtlmCsSVwvoLvIlo62UflsTlvky7oZYS2ciphHeZTTL4V6MP1h+CG6EFQ5WgBpuabPZlzBmzXrTUA0gVC6+el4x5Hg6LR4WYs0k3rsgTgxCjMkFXVdnLkx8o//gXXv4V9BbwYW3cJGIFLveRq5ptZFeZbFEqrSGBzWlVEm05cvPqspg6NrsVUkmmhI+2Il8IfDM= X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2017 13:23:23.3598 (UTC) X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=711e4ccf-2e9b-4bcf-a551-4094005b6194; Ip=[50.232.66.26]; Helo=[CAEXCH02.caveonetworks.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR07MB429 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch places common iWARP / RoCE code in qed_rdma and roce specific code in qed_roce There is one new function ( qed_roce_setup ) added, the rest of the patch removes content from the files and removes some static definitions. Signed-off-by: Michal Kalderon Signed-off-by: Yuval Mintz --- drivers/net/ethernet/qlogic/qed/Makefile | 2 +- drivers/net/ethernet/qlogic/qed/qed_dcbx.c | 2 +- drivers/net/ethernet/qlogic/qed/qed_dev.c | 2 +- drivers/net/ethernet/qlogic/qed/qed_ll2.c | 2 +- drivers/net/ethernet/qlogic/qed/qed_rdma.c | 1123 +------------------ drivers/net/ethernet/qlogic/qed/qed_rdma.h | 39 +- drivers/net/ethernet/qlogic/qed/qed_roce.c | 1682 +--------------------------- drivers/net/ethernet/qlogic/qed/qed_roce.h | 151 +-- drivers/net/ethernet/qlogic/qed/qed_spq.c | 2 +- 9 files changed, 86 insertions(+), 2919 deletions(-) diff --git a/drivers/net/ethernet/qlogic/qed/Makefile b/drivers/net/ethernet/qlogic/qed/Makefile index 974929d..6745238 100644 --- a/drivers/net/ethernet/qlogic/qed/Makefile +++ b/drivers/net/ethernet/qlogic/qed/Makefile @@ -5,6 +5,6 @@ qed-y := qed_cxt.o qed_dev.o qed_hw.o qed_init_fw_funcs.o qed_init_ops.o \ qed_selftest.o qed_dcbx.o qed_debug.o qed_ptp.o qed-$(CONFIG_QED_SRIOV) += qed_sriov.o qed_vf.o qed-$(CONFIG_QED_LL2) += qed_ll2.o -qed-$(CONFIG_QED_RDMA) += qed_roce.o +qed-$(CONFIG_QED_RDMA) += qed_roce.o qed_rdma.o qed-$(CONFIG_QED_ISCSI) += qed_iscsi.o qed_ooo.o qed-$(CONFIG_QED_FCOE) += qed_fcoe.o diff --git a/drivers/net/ethernet/qlogic/qed/qed_dcbx.c b/drivers/net/ethernet/qlogic/qed/qed_dcbx.c index f888045..eaca457 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_dcbx.c +++ b/drivers/net/ethernet/qlogic/qed/qed_dcbx.c @@ -44,7 +44,7 @@ #include "qed_hsi.h" #include "qed_sp.h" #include "qed_sriov.h" -#include "qed_roce.h" +#include "qed_rdma.h" #ifdef CONFIG_DCB #include #endif diff --git a/drivers/net/ethernet/qlogic/qed/qed_dev.c b/drivers/net/ethernet/qlogic/qed/qed_dev.c index 8b14054..49667ad 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_dev.c +++ b/drivers/net/ethernet/qlogic/qed/qed_dev.c @@ -62,7 +62,7 @@ #include "qed_sp.h" #include "qed_sriov.h" #include "qed_vf.h" -#include "qed_roce.h" +#include "qed_rdma.h" static DEFINE_SPINLOCK(qm_lock); diff --git a/drivers/net/ethernet/qlogic/qed/qed_ll2.c b/drivers/net/ethernet/qlogic/qed/qed_ll2.c index f9c51cb..17f9b0a 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_ll2.c +++ b/drivers/net/ethernet/qlogic/qed/qed_ll2.c @@ -61,7 +61,7 @@ #include "qed_ooo.h" #include "qed_reg_addr.h" #include "qed_sp.h" -#include "qed_roce.h" +#include "qed_rdma.h" #define QED_LL2_RX_REGISTERED(ll2) ((ll2)->rx_queue.b_cb_registred) #define QED_LL2_TX_REGISTERED(ll2) ((ll2)->tx_queue.b_cb_registred) diff --git a/drivers/net/ethernet/qlogic/qed/qed_rdma.c b/drivers/net/ethernet/qlogic/qed/qed_rdma.c index 9dc41a8..cb620e0 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_rdma.c +++ b/drivers/net/ethernet/qlogic/qed/qed_rdma.c @@ -53,39 +53,14 @@ #include "qed_ll2.h" #include "qed_mcp.h" #include "qed_reg_addr.h" -#include "qed_roce.h" #include +#include "qed_rdma.h" +#include "qed_roce.h" #include "qed_sp.h" -static void qed_roce_free_real_icid(struct qed_hwfn *p_hwfn, u16 icid); -static int -qed_roce_async_event(struct qed_hwfn *p_hwfn, - u8 fw_event_code, - u16 echo, union event_ring_data *data, u8 fw_return_code) -{ - if (fw_event_code == ROCE_ASYNC_EVENT_DESTROY_QP_DONE) { - u16 icid = - (u16)le32_to_cpu(data->rdma_data.rdma_destroy_qp_data.cid); - - /* icid release in this async event can occur only if the icid - * was offloaded to the FW. In case it wasn't offloaded this is - * handled in qed_roce_sp_destroy_qp. - */ - qed_roce_free_real_icid(p_hwfn, icid); - } else { - struct qed_rdma_events *events = &p_hwfn->p_rdma_info->events; - - events->affiliated_event(p_hwfn->p_rdma_info->events.context, - fw_event_code, - (void *)&data->rdma_data.async_handle); - } - - return 0; -} - -static int qed_rdma_bmap_alloc(struct qed_hwfn *p_hwfn, - struct qed_bmap *bmap, u32 max_count, char *name) +int qed_rdma_bmap_alloc(struct qed_hwfn *p_hwfn, + struct qed_bmap *bmap, u32 max_count, char *name) { DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "max_count = %08x\n", max_count); @@ -102,8 +77,8 @@ static int qed_rdma_bmap_alloc(struct qed_hwfn *p_hwfn, return 0; } -static int qed_rdma_bmap_alloc_id(struct qed_hwfn *p_hwfn, - struct qed_bmap *bmap, u32 *id_num) +int qed_rdma_bmap_alloc_id(struct qed_hwfn *p_hwfn, + struct qed_bmap *bmap, u32 *id_num) { *id_num = find_first_zero_bit(bmap->bitmap, bmap->max_count); if (*id_num >= bmap->max_count) @@ -117,8 +92,8 @@ static int qed_rdma_bmap_alloc_id(struct qed_hwfn *p_hwfn, return 0; } -static void qed_bmap_set_id(struct qed_hwfn *p_hwfn, - struct qed_bmap *bmap, u32 id_num) +void qed_bmap_set_id(struct qed_hwfn *p_hwfn, + struct qed_bmap *bmap, u32 id_num) { if (id_num >= bmap->max_count) return; @@ -126,8 +101,8 @@ static void qed_bmap_set_id(struct qed_hwfn *p_hwfn, __set_bit(id_num, bmap->bitmap); } -static void qed_bmap_release_id(struct qed_hwfn *p_hwfn, - struct qed_bmap *bmap, u32 id_num) +void qed_bmap_release_id(struct qed_hwfn *p_hwfn, + struct qed_bmap *bmap, u32 id_num) { bool b_acquired; @@ -145,8 +120,8 @@ static void qed_bmap_release_id(struct qed_hwfn *p_hwfn, bmap->name, id_num); } -static int qed_bmap_test_id(struct qed_hwfn *p_hwfn, - struct qed_bmap *bmap, u32 id_num) +int qed_bmap_test_id(struct qed_hwfn *p_hwfn, + struct qed_bmap *bmap, u32 id_num) { if (id_num >= bmap->max_count) return -1; @@ -159,7 +134,7 @@ static bool qed_bmap_is_empty(struct qed_bmap *bmap) return bmap->max_count == find_first_bit(bmap->bitmap, bmap->max_count); } -static u32 qed_rdma_get_sb_id(void *p_hwfn, u32 rel_sb_id) +u32 qed_rdma_get_sb_id(void *p_hwfn, u32 rel_sb_id) { /* First sb id for RoCE is after all the l2 sb */ return FEAT_NUM((struct qed_hwfn *)p_hwfn, QED_PF_L2_QUE) + rel_sb_id; @@ -302,8 +277,8 @@ static int qed_rdma_alloc(struct qed_hwfn *p_hwfn, return rc; } -static void qed_rdma_bmap_free(struct qed_hwfn *p_hwfn, - struct qed_bmap *bmap, bool check) +void qed_rdma_bmap_free(struct qed_hwfn *p_hwfn, + struct qed_bmap *bmap, bool check) { int weight = bitmap_weight(bmap->bitmap, bmap->max_count); int last_line = bmap->max_count / (64 * 8); @@ -666,33 +641,12 @@ static int qed_rdma_setup(struct qed_hwfn *p_hwfn, if (rc) return rc; - qed_spq_register_async_cb(p_hwfn, PROTOCOLID_ROCE, - qed_roce_async_event); + qed_roce_setup(p_hwfn); return qed_rdma_start_fw(p_hwfn, params, p_ptt); } -void qed_roce_stop(struct qed_hwfn *p_hwfn) -{ - struct qed_bmap *rcid_map = &p_hwfn->p_rdma_info->real_cid_map; - int wait_count = 0; - - /* when destroying a_RoCE QP the control is returned to the user after - * the synchronous part. The asynchronous part may take a little longer. - * We delay for a short while if an async destroy QP is still expected. - * Beyond the added delay we clear the bitmap anyway. - */ - while (bitmap_weight(rcid_map->bitmap, rcid_map->max_count)) { - msleep(100); - if (wait_count++ > 20) { - DP_NOTICE(p_hwfn, "cid bitmap wait timed out\n"); - break; - } - } - qed_spq_unregister_async_cb(p_hwfn, PROTOCOLID_ROCE); -} - -static int qed_rdma_stop(void *rdma_cxt) +int qed_rdma_stop(void *rdma_cxt) { struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; struct rdma_close_func_ramrod_data *p_ramrod; @@ -1146,904 +1100,13 @@ static int qed_rdma_create_cq(void *rdma_cxt, return rc; } -static void qed_rdma_set_fw_mac(u16 *p_fw_mac, u8 *p_qed_mac) +void qed_rdma_set_fw_mac(u16 *p_fw_mac, u8 *p_qed_mac) { p_fw_mac[0] = cpu_to_le16((p_qed_mac[0] << 8) + p_qed_mac[1]); p_fw_mac[1] = cpu_to_le16((p_qed_mac[2] << 8) + p_qed_mac[3]); p_fw_mac[2] = cpu_to_le16((p_qed_mac[4] << 8) + p_qed_mac[5]); } -static void qed_rdma_copy_gids(struct qed_rdma_qp *qp, __le32 *src_gid, - __le32 *dst_gid) -{ - u32 i; - - if (qp->roce_mode == ROCE_V2_IPV4) { - /* The IPv4 addresses shall be aligned to the highest word. - * The lower words must be zero. - */ - memset(src_gid, 0, sizeof(union qed_gid)); - memset(dst_gid, 0, sizeof(union qed_gid)); - src_gid[3] = cpu_to_le32(qp->sgid.ipv4_addr); - dst_gid[3] = cpu_to_le32(qp->dgid.ipv4_addr); - } else { - /* GIDs and IPv6 addresses coincide in location and size */ - for (i = 0; i < ARRAY_SIZE(qp->sgid.dwords); i++) { - src_gid[i] = cpu_to_le32(qp->sgid.dwords[i]); - dst_gid[i] = cpu_to_le32(qp->dgid.dwords[i]); - } - } -} - -static enum roce_flavor qed_roce_mode_to_flavor(enum roce_mode roce_mode) -{ - enum roce_flavor flavor; - - switch (roce_mode) { - case ROCE_V1: - flavor = PLAIN_ROCE; - break; - case ROCE_V2_IPV4: - flavor = RROCE_IPV4; - break; - case ROCE_V2_IPV6: - flavor = ROCE_V2_IPV6; - break; - default: - flavor = MAX_ROCE_MODE; - break; - } - return flavor; -} - -void qed_roce_free_cid_pair(struct qed_hwfn *p_hwfn, u16 cid) -{ - spin_lock_bh(&p_hwfn->p_rdma_info->lock); - qed_bmap_release_id(p_hwfn, &p_hwfn->p_rdma_info->cid_map, cid); - qed_bmap_release_id(p_hwfn, &p_hwfn->p_rdma_info->cid_map, cid + 1); - spin_unlock_bh(&p_hwfn->p_rdma_info->lock); -} - -static int qed_roce_alloc_cid(struct qed_hwfn *p_hwfn, u16 *cid) -{ - struct qed_rdma_info *p_rdma_info = p_hwfn->p_rdma_info; - u32 responder_icid; - u32 requester_icid; - int rc; - - spin_lock_bh(&p_hwfn->p_rdma_info->lock); - rc = qed_rdma_bmap_alloc_id(p_hwfn, &p_rdma_info->cid_map, - &responder_icid); - if (rc) { - spin_unlock_bh(&p_rdma_info->lock); - return rc; - } - - rc = qed_rdma_bmap_alloc_id(p_hwfn, &p_rdma_info->cid_map, - &requester_icid); - - spin_unlock_bh(&p_rdma_info->lock); - if (rc) - goto err; - - /* the two icid's should be adjacent */ - if ((requester_icid - responder_icid) != 1) { - DP_NOTICE(p_hwfn, "Failed to allocate two adjacent qp's'\n"); - rc = -EINVAL; - goto err; - } - - responder_icid += qed_cxt_get_proto_cid_start(p_hwfn, - p_rdma_info->proto); - requester_icid += qed_cxt_get_proto_cid_start(p_hwfn, - p_rdma_info->proto); - - /* If these icids require a new ILT line allocate DMA-able context for - * an ILT page - */ - rc = qed_cxt_dynamic_ilt_alloc(p_hwfn, QED_ELEM_CXT, responder_icid); - if (rc) - goto err; - - rc = qed_cxt_dynamic_ilt_alloc(p_hwfn, QED_ELEM_CXT, requester_icid); - if (rc) - goto err; - - *cid = (u16)responder_icid; - return rc; - -err: - spin_lock_bh(&p_rdma_info->lock); - qed_bmap_release_id(p_hwfn, &p_rdma_info->cid_map, responder_icid); - qed_bmap_release_id(p_hwfn, &p_rdma_info->cid_map, requester_icid); - - spin_unlock_bh(&p_rdma_info->lock); - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, - "Allocate CID - failed, rc = %d\n", rc); - return rc; -} - -static void qed_roce_set_real_cid(struct qed_hwfn *p_hwfn, u32 cid) -{ - spin_lock_bh(&p_hwfn->p_rdma_info->lock); - qed_bmap_set_id(p_hwfn, &p_hwfn->p_rdma_info->real_cid_map, cid); - spin_unlock_bh(&p_hwfn->p_rdma_info->lock); -} - -static int qed_roce_sp_create_responder(struct qed_hwfn *p_hwfn, - struct qed_rdma_qp *qp) -{ - struct roce_create_qp_resp_ramrod_data *p_ramrod; - struct qed_sp_init_data init_data; - enum roce_flavor roce_flavor; - struct qed_spq_entry *p_ent; - u16 regular_latency_queue; - enum protocol_type proto; - int rc; - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "icid = %08x\n", qp->icid); - - /* Allocate DMA-able memory for IRQ */ - qp->irq_num_pages = 1; - qp->irq = dma_alloc_coherent(&p_hwfn->cdev->pdev->dev, - RDMA_RING_PAGE_SIZE, - &qp->irq_phys_addr, GFP_KERNEL); - if (!qp->irq) { - rc = -ENOMEM; - DP_NOTICE(p_hwfn, - "qed create responder failed: cannot allocate memory (irq). rc = %d\n", - rc); - return rc; - } - - /* Get SPQ entry */ - memset(&init_data, 0, sizeof(init_data)); - init_data.cid = qp->icid; - init_data.opaque_fid = p_hwfn->hw_info.opaque_fid; - init_data.comp_mode = QED_SPQ_MODE_EBLOCK; - - rc = qed_sp_init_request(p_hwfn, &p_ent, ROCE_RAMROD_CREATE_QP, - PROTOCOLID_ROCE, &init_data); - if (rc) - goto err; - - p_ramrod = &p_ent->ramrod.roce_create_qp_resp; - - p_ramrod->flags = 0; - - roce_flavor = qed_roce_mode_to_flavor(qp->roce_mode); - SET_FIELD(p_ramrod->flags, - ROCE_CREATE_QP_RESP_RAMROD_DATA_ROCE_FLAVOR, roce_flavor); - - SET_FIELD(p_ramrod->flags, - ROCE_CREATE_QP_RESP_RAMROD_DATA_RDMA_RD_EN, - qp->incoming_rdma_read_en); - - SET_FIELD(p_ramrod->flags, - ROCE_CREATE_QP_RESP_RAMROD_DATA_RDMA_WR_EN, - qp->incoming_rdma_write_en); - - SET_FIELD(p_ramrod->flags, - ROCE_CREATE_QP_RESP_RAMROD_DATA_ATOMIC_EN, - qp->incoming_atomic_en); - - SET_FIELD(p_ramrod->flags, - ROCE_CREATE_QP_RESP_RAMROD_DATA_E2E_FLOW_CONTROL_EN, - qp->e2e_flow_control_en); - - SET_FIELD(p_ramrod->flags, - ROCE_CREATE_QP_RESP_RAMROD_DATA_SRQ_FLG, qp->use_srq); - - SET_FIELD(p_ramrod->flags, - ROCE_CREATE_QP_RESP_RAMROD_DATA_RESERVED_KEY_EN, - qp->fmr_and_reserved_lkey); - - SET_FIELD(p_ramrod->flags, - ROCE_CREATE_QP_RESP_RAMROD_DATA_MIN_RNR_NAK_TIMER, - qp->min_rnr_nak_timer); - - p_ramrod->max_ird = qp->max_rd_atomic_resp; - p_ramrod->traffic_class = qp->traffic_class_tos; - p_ramrod->hop_limit = qp->hop_limit_ttl; - p_ramrod->irq_num_pages = qp->irq_num_pages; - p_ramrod->p_key = cpu_to_le16(qp->pkey); - p_ramrod->flow_label = cpu_to_le32(qp->flow_label); - p_ramrod->dst_qp_id = cpu_to_le32(qp->dest_qp); - p_ramrod->mtu = cpu_to_le16(qp->mtu); - p_ramrod->initial_psn = cpu_to_le32(qp->rq_psn); - p_ramrod->pd = cpu_to_le16(qp->pd); - p_ramrod->rq_num_pages = cpu_to_le16(qp->rq_num_pages); - DMA_REGPAIR_LE(p_ramrod->rq_pbl_addr, qp->rq_pbl_ptr); - DMA_REGPAIR_LE(p_ramrod->irq_pbl_addr, qp->irq_phys_addr); - qed_rdma_copy_gids(qp, p_ramrod->src_gid, p_ramrod->dst_gid); - p_ramrod->qp_handle_for_async.hi = cpu_to_le32(qp->qp_handle_async.hi); - p_ramrod->qp_handle_for_async.lo = cpu_to_le32(qp->qp_handle_async.lo); - p_ramrod->qp_handle_for_cqe.hi = cpu_to_le32(qp->qp_handle.hi); - p_ramrod->qp_handle_for_cqe.lo = cpu_to_le32(qp->qp_handle.lo); - p_ramrod->cq_cid = cpu_to_le32((p_hwfn->hw_info.opaque_fid << 16) | - qp->rq_cq_id); - - regular_latency_queue = qed_get_cm_pq_idx(p_hwfn, PQ_FLAGS_OFLD); - - p_ramrod->regular_latency_phy_queue = - cpu_to_le16(regular_latency_queue); - p_ramrod->low_latency_phy_queue = - cpu_to_le16(regular_latency_queue); - - p_ramrod->dpi = cpu_to_le16(qp->dpi); - - qed_rdma_set_fw_mac(p_ramrod->remote_mac_addr, qp->remote_mac_addr); - qed_rdma_set_fw_mac(p_ramrod->local_mac_addr, qp->local_mac_addr); - - p_ramrod->udp_src_port = qp->udp_src_port; - p_ramrod->vlan_id = cpu_to_le16(qp->vlan_id); - p_ramrod->srq_id.srq_idx = cpu_to_le16(qp->srq_id); - p_ramrod->srq_id.opaque_fid = cpu_to_le16(p_hwfn->hw_info.opaque_fid); - - p_ramrod->stats_counter_id = RESC_START(p_hwfn, QED_RDMA_STATS_QUEUE) + - qp->stats_queue; - - rc = qed_spq_post(p_hwfn, p_ent, NULL); - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, - "rc = %d regular physical queue = 0x%x\n", rc, - regular_latency_queue); - - if (rc) - goto err; - - qp->resp_offloaded = true; - qp->cq_prod = 0; - - proto = p_hwfn->p_rdma_info->proto; - qed_roce_set_real_cid(p_hwfn, qp->icid - - qed_cxt_get_proto_cid_start(p_hwfn, proto)); - - return rc; - -err: - DP_NOTICE(p_hwfn, "create responder - failed, rc = %d\n", rc); - dma_free_coherent(&p_hwfn->cdev->pdev->dev, - qp->irq_num_pages * RDMA_RING_PAGE_SIZE, - qp->irq, qp->irq_phys_addr); - - return rc; -} - -static int qed_roce_sp_create_requester(struct qed_hwfn *p_hwfn, - struct qed_rdma_qp *qp) -{ - struct roce_create_qp_req_ramrod_data *p_ramrod; - struct qed_sp_init_data init_data; - enum roce_flavor roce_flavor; - struct qed_spq_entry *p_ent; - u16 regular_latency_queue; - enum protocol_type proto; - int rc; - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "icid = %08x\n", qp->icid); - - /* Allocate DMA-able memory for ORQ */ - qp->orq_num_pages = 1; - qp->orq = dma_alloc_coherent(&p_hwfn->cdev->pdev->dev, - RDMA_RING_PAGE_SIZE, - &qp->orq_phys_addr, GFP_KERNEL); - if (!qp->orq) { - rc = -ENOMEM; - DP_NOTICE(p_hwfn, - "qed create requester failed: cannot allocate memory (orq). rc = %d\n", - rc); - return rc; - } - - /* Get SPQ entry */ - memset(&init_data, 0, sizeof(init_data)); - init_data.cid = qp->icid + 1; - init_data.opaque_fid = p_hwfn->hw_info.opaque_fid; - init_data.comp_mode = QED_SPQ_MODE_EBLOCK; - - rc = qed_sp_init_request(p_hwfn, &p_ent, - ROCE_RAMROD_CREATE_QP, - PROTOCOLID_ROCE, &init_data); - if (rc) - goto err; - - p_ramrod = &p_ent->ramrod.roce_create_qp_req; - - p_ramrod->flags = 0; - - roce_flavor = qed_roce_mode_to_flavor(qp->roce_mode); - SET_FIELD(p_ramrod->flags, - ROCE_CREATE_QP_REQ_RAMROD_DATA_ROCE_FLAVOR, roce_flavor); - - SET_FIELD(p_ramrod->flags, - ROCE_CREATE_QP_REQ_RAMROD_DATA_FMR_AND_RESERVED_EN, - qp->fmr_and_reserved_lkey); - - SET_FIELD(p_ramrod->flags, - ROCE_CREATE_QP_REQ_RAMROD_DATA_SIGNALED_COMP, qp->signal_all); - - SET_FIELD(p_ramrod->flags, - ROCE_CREATE_QP_REQ_RAMROD_DATA_ERR_RETRY_CNT, qp->retry_cnt); - - SET_FIELD(p_ramrod->flags, - ROCE_CREATE_QP_REQ_RAMROD_DATA_RNR_NAK_CNT, - qp->rnr_retry_cnt); - - p_ramrod->max_ord = qp->max_rd_atomic_req; - p_ramrod->traffic_class = qp->traffic_class_tos; - p_ramrod->hop_limit = qp->hop_limit_ttl; - p_ramrod->orq_num_pages = qp->orq_num_pages; - p_ramrod->p_key = cpu_to_le16(qp->pkey); - p_ramrod->flow_label = cpu_to_le32(qp->flow_label); - p_ramrod->dst_qp_id = cpu_to_le32(qp->dest_qp); - p_ramrod->ack_timeout_val = cpu_to_le32(qp->ack_timeout); - p_ramrod->mtu = cpu_to_le16(qp->mtu); - p_ramrod->initial_psn = cpu_to_le32(qp->sq_psn); - p_ramrod->pd = cpu_to_le16(qp->pd); - p_ramrod->sq_num_pages = cpu_to_le16(qp->sq_num_pages); - DMA_REGPAIR_LE(p_ramrod->sq_pbl_addr, qp->sq_pbl_ptr); - DMA_REGPAIR_LE(p_ramrod->orq_pbl_addr, qp->orq_phys_addr); - qed_rdma_copy_gids(qp, p_ramrod->src_gid, p_ramrod->dst_gid); - p_ramrod->qp_handle_for_async.hi = cpu_to_le32(qp->qp_handle_async.hi); - p_ramrod->qp_handle_for_async.lo = cpu_to_le32(qp->qp_handle_async.lo); - p_ramrod->qp_handle_for_cqe.hi = cpu_to_le32(qp->qp_handle.hi); - p_ramrod->qp_handle_for_cqe.lo = cpu_to_le32(qp->qp_handle.lo); - p_ramrod->cq_cid = - cpu_to_le32((p_hwfn->hw_info.opaque_fid << 16) | qp->sq_cq_id); - - regular_latency_queue = qed_get_cm_pq_idx(p_hwfn, PQ_FLAGS_OFLD); - - p_ramrod->regular_latency_phy_queue = - cpu_to_le16(regular_latency_queue); - p_ramrod->low_latency_phy_queue = - cpu_to_le16(regular_latency_queue); - - p_ramrod->dpi = cpu_to_le16(qp->dpi); - - qed_rdma_set_fw_mac(p_ramrod->remote_mac_addr, qp->remote_mac_addr); - qed_rdma_set_fw_mac(p_ramrod->local_mac_addr, qp->local_mac_addr); - - p_ramrod->udp_src_port = qp->udp_src_port; - p_ramrod->vlan_id = cpu_to_le16(qp->vlan_id); - p_ramrod->stats_counter_id = RESC_START(p_hwfn, QED_RDMA_STATS_QUEUE) + - qp->stats_queue; - - rc = qed_spq_post(p_hwfn, p_ent, NULL); - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "rc = %d\n", rc); - - if (rc) - goto err; - - qp->req_offloaded = true; - proto = p_hwfn->p_rdma_info->proto; - qed_roce_set_real_cid(p_hwfn, - qp->icid + 1 - - qed_cxt_get_proto_cid_start(p_hwfn, proto)); - - return rc; - -err: - DP_NOTICE(p_hwfn, "Create requested - failed, rc = %d\n", rc); - dma_free_coherent(&p_hwfn->cdev->pdev->dev, - qp->orq_num_pages * RDMA_RING_PAGE_SIZE, - qp->orq, qp->orq_phys_addr); - return rc; -} - -static int qed_roce_sp_modify_responder(struct qed_hwfn *p_hwfn, - struct qed_rdma_qp *qp, - bool move_to_err, u32 modify_flags) -{ - struct roce_modify_qp_resp_ramrod_data *p_ramrod; - struct qed_sp_init_data init_data; - struct qed_spq_entry *p_ent; - int rc; - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "icid = %08x\n", qp->icid); - - if (move_to_err && !qp->resp_offloaded) - return 0; - - /* Get SPQ entry */ - memset(&init_data, 0, sizeof(init_data)); - init_data.cid = qp->icid; - init_data.opaque_fid = p_hwfn->hw_info.opaque_fid; - init_data.comp_mode = QED_SPQ_MODE_EBLOCK; - - rc = qed_sp_init_request(p_hwfn, &p_ent, - ROCE_EVENT_MODIFY_QP, - PROTOCOLID_ROCE, &init_data); - if (rc) { - DP_NOTICE(p_hwfn, "rc = %d\n", rc); - return rc; - } - - p_ramrod = &p_ent->ramrod.roce_modify_qp_resp; - - p_ramrod->flags = 0; - - SET_FIELD(p_ramrod->flags, - ROCE_MODIFY_QP_RESP_RAMROD_DATA_MOVE_TO_ERR_FLG, move_to_err); - - SET_FIELD(p_ramrod->flags, - ROCE_MODIFY_QP_RESP_RAMROD_DATA_RDMA_RD_EN, - qp->incoming_rdma_read_en); - - SET_FIELD(p_ramrod->flags, - ROCE_MODIFY_QP_RESP_RAMROD_DATA_RDMA_WR_EN, - qp->incoming_rdma_write_en); - - SET_FIELD(p_ramrod->flags, - ROCE_MODIFY_QP_RESP_RAMROD_DATA_ATOMIC_EN, - qp->incoming_atomic_en); - - SET_FIELD(p_ramrod->flags, - ROCE_CREATE_QP_RESP_RAMROD_DATA_E2E_FLOW_CONTROL_EN, - qp->e2e_flow_control_en); - - SET_FIELD(p_ramrod->flags, - ROCE_MODIFY_QP_RESP_RAMROD_DATA_RDMA_OPS_EN_FLG, - GET_FIELD(modify_flags, - QED_RDMA_MODIFY_QP_VALID_RDMA_OPS_EN)); - - SET_FIELD(p_ramrod->flags, - ROCE_MODIFY_QP_RESP_RAMROD_DATA_P_KEY_FLG, - GET_FIELD(modify_flags, QED_ROCE_MODIFY_QP_VALID_PKEY)); - - SET_FIELD(p_ramrod->flags, - ROCE_MODIFY_QP_RESP_RAMROD_DATA_ADDRESS_VECTOR_FLG, - GET_FIELD(modify_flags, - QED_ROCE_MODIFY_QP_VALID_ADDRESS_VECTOR)); - - SET_FIELD(p_ramrod->flags, - ROCE_MODIFY_QP_RESP_RAMROD_DATA_MAX_IRD_FLG, - GET_FIELD(modify_flags, - QED_RDMA_MODIFY_QP_VALID_MAX_RD_ATOMIC_RESP)); - - SET_FIELD(p_ramrod->flags, - ROCE_MODIFY_QP_RESP_RAMROD_DATA_MIN_RNR_NAK_TIMER_FLG, - GET_FIELD(modify_flags, - QED_ROCE_MODIFY_QP_VALID_MIN_RNR_NAK_TIMER)); - - p_ramrod->fields = 0; - SET_FIELD(p_ramrod->fields, - ROCE_MODIFY_QP_RESP_RAMROD_DATA_MIN_RNR_NAK_TIMER, - qp->min_rnr_nak_timer); - - p_ramrod->max_ird = qp->max_rd_atomic_resp; - p_ramrod->traffic_class = qp->traffic_class_tos; - p_ramrod->hop_limit = qp->hop_limit_ttl; - p_ramrod->p_key = cpu_to_le16(qp->pkey); - p_ramrod->flow_label = cpu_to_le32(qp->flow_label); - p_ramrod->mtu = cpu_to_le16(qp->mtu); - qed_rdma_copy_gids(qp, p_ramrod->src_gid, p_ramrod->dst_gid); - rc = qed_spq_post(p_hwfn, p_ent, NULL); - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Modify responder, rc = %d\n", rc); - return rc; -} - -static int qed_roce_sp_modify_requester(struct qed_hwfn *p_hwfn, - struct qed_rdma_qp *qp, - bool move_to_sqd, - bool move_to_err, u32 modify_flags) -{ - struct roce_modify_qp_req_ramrod_data *p_ramrod; - struct qed_sp_init_data init_data; - struct qed_spq_entry *p_ent; - int rc; - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "icid = %08x\n", qp->icid); - - if (move_to_err && !(qp->req_offloaded)) - return 0; - - /* Get SPQ entry */ - memset(&init_data, 0, sizeof(init_data)); - init_data.cid = qp->icid + 1; - init_data.opaque_fid = p_hwfn->hw_info.opaque_fid; - init_data.comp_mode = QED_SPQ_MODE_EBLOCK; - - rc = qed_sp_init_request(p_hwfn, &p_ent, - ROCE_EVENT_MODIFY_QP, - PROTOCOLID_ROCE, &init_data); - if (rc) { - DP_NOTICE(p_hwfn, "rc = %d\n", rc); - return rc; - } - - p_ramrod = &p_ent->ramrod.roce_modify_qp_req; - - p_ramrod->flags = 0; - - SET_FIELD(p_ramrod->flags, - ROCE_MODIFY_QP_REQ_RAMROD_DATA_MOVE_TO_ERR_FLG, move_to_err); - - SET_FIELD(p_ramrod->flags, - ROCE_MODIFY_QP_REQ_RAMROD_DATA_MOVE_TO_SQD_FLG, move_to_sqd); - - SET_FIELD(p_ramrod->flags, - ROCE_MODIFY_QP_REQ_RAMROD_DATA_EN_SQD_ASYNC_NOTIFY, - qp->sqd_async); - - SET_FIELD(p_ramrod->flags, - ROCE_MODIFY_QP_REQ_RAMROD_DATA_P_KEY_FLG, - GET_FIELD(modify_flags, QED_ROCE_MODIFY_QP_VALID_PKEY)); - - SET_FIELD(p_ramrod->flags, - ROCE_MODIFY_QP_REQ_RAMROD_DATA_ADDRESS_VECTOR_FLG, - GET_FIELD(modify_flags, - QED_ROCE_MODIFY_QP_VALID_ADDRESS_VECTOR)); - - SET_FIELD(p_ramrod->flags, - ROCE_MODIFY_QP_REQ_RAMROD_DATA_MAX_ORD_FLG, - GET_FIELD(modify_flags, - QED_RDMA_MODIFY_QP_VALID_MAX_RD_ATOMIC_REQ)); - - SET_FIELD(p_ramrod->flags, - ROCE_MODIFY_QP_REQ_RAMROD_DATA_RNR_NAK_CNT_FLG, - GET_FIELD(modify_flags, - QED_ROCE_MODIFY_QP_VALID_RNR_RETRY_CNT)); - - SET_FIELD(p_ramrod->flags, - ROCE_MODIFY_QP_REQ_RAMROD_DATA_ERR_RETRY_CNT_FLG, - GET_FIELD(modify_flags, QED_ROCE_MODIFY_QP_VALID_RETRY_CNT)); - - SET_FIELD(p_ramrod->flags, - ROCE_MODIFY_QP_REQ_RAMROD_DATA_ACK_TIMEOUT_FLG, - GET_FIELD(modify_flags, - QED_ROCE_MODIFY_QP_VALID_ACK_TIMEOUT)); - - p_ramrod->fields = 0; - SET_FIELD(p_ramrod->fields, - ROCE_MODIFY_QP_REQ_RAMROD_DATA_ERR_RETRY_CNT, qp->retry_cnt); - - SET_FIELD(p_ramrod->fields, - ROCE_MODIFY_QP_REQ_RAMROD_DATA_RNR_NAK_CNT, - qp->rnr_retry_cnt); - - p_ramrod->max_ord = qp->max_rd_atomic_req; - p_ramrod->traffic_class = qp->traffic_class_tos; - p_ramrod->hop_limit = qp->hop_limit_ttl; - p_ramrod->p_key = cpu_to_le16(qp->pkey); - p_ramrod->flow_label = cpu_to_le32(qp->flow_label); - p_ramrod->ack_timeout_val = cpu_to_le32(qp->ack_timeout); - p_ramrod->mtu = cpu_to_le16(qp->mtu); - qed_rdma_copy_gids(qp, p_ramrod->src_gid, p_ramrod->dst_gid); - rc = qed_spq_post(p_hwfn, p_ent, NULL); - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Modify requester, rc = %d\n", rc); - return rc; -} - -static int qed_roce_sp_destroy_qp_responder(struct qed_hwfn *p_hwfn, - struct qed_rdma_qp *qp, - u32 *num_invalidated_mw, - u32 *cq_prod) -{ - struct roce_destroy_qp_resp_output_params *p_ramrod_res; - struct roce_destroy_qp_resp_ramrod_data *p_ramrod; - struct qed_sp_init_data init_data; - struct qed_spq_entry *p_ent; - dma_addr_t ramrod_res_phys; - int rc; - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "icid = %08x\n", qp->icid); - - *num_invalidated_mw = 0; - *cq_prod = qp->cq_prod; - - if (!qp->resp_offloaded) { - /* If a responder was never offload, we need to free the cids - * allocated in create_qp as a FW async event will never arrive - */ - u32 cid; - - cid = qp->icid - - qed_cxt_get_proto_cid_start(p_hwfn, - p_hwfn->p_rdma_info->proto); - qed_roce_free_cid_pair(p_hwfn, (u16)cid); - - return 0; - } - - /* Get SPQ entry */ - memset(&init_data, 0, sizeof(init_data)); - init_data.cid = qp->icid; - init_data.opaque_fid = p_hwfn->hw_info.opaque_fid; - init_data.comp_mode = QED_SPQ_MODE_EBLOCK; - - rc = qed_sp_init_request(p_hwfn, &p_ent, - ROCE_RAMROD_DESTROY_QP, - PROTOCOLID_ROCE, &init_data); - if (rc) - return rc; - - p_ramrod = &p_ent->ramrod.roce_destroy_qp_resp; - - p_ramrod_res = (struct roce_destroy_qp_resp_output_params *) - dma_alloc_coherent(&p_hwfn->cdev->pdev->dev, sizeof(*p_ramrod_res), - &ramrod_res_phys, GFP_KERNEL); - - if (!p_ramrod_res) { - rc = -ENOMEM; - DP_NOTICE(p_hwfn, - "qed destroy responder failed: cannot allocate memory (ramrod). rc = %d\n", - rc); - return rc; - } - - DMA_REGPAIR_LE(p_ramrod->output_params_addr, ramrod_res_phys); - - rc = qed_spq_post(p_hwfn, p_ent, NULL); - if (rc) - goto err; - - *num_invalidated_mw = le32_to_cpu(p_ramrod_res->num_invalidated_mw); - *cq_prod = le32_to_cpu(p_ramrod_res->cq_prod); - qp->cq_prod = *cq_prod; - - /* Free IRQ - only if ramrod succeeded, in case FW is still using it */ - dma_free_coherent(&p_hwfn->cdev->pdev->dev, - qp->irq_num_pages * RDMA_RING_PAGE_SIZE, - qp->irq, qp->irq_phys_addr); - - qp->resp_offloaded = false; - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Destroy responder, rc = %d\n", rc); - -err: - dma_free_coherent(&p_hwfn->cdev->pdev->dev, - sizeof(struct roce_destroy_qp_resp_output_params), - p_ramrod_res, ramrod_res_phys); - - return rc; -} - -static int qed_roce_sp_destroy_qp_requester(struct qed_hwfn *p_hwfn, - struct qed_rdma_qp *qp, - u32 *num_bound_mw) -{ - struct roce_destroy_qp_req_output_params *p_ramrod_res; - struct roce_destroy_qp_req_ramrod_data *p_ramrod; - struct qed_sp_init_data init_data; - struct qed_spq_entry *p_ent; - dma_addr_t ramrod_res_phys; - int rc = -ENOMEM; - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "icid = %08x\n", qp->icid); - - if (!qp->req_offloaded) - return 0; - - p_ramrod_res = (struct roce_destroy_qp_req_output_params *) - dma_alloc_coherent(&p_hwfn->cdev->pdev->dev, - sizeof(*p_ramrod_res), - &ramrod_res_phys, GFP_KERNEL); - if (!p_ramrod_res) { - DP_NOTICE(p_hwfn, - "qed destroy requester failed: cannot allocate memory (ramrod)\n"); - return rc; - } - - /* Get SPQ entry */ - memset(&init_data, 0, sizeof(init_data)); - init_data.cid = qp->icid + 1; - init_data.opaque_fid = p_hwfn->hw_info.opaque_fid; - init_data.comp_mode = QED_SPQ_MODE_EBLOCK; - - rc = qed_sp_init_request(p_hwfn, &p_ent, ROCE_RAMROD_DESTROY_QP, - PROTOCOLID_ROCE, &init_data); - if (rc) - goto err; - - p_ramrod = &p_ent->ramrod.roce_destroy_qp_req; - DMA_REGPAIR_LE(p_ramrod->output_params_addr, ramrod_res_phys); - - rc = qed_spq_post(p_hwfn, p_ent, NULL); - if (rc) - goto err; - - *num_bound_mw = le32_to_cpu(p_ramrod_res->num_bound_mw); - - /* Free ORQ - only if ramrod succeeded, in case FW is still using it */ - dma_free_coherent(&p_hwfn->cdev->pdev->dev, - qp->orq_num_pages * RDMA_RING_PAGE_SIZE, - qp->orq, qp->orq_phys_addr); - - qp->req_offloaded = false; - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Destroy requester, rc = %d\n", rc); - -err: - dma_free_coherent(&p_hwfn->cdev->pdev->dev, sizeof(*p_ramrod_res), - p_ramrod_res, ramrod_res_phys); - - return rc; -} - -static int qed_roce_query_qp(struct qed_hwfn *p_hwfn, - struct qed_rdma_qp *qp, - struct qed_rdma_query_qp_out_params *out_params) -{ - struct roce_query_qp_resp_output_params *p_resp_ramrod_res; - struct roce_query_qp_req_output_params *p_req_ramrod_res; - struct roce_query_qp_resp_ramrod_data *p_resp_ramrod; - struct roce_query_qp_req_ramrod_data *p_req_ramrod; - struct qed_sp_init_data init_data; - dma_addr_t resp_ramrod_res_phys; - dma_addr_t req_ramrod_res_phys; - struct qed_spq_entry *p_ent; - bool rq_err_state; - bool sq_err_state; - bool sq_draining; - int rc = -ENOMEM; - - if ((!(qp->resp_offloaded)) && (!(qp->req_offloaded))) { - /* We can't send ramrod to the fw since this qp wasn't offloaded - * to the fw yet - */ - out_params->draining = false; - out_params->rq_psn = qp->rq_psn; - out_params->sq_psn = qp->sq_psn; - out_params->state = qp->cur_state; - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "No QPs as no offload\n"); - return 0; - } - - if (!(qp->resp_offloaded)) { - DP_NOTICE(p_hwfn, - "The responder's qp should be offloded before requester's\n"); - return -EINVAL; - } - - /* Send a query responder ramrod to FW to get RQ-PSN and state */ - p_resp_ramrod_res = (struct roce_query_qp_resp_output_params *) - dma_alloc_coherent(&p_hwfn->cdev->pdev->dev, - sizeof(*p_resp_ramrod_res), - &resp_ramrod_res_phys, GFP_KERNEL); - if (!p_resp_ramrod_res) { - DP_NOTICE(p_hwfn, - "qed query qp failed: cannot allocate memory (ramrod)\n"); - return rc; - } - - /* Get SPQ entry */ - memset(&init_data, 0, sizeof(init_data)); - init_data.cid = qp->icid; - init_data.opaque_fid = p_hwfn->hw_info.opaque_fid; - init_data.comp_mode = QED_SPQ_MODE_EBLOCK; - rc = qed_sp_init_request(p_hwfn, &p_ent, ROCE_RAMROD_QUERY_QP, - PROTOCOLID_ROCE, &init_data); - if (rc) - goto err_resp; - - p_resp_ramrod = &p_ent->ramrod.roce_query_qp_resp; - DMA_REGPAIR_LE(p_resp_ramrod->output_params_addr, resp_ramrod_res_phys); - - rc = qed_spq_post(p_hwfn, p_ent, NULL); - if (rc) - goto err_resp; - - out_params->rq_psn = le32_to_cpu(p_resp_ramrod_res->psn); - rq_err_state = GET_FIELD(le32_to_cpu(p_resp_ramrod_res->err_flag), - ROCE_QUERY_QP_RESP_OUTPUT_PARAMS_ERROR_FLG); - - dma_free_coherent(&p_hwfn->cdev->pdev->dev, sizeof(*p_resp_ramrod_res), - p_resp_ramrod_res, resp_ramrod_res_phys); - - if (!(qp->req_offloaded)) { - /* Don't send query qp for the requester */ - out_params->sq_psn = qp->sq_psn; - out_params->draining = false; - - if (rq_err_state) - qp->cur_state = QED_ROCE_QP_STATE_ERR; - - out_params->state = qp->cur_state; - - return 0; - } - - /* Send a query requester ramrod to FW to get SQ-PSN and state */ - p_req_ramrod_res = (struct roce_query_qp_req_output_params *) - dma_alloc_coherent(&p_hwfn->cdev->pdev->dev, - sizeof(*p_req_ramrod_res), - &req_ramrod_res_phys, - GFP_KERNEL); - if (!p_req_ramrod_res) { - rc = -ENOMEM; - DP_NOTICE(p_hwfn, - "qed query qp failed: cannot allocate memory (ramrod)\n"); - return rc; - } - - /* Get SPQ entry */ - init_data.cid = qp->icid + 1; - rc = qed_sp_init_request(p_hwfn, &p_ent, ROCE_RAMROD_QUERY_QP, - PROTOCOLID_ROCE, &init_data); - if (rc) - goto err_req; - - p_req_ramrod = &p_ent->ramrod.roce_query_qp_req; - DMA_REGPAIR_LE(p_req_ramrod->output_params_addr, req_ramrod_res_phys); - - rc = qed_spq_post(p_hwfn, p_ent, NULL); - if (rc) - goto err_req; - - out_params->sq_psn = le32_to_cpu(p_req_ramrod_res->psn); - sq_err_state = GET_FIELD(le32_to_cpu(p_req_ramrod_res->flags), - ROCE_QUERY_QP_REQ_OUTPUT_PARAMS_ERR_FLG); - sq_draining = - GET_FIELD(le32_to_cpu(p_req_ramrod_res->flags), - ROCE_QUERY_QP_REQ_OUTPUT_PARAMS_SQ_DRAINING_FLG); - - dma_free_coherent(&p_hwfn->cdev->pdev->dev, sizeof(*p_req_ramrod_res), - p_req_ramrod_res, req_ramrod_res_phys); - - out_params->draining = false; - - if (rq_err_state || sq_err_state) - qp->cur_state = QED_ROCE_QP_STATE_ERR; - else if (sq_draining) - out_params->draining = true; - out_params->state = qp->cur_state; - - return 0; - -err_req: - dma_free_coherent(&p_hwfn->cdev->pdev->dev, sizeof(*p_req_ramrod_res), - p_req_ramrod_res, req_ramrod_res_phys); - return rc; -err_resp: - dma_free_coherent(&p_hwfn->cdev->pdev->dev, sizeof(*p_resp_ramrod_res), - p_resp_ramrod_res, resp_ramrod_res_phys); - return rc; -} - -static int qed_roce_destroy_qp(struct qed_hwfn *p_hwfn, struct qed_rdma_qp *qp) -{ - u32 num_invalidated_mw = 0; - u32 num_bound_mw = 0; - u32 cq_prod; - int rc; - - /* Destroys the specified QP */ - if ((qp->cur_state != QED_ROCE_QP_STATE_RESET) && - (qp->cur_state != QED_ROCE_QP_STATE_ERR) && - (qp->cur_state != QED_ROCE_QP_STATE_INIT)) { - DP_NOTICE(p_hwfn, - "QP must be in error, reset or init state before destroying it\n"); - return -EINVAL; - } - - if (qp->cur_state != QED_ROCE_QP_STATE_RESET) { - rc = qed_roce_sp_destroy_qp_responder(p_hwfn, qp, - &num_invalidated_mw, - &cq_prod); - if (rc) - return rc; - - /* Send destroy requester ramrod */ - rc = qed_roce_sp_destroy_qp_requester(p_hwfn, qp, - &num_bound_mw); - if (rc) - return rc; - - if (num_invalidated_mw != num_bound_mw) { - DP_NOTICE(p_hwfn, - "number of invalidate memory windows is different from bounded ones\n"); - return -EINVAL; - } - } - - return 0; -} - static int qed_rdma_query_qp(void *rdma_cxt, struct qed_rdma_qp *qp, struct qed_rdma_query_qp_out_params *out_params) @@ -2170,114 +1233,6 @@ static int qed_rdma_destroy_qp(void *rdma_cxt, struct qed_rdma_qp *qp) return qp; } -static int qed_roce_modify_qp(struct qed_hwfn *p_hwfn, - struct qed_rdma_qp *qp, - enum qed_roce_qp_state prev_state, - struct qed_rdma_modify_qp_in_params *params) -{ - u32 num_invalidated_mw = 0, num_bound_mw = 0; - int rc = 0; - - /* Perform additional operations according to the current state and the - * next state - */ - if (((prev_state == QED_ROCE_QP_STATE_INIT) || - (prev_state == QED_ROCE_QP_STATE_RESET)) && - (qp->cur_state == QED_ROCE_QP_STATE_RTR)) { - /* Init->RTR or Reset->RTR */ - rc = qed_roce_sp_create_responder(p_hwfn, qp); - return rc; - } else if ((prev_state == QED_ROCE_QP_STATE_RTR) && - (qp->cur_state == QED_ROCE_QP_STATE_RTS)) { - /* RTR-> RTS */ - rc = qed_roce_sp_create_requester(p_hwfn, qp); - if (rc) - return rc; - - /* Send modify responder ramrod */ - rc = qed_roce_sp_modify_responder(p_hwfn, qp, false, - params->modify_flags); - return rc; - } else if ((prev_state == QED_ROCE_QP_STATE_RTS) && - (qp->cur_state == QED_ROCE_QP_STATE_RTS)) { - /* RTS->RTS */ - rc = qed_roce_sp_modify_responder(p_hwfn, qp, false, - params->modify_flags); - if (rc) - return rc; - - rc = qed_roce_sp_modify_requester(p_hwfn, qp, false, false, - params->modify_flags); - return rc; - } else if ((prev_state == QED_ROCE_QP_STATE_RTS) && - (qp->cur_state == QED_ROCE_QP_STATE_SQD)) { - /* RTS->SQD */ - rc = qed_roce_sp_modify_requester(p_hwfn, qp, true, false, - params->modify_flags); - return rc; - } else if ((prev_state == QED_ROCE_QP_STATE_SQD) && - (qp->cur_state == QED_ROCE_QP_STATE_SQD)) { - /* SQD->SQD */ - rc = qed_roce_sp_modify_responder(p_hwfn, qp, false, - params->modify_flags); - if (rc) - return rc; - - rc = qed_roce_sp_modify_requester(p_hwfn, qp, false, false, - params->modify_flags); - return rc; - } else if ((prev_state == QED_ROCE_QP_STATE_SQD) && - (qp->cur_state == QED_ROCE_QP_STATE_RTS)) { - /* SQD->RTS */ - rc = qed_roce_sp_modify_responder(p_hwfn, qp, false, - params->modify_flags); - if (rc) - return rc; - - rc = qed_roce_sp_modify_requester(p_hwfn, qp, false, false, - params->modify_flags); - - return rc; - } else if (qp->cur_state == QED_ROCE_QP_STATE_ERR) { - /* ->ERR */ - rc = qed_roce_sp_modify_responder(p_hwfn, qp, true, - params->modify_flags); - if (rc) - return rc; - - rc = qed_roce_sp_modify_requester(p_hwfn, qp, false, true, - params->modify_flags); - return rc; - } else if (qp->cur_state == QED_ROCE_QP_STATE_RESET) { - /* Any state -> RESET */ - u32 cq_prod; - - /* Send destroy responder ramrod */ - rc = qed_roce_sp_destroy_qp_responder(p_hwfn, - qp, - &num_invalidated_mw, - &cq_prod); - - if (rc) - return rc; - - qp->cq_prod = cq_prod; - - rc = qed_roce_sp_destroy_qp_requester(p_hwfn, qp, - &num_bound_mw); - - if (num_invalidated_mw != num_bound_mw) { - DP_NOTICE(p_hwfn, - "number of invalidate memory windows is different from bounded ones\n"); - return -EINVAL; - } - } else { - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "0\n"); - } - - return rc; -} - static int qed_rdma_modify_qp(void *rdma_cxt, struct qed_rdma_qp *qp, struct qed_rdma_modify_qp_in_params *params) @@ -2599,37 +1554,12 @@ static int qed_rdma_deregister_tid(void *rdma_cxt, u32 itid) return rc; } -static void qed_roce_free_real_icid(struct qed_hwfn *p_hwfn, u16 icid) -{ - struct qed_rdma_info *p_rdma_info = p_hwfn->p_rdma_info; - u32 start_cid, cid, xcid; - - /* an even icid belongs to a responder while an odd icid belongs to a - * requester. The 'cid' received as an input can be either. We calculate - * the "partner" icid and call it xcid. Only if both are free then the - * "cid" map can be cleared. - */ - start_cid = qed_cxt_get_proto_cid_start(p_hwfn, p_rdma_info->proto); - cid = icid - start_cid; - xcid = cid ^ 1; - - spin_lock_bh(&p_rdma_info->lock); - - qed_bmap_release_id(p_hwfn, &p_rdma_info->real_cid_map, cid); - if (qed_bmap_test_id(p_hwfn, &p_rdma_info->real_cid_map, xcid) == 0) { - qed_bmap_release_id(p_hwfn, &p_rdma_info->cid_map, cid); - qed_bmap_release_id(p_hwfn, &p_rdma_info->cid_map, xcid); - } - - spin_unlock_bh(&p_hwfn->p_rdma_info->lock); -} - static void *qed_rdma_get_rdma_ctx(struct qed_dev *cdev) { return QED_LEADING_HWFN(cdev); } -static bool qed_rdma_allocated_qps(struct qed_hwfn *p_hwfn) +bool qed_rdma_allocated_qps(struct qed_hwfn *p_hwfn) { bool result; @@ -2646,7 +1576,7 @@ static bool qed_rdma_allocated_qps(struct qed_hwfn *p_hwfn) return result; } -static void qed_rdma_dpm_conf(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt) +void qed_rdma_dpm_conf(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt) { u32 val; @@ -2658,19 +1588,6 @@ static void qed_rdma_dpm_conf(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt) val, p_hwfn->dcbx_no_edpm, p_hwfn->db_bar_no_edpm); } -void qed_roce_dpm_dcbx(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt) -{ - u8 val; - - /* if any QPs are already active, we want to disable DPM, since their - * context information contains information from before the latest DCBx - * update. Otherwise enable it. - */ - val = qed_rdma_allocated_qps(p_hwfn) ? true : false; - p_hwfn->dcbx_no_edpm = (u8)val; - - qed_rdma_dpm_conf(p_hwfn, p_ptt); -} void qed_rdma_dpm_bar(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt) { diff --git a/drivers/net/ethernet/qlogic/qed/qed_rdma.h b/drivers/net/ethernet/qlogic/qed/qed_rdma.h index b178d99..1836ff1 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_rdma.h +++ b/drivers/net/ethernet/qlogic/qed/qed_rdma.h @@ -29,8 +29,8 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#ifndef _QED_ROCE_H -#define _QED_ROCE_H +#ifndef _QED_RDMA_H +#define _QED_RDMA_H #include #include #include @@ -42,7 +42,7 @@ #include "qed.h" #include "qed_dev_api.h" #include "qed_hsi.h" -#include "qed_ll2.h" +#include "qed_roce.h" #define QED_RDMA_MAX_FMR (RDMA_MAX_TIDS) #define QED_RDMA_MAX_P_KEY (1) @@ -168,11 +168,34 @@ struct qed_rdma_qp { #if IS_ENABLED(CONFIG_QED_RDMA) void qed_rdma_dpm_bar(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt); -void qed_roce_dpm_dcbx(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt); +void qed_rdma_dpm_conf(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt); #else -static inline void qed_rdma_dpm_bar(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt) {} - -static inline void qed_roce_dpm_dcbx(struct qed_hwfn *p_hwfn, - struct qed_ptt *p_ptt) {} +static inline void qed_rdma_dpm_conf(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt) {} +static inline void qed_rdma_dpm_bar(struct qed_hwfn *p_hwfn, + struct qed_ptt *p_ptt) {} #endif + +int +qed_rdma_bmap_alloc(struct qed_hwfn *p_hwfn, + struct qed_bmap *bmap, u32 max_count, char *name); + +void +qed_rdma_bmap_free(struct qed_hwfn *p_hwfn, struct qed_bmap *bmap, bool check); + +int +qed_rdma_bmap_alloc_id(struct qed_hwfn *p_hwfn, + struct qed_bmap *bmap, u32 *id_num); + +void +qed_bmap_set_id(struct qed_hwfn *p_hwfn, struct qed_bmap *bmap, u32 id_num); + +void +qed_bmap_release_id(struct qed_hwfn *p_hwfn, struct qed_bmap *bmap, u32 id_num); + +int +qed_bmap_test_id(struct qed_hwfn *p_hwfn, struct qed_bmap *bmap, u32 id_num); + +void qed_rdma_set_fw_mac(u16 *p_fw_mac, u8 *p_qed_mac); + +bool qed_rdma_allocated_qps(struct qed_hwfn *p_hwfn); #endif diff --git a/drivers/net/ethernet/qlogic/qed/qed_roce.c b/drivers/net/ethernet/qlogic/qed/qed_roce.c index 9dc41a8..a842693 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_roce.c +++ b/drivers/net/ethernet/qlogic/qed/qed_roce.c @@ -53,8 +53,9 @@ #include "qed_ll2.h" #include "qed_mcp.h" #include "qed_reg_addr.h" -#include "qed_roce.h" #include +#include "qed_rdma.h" +#include "qed_roce.h" #include "qed_sp.h" static void qed_roce_free_real_icid(struct qed_hwfn *p_hwfn, u16 icid); @@ -84,594 +85,6 @@ return 0; } -static int qed_rdma_bmap_alloc(struct qed_hwfn *p_hwfn, - struct qed_bmap *bmap, u32 max_count, char *name) -{ - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "max_count = %08x\n", max_count); - - bmap->max_count = max_count; - - bmap->bitmap = kcalloc(BITS_TO_LONGS(max_count), sizeof(long), - GFP_KERNEL); - if (!bmap->bitmap) - return -ENOMEM; - - snprintf(bmap->name, QED_RDMA_MAX_BMAP_NAME, "%s", name); - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "0\n"); - return 0; -} - -static int qed_rdma_bmap_alloc_id(struct qed_hwfn *p_hwfn, - struct qed_bmap *bmap, u32 *id_num) -{ - *id_num = find_first_zero_bit(bmap->bitmap, bmap->max_count); - if (*id_num >= bmap->max_count) - return -EINVAL; - - __set_bit(*id_num, bmap->bitmap); - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "%s bitmap: allocated id %d\n", - bmap->name, *id_num); - - return 0; -} - -static void qed_bmap_set_id(struct qed_hwfn *p_hwfn, - struct qed_bmap *bmap, u32 id_num) -{ - if (id_num >= bmap->max_count) - return; - - __set_bit(id_num, bmap->bitmap); -} - -static void qed_bmap_release_id(struct qed_hwfn *p_hwfn, - struct qed_bmap *bmap, u32 id_num) -{ - bool b_acquired; - - if (id_num >= bmap->max_count) - return; - - b_acquired = test_and_clear_bit(id_num, bmap->bitmap); - if (!b_acquired) { - DP_NOTICE(p_hwfn, "%s bitmap: id %d already released\n", - bmap->name, id_num); - return; - } - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "%s bitmap: released id %d\n", - bmap->name, id_num); -} - -static int qed_bmap_test_id(struct qed_hwfn *p_hwfn, - struct qed_bmap *bmap, u32 id_num) -{ - if (id_num >= bmap->max_count) - return -1; - - return test_bit(id_num, bmap->bitmap); -} - -static bool qed_bmap_is_empty(struct qed_bmap *bmap) -{ - return bmap->max_count == find_first_bit(bmap->bitmap, bmap->max_count); -} - -static u32 qed_rdma_get_sb_id(void *p_hwfn, u32 rel_sb_id) -{ - /* First sb id for RoCE is after all the l2 sb */ - return FEAT_NUM((struct qed_hwfn *)p_hwfn, QED_PF_L2_QUE) + rel_sb_id; -} - -static int qed_rdma_alloc(struct qed_hwfn *p_hwfn, - struct qed_ptt *p_ptt, - struct qed_rdma_start_in_params *params) -{ - struct qed_rdma_info *p_rdma_info; - u32 num_cons, num_tasks; - int rc = -ENOMEM; - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Allocating RDMA\n"); - - /* Allocate a struct with current pf rdma info */ - p_rdma_info = kzalloc(sizeof(*p_rdma_info), GFP_KERNEL); - if (!p_rdma_info) - return rc; - - p_hwfn->p_rdma_info = p_rdma_info; - p_rdma_info->proto = PROTOCOLID_ROCE; - - num_cons = qed_cxt_get_proto_cid_count(p_hwfn, p_rdma_info->proto, - NULL); - - p_rdma_info->num_qps = num_cons / 2; - - num_tasks = qed_cxt_get_proto_tid_count(p_hwfn, PROTOCOLID_ROCE); - - /* Each MR uses a single task */ - p_rdma_info->num_mrs = num_tasks; - - /* Queue zone lines are shared between RoCE and L2 in such a way that - * they can be used by each without obstructing the other. - */ - p_rdma_info->queue_zone_base = (u16)RESC_START(p_hwfn, QED_L2_QUEUE); - p_rdma_info->max_queue_zones = (u16)RESC_NUM(p_hwfn, QED_L2_QUEUE); - - /* Allocate a struct with device params and fill it */ - p_rdma_info->dev = kzalloc(sizeof(*p_rdma_info->dev), GFP_KERNEL); - if (!p_rdma_info->dev) - goto free_rdma_info; - - /* Allocate a struct with port params and fill it */ - p_rdma_info->port = kzalloc(sizeof(*p_rdma_info->port), GFP_KERNEL); - if (!p_rdma_info->port) - goto free_rdma_dev; - - /* Allocate bit map for pd's */ - rc = qed_rdma_bmap_alloc(p_hwfn, &p_rdma_info->pd_map, RDMA_MAX_PDS, - "PD"); - if (rc) { - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, - "Failed to allocate pd_map, rc = %d\n", - rc); - goto free_rdma_port; - } - - /* Allocate DPI bitmap */ - rc = qed_rdma_bmap_alloc(p_hwfn, &p_rdma_info->dpi_map, - p_hwfn->dpi_count, "DPI"); - if (rc) { - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, - "Failed to allocate DPI bitmap, rc = %d\n", rc); - goto free_pd_map; - } - - /* Allocate bitmap for cq's. The maximum number of CQs is bounded to - * twice the number of QPs. - */ - rc = qed_rdma_bmap_alloc(p_hwfn, &p_rdma_info->cq_map, - p_rdma_info->num_qps * 2, "CQ"); - if (rc) { - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, - "Failed to allocate cq bitmap, rc = %d\n", rc); - goto free_dpi_map; - } - - /* Allocate bitmap for toggle bit for cq icids - * We toggle the bit every time we create or resize cq for a given icid. - * The maximum number of CQs is bounded to twice the number of QPs. - */ - rc = qed_rdma_bmap_alloc(p_hwfn, &p_rdma_info->toggle_bits, - p_rdma_info->num_qps * 2, "Toggle"); - if (rc) { - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, - "Failed to allocate toogle bits, rc = %d\n", rc); - goto free_cq_map; - } - - /* Allocate bitmap for itids */ - rc = qed_rdma_bmap_alloc(p_hwfn, &p_rdma_info->tid_map, - p_rdma_info->num_mrs, "MR"); - if (rc) { - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, - "Failed to allocate itids bitmaps, rc = %d\n", rc); - goto free_toggle_map; - } - - /* Allocate bitmap for cids used for qps. */ - rc = qed_rdma_bmap_alloc(p_hwfn, &p_rdma_info->cid_map, num_cons, - "CID"); - if (rc) { - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, - "Failed to allocate cid bitmap, rc = %d\n", rc); - goto free_tid_map; - } - - /* Allocate bitmap for cids used for responders/requesters. */ - rc = qed_rdma_bmap_alloc(p_hwfn, &p_rdma_info->real_cid_map, num_cons, - "REAL_CID"); - if (rc) { - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, - "Failed to allocate real cid bitmap, rc = %d\n", rc); - goto free_cid_map; - } - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Allocation successful\n"); - return 0; - -free_cid_map: - kfree(p_rdma_info->cid_map.bitmap); -free_tid_map: - kfree(p_rdma_info->tid_map.bitmap); -free_toggle_map: - kfree(p_rdma_info->toggle_bits.bitmap); -free_cq_map: - kfree(p_rdma_info->cq_map.bitmap); -free_dpi_map: - kfree(p_rdma_info->dpi_map.bitmap); -free_pd_map: - kfree(p_rdma_info->pd_map.bitmap); -free_rdma_port: - kfree(p_rdma_info->port); -free_rdma_dev: - kfree(p_rdma_info->dev); -free_rdma_info: - kfree(p_rdma_info); - - return rc; -} - -static void qed_rdma_bmap_free(struct qed_hwfn *p_hwfn, - struct qed_bmap *bmap, bool check) -{ - int weight = bitmap_weight(bmap->bitmap, bmap->max_count); - int last_line = bmap->max_count / (64 * 8); - int last_item = last_line * 8 + - DIV_ROUND_UP(bmap->max_count % (64 * 8), 64); - u64 *pmap = (u64 *)bmap->bitmap; - int line, item, offset; - u8 str_last_line[200] = { 0 }; - - if (!weight || !check) - goto end; - - DP_NOTICE(p_hwfn, - "%s bitmap not free - size=%d, weight=%d, 512 bits per line\n", - bmap->name, bmap->max_count, weight); - - /* print aligned non-zero lines, if any */ - for (item = 0, line = 0; line < last_line; line++, item += 8) - if (bitmap_weight((unsigned long *)&pmap[item], 64 * 8)) - DP_NOTICE(p_hwfn, - "line 0x%04x: 0x%016llx 0x%016llx 0x%016llx 0x%016llx 0x%016llx 0x%016llx 0x%016llx 0x%016llx\n", - line, - pmap[item], - pmap[item + 1], - pmap[item + 2], - pmap[item + 3], - pmap[item + 4], - pmap[item + 5], - pmap[item + 6], pmap[item + 7]); - - /* print last unaligned non-zero line, if any */ - if ((bmap->max_count % (64 * 8)) && - (bitmap_weight((unsigned long *)&pmap[item], - bmap->max_count - item * 64))) { - offset = sprintf(str_last_line, "line 0x%04x: ", line); - for (; item < last_item; item++) - offset += sprintf(str_last_line + offset, - "0x%016llx ", pmap[item]); - DP_NOTICE(p_hwfn, "%s\n", str_last_line); - } - -end: - kfree(bmap->bitmap); - bmap->bitmap = NULL; -} - -static void qed_rdma_resc_free(struct qed_hwfn *p_hwfn) -{ - struct qed_rdma_info *p_rdma_info = p_hwfn->p_rdma_info; - - qed_rdma_bmap_free(p_hwfn, &p_hwfn->p_rdma_info->cid_map, 1); - qed_rdma_bmap_free(p_hwfn, &p_hwfn->p_rdma_info->pd_map, 1); - qed_rdma_bmap_free(p_hwfn, &p_hwfn->p_rdma_info->dpi_map, 1); - qed_rdma_bmap_free(p_hwfn, &p_hwfn->p_rdma_info->cq_map, 1); - qed_rdma_bmap_free(p_hwfn, &p_hwfn->p_rdma_info->toggle_bits, 0); - qed_rdma_bmap_free(p_hwfn, &p_hwfn->p_rdma_info->tid_map, 1); - - kfree(p_rdma_info->port); - kfree(p_rdma_info->dev); - - kfree(p_rdma_info); -} - -static void qed_rdma_free(struct qed_hwfn *p_hwfn) -{ - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Freeing RDMA\n"); - - qed_rdma_resc_free(p_hwfn); -} - -static void qed_rdma_get_guid(struct qed_hwfn *p_hwfn, u8 *guid) -{ - guid[0] = p_hwfn->hw_info.hw_mac_addr[0] ^ 2; - guid[1] = p_hwfn->hw_info.hw_mac_addr[1]; - guid[2] = p_hwfn->hw_info.hw_mac_addr[2]; - guid[3] = 0xff; - guid[4] = 0xfe; - guid[5] = p_hwfn->hw_info.hw_mac_addr[3]; - guid[6] = p_hwfn->hw_info.hw_mac_addr[4]; - guid[7] = p_hwfn->hw_info.hw_mac_addr[5]; -} - -static void qed_rdma_init_events(struct qed_hwfn *p_hwfn, - struct qed_rdma_start_in_params *params) -{ - struct qed_rdma_events *events; - - events = &p_hwfn->p_rdma_info->events; - - events->unaffiliated_event = params->events->unaffiliated_event; - events->affiliated_event = params->events->affiliated_event; - events->context = params->events->context; -} - -static void qed_rdma_init_devinfo(struct qed_hwfn *p_hwfn, - struct qed_rdma_start_in_params *params) -{ - struct qed_rdma_device *dev = p_hwfn->p_rdma_info->dev; - struct qed_dev *cdev = p_hwfn->cdev; - u32 pci_status_control; - u32 num_qps; - - /* Vendor specific information */ - dev->vendor_id = cdev->vendor_id; - dev->vendor_part_id = cdev->device_id; - dev->hw_ver = 0; - dev->fw_ver = (FW_MAJOR_VERSION << 24) | (FW_MINOR_VERSION << 16) | - (FW_REVISION_VERSION << 8) | (FW_ENGINEERING_VERSION); - - qed_rdma_get_guid(p_hwfn, (u8 *)&dev->sys_image_guid); - dev->node_guid = dev->sys_image_guid; - - dev->max_sge = min_t(u32, RDMA_MAX_SGE_PER_SQ_WQE, - RDMA_MAX_SGE_PER_RQ_WQE); - - if (cdev->rdma_max_sge) - dev->max_sge = min_t(u32, cdev->rdma_max_sge, dev->max_sge); - - dev->max_inline = ROCE_REQ_MAX_INLINE_DATA_SIZE; - - dev->max_inline = (cdev->rdma_max_inline) ? - min_t(u32, cdev->rdma_max_inline, dev->max_inline) : - dev->max_inline; - - dev->max_wqe = QED_RDMA_MAX_WQE; - dev->max_cnq = (u8)FEAT_NUM(p_hwfn, QED_RDMA_CNQ); - - /* The number of QPs may be higher than QED_ROCE_MAX_QPS, because - * it is up-aligned to 16 and then to ILT page size within qed cxt. - * This is OK in terms of ILT but we don't want to configure the FW - * above its abilities - */ - num_qps = ROCE_MAX_QPS; - num_qps = min_t(u64, num_qps, p_hwfn->p_rdma_info->num_qps); - dev->max_qp = num_qps; - - /* CQs uses the same icids that QPs use hence they are limited by the - * number of icids. There are two icids per QP. - */ - dev->max_cq = num_qps * 2; - - /* The number of mrs is smaller by 1 since the first is reserved */ - dev->max_mr = p_hwfn->p_rdma_info->num_mrs - 1; - dev->max_mr_size = QED_RDMA_MAX_MR_SIZE; - - /* The maximum CQE capacity per CQ supported. - * max number of cqes will be in two layer pbl, - * 8 is the pointer size in bytes - * 32 is the size of cq element in bytes - */ - if (params->cq_mode == QED_RDMA_CQ_MODE_32_BITS) - dev->max_cqe = QED_RDMA_MAX_CQE_32_BIT; - else - dev->max_cqe = QED_RDMA_MAX_CQE_16_BIT; - - dev->max_mw = 0; - dev->max_fmr = QED_RDMA_MAX_FMR; - dev->max_mr_mw_fmr_pbl = (PAGE_SIZE / 8) * (PAGE_SIZE / 8); - dev->max_mr_mw_fmr_size = dev->max_mr_mw_fmr_pbl * PAGE_SIZE; - dev->max_pkey = QED_RDMA_MAX_P_KEY; - - dev->max_qp_resp_rd_atomic_resc = RDMA_RING_PAGE_SIZE / - (RDMA_RESP_RD_ATOMIC_ELM_SIZE * 2); - dev->max_qp_req_rd_atomic_resc = RDMA_RING_PAGE_SIZE / - RDMA_REQ_RD_ATOMIC_ELM_SIZE; - dev->max_dev_resp_rd_atomic_resc = dev->max_qp_resp_rd_atomic_resc * - p_hwfn->p_rdma_info->num_qps; - dev->page_size_caps = QED_RDMA_PAGE_SIZE_CAPS; - dev->dev_ack_delay = QED_RDMA_ACK_DELAY; - dev->max_pd = RDMA_MAX_PDS; - dev->max_ah = p_hwfn->p_rdma_info->num_qps; - dev->max_stats_queues = (u8)RESC_NUM(p_hwfn, QED_RDMA_STATS_QUEUE); - - /* Set capablities */ - dev->dev_caps = 0; - SET_FIELD(dev->dev_caps, QED_RDMA_DEV_CAP_RNR_NAK, 1); - SET_FIELD(dev->dev_caps, QED_RDMA_DEV_CAP_PORT_ACTIVE_EVENT, 1); - SET_FIELD(dev->dev_caps, QED_RDMA_DEV_CAP_PORT_CHANGE_EVENT, 1); - SET_FIELD(dev->dev_caps, QED_RDMA_DEV_CAP_RESIZE_CQ, 1); - SET_FIELD(dev->dev_caps, QED_RDMA_DEV_CAP_BASE_MEMORY_EXT, 1); - SET_FIELD(dev->dev_caps, QED_RDMA_DEV_CAP_BASE_QUEUE_EXT, 1); - SET_FIELD(dev->dev_caps, QED_RDMA_DEV_CAP_ZBVA, 1); - SET_FIELD(dev->dev_caps, QED_RDMA_DEV_CAP_LOCAL_INV_FENCE, 1); - - /* Check atomic operations support in PCI configuration space. */ - pci_read_config_dword(cdev->pdev, - cdev->pdev->pcie_cap + PCI_EXP_DEVCTL2, - &pci_status_control); - - if (pci_status_control & PCI_EXP_DEVCTL2_LTR_EN) - SET_FIELD(dev->dev_caps, QED_RDMA_DEV_CAP_ATOMIC_OP, 1); -} - -static void qed_rdma_init_port(struct qed_hwfn *p_hwfn) -{ - struct qed_rdma_port *port = p_hwfn->p_rdma_info->port; - struct qed_rdma_device *dev = p_hwfn->p_rdma_info->dev; - - port->port_state = p_hwfn->mcp_info->link_output.link_up ? - QED_RDMA_PORT_UP : QED_RDMA_PORT_DOWN; - - port->max_msg_size = min_t(u64, - (dev->max_mr_mw_fmr_size * - p_hwfn->cdev->rdma_max_sge), - BIT(31)); - - port->pkey_bad_counter = 0; -} - -static int qed_rdma_init_hw(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt) -{ - u32 ll2_ethertype_en; - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Initializing HW\n"); - p_hwfn->b_rdma_enabled_in_prs = false; - - qed_wr(p_hwfn, p_ptt, PRS_REG_ROCE_DEST_QP_MAX_PF, 0); - - p_hwfn->rdma_prs_search_reg = PRS_REG_SEARCH_ROCE; - - /* We delay writing to this reg until first cid is allocated. See - * qed_cxt_dynamic_ilt_alloc function for more details - */ - ll2_ethertype_en = qed_rd(p_hwfn, p_ptt, PRS_REG_LIGHT_L2_ETHERTYPE_EN); - qed_wr(p_hwfn, p_ptt, PRS_REG_LIGHT_L2_ETHERTYPE_EN, - (ll2_ethertype_en | 0x01)); - - if (qed_cxt_get_proto_cid_start(p_hwfn, PROTOCOLID_ROCE) % 2) { - DP_NOTICE(p_hwfn, "The first RoCE's cid should be even\n"); - return -EINVAL; - } - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Initializing HW - Done\n"); - return 0; -} - -static int qed_rdma_start_fw(struct qed_hwfn *p_hwfn, - struct qed_rdma_start_in_params *params, - struct qed_ptt *p_ptt) -{ - struct rdma_init_func_ramrod_data *p_ramrod; - struct qed_rdma_cnq_params *p_cnq_pbl_list; - struct rdma_init_func_hdr *p_params_header; - struct rdma_cnq_params *p_cnq_params; - struct qed_sp_init_data init_data; - struct qed_spq_entry *p_ent; - u32 cnq_id, sb_id; - u16 igu_sb_id; - int rc; - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Starting FW\n"); - - /* Save the number of cnqs for the function close ramrod */ - p_hwfn->p_rdma_info->num_cnqs = params->desired_cnq; - - /* Get SPQ entry */ - memset(&init_data, 0, sizeof(init_data)); - init_data.opaque_fid = p_hwfn->hw_info.opaque_fid; - init_data.comp_mode = QED_SPQ_MODE_EBLOCK; - - rc = qed_sp_init_request(p_hwfn, &p_ent, RDMA_RAMROD_FUNC_INIT, - p_hwfn->p_rdma_info->proto, &init_data); - if (rc) - return rc; - - p_ramrod = &p_ent->ramrod.roce_init_func.rdma; - - p_params_header = &p_ramrod->params_header; - p_params_header->cnq_start_offset = (u8)RESC_START(p_hwfn, - QED_RDMA_CNQ_RAM); - p_params_header->num_cnqs = params->desired_cnq; - - if (params->cq_mode == QED_RDMA_CQ_MODE_16_BITS) - p_params_header->cq_ring_mode = 1; - else - p_params_header->cq_ring_mode = 0; - - for (cnq_id = 0; cnq_id < params->desired_cnq; cnq_id++) { - sb_id = qed_rdma_get_sb_id(p_hwfn, cnq_id); - igu_sb_id = qed_get_igu_sb_id(p_hwfn, sb_id); - p_ramrod->cnq_params[cnq_id].sb_num = cpu_to_le16(igu_sb_id); - p_cnq_params = &p_ramrod->cnq_params[cnq_id]; - p_cnq_pbl_list = ¶ms->cnq_pbl_list[cnq_id]; - - p_cnq_params->sb_index = p_hwfn->pf_params.rdma_pf_params.gl_pi; - p_cnq_params->num_pbl_pages = p_cnq_pbl_list->num_pbl_pages; - - DMA_REGPAIR_LE(p_cnq_params->pbl_base_addr, - p_cnq_pbl_list->pbl_ptr); - - /* we assume here that cnq_id and qz_offset are the same */ - p_cnq_params->queue_zone_num = - cpu_to_le16(p_hwfn->p_rdma_info->queue_zone_base + - cnq_id); - } - - return qed_spq_post(p_hwfn, p_ent, NULL); -} - -static int qed_rdma_alloc_tid(void *rdma_cxt, u32 *itid) -{ - struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; - int rc; - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Allocate TID\n"); - - spin_lock_bh(&p_hwfn->p_rdma_info->lock); - rc = qed_rdma_bmap_alloc_id(p_hwfn, - &p_hwfn->p_rdma_info->tid_map, itid); - spin_unlock_bh(&p_hwfn->p_rdma_info->lock); - if (rc) - goto out; - - rc = qed_cxt_dynamic_ilt_alloc(p_hwfn, QED_ELEM_TASK, *itid); -out: - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Allocate TID - done, rc = %d\n", rc); - return rc; -} - -static int qed_rdma_reserve_lkey(struct qed_hwfn *p_hwfn) -{ - struct qed_rdma_device *dev = p_hwfn->p_rdma_info->dev; - - /* The first DPI is reserved for the Kernel */ - __set_bit(0, p_hwfn->p_rdma_info->dpi_map.bitmap); - - /* Tid 0 will be used as the key for "reserved MR". - * The driver should allocate memory for it so it can be loaded but no - * ramrod should be passed on it. - */ - qed_rdma_alloc_tid(p_hwfn, &dev->reserved_lkey); - if (dev->reserved_lkey != RDMA_RESERVED_LKEY) { - DP_NOTICE(p_hwfn, - "Reserved lkey should be equal to RDMA_RESERVED_LKEY\n"); - return -EINVAL; - } - - return 0; -} - -static int qed_rdma_setup(struct qed_hwfn *p_hwfn, - struct qed_ptt *p_ptt, - struct qed_rdma_start_in_params *params) -{ - int rc; - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "RDMA setup\n"); - - spin_lock_init(&p_hwfn->p_rdma_info->lock); - - qed_rdma_init_devinfo(p_hwfn, params); - qed_rdma_init_port(p_hwfn); - qed_rdma_init_events(p_hwfn, params); - - rc = qed_rdma_reserve_lkey(p_hwfn); - if (rc) - return rc; - - rc = qed_rdma_init_hw(p_hwfn, p_ptt); - if (rc) - return rc; - - qed_spq_register_async_cb(p_hwfn, PROTOCOLID_ROCE, - qed_roce_async_event); - - return qed_rdma_start_fw(p_hwfn, params, p_ptt); -} - void qed_roce_stop(struct qed_hwfn *p_hwfn) { struct qed_bmap *rcid_map = &p_hwfn->p_rdma_info->real_cid_map; @@ -692,467 +105,6 @@ void qed_roce_stop(struct qed_hwfn *p_hwfn) qed_spq_unregister_async_cb(p_hwfn, PROTOCOLID_ROCE); } -static int qed_rdma_stop(void *rdma_cxt) -{ - struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; - struct rdma_close_func_ramrod_data *p_ramrod; - struct qed_sp_init_data init_data; - struct qed_spq_entry *p_ent; - struct qed_ptt *p_ptt; - u32 ll2_ethertype_en; - int rc = -EBUSY; - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "RDMA stop\n"); - - p_ptt = qed_ptt_acquire(p_hwfn); - if (!p_ptt) { - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Failed to acquire PTT\n"); - return rc; - } - - /* Disable RoCE search */ - qed_wr(p_hwfn, p_ptt, p_hwfn->rdma_prs_search_reg, 0); - p_hwfn->b_rdma_enabled_in_prs = false; - - qed_wr(p_hwfn, p_ptt, PRS_REG_ROCE_DEST_QP_MAX_PF, 0); - - ll2_ethertype_en = qed_rd(p_hwfn, p_ptt, PRS_REG_LIGHT_L2_ETHERTYPE_EN); - - qed_wr(p_hwfn, p_ptt, PRS_REG_LIGHT_L2_ETHERTYPE_EN, - (ll2_ethertype_en & 0xFFFE)); - - qed_roce_stop(p_hwfn); - qed_ptt_release(p_hwfn, p_ptt); - - /* Get SPQ entry */ - memset(&init_data, 0, sizeof(init_data)); - init_data.opaque_fid = p_hwfn->hw_info.opaque_fid; - init_data.comp_mode = QED_SPQ_MODE_EBLOCK; - - /* Stop RoCE */ - rc = qed_sp_init_request(p_hwfn, &p_ent, RDMA_RAMROD_FUNC_CLOSE, - p_hwfn->p_rdma_info->proto, &init_data); - if (rc) - goto out; - - p_ramrod = &p_ent->ramrod.rdma_close_func; - - p_ramrod->num_cnqs = p_hwfn->p_rdma_info->num_cnqs; - p_ramrod->cnq_start_offset = (u8)RESC_START(p_hwfn, QED_RDMA_CNQ_RAM); - - rc = qed_spq_post(p_hwfn, p_ent, NULL); - -out: - qed_rdma_free(p_hwfn); - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "RDMA stop done, rc = %d\n", rc); - return rc; -} - -static int qed_rdma_add_user(void *rdma_cxt, - struct qed_rdma_add_user_out_params *out_params) -{ - struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; - u32 dpi_start_offset; - u32 returned_id = 0; - int rc; - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Adding User\n"); - - /* Allocate DPI */ - spin_lock_bh(&p_hwfn->p_rdma_info->lock); - rc = qed_rdma_bmap_alloc_id(p_hwfn, &p_hwfn->p_rdma_info->dpi_map, - &returned_id); - spin_unlock_bh(&p_hwfn->p_rdma_info->lock); - - out_params->dpi = (u16)returned_id; - - /* Calculate the corresponding DPI address */ - dpi_start_offset = p_hwfn->dpi_start_offset; - - out_params->dpi_addr = (u64)((u8 __iomem *)p_hwfn->doorbells + - dpi_start_offset + - ((out_params->dpi) * p_hwfn->dpi_size)); - - out_params->dpi_phys_addr = p_hwfn->cdev->db_phys_addr + - dpi_start_offset + - ((out_params->dpi) * p_hwfn->dpi_size); - - out_params->dpi_size = p_hwfn->dpi_size; - out_params->wid_count = p_hwfn->wid_count; - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Adding user - done, rc = %d\n", rc); - return rc; -} - -static struct qed_rdma_port *qed_rdma_query_port(void *rdma_cxt) -{ - struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; - struct qed_rdma_port *p_port = p_hwfn->p_rdma_info->port; - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "RDMA Query port\n"); - - /* Link may have changed */ - p_port->port_state = p_hwfn->mcp_info->link_output.link_up ? - QED_RDMA_PORT_UP : QED_RDMA_PORT_DOWN; - - p_port->link_speed = p_hwfn->mcp_info->link_output.speed; - - p_port->max_msg_size = RDMA_MAX_DATA_SIZE_IN_WQE; - - return p_port; -} - -static struct qed_rdma_device *qed_rdma_query_device(void *rdma_cxt) -{ - struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Query device\n"); - - /* Return struct with device parameters */ - return p_hwfn->p_rdma_info->dev; -} - -static void qed_rdma_free_tid(void *rdma_cxt, u32 itid) -{ - struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "itid = %08x\n", itid); - - spin_lock_bh(&p_hwfn->p_rdma_info->lock); - qed_bmap_release_id(p_hwfn, &p_hwfn->p_rdma_info->tid_map, itid); - spin_unlock_bh(&p_hwfn->p_rdma_info->lock); -} - -static void qed_rdma_cnq_prod_update(void *rdma_cxt, u8 qz_offset, u16 prod) -{ - struct qed_hwfn *p_hwfn; - u16 qz_num; - u32 addr; - - p_hwfn = (struct qed_hwfn *)rdma_cxt; - - if (qz_offset > p_hwfn->p_rdma_info->max_queue_zones) { - DP_NOTICE(p_hwfn, - "queue zone offset %d is too large (max is %d)\n", - qz_offset, p_hwfn->p_rdma_info->max_queue_zones); - return; - } - - qz_num = p_hwfn->p_rdma_info->queue_zone_base + qz_offset; - addr = GTT_BAR0_MAP_REG_USDM_RAM + - USTORM_COMMON_QUEUE_CONS_OFFSET(qz_num); - - REG_WR16(p_hwfn, addr, prod); - - /* keep prod updates ordered */ - wmb(); -} - -static int qed_fill_rdma_dev_info(struct qed_dev *cdev, - struct qed_dev_rdma_info *info) -{ - struct qed_hwfn *p_hwfn = QED_LEADING_HWFN(cdev); - - memset(info, 0, sizeof(*info)); - - info->rdma_type = QED_RDMA_TYPE_ROCE; - info->user_dpm_enabled = (p_hwfn->db_bar_no_edpm == 0); - - qed_fill_dev_info(cdev, &info->common); - - return 0; -} - -static int qed_rdma_get_sb_start(struct qed_dev *cdev) -{ - int feat_num; - - if (cdev->num_hwfns > 1) - feat_num = FEAT_NUM(QED_LEADING_HWFN(cdev), QED_PF_L2_QUE); - else - feat_num = FEAT_NUM(QED_LEADING_HWFN(cdev), QED_PF_L2_QUE) * - cdev->num_hwfns; - - return feat_num; -} - -static int qed_rdma_get_min_cnq_msix(struct qed_dev *cdev) -{ - int n_cnq = FEAT_NUM(QED_LEADING_HWFN(cdev), QED_RDMA_CNQ); - int n_msix = cdev->int_params.rdma_msix_cnt; - - return min_t(int, n_cnq, n_msix); -} - -static int qed_rdma_set_int(struct qed_dev *cdev, u16 cnt) -{ - int limit = 0; - - /* Mark the fastpath as free/used */ - cdev->int_params.fp_initialized = cnt ? true : false; - - if (cdev->int_params.out.int_mode != QED_INT_MODE_MSIX) { - DP_ERR(cdev, - "qed roce supports only MSI-X interrupts (detected %d).\n", - cdev->int_params.out.int_mode); - return -EINVAL; - } else if (cdev->int_params.fp_msix_cnt) { - limit = cdev->int_params.rdma_msix_cnt; - } - - if (!limit) - return -ENOMEM; - - return min_t(int, cnt, limit); -} - -static int qed_rdma_get_int(struct qed_dev *cdev, struct qed_int_info *info) -{ - memset(info, 0, sizeof(*info)); - - if (!cdev->int_params.fp_initialized) { - DP_INFO(cdev, - "Protocol driver requested interrupt information, but its support is not yet configured\n"); - return -EINVAL; - } - - if (cdev->int_params.out.int_mode == QED_INT_MODE_MSIX) { - int msix_base = cdev->int_params.rdma_msix_base; - - info->msix_cnt = cdev->int_params.rdma_msix_cnt; - info->msix = &cdev->int_params.msix_table[msix_base]; - - DP_VERBOSE(cdev, QED_MSG_RDMA, "msix_cnt = %d msix_base=%d\n", - info->msix_cnt, msix_base); - } - - return 0; -} - -static int qed_rdma_alloc_pd(void *rdma_cxt, u16 *pd) -{ - struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; - u32 returned_id; - int rc; - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Alloc PD\n"); - - /* Allocates an unused protection domain */ - spin_lock_bh(&p_hwfn->p_rdma_info->lock); - rc = qed_rdma_bmap_alloc_id(p_hwfn, - &p_hwfn->p_rdma_info->pd_map, &returned_id); - spin_unlock_bh(&p_hwfn->p_rdma_info->lock); - - *pd = (u16)returned_id; - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Alloc PD - done, rc = %d\n", rc); - return rc; -} - -static void qed_rdma_free_pd(void *rdma_cxt, u16 pd) -{ - struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "pd = %08x\n", pd); - - /* Returns a previously allocated protection domain for reuse */ - spin_lock_bh(&p_hwfn->p_rdma_info->lock); - qed_bmap_release_id(p_hwfn, &p_hwfn->p_rdma_info->pd_map, pd); - spin_unlock_bh(&p_hwfn->p_rdma_info->lock); -} - -static enum qed_rdma_toggle_bit -qed_rdma_toggle_bit_create_resize_cq(struct qed_hwfn *p_hwfn, u16 icid) -{ - struct qed_rdma_info *p_info = p_hwfn->p_rdma_info; - enum qed_rdma_toggle_bit toggle_bit; - u32 bmap_id; - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "icid = %08x\n", icid); - - /* the function toggle the bit that is related to a given icid - * and returns the new toggle bit's value - */ - bmap_id = icid - qed_cxt_get_proto_cid_start(p_hwfn, p_info->proto); - - spin_lock_bh(&p_info->lock); - toggle_bit = !test_and_change_bit(bmap_id, - p_info->toggle_bits.bitmap); - spin_unlock_bh(&p_info->lock); - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "QED_RDMA_TOGGLE_BIT_= %d\n", - toggle_bit); - - return toggle_bit; -} - -static int qed_rdma_create_cq(void *rdma_cxt, - struct qed_rdma_create_cq_in_params *params, - u16 *icid) -{ - struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; - struct qed_rdma_info *p_info = p_hwfn->p_rdma_info; - struct rdma_create_cq_ramrod_data *p_ramrod; - enum qed_rdma_toggle_bit toggle_bit; - struct qed_sp_init_data init_data; - struct qed_spq_entry *p_ent; - u32 returned_id, start_cid; - int rc; - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "cq_handle = %08x%08x\n", - params->cq_handle_hi, params->cq_handle_lo); - - /* Allocate icid */ - spin_lock_bh(&p_info->lock); - rc = qed_rdma_bmap_alloc_id(p_hwfn, &p_info->cq_map, &returned_id); - spin_unlock_bh(&p_info->lock); - - if (rc) { - DP_NOTICE(p_hwfn, "Can't create CQ, rc = %d\n", rc); - return rc; - } - - start_cid = qed_cxt_get_proto_cid_start(p_hwfn, - p_info->proto); - *icid = returned_id + start_cid; - - /* Check if icid requires a page allocation */ - rc = qed_cxt_dynamic_ilt_alloc(p_hwfn, QED_ELEM_CXT, *icid); - if (rc) - goto err; - - /* Get SPQ entry */ - memset(&init_data, 0, sizeof(init_data)); - init_data.cid = *icid; - init_data.opaque_fid = p_hwfn->hw_info.opaque_fid; - init_data.comp_mode = QED_SPQ_MODE_EBLOCK; - - /* Send create CQ ramrod */ - rc = qed_sp_init_request(p_hwfn, &p_ent, - RDMA_RAMROD_CREATE_CQ, - p_info->proto, &init_data); - if (rc) - goto err; - - p_ramrod = &p_ent->ramrod.rdma_create_cq; - - p_ramrod->cq_handle.hi = cpu_to_le32(params->cq_handle_hi); - p_ramrod->cq_handle.lo = cpu_to_le32(params->cq_handle_lo); - p_ramrod->dpi = cpu_to_le16(params->dpi); - p_ramrod->is_two_level_pbl = params->pbl_two_level; - p_ramrod->max_cqes = cpu_to_le32(params->cq_size); - DMA_REGPAIR_LE(p_ramrod->pbl_addr, params->pbl_ptr); - p_ramrod->pbl_num_pages = cpu_to_le16(params->pbl_num_pages); - p_ramrod->cnq_id = (u8)RESC_START(p_hwfn, QED_RDMA_CNQ_RAM) + - params->cnq_id; - p_ramrod->int_timeout = params->int_timeout; - - /* toggle the bit for every resize or create cq for a given icid */ - toggle_bit = qed_rdma_toggle_bit_create_resize_cq(p_hwfn, *icid); - - p_ramrod->toggle_bit = toggle_bit; - - rc = qed_spq_post(p_hwfn, p_ent, NULL); - if (rc) { - /* restore toggle bit */ - qed_rdma_toggle_bit_create_resize_cq(p_hwfn, *icid); - goto err; - } - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Created CQ, rc = %d\n", rc); - return rc; - -err: - /* release allocated icid */ - spin_lock_bh(&p_info->lock); - qed_bmap_release_id(p_hwfn, &p_info->cq_map, returned_id); - spin_unlock_bh(&p_info->lock); - DP_NOTICE(p_hwfn, "Create CQ failed, rc = %d\n", rc); - - return rc; -} - -static int -qed_rdma_destroy_cq(void *rdma_cxt, - struct qed_rdma_destroy_cq_in_params *in_params, - struct qed_rdma_destroy_cq_out_params *out_params) -{ - struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; - struct rdma_destroy_cq_output_params *p_ramrod_res; - struct rdma_destroy_cq_ramrod_data *p_ramrod; - struct qed_sp_init_data init_data; - struct qed_spq_entry *p_ent; - dma_addr_t ramrod_res_phys; - enum protocol_type proto; - int rc = -ENOMEM; - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "icid = %08x\n", in_params->icid); - - p_ramrod_res = - (struct rdma_destroy_cq_output_params *) - dma_alloc_coherent(&p_hwfn->cdev->pdev->dev, - sizeof(struct rdma_destroy_cq_output_params), - &ramrod_res_phys, GFP_KERNEL); - if (!p_ramrod_res) { - DP_NOTICE(p_hwfn, - "qed destroy cq failed: cannot allocate memory (ramrod)\n"); - return rc; - } - - /* Get SPQ entry */ - memset(&init_data, 0, sizeof(init_data)); - init_data.cid = in_params->icid; - init_data.opaque_fid = p_hwfn->hw_info.opaque_fid; - init_data.comp_mode = QED_SPQ_MODE_EBLOCK; - proto = p_hwfn->p_rdma_info->proto; - /* Send destroy CQ ramrod */ - rc = qed_sp_init_request(p_hwfn, &p_ent, - RDMA_RAMROD_DESTROY_CQ, - proto, &init_data); - if (rc) - goto err; - - p_ramrod = &p_ent->ramrod.rdma_destroy_cq; - DMA_REGPAIR_LE(p_ramrod->output_params_addr, ramrod_res_phys); - - rc = qed_spq_post(p_hwfn, p_ent, NULL); - if (rc) - goto err; - - out_params->num_cq_notif = le16_to_cpu(p_ramrod_res->cnq_num); - - dma_free_coherent(&p_hwfn->cdev->pdev->dev, - sizeof(struct rdma_destroy_cq_output_params), - p_ramrod_res, ramrod_res_phys); - - /* Free icid */ - spin_lock_bh(&p_hwfn->p_rdma_info->lock); - - qed_bmap_release_id(p_hwfn, - &p_hwfn->p_rdma_info->cq_map, - (in_params->icid - - qed_cxt_get_proto_cid_start(p_hwfn, proto))); - - spin_unlock_bh(&p_hwfn->p_rdma_info->lock); - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Destroyed CQ, rc = %d\n", rc); - return rc; - -err: dma_free_coherent(&p_hwfn->cdev->pdev->dev, - sizeof(struct rdma_destroy_cq_output_params), - p_ramrod_res, ramrod_res_phys); - - return rc; -} - -static void qed_rdma_set_fw_mac(u16 *p_fw_mac, u8 *p_qed_mac) -{ - p_fw_mac[0] = cpu_to_le16((p_qed_mac[0] << 8) + p_qed_mac[1]); - p_fw_mac[1] = cpu_to_le16((p_qed_mac[2] << 8) + p_qed_mac[3]); - p_fw_mac[2] = cpu_to_le16((p_qed_mac[4] << 8) + p_qed_mac[5]); -} - static void qed_rdma_copy_gids(struct qed_rdma_qp *qp, __le32 *src_gid, __le32 *dst_gid) { @@ -1204,7 +156,7 @@ void qed_roce_free_cid_pair(struct qed_hwfn *p_hwfn, u16 cid) spin_unlock_bh(&p_hwfn->p_rdma_info->lock); } -static int qed_roce_alloc_cid(struct qed_hwfn *p_hwfn, u16 *cid) +int qed_roce_alloc_cid(struct qed_hwfn *p_hwfn, u16 *cid) { struct qed_rdma_info *p_rdma_info = p_hwfn->p_rdma_info; u32 responder_icid; @@ -1864,9 +816,9 @@ static int qed_roce_sp_destroy_qp_requester(struct qed_hwfn *p_hwfn, return rc; } -static int qed_roce_query_qp(struct qed_hwfn *p_hwfn, - struct qed_rdma_qp *qp, - struct qed_rdma_query_qp_out_params *out_params) +int qed_roce_query_qp(struct qed_hwfn *p_hwfn, + struct qed_rdma_qp *qp, + struct qed_rdma_query_qp_out_params *out_params) { struct roce_query_qp_resp_output_params *p_resp_ramrod_res; struct roce_query_qp_req_output_params *p_req_ramrod_res; @@ -2005,7 +957,7 @@ static int qed_roce_query_qp(struct qed_hwfn *p_hwfn, return rc; } -static int qed_roce_destroy_qp(struct qed_hwfn *p_hwfn, struct qed_rdma_qp *qp) +int qed_roce_destroy_qp(struct qed_hwfn *p_hwfn, struct qed_rdma_qp *qp) { u32 num_invalidated_mw = 0; u32 num_bound_mw = 0; @@ -2044,136 +996,10 @@ static int qed_roce_destroy_qp(struct qed_hwfn *p_hwfn, struct qed_rdma_qp *qp) return 0; } -static int qed_rdma_query_qp(void *rdma_cxt, - struct qed_rdma_qp *qp, - struct qed_rdma_query_qp_out_params *out_params) -{ - struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; - int rc; - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "icid = %08x\n", qp->icid); - - /* The following fields are filled in from qp and not FW as they can't - * be modified by FW - */ - out_params->mtu = qp->mtu; - out_params->dest_qp = qp->dest_qp; - out_params->incoming_atomic_en = qp->incoming_atomic_en; - out_params->e2e_flow_control_en = qp->e2e_flow_control_en; - out_params->incoming_rdma_read_en = qp->incoming_rdma_read_en; - out_params->incoming_rdma_write_en = qp->incoming_rdma_write_en; - out_params->dgid = qp->dgid; - out_params->flow_label = qp->flow_label; - out_params->hop_limit_ttl = qp->hop_limit_ttl; - out_params->traffic_class_tos = qp->traffic_class_tos; - out_params->timeout = qp->ack_timeout; - out_params->rnr_retry = qp->rnr_retry_cnt; - out_params->retry_cnt = qp->retry_cnt; - out_params->min_rnr_nak_timer = qp->min_rnr_nak_timer; - out_params->pkey_index = 0; - out_params->max_rd_atomic = qp->max_rd_atomic_req; - out_params->max_dest_rd_atomic = qp->max_rd_atomic_resp; - out_params->sqd_async = qp->sqd_async; - - rc = qed_roce_query_qp(p_hwfn, qp, out_params); - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Query QP, rc = %d\n", rc); - return rc; -} - -static int qed_rdma_destroy_qp(void *rdma_cxt, struct qed_rdma_qp *qp) -{ - struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; - int rc = 0; - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "icid = %08x\n", qp->icid); - - rc = qed_roce_destroy_qp(p_hwfn, qp); - - /* free qp params struct */ - kfree(qp); - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "QP destroyed\n"); - return rc; -} - -static struct qed_rdma_qp * -qed_rdma_create_qp(void *rdma_cxt, - struct qed_rdma_create_qp_in_params *in_params, - struct qed_rdma_create_qp_out_params *out_params) -{ - struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; - struct qed_rdma_qp *qp; - u8 max_stats_queues; - int rc; - - if (!rdma_cxt || !in_params || !out_params || !p_hwfn->p_rdma_info) { - DP_ERR(p_hwfn->cdev, - "qed roce create qp failed due to NULL entry (rdma_cxt=%p, in=%p, out=%p, roce_info=?\n", - rdma_cxt, in_params, out_params); - return NULL; - } - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, - "qed rdma create qp called with qp_handle = %08x%08x\n", - in_params->qp_handle_hi, in_params->qp_handle_lo); - - /* Some sanity checks... */ - max_stats_queues = p_hwfn->p_rdma_info->dev->max_stats_queues; - if (in_params->stats_queue >= max_stats_queues) { - DP_ERR(p_hwfn->cdev, - "qed rdma create qp failed due to invalid statistics queue %d. maximum is %d\n", - in_params->stats_queue, max_stats_queues); - return NULL; - } - - qp = kzalloc(sizeof(*qp), GFP_KERNEL); - if (!qp) - return NULL; - - rc = qed_roce_alloc_cid(p_hwfn, &qp->icid); - qp->qpid = ((0xFF << 16) | qp->icid); - - DP_INFO(p_hwfn, "ROCE qpid=%x\n", qp->qpid); - - if (rc) { - kfree(qp); - return NULL; - } - - qp->cur_state = QED_ROCE_QP_STATE_RESET; - qp->qp_handle.hi = cpu_to_le32(in_params->qp_handle_hi); - qp->qp_handle.lo = cpu_to_le32(in_params->qp_handle_lo); - qp->qp_handle_async.hi = cpu_to_le32(in_params->qp_handle_async_hi); - qp->qp_handle_async.lo = cpu_to_le32(in_params->qp_handle_async_lo); - qp->use_srq = in_params->use_srq; - qp->signal_all = in_params->signal_all; - qp->fmr_and_reserved_lkey = in_params->fmr_and_reserved_lkey; - qp->pd = in_params->pd; - qp->dpi = in_params->dpi; - qp->sq_cq_id = in_params->sq_cq_id; - qp->sq_num_pages = in_params->sq_num_pages; - qp->sq_pbl_ptr = in_params->sq_pbl_ptr; - qp->rq_cq_id = in_params->rq_cq_id; - qp->rq_num_pages = in_params->rq_num_pages; - qp->rq_pbl_ptr = in_params->rq_pbl_ptr; - qp->srq_id = in_params->srq_id; - qp->req_offloaded = false; - qp->resp_offloaded = false; - qp->e2e_flow_control_en = qp->use_srq ? false : true; - qp->stats_queue = in_params->stats_queue; - - out_params->icid = qp->icid; - out_params->qp_id = qp->qpid; - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Create QP, rc = %d\n", rc); - return qp; -} - -static int qed_roce_modify_qp(struct qed_hwfn *p_hwfn, - struct qed_rdma_qp *qp, - enum qed_roce_qp_state prev_state, - struct qed_rdma_modify_qp_in_params *params) +int qed_roce_modify_qp(struct qed_hwfn *p_hwfn, + struct qed_rdma_qp *qp, + enum qed_roce_qp_state prev_state, + struct qed_rdma_modify_qp_in_params *params) { u32 num_invalidated_mw = 0, num_bound_mw = 0; int rc = 0; @@ -2278,327 +1104,6 @@ static int qed_roce_modify_qp(struct qed_hwfn *p_hwfn, return rc; } -static int qed_rdma_modify_qp(void *rdma_cxt, - struct qed_rdma_qp *qp, - struct qed_rdma_modify_qp_in_params *params) -{ - struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; - enum qed_roce_qp_state prev_state; - int rc = 0; - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "icid = %08x params->new_state=%d\n", - qp->icid, params->new_state); - - if (rc) { - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "rc = %d\n", rc); - return rc; - } - - if (GET_FIELD(params->modify_flags, - QED_RDMA_MODIFY_QP_VALID_RDMA_OPS_EN)) { - qp->incoming_rdma_read_en = params->incoming_rdma_read_en; - qp->incoming_rdma_write_en = params->incoming_rdma_write_en; - qp->incoming_atomic_en = params->incoming_atomic_en; - } - - /* Update QP structure with the updated values */ - if (GET_FIELD(params->modify_flags, QED_ROCE_MODIFY_QP_VALID_ROCE_MODE)) - qp->roce_mode = params->roce_mode; - if (GET_FIELD(params->modify_flags, QED_ROCE_MODIFY_QP_VALID_PKEY)) - qp->pkey = params->pkey; - if (GET_FIELD(params->modify_flags, - QED_ROCE_MODIFY_QP_VALID_E2E_FLOW_CONTROL_EN)) - qp->e2e_flow_control_en = params->e2e_flow_control_en; - if (GET_FIELD(params->modify_flags, QED_ROCE_MODIFY_QP_VALID_DEST_QP)) - qp->dest_qp = params->dest_qp; - if (GET_FIELD(params->modify_flags, - QED_ROCE_MODIFY_QP_VALID_ADDRESS_VECTOR)) { - /* Indicates that the following parameters have changed: - * Traffic class, flow label, hop limit, source GID, - * destination GID, loopback indicator - */ - qp->traffic_class_tos = params->traffic_class_tos; - qp->flow_label = params->flow_label; - qp->hop_limit_ttl = params->hop_limit_ttl; - - qp->sgid = params->sgid; - qp->dgid = params->dgid; - qp->udp_src_port = 0; - qp->vlan_id = params->vlan_id; - qp->mtu = params->mtu; - qp->lb_indication = params->lb_indication; - memcpy((u8 *)&qp->remote_mac_addr[0], - (u8 *)¶ms->remote_mac_addr[0], ETH_ALEN); - if (params->use_local_mac) { - memcpy((u8 *)&qp->local_mac_addr[0], - (u8 *)¶ms->local_mac_addr[0], ETH_ALEN); - } else { - memcpy((u8 *)&qp->local_mac_addr[0], - (u8 *)&p_hwfn->hw_info.hw_mac_addr, ETH_ALEN); - } - } - if (GET_FIELD(params->modify_flags, QED_ROCE_MODIFY_QP_VALID_RQ_PSN)) - qp->rq_psn = params->rq_psn; - if (GET_FIELD(params->modify_flags, QED_ROCE_MODIFY_QP_VALID_SQ_PSN)) - qp->sq_psn = params->sq_psn; - if (GET_FIELD(params->modify_flags, - QED_RDMA_MODIFY_QP_VALID_MAX_RD_ATOMIC_REQ)) - qp->max_rd_atomic_req = params->max_rd_atomic_req; - if (GET_FIELD(params->modify_flags, - QED_RDMA_MODIFY_QP_VALID_MAX_RD_ATOMIC_RESP)) - qp->max_rd_atomic_resp = params->max_rd_atomic_resp; - if (GET_FIELD(params->modify_flags, - QED_ROCE_MODIFY_QP_VALID_ACK_TIMEOUT)) - qp->ack_timeout = params->ack_timeout; - if (GET_FIELD(params->modify_flags, QED_ROCE_MODIFY_QP_VALID_RETRY_CNT)) - qp->retry_cnt = params->retry_cnt; - if (GET_FIELD(params->modify_flags, - QED_ROCE_MODIFY_QP_VALID_RNR_RETRY_CNT)) - qp->rnr_retry_cnt = params->rnr_retry_cnt; - if (GET_FIELD(params->modify_flags, - QED_ROCE_MODIFY_QP_VALID_MIN_RNR_NAK_TIMER)) - qp->min_rnr_nak_timer = params->min_rnr_nak_timer; - - qp->sqd_async = params->sqd_async; - - prev_state = qp->cur_state; - if (GET_FIELD(params->modify_flags, - QED_RDMA_MODIFY_QP_VALID_NEW_STATE)) { - qp->cur_state = params->new_state; - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "qp->cur_state=%d\n", - qp->cur_state); - } - - rc = qed_roce_modify_qp(p_hwfn, qp, prev_state, params); - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Modify QP, rc = %d\n", rc); - return rc; -} - -static int -qed_rdma_register_tid(void *rdma_cxt, - struct qed_rdma_register_tid_in_params *params) -{ - struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; - struct rdma_register_tid_ramrod_data *p_ramrod; - struct qed_sp_init_data init_data; - struct qed_spq_entry *p_ent; - enum rdma_tid_type tid_type; - u8 fw_return_code; - int rc; - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "itid = %08x\n", params->itid); - - /* Get SPQ entry */ - memset(&init_data, 0, sizeof(init_data)); - init_data.opaque_fid = p_hwfn->hw_info.opaque_fid; - init_data.comp_mode = QED_SPQ_MODE_EBLOCK; - - rc = qed_sp_init_request(p_hwfn, &p_ent, RDMA_RAMROD_REGISTER_MR, - p_hwfn->p_rdma_info->proto, &init_data); - if (rc) { - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "rc = %d\n", rc); - return rc; - } - - if (p_hwfn->p_rdma_info->last_tid < params->itid) - p_hwfn->p_rdma_info->last_tid = params->itid; - - p_ramrod = &p_ent->ramrod.rdma_register_tid; - - p_ramrod->flags = 0; - SET_FIELD(p_ramrod->flags, - RDMA_REGISTER_TID_RAMROD_DATA_TWO_LEVEL_PBL, - params->pbl_two_level); - - SET_FIELD(p_ramrod->flags, - RDMA_REGISTER_TID_RAMROD_DATA_ZERO_BASED, params->zbva); - - SET_FIELD(p_ramrod->flags, - RDMA_REGISTER_TID_RAMROD_DATA_PHY_MR, params->phy_mr); - - /* Don't initialize D/C field, as it may override other bits. */ - if (!(params->tid_type == QED_RDMA_TID_FMR) && !(params->dma_mr)) - SET_FIELD(p_ramrod->flags, - RDMA_REGISTER_TID_RAMROD_DATA_PAGE_SIZE_LOG, - params->page_size_log - 12); - - SET_FIELD(p_ramrod->flags, - RDMA_REGISTER_TID_RAMROD_DATA_REMOTE_READ, - params->remote_read); - - SET_FIELD(p_ramrod->flags, - RDMA_REGISTER_TID_RAMROD_DATA_REMOTE_WRITE, - params->remote_write); - - SET_FIELD(p_ramrod->flags, - RDMA_REGISTER_TID_RAMROD_DATA_REMOTE_ATOMIC, - params->remote_atomic); - - SET_FIELD(p_ramrod->flags, - RDMA_REGISTER_TID_RAMROD_DATA_LOCAL_WRITE, - params->local_write); - - SET_FIELD(p_ramrod->flags, - RDMA_REGISTER_TID_RAMROD_DATA_LOCAL_READ, params->local_read); - - SET_FIELD(p_ramrod->flags, - RDMA_REGISTER_TID_RAMROD_DATA_ENABLE_MW_BIND, - params->mw_bind); - - SET_FIELD(p_ramrod->flags1, - RDMA_REGISTER_TID_RAMROD_DATA_PBL_PAGE_SIZE_LOG, - params->pbl_page_size_log - 12); - - SET_FIELD(p_ramrod->flags2, - RDMA_REGISTER_TID_RAMROD_DATA_DMA_MR, params->dma_mr); - - switch (params->tid_type) { - case QED_RDMA_TID_REGISTERED_MR: - tid_type = RDMA_TID_REGISTERED_MR; - break; - case QED_RDMA_TID_FMR: - tid_type = RDMA_TID_FMR; - break; - case QED_RDMA_TID_MW_TYPE1: - tid_type = RDMA_TID_MW_TYPE1; - break; - case QED_RDMA_TID_MW_TYPE2A: - tid_type = RDMA_TID_MW_TYPE2A; - break; - default: - rc = -EINVAL; - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "rc = %d\n", rc); - return rc; - } - SET_FIELD(p_ramrod->flags1, - RDMA_REGISTER_TID_RAMROD_DATA_TID_TYPE, tid_type); - - p_ramrod->itid = cpu_to_le32(params->itid); - p_ramrod->key = params->key; - p_ramrod->pd = cpu_to_le16(params->pd); - p_ramrod->length_hi = (u8)(params->length >> 32); - p_ramrod->length_lo = DMA_LO_LE(params->length); - if (params->zbva) { - /* Lower 32 bits of the registered MR address. - * In case of zero based MR, will hold FBO - */ - p_ramrod->va.hi = 0; - p_ramrod->va.lo = cpu_to_le32(params->fbo); - } else { - DMA_REGPAIR_LE(p_ramrod->va, params->vaddr); - } - DMA_REGPAIR_LE(p_ramrod->pbl_base, params->pbl_ptr); - - /* DIF */ - if (params->dif_enabled) { - SET_FIELD(p_ramrod->flags2, - RDMA_REGISTER_TID_RAMROD_DATA_DIF_ON_HOST_FLG, 1); - DMA_REGPAIR_LE(p_ramrod->dif_error_addr, - params->dif_error_addr); - DMA_REGPAIR_LE(p_ramrod->dif_runt_addr, params->dif_runt_addr); - } - - rc = qed_spq_post(p_hwfn, p_ent, &fw_return_code); - if (rc) - return rc; - - if (fw_return_code != RDMA_RETURN_OK) { - DP_NOTICE(p_hwfn, "fw_return_code = %d\n", fw_return_code); - return -EINVAL; - } - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Register TID, rc = %d\n", rc); - return rc; -} - -static int qed_rdma_deregister_tid(void *rdma_cxt, u32 itid) -{ - struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; - struct rdma_deregister_tid_ramrod_data *p_ramrod; - struct qed_sp_init_data init_data; - struct qed_spq_entry *p_ent; - struct qed_ptt *p_ptt; - u8 fw_return_code; - int rc; - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "itid = %08x\n", itid); - - /* Get SPQ entry */ - memset(&init_data, 0, sizeof(init_data)); - init_data.opaque_fid = p_hwfn->hw_info.opaque_fid; - init_data.comp_mode = QED_SPQ_MODE_EBLOCK; - - rc = qed_sp_init_request(p_hwfn, &p_ent, RDMA_RAMROD_DEREGISTER_MR, - p_hwfn->p_rdma_info->proto, &init_data); - if (rc) { - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "rc = %d\n", rc); - return rc; - } - - p_ramrod = &p_ent->ramrod.rdma_deregister_tid; - p_ramrod->itid = cpu_to_le32(itid); - - rc = qed_spq_post(p_hwfn, p_ent, &fw_return_code); - if (rc) { - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "rc = %d\n", rc); - return rc; - } - - if (fw_return_code == RDMA_RETURN_DEREGISTER_MR_BAD_STATE_ERR) { - DP_NOTICE(p_hwfn, "fw_return_code = %d\n", fw_return_code); - return -EINVAL; - } else if (fw_return_code == RDMA_RETURN_NIG_DRAIN_REQ) { - /* Bit indicating that the TID is in use and a nig drain is - * required before sending the ramrod again - */ - p_ptt = qed_ptt_acquire(p_hwfn); - if (!p_ptt) { - rc = -EBUSY; - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, - "Failed to acquire PTT\n"); - return rc; - } - - rc = qed_mcp_drain(p_hwfn, p_ptt); - if (rc) { - qed_ptt_release(p_hwfn, p_ptt); - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, - "Drain failed\n"); - return rc; - } - - qed_ptt_release(p_hwfn, p_ptt); - - /* Resend the ramrod */ - rc = qed_sp_init_request(p_hwfn, &p_ent, - RDMA_RAMROD_DEREGISTER_MR, - p_hwfn->p_rdma_info->proto, - &init_data); - if (rc) { - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, - "Failed to init sp-element\n"); - return rc; - } - - rc = qed_spq_post(p_hwfn, p_ent, &fw_return_code); - if (rc) { - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, - "Ramrod failed\n"); - return rc; - } - - if (fw_return_code != RDMA_RETURN_OK) { - DP_NOTICE(p_hwfn, "fw_return_code = %d\n", - fw_return_code); - return rc; - } - } - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "De-registered TID, rc = %d\n", rc); - return rc; -} - static void qed_roce_free_real_icid(struct qed_hwfn *p_hwfn, u16 icid) { struct qed_rdma_info *p_rdma_info = p_hwfn->p_rdma_info; @@ -2624,40 +1129,6 @@ static void qed_roce_free_real_icid(struct qed_hwfn *p_hwfn, u16 icid) spin_unlock_bh(&p_hwfn->p_rdma_info->lock); } -static void *qed_rdma_get_rdma_ctx(struct qed_dev *cdev) -{ - return QED_LEADING_HWFN(cdev); -} - -static bool qed_rdma_allocated_qps(struct qed_hwfn *p_hwfn) -{ - bool result; - - /* if rdma info has not been allocated, naturally there are no qps */ - if (!p_hwfn->p_rdma_info) - return false; - - spin_lock_bh(&p_hwfn->p_rdma_info->lock); - if (!p_hwfn->p_rdma_info->cid_map.bitmap) - result = false; - else - result = !qed_bmap_is_empty(&p_hwfn->p_rdma_info->cid_map); - spin_unlock_bh(&p_hwfn->p_rdma_info->lock); - return result; -} - -static void qed_rdma_dpm_conf(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt) -{ - u32 val; - - val = (p_hwfn->dcbx_no_edpm || p_hwfn->db_bar_no_edpm) ? 0 : 1; - - qed_wr(p_hwfn, p_ptt, DORQ_REG_PF_DPM_ENABLE, val); - DP_VERBOSE(p_hwfn, (QED_MSG_DCB | QED_MSG_RDMA), - "Changing DPM_EN state to %d (DCBX=%d, DB_BAR=%d)\n", - val, p_hwfn->dcbx_no_edpm, p_hwfn->db_bar_no_edpm); -} - void qed_roce_dpm_dcbx(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt) { u8 val; @@ -2672,134 +1143,9 @@ void qed_roce_dpm_dcbx(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt) qed_rdma_dpm_conf(p_hwfn, p_ptt); } -void qed_rdma_dpm_bar(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt) +int qed_roce_setup(struct qed_hwfn *p_hwfn) { - p_hwfn->db_bar_no_edpm = true; - - qed_rdma_dpm_conf(p_hwfn, p_ptt); -} - -static int qed_rdma_start(void *rdma_cxt, - struct qed_rdma_start_in_params *params) -{ - struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; - struct qed_ptt *p_ptt; - int rc = -EBUSY; - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, - "desired_cnq = %08x\n", params->desired_cnq); - - p_ptt = qed_ptt_acquire(p_hwfn); - if (!p_ptt) - goto err; - - rc = qed_rdma_alloc(p_hwfn, p_ptt, params); - if (rc) - goto err1; - - rc = qed_rdma_setup(p_hwfn, p_ptt, params); - if (rc) - goto err2; - - qed_ptt_release(p_hwfn, p_ptt); - - return rc; - -err2: - qed_rdma_free(p_hwfn); -err1: - qed_ptt_release(p_hwfn, p_ptt); -err: - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "RDMA start - error, rc = %d\n", rc); - return rc; -} - -static int qed_rdma_init(struct qed_dev *cdev, - struct qed_rdma_start_in_params *params) -{ - return qed_rdma_start(QED_LEADING_HWFN(cdev), params); -} - -static void qed_rdma_remove_user(void *rdma_cxt, u16 dpi) -{ - struct qed_hwfn *p_hwfn = (struct qed_hwfn *)rdma_cxt; - - DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "dpi = %08x\n", dpi); - - spin_lock_bh(&p_hwfn->p_rdma_info->lock); - qed_bmap_release_id(p_hwfn, &p_hwfn->p_rdma_info->dpi_map, dpi); - spin_unlock_bh(&p_hwfn->p_rdma_info->lock); + return qed_spq_register_async_cb(p_hwfn, PROTOCOLID_ROCE, + qed_roce_async_event); } -static int qed_roce_ll2_set_mac_filter(struct qed_dev *cdev, - u8 *old_mac_address, - u8 *new_mac_address) -{ - struct qed_hwfn *p_hwfn = QED_LEADING_HWFN(cdev); - struct qed_ptt *p_ptt; - int rc = 0; - - p_ptt = qed_ptt_acquire(p_hwfn); - if (!p_ptt) { - DP_ERR(cdev, - "qed roce ll2 mac filter set: failed to acquire PTT\n"); - return -EINVAL; - } - - if (old_mac_address) - qed_llh_remove_mac_filter(p_hwfn, p_ptt, old_mac_address); - if (new_mac_address) - rc = qed_llh_add_mac_filter(p_hwfn, p_ptt, new_mac_address); - - qed_ptt_release(p_hwfn, p_ptt); - - if (rc) - DP_ERR(cdev, - "qed roce ll2 mac filter set: failed to add MAC filter\n"); - - return rc; -} - -static const struct qed_rdma_ops qed_rdma_ops_pass = { - .common = &qed_common_ops_pass, - .fill_dev_info = &qed_fill_rdma_dev_info, - .rdma_get_rdma_ctx = &qed_rdma_get_rdma_ctx, - .rdma_init = &qed_rdma_init, - .rdma_add_user = &qed_rdma_add_user, - .rdma_remove_user = &qed_rdma_remove_user, - .rdma_stop = &qed_rdma_stop, - .rdma_query_port = &qed_rdma_query_port, - .rdma_query_device = &qed_rdma_query_device, - .rdma_get_start_sb = &qed_rdma_get_sb_start, - .rdma_get_rdma_int = &qed_rdma_get_int, - .rdma_set_rdma_int = &qed_rdma_set_int, - .rdma_get_min_cnq_msix = &qed_rdma_get_min_cnq_msix, - .rdma_cnq_prod_update = &qed_rdma_cnq_prod_update, - .rdma_alloc_pd = &qed_rdma_alloc_pd, - .rdma_dealloc_pd = &qed_rdma_free_pd, - .rdma_create_cq = &qed_rdma_create_cq, - .rdma_destroy_cq = &qed_rdma_destroy_cq, - .rdma_create_qp = &qed_rdma_create_qp, - .rdma_modify_qp = &qed_rdma_modify_qp, - .rdma_query_qp = &qed_rdma_query_qp, - .rdma_destroy_qp = &qed_rdma_destroy_qp, - .rdma_alloc_tid = &qed_rdma_alloc_tid, - .rdma_free_tid = &qed_rdma_free_tid, - .rdma_register_tid = &qed_rdma_register_tid, - .rdma_deregister_tid = &qed_rdma_deregister_tid, - .ll2_acquire_connection = &qed_ll2_acquire_connection, - .ll2_establish_connection = &qed_ll2_establish_connection, - .ll2_terminate_connection = &qed_ll2_terminate_connection, - .ll2_release_connection = &qed_ll2_release_connection, - .ll2_post_rx_buffer = &qed_ll2_post_rx_buffer, - .ll2_prepare_tx_packet = &qed_ll2_prepare_tx_packet, - .ll2_set_fragment_of_tx_packet = &qed_ll2_set_fragment_of_tx_packet, - .ll2_set_mac_filter = &qed_roce_ll2_set_mac_filter, - .ll2_get_stats = &qed_ll2_get_stats, -}; - -const struct qed_rdma_ops *qed_get_rdma_ops(void) -{ - return &qed_rdma_ops_pass; -} -EXPORT_SYMBOL(qed_get_rdma_ops); diff --git a/drivers/net/ethernet/qlogic/qed/qed_roce.h b/drivers/net/ethernet/qlogic/qed/qed_roce.h index b178d99..f801f39 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_roce.h +++ b/drivers/net/ethernet/qlogic/qed/qed_roce.h @@ -32,147 +32,28 @@ #ifndef _QED_ROCE_H #define _QED_ROCE_H #include -#include -#include -#include #include -#include -#include -#include -#include "qed.h" -#include "qed_dev_api.h" -#include "qed_hsi.h" -#include "qed_ll2.h" - -#define QED_RDMA_MAX_FMR (RDMA_MAX_TIDS) -#define QED_RDMA_MAX_P_KEY (1) -#define QED_RDMA_MAX_WQE (0x7FFF) -#define QED_RDMA_MAX_SRQ_WQE_ELEM (0x7FFF) -#define QED_RDMA_PAGE_SIZE_CAPS (0xFFFFF000) -#define QED_RDMA_ACK_DELAY (15) -#define QED_RDMA_MAX_MR_SIZE (0x10000000000ULL) -#define QED_RDMA_MAX_CQS (RDMA_MAX_CQS) -#define QED_RDMA_MAX_MRS (RDMA_MAX_TIDS) -/* Add 1 for header element */ -#define QED_RDMA_MAX_SRQ_ELEM_PER_WQE (RDMA_MAX_SGE_PER_RQ_WQE + 1) -#define QED_RDMA_MAX_SGE_PER_SRQ_WQE (RDMA_MAX_SGE_PER_RQ_WQE) -#define QED_RDMA_SRQ_WQE_ELEM_SIZE (16) -#define QED_RDMA_MAX_SRQS (32 * 1024) - -#define QED_RDMA_MAX_CQE_32_BIT (0x7FFFFFFF - 1) -#define QED_RDMA_MAX_CQE_16_BIT (0x7FFF - 1) - -enum qed_rdma_toggle_bit { - QED_RDMA_TOGGLE_BIT_CLEAR = 0, - QED_RDMA_TOGGLE_BIT_SET = 1 -}; - -#define QED_RDMA_MAX_BMAP_NAME (10) -struct qed_bmap { - unsigned long *bitmap; - u32 max_count; - char name[QED_RDMA_MAX_BMAP_NAME]; -}; - -struct qed_rdma_info { - /* spin lock to protect bitmaps */ - spinlock_t lock; - - struct qed_bmap cq_map; - struct qed_bmap pd_map; - struct qed_bmap tid_map; - struct qed_bmap qp_map; - struct qed_bmap srq_map; - struct qed_bmap cid_map; - struct qed_bmap real_cid_map; - struct qed_bmap dpi_map; - struct qed_bmap toggle_bits; - struct qed_rdma_events events; - struct qed_rdma_device *dev; - struct qed_rdma_port *port; - u32 last_tid; - u8 num_cnqs; - u32 num_qps; - u32 num_mrs; - u16 queue_zone_base; - u16 max_queue_zones; - enum protocol_type proto; -}; - -struct qed_rdma_qp { - struct regpair qp_handle; - struct regpair qp_handle_async; - u32 qpid; - u16 icid; - enum qed_roce_qp_state cur_state; - bool use_srq; - bool signal_all; - bool fmr_and_reserved_lkey; - - bool incoming_rdma_read_en; - bool incoming_rdma_write_en; - bool incoming_atomic_en; - bool e2e_flow_control_en; - - u16 pd; - u16 pkey; - u32 dest_qp; - u16 mtu; - u16 srq_id; - u8 traffic_class_tos; - u8 hop_limit_ttl; - u16 dpi; - u32 flow_label; - bool lb_indication; - u16 vlan_id; - u32 ack_timeout; - u8 retry_cnt; - u8 rnr_retry_cnt; - u8 min_rnr_nak_timer; - bool sqd_async; - union qed_gid sgid; - union qed_gid dgid; - enum roce_mode roce_mode; - u16 udp_src_port; - u8 stats_queue; - - /* requeseter */ - u8 max_rd_atomic_req; - u32 sq_psn; - u16 sq_cq_id; - u16 sq_num_pages; - dma_addr_t sq_pbl_ptr; - void *orq; - dma_addr_t orq_phys_addr; - u8 orq_num_pages; - bool req_offloaded; - - /* responder */ - u8 max_rd_atomic_resp; - u32 rq_psn; - u16 rq_cq_id; - u16 rq_num_pages; - dma_addr_t rq_pbl_ptr; - void *irq; - dma_addr_t irq_phys_addr; - u8 irq_num_pages; - bool resp_offloaded; - u32 cq_prod; - - u8 remote_mac_addr[6]; - u8 local_mac_addr[6]; - - void *shared_queue; - dma_addr_t shared_queue_phys_addr; -}; #if IS_ENABLED(CONFIG_QED_RDMA) -void qed_rdma_dpm_bar(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt); void qed_roce_dpm_dcbx(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt); #else -static inline void qed_rdma_dpm_bar(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt) {} - static inline void qed_roce_dpm_dcbx(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt) {} #endif + +int qed_roce_setup(struct qed_hwfn *p_hwfn); +void qed_roce_stop(struct qed_hwfn *p_hwfn); +int qed_roce_init_hw(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt); +int qed_roce_alloc_cid(struct qed_hwfn *p_hwfn, u16 *cid); +int qed_roce_destroy_qp(struct qed_hwfn *p_hwfn, struct qed_rdma_qp *qp); + +int qed_roce_query_qp(struct qed_hwfn *p_hwfn, + struct qed_rdma_qp *qp, + struct qed_rdma_query_qp_out_params *out_params); + +int qed_roce_modify_qp(struct qed_hwfn *p_hwfn, + struct qed_rdma_qp *qp, + enum qed_roce_qp_state prev_state, + struct qed_rdma_modify_qp_in_params *params); + #endif diff --git a/drivers/net/ethernet/qlogic/qed/qed_spq.c b/drivers/net/ethernet/qlogic/qed/qed_spq.c index 78954d2..be48d9a 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_spq.c +++ b/drivers/net/ethernet/qlogic/qed/qed_spq.c @@ -54,7 +54,7 @@ #include "qed_reg_addr.h" #include "qed_sp.h" #include "qed_sriov.h" -#include "qed_roce.h" +#include "qed_rdma.h" /*************************************************************************** * Structures & Definitions