xiaoxiang781216 edited a comment on pull request #1047:
URL: https://github.com/apache/incubator-nuttx/pull/1047#issuecomment-629003652


   > I don't understand under what conditions this logic would be invoked. 
There is one one: If netdev_register() were called twice with the same driver 
instance. That does not happen.
   > 
   
   sim just support one tapdev by desgin(many global variables are used), so 
netdev_register is just callded once.
   
   > Have you changed the logic in some way? Do you call netdev_register() 
mutliple times with the same device structure? If so, why?
   
   The initializition flow is same as before, the real difference is:
   1.Add netdriver_setmtu
   2.Call netdriver_setmtu in tapdev_init to tell NuttX what mtu size is really 
used by tapdev
   The same logic is also used by netdriver_setmacaddr too.
   
   Why don't we use Kconfig to determine the ethernet patcket length on sim 
like other platform? Because the mtu(default 1500) of tapdev can be assgined 
when you create the net bridge(default nuttx0):
   ```
   ip link set dev nuttx0 mtu size?
   ```
   
   The keypoint is that the mtu of tapdev can be changed dynamically, the 
packet length from Kconfig isn't suitable for this situation.
   
   > 
   > The logic looks wrong to me unless you can explain when that would happen.
   
   Now let's look at netdriver_register logic, it always set the 
d_llhdrlen/d_pktsize to Kconfig value base on the link type, it work for the 
most case, but not good for simulator as I described before.
   How to fix this problem? we follow the same approach what d_ifname has been 
used:
   1.If d_pktsize is zero, assign the value from Kconfig to d_pktsize
   2.if d_pktsize isn't zero, use this value directly
   With this change, simulator can query the real mtu from net bridge and 
initialize d_pktsize before calling netdriver_register. The final result is 
both side(NuttX and host) has the same mtu size.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to