From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id A17ED41B8E;
	Tue, 31 Jan 2023 12:29:34 +0100 (CET)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 3FAAB40DFB;
	Tue, 31 Jan 2023 12:29:34 +0100 (CET)
Received: from us-smtp-delivery-124.mimecast.com
 (us-smtp-delivery-124.mimecast.com [170.10.133.124])
 by mails.dpdk.org (Postfix) with ESMTP id B0F174067B
 for <dev@dpdk.org>; Tue, 31 Jan 2023 12:29:33 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;
 s=mimecast20190719; t=1675164573;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:content-type:content-type:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=KLRN8ZrDvhSzbqpAnEIswP7thkCrFZR9YT9QQLM2YNw=;
 b=CLNfz7B3Tk5R5L7rN9gAQUtfCBTk9hUxEyaNI+pw8OJWrKyTspN2a/mXZWHTinwcRURQ5g
 4xftWxFM0mvG4OSl7BCew7WrqTitv+GSOo0trXzTMrlzD3lniSd39ZOpdDRvC/VPGrMK2Y
 VgoSQnYL5u8x9JNpxCtgNVZERrey81Y=
Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com
 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS
 (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 us-mta-636-i8an8unJMn2lfUDAY8iUBA-1; Tue, 31 Jan 2023 06:29:22 -0500
X-MC-Unique: i8an8unJMn2lfUDAY8iUBA-1
Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com
 [10.11.54.6])
 (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
 (No client certificate requested)
 by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 216043802B80;
 Tue, 31 Jan 2023 11:29:22 +0000 (UTC)
Received: from [10.39.208.22] (unknown [10.39.208.22])
 by smtp.corp.redhat.com (Postfix) with ESMTPS id ED2F82166B33;
 Tue, 31 Jan 2023 11:29:20 +0000 (UTC)
Message-ID: <58e9fd37-30db-c902-13bf-136bf0415d2b@redhat.com>
Date: Tue, 31 Jan 2023 12:29:19 +0100
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
 Thunderbird/102.6.0
Subject: Re: [PATCH v1 08/13] test/bbdev: extend support for large TB
To: Hernan Vargas <hernan.vargas@intel.com>, dev@dpdk.org,
 gakhil@marvell.com, trix@redhat.com
Cc: nicolas.chautru@intel.com, qi.z.zhang@intel.com
References: <20230117165023.20567-1-hernan.vargas@intel.com>
 <20230117165023.20567-9-hernan.vargas@intel.com>
From: Maxime Coquelin <maxime.coquelin@redhat.com>
In-Reply-To: <20230117165023.20567-9-hernan.vargas@intel.com>
X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6
X-Mimecast-Spam-Score: 0
X-Mimecast-Originator: redhat.com
Content-Language: en-US
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
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>,
 <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>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org



On 1/17/23 17:50, Hernan Vargas wrote:
> Add support for large TB when it cannot fit into a true mbuf.
> 
> Signed-off-by: Hernan Vargas <hernan.vargas@intel.com>
> ---
>   app/test-bbdev/test_bbdev_perf.c | 21 ++++++++++++---------
>   1 file changed, 12 insertions(+), 9 deletions(-)
> 
> diff --git a/app/test-bbdev/test_bbdev_perf.c b/app/test-bbdev/test_bbdev_perf.c
> index 69b86cdeb1..fdf7a28ba2 100644
> --- a/app/test-bbdev/test_bbdev_perf.c
> +++ b/app/test-bbdev/test_bbdev_perf.c
> @@ -1072,8 +1072,6 @@ init_op_data_objs(struct rte_bbdev_op_data *bufs,
>   			 * Special case when DPDK mbuf cannot handle
>   			 * the required input size
>   			 */
> -			printf("Warning: Larger input size than DPDK mbuf %d\n",
> -					seg->length);
>   			large_input = true;
>   		}
>   		bufs[i].data = m_head;
> @@ -2030,6 +2028,7 @@ validate_op_chain(struct rte_bbdev_op_data *op,
>   	struct rte_mbuf *m = op->data;
>   	uint8_t nb_dst_segments = orig_op->nb_segments;
>   	uint32_t total_data_size = 0;
> +	bool ignore_mbuf = false; /* ignore mbuf limitations */
>   
>   	TEST_ASSERT(nb_dst_segments == m->nb_segs,
>   			"Number of segments differ in original (%u) and filled (%u) op",
> @@ -2042,21 +2041,25 @@ validate_op_chain(struct rte_bbdev_op_data *op,
>   		uint16_t data_len = rte_pktmbuf_data_len(m) - offset;
>   		total_data_size += orig_op->segments[i].length;
>   
> -		TEST_ASSERT(orig_op->segments[i].length == data_len,
> -				"Length of segment differ in original (%u) and filled (%u) op",
> -				orig_op->segments[i].length, data_len);
> +		if (orig_op->segments[i].length > RTE_BBDEV_LDPC_E_MAX_MBUF)
> +			ignore_mbuf = true;
> +		if (!ignore_mbuf)
> +			TEST_ASSERT(orig_op->segments[i].length == data_len,
> +					"Length of segment differ in original (%u) and filled (%u) op",
> +					orig_op->segments[i].length, data_len);
>   		TEST_ASSERT_BUFFERS_ARE_EQUAL(orig_op->segments[i].addr,
>   				rte_pktmbuf_mtod_offset(m, uint32_t *, offset),
> -				data_len,
> +				orig_op->segments[i].length,

Isn't it ending up in performing out of bounds access in the mbuf?

>   				"Output buffers (CB=%u) are not equal", i);
>   		m = m->next;
>   	}
>   
>   	/* Validate total mbuf pkt length */
>   	uint32_t pkt_len = rte_pktmbuf_pkt_len(op->data) - op->offset;
> -	TEST_ASSERT(total_data_size == pkt_len,
> -			"Length of data differ in original (%u) and filled (%u) op",
> -			total_data_size, pkt_len);
> +	if (!ignore_mbuf)
> +		TEST_ASSERT(total_data_size == pkt_len,
> +				"Length of data differ in original (%u) and filled (%u) op",
> +				total_data_size, pkt_len);
>   
>   	return TEST_SUCCESS;
>   }