I would like to ask if the P4 switch can respond to dynamic routing (e.g. ospf, rip, etc.) and inform the router about the available network neighbors of the P4 switch?
For example, OSPF, where there is an exchange of information to know its network neighbors, can this be implemented on P4?
The simplest answer is that P4 is for writing dataplane programs, while in the mentioned protocols it is mostly a control-plane functionality. So to implement such programs you simply have to implement the logic at the control plane level.
And to add just a little bit to the previous answer, P4 programs written to cooperate with the control plane in this way must have at least a little bit of code that recognizes all of the appropriate control messages of the desired control protocols, e.g. OSPF Hello Packets, and sends them to a local control CPU that is running the routing protocols. The software running on the control CPU also needs a way to send packets to the P4-programmable switch ASIC in such a way that it can control the full contents of messages going out of the switch, and on which physical port.
You are looking for resources to learn more about how to co-develop routing protocols and P4 programs such that together they implement that routing protocol?
Or are you asking more specifically about resources on learning the P4 part of that?