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 5B492A09E4; Thu, 21 Jan 2021 13:35:02 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EFC2C140D41; Thu, 21 Jan 2021 13:35:01 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mails.dpdk.org (Postfix) with ESMTP id 498FE140D01 for ; Thu, 21 Jan 2021 13:35:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611232499; 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=taodCrjZOCWi+m1LaAr4LkmQYz3tSCKgQr1MatqXXnQ=; b=RI6gw9ChwCUpU9tQl58jAgYyrDJFNec7J6g77ghiJGxE6ZuHlt6wlTNdxyXIzDQqW8/VF7 0ouxtFNPqzmQqcsyHv8K+qIRmTArlaoaBAoRbb9NDDT/9/DYMrnsoy5lWFMcZTgKXatcnA ZHJWSZCphzX/aQIsQci4RYo7RvOzDPs= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-153-bzggDFT3M3mH2hvNatsJVA-1; Thu, 21 Jan 2021 07:34:55 -0500 X-MC-Unique: bzggDFT3M3mH2hvNatsJVA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7A4BA107ACE3; Thu, 21 Jan 2021 12:34:54 +0000 (UTC) Received: from [10.36.110.29] (unknown [10.36.110.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 243322C6BF; Thu, 21 Jan 2021 12:34:52 +0000 (UTC) To: Cheng Jiang , chenbo.xia@intel.com Cc: dev@dpdk.org, Jiayu.Hu@intel.com, YvonneX.Yang@intel.com, yinan.wang@intel.com References: <20201218113327.70528-1-Cheng1.jiang@intel.com> <20210112043857.19826-1-Cheng1.jiang@intel.com> <20210112043857.19826-2-Cheng1.jiang@intel.com> From: Maxime Coquelin Message-ID: <47b8dd37-be4e-c35c-3c5b-1cfd260d9f51@redhat.com> Date: Thu, 21 Jan 2021 13:34:50 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <20210112043857.19826-2-Cheng1.jiang@intel.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=maxime.coquelin@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v9 1/2] examples/vhost: add ioat ring space count and check 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 Sender: "dev" On 1/12/21 5:38 AM, Cheng Jiang wrote: > Add ioat ring space count and check, if ioat ring space is not enough > for the next async vhost packet enqueue, then just return to prevent > enqueue failure. Add rte_ioat_completed_ops() fail handler. > > Signed-off-by: Cheng Jiang > Reviewed-by: Jiayu Hu > Reviewed-by: Maxime Coquelin > --- > examples/vhost/ioat.c | 24 +++++++++++++----------- > 1 file changed, 13 insertions(+), 11 deletions(-) > > diff --git a/examples/vhost/ioat.c b/examples/vhost/ioat.c > index 71d8a1f1f..dbad28d43 100644 > --- a/examples/vhost/ioat.c > +++ b/examples/vhost/ioat.c > @@ -17,6 +17,7 @@ struct packet_tracker { > unsigned short next_read; > unsigned short next_write; > unsigned short last_remain; > + unsigned short ioat_space; > }; > > struct packet_tracker cb_tracker[MAX_VHOST_DEVICE]; > @@ -113,7 +114,7 @@ open_ioat(const char *value) > goto out; > } > rte_rawdev_start(dev_id); > - > + cb_tracker[dev_id].ioat_space = IOAT_RING_SIZE; > dma_info->nr++; > i++; > } > @@ -140,13 +141,9 @@ ioat_transfer_data_cb(int vid, uint16_t queue_id, > src = descs[i_desc].src; > dst = descs[i_desc].dst; > i_seg = 0; > + if (cb_tracker[dev_id].ioat_space < src->nr_segs) > + break; > while (i_seg < src->nr_segs) { > - /* > - * TODO: Assuming that the ring space of the > - * IOAT device is large enough, so there is no > - * error here, and the actual error handling > - * will be added later. > - */ > rte_ioat_enqueue_copy(dev_id, > (uintptr_t)(src->iov[i_seg].iov_base) > + src->offset, > @@ -158,7 +155,8 @@ ioat_transfer_data_cb(int vid, uint16_t queue_id, > i_seg++; > } > write &= mask; > - cb_tracker[dev_id].size_track[write] = i_seg; > + cb_tracker[dev_id].size_track[write] = src->nr_segs; > + cb_tracker[dev_id].ioat_space -= src->nr_segs; > write++; > } > } else { > @@ -178,17 +176,21 @@ ioat_check_completed_copies_cb(int vid, uint16_t queue_id, > { > if (!opaque_data) { > uintptr_t dump[255]; > - unsigned short n_seg; > + int n_seg; > unsigned short read, write; > unsigned short nb_packet = 0; > unsigned short mask = MAX_ENQUEUED_SIZE - 1; > unsigned short i; > + > int dev_id = dma_bind[vid].dmas[queue_id * 2 > + VIRTIO_RXQ].dev_id; > n_seg = rte_ioat_completed_ops(dev_id, 255, dump, dump); > - n_seg += cb_tracker[dev_id].last_remain; > - if (!n_seg) > + if (n_seg <= 0) > return 0; In a separate patch, it might make sense to propagate the error if rte_ioat_completed_ops return -1. Reviewed-by: Maxime Coquelin Maxime > + > + cb_tracker[dev_id].ioat_space += n_seg; > + n_seg += cb_tracker[dev_id].last_remain; > + > read = cb_tracker[dev_id].next_read; > write = cb_tracker[dev_id].next_write; > for (i = 0; i < max_packets; i++) { > -- > 2.29.2 >