
Wolfgang Denk wrote:
Dear Ben,
I just ran over this piece of code in NetLoop() [see "net/net.c"]:
286 int 287 NetLoop(proto_t protocol) 288 { ... 322 eth_halt(); 323 #ifdef CONFIG_NET_MULTI 324 eth_set_current(); 325 #endif 326 if (eth_init(bd) < 0) { 327 eth_halt(); 328 return(-1); 329 }
Am I reading this correctly that we eth_halt() and eth_init() the network interface for each and every call to NetLoop?
Yes, it looks that way. Ripe for gutting.
This looks terribly inefficient to me - is there any rationale behind this?
Probably, but it escapes me. It most certainly predates my involvement in this project.
Also, the eth_set_current() checking should IMHO be done just once, before we start a network transfer, or when we actually switch interfaces, but not for each and every call to NetLoop() ?
Maybe, but eth_set_current() is pretty lightweight. NetLoop is only called when we start a network transfer, so this doesn't seem too egregious. It could definitely stand to be refactored.
Best regards,
Wolfgang Denk
regards, Ben