All of lore.kernel.org
 help / color / mirror / Atom feed
* Writing driver for a net device which does not support interrupt
@ 2015-03-23 10:51 Freeman Zhang
  2015-03-23 15:51 ` Valdis.Kletnieks at vt.edu
  2015-03-23 16:59 ` phil
  0 siblings, 2 replies; 6+ messages in thread
From: Freeman Zhang @ 2015-03-23 10:51 UTC (permalink / raw)
  To: kernelnewbies

Hi list,

I'm writing a net device driver for my final project in college. But the
half-finished device doesn't support interrupt yet(those hardware guys...)

So I'm wondering if there is some way to poll the device for its status
and events.

Google tells me 'NAPI' uses a polling mechanism, but it still needs
hardware interrupt support :(

Any suggestions?


Thanks
Freeman

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20150323/6441e188/attachment.bin 

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

* Writing driver for a net device which does not support interrupt
  2015-03-23 10:51 Writing driver for a net device which does not support interrupt Freeman Zhang
@ 2015-03-23 15:51 ` Valdis.Kletnieks at vt.edu
  2015-03-24  1:24   ` Freeman Zhang
  2015-03-23 16:59 ` phil
  1 sibling, 1 reply; 6+ messages in thread
From: Valdis.Kletnieks at vt.edu @ 2015-03-23 15:51 UTC (permalink / raw)
  To: kernelnewbies

On Mon, 23 Mar 2015 18:51:51 +0800, Freeman Zhang said:
> I'm writing a net device driver for my final project in college. But the
> half-finished device doesn't support interrupt yet(those hardware guys...)
>
> So I'm wondering if there is some way to poll the device for its status
> and events.

As a realistic datapoint - if it still doesn't support interrupts, the *rest*
of it is probably still so buggy that trying to write a driver isn't worth
the effort.

It's doable if you are working with a group of talented and experienced
engineers - but if the hardware is also being done as a final project,
you're in for naught but misery.

You *could* do something like this:

      while (waiting) {
          status = read_status_bits(your_device);
          if (status & DATA_AVAIL_MASK) break;
          msleep(100);
      }

But having seen enough student hardware design projects in my life, I estimate
that if it still can't signal interrupts, the status bits probably aren't valid
either. (Think about it - a bog-simple implementation of interrupts would be
to just feed a transition-high on the appropriate status bit to the interrupt
pin, and use a read from the chip to clear the pin).

Good luck - I suspect you're going to need it....
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 848 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20150323/d9f1295d/attachment.bin 

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

* Writing driver for a net device which does not support interrupt
  2015-03-23 10:51 Writing driver for a net device which does not support interrupt Freeman Zhang
  2015-03-23 15:51 ` Valdis.Kletnieks at vt.edu
@ 2015-03-23 16:59 ` phil
  2015-03-24  1:34   ` Freeman Zhang
  1 sibling, 1 reply; 6+ messages in thread
From: phil @ 2015-03-23 16:59 UTC (permalink / raw)
  To: kernelnewbies



On 23/03/15 10:51, Freeman Zhang wrote:
> I'm writing a net device driver for my final project in college. But the
> half-finished device doesn't support interrupt yet(those hardware guys...)
>
> So I'm wondering if there is some way to poll the device for its status
> and events.

You should take a look at kernel timers, this is a rather old resource 
and was just the first hit in a google search but it should still be 
relevant.

http://www.ibm.com/developerworks/library/l-timers-list/

Kernel timers will sort of prepare you for interrupts i.e. a kernel 
timer will fire every $time_value and you can put your code which should 
normally run during an interrupt in the callback code.

I've used kernel timers to debug interrupts on our hardware devices, 
i.e. there have been times when the hardware has stopped raising 
interrupts and I've put timers in to cover this. For example a new 
firmware might work fine, but have completely broken interrupts or not 
fire interrupts often enough and timers can prove to the hardware guys 
that it's interrupts at fault ;)

hint: you might also want to look at tasklets and have your timer 
callback just call a tasklet.

Phil

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

* Writing driver for a net device which does not support interrupt
  2015-03-23 15:51 ` Valdis.Kletnieks at vt.edu
@ 2015-03-24  1:24   ` Freeman Zhang
  0 siblings, 0 replies; 6+ messages in thread
From: Freeman Zhang @ 2015-03-24  1:24 UTC (permalink / raw)
  To: kernelnewbies

Hi Valdis,

Thanks for your warning. I feel like I believe in my group and those
engineers. In fact, implementing interrupts is part of the plan, but,
yes, the prototype is really buggy.... However they are trying hard to
fix it, and I should not stand by just to watch, waiting for the
deadline, should I?

Anyway, this is a serious project. This work need to be done. And I just
figured out something that might solve the current problem and might be
easily modifid when hardware interrupt is available. I think I could use
soft interrupt to active NAPI polling, so that I can use existing
infrastructure, as what 'snull' does. What do you think?


Thanks again!
Freeman

-------- Original Message --------
> On Mon, 23 Mar 2015 18:51:51 +0800, Freeman Zhang said:
>> I'm writing a net device driver for my final project in college. But the
>> half-finished device doesn't support interrupt yet(those hardware guys...)
>>
>> So I'm wondering if there is some way to poll the device for its status
>> and events.
> 
> As a realistic datapoint - if it still doesn't support interrupts, the *rest*
> of it is probably still so buggy that trying to write a driver isn't worth
> the effort.
> 
> It's doable if you are working with a group of talented and experienced
> engineers - but if the hardware is also being done as a final project,
> you're in for naught but misery.
> 
> You *could* do something like this:
> 
>       while (waiting) {
>           status = read_status_bits(your_device);
>           if (status & DATA_AVAIL_MASK) break;
>           msleep(100);
>       }
> 
> But having seen enough student hardware design projects in my life, I estimate
> that if it still can't signal interrupts, the status bits probably aren't valid
> either. (Think about it - a bog-simple implementation of interrupts would be
> to just feed a transition-high on the appropriate status bit to the interrupt
> pin, and use a read from the chip to clear the pin).
> 
> Good luck - I suspect you're going to need it....
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20150324/db9d6838/attachment.bin 

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

* Writing driver for a net device which does not support interrupt
  2015-03-23 16:59 ` phil
@ 2015-03-24  1:34   ` Freeman Zhang
  2015-03-24 16:52     ` Daniel Baluta
  0 siblings, 1 reply; 6+ messages in thread
From: Freeman Zhang @ 2015-03-24  1:34 UTC (permalink / raw)
  To: kernelnewbies

Hi phil,

Thanks for your reply! I googled timer, it might be a solution except
that interval granularity is a little bit large. This device is for high
performance network. I'm not sure whether the missmatch will cause problem.

And I just figured another potential solution, to use soft interrupt to
active NAPI. I will spend some time to varify these ideas.


Thanks again!
Freeman

-------- Original Message --------
> 
> 
> On 23/03/15 10:51, Freeman Zhang wrote:
>> I'm writing a net device driver for my final project in college. But the
>> half-finished device doesn't support interrupt yet(those hardware
>> guys...)
>>
>> So I'm wondering if there is some way to poll the device for its status
>> and events.
> 
> You should take a look at kernel timers, this is a rather old resource
> and was just the first hit in a google search but it should still be
> relevant.
> 
> http://www.ibm.com/developerworks/library/l-timers-list/
> 
> Kernel timers will sort of prepare you for interrupts i.e. a kernel
> timer will fire every $time_value and you can put your code which should
> normally run during an interrupt in the callback code.
> 
> I've used kernel timers to debug interrupts on our hardware devices,
> i.e. there have been times when the hardware has stopped raising
> interrupts and I've put timers in to cover this. For example a new
> firmware might work fine, but have completely broken interrupts or not
> fire interrupts often enough and timers can prove to the hardware guys
> that it's interrupts at fault ;)
> 
> hint: you might also want to look at tasklets and have your timer
> callback just call a tasklet.
> 
> Phil

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20150324/ce71afc6/attachment.bin 

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

* Writing driver for a net device which does not support interrupt
  2015-03-24  1:34   ` Freeman Zhang
@ 2015-03-24 16:52     ` Daniel Baluta
  0 siblings, 0 replies; 6+ messages in thread
From: Daniel Baluta @ 2015-03-24 16:52 UTC (permalink / raw)
  To: kernelnewbies

On Tue, Mar 24, 2015 at 3:34 AM, Freeman Zhang
<freeman.zhang1992@gmail.com> wrote:
> Hi phil,
>
> Thanks for your reply! I googled timer, it might be a solution except
> that interval granularity is a little bit large. This device is for high
> performance network. I'm not sure whether the missmatch will cause problem.

Google for high resolution timers.

Daniel.

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

end of thread, other threads:[~2015-03-24 16:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-23 10:51 Writing driver for a net device which does not support interrupt Freeman Zhang
2015-03-23 15:51 ` Valdis.Kletnieks at vt.edu
2015-03-24  1:24   ` Freeman Zhang
2015-03-23 16:59 ` phil
2015-03-24  1:34   ` Freeman Zhang
2015-03-24 16:52     ` Daniel Baluta

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.