// RPMsg static endpoints

digraph G {
  rankdir="LR";

  subgraph roles {
    node [style="filled", fillcolor="lightblue"];
    host [label="Host"];
    remote [label="Remote"];
  }

  subgraph m_comment_nodes {
    node [group=m_comment, shape="note", style="filled", fillcolor="yellow"];
    rank="same";
    m_remoteproc_init_comment [label="this is initialize rproc call"];
    m_remoteproc_boot_comment [label="it will setup vdev before booting the remote"];
    m_rpmsg_vdev_init_comment [label="\l* It will initialize vrings with the shared memory\l* As vdev doesn't support name service, it will not create name service endpoint;\l* it sets vdev status to DRVIER_READY, And will notify remote.\l"];
    m_rpmsg_create_ep_comment [label="\lAs vdev doesn't supports name service,\lit will not send out name service.\l"];
  }

  subgraph m_flow_nodes {
    node [shape="box"];
    rank="same";
    m_remoteproc_init [label="rproc = remoteproc_init(&remoteproc_ops, &arg);"];
    m_remoteproc_load [label="calls remoteproc_load() to load application"];
    m_remoteproc_boot [shape="box", label="ret=remoteproc_boot(&rproc)"];
    m_remoteproc_get_vdev [label="vdev=remoteproc_create_virtio(rproc, rpmsg_vdev_id, VIRTIO_DEV_DRIVER, NULL);"];
    m_rpmsg_shmpool_init[label="rpmsg_virtio_init_shm_pool(shpool, shbuf, shbuf_pool_size);"];
    m_rpmsg_vdev_init [label="rpdev=rpmsg_init_vdev(rpvdev, vdev, ns_bind_cb, &shm_io, shpool);"];
    m_rpmsg_create_ep [label="\lept=rpmsg_create_ept(ept, rdev, ept_name, ept_addr, dest_addr, \lendpoint_cb, ns_unbind_cb);\l"];
    m_rpmsg_send [label="rpmsg_send(ept,data)"];
    m_rpmsg_rx_cb [label="rpmsg_rx_callback()"];
    m_ep_cb [label="endpoint_cb(ept, data, size, src_addr)"];
    m_rpmsg_destroy_ep [label="rpmsg_destroy_endpoint(ept)"];

    m_remoteproc_init -> m_remoteproc_load -> m_remoteproc_boot -> m_remoteproc_get_vdev ->
    m_rpmsg_shmpool_init -> m_rpmsg_vdev_init -> m_rpmsg_create_ep -> m_rpmsg_send;
    m_rpmsg_send -> m_rpmsg_rx_cb -> m_ep_cb ->
    m_rpmsg_destroy_ep [dir="none", style="dashed"];
  }

  subgraph s_flow_nodes {
    rank="same";
    node [shape="box"];
    s_remoteproc_init [label="rproc = remoteproc_init(&remoteproc_ops, &arg);"];

    s_remoteproc_parse_rsc [label="ret = remoteproc_set_rsc_table(rproc, &rsc_table, rsc_size)"];
    s_remoteproc_get_vdev [label="vdev=remoteproc_create_virtio(rproc, rpmsg_vdev_id, VIRTIO_DEV_DEVICE, rst_cb);"];
    s_rpmsg_vdev_init [label="rpdev=rpmsg_init_vdev(rpvdev, vdev, ns_bind_cb, &shm_io, NULL);"];
    s_rpmsg_create_ep [label="\lept=rpmsg_create_ept(ept, rdev, ept_name, ept_addr, dest_addr, \lendpoint_cb, ns_unbind_cb);\l"];
    s_rpmsg_send [label="rpmsg_send(ept,data)"];
    s_rpmsg_rx_cb [label="rpmsg_rx_callback()"];
    s_ep_cb [label="endpoint_cb(ept, data, size, src_addr)"];
    s_rpmsg_destroy_ep [label="rpmsg_destroy_endpoint(ept)"];

    s_remoteproc_init -> s_remoteproc_parse_rsc -> s_remoteproc_get_vdev ->
    s_rpmsg_vdev_init -> s_rpmsg_create_ep;
    s_rpmsg_create_ep -> s_rpmsg_rx_cb ->
    s_ep_cb -> s_rpmsg_send -> s_rpmsg_destroy_ep [dir="none", style="dash"];

  }

  subgraph s_comment_nodes {
    node [group=s_comment, shape="note", style="filled", fillcolor="yellow"];
    rank="same";
    s_rpmsg_vdev_init_comment [label="\l* As vdev doesn't support name service, it will not create name service endpoint;\l* It will not return until the host set status to DRIVER READY\l"];
    s_rpmsg_rx_cb_comment [label="\l* It will look for the endpoint which matches the destination address.\lIf no endpoint has found, it will drop the message.\l"];
  }

  host -> m_remoteproc_init [dir="none"];
  remote -> s_remoteproc_init [dir="none"];
  m_rpmsg_send -> s_rpmsg_rx_cb [label="RPMsg data"];
  s_rpmsg_send -> m_rpmsg_rx_cb [label="RPMsg data"];

  m_remoteproc_init_comment -> m_remoteproc_init [dir="none"];
  m_remoteproc_boot_comment -> m_remoteproc_boot [dir="none"];
  m_rpmsg_vdev_init_comment -> m_rpmsg_vdev_init [dir="none"];
  m_rpmsg_create_ep_comment -> m_rpmsg_create_ep [dir="none"];

  s_rpmsg_vdev_init -> s_rpmsg_vdev_init_comment [dir="none"];
  s_rpmsg_rx_cb -> s_rpmsg_rx_cb_comment [dir="none"];

  {rank=same; host; m_remoteproc_init}
  {rank=same; remote; s_remoteproc_init}

}

