ether82598, etherigbe: remove receive buffer pool optimization
This commit is contained in:
parent
95b7745419
commit
c23715d268
2 changed files with 7 additions and 105 deletions
|
@ -268,7 +268,6 @@ typedef struct {
|
|||
uchar flag;
|
||||
int nrd;
|
||||
int ntd;
|
||||
int nrb;
|
||||
int rbsz;
|
||||
Lock slock;
|
||||
Lock alock;
|
||||
|
@ -309,8 +308,6 @@ enum {
|
|||
|
||||
static Ctlr *ctlrtab[4];
|
||||
static int nctlr;
|
||||
static Lock rblock;
|
||||
static Block *rbpool;
|
||||
|
||||
static void
|
||||
readstats(Ctlr *c)
|
||||
|
@ -400,32 +397,6 @@ ctl(Ether *, void *, long)
|
|||
return -1;
|
||||
}
|
||||
|
||||
static Block*
|
||||
rballoc(void)
|
||||
{
|
||||
Block *bp;
|
||||
|
||||
ilock(&rblock);
|
||||
if((bp = rbpool) != nil){
|
||||
rbpool = bp->next;
|
||||
bp->next = 0;
|
||||
_xinc(&bp->ref); /* prevent bp from being freed */
|
||||
}
|
||||
iunlock(&rblock);
|
||||
return bp;
|
||||
}
|
||||
|
||||
void
|
||||
rbfree(Block *b)
|
||||
{
|
||||
b->rp = b->wp = (uchar*)PGROUND((uintptr)b->base);
|
||||
b->flag &= ~(Bipck | Budpck | Btcpck | Bpktck);
|
||||
ilock(&rblock);
|
||||
b->next = rbpool;
|
||||
rbpool = b;
|
||||
iunlock(&rblock);
|
||||
}
|
||||
|
||||
#define Next(x, m) (((x)+1) & (m))
|
||||
|
||||
static int
|
||||
|
@ -545,12 +516,11 @@ replenish(Ctlr *c, uint rdh)
|
|||
m = c->nrd - 1;
|
||||
i = 0;
|
||||
for(rdt = c->rdt; Next(rdt, m) != rdh; rdt = Next(rdt, m)){
|
||||
r = c->rdba + rdt;
|
||||
if(!(b = rballoc())){
|
||||
print("82598: no buffers\n");
|
||||
break;
|
||||
}
|
||||
b = allocb(c->rbsz+BY2PG);
|
||||
b->rp = (uchar*)PGROUND((uintptr)b->base);
|
||||
b->wp = b->rp;
|
||||
c->rb[rdt] = b;
|
||||
r = c->rdba + rdt;
|
||||
r->addr[0] = PCIWADDR(b->rp);
|
||||
r->status = 0;
|
||||
c->rdfree++;
|
||||
|
@ -796,7 +766,6 @@ txinit(Ctlr *c)
|
|||
static void
|
||||
attach(Ether *e)
|
||||
{
|
||||
Block *b;
|
||||
Ctlr *c;
|
||||
int t;
|
||||
char buf[KNAMELEN];
|
||||
|
@ -824,23 +793,6 @@ attach(Ether *e)
|
|||
c->rb = (Block**)(c->tdba + c->ntd);
|
||||
c->tb = (Block**)(c->rb + c->nrd);
|
||||
|
||||
if(waserror()){
|
||||
while(b = rballoc()){
|
||||
b->free = 0;
|
||||
freeb(b);
|
||||
}
|
||||
free(c->alloc);
|
||||
c->alloc = nil;
|
||||
nexterror();
|
||||
}
|
||||
for(c->nrb = 0; c->nrb < 2*Nrb; c->nrb++){
|
||||
if(!(b = allocb(c->rbsz+BY2PG)))
|
||||
error(Enomem);
|
||||
b->free = rbfree;
|
||||
freeb(b);
|
||||
}
|
||||
poperror();
|
||||
|
||||
rxinit(c);
|
||||
txinit(c);
|
||||
|
||||
|
|
|
@ -466,7 +466,6 @@ typedef struct Ctlr {
|
|||
void* alloc; /* receive/transmit descriptors */
|
||||
int nrd;
|
||||
int ntd;
|
||||
int nrb; /* how many this Ctlr has in the pool */
|
||||
|
||||
int* nic;
|
||||
Lock imlock;
|
||||
|
@ -521,9 +520,6 @@ typedef struct Ctlr {
|
|||
static Ctlr* igbectlrhead;
|
||||
static Ctlr* igbectlrtail;
|
||||
|
||||
static Lock igberblock; /* free receive Blocks */
|
||||
static Block* igberbpool; /* receive Blocks for all igbe controllers */
|
||||
|
||||
static char* statistics[Nstatistics] = {
|
||||
"CRC Error",
|
||||
"Alignment Error",
|
||||
|
@ -761,35 +757,6 @@ igbemulticast(void* arg, uchar* addr, int add)
|
|||
csr32w(ctlr, Mta+x*4, ctlr->mta[x]);
|
||||
}
|
||||
|
||||
static Block*
|
||||
igberballoc(void)
|
||||
{
|
||||
Block *bp;
|
||||
|
||||
ilock(&igberblock);
|
||||
if((bp = igberbpool) != nil){
|
||||
igberbpool = bp->next;
|
||||
bp->next = nil;
|
||||
_xinc(&bp->ref); /* prevent bp from being freed */
|
||||
}
|
||||
iunlock(&igberblock);
|
||||
|
||||
return bp;
|
||||
}
|
||||
|
||||
static void
|
||||
igberbfree(Block* bp)
|
||||
{
|
||||
bp->rp = bp->lim - Rbsz;
|
||||
bp->wp = bp->rp;
|
||||
bp->flag &= ~(Bipck | Budpck | Btcpck | Bpktck);
|
||||
|
||||
ilock(&igberblock);
|
||||
bp->next = igberbpool;
|
||||
igberbpool = bp;
|
||||
iunlock(&igberblock);
|
||||
}
|
||||
|
||||
static void
|
||||
igbeim(Ctlr* ctlr, int im)
|
||||
{
|
||||
|
@ -1036,12 +1003,9 @@ igbereplenish(Ctlr* ctlr)
|
|||
while(NEXT(rdt, ctlr->nrd) != ctlr->rdh){
|
||||
rd = &ctlr->rdba[rdt];
|
||||
if(ctlr->rb[rdt] == nil){
|
||||
bp = igberballoc();
|
||||
if(bp == nil){
|
||||
iprint("#l%d: igbereplenish: no available buffers\n",
|
||||
ctlr->edev->ctlrno);
|
||||
break;
|
||||
}
|
||||
bp = allocb(Rbsz);
|
||||
bp->rp = bp->lim - Rbsz;
|
||||
bp->wp = bp->rp;
|
||||
ctlr->rb[rdt] = bp;
|
||||
rd->addr[0] = PCIWADDR(bp->rp);
|
||||
rd->addr[1] = 0;
|
||||
|
@ -1195,7 +1159,6 @@ igberproc(void* arg)
|
|||
static void
|
||||
igbeattach(Ether* edev)
|
||||
{
|
||||
Block *bp;
|
||||
Ctlr *ctlr;
|
||||
char name[KNAMELEN];
|
||||
|
||||
|
@ -1227,12 +1190,6 @@ igbeattach(Ether* edev)
|
|||
}
|
||||
|
||||
if(waserror()){
|
||||
while(ctlr->nrb > 0){
|
||||
bp = igberballoc();
|
||||
bp->free = nil;
|
||||
freeb(bp);
|
||||
ctlr->nrb--;
|
||||
}
|
||||
free(ctlr->tb);
|
||||
ctlr->tb = nil;
|
||||
free(ctlr->rb);
|
||||
|
@ -1243,13 +1200,6 @@ igbeattach(Ether* edev)
|
|||
nexterror();
|
||||
}
|
||||
|
||||
for(ctlr->nrb = 0; ctlr->nrb < Nrb; ctlr->nrb++){
|
||||
if((bp = allocb(Rbsz)) == nil)
|
||||
break;
|
||||
bp->free = igberbfree;
|
||||
freeb(bp);
|
||||
}
|
||||
|
||||
snprint(name, KNAMELEN, "#l%dlproc", edev->ctlrno);
|
||||
kproc(name, igbelproc, edev);
|
||||
|
||||
|
|
Loading…
Reference in a new issue