Hello Premkumar
The details of packet processing on a L3 switch can be quite complicated, and are often specific to the vendor and even the model of switch that is being used. Let me try to clarify:
Let’s take the first situation as an example. Host A pings Host B. When the L3 switch receives the packet, it begins decapsulation. It reads the destination MAC address and it looks up that MAC address in the MAC address table for VLAN 10. If that address exists in the MAC address table, then the frame can be switched to the proper port and egress that port to reach Host C.
Strictly speaking, just for the processes described, further decapsulation should not be necessary. However, the packet will typically be further decapsulated so that the information in the IP header can be read and used in processes such as ACLs, QoS. Or it may just want to confirm that the packet is indeed to be switched and not routed, so it checks the destination IP address to ensure it is in the same subnet (and matches the information it determined from the frame header).
Now the question of what physical hardware performs all of this processing also depends on the architecture of the device. Typically, this is done by Application-Specific Integrated Circuits (ASICs), but some lower-end devices may have the central CPU perform these functions.
Let’s now take a look at your second situation. Host A pings Host B. In that case, the frame is received, and the destination MAC address is determined and compared with the MAC address table. It will not find the MAC address in VLAN 10’s MAC address table, and it would need to further decapsulate the packet to determine the destination IP. It sees that the destination IP is in a different subnet, so it is then routed (i.e. destination IP address is compared to entries in the routing table to determine the egress port). The egress port is determined, it is re-encapsulated and sent to host C on VLAN 20.
Now where this is processed physically, again depends upon the architecture of the switch. Some higher-end switches will also have Network Processors, which are dedicated CPUs for performing such processing. Another thing to keep in mind is whether or not processes such as Cisco Express Forwarding (CEF) are used or not.
So, unfortunately, there’s no clear-cut answer, but it depends upon the switch architecture. Does that make sense?
I hope this has been helpful!
Laz