diff options
Diffstat (limited to 'drivers/net/ethernet/ibm/ibmveth.c')
-rw-r--r-- | drivers/net/ethernet/ibm/ibmveth.c | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c index 952d795230a4..1fc8334fc181 100644 --- a/drivers/net/ethernet/ibm/ibmveth.c +++ b/drivers/net/ethernet/ibm/ibmveth.c | |||
@@ -12,8 +12,7 @@ | |||
12 | * GNU General Public License for more details. | 12 | * GNU General Public License for more details. |
13 | * | 13 | * |
14 | * You should have received a copy of the GNU General Public License | 14 | * You should have received a copy of the GNU General Public License |
15 | * along with this program; if not, write to the Free Software | 15 | * along with this program; if not, see <http://www.gnu.org/licenses/>. |
16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
17 | * | 16 | * |
18 | * Copyright (C) IBM Corporation, 2003, 2010 | 17 | * Copyright (C) IBM Corporation, 2003, 2010 |
19 | * | 18 | * |
@@ -523,10 +522,21 @@ retry: | |||
523 | return rc; | 522 | return rc; |
524 | } | 523 | } |
525 | 524 | ||
525 | static u64 ibmveth_encode_mac_addr(u8 *mac) | ||
526 | { | ||
527 | int i; | ||
528 | u64 encoded = 0; | ||
529 | |||
530 | for (i = 0; i < ETH_ALEN; i++) | ||
531 | encoded = (encoded << 8) | mac[i]; | ||
532 | |||
533 | return encoded; | ||
534 | } | ||
535 | |||
526 | static int ibmveth_open(struct net_device *netdev) | 536 | static int ibmveth_open(struct net_device *netdev) |
527 | { | 537 | { |
528 | struct ibmveth_adapter *adapter = netdev_priv(netdev); | 538 | struct ibmveth_adapter *adapter = netdev_priv(netdev); |
529 | u64 mac_address = 0; | 539 | u64 mac_address; |
530 | int rxq_entries = 1; | 540 | int rxq_entries = 1; |
531 | unsigned long lpar_rc; | 541 | unsigned long lpar_rc; |
532 | int rc; | 542 | int rc; |
@@ -580,8 +590,7 @@ static int ibmveth_open(struct net_device *netdev) | |||
580 | adapter->rx_queue.num_slots = rxq_entries; | 590 | adapter->rx_queue.num_slots = rxq_entries; |
581 | adapter->rx_queue.toggle = 1; | 591 | adapter->rx_queue.toggle = 1; |
582 | 592 | ||
583 | memcpy(&mac_address, netdev->dev_addr, netdev->addr_len); | 593 | mac_address = ibmveth_encode_mac_addr(netdev->dev_addr); |
584 | mac_address = mac_address >> 16; | ||
585 | 594 | ||
586 | rxq_desc.fields.flags_len = IBMVETH_BUF_VALID | | 595 | rxq_desc.fields.flags_len = IBMVETH_BUF_VALID | |
587 | adapter->rx_queue.queue_len; | 596 | adapter->rx_queue.queue_len; |
@@ -1184,8 +1193,8 @@ static void ibmveth_set_multicast_list(struct net_device *netdev) | |||
1184 | /* add the addresses to the filter table */ | 1193 | /* add the addresses to the filter table */ |
1185 | netdev_for_each_mc_addr(ha, netdev) { | 1194 | netdev_for_each_mc_addr(ha, netdev) { |
1186 | /* add the multicast address to the filter table */ | 1195 | /* add the multicast address to the filter table */ |
1187 | unsigned long mcast_addr = 0; | 1196 | u64 mcast_addr; |
1188 | memcpy(((char *)&mcast_addr)+2, ha->addr, ETH_ALEN); | 1197 | mcast_addr = ibmveth_encode_mac_addr(ha->addr); |
1189 | lpar_rc = h_multicast_ctrl(adapter->vdev->unit_address, | 1198 | lpar_rc = h_multicast_ctrl(adapter->vdev->unit_address, |
1190 | IbmVethMcastAddFilter, | 1199 | IbmVethMcastAddFilter, |
1191 | mcast_addr); | 1200 | mcast_addr); |
@@ -1276,18 +1285,21 @@ static unsigned long ibmveth_get_desired_dma(struct vio_dev *vdev) | |||
1276 | { | 1285 | { |
1277 | struct net_device *netdev = dev_get_drvdata(&vdev->dev); | 1286 | struct net_device *netdev = dev_get_drvdata(&vdev->dev); |
1278 | struct ibmveth_adapter *adapter; | 1287 | struct ibmveth_adapter *adapter; |
1288 | struct iommu_table *tbl; | ||
1279 | unsigned long ret; | 1289 | unsigned long ret; |
1280 | int i; | 1290 | int i; |
1281 | int rxqentries = 1; | 1291 | int rxqentries = 1; |
1282 | 1292 | ||
1293 | tbl = get_iommu_table_base(&vdev->dev); | ||
1294 | |||
1283 | /* netdev inits at probe time along with the structures we need below*/ | 1295 | /* netdev inits at probe time along with the structures we need below*/ |
1284 | if (netdev == NULL) | 1296 | if (netdev == NULL) |
1285 | return IOMMU_PAGE_ALIGN(IBMVETH_IO_ENTITLEMENT_DEFAULT); | 1297 | return IOMMU_PAGE_ALIGN(IBMVETH_IO_ENTITLEMENT_DEFAULT, tbl); |
1286 | 1298 | ||
1287 | adapter = netdev_priv(netdev); | 1299 | adapter = netdev_priv(netdev); |
1288 | 1300 | ||
1289 | ret = IBMVETH_BUFF_LIST_SIZE + IBMVETH_FILT_LIST_SIZE; | 1301 | ret = IBMVETH_BUFF_LIST_SIZE + IBMVETH_FILT_LIST_SIZE; |
1290 | ret += IOMMU_PAGE_ALIGN(netdev->mtu); | 1302 | ret += IOMMU_PAGE_ALIGN(netdev->mtu, tbl); |
1291 | 1303 | ||
1292 | for (i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++) { | 1304 | for (i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++) { |
1293 | /* add the size of the active receive buffers */ | 1305 | /* add the size of the active receive buffers */ |
@@ -1295,11 +1307,12 @@ static unsigned long ibmveth_get_desired_dma(struct vio_dev *vdev) | |||
1295 | ret += | 1307 | ret += |
1296 | adapter->rx_buff_pool[i].size * | 1308 | adapter->rx_buff_pool[i].size * |
1297 | IOMMU_PAGE_ALIGN(adapter->rx_buff_pool[i]. | 1309 | IOMMU_PAGE_ALIGN(adapter->rx_buff_pool[i]. |
1298 | buff_size); | 1310 | buff_size, tbl); |
1299 | rxqentries += adapter->rx_buff_pool[i].size; | 1311 | rxqentries += adapter->rx_buff_pool[i].size; |
1300 | } | 1312 | } |
1301 | /* add the size of the receive queue entries */ | 1313 | /* add the size of the receive queue entries */ |
1302 | ret += IOMMU_PAGE_ALIGN(rxqentries * sizeof(struct ibmveth_rx_q_entry)); | 1314 | ret += IOMMU_PAGE_ALIGN( |
1315 | rxqentries * sizeof(struct ibmveth_rx_q_entry), tbl); | ||
1303 | 1316 | ||
1304 | return ret; | 1317 | return ret; |
1305 | } | 1318 | } |
@@ -1369,9 +1382,6 @@ static int ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id) | |||
1369 | 1382 | ||
1370 | netif_napi_add(netdev, &adapter->napi, ibmveth_poll, 16); | 1383 | netif_napi_add(netdev, &adapter->napi, ibmveth_poll, 16); |
1371 | 1384 | ||
1372 | adapter->mac_addr = 0; | ||
1373 | memcpy(&adapter->mac_addr, mac_addr_p, ETH_ALEN); | ||
1374 | |||
1375 | netdev->irq = dev->irq; | 1385 | netdev->irq = dev->irq; |
1376 | netdev->netdev_ops = &ibmveth_netdev_ops; | 1386 | netdev->netdev_ops = &ibmveth_netdev_ops; |
1377 | netdev->ethtool_ops = &netdev_ethtool_ops; | 1387 | netdev->ethtool_ops = &netdev_ethtool_ops; |
@@ -1380,7 +1390,7 @@ static int ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id) | |||
1380 | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; | 1390 | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; |
1381 | netdev->features |= netdev->hw_features; | 1391 | netdev->features |= netdev->hw_features; |
1382 | 1392 | ||
1383 | memcpy(netdev->dev_addr, &adapter->mac_addr, netdev->addr_len); | 1393 | memcpy(netdev->dev_addr, mac_addr_p, ETH_ALEN); |
1384 | 1394 | ||
1385 | for (i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++) { | 1395 | for (i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++) { |
1386 | struct kobject *kobj = &adapter->rx_buff_pool[i].kobj; | 1396 | struct kobject *kobj = &adapter->rx_buff_pool[i].kobj; |