What is the purpose of "config switch_port" section?

An example taken from here:

config 'switch_vlan'
   option 'vlan'       '0'
   option 'device'     'eth1'
   option 'ports'      '0 1 2 5t'

config 'switch_vlan'
   option 'vlan'       '1'
   option 'device'     'eth1'
   option 'ports'      '3 5t'

config 'switch_port'
    option 'port'      '3'
    option 'pvid'      '1'

The 2nd block defines VLAN 1 (with VID 1 by default) on port 3 and 5, with port 3 being untagged and port 5 being tagged.

The 3rd block, which is config 'switch_port' does nothing other than defining port 3 has the native VLAN of 1 (pvid = 1). That means all traffic belongs to VLAN1 will be forwarded to this port, and such traffic will be untagged. Same as above.

Why do we need to define VLAN function of that port twice?

This page is a bit old, better read the ones mentioned in the header.

In this example it is shown better:
Port 3 it tagged in the previous references, so you might want to define the native vlan.

I've taken a look at your example:

config 'switch_vlan' 'eth0_1'
        option 'device' 'eth0'
        option 'vlan' '1'
        option 'ports' '0 1 3t 5t'	# VLAN1 traffic is tagged on port 3
 
config 'switch_vlan' 'eth0_3'
        option 'device' 'eth0'
        option 'vlan' '3'
        option 'ports' '3t 4t'	# VLAN3 traffic is also tagged on port 3
 
config 'switch_port'
        option 'device' 'eth0'
        option 'port' '3'
        option 'pvid' '3'		# Now remove tagged traffic for VLAN3, what's the point?

Still, I don't find any practical use of the config switch_port section. If it were me:

config 'switch_vlan' 'eth0_1'
        option 'device' 'eth0'
        option 'vlan' '1'
        option 'ports' '0 1 3t 5t'
 
config 'switch_vlan' 'eth0_3'
        option 'device' 'eth0'
        option 'vlan' '3'
        option 'ports' '3 4t'	# 't' removed from port 3

And the problem is solved.

What if the port receives a tagged frame with VLAN 3?

I think the switch will considered all untagged traffic as VLAN3 traffic, which we can access on eth0.3 interface. All tagged frames with a VID=3 will be dropped.

If it also accepts tagged frames with VID=3 as you say, I feel confused because I can't tell which I shall get on eth0.3: VID=3 tagged frames or untagged frames? :confused:

Correct, but with the above configuration you can accept tagged frames in VLAN3, as well as untagged frames which will be assigned to VLAN3.
You can read more if you search for native vlan. Maybe it would be easier to understand like this:

config 'switch_vlan' 'eth0_1'
        option 'device' 'eth0'
        option 'vlan' '1'
        option 'ports' '0 1 3t 5t'
 
config 'switch_vlan' 'eth0_3'
        option 'device' 'eth0'
        option 'vlan' '3'
        option 'ports' '3t 5t'
 
config 'switch_port'
        option 'device' 'eth0'
        option 'port' '3'
        option 'pvid' '10'

Port 3 is trunking vlans 1 and 3, they must be tagged.
If the port receives an untagged frame, it will be assigned to VLAN10.

So, with the configuration in your link above:

config 'switch_vlan' 'eth0_1'
        option 'device' 'eth0'
        option 'vlan' '1'
        option 'ports' '0 1 3t 5t'	# VLAN1 traffic is tagged on port 3
 
config 'switch_vlan' 'eth0_3'
        option 'device' 'eth0'
        option 'vlan' '3'
        option 'ports' '3t 4t'	# VLAN3 traffic is also tagged on port 3
 
config 'switch_port'
        option 'device' 'eth0'
        option 'port' '3'
        option 'pvid' '3'		# VLAN3 is the native VLAN

For input traffic, both VID=3 tagged frames and untagged frames are accepted on that port, then both of them are considered to be belonged to VLAN3.

For output traffic, the switch only sends VID=3 tagged frames out of that port.

Are these correct?

This is a weird example, I haven't seen native vlan the same as the tagged vlans.
So the concept is that if a frame in VLAN 10 is to egress this port, it will be untagged.
I cannot imagine that the port would send the frame twice, one time tagged in VLAN3 and the other untagged.

I find it weird too, because the device which sends untagged frames will receive tagged frames in response -- it may have no clue about 802.1q. So, let's considered the native VLAN is different from the tagged VLANs on a single port. Are there any diffences between this (your example above):

config 'switch_vlan' 'eth0_1'
        option 'device' 'eth0'
        option 'vlan' '1'
        option 'ports' '0 1 3t 5t'
 
config 'switch_vlan' 'eth0_3'
        option 'device' 'eth0'
        option 'vlan' '3'
        option 'ports' '3t 5t'
 
config 'switch_port'
        option 'device' 'eth0'
        option 'port' '3'
        option 'pvid' '10'

And this:

config 'switch_vlan' 'eth0_1'
        option 'device' 'eth0'
        option 'vlan' '1'
        option 'ports' '0 1 3t 5t'
 
config 'switch_vlan' 'eth0_3'
        option 'device' 'eth0'
        option 'vlan' '3'
        option 'ports' '3t 5t'
 
config 'switch_vlan' 'eth0_10'
        option 'device' 'eth0'
        option 'vlan' '10'
        option 'ports' '3'	# other ports can be added here, as long as port 3 is untagged

The end results seem to be the same to me.

Usually you use native vlan to blackhole untagged traffic or use it as a quick and dirty way to access the device in case of troubleshooting from a dot1q ignorant device (e.g windows).
In other cases I have seen this kind of configuration in some TP-link switches, when you want to change the ingress untagged frame vlan, because vlan1 cannot be disabled.

The difference of vlan and pvid in the above examples is that sometimes the devices do not support more than 16 or so vlans. So if you want to use a vlan above that limit, you specify the vlan id with pvid. The vlan number is then used for internal switch segregation, but not for tagging.