diff options
author | Olof Johansson <olof@lixom.net> | 2008-01-23 14:56:19 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-02-03 07:27:53 -0500 |
commit | 5cea73b0f7d4d49e276b0c4842465890d00de861 (patch) | |
tree | 9d46b61c0c050942a4df9e7dd68c796016ddb746 /drivers | |
parent | c88559539bd16eae4e9056d4734b3fe8a9858c45 (diff) |
pasemi_mac: Add support for changing mac address
Straightforward. It used to be hardcoded and impossible to override
with ifconfig.
Signed-off-by: Olof Johansson <olof@lixom.net>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/pasemi_mac.c | 28 | ||||
-rw-r--r-- | drivers/net/pasemi_mac.h | 2 |
2 files changed, 30 insertions, 0 deletions
diff --git a/drivers/net/pasemi_mac.c b/drivers/net/pasemi_mac.c index bb88a41b7591..59dea3f829fc 100644 --- a/drivers/net/pasemi_mac.c +++ b/drivers/net/pasemi_mac.c | |||
@@ -221,6 +221,33 @@ static int pasemi_get_mac_addr(struct pasemi_mac *mac) | |||
221 | return 0; | 221 | return 0; |
222 | } | 222 | } |
223 | 223 | ||
224 | static int pasemi_mac_set_mac_addr(struct net_device *dev, void *p) | ||
225 | { | ||
226 | struct pasemi_mac *mac = netdev_priv(dev); | ||
227 | struct sockaddr *addr = p; | ||
228 | unsigned int adr0, adr1; | ||
229 | |||
230 | if (!is_valid_ether_addr(addr->sa_data)) | ||
231 | return -EINVAL; | ||
232 | |||
233 | memcpy(dev->dev_addr, addr->sa_data, dev->addr_len); | ||
234 | |||
235 | adr0 = dev->dev_addr[2] << 24 | | ||
236 | dev->dev_addr[3] << 16 | | ||
237 | dev->dev_addr[4] << 8 | | ||
238 | dev->dev_addr[5]; | ||
239 | adr1 = read_mac_reg(mac, PAS_MAC_CFG_ADR1); | ||
240 | adr1 &= ~0xffff; | ||
241 | adr1 |= dev->dev_addr[0] << 8 | dev->dev_addr[1]; | ||
242 | |||
243 | pasemi_mac_intf_disable(mac); | ||
244 | write_mac_reg(mac, PAS_MAC_CFG_ADR0, adr0); | ||
245 | write_mac_reg(mac, PAS_MAC_CFG_ADR1, adr1); | ||
246 | pasemi_mac_intf_enable(mac); | ||
247 | |||
248 | return 0; | ||
249 | } | ||
250 | |||
224 | static int get_skb_hdr(struct sk_buff *skb, void **iphdr, | 251 | static int get_skb_hdr(struct sk_buff *skb, void **iphdr, |
225 | void **tcph, u64 *hdr_flags, void *data) | 252 | void **tcph, u64 *hdr_flags, void *data) |
226 | { | 253 | { |
@@ -1475,6 +1502,7 @@ pasemi_mac_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1475 | dev->stop = pasemi_mac_close; | 1502 | dev->stop = pasemi_mac_close; |
1476 | dev->hard_start_xmit = pasemi_mac_start_tx; | 1503 | dev->hard_start_xmit = pasemi_mac_start_tx; |
1477 | dev->set_multicast_list = pasemi_mac_set_rx_mode; | 1504 | dev->set_multicast_list = pasemi_mac_set_rx_mode; |
1505 | dev->set_mac_address = pasemi_mac_set_mac_addr; | ||
1478 | 1506 | ||
1479 | if (err) | 1507 | if (err) |
1480 | goto out; | 1508 | goto out; |
diff --git a/drivers/net/pasemi_mac.h b/drivers/net/pasemi_mac.h index 8bee2a664c83..39d325940a76 100644 --- a/drivers/net/pasemi_mac.h +++ b/drivers/net/pasemi_mac.h | |||
@@ -96,6 +96,8 @@ struct pasemi_mac_buffer { | |||
96 | /* MAC CFG register offsets */ | 96 | /* MAC CFG register offsets */ |
97 | enum { | 97 | enum { |
98 | PAS_MAC_CFG_PCFG = 0x80, | 98 | PAS_MAC_CFG_PCFG = 0x80, |
99 | PAS_MAC_CFG_ADR0 = 0x8c, | ||
100 | PAS_MAC_CFG_ADR1 = 0x90, | ||
99 | PAS_MAC_CFG_TXP = 0x98, | 101 | PAS_MAC_CFG_TXP = 0x98, |
100 | PAS_MAC_IPC_CHNL = 0x208, | 102 | PAS_MAC_IPC_CHNL = 0x208, |
101 | }; | 103 | }; |