ThirdParty/sw_services/openamp/src/open-amp/lib/rpmsg/rpmsg_virtio.c
static void rpmsg_virtio_rx_callback(struct virtqueue *vq)
{
	struct virtio_device *vdev = vq->vq_dev;
	struct rpmsg_virtio_device *rvdev = vdev->priv;
	struct rpmsg_device *rdev = &rvdev->rdev;
	struct rpmsg_endpoint *ept;
	struct rpmsg_hdr *rp_hdr;
	uint32_t len;
	uint16_t idx;
	int status;

	metal_mutex_acquire(&rdev->lock);

	/* Process the received data from remote node */
	rp_hdr = rpmsg_virtio_get_rx_buffer(rvdev, &len, &idx);

	metal_mutex_release(&rdev->lock);

	while (rp_hdr) {
		/* Get the channel node from the remote device channels list. */
		metal_mutex_acquire(&rdev->lock);
		ept = rpmsg_get_ept_from_addr(rdev, rp_hdr->dst);
		metal_mutex_release(&rdev->lock);

		if (ept) {
			if (ept->dest_addr == RPMSG_ADDR_ANY) {
				/*
				 * First message received from the remote side,
				 * update channel destination address
				 */
				ept->dest_addr = rp_hdr->src;
			}
			status = ept->cb(ept, RPMSG_LOCATE_DATA(rp_hdr),
					 rp_hdr->len, rp_hdr->src, ept->priv);

			RPMSG_ASSERT(status == RPMSG_SUCCESS,
				     "unexpected callback status\r\n");
		}

		metal_mutex_acquire(&rdev->lock);

		/* Return used buffers. */
		rpmsg_virtio_return_buffer(rvdev, rp_hdr, len, idx);

		rp_hdr = rpmsg_virtio_get_rx_buffer(rvdev, &len, &idx);
		if (rp_hdr == NULL) {
			/* tell peer we return some rx buffer */
			virtqueue_kick(rvdev->rvq);
		}
		metal_mutex_release(&rdev->lock);
	}
}
/**
 * rpmsg_virtio_rx_callback
 *
 * Rx callback function.
 *
 * @param vq - pointer to virtqueue on which messages is received
 *
 */
rpmsg_virtio_rx_callback
Rx callback function.

@param vq - pointer to virtqueue on which messages is received
rpmsg_virtio_rx_callback Rx callback function . @param vq - pointer to virtqueue on which messages is received
static void rpmsg_virtio_rx_callback(struct virtqueue *vq)
{
	struct virtio_device *vdev = vq->vq_dev;
	struct rpmsg_virtio_device *rvdev = vdev->priv;
	struct rpmsg_device *rdev = &rvdev->rdev;
	struct rpmsg_endpoint *ept;
	struct rpmsg_hdr *rp_hdr;
	uint32_t len;
	uint16_t idx;
	int status;
	metal_mutex_acquire(&rdev->lock);
	rp_hdr = rpmsg_virtio_get_rx_buffer(rvdev, &len, &idx);
	metal_mutex_release(&rdev->lock);
	while (rp_hdr) {
		metal_mutex_acquire(&rdev->lock);
		ept = rpmsg_get_ept_from_addr(rdev, rp_hdr->dst);
		metal_mutex_release(&rdev->lock);
		if (ept) {
			if (ept->dest_addr == RPMSG_ADDR_ANY) {
				ept->dest_addr = rp_hdr->src;
			}
			status = ept->cb(ept, RPMSG_LOCATE_DATA(rp_hdr),
					 rp_hdr->len, rp_hdr->src, ept->priv);
			RPMSG_ASSERT(status == RPMSG_SUCCESS,
				     "unexpected callback status\r\n");
		}
		metal_mutex_acquire(&rdev->lock);
		rpmsg_virtio_return_buffer(rvdev, rp_hdr, len, idx);
		rp_hdr = rpmsg_virtio_get_rx_buffer(rvdev, &len, &idx);
		if (rp_hdr == NULL) {
			virtqueue_kick(rvdev->rvq);
		}
		metal_mutex_release(&rdev->lock);
	}
}
static void rpmsg_virtio_rx_callback ( struct virtqueue * vq ) { struct virtio_device * vdev = vq -> vq_dev ; struct rpmsg_virtio_device * rvdev = vdev -> priv ; struct rpmsg_device * rdev = & rvdev -> rdev ; struct rpmsg_endpoint * ept ; struct rpmsg_hdr * rp_hdr ; uint32_t len ; uint16_t idx ; int status ; metal_mutex_acquire ( & rdev -> lock ) ; rp_hdr = rpmsg_virtio_get_rx_buffer ( rvdev , & len , & idx ) ; metal_mutex_release ( & rdev -> lock ) ; while ( rp_hdr ) { metal_mutex_acquire ( & rdev -> lock ) ; ept = rpmsg_get_ept_from_addr ( rdev , rp_hdr -> dst ) ; metal_mutex_release ( & rdev -> lock ) ; if ( ept ) { if ( ept -> dest_addr == RPMSG_ADDR_ANY ) { ept -> dest_addr = rp_hdr -> src ; } status = ept -> cb ( ept , RPMSG_LOCATE_DATA ( rp_hdr ) , rp_hdr -> len , rp_hdr -> src , ept -> priv ) ; RPMSG_ASSERT ( status == RPMSG_SUCCESS , " \r \n " ) ; } metal_mutex_acquire ( & rdev -> lock ) ; rpmsg_virtio_return_buffer ( rvdev , rp_hdr , len , idx ) ; rp_hdr = rpmsg_virtio_get_rx_buffer ( rvdev , & len , & idx ) ; if ( rp_hdr == NULL ) { virtqueue_kick ( rvdev -> rvq ) ; } metal_mutex_release ( & rdev -> lock ) ; } }
rpmsg_virtio_rx_callback
 Rx callback function.
rpmsg_virtio_rx_callback Rx callback function .
/* Process the received data from remote node */ /* Get the channel node from the remote device channels list. */ /*
				 * First message received from the remote side,
				 * update channel destination address
				 */ /* Return used buffers. */ /* tell peer we return some rx buffer */