diff options
author | Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> | 2014-04-08 11:54:55 +0530 |
---|---|---|
committer | Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> | 2014-04-08 17:45:09 +0530 |
commit | cce8657eaaa992cb8b6e0e1a98bc02b357e60be0 (patch) | |
tree | 85e6b83e327a5951c5b76ab30870b81e36b939ad | |
parent | c90b50b5055f976a0da3c032f26fb80157292adc (diff) | |
download | SLOF-cce8657eaaa992cb8b6e0e1a98bc02b357e60be0.zip SLOF-cce8657eaaa992cb8b6e0e1a98bc02b357e60be0.tar.gz SLOF-cce8657eaaa992cb8b6e0e1a98bc02b357e60be0.tar.bz2 |
e1000: fix usage of multiple nics
When using multiple e1000 network interface netboot would fail if we
try to boot from the first interface.
During first e1000 device initialization, m_e1k.m_baseaddr_u64 (static
variable) is set to read/write pci registers. Later the second device
does process. When first e1000 driver tries netboot, it has an
assumption that m_e1k.m_baseaddr_u64 is correct, which is not the
case.
Ensure reinitialization for m_e1k.m_baseaddr_u64 when open interface
of device is called.
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
Reviewed-by: Thomas Huth <thuth@linux.vnet.ibm.com>
-rw-r--r-- | board-qemu/slof/e1k.fs | 7 | ||||
-rw-r--r-- | lib/libe1k/e1k.c | 3 | ||||
-rw-r--r-- | lib/libe1k/e1k.code | 5 | ||||
-rw-r--r-- | lib/libe1k/e1k.h | 2 |
4 files changed, 11 insertions, 6 deletions
diff --git a/board-qemu/slof/e1k.fs b/board-qemu/slof/e1k.fs index 6bfaef1..51855be 100644 --- a/board-qemu/slof/e1k.fs +++ b/board-qemu/slof/e1k.fs @@ -16,13 +16,15 @@ s" network" device-type INSTANCE VARIABLE obp-tftp-package get-node CONSTANT my-phandle +10 config-l@ translate-my-address 3 not AND CONSTANT baseaddr 0 VALUE e1k-priv 0 VALUE open-count : open ( -- okay? ) open-count 0= IF - open IF + open IF + baseaddr e1k-open dup not IF ." e1k-open failed" EXIT THEN drop TO e1k-priv true @@ -80,11 +82,12 @@ get-node CONSTANT my-phandle decode-int nip nip " device-id" get-node get-property IF EXIT THEN decode-int nip nip - " 10 config-l@ translate-my-address 3 not AND" evaluate + baseaddr local-mac e1k-mac-setup IF encode-bytes " local-mac-address" property THEN ; + setup-mac : setup-alias ( -- ) diff --git a/lib/libe1k/e1k.c b/lib/libe1k/e1k.c index 0e9f3ca..4dd7d2e 100644 --- a/lib/libe1k/e1k.c +++ b/lib/libe1k/e1k.c @@ -940,10 +940,11 @@ e1k_term(void) return 0; } -net_driver_t *e1k_open(void) +net_driver_t *e1k_open(uint64_t baseaddr) { net_driver_t *driver; + m_e1k.m_baseaddr_u64 = baseaddr; driver = SLOF_alloc_mem(sizeof(*driver)); if (!driver) { printf("Unable to allocate virtio-net driver\n"); diff --git a/lib/libe1k/e1k.code b/lib/libe1k/e1k.code index ce57964..225ed4e 100644 --- a/lib/libe1k/e1k.code +++ b/lib/libe1k/e1k.code @@ -16,10 +16,11 @@ #include <e1k.h> -// : e1k-open ( -- false | [ driver true ] ) +// : e1k-open ( baseaddr -- false | [ driver true ] ) PRIM(E1K_X2d_OPEN) { - net_driver_t *net_driver = e1k_open(); + uint64_t baseaddr = TOS.u; POP; + net_driver_t *net_driver = e1k_open(baseaddr); if (net_driver) { PUSH; TOS.u = (unsigned long)net_driver; PUSH; diff --git a/lib/libe1k/e1k.h b/lib/libe1k/e1k.h index 628b771..c88b3e5 100644 --- a/lib/libe1k/e1k.h +++ b/lib/libe1k/e1k.h @@ -100,7 +100,7 @@ //#define mb() asm volatile("sync" ::: "memory"); -extern net_driver_t *e1k_open(void); +extern net_driver_t *e1k_open(uint64_t baseaddr); extern void e1k_close(net_driver_t *driver); extern int e1k_read(char *buf, int len); extern int e1k_write(char *buf, int len); |