devether: remove (unimplemented) detach, allow device creation on attach
we allow devether to create ethernet cards on attach. this is useull for virtual cards like the sink driver, so we can create a sink by simply: bind -a '#l2:sink ea=112233445566' /net the detach routine was never called, so remove it from the few drivers that attempted to implement it.
This commit is contained in:
parent
5560efb3db
commit
f0a314605f
7 changed files with 48 additions and 34 deletions
|
@ -1614,7 +1614,6 @@ m10gpnp(Ether *e)
|
||||||
memmove(e->ea, c->ra, Eaddrlen);
|
memmove(e->ea, c->ra, Eaddrlen);
|
||||||
|
|
||||||
e->attach = m10gattach;
|
e->attach = m10gattach;
|
||||||
e->detach = m10gshutdown;
|
|
||||||
e->transmit = m10gtransmit;
|
e->transmit = m10gtransmit;
|
||||||
e->interrupt = m10ginterrupt;
|
e->interrupt = m10ginterrupt;
|
||||||
e->ifstat = m10gifstat;
|
e->ifstat = m10gifstat;
|
||||||
|
|
|
@ -1234,7 +1234,6 @@ wavelanreset(Ether* ether, Ctlr *ctlr)
|
||||||
ether->ctlr = ctlr;
|
ether->ctlr = ctlr;
|
||||||
ether->mbps = 10;
|
ether->mbps = 10;
|
||||||
ether->attach = w_attach;
|
ether->attach = w_attach;
|
||||||
ether->detach = w_detach;
|
|
||||||
ether->transmit = w_transmit;
|
ether->transmit = w_transmit;
|
||||||
ether->ifstat = w_ifstat;
|
ether->ifstat = w_ifstat;
|
||||||
ether->ctl = w_ctl;
|
ether->ctl = w_ctl;
|
||||||
|
|
|
@ -14,23 +14,35 @@ extern int eipfmt(Fmt*);
|
||||||
extern ushort ipcsum(uchar *);
|
extern ushort ipcsum(uchar *);
|
||||||
|
|
||||||
static Ether *etherxx[MaxEther];
|
static Ether *etherxx[MaxEther];
|
||||||
|
static Ether *etherprobe(int cardno, int ctlrno, char *conf);
|
||||||
|
|
||||||
Chan*
|
Chan*
|
||||||
etherattach(char* spec)
|
etherattach(char* spec)
|
||||||
{
|
{
|
||||||
ulong ctlrno;
|
ulong ctlrno;
|
||||||
char *p;
|
char *conf;
|
||||||
Chan *chan;
|
Chan *chan;
|
||||||
|
|
||||||
ctlrno = 0;
|
ctlrno = 0;
|
||||||
if(spec && *spec){
|
if(*spec){
|
||||||
ctlrno = strtoul(spec, &p, 0);
|
ctlrno = strtoul(spec, &conf, 0);
|
||||||
if((ctlrno == 0 && p == spec) || *p || (ctlrno >= MaxEther))
|
if(ctlrno >= MaxEther)
|
||||||
error(Ebadarg);
|
error(Enodev);
|
||||||
|
if(conf == spec)
|
||||||
|
error(Ebadspec);
|
||||||
|
if(*conf){
|
||||||
|
if(*conf != ':')
|
||||||
|
error(Ebadspec);
|
||||||
|
*conf++ = 0;
|
||||||
|
if(!iseve())
|
||||||
|
error(Enoattach);
|
||||||
|
if(etherxx[ctlrno] != nil)
|
||||||
|
error(Einuse);
|
||||||
|
etherxx[ctlrno] = etherprobe(-1, ctlrno, conf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(etherxx[ctlrno] == 0)
|
if(etherxx[ctlrno] == nil)
|
||||||
error(Enodev);
|
error(Enodev);
|
||||||
|
|
||||||
chan = devattach('l', spec);
|
chan = devattach('l', spec);
|
||||||
if(waserror()){
|
if(waserror()){
|
||||||
chanfree(chan);
|
chanfree(chan);
|
||||||
|
@ -350,7 +362,7 @@ addethercard(char* t, int (*r)(Ether*))
|
||||||
}
|
}
|
||||||
|
|
||||||
static Ether*
|
static Ether*
|
||||||
etherprobe(int cardno, int ctlrno)
|
etherprobe(int cardno, int ctlrno, char *conf)
|
||||||
{
|
{
|
||||||
int i, lg;
|
int i, lg;
|
||||||
ulong mb, bsz;
|
ulong mb, bsz;
|
||||||
|
@ -370,36 +382,41 @@ etherprobe(int cardno, int ctlrno)
|
||||||
ether->maxmtu = ETHERMAXTU;
|
ether->maxmtu = ETHERMAXTU;
|
||||||
|
|
||||||
if(cardno < 0){
|
if(cardno < 0){
|
||||||
if(isaconfig("ether", ctlrno, ether) == 0){
|
if(conf != nil){
|
||||||
free(ether);
|
kstrdup(ðer->type, conf);
|
||||||
return nil;
|
ether->nopt = tokenize(ether->type, ether->opt, nelem(ether->opt));
|
||||||
}
|
if(ether->nopt < 1)
|
||||||
for(cardno = 0; cards[cardno].type; cardno++){
|
goto Nope;
|
||||||
if(cistrcmp(cards[cardno].type, ether->type))
|
memmove(ðer->opt[0], ðer->opt[1], --ether->nopt*sizeof(ether->opt[0]));
|
||||||
continue;
|
} else if(isaconfig("ether", ctlrno, ether) == 0)
|
||||||
for(i = 0; i < ether->nopt; i++){
|
goto Nope;
|
||||||
if(strncmp(ether->opt[i], "ea=", 3))
|
|
||||||
continue;
|
for(cardno = 0; cards[cardno].type != nil; cardno++)
|
||||||
|
if(cistrcmp(cards[cardno].type, ether->type) == 0)
|
||||||
|
break;
|
||||||
|
if(cards[cardno].type == nil)
|
||||||
|
goto Nope;
|
||||||
|
|
||||||
|
for(i = 0; i < ether->nopt; i++){
|
||||||
|
if(strncmp(ether->opt[i], "ea=", 3) == 0){
|
||||||
if(parseether(ether->ea, ðer->opt[i][3]))
|
if(parseether(ether->ea, ðer->opt[i][3]))
|
||||||
memset(ether->ea, 0, Eaddrlen);
|
memset(ether->ea, 0, Eaddrlen);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(cardno >= MaxEther || cards[cardno].type == nil)
|
||||||
if(cardno >= MaxEther || cards[cardno].type == nil){
|
goto Nope;
|
||||||
free(ether);
|
|
||||||
return nil;
|
|
||||||
}
|
|
||||||
snprint(ether->name, sizeof(ether->name), "ether%d", ctlrno);
|
snprint(ether->name, sizeof(ether->name), "ether%d", ctlrno);
|
||||||
if(cards[cardno].reset(ether) < 0){
|
if(cards[cardno].reset(ether) < 0){
|
||||||
|
Nope:
|
||||||
|
if(conf != nil) free(ether->type); /* see kstrdup() above */
|
||||||
free(ether);
|
free(ether);
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
ether->type = cards[cardno].type;
|
||||||
|
|
||||||
print("#l%d: %s: %dMbps port 0x%luX irq %d ea %E\n",
|
print("#l%d: %s: %dMbps port 0x%luX irq %d ea %E\n",
|
||||||
ctlrno, cards[cardno].type,
|
ctlrno, ether->type, ether->mbps, ether->port, ether->irq, ether->ea);
|
||||||
ether->mbps, ether->port, ether->irq, ether->ea);
|
|
||||||
|
|
||||||
/* compute log10(ether->mbps) into lg */
|
/* compute log10(ether->mbps) into lg */
|
||||||
for(lg = 0, mb = ether->mbps; mb >= 10; lg++)
|
for(lg = 0, mb = ether->mbps; mb >= 10; lg++)
|
||||||
|
@ -439,7 +456,7 @@ etherreset(void)
|
||||||
fmtinstall('E', eipfmt);
|
fmtinstall('E', eipfmt);
|
||||||
|
|
||||||
for(ctlrno = 0; ctlrno < MaxEther; ctlrno++){
|
for(ctlrno = 0; ctlrno < MaxEther; ctlrno++){
|
||||||
if((ether = etherprobe(-1, ctlrno)) == nil)
|
if((ether = etherprobe(-1, ctlrno, nil)) == nil)
|
||||||
continue;
|
continue;
|
||||||
etherxx[ctlrno] = ether;
|
etherxx[ctlrno] = ether;
|
||||||
}
|
}
|
||||||
|
@ -451,7 +468,7 @@ etherreset(void)
|
||||||
ctlrno++;
|
ctlrno++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if((ether = etherprobe(cardno, ctlrno)) == nil){
|
if((ether = etherprobe(cardno, ctlrno, nil)) == nil){
|
||||||
cardno++;
|
cardno++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@ struct Ether {
|
||||||
int maxmtu;
|
int maxmtu;
|
||||||
|
|
||||||
void (*attach)(Ether*); /* filled in by reset routine */
|
void (*attach)(Ether*); /* filled in by reset routine */
|
||||||
void (*detach)(Ether*);
|
|
||||||
void (*transmit)(Ether*);
|
void (*transmit)(Ether*);
|
||||||
long (*ifstat)(Ether*, void*, long, ulong);
|
long (*ifstat)(Ether*, void*, long, ulong);
|
||||||
long (*ctl)(Ether*, void*, long); /* custom ctl messages */
|
long (*ctl)(Ether*, void*, long); /* custom ctl messages */
|
||||||
|
|
|
@ -80,7 +80,7 @@ netifgen(Chan *c, char*, Dirtab *vp, int, int i, Dir *dp)
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
q.path = Naddrqid;
|
q.path = Naddrqid;
|
||||||
devdir(c, q, "addr", 0, eve, 0666, dp);
|
devdir(c, q, "addr", 0, eve, 0444, dp);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
q.path = Nstatqid;
|
q.path = Nstatqid;
|
||||||
|
|
|
@ -474,7 +474,6 @@ pnp(Ether* ether)
|
||||||
memmove(ether->ea, ea, sizeof ether->ea);
|
memmove(ether->ea, ea, sizeof ether->ea);
|
||||||
ether->mbps = 100; // XXX what speed?
|
ether->mbps = 100; // XXX what speed?
|
||||||
ether->attach = etherxenattach;
|
ether->attach = etherxenattach;
|
||||||
ether->detach = nil;
|
|
||||||
ether->transmit = etherxentransmit;
|
ether->transmit = etherxentransmit;
|
||||||
ether->irq = -1;
|
ether->irq = -1;
|
||||||
ether->tbdf = BUSUNKNOWN;
|
ether->tbdf = BUSUNKNOWN;
|
||||||
|
|
|
@ -159,13 +159,14 @@ struct Mach
|
||||||
int stack[1];
|
int stack[1];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define NISAOPT 8
|
||||||
struct ISAConf
|
struct ISAConf
|
||||||
{
|
{
|
||||||
char *type;
|
char *type;
|
||||||
ulong port;
|
ulong port;
|
||||||
int irq;
|
int irq;
|
||||||
int nopt;
|
int nopt;
|
||||||
char *opt[1];
|
char *opt[NISAOPT];
|
||||||
};
|
};
|
||||||
#define BUSUNKNOWN -1
|
#define BUSUNKNOWN -1
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue