fix multiport support in ethernet drivers

This commit is contained in:
David van Moolenbroek 2010-05-10 20:19:55 +00:00
parent b7bf2733d6
commit 713454aca7
10 changed files with 72 additions and 35 deletions

View File

@ -37,7 +37,7 @@ _PROTOTYPE( PRIVATE void do_vread_s, (const message *, int); );
_PROTOTYPE( PRIVATE void do_watchdog, (void *); ); _PROTOTYPE( PRIVATE void do_watchdog, (void *); );
_PROTOTYPE( PRIVATE void de_update_conf, (dpeth_t *); ); _PROTOTYPE( PRIVATE void de_update_conf, (dpeth_t *); );
_PROTOTYPE( PRIVATE int de_probe, (dpeth_t *); ); _PROTOTYPE( PRIVATE int de_probe, (dpeth_t *, int skip); );
_PROTOTYPE( PRIVATE void de_conf_addr, (dpeth_t *); ); _PROTOTYPE( PRIVATE void de_conf_addr, (dpeth_t *); );
_PROTOTYPE( PRIVATE void de_first_init, (dpeth_t *); ); _PROTOTYPE( PRIVATE void de_first_init, (dpeth_t *); );
_PROTOTYPE( PRIVATE void de_reset, (const dpeth_t *); ); _PROTOTYPE( PRIVATE void de_reset, (const dpeth_t *); );
@ -213,7 +213,7 @@ PRIVATE void do_conf(const message * mp)
if (dep->de_mode == DEM_DISABLED) { if (dep->de_mode == DEM_DISABLED) {
de_update_conf(dep); de_update_conf(dep);
pci_init(); pci_init();
if (dep->de_mode == DEM_ENABLED && !de_probe(dep)) { if (dep->de_mode == DEM_ENABLED && !de_probe(dep, port)) {
printf("%s: warning no ethernet card found at 0x%04X\n", printf("%s: warning no ethernet card found at 0x%04X\n",
dep->de_name, dep->de_base_port); dep->de_name, dep->de_base_port);
dep->de_mode = DEM_DISABLED; dep->de_mode = DEM_DISABLED;
@ -320,7 +320,7 @@ PRIVATE void do_watchdog(void *UNUSED(message))
return; return;
} }
PRIVATE int de_probe(dpeth_t *dep){ PRIVATE int de_probe(dpeth_t *dep, int skip){
int i, r, devind; int i, r, devind;
u16_t vid, did, temp16; u16_t vid, did, temp16;
@ -334,7 +334,11 @@ PRIVATE int de_probe(dpeth_t *dep){
{ {
if ( DEC21140A_VID == vid && if ( DEC21140A_VID == vid &&
DEC21140A_DID == did) DEC21140A_DID == did)
break; {
if (!skip)
break;
skip--;
}
r= pci_next_dev(&devind, &vid, &did); r= pci_next_dev(&devind, &vid, &did);
if (!r) if (!r)

View File

@ -466,7 +466,7 @@ static void pci_conf()
{ {
continue; continue;
} }
if (!rtl_probe(dep)) if (!rtl_probe(dep, i))
dep->de_pci= -1; dep->de_pci= -1;
} }
} }

View File

@ -23,7 +23,7 @@ _PROTOTYPE( int ne_probe, (struct dpeth *dep) );
_PROTOTYPE( void ne_init, (struct dpeth *dep) ); _PROTOTYPE( void ne_init, (struct dpeth *dep) );
/* rtl8029.c */ /* rtl8029.c */
_PROTOTYPE( int rtl_probe, (struct dpeth *dep) ); _PROTOTYPE( int rtl_probe, (struct dpeth *dep, int skip) );
/* wdeth.c */ /* wdeth.c */
_PROTOTYPE( int wdeth_probe, (struct dpeth* dep) ); _PROTOTYPE( int wdeth_probe, (struct dpeth* dep) );

View File

@ -42,8 +42,9 @@ _PROTOTYPE( static void set_ee_word, (dpeth_t *dep, int a, u16_t w) );
_PROTOTYPE( static void ee_wds, (dpeth_t *dep) ); _PROTOTYPE( static void ee_wds, (dpeth_t *dep) );
#endif #endif
PUBLIC int rtl_probe(dep) PUBLIC int rtl_probe(dep, skip)
struct dpeth *dep; struct dpeth *dep;
int skip;
{ {
int i, r, devind, just_one; int i, r, devind, just_one;
u16_t vid, did; u16_t vid, did;
@ -89,8 +90,11 @@ struct dpeth *dep;
} }
break; break;
} }
if (pcitab[i].vid != 0 || pcitab[i].did != 0) if (pcitab[i].vid != 0 || pcitab[i].did != 0) {
break; if (just_one || !skip)
break;
skip--;
}
if (just_one) if (just_one)
{ {

View File

@ -33,7 +33,7 @@ PRIVATE e1000_t e1000_table[E1000_PORT_NR];
_PROTOTYPE( PRIVATE void e1000_init, (message *mp) ); _PROTOTYPE( PRIVATE void e1000_init, (message *mp) );
_PROTOTYPE( PRIVATE void e1000_init_pci, (void) ); _PROTOTYPE( PRIVATE void e1000_init_pci, (void) );
_PROTOTYPE( PRIVATE int e1000_probe, (e1000_t *e) ); _PROTOTYPE( PRIVATE int e1000_probe, (e1000_t *e, int skip) );
_PROTOTYPE( PRIVATE int e1000_init_hw, (e1000_t *e) ); _PROTOTYPE( PRIVATE int e1000_init_hw, (e1000_t *e) );
_PROTOTYPE( PRIVATE void e1000_init_addr, (e1000_t *e) ); _PROTOTYPE( PRIVATE void e1000_init_addr, (e1000_t *e) );
_PROTOTYPE( PRIVATE void e1000_init_buf, (e1000_t *e) ); _PROTOTYPE( PRIVATE void e1000_init_buf, (e1000_t *e) );
@ -236,14 +236,14 @@ PRIVATE void e1000_init_pci()
{ {
strcpy(e->name, "e1000#0"); strcpy(e->name, "e1000#0");
e->name[6] += i; e->name[6] += i;
e1000_probe(e); e1000_probe(e, i);
} }
} }
/*===========================================================================* /*===========================================================================*
* e1000_probe * * e1000_probe *
*===========================================================================*/ *===========================================================================*/
PRIVATE int e1000_probe(e1000_t *e) PRIVATE int e1000_probe(e1000_t *e, int skip)
{ {
int i, r, devind; int i, r, devind;
u16_t vid, did; u16_t vid, did;
@ -274,7 +274,11 @@ PRIVATE int e1000_probe(e1000_t *e)
break; break;
} }
if (pcitab_e1000[i] != 0) if (pcitab_e1000[i] != 0)
break; {
if (!skip)
break;
skip--;
}
if (!(r = pci_next_dev(&devind, &vid, &did))) if (!(r = pci_next_dev(&devind, &vid, &did)))
{ {

View File

@ -224,7 +224,7 @@ PRIVATE u32_t system_hz;
_PROTOTYPE( static void fxp_init, (message *mp) ); _PROTOTYPE( static void fxp_init, (message *mp) );
_PROTOTYPE( static void fxp_pci_conf, (void) ); _PROTOTYPE( static void fxp_pci_conf, (void) );
_PROTOTYPE( static int fxp_probe, (fxp_t *fp) ); _PROTOTYPE( static int fxp_probe, (fxp_t *fp, int skip) );
_PROTOTYPE( static void fxp_conf_hw, (fxp_t *fp) ); _PROTOTYPE( static void fxp_conf_hw, (fxp_t *fp) );
_PROTOTYPE( static void fxp_init_hw, (fxp_t *fp) ); _PROTOTYPE( static void fxp_init_hw, (fxp_t *fp) );
_PROTOTYPE( static void fxp_init_buf, (fxp_t *fp) ); _PROTOTYPE( static void fxp_init_buf, (fxp_t *fp) );
@ -567,7 +567,7 @@ static void fxp_pci_conf()
{ {
continue; continue;
} }
if (fxp_probe(fp)) if (fxp_probe(fp, i))
fp->fxp_seen= TRUE; fp->fxp_seen= TRUE;
} }
} }
@ -576,7 +576,7 @@ static void fxp_pci_conf()
/*===========================================================================* /*===========================================================================*
* fxp_probe * * fxp_probe *
*===========================================================================*/ *===========================================================================*/
static int fxp_probe(fxp_t *fp) static int fxp_probe(fxp_t *fp, int skip)
{ {
int i, r, devind, just_one; int i, r, devind, just_one;
u16_t vid, did; u16_t vid, did;
@ -621,7 +621,11 @@ static int fxp_probe(fxp_t *fp)
break; break;
} }
if (pcitab_fxp[i].vid != 0) if (pcitab_fxp[i].vid != 0)
break; {
if (just_one || !skip)
break;
skip--;
}
if (just_one) if (just_one)
{ {

View File

@ -125,7 +125,7 @@ _PROTOTYPE( static void lance_dump, (void) );
_PROTOTYPE( static void getAddressing, (int devind, ether_card_t *ec) ); _PROTOTYPE( static void getAddressing, (int devind, ether_card_t *ec) );
/* probe+init LANCE cards */ /* probe+init LANCE cards */
_PROTOTYPE( static int lance_probe, (ether_card_t *ec) ); _PROTOTYPE( static int lance_probe, (ether_card_t *ec, int skip) );
_PROTOTYPE( static void lance_init_card, (ether_card_t *ec) ); _PROTOTYPE( static void lance_init_card, (ether_card_t *ec) );
/* Accesses Lance Control and Status Registers */ /* Accesses Lance Control and Status Registers */
@ -622,7 +622,7 @@ ether_card_t *ec;
if (ec->mode != EC_ENABLED) if (ec->mode != EC_ENABLED)
return; return;
if (!lance_probe(ec)) if (!lance_probe(ec, ifnr))
{ {
printf("%s: No ethernet card found on PCI-BIOS info.\n", printf("%s: No ethernet card found on PCI-BIOS info.\n",
ec->port_name); ec->port_name);
@ -1463,8 +1463,9 @@ ether_card_t *ec;
/*===========================================================================* /*===========================================================================*
* lance_probe * * lance_probe *
*===========================================================================*/ *===========================================================================*/
static int lance_probe(ec) static int lance_probe(ec, skip)
ether_card_t *ec; ether_card_t *ec;
int skip;
{ {
unsigned short pci_cmd; unsigned short pci_cmd;
unsigned short ioaddr; unsigned short ioaddr;
@ -1510,7 +1511,11 @@ ether_card_t *ec;
break; break;
} }
if (pcitab[i].vid != 0) if (pcitab[i].vid != 0)
break; {
if (just_one || !skip)
break;
skip--;
}
if (just_one) if (just_one)
{ {

View File

@ -190,7 +190,7 @@ _PROTOTYPE (static void or_readv, (message * mp, int from_int, int vectored));
_PROTOTYPE (static void or_writev_s, (message * mp, int from_int)); _PROTOTYPE (static void or_writev_s, (message * mp, int from_int));
_PROTOTYPE (static void or_readv_s, (message * mp, int from_int)); _PROTOTYPE (static void or_readv_s, (message * mp, int from_int));
_PROTOTYPE (static void reply, (t_or * orp, int err, int may_block)); _PROTOTYPE (static void reply, (t_or * orp, int err, int may_block));
_PROTOTYPE (static int or_probe, (t_or *)); _PROTOTYPE (static int or_probe, (t_or *, int skip));
_PROTOTYPE (static void or_ev_info, (t_or *)); _PROTOTYPE (static void or_ev_info, (t_or *));
_PROTOTYPE (static void or_init, (message *)); _PROTOTYPE (static void or_init, (message *));
_PROTOTYPE (static void or_pci_conf, (void)); _PROTOTYPE (static void or_pci_conf, (void));
@ -636,7 +636,7 @@ static void or_pci_conf () {
orp->or_pci_func) != 0) != h) { orp->or_pci_func) != 0) != h) {
continue; continue;
} }
if (or_probe (orp)) if (or_probe (orp, i))
orp->or_seen = TRUE; orp->or_seen = TRUE;
} }
} }
@ -647,7 +647,7 @@ static void or_pci_conf () {
* Try to find the card based on information provided by pci and get irq and * * Try to find the card based on information provided by pci and get irq and *
* bar * * bar *
*****************************************************************************/ *****************************************************************************/
static int or_probe (t_or * orp) static int or_probe (t_or * orp, int skip)
{ {
u8_t ilr; u8_t ilr;
u32_t bar; u32_t bar;
@ -694,8 +694,15 @@ static int or_probe (t_or * orp)
/* we have found the card in the pci bus */ /* we have found the card in the pci bus */
break; break;
} }
if (pcitab[i].vid != 0)
break; /* unless we are looking for a specific device, we may have to
* skip a number of cards because they are already reserved for
* other (lower) ports of this driver */
if (pcitab[i].vid != 0) {
if (just_one || !skip)
break;
skip--;
}
if (just_one) { if (just_one) {
printf ("%s: wrong PCI device", orp->or_name); printf ("%s: wrong PCI device", orp->or_name);

View File

@ -140,7 +140,7 @@ static void my_outl(u16_t port, u32_t value) {
_PROTOTYPE( static void rl_init, (message *mp) ); _PROTOTYPE( static void rl_init, (message *mp) );
_PROTOTYPE( static void rl_pci_conf, (void) ); _PROTOTYPE( static void rl_pci_conf, (void) );
_PROTOTYPE( static int rl_probe, (re_t *rep) ); _PROTOTYPE( static int rl_probe, (re_t *rep, int skip) );
_PROTOTYPE( static void rl_conf_hw, (re_t *rep) ); _PROTOTYPE( static void rl_conf_hw, (re_t *rep) );
_PROTOTYPE( static void rl_init_buf, (re_t *rep) ); _PROTOTYPE( static void rl_init_buf, (re_t *rep) );
_PROTOTYPE( static void rl_init_hw, (re_t *rep) ); _PROTOTYPE( static void rl_init_hw, (re_t *rep) );
@ -542,7 +542,7 @@ static void rl_pci_conf()
{ {
continue; continue;
} }
if (rl_probe(rep)) if (rl_probe(rep, i))
rep->re_seen= TRUE; rep->re_seen= TRUE;
} }
} }
@ -551,8 +551,9 @@ static void rl_pci_conf()
/*===========================================================================* /*===========================================================================*
* rl_probe * * rl_probe *
*===========================================================================*/ *===========================================================================*/
static int rl_probe(rep) static int rl_probe(rep, skip)
re_t *rep; re_t *rep;
int skip;
{ {
int i, r, devind, just_one; int i, r, devind, just_one;
u16_t vid, did; u16_t vid, did;
@ -597,7 +598,11 @@ re_t *rep;
break; break;
} }
if (pcitab[i].vid != 0) if (pcitab[i].vid != 0)
break; {
if (just_one || !skip)
break;
skip--;
}
if (just_one) if (just_one)
{ {

View File

@ -237,7 +237,7 @@ static void my_outl(u16_t port, u32_t value)
_PROTOTYPE( static void rl_init, (message *mp) ); _PROTOTYPE( static void rl_init, (message *mp) );
_PROTOTYPE( static void rl_pci_conf, (void) ); _PROTOTYPE( static void rl_pci_conf, (void) );
_PROTOTYPE( static int rl_probe, (re_t *rep) ); _PROTOTYPE( static int rl_probe, (re_t *rep, int skip) );
_PROTOTYPE( static void rl_conf_hw, (re_t *rep) ); _PROTOTYPE( static void rl_conf_hw, (re_t *rep) );
_PROTOTYPE( static void rl_init_buf, (re_t *rep) ); _PROTOTYPE( static void rl_init_buf, (re_t *rep) );
_PROTOTYPE( static void rl_init_hw, (re_t *rep) ); _PROTOTYPE( static void rl_init_hw, (re_t *rep) );
@ -686,7 +686,7 @@ static void rl_pci_conf()
rep->re_pcifunc) != 0) != h) { rep->re_pcifunc) != 0) != h) {
continue; continue;
} }
if (rl_probe(rep)) if (rl_probe(rep, i))
rep->re_seen = TRUE; rep->re_seen = TRUE;
} }
} }
@ -695,8 +695,9 @@ static void rl_pci_conf()
/*===========================================================================* /*===========================================================================*
* rl_probe * * rl_probe *
*===========================================================================*/ *===========================================================================*/
static int rl_probe(rep) static int rl_probe(rep, skip)
re_t *rep; re_t *rep;
int skip;
{ {
int i, r, devind, just_one; int i, r, devind, just_one;
u16_t vid, did; u16_t vid, did;
@ -734,8 +735,11 @@ re_t *rep;
} }
break; break;
} }
if (pcitab[i].vid != 0) if (pcitab[i].vid != 0) {
break; if (just_one || !skip)
break;
skip--;
}
if (just_one) { if (just_one) {
printf("%s: wrong PCI device (%04x/%04x) found at %d.%d.%d\n", printf("%s: wrong PCI device (%04x/%04x) found at %d.%d.%d\n",