get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 89281,
    "url": "http://patches.dpdk.org/api/patches/89281/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20210316221857.2254-5-timothy.mcdaniel@intel.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": "<20210316221857.2254-5-timothy.mcdaniel@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20210316221857.2254-5-timothy.mcdaniel@intel.com",
    "date": "2021-03-16T22:18:36",
    "name": "[04/25] event/dlb2: add DLB v2.5 support to create sched domain",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "aba0d4f373b0105388608b7903957e08bd5272f6",
    "submitter": {
        "id": 826,
        "url": "http://patches.dpdk.org/api/people/826/?format=api",
        "name": "Timothy McDaniel",
        "email": "timothy.mcdaniel@intel.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/20210316221857.2254-5-timothy.mcdaniel@intel.com/mbox/",
    "series": [
        {
            "id": 15709,
            "url": "http://patches.dpdk.org/api/series/15709/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=15709",
            "date": "2021-03-16T22:18:32",
            "name": "Add Support for DLB v2.5",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/15709/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/89281/comments/",
    "check": "warning",
    "checks": "http://patches.dpdk.org/api/patches/89281/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 EF56DA054F;\n\tTue, 16 Mar 2021 23:20:19 +0100 (CET)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 7A700242A8C;\n\tTue, 16 Mar 2021 23:19:53 +0100 (CET)",
            "from mga07.intel.com (mga07.intel.com [134.134.136.100])\n by mails.dpdk.org (Postfix) with ESMTP id 0D339242A59\n for <dev@dpdk.org>; Tue, 16 Mar 2021 23:19:48 +0100 (CET)",
            "from fmsmga005.fm.intel.com ([10.253.24.32])\n by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 16 Mar 2021 15:19:48 -0700",
            "from txasoft-yocto.an.intel.com ([10.123.72.192])\n by fmsmga005.fm.intel.com with ESMTP; 16 Mar 2021 15:19:47 -0700"
        ],
        "IronPort-SDR": [
            "\n p19ubf3S4BdySiwrYYaLx1CiKXwSN8KfXY2VncNyrpt6YmesjriSSGFJZrfE6KhQ+GAgPSvT6H\n vYVUR7aefg3Q==",
            "\n V8NnbeXar1P2l2wChdVtk1mDrOQQMsmvaLLafME1He1CWMsOQ6rmkVVn3Dj61WrSbtjH0cLx+e\n CYjqLpGAHrvQ=="
        ],
        "X-IronPort-AV": [
            "E=McAfee;i=\"6000,8403,9925\"; a=\"253359223\"",
            "E=Sophos;i=\"5.81,254,1610438400\"; d=\"scan'208\";a=\"253359223\"",
            "E=Sophos;i=\"5.81,254,1610438400\"; d=\"scan'208\";a=\"605440200\""
        ],
        "X-ExtLoop1": "1",
        "From": "Timothy McDaniel <timothy.mcdaniel@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "jerinj@marvell.com, harry.van.haaren@intel.com, mdr@ashroe.eu,\n nhorman@tuxdriver.com, nikhil.rao@intel.com, erik.g.carrillo@intel.com,\n abhinandan.gujjar@intel.com, pbhagavatula@marvell.com,\n hemant.agrawal@nxp.com, mattias.ronnblom@ericsson.com,\n peter.mccarthy@intel.com",
        "Date": "Tue, 16 Mar 2021 17:18:36 -0500",
        "Message-Id": "<20210316221857.2254-5-timothy.mcdaniel@intel.com>",
        "X-Mailer": "git-send-email 2.23.0",
        "In-Reply-To": "<20210316221857.2254-1-timothy.mcdaniel@intel.com>",
        "References": "<20210316221857.2254-1-timothy.mcdaniel@intel.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[dpdk-dev] [PATCH 04/25] event/dlb2: add DLB v2.5 support to create\n sched domain",
        "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": "Update domain creation logic to account for DLB v2.5\ncredit scheme, new register map, and new register access\nmacros.\n\nSigned-off-by: Timothy McDaniel <timothy.mcdaniel@intel.com>\n---\n drivers/event/dlb2/dlb2_user.h                |  13 +-\n drivers/event/dlb2/pf/base/dlb2_resource.c    | 645 ----------------\n .../event/dlb2/pf/base/dlb2_resource_new.c    | 696 ++++++++++++++++++\n 3 files changed, 707 insertions(+), 647 deletions(-)",
    "diff": "diff --git a/drivers/event/dlb2/dlb2_user.h b/drivers/event/dlb2/dlb2_user.h\nindex b7d125dec..9760e9bda 100644\n--- a/drivers/event/dlb2/dlb2_user.h\n+++ b/drivers/event/dlb2/dlb2_user.h\n@@ -18,6 +18,7 @@ enum dlb2_error {\n \tDLB2_ST_LDB_QUEUES_UNAVAILABLE,\n \tDLB2_ST_LDB_CREDITS_UNAVAILABLE,\n \tDLB2_ST_DIR_CREDITS_UNAVAILABLE,\n+\tDLB2_ST_CREDITS_UNAVAILABLE,\n \tDLB2_ST_SEQUENCE_NUMBERS_UNAVAILABLE,\n \tDLB2_ST_INVALID_DOMAIN_ID,\n \tDLB2_ST_INVALID_QID_INFLIGHT_ALLOCATION,\n@@ -57,6 +58,7 @@ static const char dlb2_error_strings[][128] = {\n \t\"DLB2_ST_LDB_QUEUES_UNAVAILABLE\",\n \t\"DLB2_ST_LDB_CREDITS_UNAVAILABLE\",\n \t\"DLB2_ST_DIR_CREDITS_UNAVAILABLE\",\n+\t\"DLB2_ST_CREDITS_UNAVAILABLE\",\n \t\"DLB2_ST_SEQUENCE_NUMBERS_UNAVAILABLE\",\n \t\"DLB2_ST_INVALID_DOMAIN_ID\",\n \t\"DLB2_ST_INVALID_QID_INFLIGHT_ALLOCATION\",\n@@ -170,8 +172,15 @@ struct dlb2_create_sched_domain_args {\n \t__u32 num_dir_ports;\n \t__u32 num_atomic_inflights;\n \t__u32 num_hist_list_entries;\n-\t__u32 num_ldb_credits;\n-\t__u32 num_dir_credits;\n+\tunion {\n+\t\tstruct {\n+\t\t\t__u32 num_ldb_credits;\n+\t\t\t__u32 num_dir_credits;\n+\t\t};\n+\t\tstruct {\n+\t\t\t__u32 num_credits;\n+\t\t};\n+\t};\n \t__u8 cos_strict;\n \t__u8 padding1[3];\n };\ndiff --git a/drivers/event/dlb2/pf/base/dlb2_resource.c b/drivers/event/dlb2/pf/base/dlb2_resource.c\nindex 5b8723aaf..5d296f725 100644\n--- a/drivers/event/dlb2/pf/base/dlb2_resource.c\n+++ b/drivers/event/dlb2/pf/base/dlb2_resource.c\n@@ -33,21 +33,6 @@\n #define DLB2_FUNC_LIST_FOR_SAFE(head, ptr, ptr_tmp, it, it_tmp) \\\n \tDLB2_LIST_FOR_EACH_SAFE((head), ptr, ptr_tmp, func_list, it, it_tmp)\n \n-static void dlb2_init_domain_rsrc_lists(struct dlb2_hw_domain *domain)\n-{\n-\tint i;\n-\n-\tdlb2_list_init_head(&domain->used_ldb_queues);\n-\tdlb2_list_init_head(&domain->used_dir_pq_pairs);\n-\tdlb2_list_init_head(&domain->avail_ldb_queues);\n-\tdlb2_list_init_head(&domain->avail_dir_pq_pairs);\n-\n-\tfor (i = 0; i < DLB2_NUM_COS_DOMAINS; i++)\n-\t\tdlb2_list_init_head(&domain->used_ldb_ports[i]);\n-\tfor (i = 0; i < DLB2_NUM_COS_DOMAINS; i++)\n-\t\tdlb2_list_init_head(&domain->avail_ldb_ports[i]);\n-}\n-\n void dlb2_hw_enable_sparse_dir_cq_mode(struct dlb2_hw *hw)\n {\n \tunion dlb2_chp_cfg_chp_csr_ctrl r0;\n@@ -70,636 +55,6 @@ void dlb2_hw_enable_sparse_ldb_cq_mode(struct dlb2_hw *hw)\n \tDLB2_CSR_WR(hw, DLB2_CHP_CFG_CHP_CSR_CTRL, r0.val);\n }\n \n-static void dlb2_configure_domain_credits(struct dlb2_hw *hw,\n-\t\t\t\t\t  struct dlb2_hw_domain *domain)\n-{\n-\tunion dlb2_chp_cfg_ldb_vas_crd r0 = { {0} };\n-\tunion dlb2_chp_cfg_dir_vas_crd r1 = { {0} };\n-\n-\tr0.field.count = domain->num_ldb_credits;\n-\n-\tDLB2_CSR_WR(hw, DLB2_CHP_CFG_LDB_VAS_CRD(domain->id.phys_id), r0.val);\n-\n-\tr1.field.count = domain->num_dir_credits;\n-\n-\tDLB2_CSR_WR(hw, DLB2_CHP_CFG_DIR_VAS_CRD(domain->id.phys_id), r1.val);\n-}\n-\n-static struct dlb2_ldb_port *\n-dlb2_get_next_ldb_port(struct dlb2_hw *hw,\n-\t\t       struct dlb2_function_resources *rsrcs,\n-\t\t       u32 domain_id,\n-\t\t       u32 cos_id)\n-{\n-\tstruct dlb2_list_entry *iter;\n-\tstruct dlb2_ldb_port *port;\n-\tRTE_SET_USED(iter);\n-\t/*\n-\t * To reduce the odds of consecutive load-balanced ports mapping to the\n-\t * same queue(s), the driver attempts to allocate ports whose neighbors\n-\t * are owned by a different domain.\n-\t */\n-\tDLB2_FUNC_LIST_FOR(rsrcs->avail_ldb_ports[cos_id], port, iter) {\n-\t\tu32 next, prev;\n-\t\tu32 phys_id;\n-\n-\t\tphys_id = port->id.phys_id;\n-\t\tnext = phys_id + 1;\n-\t\tprev = phys_id - 1;\n-\n-\t\tif (phys_id == DLB2_MAX_NUM_LDB_PORTS - 1)\n-\t\t\tnext = 0;\n-\t\tif (phys_id == 0)\n-\t\t\tprev = DLB2_MAX_NUM_LDB_PORTS - 1;\n-\n-\t\tif (!hw->rsrcs.ldb_ports[next].owned ||\n-\t\t    hw->rsrcs.ldb_ports[next].domain_id.phys_id == domain_id)\n-\t\t\tcontinue;\n-\n-\t\tif (!hw->rsrcs.ldb_ports[prev].owned ||\n-\t\t    hw->rsrcs.ldb_ports[prev].domain_id.phys_id == domain_id)\n-\t\t\tcontinue;\n-\n-\t\treturn port;\n-\t}\n-\n-\t/*\n-\t * Failing that, the driver looks for a port with one neighbor owned by\n-\t * a different domain and the other unallocated.\n-\t */\n-\tDLB2_FUNC_LIST_FOR(rsrcs->avail_ldb_ports[cos_id], port, iter) {\n-\t\tu32 next, prev;\n-\t\tu32 phys_id;\n-\n-\t\tphys_id = port->id.phys_id;\n-\t\tnext = phys_id + 1;\n-\t\tprev = phys_id - 1;\n-\n-\t\tif (phys_id == DLB2_MAX_NUM_LDB_PORTS - 1)\n-\t\t\tnext = 0;\n-\t\tif (phys_id == 0)\n-\t\t\tprev = DLB2_MAX_NUM_LDB_PORTS - 1;\n-\n-\t\tif (!hw->rsrcs.ldb_ports[prev].owned &&\n-\t\t    hw->rsrcs.ldb_ports[next].owned &&\n-\t\t    hw->rsrcs.ldb_ports[next].domain_id.phys_id != domain_id)\n-\t\t\treturn port;\n-\n-\t\tif (!hw->rsrcs.ldb_ports[next].owned &&\n-\t\t    hw->rsrcs.ldb_ports[prev].owned &&\n-\t\t    hw->rsrcs.ldb_ports[prev].domain_id.phys_id != domain_id)\n-\t\t\treturn port;\n-\t}\n-\n-\t/*\n-\t * Failing that, the driver looks for a port with both neighbors\n-\t * unallocated.\n-\t */\n-\tDLB2_FUNC_LIST_FOR(rsrcs->avail_ldb_ports[cos_id], port, iter) {\n-\t\tu32 next, prev;\n-\t\tu32 phys_id;\n-\n-\t\tphys_id = port->id.phys_id;\n-\t\tnext = phys_id + 1;\n-\t\tprev = phys_id - 1;\n-\n-\t\tif (phys_id == DLB2_MAX_NUM_LDB_PORTS - 1)\n-\t\t\tnext = 0;\n-\t\tif (phys_id == 0)\n-\t\t\tprev = DLB2_MAX_NUM_LDB_PORTS - 1;\n-\n-\t\tif (!hw->rsrcs.ldb_ports[prev].owned &&\n-\t\t    !hw->rsrcs.ldb_ports[next].owned)\n-\t\t\treturn port;\n-\t}\n-\n-\t/* If all else fails, the driver returns the next available port. */\n-\treturn DLB2_FUNC_LIST_HEAD(rsrcs->avail_ldb_ports[cos_id],\n-\t\t\t\t   typeof(*port));\n-}\n-\n-static int __dlb2_attach_ldb_ports(struct dlb2_hw *hw,\n-\t\t\t\t   struct dlb2_function_resources *rsrcs,\n-\t\t\t\t   struct dlb2_hw_domain *domain,\n-\t\t\t\t   u32 num_ports,\n-\t\t\t\t   u32 cos_id,\n-\t\t\t\t   struct dlb2_cmd_response *resp)\n-{\n-\tunsigned int i;\n-\n-\tif (rsrcs->num_avail_ldb_ports[cos_id] < num_ports) {\n-\t\tresp->status = DLB2_ST_LDB_PORTS_UNAVAILABLE;\n-\t\treturn -EINVAL;\n-\t}\n-\n-\tfor (i = 0; i < num_ports; i++) {\n-\t\tstruct dlb2_ldb_port *port;\n-\n-\t\tport = dlb2_get_next_ldb_port(hw, rsrcs,\n-\t\t\t\t\t      domain->id.phys_id, cos_id);\n-\t\tif (port == NULL) {\n-\t\t\tDLB2_HW_ERR(hw,\n-\t\t\t\t    \"[%s()] Internal error: domain validation failed\\n\",\n-\t\t\t\t    __func__);\n-\t\t\treturn -EFAULT;\n-\t\t}\n-\n-\t\tdlb2_list_del(&rsrcs->avail_ldb_ports[cos_id],\n-\t\t\t      &port->func_list);\n-\n-\t\tport->domain_id = domain->id;\n-\t\tport->owned = true;\n-\n-\t\tdlb2_list_add(&domain->avail_ldb_ports[cos_id],\n-\t\t\t      &port->domain_list);\n-\t}\n-\n-\trsrcs->num_avail_ldb_ports[cos_id] -= num_ports;\n-\n-\treturn 0;\n-}\n-\n-static int dlb2_attach_ldb_ports(struct dlb2_hw *hw,\n-\t\t\t\t struct dlb2_function_resources *rsrcs,\n-\t\t\t\t struct dlb2_hw_domain *domain,\n-\t\t\t\t struct dlb2_create_sched_domain_args *args,\n-\t\t\t\t struct dlb2_cmd_response *resp)\n-{\n-\tunsigned int i, j;\n-\tint ret;\n-\n-\tif (args->cos_strict) {\n-\t\tfor (i = 0; i < DLB2_NUM_COS_DOMAINS; i++) {\n-\t\t\tu32 num = args->num_cos_ldb_ports[i];\n-\n-\t\t\t/* Allocate ports from specific classes-of-service */\n-\t\t\tret = __dlb2_attach_ldb_ports(hw,\n-\t\t\t\t\t\t      rsrcs,\n-\t\t\t\t\t\t      domain,\n-\t\t\t\t\t\t      num,\n-\t\t\t\t\t\t      i,\n-\t\t\t\t\t\t      resp);\n-\t\t\tif (ret)\n-\t\t\t\treturn ret;\n-\t\t}\n-\t} else {\n-\t\tunsigned int k;\n-\t\tu32 cos_id;\n-\n-\t\t/*\n-\t\t * Attempt to allocate from specific class-of-service, but\n-\t\t * fallback to the other classes if that fails.\n-\t\t */\n-\t\tfor (i = 0; i < DLB2_NUM_COS_DOMAINS; i++) {\n-\t\t\tfor (j = 0; j < args->num_cos_ldb_ports[i]; j++) {\n-\t\t\t\tfor (k = 0; k < DLB2_NUM_COS_DOMAINS; k++) {\n-\t\t\t\t\tcos_id = (i + k) % DLB2_NUM_COS_DOMAINS;\n-\n-\t\t\t\t\tret = __dlb2_attach_ldb_ports(hw,\n-\t\t\t\t\t\t\t\t      rsrcs,\n-\t\t\t\t\t\t\t\t      domain,\n-\t\t\t\t\t\t\t\t      1,\n-\t\t\t\t\t\t\t\t      cos_id,\n-\t\t\t\t\t\t\t\t      resp);\n-\t\t\t\t\tif (ret == 0)\n-\t\t\t\t\t\tbreak;\n-\t\t\t\t}\n-\n-\t\t\t\tif (ret < 0)\n-\t\t\t\t\treturn ret;\n-\t\t\t}\n-\t\t}\n-\t}\n-\n-\t/* Allocate num_ldb_ports from any class-of-service */\n-\tfor (i = 0; i < args->num_ldb_ports; i++) {\n-\t\tfor (j = 0; j < DLB2_NUM_COS_DOMAINS; j++) {\n-\t\t\tret = __dlb2_attach_ldb_ports(hw,\n-\t\t\t\t\t\t      rsrcs,\n-\t\t\t\t\t\t      domain,\n-\t\t\t\t\t\t      1,\n-\t\t\t\t\t\t      j,\n-\t\t\t\t\t\t      resp);\n-\t\t\tif (ret == 0)\n-\t\t\t\tbreak;\n-\t\t}\n-\n-\t\tif (ret < 0)\n-\t\t\treturn ret;\n-\t}\n-\n-\treturn 0;\n-}\n-\n-static int dlb2_attach_dir_ports(struct dlb2_hw *hw,\n-\t\t\t\t struct dlb2_function_resources *rsrcs,\n-\t\t\t\t struct dlb2_hw_domain *domain,\n-\t\t\t\t u32 num_ports,\n-\t\t\t\t struct dlb2_cmd_response *resp)\n-{\n-\tunsigned int i;\n-\n-\tif (rsrcs->num_avail_dir_pq_pairs < num_ports) {\n-\t\tresp->status = DLB2_ST_DIR_PORTS_UNAVAILABLE;\n-\t\treturn -EINVAL;\n-\t}\n-\n-\tfor (i = 0; i < num_ports; i++) {\n-\t\tstruct dlb2_dir_pq_pair *port;\n-\n-\t\tport = DLB2_FUNC_LIST_HEAD(rsrcs->avail_dir_pq_pairs,\n-\t\t\t\t\t   typeof(*port));\n-\t\tif (port == NULL) {\n-\t\t\tDLB2_HW_ERR(hw,\n-\t\t\t\t    \"[%s()] Internal error: domain validation failed\\n\",\n-\t\t\t\t    __func__);\n-\t\t\treturn -EFAULT;\n-\t\t}\n-\n-\t\tdlb2_list_del(&rsrcs->avail_dir_pq_pairs, &port->func_list);\n-\n-\t\tport->domain_id = domain->id;\n-\t\tport->owned = true;\n-\n-\t\tdlb2_list_add(&domain->avail_dir_pq_pairs, &port->domain_list);\n-\t}\n-\n-\trsrcs->num_avail_dir_pq_pairs -= num_ports;\n-\n-\treturn 0;\n-}\n-\n-static int dlb2_attach_ldb_credits(struct dlb2_function_resources *rsrcs,\n-\t\t\t\t   struct dlb2_hw_domain *domain,\n-\t\t\t\t   u32 num_credits,\n-\t\t\t\t   struct dlb2_cmd_response *resp)\n-{\n-\tif (rsrcs->num_avail_qed_entries < num_credits) {\n-\t\tresp->status = DLB2_ST_LDB_CREDITS_UNAVAILABLE;\n-\t\treturn -EINVAL;\n-\t}\n-\n-\trsrcs->num_avail_qed_entries -= num_credits;\n-\tdomain->num_ldb_credits += num_credits;\n-\treturn 0;\n-}\n-\n-static int dlb2_attach_dir_credits(struct dlb2_function_resources *rsrcs,\n-\t\t\t\t   struct dlb2_hw_domain *domain,\n-\t\t\t\t   u32 num_credits,\n-\t\t\t\t   struct dlb2_cmd_response *resp)\n-{\n-\tif (rsrcs->num_avail_dqed_entries < num_credits) {\n-\t\tresp->status = DLB2_ST_DIR_CREDITS_UNAVAILABLE;\n-\t\treturn -EINVAL;\n-\t}\n-\n-\trsrcs->num_avail_dqed_entries -= num_credits;\n-\tdomain->num_dir_credits += num_credits;\n-\treturn 0;\n-}\n-\n-static int dlb2_attach_atomic_inflights(struct dlb2_function_resources *rsrcs,\n-\t\t\t\t\tstruct dlb2_hw_domain *domain,\n-\t\t\t\t\tu32 num_atomic_inflights,\n-\t\t\t\t\tstruct dlb2_cmd_response *resp)\n-{\n-\tif (rsrcs->num_avail_aqed_entries < num_atomic_inflights) {\n-\t\tresp->status = DLB2_ST_ATOMIC_INFLIGHTS_UNAVAILABLE;\n-\t\treturn -EINVAL;\n-\t}\n-\n-\trsrcs->num_avail_aqed_entries -= num_atomic_inflights;\n-\tdomain->num_avail_aqed_entries += num_atomic_inflights;\n-\treturn 0;\n-}\n-\n-static int\n-dlb2_attach_domain_hist_list_entries(struct dlb2_function_resources *rsrcs,\n-\t\t\t\t     struct dlb2_hw_domain *domain,\n-\t\t\t\t     u32 num_hist_list_entries,\n-\t\t\t\t     struct dlb2_cmd_response *resp)\n-{\n-\tstruct dlb2_bitmap *bitmap;\n-\tint base;\n-\n-\tif (num_hist_list_entries) {\n-\t\tbitmap = rsrcs->avail_hist_list_entries;\n-\n-\t\tbase = dlb2_bitmap_find_set_bit_range(bitmap,\n-\t\t\t\t\t\t      num_hist_list_entries);\n-\t\tif (base < 0)\n-\t\t\tgoto error;\n-\n-\t\tdomain->total_hist_list_entries = num_hist_list_entries;\n-\t\tdomain->avail_hist_list_entries = num_hist_list_entries;\n-\t\tdomain->hist_list_entry_base = base;\n-\t\tdomain->hist_list_entry_offset = 0;\n-\n-\t\tdlb2_bitmap_clear_range(bitmap, base, num_hist_list_entries);\n-\t}\n-\treturn 0;\n-\n-error:\n-\tresp->status = DLB2_ST_HIST_LIST_ENTRIES_UNAVAILABLE;\n-\treturn -EINVAL;\n-}\n-\n-static int dlb2_attach_ldb_queues(struct dlb2_hw *hw,\n-\t\t\t\t  struct dlb2_function_resources *rsrcs,\n-\t\t\t\t  struct dlb2_hw_domain *domain,\n-\t\t\t\t  u32 num_queues,\n-\t\t\t\t  struct dlb2_cmd_response *resp)\n-{\n-\tunsigned int i;\n-\n-\tif (rsrcs->num_avail_ldb_queues < num_queues) {\n-\t\tresp->status = DLB2_ST_LDB_QUEUES_UNAVAILABLE;\n-\t\treturn -EINVAL;\n-\t}\n-\n-\tfor (i = 0; i < num_queues; i++) {\n-\t\tstruct dlb2_ldb_queue *queue;\n-\n-\t\tqueue = DLB2_FUNC_LIST_HEAD(rsrcs->avail_ldb_queues,\n-\t\t\t\t\t    typeof(*queue));\n-\t\tif (queue == NULL) {\n-\t\t\tDLB2_HW_ERR(hw,\n-\t\t\t\t    \"[%s()] Internal error: domain validation failed\\n\",\n-\t\t\t\t    __func__);\n-\t\t\treturn -EFAULT;\n-\t\t}\n-\n-\t\tdlb2_list_del(&rsrcs->avail_ldb_queues, &queue->func_list);\n-\n-\t\tqueue->domain_id = domain->id;\n-\t\tqueue->owned = true;\n-\n-\t\tdlb2_list_add(&domain->avail_ldb_queues, &queue->domain_list);\n-\t}\n-\n-\trsrcs->num_avail_ldb_queues -= num_queues;\n-\n-\treturn 0;\n-}\n-\n-static int\n-dlb2_domain_attach_resources(struct dlb2_hw *hw,\n-\t\t\t     struct dlb2_function_resources *rsrcs,\n-\t\t\t     struct dlb2_hw_domain *domain,\n-\t\t\t     struct dlb2_create_sched_domain_args *args,\n-\t\t\t     struct dlb2_cmd_response *resp)\n-{\n-\tint ret;\n-\n-\tret = dlb2_attach_ldb_queues(hw,\n-\t\t\t\t     rsrcs,\n-\t\t\t\t     domain,\n-\t\t\t\t     args->num_ldb_queues,\n-\t\t\t\t     resp);\n-\tif (ret < 0)\n-\t\treturn ret;\n-\n-\tret = dlb2_attach_ldb_ports(hw,\n-\t\t\t\t    rsrcs,\n-\t\t\t\t    domain,\n-\t\t\t\t    args,\n-\t\t\t\t    resp);\n-\tif (ret < 0)\n-\t\treturn ret;\n-\n-\tret = dlb2_attach_dir_ports(hw,\n-\t\t\t\t    rsrcs,\n-\t\t\t\t    domain,\n-\t\t\t\t    args->num_dir_ports,\n-\t\t\t\t    resp);\n-\tif (ret < 0)\n-\t\treturn ret;\n-\n-\tret = dlb2_attach_ldb_credits(rsrcs,\n-\t\t\t\t      domain,\n-\t\t\t\t      args->num_ldb_credits,\n-\t\t\t\t      resp);\n-\tif (ret < 0)\n-\t\treturn ret;\n-\n-\tret = dlb2_attach_dir_credits(rsrcs,\n-\t\t\t\t      domain,\n-\t\t\t\t      args->num_dir_credits,\n-\t\t\t\t      resp);\n-\tif (ret < 0)\n-\t\treturn ret;\n-\n-\tret = dlb2_attach_domain_hist_list_entries(rsrcs,\n-\t\t\t\t\t\t   domain,\n-\t\t\t\t\t\t   args->num_hist_list_entries,\n-\t\t\t\t\t\t   resp);\n-\tif (ret < 0)\n-\t\treturn ret;\n-\n-\tret = dlb2_attach_atomic_inflights(rsrcs,\n-\t\t\t\t\t   domain,\n-\t\t\t\t\t   args->num_atomic_inflights,\n-\t\t\t\t\t   resp);\n-\tif (ret < 0)\n-\t\treturn ret;\n-\n-\tdlb2_configure_domain_credits(hw, domain);\n-\n-\tdomain->configured = true;\n-\n-\tdomain->started = false;\n-\n-\trsrcs->num_avail_domains--;\n-\n-\treturn 0;\n-}\n-\n-static int\n-dlb2_verify_create_sched_dom_args(struct dlb2_function_resources *rsrcs,\n-\t\t\t\t  struct dlb2_create_sched_domain_args *args,\n-\t\t\t\t  struct dlb2_cmd_response *resp)\n-{\n-\tu32 num_avail_ldb_ports, req_ldb_ports;\n-\tstruct dlb2_bitmap *avail_hl_entries;\n-\tunsigned int max_contig_hl_range;\n-\tint i;\n-\n-\tavail_hl_entries = rsrcs->avail_hist_list_entries;\n-\n-\tmax_contig_hl_range = dlb2_bitmap_longest_set_range(avail_hl_entries);\n-\n-\tnum_avail_ldb_ports = 0;\n-\treq_ldb_ports = 0;\n-\tfor (i = 0; i < DLB2_NUM_COS_DOMAINS; i++) {\n-\t\tnum_avail_ldb_ports += rsrcs->num_avail_ldb_ports[i];\n-\n-\t\treq_ldb_ports += args->num_cos_ldb_ports[i];\n-\t}\n-\n-\treq_ldb_ports += args->num_ldb_ports;\n-\n-\tif (rsrcs->num_avail_domains < 1) {\n-\t\tresp->status = DLB2_ST_DOMAIN_UNAVAILABLE;\n-\t\treturn -EINVAL;\n-\t}\n-\n-\tif (rsrcs->num_avail_ldb_queues < args->num_ldb_queues) {\n-\t\tresp->status = DLB2_ST_LDB_QUEUES_UNAVAILABLE;\n-\t\treturn -EINVAL;\n-\t}\n-\n-\tif (req_ldb_ports > num_avail_ldb_ports) {\n-\t\tresp->status = DLB2_ST_LDB_PORTS_UNAVAILABLE;\n-\t\treturn -EINVAL;\n-\t}\n-\n-\tfor (i = 0; args->cos_strict && i < DLB2_NUM_COS_DOMAINS; i++) {\n-\t\tif (args->num_cos_ldb_ports[i] >\n-\t\t    rsrcs->num_avail_ldb_ports[i]) {\n-\t\t\tresp->status = DLB2_ST_LDB_PORTS_UNAVAILABLE;\n-\t\t\treturn -EINVAL;\n-\t\t}\n-\t}\n-\n-\tif (args->num_ldb_queues > 0 && req_ldb_ports == 0) {\n-\t\tresp->status = DLB2_ST_LDB_PORT_REQUIRED_FOR_LDB_QUEUES;\n-\t\treturn -EINVAL;\n-\t}\n-\n-\tif (rsrcs->num_avail_dir_pq_pairs < args->num_dir_ports) {\n-\t\tresp->status = DLB2_ST_DIR_PORTS_UNAVAILABLE;\n-\t\treturn -EINVAL;\n-\t}\n-\n-\tif (rsrcs->num_avail_qed_entries < args->num_ldb_credits) {\n-\t\tresp->status = DLB2_ST_LDB_CREDITS_UNAVAILABLE;\n-\t\treturn -EINVAL;\n-\t}\n-\n-\tif (rsrcs->num_avail_dqed_entries < args->num_dir_credits) {\n-\t\tresp->status = DLB2_ST_DIR_CREDITS_UNAVAILABLE;\n-\t\treturn -EINVAL;\n-\t}\n-\n-\tif (rsrcs->num_avail_aqed_entries < args->num_atomic_inflights) {\n-\t\tresp->status = DLB2_ST_ATOMIC_INFLIGHTS_UNAVAILABLE;\n-\t\treturn -EINVAL;\n-\t}\n-\n-\tif (max_contig_hl_range < args->num_hist_list_entries) {\n-\t\tresp->status = DLB2_ST_HIST_LIST_ENTRIES_UNAVAILABLE;\n-\t\treturn -EINVAL;\n-\t}\n-\n-\treturn 0;\n-}\n-\n-static void\n-dlb2_log_create_sched_domain_args(struct dlb2_hw *hw,\n-\t\t\t\t  struct dlb2_create_sched_domain_args *args,\n-\t\t\t\t  bool vdev_req,\n-\t\t\t\t  unsigned int vdev_id)\n-{\n-\tDLB2_HW_DBG(hw, \"DLB2 create sched domain arguments:\\n\");\n-\tif (vdev_req)\n-\t\tDLB2_HW_DBG(hw, \"(Request from vdev %d)\\n\", vdev_id);\n-\tDLB2_HW_DBG(hw, \"\\tNumber of LDB queues:          %d\\n\",\n-\t\t    args->num_ldb_queues);\n-\tDLB2_HW_DBG(hw, \"\\tNumber of LDB ports (any CoS): %d\\n\",\n-\t\t    args->num_ldb_ports);\n-\tDLB2_HW_DBG(hw, \"\\tNumber of LDB ports (CoS 0):   %d\\n\",\n-\t\t    args->num_cos_ldb_ports[0]);\n-\tDLB2_HW_DBG(hw, \"\\tNumber of LDB ports (CoS 1):   %d\\n\",\n-\t\t    args->num_cos_ldb_ports[1]);\n-\tDLB2_HW_DBG(hw, \"\\tNumber of LDB ports (CoS 2):   %d\\n\",\n-\t\t    args->num_cos_ldb_ports[1]);\n-\tDLB2_HW_DBG(hw, \"\\tNumber of LDB ports (CoS 3):   %d\\n\",\n-\t\t    args->num_cos_ldb_ports[1]);\n-\tDLB2_HW_DBG(hw, \"\\tStrict CoS allocation:         %d\\n\",\n-\t\t    args->cos_strict);\n-\tDLB2_HW_DBG(hw, \"\\tNumber of DIR ports:           %d\\n\",\n-\t\t    args->num_dir_ports);\n-\tDLB2_HW_DBG(hw, \"\\tNumber of ATM inflights:       %d\\n\",\n-\t\t    args->num_atomic_inflights);\n-\tDLB2_HW_DBG(hw, \"\\tNumber of hist list entries:   %d\\n\",\n-\t\t    args->num_hist_list_entries);\n-\tDLB2_HW_DBG(hw, \"\\tNumber of LDB credits:         %d\\n\",\n-\t\t    args->num_ldb_credits);\n-\tDLB2_HW_DBG(hw, \"\\tNumber of DIR credits:         %d\\n\",\n-\t\t    args->num_dir_credits);\n-}\n-\n-/**\n- * dlb2_hw_create_sched_domain() - Allocate and initialize a DLB scheduling\n- *\tdomain and its resources.\n- * @hw:\tContains the current state of the DLB2 hardware.\n- * @args: User-provided arguments.\n- * @resp: Response to user.\n- * @vdev_req: Request came from a virtual device.\n- * @vdev_id: If vdev_req is true, this contains the virtual device's ID.\n- *\n- * Return: returns < 0 on error, 0 otherwise. If the driver is unable to\n- * satisfy a request, resp->status will be set accordingly.\n- */\n-int dlb2_hw_create_sched_domain(struct dlb2_hw *hw,\n-\t\t\t\tstruct dlb2_create_sched_domain_args *args,\n-\t\t\t\tstruct dlb2_cmd_response *resp,\n-\t\t\t\tbool vdev_req,\n-\t\t\t\tunsigned int vdev_id)\n-{\n-\tstruct dlb2_function_resources *rsrcs;\n-\tstruct dlb2_hw_domain *domain;\n-\tint ret;\n-\n-\trsrcs = (vdev_req) ? &hw->vdev[vdev_id] : &hw->pf;\n-\n-\tdlb2_log_create_sched_domain_args(hw, args, vdev_req, vdev_id);\n-\n-\t/*\n-\t * Verify that hardware resources are available before attempting to\n-\t * satisfy the request. This simplifies the error unwinding code.\n-\t */\n-\tret = dlb2_verify_create_sched_dom_args(rsrcs, args, resp);\n-\tif (ret)\n-\t\treturn ret;\n-\n-\tdomain = DLB2_FUNC_LIST_HEAD(rsrcs->avail_domains, typeof(*domain));\n-\tif (domain == NULL) {\n-\t\tDLB2_HW_ERR(hw,\n-\t\t\t    \"[%s():%d] Internal error: no available domains\\n\",\n-\t\t\t    __func__, __LINE__);\n-\t\treturn -EFAULT;\n-\t}\n-\n-\tif (domain->configured) {\n-\t\tDLB2_HW_ERR(hw,\n-\t\t\t    \"[%s()] Internal error: avail_domains contains configured domains.\\n\",\n-\t\t\t    __func__);\n-\t\treturn -EFAULT;\n-\t}\n-\n-\tdlb2_init_domain_rsrc_lists(domain);\n-\n-\tret = dlb2_domain_attach_resources(hw, rsrcs, domain, args, resp);\n-\tif (ret < 0) {\n-\t\tDLB2_HW_ERR(hw,\n-\t\t\t    \"[%s()] Internal error: failed to verify args.\\n\",\n-\t\t\t    __func__);\n-\n-\t\treturn ret;\n-\t}\n-\n-\tdlb2_list_del(&rsrcs->avail_domains, &domain->func_list);\n-\n-\tdlb2_list_add(&rsrcs->used_domains, &domain->func_list);\n-\n-\tresp->id = (vdev_req) ? domain->id.virt_id : domain->id.phys_id;\n-\tresp->status = 0;\n-\n-\treturn 0;\n-}\n-\n /*\n  * The PF driver cannot assume that a register write will affect subsequent HCW\n  * writes. To ensure a write completes, the driver must read back a CSR. This\ndiff --git a/drivers/event/dlb2/pf/base/dlb2_resource_new.c b/drivers/event/dlb2/pf/base/dlb2_resource_new.c\nindex b0fd37a55..4d679a0a9 100644\n--- a/drivers/event/dlb2/pf/base/dlb2_resource_new.c\n+++ b/drivers/event/dlb2/pf/base/dlb2_resource_new.c\n@@ -335,3 +335,699 @@ int dlb2_hw_get_num_resources(struct dlb2_hw *hw,\n \t}\n \treturn 0;\n }\n+\n+static void dlb2_configure_domain_credits_v2_5(struct dlb2_hw *hw,\n+\t\t\t\t\t       struct dlb2_hw_domain *domain)\n+{\n+\tu32 reg = 0;\n+\n+\tDLB2_BITS_SET(reg, domain->num_credits, DLB2_CHP_CFG_LDB_VAS_CRD_COUNT);\n+\tDLB2_CSR_WR(hw, DLB2_CHP_CFG_VAS_CRD(domain->id.phys_id), reg);\n+}\n+\n+static void dlb2_configure_domain_credits_v2(struct dlb2_hw *hw,\n+\t\t\t\t\t     struct dlb2_hw_domain *domain)\n+{\n+\tu32 reg = 0;\n+\n+\tDLB2_BITS_SET(reg, domain->num_ldb_credits,\n+\t\t      DLB2_CHP_CFG_LDB_VAS_CRD_COUNT);\n+\tDLB2_CSR_WR(hw, DLB2_CHP_CFG_LDB_VAS_CRD(domain->id.phys_id), reg);\n+\n+\treg = 0;\n+\tDLB2_BITS_SET(reg, domain->num_dir_credits,\n+\t\t      DLB2_CHP_CFG_DIR_VAS_CRD_COUNT);\n+\tDLB2_CSR_WR(hw, DLB2_CHP_CFG_DIR_VAS_CRD(domain->id.phys_id), reg);\n+}\n+\n+static void dlb2_configure_domain_credits(struct dlb2_hw *hw,\n+\t\t\t\t\t  struct dlb2_hw_domain *domain)\n+{\n+\tif (hw->ver == DLB2_HW_V2)\n+\t\tdlb2_configure_domain_credits_v2(hw, domain);\n+\telse\n+\t\tdlb2_configure_domain_credits_v2_5(hw, domain);\n+}\n+\n+static int dlb2_attach_credits(struct dlb2_function_resources *rsrcs,\n+\t\t\t       struct dlb2_hw_domain *domain,\n+\t\t\t       u32 num_credits,\n+\t\t\t       struct dlb2_cmd_response *resp)\n+{\n+\tif (rsrcs->num_avail_entries < num_credits) {\n+\t\tresp->status = DLB2_ST_CREDITS_UNAVAILABLE;\n+\t\treturn -EINVAL;\n+\t}\n+\n+\trsrcs->num_avail_entries -= num_credits;\n+\tdomain->num_credits += num_credits;\n+\treturn 0;\n+}\n+\n+static struct dlb2_ldb_port *\n+dlb2_get_next_ldb_port(struct dlb2_hw *hw,\n+\t\t       struct dlb2_function_resources *rsrcs,\n+\t\t       u32 domain_id,\n+\t\t       u32 cos_id)\n+{\n+\tstruct dlb2_list_entry *iter;\n+\tstruct dlb2_ldb_port *port;\n+\tRTE_SET_USED(iter);\n+\n+\t/*\n+\t * To reduce the odds of consecutive load-balanced ports mapping to the\n+\t * same queue(s), the driver attempts to allocate ports whose neighbors\n+\t * are owned by a different domain.\n+\t */\n+\tDLB2_FUNC_LIST_FOR(rsrcs->avail_ldb_ports[cos_id], port, iter) {\n+\t\tu32 next, prev;\n+\t\tu32 phys_id;\n+\n+\t\tphys_id = port->id.phys_id;\n+\t\tnext = phys_id + 1;\n+\t\tprev = phys_id - 1;\n+\n+\t\tif (phys_id == DLB2_MAX_NUM_LDB_PORTS - 1)\n+\t\t\tnext = 0;\n+\t\tif (phys_id == 0)\n+\t\t\tprev = DLB2_MAX_NUM_LDB_PORTS - 1;\n+\n+\t\tif (!hw->rsrcs.ldb_ports[next].owned ||\n+\t\t    hw->rsrcs.ldb_ports[next].domain_id.phys_id == domain_id)\n+\t\t\tcontinue;\n+\n+\t\tif (!hw->rsrcs.ldb_ports[prev].owned ||\n+\t\t    hw->rsrcs.ldb_ports[prev].domain_id.phys_id == domain_id)\n+\t\t\tcontinue;\n+\n+\t\treturn port;\n+\t}\n+\n+\t/*\n+\t * Failing that, the driver looks for a port with one neighbor owned by\n+\t * a different domain and the other unallocated.\n+\t */\n+\tDLB2_FUNC_LIST_FOR(rsrcs->avail_ldb_ports[cos_id], port, iter) {\n+\t\tu32 next, prev;\n+\t\tu32 phys_id;\n+\n+\t\tphys_id = port->id.phys_id;\n+\t\tnext = phys_id + 1;\n+\t\tprev = phys_id - 1;\n+\n+\t\tif (phys_id == DLB2_MAX_NUM_LDB_PORTS - 1)\n+\t\t\tnext = 0;\n+\t\tif (phys_id == 0)\n+\t\t\tprev = DLB2_MAX_NUM_LDB_PORTS - 1;\n+\n+\t\tif (!hw->rsrcs.ldb_ports[prev].owned &&\n+\t\t    hw->rsrcs.ldb_ports[next].owned &&\n+\t\t    hw->rsrcs.ldb_ports[next].domain_id.phys_id != domain_id)\n+\t\t\treturn port;\n+\n+\t\tif (!hw->rsrcs.ldb_ports[next].owned &&\n+\t\t    hw->rsrcs.ldb_ports[prev].owned &&\n+\t\t    hw->rsrcs.ldb_ports[prev].domain_id.phys_id != domain_id)\n+\t\t\treturn port;\n+\t}\n+\n+\t/*\n+\t * Failing that, the driver looks for a port with both neighbors\n+\t * unallocated.\n+\t */\n+\tDLB2_FUNC_LIST_FOR(rsrcs->avail_ldb_ports[cos_id], port, iter) {\n+\t\tu32 next, prev;\n+\t\tu32 phys_id;\n+\n+\t\tphys_id = port->id.phys_id;\n+\t\tnext = phys_id + 1;\n+\t\tprev = phys_id - 1;\n+\n+\t\tif (phys_id == DLB2_MAX_NUM_LDB_PORTS - 1)\n+\t\t\tnext = 0;\n+\t\tif (phys_id == 0)\n+\t\t\tprev = DLB2_MAX_NUM_LDB_PORTS - 1;\n+\n+\t\tif (!hw->rsrcs.ldb_ports[prev].owned &&\n+\t\t    !hw->rsrcs.ldb_ports[next].owned)\n+\t\t\treturn port;\n+\t}\n+\n+\t/* If all else fails, the driver returns the next available port. */\n+\treturn DLB2_FUNC_LIST_HEAD(rsrcs->avail_ldb_ports[cos_id],\n+\t\t\t\t   typeof(*port));\n+}\n+\n+static int __dlb2_attach_ldb_ports(struct dlb2_hw *hw,\n+\t\t\t\t   struct dlb2_function_resources *rsrcs,\n+\t\t\t\t   struct dlb2_hw_domain *domain,\n+\t\t\t\t   u32 num_ports,\n+\t\t\t\t   u32 cos_id,\n+\t\t\t\t   struct dlb2_cmd_response *resp)\n+{\n+\tunsigned int i;\n+\n+\tif (rsrcs->num_avail_ldb_ports[cos_id] < num_ports) {\n+\t\tresp->status = DLB2_ST_LDB_PORTS_UNAVAILABLE;\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tfor (i = 0; i < num_ports; i++) {\n+\t\tstruct dlb2_ldb_port *port;\n+\n+\t\tport = dlb2_get_next_ldb_port(hw, rsrcs,\n+\t\t\t\t\t      domain->id.phys_id, cos_id);\n+\t\tif (port == NULL) {\n+\t\t\tDLB2_HW_ERR(hw,\n+\t\t\t\t    \"[%s()] Internal error: domain validation failed\\n\",\n+\t\t\t\t    __func__);\n+\t\t\treturn -EFAULT;\n+\t\t}\n+\n+\t\tdlb2_list_del(&rsrcs->avail_ldb_ports[cos_id],\n+\t\t\t      &port->func_list);\n+\n+\t\tport->domain_id = domain->id;\n+\t\tport->owned = true;\n+\n+\t\tdlb2_list_add(&domain->avail_ldb_ports[cos_id],\n+\t\t\t      &port->domain_list);\n+\t}\n+\n+\trsrcs->num_avail_ldb_ports[cos_id] -= num_ports;\n+\n+\treturn 0;\n+}\n+\n+\n+static int dlb2_attach_ldb_ports(struct dlb2_hw *hw,\n+\t\t\t\t struct dlb2_function_resources *rsrcs,\n+\t\t\t\t struct dlb2_hw_domain *domain,\n+\t\t\t\t struct dlb2_create_sched_domain_args *args,\n+\t\t\t\t struct dlb2_cmd_response *resp)\n+{\n+\tunsigned int i, j;\n+\tint ret;\n+\n+\tif (args->cos_strict) {\n+\t\tfor (i = 0; i < DLB2_NUM_COS_DOMAINS; i++) {\n+\t\t\tu32 num = args->num_cos_ldb_ports[i];\n+\n+\t\t\t/* Allocate ports from specific classes-of-service */\n+\t\t\tret = __dlb2_attach_ldb_ports(hw,\n+\t\t\t\t\t\t      rsrcs,\n+\t\t\t\t\t\t      domain,\n+\t\t\t\t\t\t      num,\n+\t\t\t\t\t\t      i,\n+\t\t\t\t\t\t      resp);\n+\t\t\tif (ret)\n+\t\t\t\treturn ret;\n+\t\t}\n+\t} else {\n+\t\tunsigned int k;\n+\t\tu32 cos_id;\n+\n+\t\t/*\n+\t\t * Attempt to allocate from specific class-of-service, but\n+\t\t * fallback to the other classes if that fails.\n+\t\t */\n+\t\tfor (i = 0; i < DLB2_NUM_COS_DOMAINS; i++) {\n+\t\t\tfor (j = 0; j < args->num_cos_ldb_ports[i]; j++) {\n+\t\t\t\tfor (k = 0; k < DLB2_NUM_COS_DOMAINS; k++) {\n+\t\t\t\t\tcos_id = (i + k) % DLB2_NUM_COS_DOMAINS;\n+\n+\t\t\t\t\tret = __dlb2_attach_ldb_ports(hw,\n+\t\t\t\t\t\t\t\t      rsrcs,\n+\t\t\t\t\t\t\t\t      domain,\n+\t\t\t\t\t\t\t\t      1,\n+\t\t\t\t\t\t\t\t      cos_id,\n+\t\t\t\t\t\t\t\t      resp);\n+\t\t\t\t\tif (ret == 0)\n+\t\t\t\t\t\tbreak;\n+\t\t\t\t}\n+\n+\t\t\t\tif (ret)\n+\t\t\t\t\treturn ret;\n+\t\t\t}\n+\t\t}\n+\t}\n+\n+\t/* Allocate num_ldb_ports from any class-of-service */\n+\tfor (i = 0; i < args->num_ldb_ports; i++) {\n+\t\tfor (j = 0; j < DLB2_NUM_COS_DOMAINS; j++) {\n+\t\t\tret = __dlb2_attach_ldb_ports(hw,\n+\t\t\t\t\t\t      rsrcs,\n+\t\t\t\t\t\t      domain,\n+\t\t\t\t\t\t      1,\n+\t\t\t\t\t\t      j,\n+\t\t\t\t\t\t      resp);\n+\t\t\tif (ret == 0)\n+\t\t\t\tbreak;\n+\t\t}\n+\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static int dlb2_attach_dir_ports(struct dlb2_hw *hw,\n+\t\t\t\t struct dlb2_function_resources *rsrcs,\n+\t\t\t\t struct dlb2_hw_domain *domain,\n+\t\t\t\t u32 num_ports,\n+\t\t\t\t struct dlb2_cmd_response *resp)\n+{\n+\tunsigned int i;\n+\n+\tif (rsrcs->num_avail_dir_pq_pairs < num_ports) {\n+\t\tresp->status = DLB2_ST_DIR_PORTS_UNAVAILABLE;\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tfor (i = 0; i < num_ports; i++) {\n+\t\tstruct dlb2_dir_pq_pair *port;\n+\n+\t\tport = DLB2_FUNC_LIST_HEAD(rsrcs->avail_dir_pq_pairs,\n+\t\t\t\t\t   typeof(*port));\n+\t\tif (port == NULL) {\n+\t\t\tDLB2_HW_ERR(hw,\n+\t\t\t\t    \"[%s()] Internal error: domain validation failed\\n\",\n+\t\t\t\t    __func__);\n+\t\t\treturn -EFAULT;\n+\t\t}\n+\n+\t\tdlb2_list_del(&rsrcs->avail_dir_pq_pairs, &port->func_list);\n+\n+\t\tport->domain_id = domain->id;\n+\t\tport->owned = true;\n+\n+\t\tdlb2_list_add(&domain->avail_dir_pq_pairs, &port->domain_list);\n+\t}\n+\n+\trsrcs->num_avail_dir_pq_pairs -= num_ports;\n+\n+\treturn 0;\n+}\n+\n+static int dlb2_attach_ldb_credits(struct dlb2_function_resources *rsrcs,\n+\t\t\t\t   struct dlb2_hw_domain *domain,\n+\t\t\t\t   u32 num_credits,\n+\t\t\t\t   struct dlb2_cmd_response *resp)\n+{\n+\tif (rsrcs->num_avail_qed_entries < num_credits) {\n+\t\tresp->status = DLB2_ST_LDB_CREDITS_UNAVAILABLE;\n+\t\treturn -EINVAL;\n+\t}\n+\n+\trsrcs->num_avail_qed_entries -= num_credits;\n+\tdomain->num_ldb_credits += num_credits;\n+\treturn 0;\n+}\n+\n+static int dlb2_attach_dir_credits(struct dlb2_function_resources *rsrcs,\n+\t\t\t\t   struct dlb2_hw_domain *domain,\n+\t\t\t\t   u32 num_credits,\n+\t\t\t\t   struct dlb2_cmd_response *resp)\n+{\n+\tif (rsrcs->num_avail_dqed_entries < num_credits) {\n+\t\tresp->status = DLB2_ST_DIR_CREDITS_UNAVAILABLE;\n+\t\treturn -EINVAL;\n+\t}\n+\n+\trsrcs->num_avail_dqed_entries -= num_credits;\n+\tdomain->num_dir_credits += num_credits;\n+\treturn 0;\n+}\n+\n+\n+static int dlb2_attach_atomic_inflights(struct dlb2_function_resources *rsrcs,\n+\t\t\t\t\tstruct dlb2_hw_domain *domain,\n+\t\t\t\t\tu32 num_atomic_inflights,\n+\t\t\t\t\tstruct dlb2_cmd_response *resp)\n+{\n+\tif (rsrcs->num_avail_aqed_entries < num_atomic_inflights) {\n+\t\tresp->status = DLB2_ST_ATOMIC_INFLIGHTS_UNAVAILABLE;\n+\t\treturn -EINVAL;\n+\t}\n+\n+\trsrcs->num_avail_aqed_entries -= num_atomic_inflights;\n+\tdomain->num_avail_aqed_entries += num_atomic_inflights;\n+\treturn 0;\n+}\n+\n+static int\n+dlb2_attach_domain_hist_list_entries(struct dlb2_function_resources *rsrcs,\n+\t\t\t\t     struct dlb2_hw_domain *domain,\n+\t\t\t\t     u32 num_hist_list_entries,\n+\t\t\t\t     struct dlb2_cmd_response *resp)\n+{\n+\tstruct dlb2_bitmap *bitmap;\n+\tint base;\n+\n+\tif (num_hist_list_entries) {\n+\t\tbitmap = rsrcs->avail_hist_list_entries;\n+\n+\t\tbase = dlb2_bitmap_find_set_bit_range(bitmap,\n+\t\t\t\t\t\t      num_hist_list_entries);\n+\t\tif (base < 0)\n+\t\t\tgoto error;\n+\n+\t\tdomain->total_hist_list_entries = num_hist_list_entries;\n+\t\tdomain->avail_hist_list_entries = num_hist_list_entries;\n+\t\tdomain->hist_list_entry_base = base;\n+\t\tdomain->hist_list_entry_offset = 0;\n+\n+\t\tdlb2_bitmap_clear_range(bitmap, base, num_hist_list_entries);\n+\t}\n+\treturn 0;\n+\n+error:\n+\tresp->status = DLB2_ST_HIST_LIST_ENTRIES_UNAVAILABLE;\n+\treturn -EINVAL;\n+}\n+\n+static int dlb2_attach_ldb_queues(struct dlb2_hw *hw,\n+\t\t\t\t  struct dlb2_function_resources *rsrcs,\n+\t\t\t\t  struct dlb2_hw_domain *domain,\n+\t\t\t\t  u32 num_queues,\n+\t\t\t\t  struct dlb2_cmd_response *resp)\n+{\n+\tunsigned int i;\n+\n+\tif (rsrcs->num_avail_ldb_queues < num_queues) {\n+\t\tresp->status = DLB2_ST_LDB_QUEUES_UNAVAILABLE;\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tfor (i = 0; i < num_queues; i++) {\n+\t\tstruct dlb2_ldb_queue *queue;\n+\n+\t\tqueue = DLB2_FUNC_LIST_HEAD(rsrcs->avail_ldb_queues,\n+\t\t\t\t\t    typeof(*queue));\n+\t\tif (queue == NULL) {\n+\t\t\tDLB2_HW_ERR(hw,\n+\t\t\t\t    \"[%s()] Internal error: domain validation failed\\n\",\n+\t\t\t\t    __func__);\n+\t\t\treturn -EFAULT;\n+\t\t}\n+\n+\t\tdlb2_list_del(&rsrcs->avail_ldb_queues, &queue->func_list);\n+\n+\t\tqueue->domain_id = domain->id;\n+\t\tqueue->owned = true;\n+\n+\t\tdlb2_list_add(&domain->avail_ldb_queues, &queue->domain_list);\n+\t}\n+\n+\trsrcs->num_avail_ldb_queues -= num_queues;\n+\n+\treturn 0;\n+}\n+\n+static int\n+dlb2_domain_attach_resources(struct dlb2_hw *hw,\n+\t\t\t     struct dlb2_function_resources *rsrcs,\n+\t\t\t     struct dlb2_hw_domain *domain,\n+\t\t\t     struct dlb2_create_sched_domain_args *args,\n+\t\t\t     struct dlb2_cmd_response *resp)\n+{\n+\tint ret;\n+\n+\tret = dlb2_attach_ldb_queues(hw,\n+\t\t\t\t     rsrcs,\n+\t\t\t\t     domain,\n+\t\t\t\t     args->num_ldb_queues,\n+\t\t\t\t     resp);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tret = dlb2_attach_ldb_ports(hw,\n+\t\t\t\t    rsrcs,\n+\t\t\t\t    domain,\n+\t\t\t\t    args,\n+\t\t\t\t    resp);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tret = dlb2_attach_dir_ports(hw,\n+\t\t\t\t    rsrcs,\n+\t\t\t\t    domain,\n+\t\t\t\t    args->num_dir_ports,\n+\t\t\t\t    resp);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tif (hw->ver == DLB2_HW_V2) {\n+\t\tret = dlb2_attach_ldb_credits(rsrcs,\n+\t\t\t\t\t      domain,\n+\t\t\t\t\t      args->num_ldb_credits,\n+\t\t\t\t\t      resp);\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\n+\t\tret = dlb2_attach_dir_credits(rsrcs,\n+\t\t\t\t\t      domain,\n+\t\t\t\t\t      args->num_dir_credits,\n+\t\t\t\t\t      resp);\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\t} else {  /* DLB 2.5 */\n+\t\tret = dlb2_attach_credits(rsrcs,\n+\t\t\t\t\t  domain,\n+\t\t\t\t\t  args->num_credits,\n+\t\t\t\t\t  resp);\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\t}\n+\n+\tret = dlb2_attach_domain_hist_list_entries(rsrcs,\n+\t\t\t\t\t\t   domain,\n+\t\t\t\t\t\t   args->num_hist_list_entries,\n+\t\t\t\t\t\t   resp);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tret = dlb2_attach_atomic_inflights(rsrcs,\n+\t\t\t\t\t   domain,\n+\t\t\t\t\t   args->num_atomic_inflights,\n+\t\t\t\t\t   resp);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tdlb2_configure_domain_credits(hw, domain);\n+\n+\tdomain->configured = true;\n+\n+\tdomain->started = false;\n+\n+\trsrcs->num_avail_domains--;\n+\n+\treturn 0;\n+}\n+\n+static int\n+dlb2_verify_create_sched_dom_args(struct dlb2_function_resources *rsrcs,\n+\t\t\t\t  struct dlb2_create_sched_domain_args *args,\n+\t\t\t\t  struct dlb2_cmd_response *resp,\n+\t\t\t\t  struct dlb2_hw *hw,\n+\t\t\t\t  struct dlb2_hw_domain **out_domain)\n+{\n+\tu32 num_avail_ldb_ports, req_ldb_ports;\n+\tstruct dlb2_bitmap *avail_hl_entries;\n+\tunsigned int max_contig_hl_range;\n+\tstruct dlb2_hw_domain *domain;\n+\tint i;\n+\n+\tavail_hl_entries = rsrcs->avail_hist_list_entries;\n+\n+\tmax_contig_hl_range = dlb2_bitmap_longest_set_range(avail_hl_entries);\n+\n+\tnum_avail_ldb_ports = 0;\n+\treq_ldb_ports = 0;\n+\tfor (i = 0; i < DLB2_NUM_COS_DOMAINS; i++) {\n+\t\tnum_avail_ldb_ports += rsrcs->num_avail_ldb_ports[i];\n+\n+\t\treq_ldb_ports += args->num_cos_ldb_ports[i];\n+\t}\n+\n+\treq_ldb_ports += args->num_ldb_ports;\n+\n+\tif (rsrcs->num_avail_domains < 1) {\n+\t\tresp->status = DLB2_ST_DOMAIN_UNAVAILABLE;\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tdomain = DLB2_FUNC_LIST_HEAD(rsrcs->avail_domains, typeof(*domain));\n+\tif (domain == NULL) {\n+\t\tresp->status = DLB2_ST_DOMAIN_UNAVAILABLE;\n+\t\treturn -EFAULT;\n+\t}\n+\n+\tif (rsrcs->num_avail_ldb_queues < args->num_ldb_queues) {\n+\t\tresp->status = DLB2_ST_LDB_QUEUES_UNAVAILABLE;\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (req_ldb_ports > num_avail_ldb_ports) {\n+\t\tresp->status = DLB2_ST_LDB_PORTS_UNAVAILABLE;\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tfor (i = 0; args->cos_strict && i < DLB2_NUM_COS_DOMAINS; i++) {\n+\t\tif (args->num_cos_ldb_ports[i] >\n+\t\t    rsrcs->num_avail_ldb_ports[i]) {\n+\t\t\tresp->status = DLB2_ST_LDB_PORTS_UNAVAILABLE;\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\t}\n+\n+\tif (args->num_ldb_queues > 0 && req_ldb_ports == 0) {\n+\t\tresp->status = DLB2_ST_LDB_PORT_REQUIRED_FOR_LDB_QUEUES;\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (rsrcs->num_avail_dir_pq_pairs < args->num_dir_ports) {\n+\t\tresp->status = DLB2_ST_DIR_PORTS_UNAVAILABLE;\n+\t\treturn -EINVAL;\n+\t}\n+\tif (hw->ver == DLB2_HW_V2_5) {\n+\t\tif (rsrcs->num_avail_entries < args->num_credits) {\n+\t\t\tresp->status = DLB2_ST_CREDITS_UNAVAILABLE;\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\t} else {\n+\t\tif (rsrcs->num_avail_qed_entries < args->num_ldb_credits) {\n+\t\t\tresp->status = DLB2_ST_LDB_CREDITS_UNAVAILABLE;\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\t\tif (rsrcs->num_avail_dqed_entries < args->num_dir_credits) {\n+\t\t\tresp->status = DLB2_ST_DIR_CREDITS_UNAVAILABLE;\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\t}\n+\n+\tif (rsrcs->num_avail_aqed_entries < args->num_atomic_inflights) {\n+\t\tresp->status = DLB2_ST_ATOMIC_INFLIGHTS_UNAVAILABLE;\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (max_contig_hl_range < args->num_hist_list_entries) {\n+\t\tresp->status = DLB2_ST_HIST_LIST_ENTRIES_UNAVAILABLE;\n+\t\treturn -EINVAL;\n+\t}\n+\n+\t*out_domain = domain;\n+\n+\treturn 0;\n+}\n+\n+static void\n+dlb2_log_create_sched_domain_args(struct dlb2_hw *hw,\n+\t\t\t\t  struct dlb2_create_sched_domain_args *args,\n+\t\t\t\t  bool vdev_req,\n+\t\t\t\t  unsigned int vdev_id)\n+{\n+\tDLB2_HW_DBG(hw, \"DLB2 create sched domain arguments:\\n\");\n+\tif (vdev_req)\n+\t\tDLB2_HW_DBG(hw, \"(Request from vdev %d)\\n\", vdev_id);\n+\tDLB2_HW_DBG(hw, \"\\tNumber of LDB queues:          %d\\n\",\n+\t\t    args->num_ldb_queues);\n+\tDLB2_HW_DBG(hw, \"\\tNumber of LDB ports (any CoS): %d\\n\",\n+\t\t    args->num_ldb_ports);\n+\tDLB2_HW_DBG(hw, \"\\tNumber of LDB ports (CoS 0):   %d\\n\",\n+\t\t    args->num_cos_ldb_ports[0]);\n+\tDLB2_HW_DBG(hw, \"\\tNumber of LDB ports (CoS 1):   %d\\n\",\n+\t\t    args->num_cos_ldb_ports[1]);\n+\tDLB2_HW_DBG(hw, \"\\tNumber of LDB ports (CoS 2):   %d\\n\",\n+\t\t    args->num_cos_ldb_ports[2]);\n+\tDLB2_HW_DBG(hw, \"\\tNumber of LDB ports (CoS 3):   %d\\n\",\n+\t\t    args->num_cos_ldb_ports[3]);\n+\tDLB2_HW_DBG(hw, \"\\tStrict CoS allocation:         %d\\n\",\n+\t\t    args->cos_strict);\n+\tDLB2_HW_DBG(hw, \"\\tNumber of DIR ports:           %d\\n\",\n+\t\t    args->num_dir_ports);\n+\tDLB2_HW_DBG(hw, \"\\tNumber of ATM inflights:       %d\\n\",\n+\t\t    args->num_atomic_inflights);\n+\tDLB2_HW_DBG(hw, \"\\tNumber of hist list entries:   %d\\n\",\n+\t\t    args->num_hist_list_entries);\n+\tif (hw->ver == DLB2_HW_V2) {\n+\t\tDLB2_HW_DBG(hw, \"\\tNumber of LDB credits:         %d\\n\",\n+\t\t\t    args->num_ldb_credits);\n+\t\tDLB2_HW_DBG(hw, \"\\tNumber of DIR credits:         %d\\n\",\n+\t\t\t    args->num_dir_credits);\n+\t} else {\n+\t\tDLB2_HW_DBG(hw, \"\\tNumber of credits:         %d\\n\",\n+\t\t\t    args->num_credits);\n+\t}\n+}\n+\n+/**\n+ * dlb2_hw_create_sched_domain() - create a scheduling domain\n+ * @hw: dlb2_hw handle for a particular device.\n+ * @args: scheduling domain creation arguments.\n+ * @resp: response structure.\n+ * @vdev_req: indicates whether this request came from a vdev.\n+ * @vdev_id: If vdev_req is true, this contains the vdev's ID.\n+ *\n+ * This function creates a scheduling domain containing the resources specified\n+ * in args. The individual resources (queues, ports, credits) can be configured\n+ * after creating a scheduling domain.\n+ *\n+ * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual\n+ * device.\n+ *\n+ * Return:\n+ * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is\n+ * assigned a detailed error code from enum dlb2_error. If successful, resp->id\n+ * contains the domain ID.\n+ *\n+ * resp->id contains a virtual ID if vdev_req is true.\n+ *\n+ * Errors:\n+ * EINVAL - A requested resource is unavailable, or the requested domain name\n+ *\t    is already in use.\n+ * EFAULT - Internal error (resp->status not set).\n+ */\n+int dlb2_hw_create_sched_domain(struct dlb2_hw *hw,\n+\t\t\t\tstruct dlb2_create_sched_domain_args *args,\n+\t\t\t\tstruct dlb2_cmd_response *resp,\n+\t\t\t\tbool vdev_req,\n+\t\t\t\tunsigned int vdev_id)\n+{\n+\tstruct dlb2_function_resources *rsrcs;\n+\tstruct dlb2_hw_domain *domain;\n+\tint ret;\n+\n+\trsrcs = (vdev_req) ? &hw->vdev[vdev_id] : &hw->pf;\n+\n+\tdlb2_log_create_sched_domain_args(hw, args, vdev_req, vdev_id);\n+\n+\t/*\n+\t * Verify that hardware resources are available before attempting to\n+\t * satisfy the request. This simplifies the error unwinding code.\n+\t */\n+\tret = dlb2_verify_create_sched_dom_args(rsrcs, args, resp, hw, &domain);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tdlb2_init_domain_rsrc_lists(domain);\n+\n+\tret = dlb2_domain_attach_resources(hw, rsrcs, domain, args, resp);\n+\tif (ret) {\n+\t\tDLB2_HW_ERR(hw,\n+\t\t\t    \"[%s()] Internal error: failed to verify args.\\n\",\n+\t\t\t    __func__);\n+\n+\t\treturn ret;\n+\t}\n+\n+\tdlb2_list_del(&rsrcs->avail_domains, &domain->func_list);\n+\n+\tdlb2_list_add(&rsrcs->used_domains, &domain->func_list);\n+\n+\tresp->id = (vdev_req) ? domain->id.virt_id : domain->id.phys_id;\n+\tresp->status = 0;\n+\n+\treturn 0;\n+}\n",
    "prefixes": [
        "04/25"
    ]
}