From patchwork Wed Oct 12 23:50:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sevincer, Abdullah" X-Patchwork-Id: 118097 X-Patchwork-Delegate: jerinj@marvell.com Return-Path: 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]) by inbox.dpdk.org (Postfix) with ESMTP id 4C2C0A00C2; Thu, 13 Oct 2022 01:51:05 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 027D042C9C; Thu, 13 Oct 2022 01:51:05 +0200 (CEST) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id 33BB942C27 for ; Thu, 13 Oct 2022 01:51:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1665618663; x=1697154663; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/vH2ynVWeqxWlcXDp0YJ+YapW61F4fUpRa4BKxii08A=; b=mq3Ik0snZ7/hwVDF3GZqezNtvOKWgkJDka19N+PcjnwClbMBWVITalcy GEFiZ5LwnMQubSOSXkQtoFSscMPQ4DRzAbxdNxbrLnGKjV9h2BC+gdXaz Dq62Oxo+Z8B+F2zyI8SLul9pRZYRmvqSI761zgCQNRXETMVSZiC8tbDa2 4FFD1Nd7bodqESm0G1sE9+QM7qhPiXte5gEie0mzZylT6WhzaHY17MRn6 b5pKjkFZ+SKataHEr1GRg4+oKIWkAfghAHcI3pzkiGPsgpWXjPsa5we6G NtfuaZBo05WVKSNdSSMVMual3Mcg6ZCtatf4mOBhCOl++Pt4us19prRKh w==; X-IronPort-AV: E=McAfee;i="6500,9779,10498"; a="366936400" X-IronPort-AV: E=Sophos;i="5.95,180,1661842800"; d="scan'208";a="366936400" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Oct 2022 16:50:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10498"; a="604746821" X-IronPort-AV: E=Sophos;i="5.95,180,1661842800"; d="scan'208";a="604746821" Received: from txanpdk02.an.intel.com ([10.123.117.76]) by orsmga006.jf.intel.com with ESMTP; 12 Oct 2022 16:50:40 -0700 From: Abdullah Sevincer To: dev@dpdk.org Cc: jerinj@marvell.com, Abdullah Sevincer Subject: [PATCH v2 1/4] event/dlb2: remove cos from port probing Date: Wed, 12 Oct 2022 18:50:34 -0500 Message-Id: <20221012235037.3293072-1-abdullah.sevincer@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221012143247.3239356-1-abdullah.sevincer@intel.com, shivani.doneria@intel.com> References: <20221012143247.3239356-1-abdullah.sevincer@intel.com, shivani.doneria@intel.com> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org This commit removes cos (class of service) from port probing criteria and applies enhancements for selection of ports from best cos when default cos (255) is used. Signed-off-by: Abdullah Sevincer --- drivers/event/dlb2/dlb2.c | 5 +- drivers/event/dlb2/dlb2_priv.h | 2 +- drivers/event/dlb2/dlb2_user.h | 2 +- drivers/event/dlb2/pf/base/dlb2_hw_types.h | 2 +- drivers/event/dlb2/pf/base/dlb2_resource.c | 85 ++++++++++++++-------- 5 files changed, 60 insertions(+), 36 deletions(-) diff --git a/drivers/event/dlb2/dlb2.c b/drivers/event/dlb2/dlb2.c index 7fd89e940b..b52ce20a4e 100644 --- a/drivers/event/dlb2/dlb2.c +++ b/drivers/event/dlb2/dlb2.c @@ -180,11 +180,12 @@ dlb2_init_port_cos(struct dlb2_eventdev *dlb2, int *port_cos) { int q; - for (q = 0; q < DLB2_MAX_NUM_PORTS_ALL; q++) + for (q = 0; q < DLB2_MAX_NUM_PORTS_ALL; q++) { + dlb2->ev_ports[q].cos_id = port_cos[q]; if (port_cos[q] != DLB2_COS_DEFAULT) { - dlb2->ev_ports[q].cos_id = port_cos[q]; dlb2->cos_ports[port_cos[q]]++; } + } } static void diff --git a/drivers/event/dlb2/dlb2_priv.h b/drivers/event/dlb2/dlb2_priv.h index 9ef5bcb901..fca1720504 100644 --- a/drivers/event/dlb2/dlb2_priv.h +++ b/drivers/event/dlb2/dlb2_priv.h @@ -421,7 +421,7 @@ struct dlb2_config { }; enum dlb2_cos { - DLB2_COS_DEFAULT = -1, + DLB2_COS_DEFAULT = 255, DLB2_COS_0 = 0, DLB2_COS_1, DLB2_COS_2, diff --git a/drivers/event/dlb2/dlb2_user.h b/drivers/event/dlb2/dlb2_user.h index 28c6aaaf43..8739e2a5ac 100644 --- a/drivers/event/dlb2/dlb2_user.h +++ b/drivers/event/dlb2/dlb2_user.h @@ -450,7 +450,7 @@ struct dlb2_create_dir_queue_args { * - num_hist_list_entries: Number of history list entries. This must be * greater than or equal cq_depth. * - cos_id: class-of-service to allocate this port from. Must be between 0 and - * 3, inclusive. + * 3, inclusive. Should be 255 if default. * - cos_strict: If set, return an error if there are no available ports in the * requested class-of-service. Else, allocate the port from a different * class-of-service if the requested class has no available ports. diff --git a/drivers/event/dlb2/pf/base/dlb2_hw_types.h b/drivers/event/dlb2/pf/base/dlb2_hw_types.h index 87996ef621..be09363893 100644 --- a/drivers/event/dlb2/pf/base/dlb2_hw_types.h +++ b/drivers/event/dlb2/pf/base/dlb2_hw_types.h @@ -351,7 +351,7 @@ struct dlb2_hw { int prod_core_list[RTE_MAX_LCORE]; u8 num_prod_cores; int dir_pp_allocations[DLB2_MAX_NUM_DIR_PORTS_V2_5]; - int ldb_pp_allocations[DLB2_MAX_NUM_LDB_PORTS]; + int ldb_pp_allocations[DLB2_MAX_NUM_LDB_PORTS + DLB2_NUM_COS_DOMAINS]; /* Virtualization */ int virt_mode; diff --git a/drivers/event/dlb2/pf/base/dlb2_resource.c b/drivers/event/dlb2/pf/base/dlb2_resource.c index 280a8e51b1..3f36acb6a4 100644 --- a/drivers/event/dlb2/pf/base/dlb2_resource.c +++ b/drivers/event/dlb2/pf/base/dlb2_resource.c @@ -577,11 +577,14 @@ static int dlb2_attach_ldb_ports(struct dlb2_hw *hw, /* Allocate num_ldb_ports from any class-of-service */ for (i = 0; i < args->num_ldb_ports; i++) { for (j = 0; j < DLB2_NUM_COS_DOMAINS; j++) { + /* Allocate from best performing cos */ + u32 cos_idx = j + DLB2_MAX_NUM_LDB_PORTS; + u32 cos_id = hw->ldb_pp_allocations[cos_idx]; ret = __dlb2_attach_ldb_ports(hw, rsrcs, domain, 1, - j, + cos_id, resp); if (ret == 0) break; @@ -819,21 +822,29 @@ static int dlb2_pp_cycle_comp(const void *a, const void *b) /* Probe producer ports from different CPU cores */ static void -dlb2_get_pp_allocation(struct dlb2_hw *hw, int cpu, int port_type, int cos_id) +dlb2_get_pp_allocation(struct dlb2_hw *hw, int cpu, int port_type) { + struct dlb2_pp_thread_data dlb2_thread_data[DLB2_MAX_NUM_DIR_PORTS_V2_5]; struct dlb2_dev *dlb2_dev = container_of(hw, struct dlb2_dev, hw); - int i, err, ver = DLB2_HW_DEVICE_FROM_PCI_ID(dlb2_dev->pdev); + struct dlb2_pp_thread_data cos_cycles[DLB2_NUM_COS_DOMAINS]; + int ver = DLB2_HW_DEVICE_FROM_PCI_ID(dlb2_dev->pdev); + int num_ports_per_sort, num_ports, num_sort, i, err; bool is_ldb = (port_type == DLB2_LDB_PORT); - int num_ports = is_ldb ? DLB2_MAX_NUM_LDB_PORTS : - DLB2_MAX_NUM_DIR_PORTS(ver); - struct dlb2_pp_thread_data dlb2_thread_data[num_ports]; - int *port_allocations = is_ldb ? hw->ldb_pp_allocations : - hw->dir_pp_allocations; - int num_sort = is_ldb ? DLB2_NUM_COS_DOMAINS : 1; - struct dlb2_pp_thread_data cos_cycles[num_sort]; - int num_ports_per_sort = num_ports / num_sort; + int *port_allocations; pthread_t pthread; + if (is_ldb) { + port_allocations = hw->ldb_pp_allocations; + num_ports = DLB2_MAX_NUM_LDB_PORTS; + num_sort = DLB2_NUM_COS_DOMAINS; + } else { + port_allocations = hw->dir_pp_allocations; + num_ports = DLB2_MAX_NUM_DIR_PORTS(ver); + num_sort = 1; + } + + num_ports_per_sort = num_ports / num_sort; + dlb2_dev->enqueue_four = dlb2_movdir64b; DLB2_LOG_INFO(" for %s: cpu core used in pp profiling: %d\n", @@ -841,8 +852,7 @@ dlb2_get_pp_allocation(struct dlb2_hw *hw, int cpu, int port_type, int cos_id) memset(cos_cycles, 0, num_sort * sizeof(struct dlb2_pp_thread_data)); for (i = 0; i < num_ports; i++) { - int cos = is_ldb ? (i >> DLB2_NUM_COS_DOMAINS) : 0; - + int cos = (i >> DLB2_NUM_COS_DOMAINS) % DLB2_NUM_COS_DOMAINS; dlb2_thread_data[i].is_ldb = is_ldb; dlb2_thread_data[i].pp = i; dlb2_thread_data[i].cycles = 0; @@ -861,12 +871,17 @@ dlb2_get_pp_allocation(struct dlb2_hw *hw, int cpu, int port_type, int cos_id) DLB2_LOG_ERR(": thread join failed! err=%d", err); return; } - cos_cycles[cos].cycles += dlb2_thread_data[i].cycles; + + if (is_ldb) + cos_cycles[cos].cycles += dlb2_thread_data[i].cycles; if ((i + 1) % num_ports_per_sort == 0) { - int index = cos * num_ports_per_sort; + int index = 0; - cos_cycles[cos].pp = index; + if (is_ldb) { + cos_cycles[cos].pp = cos; + index = cos * num_ports_per_sort; + } /* * For LDB ports first sort with in a cos. Later sort * the best cos based on total cycles for the cos. @@ -880,21 +895,23 @@ dlb2_get_pp_allocation(struct dlb2_hw *hw, int cpu, int port_type, int cos_id) } /* - * Re-arrange best ports by cos if default cos is used. + * Sort by best cos aggregated over all ports per cos + * Note: After DLB2_MAX_NUM_LDB_PORTS sorted cos is stored and so'pp' + * is cos_id and not port id. */ - if (is_ldb && cos_id == DLB2_COS_DEFAULT) - qsort(cos_cycles, num_sort, - sizeof(struct dlb2_pp_thread_data), + if (is_ldb) { + qsort(cos_cycles, num_sort, sizeof(struct dlb2_pp_thread_data), dlb2_pp_cycle_comp); + for (i = 0; i < DLB2_NUM_COS_DOMAINS; i++) + port_allocations[i + DLB2_MAX_NUM_LDB_PORTS] = cos_cycles[i].pp; + } for (i = 0; i < num_ports; i++) { - int start = is_ldb ? cos_cycles[i / num_ports_per_sort].pp : 0; - int index = i % num_ports_per_sort; - - port_allocations[i] = dlb2_thread_data[start + index].pp; + port_allocations[i] = dlb2_thread_data[i].pp; DLB2_LOG_INFO(": pp %d cycles %d", port_allocations[i], - dlb2_thread_data[start + index].cycles); + dlb2_thread_data[i].cycles); } + } int @@ -903,11 +920,10 @@ dlb2_resource_probe(struct dlb2_hw *hw, const void *probe_args) const struct dlb2_devargs *args = (const struct dlb2_devargs *)probe_args; const char *mask = NULL; int cpu = 0, cnt = 0, cores[RTE_MAX_LCORE]; - int i, cos_id = DLB2_COS_DEFAULT; + int i; if (args) { mask = (const char *)args->producer_coremask; - cos_id = args->cos_id; } if (mask && rte_eal_parse_coremask(mask, cores)) { @@ -942,8 +958,8 @@ dlb2_resource_probe(struct dlb2_hw *hw, const void *probe_args) if (hw->num_prod_cores) cpu = hw->prod_core_list[0]; - dlb2_get_pp_allocation(hw, cpu, DLB2_LDB_PORT, cos_id); - dlb2_get_pp_allocation(hw, cpu, DLB2_DIR_PORT, DLB2_COS_DEFAULT); + dlb2_get_pp_allocation(hw, cpu, DLB2_LDB_PORT); + dlb2_get_pp_allocation(hw, cpu, DLB2_DIR_PORT); return 0; } @@ -4543,7 +4559,8 @@ dlb2_verify_create_ldb_port_args(struct dlb2_hw *hw, return -EINVAL; } - if (args->cos_id >= DLB2_NUM_COS_DOMAINS) { + if (args->cos_id >= DLB2_NUM_COS_DOMAINS && + (args->cos_id != DLB2_COS_DEFAULT || args->cos_strict)) { resp->status = DLB2_ST_INVALID_COS_ID; return -EINVAL; } @@ -4554,7 +4571,13 @@ dlb2_verify_create_ldb_port_args(struct dlb2_hw *hw, typeof(*port)); } else { for (i = 0; i < DLB2_NUM_COS_DOMAINS; i++) { - id = (args->cos_id + i) % DLB2_NUM_COS_DOMAINS; + if (args->cos_id == DLB2_COS_DEFAULT) { + /* Allocate from best performing cos */ + u32 cos_idx = i + DLB2_MAX_NUM_LDB_PORTS; + id = hw->ldb_pp_allocations[cos_idx]; + } else { + id = (args->cos_id + i) % DLB2_NUM_COS_DOMAINS; + } port = DLB2_DOM_LIST_HEAD(domain->avail_ldb_ports[id], typeof(*port));