diff options
author | Suresh R <sureshr@serverengines.com> | 2009-12-03 19:15:52 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-12-03 19:15:52 -0500 |
commit | ff33a6e2ab97f4cde484cdf1a41778af6d6b7cff (patch) | |
tree | 655e8cc5a61e6ed5245b182217fbca9632d17499 /drivers/net/benet/be_cmds.c | |
parent | 49d09007879ce7bee36ab453c73e97c00adce884 (diff) |
be2net: Add support for ethtool self test
This patch adds support for ethtool selftest.
From: Suresh R <sureshr@serverengines.com>
Signed-off-by: Ajit Khaparde <ajitk@serverengines.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/benet/be_cmds.c')
-rw-r--r-- | drivers/net/benet/be_cmds.c | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/drivers/net/benet/be_cmds.c b/drivers/net/benet/be_cmds.c index bee7b822d120..1b68bd98dc0c 100644 --- a/drivers/net/benet/be_cmds.c +++ b/drivers/net/benet/be_cmds.c | |||
@@ -1478,3 +1478,96 @@ err: | |||
1478 | spin_unlock_bh(&adapter->mcc_lock); | 1478 | spin_unlock_bh(&adapter->mcc_lock); |
1479 | return status; | 1479 | return status; |
1480 | } | 1480 | } |
1481 | |||
1482 | int be_cmd_loopback_test(struct be_adapter *adapter, u32 port_num, | ||
1483 | u32 loopback_type, u32 pkt_size, u32 num_pkts, u64 pattern) | ||
1484 | { | ||
1485 | struct be_mcc_wrb *wrb; | ||
1486 | struct be_cmd_req_loopback_test *req; | ||
1487 | int status; | ||
1488 | |||
1489 | spin_lock_bh(&adapter->mcc_lock); | ||
1490 | |||
1491 | wrb = wrb_from_mccq(adapter); | ||
1492 | if (!wrb) { | ||
1493 | status = -EBUSY; | ||
1494 | goto err; | ||
1495 | } | ||
1496 | |||
1497 | req = embedded_payload(wrb); | ||
1498 | |||
1499 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0, | ||
1500 | OPCODE_LOWLEVEL_LOOPBACK_TEST); | ||
1501 | |||
1502 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_LOWLEVEL, | ||
1503 | OPCODE_LOWLEVEL_LOOPBACK_TEST, sizeof(*req)); | ||
1504 | |||
1505 | req->pattern = cpu_to_le64(pattern); | ||
1506 | req->src_port = cpu_to_le32(port_num); | ||
1507 | req->dest_port = cpu_to_le32(port_num); | ||
1508 | req->pkt_size = cpu_to_le32(pkt_size); | ||
1509 | req->num_pkts = cpu_to_le32(num_pkts); | ||
1510 | req->loopback_type = cpu_to_le32(loopback_type); | ||
1511 | |||
1512 | status = be_mcc_notify_wait(adapter); | ||
1513 | if (!status) { | ||
1514 | struct be_cmd_resp_loopback_test *resp = embedded_payload(wrb); | ||
1515 | status = le32_to_cpu(resp->status); | ||
1516 | } | ||
1517 | |||
1518 | err: | ||
1519 | spin_unlock_bh(&adapter->mcc_lock); | ||
1520 | return status; | ||
1521 | } | ||
1522 | |||
1523 | int be_cmd_ddr_dma_test(struct be_adapter *adapter, u64 pattern, | ||
1524 | u32 byte_cnt, struct be_dma_mem *cmd) | ||
1525 | { | ||
1526 | struct be_mcc_wrb *wrb; | ||
1527 | struct be_cmd_req_ddrdma_test *req; | ||
1528 | struct be_sge *sge; | ||
1529 | int status; | ||
1530 | int i, j = 0; | ||
1531 | |||
1532 | spin_lock_bh(&adapter->mcc_lock); | ||
1533 | |||
1534 | wrb = wrb_from_mccq(adapter); | ||
1535 | if (!wrb) { | ||
1536 | status = -EBUSY; | ||
1537 | goto err; | ||
1538 | } | ||
1539 | req = cmd->va; | ||
1540 | sge = nonembedded_sgl(wrb); | ||
1541 | be_wrb_hdr_prepare(wrb, cmd->size, false, 1, | ||
1542 | OPCODE_LOWLEVEL_HOST_DDR_DMA); | ||
1543 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_LOWLEVEL, | ||
1544 | OPCODE_LOWLEVEL_HOST_DDR_DMA, cmd->size); | ||
1545 | |||
1546 | sge->pa_hi = cpu_to_le32(upper_32_bits(cmd->dma)); | ||
1547 | sge->pa_lo = cpu_to_le32(cmd->dma & 0xFFFFFFFF); | ||
1548 | sge->len = cpu_to_le32(cmd->size); | ||
1549 | |||
1550 | req->pattern = cpu_to_le64(pattern); | ||
1551 | req->byte_count = cpu_to_le32(byte_cnt); | ||
1552 | for (i = 0; i < byte_cnt; i++) { | ||
1553 | req->snd_buff[i] = (u8)(pattern >> (j*8)); | ||
1554 | j++; | ||
1555 | if (j > 7) | ||
1556 | j = 0; | ||
1557 | } | ||
1558 | |||
1559 | status = be_mcc_notify_wait(adapter); | ||
1560 | |||
1561 | if (!status) { | ||
1562 | struct be_cmd_resp_ddrdma_test *resp; | ||
1563 | resp = cmd->va; | ||
1564 | if ((memcmp(resp->rcv_buff, req->snd_buff, byte_cnt) != 0) || | ||
1565 | resp->snd_err) { | ||
1566 | status = -1; | ||
1567 | } | ||
1568 | } | ||
1569 | |||
1570 | err: | ||
1571 | spin_unlock_bh(&adapter->mcc_lock); | ||
1572 | return status; | ||
1573 | } | ||