netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* query : unregister/register netdev
@ 2011-11-18 12:23 Madhvapathi Sriram
  2011-11-18 15:52 ` Ben Hutchings
  2011-11-18 16:22 ` Stephen Hemminger
  0 siblings, 2 replies; 4+ messages in thread
From: Madhvapathi Sriram @ 2011-11-18 12:23 UTC (permalink / raw)
  To: netdev

Hi,

In register_netdevice(), BUG_ON(dev->reg_state != NETREG_UNINITIALIZED) is
used to check if the device that is being registered is indeed a new one.

However, I see that this state is never moved to. It only happens when a
netdevice is allocated (by default to 0 using kzalloc).

So, the cycle register-->unregister-->register would fail since in the
unregister_netdevice the state is only moved to NETREG_UNREGISTERED (at max
to NETREG_RELEASED using free_netdev)

So, I presume that to reinitialize a netdevice one has to free the
netdevice, re allocate netdevice and only then re register.

Wondering why unregister and reregister is not allowed, rather than having
go through the free/alloc cycle - I am not an expert though.

Thanks
-Sriram

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: query : unregister/register netdev
  2011-11-18 12:23 query : unregister/register netdev Madhvapathi Sriram
@ 2011-11-18 15:52 ` Ben Hutchings
  2011-11-18 16:22 ` Stephen Hemminger
  1 sibling, 0 replies; 4+ messages in thread
From: Ben Hutchings @ 2011-11-18 15:52 UTC (permalink / raw)
  To: Madhvapathi Sriram; +Cc: netdev

On Fri, 2011-11-18 at 17:53 +0530, Madhvapathi Sriram wrote:
> Hi,
> 
> In register_netdevice(), BUG_ON(dev->reg_state != NETREG_UNINITIALIZED) is
> used to check if the device that is being registered is indeed a new one.
> 
> However, I see that this state is never moved to. It only happens when a
> netdevice is allocated (by default to 0 using kzalloc).
> 
> So, the cycle register-->unregister-->register would fail since in the
> unregister_netdevice the state is only moved to NETREG_UNREGISTERED (at max
> to NETREG_RELEASED using free_netdev)
> 
> So, I presume that to reinitialize a netdevice one has to free the
> netdevice, re allocate netdevice and only then re register.
> 
> Wondering why unregister and reregister is not allowed, rather than having
> go through the free/alloc cycle - I am not an expert though.

Why do you think that would be useful?

Ben.

-- 
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: query : unregister/register netdev
  2011-11-18 12:23 query : unregister/register netdev Madhvapathi Sriram
  2011-11-18 15:52 ` Ben Hutchings
@ 2011-11-18 16:22 ` Stephen Hemminger
  1 sibling, 0 replies; 4+ messages in thread
From: Stephen Hemminger @ 2011-11-18 16:22 UTC (permalink / raw)
  To: Madhvapathi Sriram; +Cc: netdev

On Fri, 18 Nov 2011 17:53:37 +0530
Madhvapathi Sriram <sriram.madhvapathi@gmail.com> wrote:

> In register_netdevice(), BUG_ON(dev->reg_state != NETREG_UNINITIALIZED) is
> used to check if the device that is being registered is indeed a new one.
> 
> However, I see that this state is never moved to. It only happens when a
> netdevice is allocated (by default to 0 using kzalloc).
> 
> So, the cycle register-->unregister-->register would fail since in the
> unregister_netdevice the state is only moved to NETREG_UNREGISTERED (at max
> to NETREG_RELEASED using free_netdev)
> 
> So, I presume that to reinitialize a netdevice one has to free the
> netdevice, re allocate netdevice and only then re register.
> 
> Wondering why unregister and reregister is not allowed, rather than having
> go through the free/alloc cycle - I am not an expert though.

There are two reasons. First because of RCU the device object still might
be in use after unregister (until after RCU quiescent period). But the real
reason is that no device driver existing needed it. The normal use case
of unregister is when device is being removed or session for a virtual device
is going away.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* query : unregister/register netdev
@ 2011-11-23 11:14 manoj bm
  0 siblings, 0 replies; 4+ messages in thread
From: manoj bm @ 2011-11-23 11:14 UTC (permalink / raw)
  To: netdev

Hi Guys,
   WRT below mail chain link, I am facing similar issue.
http://www.spinics.net/lists/netdev/msg180176.html

Please find the usage details below:

Situation:
I have concurrent  interfaces running & active doing data
transactions. (ex: interface0 & interface1)

-> whenever user want to delete activity on one interface, i have to
stop activity & hide from user (this i am trying to achieve by
unregistering the netdev but not freeing it)
-> whenever user want to  create activity on interface, i have to
start activity & make it visible to user (this i am trying to achieve
by registering the netdev which would have unregistered previously)

Issues
-> First interface(0) is basic so i have allocated private driver data
area to it & other interfaces contains basic info & pointing to this
"netdev[0]->net_priv" (i.e. first interface private data area).
Because of this above requirement i cant free the netdev0 until chip
is power supply removed.

Other options thought of but not used are:

-> I can remove other interfaces using unregister_netdev followed by
free_netdev() BUT i am afraid that  during the heavy data traffic
conditions(apps continuously pumping data with high bandwidth),
allocating & registering might causes the issue of registration fail
because of resource crunch. Which we never tolerate as this a
concurrent interface solution

-> After verification found that, even ethernet also works in similar
fashion. If chip is powered then irrespective of RJ45 connected or not
interface is given & visible to the user. That's the way i also
created all of my interfaces statically(during initialization)
depending on the user input i want to hide/unhide (i.e.
register/unregister netdev) corresponding netdevice visible using
ifconfig.

Currently i am facing a issue that  bug_on from kernel
--------------------------------------------------------------------------
-> Depending on application input i have to unregister & register the
same netdev without freeing
I am facing the bug_on from kernel during registration as below
BUG_ON(dev->reg_state != NETREG_UNINITIALIZED);

-> If we forcefully reset the dev->reg_state to uninitialized in our
driver, then this works fine but kernel warns already registered
device & some thing seriously wrong here (i dont want to hack netdev
structures here :))

->  Then i have tried to initialize the device after unregistration by
calling ether_setup & then again registering BUT same bug_on appeared.

My requirement is quiet simple,
-> Whenever user application want to "delete the netdev interface"
then i have to make the interface disappeared for ifconfig/iwconfig,
so that user can't play with that
-> Whenever user application want to "Add the netdev interface" then i
have to make the interface appearing for ifconfig/iwconfig, so that
user can use those

The problem is i don't want to call Alloc_netdev/free_netdev based on
application input (dynamically creating/destroying), i just want to
register/unregister statically created interfaces accordingly.

Please let me know your views on it. Thanks in advance

Thanks,
  Manoj

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-11-23 11:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-18 12:23 query : unregister/register netdev Madhvapathi Sriram
2011-11-18 15:52 ` Ben Hutchings
2011-11-18 16:22 ` Stephen Hemminger
  -- strict thread matches above, loose matches on Subject: below --
2011-11-23 11:14 manoj bm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).