host-drivers/base-driver/vca/vop/vop_kvec_buff.c
void vop_kvec_buf_update(struct vop_dev_common *cdev)
{
	struct vop_device *vdev;
	struct vop_kvec_buff *kvec_buff;
	struct vop_vringh* vringh;
	struct vringh_kiov* wiov;
	u16 head = USHRT_MAX;
	int ring_id;
	unsigned cnt_size[KVEC_BUF_NUM], cnt_total = 0;

	if (!cdev || !cdev->ready) {
		return;
	}

	kvec_buff = &cdev->kvec_buff;
	kvec_buff->remote_write_kvecs.is_update = true;

	vdev = cdev->vdev;
	vringh = cdev->vringh_rcv;
	wiov = &kvec_buff->remote_write_kvecs.kiov;
	memset(cnt_size, 0, sizeof (cnt_size));

	if (!kvec_buff->remote_write_kvecs.mapped) {
		dev_err(&vdev->dev, "%s not ready remote rings\n", __func__);
		kvec_buff->remote_write_kvecs.is_update = false;
		return;
	}

	common_dev_notify_avail(cdev);

	while(vop_common_get_descriptors_with_lock(cdev, &vringh->vrh, &head, wiov, false) > 0) {
		dev_dbg(&vdev->dev,
			"%s fetched %d descriptors from local queue\n",
			__func__, wiov->used);

		ring_id = vop_kvec_put(cdev, wiov, &head);
		if (ring_id >= 0) {
			++cnt_size[ring_id];
			++cnt_total;
			++kvec_buff->remote_write_kvecs.rings[ring_id].stats_num;
			head = USHRT_MAX;

			if ( !((cnt_total) % KVEC_INDEX_UPDATE_PERIOD) && cnt_total) {
				vop_kvec_buff_update_idx(cdev, cnt_size);
			}
		}
	}

	vop_kvec_buff_update_idx(cdev, cnt_size);
	kvec_buff->remote_write_kvecs.is_update = false;
}
/**
 * vop_kvec_update_buf - put decriptors from local vring to a ring buffer
 * allocated by the other host. Ring buffer is used instead of sharing
 * vring memory directly to reduce number of transactions on the shared
 * memory - this function issues writes only eliminating reads.
 * */
put decriptors from local vring to a ring buffer
allocated by the other host. Ring buffer is used instead of sharing
vring memory directly to reduce number of transactions on the shared
memory - this function issues writes only eliminating reads.
put decriptors from local vring to a ring buffer allocated by the other host . Ring buffer is used instead of sharing vring memory directly to reduce number of transactions on the shared memory - this function issues writes only eliminating reads .
void vop_kvec_buf_update(struct vop_dev_common *cdev)
{
	struct vop_device *vdev;
	struct vop_kvec_buff *kvec_buff;
	struct vop_vringh* vringh;
	struct vringh_kiov* wiov;
	u16 head = USHRT_MAX;
	int ring_id;
	unsigned cnt_size[KVEC_BUF_NUM], cnt_total = 0;
	if (!cdev || !cdev->ready) {
		return;
	}
	kvec_buff = &cdev->kvec_buff;
	kvec_buff->remote_write_kvecs.is_update = true;
	vdev = cdev->vdev;
	vringh = cdev->vringh_rcv;
	wiov = &kvec_buff->remote_write_kvecs.kiov;
	memset(cnt_size, 0, sizeof (cnt_size));
	if (!kvec_buff->remote_write_kvecs.mapped) {
		dev_err(&vdev->dev, "%s not ready remote rings\n", __func__);
		kvec_buff->remote_write_kvecs.is_update = false;
		return;
	}
	common_dev_notify_avail(cdev);
	while(vop_common_get_descriptors_with_lock(cdev, &vringh->vrh, &head, wiov, false) > 0) {
		dev_dbg(&vdev->dev,
			"%s fetched %d descriptors from local queue\n",
			__func__, wiov->used);
		ring_id = vop_kvec_put(cdev, wiov, &head);
		if (ring_id >= 0) {
			++cnt_size[ring_id];
			++cnt_total;
			++kvec_buff->remote_write_kvecs.rings[ring_id].stats_num;
			head = USHRT_MAX;
			if ( !((cnt_total) % KVEC_INDEX_UPDATE_PERIOD) && cnt_total) {
				vop_kvec_buff_update_idx(cdev, cnt_size);
			}
		}
	}
	vop_kvec_buff_update_idx(cdev, cnt_size);
	kvec_buff->remote_write_kvecs.is_update = false;
}
void vop_kvec_buf_update ( struct vop_dev_common * cdev ) { struct vop_device * vdev ; struct vop_kvec_buff * kvec_buff ; struct vop_vringh * vringh ; struct vringh_kiov * wiov ; u16 head = USHRT_MAX ; int ring_id ; unsigned cnt_size [ KVEC_BUF_NUM ] , cnt_total = 0 ; if ( ! cdev || ! cdev -> ready ) { return ; } kvec_buff = & cdev -> kvec_buff ; kvec_buff -> remote_write_kvecs . is_update = true ; vdev = cdev -> vdev ; vringh = cdev -> vringh_rcv ; wiov = & kvec_buff -> remote_write_kvecs . kiov ; memset ( cnt_size , 0 , sizeof ( cnt_size ) ) ; if ( ! kvec_buff -> remote_write_kvecs . mapped ) { dev_err ( & vdev -> dev , " \n " , __func__ ) ; kvec_buff -> remote_write_kvecs . is_update = false ; return ; } common_dev_notify_avail ( cdev ) ; while ( vop_common_get_descriptors_with_lock ( cdev , & vringh -> vrh , & head , wiov , false ) > 0 ) { dev_dbg ( & vdev -> dev , " \n " , __func__ , wiov -> used ) ; ring_id = vop_kvec_put ( cdev , wiov , & head ) ; if ( ring_id >= 0 ) { ++ cnt_size [ ring_id ] ; ++ cnt_total ; ++ kvec_buff -> remote_write_kvecs . rings [ ring_id ] . stats_num ; head = USHRT_MAX ; if ( ! ( ( cnt_total ) % KVEC_INDEX_UPDATE_PERIOD ) && cnt_total ) { vop_kvec_buff_update_idx ( cdev , cnt_size ) ; } } } vop_kvec_buff_update_idx ( cdev , cnt_size ) ; kvec_buff -> remote_write_kvecs . is_update = false ; }
vop_kvec_update_buf - put decriptors from local vring to a ring buffer
 allocated by the other host.
vop_kvec_update_buf - put decriptors from local vring to a ring buffer allocated by the other host .