diff options
author | Max Filippov <jcmvbkbc@gmail.com> | 2013-11-09 23:48:34 -0500 |
---|---|---|
committer | Chris Zankel <chris@zankel.net> | 2014-01-14 13:19:50 -0500 |
commit | 8991fd88354f924cc3f4e6386c619fc39fb48f21 (patch) | |
tree | 71b5742711b7f02033e5c5f07a223e3093e093df /arch/xtensa/platforms/iss/network.c | |
parent | 358b181003dbb30985331a77e753e1b05c05d87d (diff) |
xtensa: ISS: drop IP setup, clean up MAC setup
Without proper MAC setup network device doesn't work. IP setup is
redundant and may be done with 'ip=...' kernel parameter.
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Chris Zankel <chris@zankel.net>
Diffstat (limited to 'arch/xtensa/platforms/iss/network.c')
-rw-r--r-- | arch/xtensa/platforms/iss/network.c | 77 |
1 files changed, 31 insertions, 46 deletions
diff --git a/arch/xtensa/platforms/iss/network.c b/arch/xtensa/platforms/iss/network.c index 3718cff3909a..f7709c7efca4 100644 --- a/arch/xtensa/platforms/iss/network.c +++ b/arch/xtensa/platforms/iss/network.c | |||
@@ -81,9 +81,6 @@ struct iss_net_private { | |||
81 | int index; | 81 | int index; |
82 | int mtu; | 82 | int mtu; |
83 | 83 | ||
84 | unsigned char mac[ETH_ALEN]; | ||
85 | int have_mac; | ||
86 | |||
87 | struct { | 84 | struct { |
88 | union { | 85 | union { |
89 | struct tuntap_info tuntap; | 86 | struct tuntap_info tuntap; |
@@ -123,44 +120,41 @@ static char *split_if_spec(char *str, ...) | |||
123 | return str; | 120 | return str; |
124 | } | 121 | } |
125 | 122 | ||
123 | /* Set Ethernet address of the specified device. */ | ||
126 | 124 | ||
127 | /* Return the IP address as a string for a given device. */ | 125 | static void setup_etheraddr(struct net_device *dev, char *str) |
128 | |||
129 | static void dev_ip_addr(void *d, char *buf, char *bin_buf) | ||
130 | { | 126 | { |
131 | struct net_device *dev = d; | 127 | unsigned char *addr = dev->dev_addr; |
132 | struct in_device *ip = dev->ip_ptr; | ||
133 | struct in_ifaddr *in; | ||
134 | __be32 addr; | ||
135 | |||
136 | if (ip == NULL || ip->ifa_list == NULL) { | ||
137 | pr_warn("Device not assigned an IP address!\n"); | ||
138 | return; | ||
139 | } | ||
140 | 128 | ||
141 | in = ip->ifa_list; | 129 | if (str == NULL) |
130 | goto random; | ||
142 | 131 | ||
143 | addr = in->ifa_address; | 132 | if (!mac_pton(str, addr)) { |
144 | sprintf(buf, "%d.%d.%d.%d", addr & 0xff, (addr >> 8) & 0xff, | 133 | pr_err("%s: failed to parse '%s' as an ethernet address\n", |
145 | (addr >> 16) & 0xff, addr >> 24); | 134 | dev->name, str); |
146 | 135 | goto random; | |
147 | if (bin_buf) { | ||
148 | bin_buf[0] = addr & 0xff; | ||
149 | bin_buf[1] = (addr >> 8) & 0xff; | ||
150 | bin_buf[2] = (addr >> 16) & 0xff; | ||
151 | bin_buf[3] = addr >> 24; | ||
152 | } | 136 | } |
137 | if (is_multicast_ether_addr(addr)) { | ||
138 | pr_err("%s: attempt to assign a multicast ethernet address\n", | ||
139 | dev->name); | ||
140 | goto random; | ||
141 | } | ||
142 | if (!is_valid_ether_addr(addr)) { | ||
143 | pr_err("%s: attempt to assign an invalid ethernet address\n", | ||
144 | dev->name); | ||
145 | goto random; | ||
146 | } | ||
147 | if (!is_local_ether_addr(addr)) | ||
148 | pr_warn("%s: assigning a globally valid ethernet address\n", | ||
149 | dev->name); | ||
150 | return; | ||
151 | |||
152 | random: | ||
153 | pr_info("%s: choosing a random ethernet address\n", | ||
154 | dev->name); | ||
155 | eth_hw_addr_random(dev); | ||
153 | } | 156 | } |
154 | 157 | ||
155 | /* Set Ethernet address of the specified device. */ | ||
156 | |||
157 | static inline void set_ether_mac(void *d, unsigned char *addr) | ||
158 | { | ||
159 | struct net_device *dev = d; | ||
160 | memcpy(dev->dev_addr, addr, ETH_ALEN); | ||
161 | } | ||
162 | |||
163 | |||
164 | /* ======================= TUNTAP TRANSPORT INTERFACE ====================== */ | 158 | /* ======================= TUNTAP TRANSPORT INTERFACE ====================== */ |
165 | 159 | ||
166 | static int tuntap_open(struct iss_net_private *lp) | 160 | static int tuntap_open(struct iss_net_private *lp) |
@@ -232,6 +226,7 @@ static int tuntap_poll(struct iss_net_private *lp) | |||
232 | 226 | ||
233 | static int tuntap_probe(struct iss_net_private *lp, int index, char *init) | 227 | static int tuntap_probe(struct iss_net_private *lp, int index, char *init) |
234 | { | 228 | { |
229 | struct net_device *dev = lp->dev; | ||
235 | char *dev_name = NULL, *mac_str = NULL, *rem = NULL; | 230 | char *dev_name = NULL, *mac_str = NULL, *rem = NULL; |
236 | 231 | ||
237 | /* Transport should be 'tuntap': ethX=tuntap,mac,dev_name */ | 232 | /* Transport should be 'tuntap': ethX=tuntap,mac,dev_name */ |
@@ -259,6 +254,7 @@ static int tuntap_probe(struct iss_net_private *lp, int index, char *init) | |||
259 | } else | 254 | } else |
260 | strcpy(lp->tp.info.tuntap.dev_name, TRANSPORT_TUNTAP_NAME); | 255 | strcpy(lp->tp.info.tuntap.dev_name, TRANSPORT_TUNTAP_NAME); |
261 | 256 | ||
257 | setup_etheraddr(dev, mac_str); | ||
262 | 258 | ||
263 | lp->mtu = TRANSPORT_TUNTAP_MTU; | 259 | lp->mtu = TRANSPORT_TUNTAP_MTU; |
264 | 260 | ||
@@ -369,7 +365,6 @@ static void iss_net_timer(unsigned long priv) | |||
369 | static int iss_net_open(struct net_device *dev) | 365 | static int iss_net_open(struct net_device *dev) |
370 | { | 366 | { |
371 | struct iss_net_private *lp = netdev_priv(dev); | 367 | struct iss_net_private *lp = netdev_priv(dev); |
372 | char addr[sizeof("255.255.255.255\0")]; | ||
373 | int err; | 368 | int err; |
374 | 369 | ||
375 | spin_lock(&lp->lock); | 370 | spin_lock(&lp->lock); |
@@ -378,11 +373,6 @@ static int iss_net_open(struct net_device *dev) | |||
378 | if (err < 0) | 373 | if (err < 0) |
379 | goto out; | 374 | goto out; |
380 | 375 | ||
381 | if (!lp->have_mac) { | ||
382 | dev_ip_addr(dev, addr, &lp->mac[2]); | ||
383 | set_ether_mac(dev, lp->mac); | ||
384 | } | ||
385 | |||
386 | netif_start_queue(dev); | 376 | netif_start_queue(dev); |
387 | 377 | ||
388 | /* clear buffer - it can happen that the host side of the interface | 378 | /* clear buffer - it can happen that the host side of the interface |
@@ -540,8 +530,6 @@ static int iss_net_configure(int index, char *init) | |||
540 | .lock = __SPIN_LOCK_UNLOCKED(lp.lock), | 530 | .lock = __SPIN_LOCK_UNLOCKED(lp.lock), |
541 | .dev = dev, | 531 | .dev = dev, |
542 | .index = index, | 532 | .index = index, |
543 | .mac = { 0xfe, 0xfd, 0x0, 0x0, 0x0, 0x0 }, | ||
544 | .have_mac = 0, | ||
545 | }; | 533 | }; |
546 | 534 | ||
547 | /* | 535 | /* |
@@ -561,10 +549,7 @@ static int iss_net_configure(int index, char *init) | |||
561 | goto errout; | 549 | goto errout; |
562 | } | 550 | } |
563 | 551 | ||
564 | printk(KERN_INFO "Netdevice %d ", index); | 552 | pr_info("Netdevice %d (%pM)\n", index, dev->dev_addr); |
565 | if (lp->have_mac) | ||
566 | printk("(%pM) ", lp->mac); | ||
567 | printk(": "); | ||
568 | 553 | ||
569 | /* sysfs register */ | 554 | /* sysfs register */ |
570 | 555 | ||