From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (xvm-189-124.dc0.ghst.net [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 30CD3A09FF; Tue, 5 Jan 2021 02:19:54 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A7700160733; Tue, 5 Jan 2021 02:19:53 +0100 (CET) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id EBADF160715 for ; Tue, 5 Jan 2021 02:19:51 +0100 (CET) IronPort-SDR: GSaH2YAF43iYEPJ9NgSFifKh95TfgYXdRUw08N/vcziZqD8KBaraSCo6KtPj7QW/J9Wp4ebTcZ FS0LRXVUfX8A== X-IronPort-AV: E=McAfee;i="6000,8403,9854"; a="156227280" X-IronPort-AV: E=Sophos;i="5.78,475,1599548400"; d="scan'208";a="156227280" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jan 2021 17:19:50 -0800 IronPort-SDR: TaLMmai6EIKkHiaEyOBYvZzEo40HwWlD86j/P5tMgcUSr3+irn1c8fSjywzAB5jEKXZViCnJ7I 8IE+Vnqllnlg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.78,475,1599548400"; d="scan'208";a="569544113" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by fmsmga005.fm.intel.com with ESMTP; 04 Jan 2021 17:19:50 -0800 Received: from shsmsx605.ccr.corp.intel.com (10.109.6.215) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Mon, 4 Jan 2021 17:19:50 -0800 Received: from shsmsx606.ccr.corp.intel.com (10.109.6.216) by SHSMSX605.ccr.corp.intel.com (10.109.6.215) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 5 Jan 2021 09:19:48 +0800 Received: from shsmsx606.ccr.corp.intel.com ([10.109.6.216]) by SHSMSX606.ccr.corp.intel.com ([10.109.6.216]) with mapi id 15.01.1713.004; Tue, 5 Jan 2021 09:19:48 +0800 From: "Hu, Jiayu" To: "Jiang, Cheng1" , "maxime.coquelin@redhat.com" , "Xia, Chenbo" CC: "dev@dpdk.org" , "Yang, YvonneX" , "Wang, Yinan" Thread-Topic: [PATCH v6 1/2] examples/vhost: add ioat ring space count and check Thread-Index: AQHW4lhDXBG3r7AGdU6Tuv4fZuNQtKoYOibw Date: Tue, 5 Jan 2021 01:19:48 +0000 Message-ID: References: <20201218113327.70528-1-Cheng1.jiang@intel.com> <20210104045753.62487-1-Cheng1.jiang@intel.com> <20210104045753.62487-2-Cheng1.jiang@intel.com> In-Reply-To: <20210104045753.62487-2-Cheng1.jiang@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-reaction: no-action dlp-version: 11.5.1.3 dlp-product: dlpe-windows x-originating-ip: [10.239.127.36] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v6 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" Hi Cheng, > -----Original Message----- > From: Jiang, Cheng1 > Sent: Monday, January 4, 2021 12:58 PM > To: maxime.coquelin@redhat.com; Xia, Chenbo > Cc: dev@dpdk.org; Hu, Jiayu ; Yang, YvonneX > ; Wang, Yinan ; Jiang, > Cheng1 > Subject: [PATCH v6 1/2] examples/vhost: add ioat ring space count and che= ck >=20 > 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. >=20 > Signed-off-by: Cheng Jiang > --- > examples/vhost/ioat.c | 22 ++++++++++++---------- > 1 file changed, 12 insertions(+), 10 deletions(-) >=20 > diff --git a/examples/vhost/ioat.c b/examples/vhost/ioat.c > index 71d8a1f1f5..679d1e2f58 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; > }; >=20 > 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 =3D IOAT_RING_SIZE; > dma_info->nr++; > i++; > } > @@ -140,13 +141,9 @@ ioat_transfer_data_cb(int vid, uint16_t queue_id, > src =3D descs[i_desc].src; > dst =3D descs[i_desc].dst; > i_seg =3D 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 &=3D mask; > - cb_tracker[dev_id].size_track[write] =3D i_seg; > + cb_tracker[dev_id].size_track[write] =3D src->nr_segs; > + cb_tracker[dev_id].ioat_space -=3D 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 =3D 0; > unsigned short mask =3D MAX_ENQUEUED_SIZE - 1; > unsigned short i; > + > int dev_id =3D dma_bind[vid].dmas[queue_id * 2 > + VIRTIO_RXQ].dev_id; > n_seg =3D rte_ioat_completed_ops(dev_id, 255, dump, dump); > - n_seg +=3D cb_tracker[dev_id].last_remain; > if (!n_seg) > return 0; > + > + cb_tracker[dev_id].ioat_space +=3D n_seg; > + n_seg +=3D cb_tracker[dev_id].last_remain; When error happens in rte_ioat_completed_ops(), where n_seg is -1, the value of "!n_seg" is false (0) and it can still pass the check of "if". Thanks, Jiayu > + > read =3D cb_tracker[dev_id].next_read; > write =3D cb_tracker[dev_id].next_write; > for (i =3D 0; i < max_packets; i++) { > -- > 2.29.2