How does `tc mirred mirror/direct action` work?

Clash Royale CLAN TAG#URR8PPP
How does `tc mirred mirror/direct action` work?
I met some problem in the tc mirred mirror/direct action, and i want to know how it works (would be cool in the code granularity).
tc mirred mirror/direct action
I know the source code is the best manual, but I just cannot find where to start even after a lot searching. if someone can provide this, it would be helpful!
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.