get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 94701,
    "url": "https://patches.dpdk.org/api/patches/94701/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20210623044702.4240-6-ndabilpuram@marvell.com/",
    "project": {
        "id": 1,
        "url": "https://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": "<20210623044702.4240-6-ndabilpuram@marvell.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20210623044702.4240-6-ndabilpuram@marvell.com",
    "date": "2021-06-23T04:46:05",
    "name": "[v4,05/62] common/cnxk: allocate lmt region in userspace",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "38aa84bc33c21b99d7a9b8638bdb165656ceb081",
    "submitter": {
        "id": 1202,
        "url": "https://patches.dpdk.org/api/people/1202/?format=api",
        "name": "Nithin Dabilpuram",
        "email": "ndabilpuram@marvell.com"
    },
    "delegate": {
        "id": 310,
        "url": "https://patches.dpdk.org/api/users/310/?format=api",
        "username": "jerin",
        "first_name": "Jerin",
        "last_name": "Jacob",
        "email": "jerinj@marvell.com"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/20210623044702.4240-6-ndabilpuram@marvell.com/mbox/",
    "series": [
        {
            "id": 17449,
            "url": "https://patches.dpdk.org/api/series/17449/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=17449",
            "date": "2021-06-23T04:46:00",
            "name": "Marvell CNXK Ethdev Driver",
            "version": 4,
            "mbox": "https://patches.dpdk.org/series/17449/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/94701/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/94701/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 3C259A0C41;\n\tWed, 23 Jun 2021 06:47:59 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 435A6410F7;\n\tWed, 23 Jun 2021 06:47:37 +0200 (CEST)",
            "from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com\n [67.231.156.173])\n by mails.dpdk.org (Postfix) with ESMTP id 04E2B410FE\n for <dev@dpdk.org>; Wed, 23 Jun 2021 06:47:35 +0200 (CEST)",
            "from pps.filterd (m0045851.ppops.net [127.0.0.1])\n by mx0b-0016f401.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id\n 15N4k6fK025518 for <dev@dpdk.org>; Tue, 22 Jun 2021 21:47:35 -0700",
            "from dc5-exch02.marvell.com ([199.233.59.182])\n by mx0b-0016f401.pphosted.com with ESMTP id 39bptj1ghf-1\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT)\n for <dev@dpdk.org>; Tue, 22 Jun 2021 21:47:35 -0700",
            "from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com\n (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18;\n Tue, 22 Jun 2021 21:47:33 -0700",
            "from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com\n (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.18 via Frontend\n Transport; Tue, 22 Jun 2021 21:47:33 -0700",
            "from hyd1588t430.marvell.com (unknown [10.29.52.204])\n by maili.marvell.com (Postfix) with ESMTP id 8160F5B6936;\n Tue, 22 Jun 2021 21:47:30 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com;\n h=from : to : cc :\n subject : date : message-id : in-reply-to : references : mime-version :\n content-type; s=pfpt0220; bh=0KvAXNDjbAoFRkfuDiQmRFOIjcdpkIDoild06K4dKac=;\n b=B5tDTpWLQ+FbMxBRby875vjcFFcQnZ791iy9zHfSTe8+nD0myNzEgn0PCxQ+8MZoScfQ\n 0Ygah1FvWiTOeSwP920Y4DEDA6m3WMrhZXKFX152PfmUjKDyCUsuLWUkHYZtMMDo3gDQ\n JdzvXWfevA1nKtun3wQ/bc40jNrm0PtlhQ0GDOmb13fCpyqfic6J3YuCxI/xAAG5aFH/\n ZZWw4+dhuQWcz5Det4sBNeEzoX3+//PRdvEHIMJmhq2o2P2btbGY1lvo/gc+DnFOwDVo\n DUfkXC+J4tPmVOAvjGgM+ZiqAqeJtZQaRjzrkp8BuVfDlo2Ayi/3qOl5bTAg6sRZxTwa Hg==",
        "From": "Nithin Dabilpuram <ndabilpuram@marvell.com>",
        "To": "<dev@dpdk.org>",
        "CC": "<jerinj@marvell.com>, <skori@marvell.com>, <skoteshwar@marvell.com>,\n <pbhagavatula@marvell.com>, <kirankumark@marvell.com>,\n <psatheesh@marvell.com>, <asekhar@marvell.com>, <hkalra@marvell.com>",
        "Date": "Wed, 23 Jun 2021 10:16:05 +0530",
        "Message-ID": "<20210623044702.4240-6-ndabilpuram@marvell.com>",
        "X-Mailer": "git-send-email 2.8.4",
        "In-Reply-To": "<20210623044702.4240-1-ndabilpuram@marvell.com>",
        "References": "<20210306153404.10781-1-ndabilpuram@marvell.com>\n <20210623044702.4240-1-ndabilpuram@marvell.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain",
        "X-Proofpoint-ORIG-GUID": "eEpKeZxkwm4C1m07QnUgTT6JyPxR9y9v",
        "X-Proofpoint-GUID": "eEpKeZxkwm4C1m07QnUgTT6JyPxR9y9v",
        "X-Proofpoint-Virus-Version": "vendor=fsecure engine=2.50.10434:6.0.391, 18.0.790\n definitions=2021-06-23_01:2021-06-22,\n 2021-06-23 signatures=0",
        "Subject": "[dpdk-dev] [PATCH v4 05/62] common/cnxk: allocate lmt region in\n userspace",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <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 <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "From: Harman Kalra <hkalra@marvell.com>\n\nAs per the new LMTST design, userspace shall allocate lmt region,\nsetup the DMA translation and share the IOVA with kernel via MBOX.\nKernel will convert this IOVA to physical memory and update the\nLMT table entry with the same.\nWith this new design also shared mode (i.e. all pci funcs sharing\nthe LMT region allocated by primary/base pci func) is intact.\n\nSigned-off-by: Harman Kalra <hkalra@marvell.com>\n---\n drivers/common/cnxk/roc_api.h      |  2 +\n drivers/common/cnxk/roc_dev.c      | 98 ++++++++++++++++++--------------------\n drivers/common/cnxk/roc_dev_priv.h |  1 +\n drivers/common/cnxk/roc_mbox.h     |  3 ++\n drivers/common/cnxk/roc_platform.h | 11 +++++\n 5 files changed, 63 insertions(+), 52 deletions(-)",
    "diff": "diff --git a/drivers/common/cnxk/roc_api.h b/drivers/common/cnxk/roc_api.h\nindex 67f5d13..32e383c 100644\n--- a/drivers/common/cnxk/roc_api.h\n+++ b/drivers/common/cnxk/roc_api.h\n@@ -24,6 +24,8 @@\n /* Platform definition */\n #include \"roc_platform.h\"\n \n+#define ROC_LMT_LINE_SZ\t\t    128\n+#define ROC_NUM_LMT_LINES\t    2048\n #define ROC_LMT_LINES_PER_CORE_LOG2 5\n #define ROC_LMT_LINE_SIZE_LOG2\t    7\n #define ROC_LMT_BASE_PER_CORE_LOG2                                             \\\ndiff --git a/drivers/common/cnxk/roc_dev.c b/drivers/common/cnxk/roc_dev.c\nindex a39acc9..adff779 100644\n--- a/drivers/common/cnxk/roc_dev.c\n+++ b/drivers/common/cnxk/roc_dev.c\n@@ -915,43 +915,30 @@ dev_vf_mbase_put(struct plt_pci_device *pci_dev, uintptr_t vf_mbase)\n \tmbox_mem_unmap((void *)vf_mbase, MBOX_SIZE * pci_dev->max_vfs);\n }\n \n-static uint16_t\n-dev_pf_total_vfs(struct plt_pci_device *pci_dev)\n-{\n-\tuint16_t total_vfs = 0;\n-\tint sriov_pos, rc;\n-\n-\tsriov_pos =\n-\t\tplt_pci_find_ext_capability(pci_dev, ROC_PCI_EXT_CAP_ID_SRIOV);\n-\tif (sriov_pos <= 0) {\n-\t\tplt_warn(\"Unable to find SRIOV cap, rc=%d\", sriov_pos);\n-\t\treturn 0;\n-\t}\n-\n-\trc = plt_pci_read_config(pci_dev, &total_vfs, 2,\n-\t\t\t\t sriov_pos + ROC_PCI_SRIOV_TOTAL_VF);\n-\tif (rc < 0) {\n-\t\tplt_warn(\"Unable to read SRIOV cap, rc=%d\", rc);\n-\t\treturn 0;\n-\t}\n-\n-\treturn total_vfs;\n-}\n-\n static int\n-dev_setup_shared_lmt_region(struct mbox *mbox)\n+dev_setup_shared_lmt_region(struct mbox *mbox, bool valid_iova, uint64_t iova)\n {\n \tstruct lmtst_tbl_setup_req *req;\n \n \treq = mbox_alloc_msg_lmtst_tbl_setup(mbox);\n-\treq->pcifunc = idev_lmt_pffunc_get();\n+\t/* This pcifunc is defined with primary pcifunc whose LMT address\n+\t * will be shared. If call contains valid IOVA, following pcifunc\n+\t * field is of no use.\n+\t */\n+\treq->pcifunc = valid_iova ? 0 : idev_lmt_pffunc_get();\n+\treq->use_local_lmt_region = valid_iova;\n+\treq->lmt_iova = iova;\n \n \treturn mbox_process(mbox);\n }\n \n+/* Total no of lines * size of each lmtline */\n+#define LMT_REGION_SIZE (ROC_NUM_LMT_LINES * ROC_LMT_LINE_SZ)\n static int\n-dev_lmt_setup(struct plt_pci_device *pci_dev, struct dev *dev)\n+dev_lmt_setup(struct dev *dev)\n {\n+\tchar name[PLT_MEMZONE_NAMESIZE];\n+\tconst struct plt_memzone *mz;\n \tstruct idev_cfg *idev;\n \tint rc;\n \n@@ -965,8 +952,11 @@ dev_lmt_setup(struct plt_pci_device *pci_dev, struct dev *dev)\n \t/* Set common lmt region from second pf_func onwards. */\n \tif (!dev->disable_shared_lmt && idev_lmt_pffunc_get() &&\n \t    dev->pf_func != idev_lmt_pffunc_get()) {\n-\t\trc = dev_setup_shared_lmt_region(dev->mbox);\n+\t\trc = dev_setup_shared_lmt_region(dev->mbox, false, 0);\n \t\tif (!rc) {\n+\t\t\t/* On success, updating lmt base of secondary pf_funcs\n+\t\t\t * with primary pf_func's lmt base.\n+\t\t\t */\n \t\t\tdev->lmt_base = roc_idev_lmt_base_addr_get();\n \t\t\treturn rc;\n \t\t}\n@@ -975,34 +965,30 @@ dev_lmt_setup(struct plt_pci_device *pci_dev, struct dev *dev)\n \t\t\tdev->pf_func, rc);\n \t}\n \n-\tif (dev_is_vf(dev)) {\n-\t\t/* VF BAR4 should always be sufficient enough to\n-\t\t * hold LMT lines.\n-\t\t */\n-\t\tif (pci_dev->mem_resource[4].len <\n-\t\t    (RVU_LMT_LINE_MAX * RVU_LMT_SZ)) {\n-\t\t\tplt_err(\"Not enough bar4 space for lmt lines\");\n-\t\t\treturn -EFAULT;\n-\t\t}\n+\t/* Allocating memory for LMT region */\n+\tsprintf(name, \"LMT_MAP%x\", dev->pf_func);\n \n-\t\tdev->lmt_base = dev->bar4;\n-\t} else {\n-\t\tuint64_t bar4_mbox_sz = MBOX_SIZE;\n-\n-\t\t/* PF BAR4 should always be sufficient enough to\n-\t\t * hold PF-AF MBOX + PF-VF MBOX + LMT lines.\n-\t\t */\n-\t\tif (pci_dev->mem_resource[4].len <\n-\t\t    (bar4_mbox_sz + (RVU_LMT_LINE_MAX * RVU_LMT_SZ))) {\n-\t\t\tplt_err(\"Not enough bar4 space for lmt lines and mbox\");\n-\t\t\treturn -EFAULT;\n-\t\t}\n+\t/* Setting alignment to ensure correct masking for resetting to lmt base\n+\t * of a core after all lmt lines under that core are used.\n+\t * Alignment value LMT_REGION_SIZE to handle the case where all lines\n+\t * are used by 1 core.\n+\t */\n+\tmz = plt_lmt_region_reserve_aligned(name, LMT_REGION_SIZE,\n+\t\t\t\t\t    LMT_REGION_SIZE);\n+\tif (!mz) {\n+\t\tplt_err(\"Memory alloc failed: %s\", strerror(errno));\n+\t\tgoto fail;\n+\t}\n \n-\t\t/* LMT base is just after total VF MBOX area */\n-\t\tbar4_mbox_sz += (MBOX_SIZE * dev_pf_total_vfs(pci_dev));\n-\t\tdev->lmt_base = dev->bar4 + bar4_mbox_sz;\n+\t/* Share the IOVA address with Kernel */\n+\trc = dev_setup_shared_lmt_region(dev->mbox, true, mz->iova);\n+\tif (rc) {\n+\t\terrno = rc;\n+\t\tgoto free;\n \t}\n \n+\tdev->lmt_base = mz->iova;\n+\tdev->lmt_mz = mz;\n \t/* Base LMT address should be chosen from only those pci funcs which\n \t * participate in LMT shared mode.\n \t */\n@@ -1016,6 +1002,10 @@ dev_lmt_setup(struct plt_pci_device *pci_dev, struct dev *dev)\n \t}\n \n \treturn 0;\n+free:\n+\tplt_memzone_free(mz);\n+fail:\n+\treturn -errno;\n }\n \n int\n@@ -1130,7 +1120,7 @@ dev_init(struct dev *dev, struct plt_pci_device *pci_dev)\n \t\tgoto iounmap;\n \n \t/* Setup LMT line base */\n-\trc = dev_lmt_setup(pci_dev, dev);\n+\trc = dev_lmt_setup(dev);\n \tif (rc)\n \t\tgoto iounmap;\n \n@@ -1161,6 +1151,10 @@ dev_fini(struct dev *dev, struct plt_pci_device *pci_dev)\n \t/* Clear references to this pci dev */\n \tnpa_lf_fini();\n \n+\t/* Releasing memory allocated for lmt region */\n+\tif (dev->lmt_mz)\n+\t\tplt_memzone_free(dev->lmt_mz);\n+\n \tmbox_unregister_irq(pci_dev, dev);\n \n \tif (!dev_is_vf(dev))\ndiff --git a/drivers/common/cnxk/roc_dev_priv.h b/drivers/common/cnxk/roc_dev_priv.h\nindex 910cfb6..7ee604e 100644\n--- a/drivers/common/cnxk/roc_dev_priv.h\n+++ b/drivers/common/cnxk/roc_dev_priv.h\n@@ -84,6 +84,7 @@ struct dev {\n \tstruct dev_ops *ops;\n \tvoid *roc_nix;\n \tbool disable_shared_lmt; /* false(default): shared lmt mode enabled */\n+\tconst struct plt_memzone *lmt_mz;\n } __plt_cache_aligned;\n \n struct npa {\ndiff --git a/drivers/common/cnxk/roc_mbox.h b/drivers/common/cnxk/roc_mbox.h\nindex f6b11b6..9c529d7 100644\n--- a/drivers/common/cnxk/roc_mbox.h\n+++ b/drivers/common/cnxk/roc_mbox.h\n@@ -403,6 +403,9 @@ struct lmtst_tbl_setup_req {\n \tuint64_t __io dis_line_pref : 1;\n \tuint64_t __io ssow_pf_func : 13;\n \tuint16_t __io pcifunc;\n+\tuint8_t __io use_local_lmt_region;\n+\tuint64_t __io lmt_iova;\n+\tuint64_t __io rsvd[2]; /* Future use */\n };\n \n /* CGX mbox message formats */\ndiff --git a/drivers/common/cnxk/roc_platform.h b/drivers/common/cnxk/roc_platform.h\nindex 911ae15..be58625 100644\n--- a/drivers/common/cnxk/roc_platform.h\n+++ b/drivers/common/cnxk/roc_platform.h\n@@ -194,4 +194,15 @@ int roc_plt_init(void);\n typedef int (*roc_plt_init_cb_t)(void);\n int __roc_api roc_plt_init_cb_register(roc_plt_init_cb_t cb);\n \n+static inline const void *\n+plt_lmt_region_reserve_aligned(const char *name, size_t len, uint32_t align)\n+{\n+\t/* To ensure returned memory is physically contiguous, bounding\n+\t * the start and end address in 2M range.\n+\t */\n+\treturn rte_memzone_reserve_bounded(name, len, SOCKET_ID_ANY,\n+\t\t\t\t\t   RTE_MEMZONE_IOVA_CONTIG,\n+\t\t\t\t\t   align, RTE_PGSIZE_2M);\n+}\n+\n #endif /* _ROC_PLATFORM_H_ */\n",
    "prefixes": [
        "v4",
        "05/62"
    ]
}