1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
--- ixp400-eth/ixp400_eth.c 1970-01-01 00:00:00.000000000 +0000
+++ ixp400-eth/ixp400_eth.c 1970-01-01 00:00:00.000000000 +0000
@@ -23,10 +23,10 @@
* This driver is written and optimized for Intel Xscale technology.
*
* SETUP NOTES:
- * By default, this driver uses predefined MAC addresses.
- * These are set in global var 'default_mac_addr' in this file.
- * If required, these can be changed at run-time using
- * the 'ifconfig' tool.
+ * By default, this driver uses MAC addresses from maclist, if
+ * these are not available the kernel api to randomly generate
+ * a locally assigned MAC address is used. The MAC can be
+ * overridden with ifconfig if absolutely necessary.
*
* Example - to set ixp0 MAC address to 00:02:B3:66:88:AA,
* run ifconfig with the following arguments:
@@ -64,6 +64,7 @@
#include <linux/sysctl.h>
#include <linux/unistd.h>
#include <linux/version.h>
+#include <net/maclist.h>
#if KERNEL_VERSION(2,6,0) <= LINUX_VERSION_CODE
#include <linux/workqueue.h>
@@ -130,6 +131,8 @@ static int dev_max_count = 1; /* only NP
static int dev_max_count = 2; /* only NPEB and NPEC */
#elif defined (CONFIG_ARCH_IXDP465) || defined(CONFIG_MACH_IXDP465)
static int dev_max_count = 3; /* all NPEs are used */
+#else
+static int dev_max_count = -1;/* use maclist_count */
#endif
#ifndef CONFIG_IXP400_NAPI
@@ -621,21 +624,6 @@ static phy_cfg_t default_phy_cfg[] =
#endif
};
-/* Default MAC addresses for EthAcc Ports 1 and 2 (using Intel MAC prefix)
- * Default is
- * IX_ETH_PORT_1 -> MAC 00:02:b3:01:01:01
- * IX_ETH_PORT_2 -> MAC 00:02:b3:02:02:02
- * IX_ETH_PORT_3 -> MAC 00:02:b3:03:03:03
-*/
-static IxEthAccMacAddr default_mac_addr[] =
-{
- {{0x00, 0x02, 0xB3, 0x01, 0x01, 0x01}} /* EthAcc Port 0 */
- ,{{0x00, 0x02, 0xB3, 0x02, 0x02, 0x02}} /* EthAcc Port 1 */
-#if defined (CONFIG_ARCH_IXDP465) || defined(CONFIG_MACH_IXDP465)
- ,{{0x00, 0x02, 0xB3, 0x03, 0x03, 0x03}} /* EthAcc Port 2 */
-#endif
-};
-
/* Default mapping of NpeImageIds for EthAcc Ports
* Default is
* IX_ETH_PORT_1 -> IX_ETH_NPE_B
@@ -3337,28 +3325,13 @@ static int __devinit dev_eth_probe(struc
/* Defines the unicast MAC address
*
- * Here is a good place to read a board-specific MAC address
- * from a non-volatile memory, e.g. an external eeprom.
- *
- * This memcpy uses a default MAC address from this
- * source code.
- *
- * This can be overriden later by the (optional) command
- *
- * ifconfig ixp0 ether 0002b3010101
- *
+ * The code reads from the maclist API.
*/
+ if (maclist_read((u8(*)[6])&ndev->dev_addr, priv->port_id) ||
+ !is_valid_ether_addr(ndev->dev_addr))
+ random_ether_addr(ndev->dev_addr);
- memcpy(ndev->dev_addr,
- &default_mac_addr[priv->port_id].macAddress,
- IX_IEEE803_MAC_ADDRESS_SIZE);
-
- /* possibly remove this test and the message when a valid MAC address
- * is not hardcoded in the driver source code.
- */
- if (is_valid_ether_addr(ndev->dev_addr))
- {
- P_WARN("Use default MAC address %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x for port %d\n",
+ P_INFO("Use MAC address %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x for port %d\n",
(unsigned)ndev->dev_addr[0],
(unsigned)ndev->dev_addr[1],
(unsigned)ndev->dev_addr[2],
@@ -3366,7 +3339,6 @@ static int __devinit dev_eth_probe(struc
(unsigned)ndev->dev_addr[4],
(unsigned)ndev->dev_addr[5],
priv->port_id);
- }
/* Set/update the internal packet size
* This can be overriden later by the command
@@ -3584,12 +3556,15 @@ static int __init ixp400_eth_init(void)
TRACE;
- /* check module parameter range */
- if (dev_max_count == 0 || dev_max_count > IX_ETH_ACC_NUMBER_OF_PORTS)
- {
- P_ERROR("Number of ports supported is dev_max_count <= %d\n", IX_ETH_ACC_NUMBER_OF_PORTS);
- return -1;
- }
+ /* fix dev_max_count to maclist_count - the actual number of
+ * available MACs
+ */
+ if (dev_max_count <= 0 || (dev_max_count > maclist_count() && maclist_count() > 0))
+ dev_max_count = maclist_count();
+ if (dev_max_count <= 0)
+ dev_max_count = 1;
+ else if (dev_max_count > IX_ETH_ACC_NUMBER_OF_PORTS)
+ dev_max_count = IX_ETH_ACC_NUMBER_OF_PORTS;
TRACE;
|