@@ -579,13 +579,13 @@ static int rpmsg_virtio_ns_callback(struct rpmsg_endpoint *ept, void *data,
579579 metal_mutex_acquire (& rdev -> lock );
580580 _ept = rpmsg_get_endpoint (rdev , name , RPMSG_ADDR_ANY , dest );
581581
582- if (ns_msg -> flags & RPMSG_NS_DESTROY ) {
582+ if (ns_msg -> flags == RPMSG_NS_DESTROY ) {
583583 if (_ept )
584584 _ept -> dest_addr = RPMSG_ADDR_ANY ;
585585 metal_mutex_release (& rdev -> lock );
586586 if (_ept && _ept -> ns_unbind_cb )
587587 _ept -> ns_unbind_cb (_ept );
588- } else {
588+ } else if ( ns_msg -> flags == RPMSG_NS_CREATE ) {
589589 if (!_ept ) {
590590 /*
591591 * send callback to application, that can
@@ -599,7 +599,15 @@ static int rpmsg_virtio_ns_callback(struct rpmsg_endpoint *ept, void *data,
599599 } else {
600600 _ept -> dest_addr = dest ;
601601 metal_mutex_release (& rdev -> lock );
602+ if (_ept -> name [0 ] && rdev -> support_ack )
603+ rpmsg_send_ns_message (_ept ,
604+ RPMSG_NS_CREATE_ACK );
602605 }
606+ } else { /* RPMSG_NS_CREATE_ACK */
607+ /* save the received destination address */
608+ if (_ept )
609+ _ept -> dest_addr = dest ;
610+ metal_mutex_release (& rdev -> lock );
603611 }
604612
605613 return RPMSG_SUCCESS ;
@@ -680,6 +688,7 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev,
680688#endif /*!VIRTIO_DRIVER_ONLY*/
681689 vdev -> features = rpmsg_virtio_get_features (rvdev );
682690 rdev -> support_ns = !!(vdev -> features & (1 << VIRTIO_RPMSG_F_NS ));
691+ rdev -> support_ack = !!(vdev -> features & (1 << VIRTIO_RPMSG_F_ACK ));
683692
684693#ifndef VIRTIO_DEVICE_ONLY
685694 if (role == RPMSG_HOST ) {
@@ -775,7 +784,7 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev,
775784 * Create name service announcement endpoint if device supports name
776785 * service announcement feature.
777786 */
778- if (rdev -> support_ns ) {
787+ if (rdev -> support_ns || rdev -> support_ack ) {
779788 rpmsg_register_endpoint (rdev , & rdev -> ns_ept , "NS" ,
780789 RPMSG_NS_EPT_ADDR , RPMSG_NS_EPT_ADDR ,
781790 rpmsg_virtio_ns_callback , NULL );
0 commit comments