diff options
Diffstat (limited to 'drivers/net/netxen/netxen_nic_init.c')
-rw-r--r-- | drivers/net/netxen/netxen_nic_init.c | 237 |
1 files changed, 0 insertions, 237 deletions
diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c index 869725f0bb18..deacc61e199c 100644 --- a/drivers/net/netxen/netxen_nic_init.c +++ b/drivers/net/netxen/netxen_nic_init.c | |||
@@ -35,7 +35,6 @@ | |||
35 | #include <linux/delay.h> | 35 | #include <linux/delay.h> |
36 | #include "netxen_nic.h" | 36 | #include "netxen_nic.h" |
37 | #include "netxen_nic_hw.h" | 37 | #include "netxen_nic_hw.h" |
38 | #include "netxen_nic_ioctl.h" | ||
39 | #include "netxen_nic_phan_reg.h" | 38 | #include "netxen_nic_phan_reg.h" |
40 | 39 | ||
41 | struct crb_addr_pair { | 40 | struct crb_addr_pair { |
@@ -1273,52 +1272,6 @@ int netxen_nic_tx_has_work(struct netxen_adapter *adapter) | |||
1273 | return 0; | 1272 | return 0; |
1274 | } | 1273 | } |
1275 | 1274 | ||
1276 | int | ||
1277 | netxen_nic_fill_statistics(struct netxen_adapter *adapter, | ||
1278 | struct netxen_port *port, | ||
1279 | struct netxen_statistics *netxen_stats) | ||
1280 | { | ||
1281 | void __iomem *addr; | ||
1282 | |||
1283 | if (adapter->ahw.board_type == NETXEN_NIC_XGBE) { | ||
1284 | netxen_nic_pci_change_crbwindow(adapter, 0); | ||
1285 | NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_XGE_TX_BYTE_CNT, | ||
1286 | &(netxen_stats->tx_bytes)); | ||
1287 | NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_XGE_TX_FRAME_CNT, | ||
1288 | &(netxen_stats->tx_packets)); | ||
1289 | NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_XGE_RX_BYTE_CNT, | ||
1290 | &(netxen_stats->rx_bytes)); | ||
1291 | NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_XGE_RX_FRAME_CNT, | ||
1292 | &(netxen_stats->rx_packets)); | ||
1293 | NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_XGE_AGGR_ERROR_CNT, | ||
1294 | &(netxen_stats->rx_errors)); | ||
1295 | NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_XGE_CRC_ERROR_CNT, | ||
1296 | &(netxen_stats->rx_crc_errors)); | ||
1297 | NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_XGE_OVERSIZE_FRAME_ERR, | ||
1298 | &(netxen_stats-> | ||
1299 | rx_long_length_error)); | ||
1300 | NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_XGE_UNDERSIZE_FRAME_ERR, | ||
1301 | &(netxen_stats-> | ||
1302 | rx_short_length_error)); | ||
1303 | |||
1304 | netxen_nic_pci_change_crbwindow(adapter, 1); | ||
1305 | } else { | ||
1306 | spin_lock_bh(&adapter->tx_lock); | ||
1307 | netxen_stats->tx_bytes = port->stats.txbytes; | ||
1308 | netxen_stats->tx_packets = port->stats.xmitedframes + | ||
1309 | port->stats.xmitfinished; | ||
1310 | netxen_stats->rx_bytes = port->stats.rxbytes; | ||
1311 | netxen_stats->rx_packets = port->stats.no_rcv; | ||
1312 | netxen_stats->rx_errors = port->stats.rcvdbadskb; | ||
1313 | netxen_stats->tx_errors = port->stats.nocmddescriptor; | ||
1314 | netxen_stats->rx_short_length_error = port->stats.uplcong; | ||
1315 | netxen_stats->rx_long_length_error = port->stats.uphcong; | ||
1316 | netxen_stats->rx_crc_errors = 0; | ||
1317 | netxen_stats->rx_mac_errors = 0; | ||
1318 | spin_unlock_bh(&adapter->tx_lock); | ||
1319 | } | ||
1320 | return 0; | ||
1321 | } | ||
1322 | 1275 | ||
1323 | void netxen_nic_clear_stats(struct netxen_adapter *adapter) | 1276 | void netxen_nic_clear_stats(struct netxen_adapter *adapter) |
1324 | { | 1277 | { |
@@ -1332,193 +1285,3 @@ void netxen_nic_clear_stats(struct netxen_adapter *adapter) | |||
1332 | } | 1285 | } |
1333 | } | 1286 | } |
1334 | 1287 | ||
1335 | int | ||
1336 | netxen_nic_clear_statistics(struct netxen_adapter *adapter, | ||
1337 | struct netxen_port *port) | ||
1338 | { | ||
1339 | int data = 0; | ||
1340 | |||
1341 | netxen_nic_pci_change_crbwindow(adapter, 0); | ||
1342 | |||
1343 | netxen_nic_locked_write_reg(adapter, NETXEN_NIU_XGE_TX_BYTE_CNT, &data); | ||
1344 | netxen_nic_locked_write_reg(adapter, NETXEN_NIU_XGE_TX_FRAME_CNT, | ||
1345 | &data); | ||
1346 | netxen_nic_locked_write_reg(adapter, NETXEN_NIU_XGE_RX_BYTE_CNT, &data); | ||
1347 | netxen_nic_locked_write_reg(adapter, NETXEN_NIU_XGE_RX_FRAME_CNT, | ||
1348 | &data); | ||
1349 | netxen_nic_locked_write_reg(adapter, NETXEN_NIU_XGE_AGGR_ERROR_CNT, | ||
1350 | &data); | ||
1351 | netxen_nic_locked_write_reg(adapter, NETXEN_NIU_XGE_CRC_ERROR_CNT, | ||
1352 | &data); | ||
1353 | netxen_nic_locked_write_reg(adapter, NETXEN_NIU_XGE_OVERSIZE_FRAME_ERR, | ||
1354 | &data); | ||
1355 | netxen_nic_locked_write_reg(adapter, NETXEN_NIU_XGE_UNDERSIZE_FRAME_ERR, | ||
1356 | &data); | ||
1357 | |||
1358 | netxen_nic_pci_change_crbwindow(adapter, 1); | ||
1359 | netxen_nic_clear_stats(adapter); | ||
1360 | return 0; | ||
1361 | } | ||
1362 | |||
1363 | int | ||
1364 | netxen_nic_do_ioctl(struct netxen_adapter *adapter, void *u_data, | ||
1365 | struct netxen_port *port) | ||
1366 | { | ||
1367 | struct netxen_nic_ioctl_data data; | ||
1368 | struct netxen_nic_ioctl_data *up_data; | ||
1369 | int retval = 0; | ||
1370 | struct netxen_statistics netxen_stats; | ||
1371 | |||
1372 | up_data = (void *)u_data; | ||
1373 | |||
1374 | DPRINTK(INFO, "doing ioctl for %p\n", adapter); | ||
1375 | if (copy_from_user(&data, (void __user *)up_data, sizeof(data))) { | ||
1376 | /* evil user tried to crash the kernel */ | ||
1377 | DPRINTK(ERR, "bad copy from userland: %d\n", (int)sizeof(data)); | ||
1378 | retval = -EFAULT; | ||
1379 | goto error_out; | ||
1380 | } | ||
1381 | |||
1382 | /* Shouldn't access beyond legal limits of "char u[64];" member */ | ||
1383 | if (!data.ptr && (data.size > sizeof(data.u))) { | ||
1384 | /* evil user tried to crash the kernel */ | ||
1385 | DPRINTK(ERR, "bad size: %d\n", data.size); | ||
1386 | retval = -EFAULT; | ||
1387 | goto error_out; | ||
1388 | } | ||
1389 | |||
1390 | switch (data.cmd) { | ||
1391 | case netxen_nic_cmd_pci_read: | ||
1392 | if ((retval = netxen_nic_hw_read_ioctl(adapter, data.off, | ||
1393 | &(data.u), data.size))) | ||
1394 | goto error_out; | ||
1395 | if (copy_to_user | ||
1396 | ((void __user *)&(up_data->u), &(data.u), data.size)) { | ||
1397 | DPRINTK(ERR, "bad copy to userland: %d\n", | ||
1398 | (int)sizeof(data)); | ||
1399 | retval = -EFAULT; | ||
1400 | goto error_out; | ||
1401 | } | ||
1402 | data.rv = 0; | ||
1403 | break; | ||
1404 | |||
1405 | case netxen_nic_cmd_pci_write: | ||
1406 | if ((retval = netxen_nic_hw_write_ioctl(adapter, data.off, | ||
1407 | &(data.u), data.size))) | ||
1408 | goto error_out; | ||
1409 | data.rv = 0; | ||
1410 | break; | ||
1411 | |||
1412 | case netxen_nic_cmd_pci_mem_read: | ||
1413 | if (netxen_nic_pci_mem_read_ioctl(adapter, data.off, &(data.u), | ||
1414 | data.size)) { | ||
1415 | DPRINTK(ERR, "Failed to read the data.\n"); | ||
1416 | retval = -EFAULT; | ||
1417 | goto error_out; | ||
1418 | } | ||
1419 | if (copy_to_user | ||
1420 | ((void __user *)&(up_data->u), &(data.u), data.size)) { | ||
1421 | DPRINTK(ERR, "bad copy to userland: %d\n", | ||
1422 | (int)sizeof(data)); | ||
1423 | retval = -EFAULT; | ||
1424 | goto error_out; | ||
1425 | } | ||
1426 | data.rv = 0; | ||
1427 | break; | ||
1428 | |||
1429 | case netxen_nic_cmd_pci_mem_write: | ||
1430 | if ((retval = netxen_nic_pci_mem_write_ioctl(adapter, data.off, | ||
1431 | &(data.u), | ||
1432 | data.size))) | ||
1433 | goto error_out; | ||
1434 | data.rv = 0; | ||
1435 | break; | ||
1436 | |||
1437 | case netxen_nic_cmd_pci_config_read: | ||
1438 | switch (data.size) { | ||
1439 | case 1: | ||
1440 | data.rv = pci_read_config_byte(adapter->ahw.pdev, | ||
1441 | data.off, | ||
1442 | (char *)&(data.u)); | ||
1443 | break; | ||
1444 | case 2: | ||
1445 | data.rv = pci_read_config_word(adapter->ahw.pdev, | ||
1446 | data.off, | ||
1447 | (short *)&(data.u)); | ||
1448 | break; | ||
1449 | case 4: | ||
1450 | data.rv = pci_read_config_dword(adapter->ahw.pdev, | ||
1451 | data.off, | ||
1452 | (u32 *) & (data.u)); | ||
1453 | break; | ||
1454 | } | ||
1455 | if (copy_to_user | ||
1456 | ((void __user *)&(up_data->u), &(data.u), data.size)) { | ||
1457 | DPRINTK(ERR, "bad copy to userland: %d\n", | ||
1458 | (int)sizeof(data)); | ||
1459 | retval = -EFAULT; | ||
1460 | goto error_out; | ||
1461 | } | ||
1462 | break; | ||
1463 | |||
1464 | case netxen_nic_cmd_pci_config_write: | ||
1465 | switch (data.size) { | ||
1466 | case 1: | ||
1467 | data.rv = pci_write_config_byte(adapter->ahw.pdev, | ||
1468 | data.off, | ||
1469 | *(char *)&(data.u)); | ||
1470 | break; | ||
1471 | case 2: | ||
1472 | data.rv = pci_write_config_word(adapter->ahw.pdev, | ||
1473 | data.off, | ||
1474 | *(short *)&(data.u)); | ||
1475 | break; | ||
1476 | case 4: | ||
1477 | data.rv = pci_write_config_dword(adapter->ahw.pdev, | ||
1478 | data.off, | ||
1479 | *(u32 *) & (data.u)); | ||
1480 | break; | ||
1481 | } | ||
1482 | break; | ||
1483 | |||
1484 | case netxen_nic_cmd_get_stats: | ||
1485 | data.rv = | ||
1486 | netxen_nic_fill_statistics(adapter, port, &netxen_stats); | ||
1487 | if (copy_to_user | ||
1488 | ((void __user *)(up_data->ptr), (void *)&netxen_stats, | ||
1489 | sizeof(struct netxen_statistics))) { | ||
1490 | DPRINTK(ERR, "bad copy to userland: %d\n", | ||
1491 | (int)sizeof(netxen_stats)); | ||
1492 | retval = -EFAULT; | ||
1493 | goto error_out; | ||
1494 | } | ||
1495 | up_data->rv = data.rv; | ||
1496 | break; | ||
1497 | |||
1498 | case netxen_nic_cmd_clear_stats: | ||
1499 | data.rv = netxen_nic_clear_statistics(adapter, port); | ||
1500 | up_data->rv = data.rv; | ||
1501 | break; | ||
1502 | |||
1503 | case netxen_nic_cmd_get_version: | ||
1504 | if (copy_to_user | ||
1505 | ((void __user *)&(up_data->u), NETXEN_NIC_LINUX_VERSIONID, | ||
1506 | sizeof(NETXEN_NIC_LINUX_VERSIONID))) { | ||
1507 | DPRINTK(ERR, "bad copy to userland: %d\n", | ||
1508 | (int)sizeof(data)); | ||
1509 | retval = -EFAULT; | ||
1510 | goto error_out; | ||
1511 | } | ||
1512 | break; | ||
1513 | |||
1514 | default: | ||
1515 | DPRINTK(INFO, "bad command %d for %p\n", data.cmd, adapter); | ||
1516 | retval = -EOPNOTSUPP; | ||
1517 | goto error_out; | ||
1518 | } | ||
1519 | put_user(data.rv, (&(up_data->rv))); | ||
1520 | DPRINTK(INFO, "done ioctl for %p well.\n", adapter); | ||
1521 | |||
1522 | error_out: | ||
1523 | return retval; | ||
1524 | } | ||