tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: ne2000 with 8bit bus width
Hi,
> I think Arnaud asked if putting "(useworddma ? FOO : 0)" conditionals
> into bus_space(9) functions could cause negative performance.
Indeed, it is such a meaning.
I'm sorry for doing a wrong answer.
Such a syntax is used only in the function of attach and detect.
Therefore, I do not think that I relate to the performance.
> With a quick glance, those conditionals are only used
> to select word/byte transfer in DCR register on
> detecting chip types and reading MAC address,
> (no additional conditionals in each transfer)
> so it seems no problem.
I agree.
> - It looks now ne2000_detect() also checks if chip is 16 bit DMA capable.
> ÂIf so, isn't it better to use the result of ne2000_detect()
> Âto set sc_useworddma, rather than setting it in backends?
ne2000_softc is not passed to the ne2000_detect() function.
> - It might be better to use bool for useworddma and sc_useworddma
> unless it's also used as an integer as current useword.
The driver that doesn't call the ne2000_detect() function exists(*1).
In addition, the driver that calls the ne2000_attach() function after
the sc_type is set exists(*2).
Because such a driver exists, it is necessary to maintain three
states(unknown, 8bit, 16bit).
Therefore, the type of the variable of the bus width is not made bool.
(*1): e.g. src/sys/arch/acorn32/podulebus/if_ne_pbus.c
(*2): e.g. src/sys/dev/mca/if_ne_mca.c
> - In a new patch, useworddma is could be 0 even on NE2000 but
> Âusewordrw is set per sc_type (i.e. 0 only on NE1000).
> ÂIs the following part still necessary to read MAC address?
> ÂIsn't it enought to use usewordrw for indexes as current code?
It is not necessary.
I backout it to original code.
Thanks,
--
NONAKA Kimihiro
Index: ne2000.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/ne2000.c,v
retrieving revision 1.61
diff -u -r1.61 ne2000.c
--- ne2000.c 5 Apr 2009 03:37:07 -0000 1.61
+++ ne2000.c 5 May 2009 06:23:44 -0000
@@ -111,7 +111,7 @@
bus_space_tag_t asict = nsc->sc_asict;
bus_space_handle_t asich = nsc->sc_asich;
u_int8_t romdata[16];
- int memsize, i, useword;
+ int memsize, i, useword, dmawidth;
/*
* Detect it again unless caller specified it; this gives us
@@ -132,21 +132,28 @@
case NE2000_TYPE_NE1000:
memsize = 8192;
useword = 0;
+ dmawidth = NE2000_DMAWIDTH_8BIT;
break;
case NE2000_TYPE_NE2000:
case NE2000_TYPE_AX88190: /* XXX really? */
case NE2000_TYPE_AX88790:
memsize = 8192 * 2;
useword = 1;
+ dmawidth = NE2000_DMAWIDTH_16BIT;
break;
case NE2000_TYPE_DL10019:
case NE2000_TYPE_DL10022:
memsize = 8192 * 3;
useword = 1;
+ dmawidth = NE2000_DMAWIDTH_16BIT;
break;
}
nsc->sc_useword = useword;
+ if (nsc->sc_dmawidth == NE2000_DMAWIDTH_UNKNOWN)
+ nsc->sc_dmawidth = dmawidth;
+ else
+ dmawidth = nsc->sc_dmawidth;
dsc->cr_proto = ED_CR_RD2;
if (nsc->sc_type == NE2000_TYPE_AX88190 ||
@@ -164,7 +171,8 @@
*
* NE1000 gets byte-wide DMA, NE2000 gets word-wide DMA.
*/
- dsc->dcr_reg = ED_DCR_FT1 | ED_DCR_LS | (useword ? ED_DCR_WTS : 0);
+ dsc->dcr_reg = ED_DCR_FT1 | ED_DCR_LS |
+ ((dmawidth == NE2000_DMAWIDTH_16BIT) ? ED_DCR_WTS : 0);
dsc->test_mem = ne2000_test_mem;
dsc->ring_copy = ne2000_ring_copy;
@@ -261,7 +269,8 @@
ED_CR_RD2 | ED_CR_PAGE_0 | ED_CR_STA);
NIC_BARRIER(nict, nich);
/* Select word transfer. */
- bus_space_write_1(nict, nich, ED_P0_DCR, ED_DCR_WTS);
+ bus_space_write_1(nict, nich, ED_P0_DCR,
+ ((dmawidth == NE2000_DMAWIDTH_16BIT) ? ED_DCR_WTS :
0));
NIC_BARRIER(nict, nich);
ne2000_readmem(nict, nich, asict, asich,
AX88190_NODEID_OFFSET, dsc->sc_enaddr,
@@ -308,7 +317,9 @@
static u_int8_t test_pattern[32] = "THIS is A memory TEST pattern";
u_int8_t test_buffer[32], tmp;
int i, rv = NE2000_TYPE_UNKNOWN;
+ int dmawidth = NE2000_DMAWIDTH_16BIT;
+ restart:
/* Reset the board. */
#ifdef GWETHER
bus_space_write_1(asict, asich, NE2000_ASIC_RESET, 0);
@@ -424,8 +435,8 @@
if (memcmp(test_pattern, test_buffer, sizeof(test_pattern))) {
/* not an NE1000 - try NE2000 */
- bus_space_write_1(nict, nich, ED_P0_DCR,
- ED_DCR_WTS | ED_DCR_FT1 | ED_DCR_LS);
+ bus_space_write_1(nict, nich, ED_P0_DCR, ED_DCR_FT1 | ED_DCR_LS
+ | ((dmawidth == NE2000_DMAWIDTH_16BIT) ? ED_DCR_WTS : 0));
bus_space_write_1(nict, nich, ED_P0_PSTART,
16384 >> ED_PAGE_SHIFT);
bus_space_write_1(nict, nich, ED_P0_PSTOP,
@@ -440,13 +451,20 @@
ne2000_readmem(nict, nich, asict, asich, 16384, test_buffer,
sizeof(test_buffer), 1);
- if (memcmp(test_pattern, test_buffer, sizeof(test_pattern)))
+ if (memcmp(test_pattern, test_buffer, sizeof(test_pattern))) {
+ if (dmawidth == NE2000_DMAWIDTH_16BIT) {
+ /* try 8bit dma */
+ dmawidth = NE2000_DMAWIDTH_8BIT;
+ goto restart;
+ }
goto out; /* not an NE2000 either */
+ }
rv = NE2000_TYPE_NE2000;
} else {
/* We're an NE1000. */
rv = NE2000_TYPE_NE1000;
+ dmawidth = NE2000_DMAWIDTH_8BIT;
}
/* Clear any pending interrupts that might have occurred above. */
@@ -804,23 +822,25 @@
struct dp8390_softc *dp = &np->sc_dp8390;
bus_space_tag_t nict = dp->sc_regt;
bus_space_handle_t nich = dp->sc_regh;
- int i, useword;
+ int i, useword, dmawidth;
#ifdef GWETHER
/* Not supported (yet?) */
return -1;
#endif
- if (np->sc_type == 0)
+ if (np->sc_type == NE2000_TYPE_UNKNOWN)
np->sc_type = ne2000_detect(nict, nich,
np->sc_asict, np->sc_asich);
- if (np->sc_type == 0)
+ if (np->sc_type == NE2000_TYPE_UNKNOWN)
return -1;
useword = np->sc_useword;
+ dmawidth = np->sc_dmawidth;
dp->cr_proto = ED_CR_RD2;
- dp->dcr_reg = ED_DCR_FT1 | ED_DCR_LS | (useword ? ED_DCR_WTS : 0);
+ dp->dcr_reg = ED_DCR_FT1 | ED_DCR_LS |
+ ((dmawidth == NE2000_DMAWIDTH_16BIT) ? ED_DCR_WTS : 0);
dp->rcr_proto = 0;
dp->test_mem = ne2000_test_mem;
@@ -876,7 +896,8 @@
ED_CR_RD2 | ED_CR_PAGE_0 | ED_CR_STA);
NIC_BARRIER(nict, nich);
/* Select word transfer */
- bus_space_write_1(nict, nich, ED_P0_DCR, ED_DCR_WTS);
+ bus_space_write_1(nict, nich, ED_P0_DCR,
+ ((dmawidth == NE2000_DMAWIDTH_16BIT) ? ED_DCR_WTS :
0));
ne2000_readmem(nict, nich, np->sc_asict, np->sc_asich,
AX88190_NODEID_OFFSET, kip->myenetaddr,
ETHER_ADDR_LEN, useword);
Index: ne2000var.h
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/ne2000var.h,v
retrieving revision 1.20
diff -u -r1.20 ne2000var.h
--- ne2000var.h 5 Apr 2009 03:37:07 -0000 1.20
+++ ne2000var.h 5 May 2009 06:23:44 -0000
@@ -49,6 +49,11 @@
NE2000_TYPE_AX88790
} sc_type;
int sc_useword;
+ enum {
+ NE2000_DMAWIDTH_UNKNOWN = 0,
+ NE2000_DMAWIDTH_16BIT,
+ NE2000_DMAWIDTH_8BIT,
+ } sc_dmawidth;
};
int ne2000_attach(struct ne2000_softc *, u_int8_t *);
Home |
Main Index |
Thread Index |
Old Index