get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 137817,
    "url": "http://patches.dpdk.org/api/patches/137817/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20240303173833.100039-4-hkalra@marvell.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": "<20240303173833.100039-4-hkalra@marvell.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20240303173833.100039-4-hkalra@marvell.com",
    "date": "2024-03-03T17:38:13",
    "name": "[v6,03/23] net/cnxk: eswitch HW resource configuration",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "416911e3321d480660f2c490dbe33cb97ed17cef",
    "submitter": {
        "id": 1182,
        "url": "http://patches.dpdk.org/api/people/1182/?format=api",
        "name": "Harman Kalra",
        "email": "hkalra@marvell.com"
    },
    "delegate": {
        "id": 310,
        "url": "http://patches.dpdk.org/api/users/310/?format=api",
        "username": "jerin",
        "first_name": "Jerin",
        "last_name": "Jacob",
        "email": "jerinj@marvell.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20240303173833.100039-4-hkalra@marvell.com/mbox/",
    "series": [
        {
            "id": 31353,
            "url": "http://patches.dpdk.org/api/series/31353/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=31353",
            "date": "2024-03-03T17:38:10",
            "name": "net/cnxk: support for port representors",
            "version": 6,
            "mbox": "http://patches.dpdk.org/series/31353/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/137817/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/137817/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 AE25943C3E;\n\tSun,  3 Mar 2024 18:39:05 +0100 (CET)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 593A443603;\n\tSun,  3 Mar 2024 18:38:51 +0100 (CET)",
            "from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com\n [67.231.148.174])\n by mails.dpdk.org (Postfix) with ESMTP id 5AF6643603\n for <dev@dpdk.org>; Sun,  3 Mar 2024 18:38:49 +0100 (CET)",
            "from pps.filterd (m0045849.ppops.net [127.0.0.1])\n by mx0a-0016f401.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id\n 423GWjXG019709 for <dev@dpdk.org>; Sun, 3 Mar 2024 09:38:48 -0800",
            "from dc6wp-exch02.marvell.com ([4.21.29.225])\n by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3wm2bptrsj-1\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT)\n for <dev@dpdk.org>; Sun, 03 Mar 2024 09:38:48 -0800 (PST)",
            "from DC6WP-EXCH02.marvell.com (10.76.176.209) by\n DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server\n (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id\n 15.2.1258.12; Sun, 3 Mar 2024 09:38:47 -0800",
            "from maili.marvell.com (10.69.176.80) by DC6WP-EXCH02.marvell.com\n (10.76.176.209) with Microsoft SMTP Server id 15.2.1258.12 via Frontend\n Transport; Sun, 3 Mar 2024 09:38:47 -0800",
            "from localhost.localdomain (unknown [10.29.52.211])\n by maili.marvell.com (Postfix) with ESMTP id B10CB3F718E;\n Sun,  3 Mar 2024 09:38:44 -0800 (PST)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=\n from:to:cc:subject:date:message-id:in-reply-to:references\n :mime-version:content-type; s=pfpt0220; bh=NiJDiXOcGiWMssIXP1hyX\n +tV6hiJGPvOeUnxxbI9dW4=; b=FLrI1AI+xW9tVfR1fJri6h7BwPZz3ZTxMgBRp\n qzvH2XSY0bXBNsNzFej0Jd1gZARSdnFCGpnCBmlL2ag8OxnPiNdwhKnh5idHLJ1y\n IOMnHabNMx1zmGd1tup3hlgmXDa7Gp/wCfIFkv9TWp7W/h3odDMb5SzsKs6DsGmz\n rC2Z+j9WkoHt3Eky3pdAX1qCKn49hkG/Xe0a1xvtlVY+UarjHmPpIV9aM+mB0Y3q\n eTHu2XpeARYtR3fKEZRwRrz/1seGiUHEOsOUqWHkRMiv4gz1wuTFgUY8PN5ovLi2\n GvaTdk6K5xzYJm1Vnfy2feRYlz/ffnhMi2tIPue/yCDBOu3hQ==",
        "From": "Harman Kalra <hkalra@marvell.com>",
        "To": "Nithin Dabilpuram <ndabilpuram@marvell.com>, Kiran Kumar K\n <kirankumark@marvell.com>, Sunil Kumar Kori <skori@marvell.com>, Satha Rao\n <skoteshwar@marvell.com>, Harman Kalra <hkalra@marvell.com>",
        "CC": "<dev@dpdk.org>",
        "Subject": "[PATCH v6 03/23] net/cnxk: eswitch HW resource configuration",
        "Date": "Sun, 3 Mar 2024 23:08:13 +0530",
        "Message-ID": "<20240303173833.100039-4-hkalra@marvell.com>",
        "X-Mailer": "git-send-email 2.18.0",
        "In-Reply-To": "<20240303173833.100039-1-hkalra@marvell.com>",
        "References": "<20230811163419.165790-1-hkalra@marvell.com>\n <20240303173833.100039-1-hkalra@marvell.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain",
        "X-Proofpoint-GUID": "cyzk3H9vTbygw5Ba9G5b_ZtI2PxrDiVa",
        "X-Proofpoint-ORIG-GUID": "cyzk3H9vTbygw5Ba9G5b_ZtI2PxrDiVa",
        "X-Proofpoint-Virus-Version": "vendor=baseguard\n engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26\n definitions=2024-03-03_08,2024-03-01_03,2023-05-22_02",
        "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"
    },
    "content": "Configuring the hardware resources used by the eswitch device.\n\nSigned-off-by: Harman Kalra <hkalra@marvell.com>\n---\n drivers/net/cnxk/cnxk_eswitch.c | 217 +++++++++++++++++++++++++++++++-\n 1 file changed, 216 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/drivers/net/cnxk/cnxk_eswitch.c b/drivers/net/cnxk/cnxk_eswitch.c\nindex 8f216d7c88..810e7c9c25 100644\n--- a/drivers/net/cnxk/cnxk_eswitch.c\n+++ b/drivers/net/cnxk/cnxk_eswitch.c\n@@ -6,13 +6,53 @@\n \n #define CNXK_NIX_DEF_SQ_COUNT 512\n \n+static int\n+eswitch_hw_rsrc_cleanup(struct cnxk_eswitch_dev *eswitch_dev, struct rte_pci_device *pci_dev)\n+{\n+\tstruct roc_nix *nix;\n+\tint rc = 0;\n+\n+\tnix = &eswitch_dev->nix;\n+\n+\troc_nix_unregister_queue_irqs(nix);\n+\troc_nix_tm_fini(nix);\n+\trc = roc_nix_lf_free(nix);\n+\tif (rc) {\n+\t\tplt_err(\"Failed to cleanup sq, rc %d\", rc);\n+\t\tgoto exit;\n+\t}\n+\n+\t/* Check if this device is hosting common resource */\n+\tnix = roc_idev_npa_nix_get();\n+\tif (!nix || nix->pci_dev != pci_dev) {\n+\t\trc = 0;\n+\t\tgoto exit;\n+\t}\n+\n+\t/* Try nix fini now */\n+\trc = roc_nix_dev_fini(nix);\n+\tif (rc == -EAGAIN) {\n+\t\tplt_info(\"Common resource in use by other devices %s\", pci_dev->name);\n+\t\tgoto exit;\n+\t} else if (rc) {\n+\t\tplt_err(\"Failed in nix dev fini, rc=%d\", rc);\n+\t\tgoto exit;\n+\t}\n+\n+\trte_free(eswitch_dev->txq);\n+\trte_free(eswitch_dev->rxq);\n+\trte_free(eswitch_dev->cxq);\n+\n+exit:\n+\treturn rc;\n+}\n+\n static int\n cnxk_eswitch_dev_remove(struct rte_pci_device *pci_dev)\n {\n \tstruct cnxk_eswitch_dev *eswitch_dev;\n \tint rc = 0;\n \n-\tPLT_SET_USED(pci_dev);\n \tif (rte_eal_process_type() != RTE_PROC_PRIMARY)\n \t\treturn 0;\n \n@@ -22,6 +62,9 @@ cnxk_eswitch_dev_remove(struct rte_pci_device *pci_dev)\n \t\tgoto exit;\n \t}\n \n+\t/* Cleanup HW resources */\n+\teswitch_hw_rsrc_cleanup(eswitch_dev, pci_dev);\n+\n \trte_free(eswitch_dev);\n exit:\n \treturn rc;\n@@ -318,6 +361,170 @@ cnxk_eswitch_txq_setup(struct cnxk_eswitch_dev *eswitch_dev, uint16_t qid, uint1\n \treturn rc;\n }\n \n+static int\n+nix_lf_setup(struct cnxk_eswitch_dev *eswitch_dev)\n+{\n+\tuint16_t nb_rxq, nb_txq, nb_cq;\n+\tstruct roc_nix_fc_cfg fc_cfg;\n+\tstruct roc_nix *nix;\n+\tuint64_t rx_cfg;\n+\tvoid *qs;\n+\tint rc;\n+\n+\t/* Initialize base roc nix */\n+\tnix = &eswitch_dev->nix;\n+\tnix->pci_dev = eswitch_dev->pci_dev;\n+\tnix->hw_vlan_ins = true;\n+\tnix->reta_sz = ROC_NIX_RSS_RETA_SZ_256;\n+\trc = roc_nix_dev_init(nix);\n+\tif (rc) {\n+\t\tplt_err(\"Failed to init nix eswitch device, rc=%d(%s)\", rc, roc_error_msg_get(rc));\n+\t\tgoto fail;\n+\t}\n+\n+\t/* Get the representors count */\n+\trc = roc_nix_max_rep_count(&eswitch_dev->nix);\n+\tif (rc) {\n+\t\tplt_err(\"Failed to get rep cnt, rc=%d(%s)\", rc, roc_error_msg_get(rc));\n+\t\tgoto free_cqs;\n+\t}\n+\n+\t/* Allocating an NIX LF */\n+\tnb_rxq = CNXK_ESWITCH_MAX_RXQ;\n+\tnb_txq = CNXK_ESWITCH_MAX_TXQ;\n+\tnb_cq = CNXK_ESWITCH_MAX_RXQ;\n+\trx_cfg = ROC_NIX_LF_RX_CFG_DIS_APAD;\n+\trc = roc_nix_lf_alloc(nix, nb_rxq, nb_txq, rx_cfg);\n+\tif (rc) {\n+\t\tplt_err(\"lf alloc failed = %s(%d)\", roc_error_msg_get(rc), rc);\n+\t\tgoto dev_fini;\n+\t}\n+\n+\tif (nb_rxq) {\n+\t\t/* Allocate memory for eswitch rq's and cq's */\n+\t\tqs = plt_zmalloc(sizeof(struct cnxk_eswitch_rxq) * nb_rxq, 0);\n+\t\tif (!qs) {\n+\t\t\tplt_err(\"Failed to alloc eswitch rxq\");\n+\t\t\tgoto lf_free;\n+\t\t}\n+\t\teswitch_dev->rxq = qs;\n+\t}\n+\n+\tif (nb_txq) {\n+\t\t/* Allocate memory for roc sq's */\n+\t\tqs = plt_zmalloc(sizeof(struct cnxk_eswitch_txq) * nb_txq, 0);\n+\t\tif (!qs) {\n+\t\t\tplt_err(\"Failed to alloc eswitch txq\");\n+\t\t\tgoto free_rqs;\n+\t\t}\n+\t\teswitch_dev->txq = qs;\n+\t}\n+\n+\tif (nb_cq) {\n+\t\tqs = plt_zmalloc(sizeof(struct cnxk_eswitch_cxq) * nb_cq, 0);\n+\t\tif (!qs) {\n+\t\t\tplt_err(\"Failed to alloc eswitch cxq\");\n+\t\t\tgoto free_sqs;\n+\t\t}\n+\t\teswitch_dev->cxq = qs;\n+\t}\n+\n+\teswitch_dev->nb_rxq = nb_rxq;\n+\teswitch_dev->nb_txq = nb_txq;\n+\n+\t/* Re-enable NIX LF error interrupts */\n+\troc_nix_err_intr_ena_dis(nix, true);\n+\troc_nix_ras_intr_ena_dis(nix, true);\n+\n+\trc = roc_nix_lso_fmt_setup(nix);\n+\tif (rc) {\n+\t\tplt_err(\"lso setup failed = %s(%d)\", roc_error_msg_get(rc), rc);\n+\t\tgoto free_cqs;\n+\t}\n+\n+\trc = roc_nix_switch_hdr_set(nix, 0, 0, 0, 0);\n+\tif (rc) {\n+\t\tplt_err(\"switch hdr set failed = %s(%d)\", roc_error_msg_get(rc), rc);\n+\t\tgoto free_cqs;\n+\t}\n+\n+\trc = roc_nix_tm_init(nix);\n+\tif (rc) {\n+\t\tplt_err(\"tm failed = %s(%d)\", roc_error_msg_get(rc), rc);\n+\t\tgoto free_cqs;\n+\t}\n+\n+\t/* Register queue IRQs */\n+\trc = roc_nix_register_queue_irqs(nix);\n+\tif (rc) {\n+\t\tplt_err(\"Failed to register queue interrupts rc=%d\", rc);\n+\t\tgoto tm_fini;\n+\t}\n+\n+\t/* Enable default tree */\n+\trc = roc_nix_tm_hierarchy_enable(nix, ROC_NIX_TM_DEFAULT, false);\n+\tif (rc) {\n+\t\tplt_err(\"tm default hierarchy enable failed = %s(%d)\", roc_error_msg_get(rc), rc);\n+\t\tgoto q_irq_fini;\n+\t}\n+\n+\tmemset(&fc_cfg, 0, sizeof(struct roc_nix_fc_cfg));\n+\tfc_cfg.rxchan_cfg.enable = false;\n+\trc = roc_nix_fc_config_set(nix, &fc_cfg);\n+\tif (rc) {\n+\t\tplt_err(\"Failed to setup flow control, rc=%d(%s)\", rc, roc_error_msg_get(rc));\n+\t\tgoto q_irq_fini;\n+\t}\n+\n+\troc_nix_fc_mode_get(nix);\n+\n+\treturn rc;\n+q_irq_fini:\n+\troc_nix_unregister_queue_irqs(nix);\n+tm_fini:\n+\troc_nix_tm_fini(nix);\n+free_cqs:\n+\trte_free(eswitch_dev->cxq);\n+free_sqs:\n+\trte_free(eswitch_dev->txq);\n+free_rqs:\n+\trte_free(eswitch_dev->rxq);\n+lf_free:\n+\troc_nix_lf_free(nix);\n+dev_fini:\n+\troc_nix_dev_fini(nix);\n+fail:\n+\treturn rc;\n+}\n+\n+static int\n+eswitch_hw_rsrc_setup(struct cnxk_eswitch_dev *eswitch_dev, struct rte_pci_device *pci_dev)\n+{\n+\tstruct roc_nix *nix;\n+\tint rc;\n+\n+\tnix = &eswitch_dev->nix;\n+\trc = nix_lf_setup(eswitch_dev);\n+\tif (rc) {\n+\t\tplt_err(\"Failed to setup hw rsrc, rc=%d(%s)\", rc, roc_error_msg_get(rc));\n+\t\tgoto fail;\n+\t}\n+\n+\t/* Initialize roc npc */\n+\teswitch_dev->npc.roc_nix = nix;\n+\teswitch_dev->npc.flow_max_priority = 3;\n+\teswitch_dev->npc.flow_prealloc_size = 1;\n+\trc = roc_npc_init(&eswitch_dev->npc);\n+\tif (rc)\n+\t\tgoto rsrc_cleanup;\n+\n+\treturn rc;\n+rsrc_cleanup:\n+\teswitch_hw_rsrc_cleanup(eswitch_dev, pci_dev);\n+fail:\n+\treturn rc;\n+}\n+\n static int\n cnxk_eswitch_dev_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)\n {\n@@ -347,6 +554,12 @@ cnxk_eswitch_dev_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pc\n \n \t\teswitch_dev = mz->addr;\n \t\teswitch_dev->pci_dev = pci_dev;\n+\n+\t\trc = eswitch_hw_rsrc_setup(eswitch_dev, pci_dev);\n+\t\tif (rc) {\n+\t\t\tplt_err(\"Failed to setup hw rsrc, rc=%d(%s)\", rc, roc_error_msg_get(rc));\n+\t\t\tgoto free_mem;\n+\t\t}\n \t}\n \n \t/* Spinlock for synchronization between representors traffic and control\n@@ -355,6 +568,8 @@ cnxk_eswitch_dev_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pc\n \trte_spinlock_init(&eswitch_dev->rep_lock);\n \n \treturn rc;\n+free_mem:\n+\trte_memzone_free(mz);\n fail:\n \treturn rc;\n }\n",
    "prefixes": [
        "v6",
        "03/23"
    ]
}