From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ben Warren Date: Thu, 25 Sep 2008 23:09:49 -0700 Subject: [U-Boot] Inefficient code in NetLoop() ? In-Reply-To: <20080912195058.8625324926@gemini.denx.de> References: <20080912195058.8625324926@gemini.denx.de> Message-ID: <48DC7CAD.9040502@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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