From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 28B5245C9F; Thu, 7 Nov 2024 14:47:05 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 924AF42FE3; Thu, 7 Nov 2024 14:46:28 +0100 (CET) Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) by mails.dpdk.org (Postfix) with ESMTP id 60A2142FE3 for ; Thu, 7 Nov 2024 14:46:27 +0100 (CET) Received: by mail-pj1-f43.google.com with SMTP id 98e67ed59e1d1-2e2a999b287so791483a91.0 for ; Thu, 07 Nov 2024 05:46:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1730987186; x=1731591986; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ooeSIz1mA8ouIIEgQJBWB1TsANr26948K2N9ewZ1mJk=; b=DGQtav3hjvEaAabtgLdKBbtl7OuHJw9vZ8dxJcNTxQF9ZdDWdjjK7wDCiMiW9xAR8b jDskRjW+6iZ9CK//S+/nJGlvzgE+Rmf1jyaG41g1pLxaBB4Z3+L7VvVdgnVI3j86LexJ cjwxLxoK6OC7Xj81qAxz6ZNCNzuGcvlGQ0RE4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730987186; x=1731591986; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ooeSIz1mA8ouIIEgQJBWB1TsANr26948K2N9ewZ1mJk=; b=ZxoVZeqmpZGc5DynB661bCP9z6Xtf4pMhzT5NsMaDcpMmmReWodpH8b/PdKoPsxYdL AcVlLmO3Gus4CrZmLpuF7s3ELwJt1KksfaJOmDO17CLULQm2H/yOiubowL3zqHleTjQI mFVaygs4mqwRQjs66cATPPOsYc+BIFX6A48KoxBcJ7uS/tnKguJK+1yAqKq3pgMX+BKL pWCFDotU8Eq8tkFz7z8XVLmdfK9ImDI7DxKdJys4Bm4NTjdCZXnvz5Xqh8CsL140rzNI tELDGvhfpO6e25Y1sKOZRb/hluRuNsw5D37vtdTL0+i/JQpjcD6U+ZMifyNZ/mUokSVL OZMw== X-Gm-Message-State: AOJu0Yxd2seegj1TBGExL/sj5uk3Z/niyhv37ox9A3Z8GDS+JJzXaGZ1 dNIyi5dP9aZ1zhzXr0gWrhmX07Rb2MbIBsWcgMhduIW3HwAMrY9eJJkO6yxjscNBkiRtxJhYhyh rAYl/mqSVpjTxXSu0Kn399vab4vPMuFo4dz86R05Yw4QQgCQjVFSdghHKsSOGDqpF7DCwlxJisq JkJXyhvY3jYUuACxD1AaKOonay3q1ynI0QMAHpFvdgsg== X-Google-Smtp-Source: AGHT+IFHrOdun7Rsg1W65sN1zAFTKbVLI68bwJPF1NKYF0JBBuKN9EQDhrrv2VI2b5YsiBi7UPL9jQ== X-Received: by 2002:a17:90b:3943:b0:2dd:4f6b:638d with SMTP id 98e67ed59e1d1-2e9ab04fe57mr1389633a91.17.1730987185852; Thu, 07 Nov 2024 05:46:25 -0800 (PST) Received: from dhcp-10-123-154-23.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e9a5f52969sm1409878a91.2.2024.11.07.05.46.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Nov 2024 05:46:25 -0800 (PST) From: Sriharsha Basavapatna To: dev@dpdk.org Cc: Randy Schacher , Sriharsha Basavapatna , Kishore Padmanabha , Ajit Khaparde Subject: [PATCH v8 36/47] net/bnxt: tf_ulp: add support for rss flow query to ULP Date: Thu, 7 Nov 2024 19:22:43 +0530 Message-Id: <20241107135254.1611676-37-sriharsha.basavapatna@broadcom.com> X-Mailer: git-send-email 2.39.0.189.g4dbebc36b0 In-Reply-To: <20241107135254.1611676-1-sriharsha.basavapatna@broadcom.com> References: <20241107135254.1611676-1-sriharsha.basavapatna@broadcom.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 From: Randy Schacher Support flow query rss command for truflow in ULP layer. Signed-off-by: Randy Schacher Signed-off-by: Sriharsha Basavapatna Reviewed-by: Kishore Padmanabha Reviewed-by: Ajit Khaparde --- drivers/net/bnxt/bnxt_vnic.c | 39 +++++++++++++- drivers/net/bnxt/bnxt_vnic.h | 6 +++ drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c | 71 +++++++++++++++++++++++++ 3 files changed, 114 insertions(+), 2 deletions(-) diff --git a/drivers/net/bnxt/bnxt_vnic.c b/drivers/net/bnxt/bnxt_vnic.c index 29124a6b9d..7b028f2ee5 100644 --- a/drivers/net/bnxt/bnxt_vnic.c +++ b/drivers/net/bnxt/bnxt_vnic.c @@ -30,6 +30,7 @@ ((BNXT_VNIC_BITMAP_SIZE - 1) - \ ((i) % BNXT_VNIC_BITMAP_SIZE))) & 1) +static uint16_t rss_query_queues[BNXT_VNIC_MAX_QUEUE_SIZE]; /* * VNIC Functions */ @@ -777,16 +778,21 @@ bnxt_vnic_rss_create(struct bnxt *bp, } /* hwrm_type conversion */ + vnic->hash_f = rss_info->rss_func; + vnic->rss_types = rss_info->rss_types; vnic->hash_type = bnxt_rte_to_hwrm_hash_types(rss_info->rss_types); vnic->hash_mode = bnxt_rte_to_hwrm_hash_level(bp, rss_info->rss_types, rss_info->rss_level); /* configure the key */ - if (!rss_info->key_len) + if (!rss_info->key_len) { /* If hash key has not been specified, use random hash key.*/ bnxt_prandom_bytes(vnic->rss_hash_key, HW_HASH_KEY_SIZE); - else + vnic->key_len = HW_HASH_KEY_SIZE; + } else { memcpy(vnic->rss_hash_key, rss_info->key, rss_info->key_len); + vnic->key_len = rss_info->key_len; + } /* Prepare the indirection table */ bnxt_vnic_populate_rss_table(bp, vnic); @@ -820,6 +826,35 @@ bnxt_vnic_rss_create(struct bnxt *bp, return NULL; } +void +bnxt_vnic_rss_query_info_fill(struct bnxt *bp, + struct rte_flow_action_rss *rss_conf, + uint16_t vnic_id) +{ + struct bnxt_vnic_info *vnic_info; + int idx; + + vnic_info = bnxt_vnic_queue_db_get_vnic(bp, vnic_id); + if (vnic_info == NULL) { + PMD_DRV_LOG_LINE(ERR, "lookup failed for id %d", vnic_id); + return; + } + + rss_conf->key_len = vnic_info->key_len; + rss_conf->key = vnic_info->rss_hash_key; + rss_conf->func = vnic_info->hash_f; + rss_conf->level = vnic_info->hash_mode; + rss_conf->types = vnic_info->rss_types; + + memset(rss_query_queues, 0, sizeof(rss_query_queues)); + for (idx = 0; idx < BNXT_VNIC_MAX_QUEUE_SIZE; idx++) + if (BNXT_VNIC_BITMAP_GET(vnic_info->queue_bitmap, idx)) { + rss_query_queues[rss_conf->queue_num] = idx; + rss_conf->queue_num += 1; + } + rss_conf->queue = (const uint16_t *)&rss_query_queues; +} + int32_t bnxt_vnic_rss_queue_status_update(struct bnxt *bp, struct bnxt_vnic_info *vnic) { diff --git a/drivers/net/bnxt/bnxt_vnic.h b/drivers/net/bnxt/bnxt_vnic.h index fe3fc4e540..c4a7c5257c 100644 --- a/drivers/net/bnxt/bnxt_vnic.h +++ b/drivers/net/bnxt/bnxt_vnic.h @@ -75,10 +75,13 @@ struct bnxt_vnic_info { bool rss_dflt_cr; uint16_t ref_cnt; uint64_t queue_bitmap[BNXT_VNIC_MAX_QUEUE_SZ_IN_64BITS]; + uint64_t rss_types; + uint32_t key_len; /**< Hash key length in bytes. */ STAILQ_HEAD(, bnxt_filter_info) filter; STAILQ_HEAD(, rte_flow) flow_list; uint8_t ring_select_mode; + enum rte_eth_hash_function hash_f; enum rte_eth_hash_function hash_f_local; uint64_t rss_types_local; uint8_t metadata_format; @@ -121,6 +124,9 @@ int32_t bnxt_vnic_queue_db_init(struct bnxt *bp); int32_t bnxt_vnic_queue_db_deinit(struct bnxt *bp); void bnxt_vnic_queue_db_update_dlft_vnic(struct bnxt *bp); +void bnxt_vnic_rss_query_info_fill(struct bnxt *bp, + struct rte_flow_action_rss *rss_conf, + uint16_t vnic_id); int32_t bnxt_vnic_rss_queue_status_update(struct bnxt *bp, struct bnxt_vnic_info *vnic); diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c b/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c index 85fb03e922..4c99c785c0 100644 --- a/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c +++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp_flow.c @@ -577,6 +577,66 @@ bnxt_ulp_flow_flush(struct rte_eth_dev *eth_dev, return ret; } +/* + * Fill the rte_flow_query_rss 'rss_conf' argument passed + * in the rte_flow_query() with the values obtained and + * accumulated locally. + * + * ctxt [in] The ulp context for the flow counter manager + * + * flow_id [in] The HW flow ID + * + * rss_conf [out] The rte_flow_query_count 'data' that is set + * + */ +static int ulp_flow_query_rss_get(struct bnxt_ulp_context *ctxt, + uint32_t flow_id, + struct rte_flow_action_rss *rss_conf) +{ + struct ulp_flow_db_res_params params; + uint32_t nxt_resource_index = 0; + bool found_cntr_resource = false; + struct bnxt *bp; + uint16_t vnic_id = 0; + int rc = 0; + + bp = bnxt_ulp_cntxt_bp_get(ctxt); + if (!bp) { + BNXT_DRV_DBG(ERR, "Failed to get bp from ulp cntxt\n"); + return -EINVAL; + } + + if (bnxt_ulp_cntxt_acquire_fdb_lock(ctxt)) { + BNXT_DRV_DBG(ERR, "Flow db lock acquire failed\n"); + return -EINVAL; + } + do { + rc = ulp_flow_db_resource_get(ctxt, + BNXT_ULP_FDB_TYPE_REGULAR, + flow_id, + &nxt_resource_index, + ¶ms); + if (params.resource_func == + BNXT_ULP_RESOURCE_FUNC_VNIC_TABLE && + (params.resource_sub_type == + BNXT_ULP_RESOURCE_SUB_TYPE_VNIC_TABLE_RSS || + params.resource_sub_type == + BNXT_ULP_RESOURCE_SUB_TYPE_VNIC_TABLE_QUEUE)) { + vnic_id = params.resource_hndl; + found_cntr_resource = true; + break; + } + + } while (!rc && nxt_resource_index); + + if (found_cntr_resource) + bnxt_vnic_rss_query_info_fill(bp, rss_conf, vnic_id); + + bnxt_ulp_cntxt_release_fdb_lock(ctxt); + + return rc; +} + /* Function to query the rte flows. */ static int32_t bnxt_ulp_flow_query(struct rte_eth_dev *eth_dev, @@ -587,6 +647,7 @@ bnxt_ulp_flow_query(struct rte_eth_dev *eth_dev, { int rc = 0; struct bnxt_ulp_context *ulp_ctx; + struct rte_flow_action_rss *rss_conf; struct rte_flow_query_count *count; uint32_t flow_id; @@ -602,6 +663,16 @@ bnxt_ulp_flow_query(struct rte_eth_dev *eth_dev, flow_id = (uint32_t)(uintptr_t)flow; switch (action->type) { + case RTE_FLOW_ACTION_TYPE_RSS: + rss_conf = (struct rte_flow_action_rss *)data; + rc = ulp_flow_query_rss_get(ulp_ctx, flow_id, rss_conf); + if (rc) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_HANDLE, NULL, + "Failed to query RSS info."); + } + + break; case RTE_FLOW_ACTION_TYPE_COUNT: count = data; rc = ulp_fc_mgr_query_count_get(ulp_ctx, flow_id, count); -- 2.39.3