fix: eth: fixed index of the Ethernet interface

- Updated the index of the Ethernet interfaces to by port number
- Issue fount in Armada-39x SoC, when using specific configuration with
  skipping on one of network interfaces (enable egiga0, egiga2 only)
- The issue found when MAC address of network interface is incorrect, e.g.
  egiga2 uses MAC address of egiga1
- This patch set the index of the Ethernet device by the port number

Change-Id: I7f5919cfbedccf1d5edb5acc1ccafd270307ac0b
Signed-off-by: Hanna Hawa <hannah@marvell.com>
Reviewed-on: http://vgitil04.il.marvell.com:8080/23554
Tested-by: Star_Automation <star@marvell.com>
Reviewed-by: Omri Itach <omrii@marvell.com>
diff --git a/board/mv_ebu/common/USP/mv_egiga_legacy.c b/board/mv_ebu/common/USP/mv_egiga_legacy.c
index 3827b12..0401a19 100644
--- a/board/mv_ebu/common/USP/mv_egiga_legacy.c
+++ b/board/mv_ebu/common/USP/mv_egiga_legacy.c
@@ -153,6 +153,7 @@
 	dev->halt = (void*)mvEgigaHalt;
 	dev->send = (void*)mvEgigaTx;
 	dev->recv = (void*)mvEgigaRx;
+	dev->index = port;
 	dev->priv = priv;
 	dev->iobase = 0;
 	dev->port = port;
@@ -518,4 +519,4 @@
 }
 
 #endif  /* legacy */
-#endif  /* #if defined (MV_INCLUDE_GIG_ETH) */
\ No newline at end of file
+#endif  /* #if defined (MV_INCLUDE_GIG_ETH) */
diff --git a/board/mv_ebu/common/USP/mv_egiga_neta.c b/board/mv_ebu/common/USP/mv_egiga_neta.c
index 55215e5..2ea503d 100755
--- a/board/mv_ebu/common/USP/mv_egiga_neta.c
+++ b/board/mv_ebu/common/USP/mv_egiga_neta.c
@@ -162,6 +162,7 @@
 	dev->priv = priv;
 	dev->iobase = 0;
 	dev->write_hwaddr = 0;
+	dev->index = port;
 	priv->port = port;
 	priv->devInit = MV_FALSE;
 	priv->devEnable = MV_FALSE;
diff --git a/board/mv_ebu/common/USP/mv_egiga_pp2.c b/board/mv_ebu/common/USP/mv_egiga_pp2.c
index 5194b1a..0a9f903 100644
--- a/board/mv_ebu/common/USP/mv_egiga_pp2.c
+++ b/board/mv_ebu/common/USP/mv_egiga_pp2.c
@@ -259,6 +259,7 @@
 	dev->priv = priv;
 	dev->iobase = 0;
 	dev->write_hwaddr = 0;
+	dev->index = port;
 	priv->port = port;
 	priv->devInit = MV_FALSE;
 	priv->devEnable = MV_FALSE;
diff --git a/net/eth.c b/net/eth.c
index 4e4a847..e9d9b06 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -231,7 +231,6 @@
 int eth_register(struct eth_device *dev)
 {
 	struct eth_device *d;
-	static int index;
 
 	assert(strlen(dev->name) < sizeof(dev->name));
 
@@ -246,7 +245,6 @@
 
 	dev->state = ETH_STATE_INIT;
 	dev->next  = eth_devices;
-	dev->index = index++;
 
 	return 0;
 }