Commit 13f85203 authored by Benjamin Herrenschmidt's avatar Benjamin Herrenschmidt Committed by David S. Miller
Browse files

net/eth/ibmveth: Fixup retrieval of MAC address

Some ancient pHyp versions used to create a 8 bytes local-mac-address
property in the device-tree instead of a 6 bytes one for veth.

The Linux driver code to deal with that is an insane hack which also
happens to break with some choices of MAC addresses in qemu by testing
for a bit in the address rather than just looking at the size of the

Sanitize this by doing the latter instead.
Signed-off-by: default avatarBenjamin Herrenschmidt <>
CC: <>
Signed-off-by: default avatarDavid S. Miller <>
parent 77d21f23
......@@ -1322,7 +1322,7 @@ static const struct net_device_ops ibmveth_netdev_ops = {
static int ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id)
int rc, i;
int rc, i, mac_len;
struct net_device *netdev;
struct ibmveth_adapter *adapter;
unsigned char *mac_addr_p;
......@@ -1332,11 +1332,19 @@ static int ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id)
mac_addr_p = (unsigned char *)vio_get_attribute(dev, VETH_MAC_ADDR,
if (!mac_addr_p) {
dev_err(&dev->dev, "Can't find VETH_MAC_ADDR attribute\n");
return -EINVAL;
/* Workaround for old/broken pHyp */
if (mac_len == 8)
mac_addr_p += 2;
else if (mac_len != 6) {
dev_err(&dev->dev, "VETH_MAC_ADDR attribute wrong len %d\n",
return -EINVAL;
mcastFilterSize_p = (unsigned int *)vio_get_attribute(dev,
......@@ -1361,17 +1369,6 @@ static int ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id)
netif_napi_add(netdev, &adapter->napi, ibmveth_poll, 16);
* Some older boxes running PHYP non-natively have an OF that returns
* a 8-byte local-mac-address field (and the first 2 bytes have to be
* ignored) while newer boxes' OF return a 6-byte field. Note that
* IEEE 1275 specifies that local-mac-address must be a 6-byte field.
* The RPA doc specifies that the first byte must be 10b, so we'll
* just look for it to solve this 8 vs. 6 byte field issue
if ((*mac_addr_p & 0x3) != 0x02)
mac_addr_p += 2;
adapter->mac_addr = 0;
memcpy(&adapter->mac_addr, mac_addr_p, 6);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment