@@ -578,13 +578,13 @@ static int rpmsg_virtio_ns_callback(struct rpmsg_endpoint *ept, void *data,
578578 metal_mutex_acquire (& rdev -> lock );
579579 _ept = rpmsg_get_endpoint (rdev , name , RPMSG_ADDR_ANY , dest );
580580
581- if (ns_msg -> flags & RPMSG_NS_DESTROY ) {
581+ if (ns_msg -> flags == RPMSG_NS_DESTROY ) {
582582 if (_ept )
583583 _ept -> dest_addr = RPMSG_ADDR_ANY ;
584584 metal_mutex_release (& rdev -> lock );
585585 if (_ept && _ept -> ns_unbind_cb )
586586 _ept -> ns_unbind_cb (_ept );
587- } else {
587+ } else if ( ns_msg -> flags == RPMSG_NS_CREATE ) {
588588 if (!_ept ) {
589589 /*
590590 * send callback to application, that can
@@ -598,7 +598,14 @@ static int rpmsg_virtio_ns_callback(struct rpmsg_endpoint *ept, void *data,
598598 } else {
599599 _ept -> dest_addr = dest ;
600600 metal_mutex_release (& rdev -> lock );
601+ if (_ept -> name [0 ] && rdev -> support_ack )
602+ rpmsg_send_ns_message (_ept , RPMSG_NS_CREATE_ACK );
601603 }
604+ } else { /* RPMSG_NS_CREATE_ACK */
605+ /* save the received destination address */
606+ if (_ept )
607+ _ept -> dest_addr = dest ;
608+ metal_mutex_release (& rdev -> lock );
602609 }
603610
604611 return RPMSG_SUCCESS ;
@@ -679,6 +686,7 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev,
679686#endif /*!VIRTIO_MASTER_ONLY*/
680687 vdev -> features = rpmsg_virtio_get_features (rvdev );
681688 rdev -> support_ns = !!(vdev -> features & (1 << VIRTIO_RPMSG_F_NS ));
689+ rdev -> support_ack = !!(vdev -> features & (1 << VIRTIO_RPMSG_F_ACK ));
682690
683691#ifndef VIRTIO_SLAVE_ONLY
684692 if (role == RPMSG_MASTER ) {
@@ -774,7 +782,7 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev,
774782 * Create name service announcement endpoint if device supports name
775783 * service announcement feature.
776784 */
777- if (rdev -> support_ns ) {
785+ if (rdev -> support_ns || rdev -> support_ack ) {
778786 rpmsg_register_endpoint (rdev , & rdev -> ns_ept , "NS" ,
779787 RPMSG_NS_EPT_ADDR , RPMSG_NS_EPT_ADDR ,
780788 rpmsg_virtio_ns_callback , NULL );
0 commit comments