PC1 would broadcasts using ethernet “in search of who has IP number xxx”. On the local net. Now if pc2 or pc3 has “xxx” they reply with a message of confirmation. The broadcast has the MAC address of pc1, and the reply has the MAC address of pc2 or pc3.
now If there is no reply, then pc1 would pass it to the network router, and if pc1 doesn’t already have that MAC address, will repeat it for the routers designated IP address, and router then replies. At which time, the packet is then sent to the router to forward as it deems necessary. Hence the switch/ router gets the MAC addresses from the host.