Subject: zs.c (was Re: problems with interrupts)
To: None <Chris_G_Demetriou@balvenie.pdl.cs.cmu.edu, torek@bsdi.com>
From: Brad Walker <bwalker@musings.com>
List: port-sparc
Date: 09/22/1995 01:06:49
> From torek@BSDI.COM Fri Sep 22 00:54 PDT 1995
> Date: Fri, 22 Sep 1995 01:54:31 -0600
> From: Chris Torek <torek@BSDI.COM>
> To: bwalker@musings.com, Chris_G_Demetriou@BALVENIE.PDL.CS.CMU.EDU
> Subject: Re: problems with interrupts
> Cc: port-sparc@NetBSD.ORG
> 

<stuff deleted>

> 
> Van Jacobson advised me not to do this.  I forget the exact details
> as to why, but I trusted he was right...
> 

I hate to disagree with my esteemed colleague, but I must. 8-) I'm
looking at the data books right now. Also, I've verified this with
several friends that this is the proper way of doing things. There
is nothing wrong or inconsistent with letting the chip provide
vectoring for you..

Here is the way I've implemented it. Do I need to do a diff, send-pr
or what, when I have improvements on the code. I could use some
guidance on this.

        for (a = zslist; a != NULL; a = b->cs_next) {
                rr3 = ZS_READ(a->cs_zc, 3);
 
#define RR3_MASK (ZSRR3_IP_A_RX|ZSRR3_IP_A_TX|ZSRR3_IP_A_STAT|ZSRR3_IP_B_RX|ZSRR
3_IP_B_TX|ZSRR3_IP_B_STAT)
 
                zc = a->cs_zc;
                i = a->cs_rbput;
                intflags |= 2;
                switch (rr3 & RR3_MASK) {
                case ZSRR3_IP_A_RX:
                        if ((v = zsrint(a, zc)) != 0) {
                                a->cs_rbuf[i++ & ZLRB_RING_MASK] = v;
                                intflags |= 1;
                        } 
                        a->cs_rbput = i;
                        goto a_return;
                        break;

                case ZSRR3_IP_A_TX:
                        if ((v = zsxint(a, zc)) != 0) {
                                a->cs_rbuf[i++ & ZLRB_RING_MASK] = v;
                                intflags |= 1;
                        }
                        a->cs_rbput = i;
                        goto a_return;
                        break;
        
                                  
                case ZSRR3_IP_A_STAT:
                        if ((v = zssint(a, zc)) != 0) {
                                a->cs_rbuf[i++ & ZLRB_RING_MASK] = v;
                                intflags |= 1;
                        }
                        a->cs_rbput = i;
                        goto a_return;
                        break;
                default:
                        intflags &= 2;
                } 
                
                zc = b->cs_zc;
                i = b->cs_rbput;
                intflags |= 2; 
                switch (rr3 & RR3_MASK) {
                case ZSRR3_IP_B_RX:
                        if ((v = zsrint(b, zc)) != 0) {
                                b->cs_rbuf[i++ & ZLRB_RING_MASK] = v;
                                intflags |= 1;
                        }
                        b->cs_rbput = i;
                        break;

                         
                case ZSRR3_IP_B_TX:
                        if ((v = zsxint(b, zc)) != 0) {
                                b->cs_rbuf[i++ & ZLRB_RING_MASK] = v;
                                intflags |= 1;
                        }        
                        b->cs_rbput = i;
                        break;
                         
                case ZSRR3_IP_B_STAT:
                        if ((v = zssint(b, zc)) != 0) {
                                b->cs_rbuf[i++ & ZLRB_RING_MASK] = v;
                                intflags |= 1;
                        }        
                        b->cs_rbput = i;
                        break;
                         
                default:
                        intflags &= 2;
                }        
                 
a_return:

        }


Let me know what you think..

-brad w.