From: David van Moolenbroek Date: Mon, 10 May 2010 20:19:55 +0000 (+0000) Subject: fix multiport support in ethernet drivers X-Git-Tag: v3.1.7~66 X-Git-Url: http://zhaoyanbai.com/repos/?a=commitdiff_plain;h=713454aca70ddba4839c59260f69e39141a2f282;p=minix.git fix multiport support in ethernet drivers --- diff --git a/drivers/dec21140A/dec21140A.c b/drivers/dec21140A/dec21140A.c index 1ac73f2e3..8943003a6 100644 --- a/drivers/dec21140A/dec21140A.c +++ b/drivers/dec21140A/dec21140A.c @@ -37,7 +37,7 @@ _PROTOTYPE( PRIVATE void do_vread_s, (const message *, int); ); _PROTOTYPE( PRIVATE void do_watchdog, (void *); ); _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_first_init, (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) { de_update_conf(dep); 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", dep->de_name, dep->de_base_port); dep->de_mode = DEM_DISABLED; @@ -320,7 +320,7 @@ PRIVATE void do_watchdog(void *UNUSED(message)) return; } -PRIVATE int de_probe(dpeth_t *dep){ +PRIVATE int de_probe(dpeth_t *dep, int skip){ int i, r, devind; u16_t vid, did, temp16; @@ -334,7 +334,11 @@ PRIVATE int de_probe(dpeth_t *dep){ { if ( DEC21140A_VID == vid && DEC21140A_DID == did) - break; + { + if (!skip) + break; + skip--; + } r= pci_next_dev(&devind, &vid, &did); if (!r) diff --git a/drivers/dp8390/dp8390.c b/drivers/dp8390/dp8390.c index ad15fe054..2700b348c 100644 --- a/drivers/dp8390/dp8390.c +++ b/drivers/dp8390/dp8390.c @@ -466,7 +466,7 @@ static void pci_conf() { continue; } - if (!rtl_probe(dep)) + if (!rtl_probe(dep, i)) dep->de_pci= -1; } } diff --git a/drivers/dp8390/local.h b/drivers/dp8390/local.h index 21b1596c4..0e1e1c5f1 100644 --- a/drivers/dp8390/local.h +++ b/drivers/dp8390/local.h @@ -23,7 +23,7 @@ _PROTOTYPE( int ne_probe, (struct dpeth *dep) ); _PROTOTYPE( void ne_init, (struct dpeth *dep) ); /* rtl8029.c */ -_PROTOTYPE( int rtl_probe, (struct dpeth *dep) ); +_PROTOTYPE( int rtl_probe, (struct dpeth *dep, int skip) ); /* wdeth.c */ _PROTOTYPE( int wdeth_probe, (struct dpeth* dep) ); diff --git a/drivers/dp8390/rtl8029.c b/drivers/dp8390/rtl8029.c index d2ff930ec..b3b47e37b 100644 --- a/drivers/dp8390/rtl8029.c +++ b/drivers/dp8390/rtl8029.c @@ -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) ); #endif -PUBLIC int rtl_probe(dep) +PUBLIC int rtl_probe(dep, skip) struct dpeth *dep; +int skip; { int i, r, devind, just_one; u16_t vid, did; @@ -89,8 +90,11 @@ struct dpeth *dep; } break; } - if (pcitab[i].vid != 0 || pcitab[i].did != 0) - break; + if (pcitab[i].vid != 0 || pcitab[i].did != 0) { + if (just_one || !skip) + break; + skip--; + } if (just_one) { diff --git a/drivers/e1000/e1000.c b/drivers/e1000/e1000.c index 214ef69fd..4cec31d92 100644 --- a/drivers/e1000/e1000.c +++ b/drivers/e1000/e1000.c @@ -33,7 +33,7 @@ PRIVATE e1000_t e1000_table[E1000_PORT_NR]; _PROTOTYPE( PRIVATE void e1000_init, (message *mp) ); _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 void e1000_init_addr, (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"); e->name[6] += i; - e1000_probe(e); + e1000_probe(e, i); } } /*===========================================================================* * e1000_probe * *===========================================================================*/ -PRIVATE int e1000_probe(e1000_t *e) +PRIVATE int e1000_probe(e1000_t *e, int skip) { int i, r, devind; u16_t vid, did; @@ -274,7 +274,11 @@ PRIVATE int e1000_probe(e1000_t *e) break; } if (pcitab_e1000[i] != 0) - break; + { + if (!skip) + break; + skip--; + } if (!(r = pci_next_dev(&devind, &vid, &did))) { diff --git a/drivers/fxp/fxp.c b/drivers/fxp/fxp.c index e38063f1f..3a61d3451 100644 --- a/drivers/fxp/fxp.c +++ b/drivers/fxp/fxp.c @@ -224,7 +224,7 @@ PRIVATE u32_t system_hz; _PROTOTYPE( static void fxp_init, (message *mp) ); _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_init_hw, (fxp_t *fp) ); _PROTOTYPE( static void fxp_init_buf, (fxp_t *fp) ); @@ -567,7 +567,7 @@ static void fxp_pci_conf() { continue; } - if (fxp_probe(fp)) + if (fxp_probe(fp, i)) fp->fxp_seen= TRUE; } } @@ -576,7 +576,7 @@ static void fxp_pci_conf() /*===========================================================================* * fxp_probe * *===========================================================================*/ -static int fxp_probe(fxp_t *fp) +static int fxp_probe(fxp_t *fp, int skip) { int i, r, devind, just_one; u16_t vid, did; @@ -621,7 +621,11 @@ static int fxp_probe(fxp_t *fp) break; } if (pcitab_fxp[i].vid != 0) - break; + { + if (just_one || !skip) + break; + skip--; + } if (just_one) { diff --git a/drivers/lance/lance.c b/drivers/lance/lance.c index 10ef1e4dc..2ad63d23c 100644 --- a/drivers/lance/lance.c +++ b/drivers/lance/lance.c @@ -125,7 +125,7 @@ _PROTOTYPE( static void lance_dump, (void) ); _PROTOTYPE( static void getAddressing, (int devind, ether_card_t *ec) ); /* 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) ); /* Accesses Lance Control and Status Registers */ @@ -622,7 +622,7 @@ ether_card_t *ec; if (ec->mode != EC_ENABLED) return; - if (!lance_probe(ec)) + if (!lance_probe(ec, ifnr)) { printf("%s: No ethernet card found on PCI-BIOS info.\n", ec->port_name); @@ -1463,8 +1463,9 @@ ether_card_t *ec; /*===========================================================================* * lance_probe * *===========================================================================*/ -static int lance_probe(ec) +static int lance_probe(ec, skip) ether_card_t *ec; +int skip; { unsigned short pci_cmd; unsigned short ioaddr; @@ -1510,7 +1511,11 @@ ether_card_t *ec; break; } if (pcitab[i].vid != 0) - break; + { + if (just_one || !skip) + break; + skip--; + } if (just_one) { diff --git a/drivers/orinoco/orinoco.c b/drivers/orinoco/orinoco.c index eb58bfb4a..768be268a 100644 --- a/drivers/orinoco/orinoco.c +++ b/drivers/orinoco/orinoco.c @@ -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_readv_s, (message * mp, int from_int)); _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_init, (message *)); _PROTOTYPE (static void or_pci_conf, (void)); @@ -636,7 +636,7 @@ static void or_pci_conf () { orp->or_pci_func) != 0) != h) { continue; } - if (or_probe (orp)) + if (or_probe (orp, i)) 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 * * bar * *****************************************************************************/ -static int or_probe (t_or * orp) +static int or_probe (t_or * orp, int skip) { u8_t ilr; u32_t bar; @@ -694,8 +694,15 @@ static int or_probe (t_or * orp) /* we have found the card in the pci bus */ 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) { printf ("%s: wrong PCI device", orp->or_name); diff --git a/drivers/rtl8139/rtl8139.c b/drivers/rtl8139/rtl8139.c index 6ae4bc4dd..61c9619c1 100644 --- a/drivers/rtl8139/rtl8139.c +++ b/drivers/rtl8139/rtl8139.c @@ -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_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_init_buf, (re_t *rep) ); _PROTOTYPE( static void rl_init_hw, (re_t *rep) ); @@ -542,7 +542,7 @@ static void rl_pci_conf() { continue; } - if (rl_probe(rep)) + if (rl_probe(rep, i)) rep->re_seen= TRUE; } } @@ -551,8 +551,9 @@ static void rl_pci_conf() /*===========================================================================* * rl_probe * *===========================================================================*/ -static int rl_probe(rep) +static int rl_probe(rep, skip) re_t *rep; +int skip; { int i, r, devind, just_one; u16_t vid, did; @@ -597,7 +598,11 @@ re_t *rep; break; } if (pcitab[i].vid != 0) - break; + { + if (just_one || !skip) + break; + skip--; + } if (just_one) { diff --git a/drivers/rtl8169/rtl8169.c b/drivers/rtl8169/rtl8169.c index 0676428d4..b7b073f32 100644 --- a/drivers/rtl8169/rtl8169.c +++ b/drivers/rtl8169/rtl8169.c @@ -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_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_init_buf, (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) { continue; } - if (rl_probe(rep)) + if (rl_probe(rep, i)) rep->re_seen = TRUE; } } @@ -695,8 +695,9 @@ static void rl_pci_conf() /*===========================================================================* * rl_probe * *===========================================================================*/ -static int rl_probe(rep) +static int rl_probe(rep, skip) re_t *rep; +int skip; { int i, r, devind, just_one; u16_t vid, did; @@ -734,8 +735,11 @@ re_t *rep; } break; } - if (pcitab[i].vid != 0) - break; + if (pcitab[i].vid != 0) { + if (just_one || !skip) + break; + skip--; + } if (just_one) { printf("%s: wrong PCI device (%04x/%04x) found at %d.%d.%d\n",