Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id ABA86C83030 for ; Tue, 8 Jul 2025 00:58:55 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 5D976840BE; Tue, 8 Jul 2025 00:58:55 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id V4S6E6RCKoh0; Tue, 8 Jul 2025 00:58:54 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.166.142; helo=lists1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 91934840BF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1751936334; bh=P9FDnZhHxjyC8B0N/AbiXE3kuN7+XVn4birvZ5/SB58=; h=From:To:Cc:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=o/i8+rXBXp0Zvl6VCxGJIVjNuExObD9lBG8vnYyrSh//sIIJYdjNAzCg4GG7lPQ+Q dls2RGR+4C5zJnYvcNnZtY8vK6xMqoyCbwGVmZOhBlNwounKIo/+PJRjQGNEZc9iQw MRUUWxUBGcNk43oK+hC/Jflc2JP5p5NYKwT47aAmptHhFRuTDvwb0Sk6RrHdMD15ui zul8ve4vXjMY2Tf+iMZPAytpx+70fIk7p0RCPxLmjCv4GKGs7GURuE6+txPfJ0rLVU RqWZ/nhCXpi+jSdFUUuWZeg1ZqxyIqj0ESgddRp6OCXYJtaji4hUK0/YAjkObNcMIx 0OoiU6RlJgGLA== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp1.osuosl.org (Postfix) with ESMTP id 91934840BF; Tue, 8 Jul 2025 00:58:54 +0000 (UTC) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists1.osuosl.org (Postfix) with ESMTP id 766B915F for ; Tue, 8 Jul 2025 00:58:51 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 5CE3140EB2 for ; Tue, 8 Jul 2025 00:58:51 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id kvRFrpOTIQ7B for ; Tue, 8 Jul 2025 00:58:50 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=192.198.163.15; helo=mgamail.intel.com; envelope-from=pavan.kumar.linga@intel.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp2.osuosl.org 7A3FB4015F DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 7A3FB4015F Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) by smtp2.osuosl.org (Postfix) with ESMTPS id 7A3FB4015F for ; Tue, 8 Jul 2025 00:58:50 +0000 (UTC) X-CSE-ConnectionGUID: +Pq7bByeTyiVwFcWYnj1yw== X-CSE-MsgGUID: IKR0IT39SzuQzw7vHZmy/g== X-IronPort-AV: E=McAfee;i="6800,10657,11487"; a="54307577" X-IronPort-AV: E=Sophos;i="6.16,295,1744095600"; d="scan'208";a="54307577" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jul 2025 17:58:47 -0700 X-CSE-ConnectionGUID: a/62FwlRTQKErCNu1P02Lg== X-CSE-MsgGUID: PNsP6eMCSJSnZ/x0fqbN+Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,295,1744095600"; d="scan'208";a="159695493" Received: from unknown (HELO localhost.jf.intel.com) ([10.166.80.55]) by orviesa003.jf.intel.com with ESMTP; 07 Jul 2025 17:58:47 -0700 From: Pavan Kumar Linga To: intel-wired-lan@lists.osuosl.org Cc: Pavan Kumar Linga , Anton Nadezhdin Date: Mon, 7 Jul 2025 17:58:30 -0700 Message-ID: <20250708005837.18510-3-pavan.kumar.linga@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250708005837.18510-1-pavan.kumar.linga@intel.com> References: <20250708005837.18510-1-pavan.kumar.linga@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1751936330; x=1783472330; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=L7iFmqV7pP5hiHIvmuGRttSkqI5mtJfOdSVbO79wvcY=; b=Om+/I0/Ju1acwB5NCO9wfPxEqiDa7oX5v4upwFsZpslaNeYaZ6oL1dNl J2MGpY9PlgYUUUFMv8GMbyCnkqcjWQ5sS0cXCxksUBUCtxeijmTeq34+n W2idMzWx4wydBGF/bU2b0DQoyGjXedjRqZ3+NWGlHPeaffjQYArBXuNo1 QFewqjvPpQZvncStXQV7QeiWLHdqqtLMkdvH1Sl4SjeUczVQ++4HwxCUX sezp8p4JQ5hx96I7ByYhwnUeefwipgvYqXXtMVeQVDjnBACINZ/a+wty5 pTNvvSlqka1zYXK/Dw8sT71gtu8WGfpEmMm5X59q7Qu5oIEL8H1p/ZrmK g==; X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dmarc=pass (p=none dis=none) header.from=intel.com X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=Om+/I0/J Subject: [Intel-wired-lan] [PATCH net-next v6 2/9] idpf: use existing queue chunk info instead of preparing it X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" Queue chunk info received from the device control plane is stored in the persistent data section. Necessary info from these chunks is parsed and stored in the queue structure. While sending the enable/disable queues virtchnl message, queue chunk info is prepared using the stored queue info. Instead of that, use the stored queue chunks directly which has info about all the queues that needs to be enabled/disabled. Reviewed-by: Anton Nadezhdin Signed-off-by: Pavan Kumar Linga --- drivers/net/ethernet/intel/idpf/idpf_lib.c | 6 +- .../net/ethernet/intel/idpf/idpf_virtchnl.c | 188 +++++------------- .../net/ethernet/intel/idpf/idpf_virtchnl.h | 6 +- 3 files changed, 52 insertions(+), 148 deletions(-) diff --git a/drivers/net/ethernet/intel/idpf/idpf_lib.c b/drivers/net/ethernet/intel/idpf/idpf_lib.c index 2579e751370b..6d9be0b69f45 100644 --- a/drivers/net/ethernet/intel/idpf/idpf_lib.c +++ b/drivers/net/ethernet/intel/idpf/idpf_lib.c @@ -852,7 +852,7 @@ static void idpf_vport_stop(struct idpf_vport *vport) chunks = &vport->adapter->vport_config[vport->idx]->qid_reg_info; idpf_send_disable_vport_msg(vport); - idpf_send_disable_queues_msg(vport); + idpf_send_disable_queues_msg(vport, chunks); idpf_send_map_unmap_queue_vector_msg(vport, false); /* Normally we ask for queues in create_vport, but if the number of * initially requested queues have changed, for example via ethtool @@ -1414,7 +1414,7 @@ static int idpf_vport_open(struct idpf_vport *vport) goto rxq_deinit; } - err = idpf_send_enable_queues_msg(vport); + err = idpf_send_enable_queues_msg(vport, chunks); if (err) { dev_err(&adapter->pdev->dev, "Failed to enable queues for vport %u: %d\n", vport->vport_id, err); @@ -1455,7 +1455,7 @@ static int idpf_vport_open(struct idpf_vport *vport) disable_vport: idpf_send_disable_vport_msg(vport); disable_queues: - idpf_send_disable_queues_msg(vport); + idpf_send_disable_queues_msg(vport, chunks); unmap_queue_vectors: idpf_send_map_unmap_queue_vector_msg(vport, false); rxq_deinit: diff --git a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c index 89d2c9d7236d..1b3f9296dd93 100644 --- a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +++ b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.c @@ -1003,6 +1003,24 @@ static void idpf_init_avail_queues(struct idpf_adapter *adapter) avail_queues->avail_complq = le16_to_cpu(caps->max_tx_complq); } +/** + * idpf_convert_reg_to_queue_chunks - copy queue chunk information to the right + * structure + * @dchunks: destination chunks to store data to + * @schunks: source chunks to copy data from + * @num_chunks: number of chunks to copy + */ +static void idpf_convert_reg_to_queue_chunks(struct virtchnl2_queue_chunk *dchunks, + struct idpf_queue_id_reg_chunk *schunks, + u16 num_chunks) +{ + for (u16 i = 0; i < num_chunks; i++) { + dchunks[i].type = cpu_to_le32(schunks[i].type); + dchunks[i].start_queue_id = cpu_to_le32(schunks[i].start_queue_id); + dchunks[i].num_queues = cpu_to_le32(schunks[i].num_queues); + } +} + /** * idpf_vport_init_queue_reg_chunks - initialize queue register chunks * @vport_config: persistent vport structure to store the queue register info @@ -1735,116 +1753,20 @@ static int idpf_send_config_rx_queues_msg(struct idpf_vport *vport) * idpf_send_ena_dis_queues_msg - Send virtchnl enable or disable * queues message * @vport: virtual port data structure + * @chunks: queue register info * @ena: if true enable, false disable * * Send enable or disable queues virtchnl message. Returns 0 on success, * negative on failure. */ -static int idpf_send_ena_dis_queues_msg(struct idpf_vport *vport, bool ena) +static int idpf_send_ena_dis_queues_msg(struct idpf_vport *vport, + struct idpf_queue_id_reg_info *chunks, + bool ena) { struct virtchnl2_del_ena_dis_queues *eq __free(kfree) = NULL; - struct virtchnl2_queue_chunk *qc __free(kfree) = NULL; - u32 num_msgs, num_chunks, num_txq, num_rxq, num_q; struct idpf_vc_xn_params xn_params = {}; - struct virtchnl2_queue_chunks *qcs; - u32 config_sz, chunk_sz, buf_sz; + u32 num_chunks, buf_sz; ssize_t reply_sz; - int i, j, k = 0; - - num_txq = vport->num_txq + vport->num_complq; - num_rxq = vport->num_rxq + vport->num_bufq; - num_q = num_txq + num_rxq; - buf_sz = sizeof(struct virtchnl2_queue_chunk) * num_q; - qc = kzalloc(buf_sz, GFP_KERNEL); - if (!qc) - return -ENOMEM; - - for (i = 0; i < vport->num_txq_grp; i++) { - struct idpf_txq_group *tx_qgrp = &vport->txq_grps[i]; - - for (j = 0; j < tx_qgrp->num_txq; j++, k++) { - qc[k].type = cpu_to_le32(VIRTCHNL2_QUEUE_TYPE_TX); - qc[k].start_queue_id = cpu_to_le32(tx_qgrp->txqs[j]->q_id); - qc[k].num_queues = cpu_to_le32(IDPF_NUMQ_PER_CHUNK); - } - } - if (vport->num_txq != k) - return -EINVAL; - - if (!idpf_is_queue_model_split(vport->txq_model)) - goto setup_rx; - - for (i = 0; i < vport->num_txq_grp; i++, k++) { - struct idpf_txq_group *tx_qgrp = &vport->txq_grps[i]; - - qc[k].type = cpu_to_le32(VIRTCHNL2_QUEUE_TYPE_TX_COMPLETION); - qc[k].start_queue_id = cpu_to_le32(tx_qgrp->complq->q_id); - qc[k].num_queues = cpu_to_le32(IDPF_NUMQ_PER_CHUNK); - } - if (vport->num_complq != (k - vport->num_txq)) - return -EINVAL; - -setup_rx: - for (i = 0; i < vport->num_rxq_grp; i++) { - struct idpf_rxq_group *rx_qgrp = &vport->rxq_grps[i]; - - if (idpf_is_queue_model_split(vport->rxq_model)) - num_rxq = rx_qgrp->splitq.num_rxq_sets; - else - num_rxq = rx_qgrp->singleq.num_rxq; - - for (j = 0; j < num_rxq; j++, k++) { - if (idpf_is_queue_model_split(vport->rxq_model)) { - qc[k].start_queue_id = - cpu_to_le32(rx_qgrp->splitq.rxq_sets[j]->rxq.q_id); - qc[k].type = - cpu_to_le32(VIRTCHNL2_QUEUE_TYPE_RX); - } else { - qc[k].start_queue_id = - cpu_to_le32(rx_qgrp->singleq.rxqs[j]->q_id); - qc[k].type = - cpu_to_le32(VIRTCHNL2_QUEUE_TYPE_RX); - } - qc[k].num_queues = cpu_to_le32(IDPF_NUMQ_PER_CHUNK); - } - } - if (vport->num_rxq != k - (vport->num_txq + vport->num_complq)) - return -EINVAL; - - if (!idpf_is_queue_model_split(vport->rxq_model)) - goto send_msg; - - for (i = 0; i < vport->num_rxq_grp; i++) { - struct idpf_rxq_group *rx_qgrp = &vport->rxq_grps[i]; - - for (j = 0; j < vport->num_bufqs_per_qgrp; j++, k++) { - const struct idpf_buf_queue *q; - - q = &rx_qgrp->splitq.bufq_sets[j].bufq; - qc[k].type = - cpu_to_le32(VIRTCHNL2_QUEUE_TYPE_RX_BUFFER); - qc[k].start_queue_id = cpu_to_le32(q->q_id); - qc[k].num_queues = cpu_to_le32(IDPF_NUMQ_PER_CHUNK); - } - } - if (vport->num_bufq != k - (vport->num_txq + - vport->num_complq + - vport->num_rxq)) - return -EINVAL; - -send_msg: - /* Chunk up the queue info into multiple messages */ - config_sz = sizeof(struct virtchnl2_del_ena_dis_queues); - chunk_sz = sizeof(struct virtchnl2_queue_chunk); - - num_chunks = min_t(u32, IDPF_NUM_CHUNKS_PER_MSG(config_sz, chunk_sz), - num_q); - num_msgs = DIV_ROUND_UP(num_q, num_chunks); - - buf_sz = struct_size(eq, chunks.chunks, num_chunks); - eq = kzalloc(buf_sz, GFP_KERNEL); - if (!eq) - return -ENOMEM; if (ena) { xn_params.vc_op = VIRTCHNL2_OP_ENABLE_QUEUES; @@ -1854,27 +1776,23 @@ static int idpf_send_ena_dis_queues_msg(struct idpf_vport *vport, bool ena) xn_params.timeout_ms = IDPF_VC_XN_MIN_TIMEOUT_MSEC; } - for (i = 0, k = 0; i < num_msgs; i++) { - memset(eq, 0, buf_sz); - eq->vport_id = cpu_to_le32(vport->vport_id); - eq->chunks.num_chunks = cpu_to_le16(num_chunks); - qcs = &eq->chunks; - memcpy(qcs->chunks, &qc[k], chunk_sz * num_chunks); + num_chunks = chunks->num_chunks; + buf_sz = struct_size(eq, chunks.chunks, num_chunks); + eq = kzalloc(buf_sz, GFP_KERNEL); + if (!eq) + return -ENOMEM; - xn_params.send_buf.iov_base = eq; - xn_params.send_buf.iov_len = buf_sz; - reply_sz = idpf_vc_xn_exec(vport->adapter, &xn_params); - if (reply_sz < 0) - return reply_sz; + eq->vport_id = cpu_to_le32(vport->vport_id); + eq->chunks.num_chunks = cpu_to_le16(num_chunks); - k += num_chunks; - num_q -= num_chunks; - num_chunks = min(num_chunks, num_q); - /* Recalculate buffer size */ - buf_sz = struct_size(eq, chunks.chunks, num_chunks); - } + idpf_convert_reg_to_queue_chunks(eq->chunks.chunks, chunks->queue_chunks, + num_chunks); - return 0; + xn_params.send_buf.iov_base = eq; + xn_params.send_buf.iov_len = buf_sz; + reply_sz = idpf_vc_xn_exec(vport->adapter, &xn_params); + + return reply_sz < 0 ? reply_sz : 0; } /** @@ -2021,53 +1939,37 @@ int idpf_send_map_unmap_queue_vector_msg(struct idpf_vport *vport, bool map) /** * idpf_send_enable_queues_msg - send enable queues virtchnl message * @vport: Virtual port private data structure + * @chunks: queue ids received over mailbox * * Will send enable queues virtchnl message. Returns 0 on success, negative on * failure. */ -int idpf_send_enable_queues_msg(struct idpf_vport *vport) +int idpf_send_enable_queues_msg(struct idpf_vport *vport, + struct idpf_queue_id_reg_info *chunks) { - return idpf_send_ena_dis_queues_msg(vport, true); + return idpf_send_ena_dis_queues_msg(vport, chunks, true); } /** * idpf_send_disable_queues_msg - send disable queues virtchnl message * @vport: Virtual port private data structure + * @chunks: queue ids received over mailbox * * Will send disable queues virtchnl message. Returns 0 on success, negative * on failure. */ -int idpf_send_disable_queues_msg(struct idpf_vport *vport) +int idpf_send_disable_queues_msg(struct idpf_vport *vport, + struct idpf_queue_id_reg_info *chunks) { int err; - err = idpf_send_ena_dis_queues_msg(vport, false); + err = idpf_send_ena_dis_queues_msg(vport, chunks, false); if (err) return err; return idpf_wait_for_marker_event(vport); } -/** - * idpf_convert_reg_to_queue_chunks - Copy queue chunk information to the right - * structure - * @dchunks: Destination chunks to store data to - * @schunks: Source chunks to copy data from - * @num_chunks: number of chunks to copy - */ -static void idpf_convert_reg_to_queue_chunks(struct virtchnl2_queue_chunk *dchunks, - struct idpf_queue_id_reg_chunk *schunks, - u16 num_chunks) -{ - u16 i; - - for (i = 0; i < num_chunks; i++) { - dchunks[i].type = cpu_to_le32(schunks[i].type); - dchunks[i].start_queue_id = cpu_to_le32(schunks[i].start_queue_id); - dchunks[i].num_queues = cpu_to_le32(schunks[i].num_queues); - } -} - /** * idpf_send_delete_queues_msg - send delete queues virtchnl message * @vport: virtual port private data structure diff --git a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.h b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.h index 27fc406a424c..3f7e5e6b235d 100644 --- a/drivers/net/ethernet/intel/idpf/idpf_virtchnl.h +++ b/drivers/net/ethernet/intel/idpf/idpf_virtchnl.h @@ -134,8 +134,10 @@ int idpf_send_add_queues_msg(const struct idpf_vport *vport, u16 num_tx_q, u16 num_complq, u16 num_rx_q, u16 num_rx_bufq); int idpf_send_delete_queues_msg(struct idpf_vport *vport, struct idpf_queue_id_reg_info *chunks); -int idpf_send_enable_queues_msg(struct idpf_vport *vport); -int idpf_send_disable_queues_msg(struct idpf_vport *vport); +int idpf_send_enable_queues_msg(struct idpf_vport *vport, + struct idpf_queue_id_reg_info *chunks); +int idpf_send_disable_queues_msg(struct idpf_vport *vport, + struct idpf_queue_id_reg_info *chunks); int idpf_send_config_queues_msg(struct idpf_vport *vport); int idpf_vport_alloc_vec_indexes(struct idpf_vport *vport); -- 2.43.0