get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/47147/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 47147,
    "url": "http://patches.dpdk.org/api/patches/47147/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20181022133021.11264-6-g.singh@nxp.com/",
    "project": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<20181022133021.11264-6-g.singh@nxp.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20181022133021.11264-6-g.singh@nxp.com",
    "date": "2018-10-22T13:31:11",
    "name": "[v3,05/15] crypto/caam_jr: add basic job ring routines",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "f30eb8745dc9009b79c07cf8b454ffc322dd975c",
    "submitter": {
        "id": 1068,
        "url": "http://patches.dpdk.org/api/people/1068/?format=api",
        "name": "Gagandeep Singh",
        "email": "g.singh@nxp.com"
    },
    "delegate": {
        "id": 6690,
        "url": "http://patches.dpdk.org/api/users/6690/?format=api",
        "username": "akhil",
        "first_name": "akhil",
        "last_name": "goyal",
        "email": "gakhil@marvell.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20181022133021.11264-6-g.singh@nxp.com/mbox/",
    "series": [
        {
            "id": 2011,
            "url": "http://patches.dpdk.org/api/series/2011/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=2011",
            "date": "2018-10-22T13:31:00",
            "name": "Introducing the NXP CAAM job ring driver",
            "version": 3,
            "mbox": "http://patches.dpdk.org/series/2011/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/47147/comments/",
    "check": "pending",
    "checks": "http://patches.dpdk.org/api/patches/47147/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id B980D5B36;\n\tMon, 22 Oct 2018 15:31:22 +0200 (CEST)",
            "from EUR02-HE1-obe.outbound.protection.outlook.com\n\t(mail-eopbgr10077.outbound.protection.outlook.com [40.107.1.77])\n\tby dpdk.org (Postfix) with ESMTP id 5E5F158CB\n\tfor <dev@dpdk.org>; Mon, 22 Oct 2018 15:31:15 +0200 (CEST)",
            "from HE1PR04MB1530.eurprd04.prod.outlook.com (10.164.48.20) by\n\tHE1PR04MB3131.eurprd04.prod.outlook.com (10.171.196.142) with\n\tMicrosoft SMTP Server (version=TLS1_2,\n\tcipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id\n\t15.20.1250.30; Mon, 22 Oct 2018 13:31:11 +0000",
            "from HE1PR04MB1530.eurprd04.prod.outlook.com\n\t([fe80::95cd:198:d5c5:59a4]) by\n\tHE1PR04MB1530.eurprd04.prod.outlook.com\n\t([fe80::95cd:198:d5c5:59a4%5]) with mapi id 15.20.1250.028;\n\tMon, 22 Oct 2018 13:31:11 +0000"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1;\n\th=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;\n\tbh=i0jxaFCHv4g/FyLrN6hR+3HbQW/xbGcGjf1cdVr+GWg=;\n\tb=kaYpUyBDfeiojpjuNnJh7wzSV1I3+f0j9GpFfZTK33kxy8thhpLAexbeWmPDdmeZyjp9iXwoY2d926o+EW7PZSti+e/4bwl1L4MttctrBEkZsZpIMBNdp3QQD6ZOvglBTTCAj9x1K1GwvZYf6MelbiBVSsl32xj7NNacVNF91lw=",
        "From": "Gagandeep Singh <G.Singh@nxp.com>",
        "To": "\"dev@dpdk.org\" <dev@dpdk.org>, Akhil Goyal <akhil.goyal@nxp.com>",
        "CC": "Gagandeep Singh <G.Singh@nxp.com>,\n\tHemant Agrawal <hemant.agrawal@nxp.com>",
        "Thread-Topic": "[PATCH v3 05/15] crypto/caam_jr: add basic job ring routines",
        "Thread-Index": "AQHUagt/xlvpz2sSqESh1Z3JN4jVpw==",
        "Date": "Mon, 22 Oct 2018 13:31:11 +0000",
        "Message-ID": "<20181022133021.11264-6-g.singh@nxp.com>",
        "References": "<20181012144055.9461-1-g.singh@nxp.com>\n\t<20181022133021.11264-1-g.singh@nxp.com>",
        "In-Reply-To": "<20181022133021.11264-1-g.singh@nxp.com>",
        "Accept-Language": "en-US",
        "Content-Language": "en-US",
        "X-MS-Has-Attach": "",
        "X-MS-TNEF-Correlator": "",
        "x-clientproxiedby": "BM1PR0101CA0016.INDPRD01.PROD.OUTLOOK.COM\n\t(2603:1096:b00:18::26) To HE1PR04MB1530.eurprd04.prod.outlook.com\n\t(2a01:111:e400:59a8::20)",
        "authentication-results": "spf=none (sender IP is )\n\tsmtp.mailfrom=G.Singh@nxp.com; ",
        "x-ms-exchange-messagesentrepresentingtype": "1",
        "x-originating-ip": "[14.142.187.166]",
        "x-ms-publictraffictype": "Email",
        "x-microsoft-exchange-diagnostics": "1; HE1PR04MB3131;\n\t6:ETlC/bgJkk6vCA0F/U3/uu9J1wGGWKMaHSgLu9r/NnBVHRg2PoUj0yTfp3fH9tHz+YL/wYarMmqaQVBYRSQoG9fdeIZMJ/cKBT/IMtfoqUKAW9+UjMdw4awbxLMsIOmFNufuZhMosY47wmPb8Qnwez+/4QvlfQir2eB4Pb57jIhIetnlgGy6ILNWJtsilez5C7dIAzmeeORUxAU3JJRqMJpRU1r3ywzOQdq2B12mT//7zKaCNG9K71VmTP7ueGaQNwpEoCeYVpYYImXry+V6c04wvT0L7rfb+LPue8blTa0dMjnneuooowrScp+5cuJwVuCzCgoqaC2yCF600PjA4WY3KZjKp5mQMXsdckNSJQs/XcO0dwz1pc3PUkEwLm8ynuM40b6Xh2gkgP25ChzEAmNVyLprvaX96bmvuVV/zRPETfkiGpkzu/YzlYDlyKol4cGw2PvwJFxRYWhip0agtg==;\n\t5:B4/ujQCDppWqeou7JHzv67JVXKwZ55euXi8nJhuzcN+r6+jcgt6WNIDwquTd9JOyIhjS8N6mdMxM7nYgIUW8ww+2b1WgElyNIoLS3/N9/HpsjHJtI9IEcqoY75IK8QWWeWnsmEew8Jaq7oDZN5uAZe4Q89kgZi2RVn7yA2kMOkQ=;\n\t7:KIxJj580zDsbf9Z0F9MftO4ER8o77VrUIMDVuRXMa7VoF7tiJraAmmCY5L/vUwCrRIYYRERLQbLC8/hj/x3WMPVHSMuaYWNXgxISTGg9mdZCRNtF5A8ThrmWJ4Msso+omyZrBNCb92Wr1i0EOHfJ2Ar1MaONNLTeIR61yeEhZSEoKf+LkF45KJ1qYsbBbJpk9G1YWlu0ARj2J472VK3UoKfcP9RlDZt3vWhQ9ysekwQwxkuZ67CNeHwyPiMhta0s",
        "x-ms-office365-filtering-correlation-id": "6aa534f9-9ef0-4f20-fc6a-08d63822a199",
        "x-ms-office365-filtering-ht": "Tenant",
        "x-microsoft-antispam": "BCL:0; PCL:0;\n\tRULEID:(7020095)(4652040)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020);\n\tSRVR:HE1PR04MB3131; ",
        "x-ms-traffictypediagnostic": "HE1PR04MB3131:",
        "x-microsoft-antispam-prvs": "<HE1PR04MB31310AFC3B39702BB1DD5AE3E1F40@HE1PR04MB3131.eurprd04.prod.outlook.com>",
        "x-exchange-antispam-report-test": "UriScan:(192374486261705)(185117386973197); ",
        "x-ms-exchange-senderadcheck": "1",
        "x-exchange-antispam-report-cfa-test": "BCL:0; PCL:0;\n\tRULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3002001)(3231355)(944501410)(52105095)(6055026)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201708071742011)(7699051)(76991095);\n\tSRVR:HE1PR04MB3131; BCL:0; PCL:0; RULEID:; SRVR:HE1PR04MB3131; ",
        "x-forefront-prvs": "08331F819E",
        "x-forefront-antispam-report": "SFV:NSPM;\n\tSFS:(10009020)(366004)(376002)(39860400002)(136003)(346002)(396003)(189003)(199004)(110136005)(99286004)(316002)(54906003)(81156014)(14454004)(25786009)(72206003)(81166006)(2900100001)(8936002)(106356001)(8676002)(6116002)(3846002)(86362001)(2616005)(476003)(6506007)(386003)(102836004)(1076002)(11346002)(446003)(26005)(186003)(305945005)(478600001)(4326008)(2906002)(76176011)(68736007)(7736002)(6636002)(97736004)(486006)(52116002)(36756003)(55236004)(105586002)(71190400001)(5660300001)(4744004)(6436002)(6486002)(78486010)(53936002)(14444005)(2501003)(256004)(66066001)(71200400001)(5250100002)(6512007);\n\tDIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR04MB3131;\n\tH:HE1PR04MB1530.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en;\n\tPTR:InfoNoRecords; MX:3; A:1; ",
        "received-spf": "None (protection.outlook.com: nxp.com does not designate\n\tpermitted sender hosts)",
        "x-microsoft-antispam-message-info": "iX0yxqZa3Z9JqGk/MjaTOkh3rywDRPry//zdVPrm02Dl2ZkgajSWU+sFITEFAAosuZe/nDCs3tL+A/53gEomaFJRwPF5FpZe9p5lwKHyyWfhNVbue+MnEqOV5yTbdUGquPy5wIO2pweQqJsu73kKzb+2ROe4SAtd/2HeqNvdrszt4v3wyQv8x/sXroZsn6fMIf66W4IOnscNPTTh0RxMAjNitWe9Wjytd9dZ+SAkLc/YCnoHf3y/oMUuicFPyixP0IB/Ui+Ip6DMpu6REJ6wjpR6ocrJ8r2cU7b/wrSDCvht5obKOHiaS0kjuOonRyE/9mcWwnqt9MpL5MnUEhE/dDyZf4APxLt5m6EIYIQJe0k=",
        "spamdiagnosticoutput": "1:99",
        "spamdiagnosticmetadata": "NSPM",
        "Content-Type": "text/plain; charset=\"iso-8859-1\"",
        "Content-Transfer-Encoding": "quoted-printable",
        "MIME-Version": "1.0",
        "X-OriginatorOrg": "nxp.com",
        "X-MS-Exchange-CrossTenant-Network-Message-Id": "6aa534f9-9ef0-4f20-fc6a-08d63822a199",
        "X-MS-Exchange-CrossTenant-originalarrivaltime": "22 Oct 2018 13:31:11.7936\n\t(UTC)",
        "X-MS-Exchange-CrossTenant-fromentityheader": "Hosted",
        "X-MS-Exchange-CrossTenant-id": "686ea1d3-bc2b-4c6f-a92c-d99c5c301635",
        "X-MS-Exchange-Transport-CrossTenantHeadersStamped": "HE1PR04MB3131",
        "Subject": "[dpdk-dev] [PATCH v3 05/15] crypto/caam_jr: add basic job ring\n\troutines",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "This patch adds following job ring routines\n - init_job_ring (configure hw/sw resources)\n - shutdown_job_ring (releases hw/sw resources)\n - close_job_ring (flush job ring)\n\nSigned-off-by: Gagandeep Singh <g.singh@nxp.com>\nSigned-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>\nAcked-by: Akhil Goyal <akhil.goyal@nxp.com>\n---\n drivers/crypto/caam_jr/caam_jr.c | 329 ++++++++++++++++++++++++++++++-\n 1 file changed, 327 insertions(+), 2 deletions(-)",
    "diff": "diff --git a/drivers/crypto/caam_jr/caam_jr.c b/drivers/crypto/caam_jr/caam_jr.c\nindex 27331194a..cb024a979 100644\n--- a/drivers/crypto/caam_jr/caam_jr.c\n+++ b/drivers/crypto/caam_jr/caam_jr.c\n@@ -17,12 +17,142 @@\n #include <rte_security_driver.h>\n #include <rte_hexdump.h>\n \n+#include <caam_jr_config.h>\n+#include <caam_jr_hw_specific.h>\n+#include <caam_jr_pvt.h>\n #include <caam_jr_log.h>\n \n+/* RTA header files */\n+#include <hw/desc/common.h>\n+#include <of.h>\n+\n #define CRYPTODEV_NAME_CAAM_JR_PMD\tcrypto_caam_jr\n static uint8_t cryptodev_driver_id;\n int caam_jr_logtype;\n \n+enum rta_sec_era rta_sec_era;\n+\n+/* Lists the states possible for the SEC user space driver. */\n+enum sec_driver_state_e {\n+\tSEC_DRIVER_STATE_IDLE,\t\t/* Driver not initialized */\n+\tSEC_DRIVER_STATE_STARTED,\t/* Driver initialized and can be used*/\n+\tSEC_DRIVER_STATE_RELEASE,\t/* Driver release is in progress */\n+};\n+\n+/* Job rings used for communication with SEC HW */\n+static struct sec_job_ring_t g_job_rings[MAX_SEC_JOB_RINGS];\n+\n+/* The current state of SEC user space driver */\n+static enum sec_driver_state_e g_driver_state = SEC_DRIVER_STATE_IDLE;\n+\n+/* The number of job rings used by SEC user space driver */\n+static int g_job_rings_no;\n+static int g_job_rings_max;\n+\n+/* @brief Poll the HW for already processed jobs in the JR\n+ * and silently discard the available jobs or notify them to UA\n+ * with indicated error code.\n+ *\n+ * @param [in,out]  job_ring        The job ring to poll.\n+ * @param [in]  do_notify           Can be #TRUE or #FALSE. Indicates if\n+ *\t\t\t\t    descriptors are to be discarded\n+ *                                  or notified to UA with given error_code.\n+ * @param [out] notified_descs    Number of notified descriptors. Can be NULL\n+ *\t\t\t\t\tif do_notify is #FALSE\n+ */\n+static void\n+hw_flush_job_ring(struct sec_job_ring_t *job_ring,\n+\t\t  uint32_t do_notify,\n+\t\t  uint32_t *notified_descs)\n+{\n+\tint32_t jobs_no_to_discard = 0;\n+\tint32_t discarded_descs_no = 0;\n+\n+\tPMD_INIT_FUNC_TRACE();\n+\tCAAM_JR_DEBUG(\"Jr[%p] pi[%d] ci[%d].Flushing jr notify desc=[%d]\",\n+\t\tjob_ring, job_ring->pidx, job_ring->cidx, do_notify);\n+\n+\tjobs_no_to_discard = hw_get_no_finished_jobs(job_ring);\n+\n+\t/* Discard all jobs */\n+\tCAAM_JR_DEBUG(\"Jr[%p] pi[%d] ci[%d].Discarding %d descs\",\n+\t\t  job_ring, job_ring->pidx, job_ring->cidx,\n+\t\t  jobs_no_to_discard);\n+\n+\twhile (jobs_no_to_discard > discarded_descs_no) {\n+\t\tdiscarded_descs_no++;\n+\t\t/* Now increment the consumer index for the current job ring,\n+\t\t * AFTER saving job in temporary location!\n+\t\t * Increment the consumer index for the current job ring\n+\t\t */\n+\t\tjob_ring->cidx = SEC_CIRCULAR_COUNTER(job_ring->cidx,\n+\t\t\t\t\t SEC_JOB_RING_SIZE);\n+\n+\t\thw_remove_entries(job_ring, 1);\n+\t}\n+\n+\tif (do_notify == true) {\n+\t\tASSERT(notified_descs != NULL);\n+\t\t*notified_descs = discarded_descs_no;\n+\t}\n+}\n+\n+\n+/* @brief Flush job rings of any processed descs.\n+ * The processed descs are silently dropped,\n+ * WITHOUT being notified to UA.\n+ */\n+static void\n+close_job_ring(struct sec_job_ring_t *job_ring)\n+{\n+\tPMD_INIT_FUNC_TRACE();\n+\tif (job_ring->irq_fd) {\n+\t\t/* Producer index is frozen. If consumer index is not equal\n+\t\t * with producer index, then we have descs to flush.\n+\t\t */\n+\t\twhile (job_ring->pidx != job_ring->cidx)\n+\t\t\thw_flush_job_ring(job_ring, false, NULL);\n+\n+\t\t/* free the uio job ring */\n+\t\tfree_job_ring(job_ring->irq_fd);\n+\t\tjob_ring->irq_fd = 0;\n+\t\tcaam_jr_dma_free(job_ring->input_ring);\n+\t\tcaam_jr_dma_free(job_ring->output_ring);\n+\t\tg_job_rings_no--;\n+\t}\n+}\n+\n+/** @brief Release the software and hardware resources tied to a job ring.\n+ * @param [in] job_ring The job ring\n+ *\n+ * @retval  0 for success\n+ * @retval  -1 for error\n+ */\n+static int\n+shutdown_job_ring(struct sec_job_ring_t *job_ring)\n+{\n+\tint ret = 0;\n+\n+\tPMD_INIT_FUNC_TRACE();\n+\tASSERT(job_ring != NULL);\n+\tret = hw_shutdown_job_ring(job_ring);\n+\tSEC_ASSERT(ret == 0, ret,\n+\t\t\"Failed to shutdown hardware job ring %p\",\n+\t\tjob_ring);\n+\n+\tif (job_ring->coalescing_en)\n+\t\thw_job_ring_disable_coalescing(job_ring);\n+\n+\tif (job_ring->jr_mode != SEC_NOTIFICATION_TYPE_POLL) {\n+\t\tret = caam_jr_disable_irqs(job_ring->irq_fd);\n+\t\tSEC_ASSERT(ret == 0, ret,\n+\t\t\"Failed to disable irqs for job ring %p\",\n+\t\tjob_ring);\n+\t}\n+\n+\treturn ret;\n+}\n+\n /*\n  * @brief Release the resources used by the SEC user space driver.\n  *\n@@ -40,28 +170,195 @@ int caam_jr_logtype;\n static int\n caam_jr_dev_uninit(struct rte_cryptodev *dev)\n {\n+\tstruct sec_job_ring_t *internals;\n+\n+\tPMD_INIT_FUNC_TRACE();\n \tif (dev == NULL)\n \t\treturn -ENODEV;\n \n+\tinternals = dev->data->dev_private;\n+\trte_free(dev->security_ctx);\n+\n+\t/* If any descriptors in flight , poll and wait\n+\t * until all descriptors are received and silently discarded.\n+\t */\n+\tif (internals) {\n+\t\tshutdown_job_ring(internals);\n+\t\tclose_job_ring(internals);\n+\t\trte_mempool_free(internals->ctx_pool);\n+\t}\n+\n \tCAAM_JR_INFO(\"Closing crypto device %s\", dev->data->name);\n \n-\treturn 0;\n+\t/* last caam jr instance) */\n+\tif (g_job_rings_no == 0)\n+\t\tg_driver_state = SEC_DRIVER_STATE_IDLE;\n+\n+\treturn SEC_SUCCESS;\n+}\n+\n+/* @brief Initialize the software and hardware resources tied to a job ring.\n+ * @param [in] jr_mode;\t\tModel to be used by SEC Driver to receive\n+ *\t\t\t\tnotifications from SEC.  Can be either\n+ *\t\t\t\tof the three: #SEC_NOTIFICATION_TYPE_NAPI\n+ *\t\t\t\t#SEC_NOTIFICATION_TYPE_IRQ or\n+ *\t\t\t\t#SEC_NOTIFICATION_TYPE_POLL\n+ * @param [in] NAPI_mode\tThe NAPI work mode to configure a job ring at\n+ *\t\t\t\tstartup. Used only when #SEC_NOTIFICATION_TYPE\n+ *\t\t\t\tis set to #SEC_NOTIFICATION_TYPE_NAPI.\n+ * @param [in] irq_coalescing_timer This value determines the maximum\n+ *\t\t\t\t\tamount of time after processing a\n+ *\t\t\t\t\tdescriptor before raising an interrupt.\n+ * @param [in] irq_coalescing_count This value determines how many\n+ *\t\t\t\t\tdescriptors are completed before\n+ *\t\t\t\t\traising an interrupt.\n+ * @param [in] reg_base_addr,\tThe job ring base address register\n+ * @param [in] irq_id\t\tThe job ring interrupt identification number.\n+ * @retval  job_ring_handle for successful job ring configuration\n+ * @retval  NULL on error\n+ *\n+ */\n+static void *\n+init_job_ring(void *reg_base_addr, uint32_t irq_id)\n+{\n+\tstruct sec_job_ring_t *job_ring = NULL;\n+\tint i, ret = 0;\n+\tint jr_mode = SEC_NOTIFICATION_TYPE_POLL;\n+\tint napi_mode = 0;\n+\tint irq_coalescing_timer = 0;\n+\tint irq_coalescing_count = 0;\n+\n+\tfor (i = 0; i < MAX_SEC_JOB_RINGS; i++) {\n+\t\tif (g_job_rings[i].irq_fd == 0) {\n+\t\t\tjob_ring = &g_job_rings[i];\n+\t\t\tg_job_rings_no++;\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+\tif (job_ring == NULL) {\n+\t\tCAAM_JR_ERR(\"No free job ring\\n\");\n+\t\treturn NULL;\n+\t}\n+\n+\tjob_ring->register_base_addr = reg_base_addr;\n+\tjob_ring->jr_mode = jr_mode;\n+\tjob_ring->napi_mode = 0;\n+\tjob_ring->irq_fd = irq_id;\n+\n+\t/* Allocate mem for input and output ring */\n+\n+\t/* Allocate memory for input ring */\n+\tjob_ring->input_ring = caam_jr_dma_mem_alloc(L1_CACHE_BYTES,\n+\t\t\t\tSEC_DMA_MEM_INPUT_RING_SIZE);\n+\tmemset(job_ring->input_ring, 0, SEC_DMA_MEM_INPUT_RING_SIZE);\n+\n+\t/* Allocate memory for output ring */\n+\tjob_ring->output_ring = caam_jr_dma_mem_alloc(L1_CACHE_BYTES,\n+\t\t\t\tSEC_DMA_MEM_OUTPUT_RING_SIZE);\n+\tmemset(job_ring->output_ring, 0, SEC_DMA_MEM_OUTPUT_RING_SIZE);\n+\n+\t/* Reset job ring in SEC hw and configure job ring registers */\n+\tret = hw_reset_job_ring(job_ring);\n+\tif (ret != 0) {\n+\t\tCAAM_JR_ERR(\"Failed to reset hardware job ring\");\n+\t\tgoto cleanup;\n+\t}\n+\n+\tif (jr_mode == SEC_NOTIFICATION_TYPE_NAPI) {\n+\t/* When SEC US driver works in NAPI mode, the UA can select\n+\t * if the driver starts with IRQs on or off.\n+\t */\n+\t\tif (napi_mode == SEC_STARTUP_INTERRUPT_MODE) {\n+\t\t\tCAAM_JR_INFO(\"Enabling DONE IRQ generationon job ring - %p\",\n+\t\t\t\tjob_ring);\n+\t\t\tret = caam_jr_enable_irqs(job_ring->irq_fd);\n+\t\t\tif (ret != 0) {\n+\t\t\t\tCAAM_JR_ERR(\"Failed to enable irqs for job ring\");\n+\t\t\t\tgoto cleanup;\n+\t\t\t}\n+\t\t}\n+\t} else if (jr_mode == SEC_NOTIFICATION_TYPE_IRQ) {\n+\t/* When SEC US driver works in pure interrupt mode,\n+\t * IRQ's are always enabled.\n+\t */\n+\t\tCAAM_JR_INFO(\"Enabling DONE IRQ generation on job ring - %p\",\n+\t\t\t job_ring);\n+\t\tret = caam_jr_enable_irqs(job_ring->irq_fd);\n+\t\tif (ret != 0) {\n+\t\t\tCAAM_JR_ERR(\"Failed to enable irqs for job ring\");\n+\t\t\tgoto cleanup;\n+\t\t}\n+\t}\n+\tif (irq_coalescing_timer || irq_coalescing_count) {\n+\t\thw_job_ring_set_coalescing_param(job_ring,\n+\t\t\t irq_coalescing_timer,\n+\t\t\t irq_coalescing_count);\n+\n+\t\thw_job_ring_enable_coalescing(job_ring);\n+\t\tjob_ring->coalescing_en = 1;\n+\t}\n+\n+\tjob_ring->jr_state = SEC_JOB_RING_STATE_STARTED;\n+\tjob_ring->max_nb_queue_pairs = RTE_CAAM_MAX_NB_SEC_QPS;\n+\tjob_ring->max_nb_sessions = RTE_CAAM_JR_PMD_MAX_NB_SESSIONS;\n+\n+\treturn job_ring;\n+cleanup:\n+\tcaam_jr_dma_free(job_ring->output_ring);\n+\tcaam_jr_dma_free(job_ring->input_ring);\n+\treturn NULL;\n }\n \n+\n static int\n caam_jr_dev_init(const char *name,\n \t\t struct rte_vdev_device *vdev,\n \t\t struct rte_cryptodev_pmd_init_params *init_params)\n {\n \tstruct rte_cryptodev *dev;\n+\tstruct uio_job_ring *job_ring;\n+\tchar str[RTE_CRYPTODEV_NAME_MAX_LEN];\n \n \tPMD_INIT_FUNC_TRACE();\n \n+\t/* Validate driver state */\n+\tif (g_driver_state == SEC_DRIVER_STATE_IDLE) {\n+\t\tg_job_rings_max = sec_configure();\n+\t\tif (!g_job_rings_max) {\n+\t\t\tCAAM_JR_ERR(\"No job ring detected on UIO !!!!\");\n+\t\t\treturn -1;\n+\t\t}\n+\t\t/* Update driver state */\n+\t\tg_driver_state = SEC_DRIVER_STATE_STARTED;\n+\t}\n+\n+\tif (g_job_rings_no >= g_job_rings_max) {\n+\t\tCAAM_JR_ERR(\"No more job rings available max=%d!!!!\",\n+\t\t\t\tg_job_rings_max);\n+\t\treturn -1;\n+\t}\n+\n+\tjob_ring = config_job_ring();\n+\tif (job_ring == NULL) {\n+\t\tCAAM_JR_ERR(\"failed to create job ring\");\n+\t\tgoto init_error;\n+\t}\n+\n+\tsnprintf(str, sizeof(str), \"caam_jr%d\", job_ring->jr_id);\n+\n \tdev = rte_cryptodev_pmd_create(name, &vdev->device, init_params);\n \tif (dev == NULL) {\n \t\tCAAM_JR_ERR(\"failed to create cryptodev vdev\");\n \t\tgoto cleanup;\n \t}\n+\t/*TODO free it during teardown*/\n+\tdev->data->dev_private = init_job_ring(job_ring->register_base_addr,\n+\t\t\t\t\t\tjob_ring->uio_fd);\n+\n+\tif (!dev->data->dev_private) {\n+\t\tCAAM_JR_ERR(\"Ring memory allocation failed\\n\");\n+\t\tgoto cleanup2;\n+\t}\n \n \tdev->driver_id = cryptodev_driver_id;\n \tdev->dev_ops = NULL;\n@@ -79,7 +376,12 @@ caam_jr_dev_init(const char *name,\n \n \treturn 0;\n \n+cleanup2:\n+\tcaam_jr_dev_uninit(dev);\n+\trte_cryptodev_pmd_release_device(dev);\n cleanup:\n+\tfree_job_ring(job_ring->uio_fd);\n+init_error:\n \tCAAM_JR_ERR(\"driver %s: cryptodev_caam_jr_create failed\",\n \t\t\tinit_params->name);\n \n@@ -92,7 +394,7 @@ cryptodev_caam_jr_probe(struct rte_vdev_device *vdev)\n {\n \tstruct rte_cryptodev_pmd_init_params init_params = {\n \t\t\"\",\n-\t\t128,\n+\t\tsizeof(struct sec_job_ring_t),\n \t\trte_socket_id(),\n \t\tRTE_CRYPTODEV_PMD_DEFAULT_MAX_NB_QUEUE_PAIRS\n \t};\n@@ -106,6 +408,29 @@ cryptodev_caam_jr_probe(struct rte_vdev_device *vdev)\n \tinput_args = rte_vdev_device_args(vdev);\n \trte_cryptodev_pmd_parse_input_args(&init_params, input_args);\n \n+\t/* if sec device version is not configured */\n+\tif (!rta_get_sec_era()) {\n+\t\tconst struct device_node *caam_node;\n+\n+\t\tfor_each_compatible_node(caam_node, NULL, \"fsl,sec-v4.0\") {\n+\t\t\tconst uint32_t *prop = of_get_property(caam_node,\n+\t\t\t\t\t\"fsl,sec-era\",\n+\t\t\t\t\tNULL);\n+\t\t\tif (prop) {\n+\t\t\t\trta_set_sec_era(\n+\t\t\t\t\tINTL_SEC_ERA(cpu_to_caam32(*prop)));\n+\t\t\t\tbreak;\n+\t\t\t}\n+\t\t}\n+\t}\n+#ifdef RTE_LIBRTE_PMD_CAAM_JR_BE\n+\tif (rta_get_sec_era() > RTA_SEC_ERA_8) {\n+\t\tRTE_LOG(ERR, PMD,\n+\t\t\"CAAM is compiled in BE mode for device with sec era > 8???\\n\");\n+\t\treturn -EINVAL;\n+\t}\n+#endif\n+\n \treturn caam_jr_dev_init(name, vdev, &init_params);\n }\n \n",
    "prefixes": [
        "v3",
        "05/15"
    ]
}