Skip to content

Commit

Permalink
be2net: increase the timeout value for loopback-test FW cmd
Browse files Browse the repository at this point in the history
The loopback test FW cmd may need upto 15 seconds to complete on
certain PHYs. This patch also fixes the name of the completion variable
used to synchronize FW cmd completions as it not used by the flashing
cmd alone anymore.

Signed-off-by: Suresh Reddy <suresh.reddy@emulex.com>
Signed-off-by: Sathya Perla <sathya.perla@emulex.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Suresh Reddy authored and David S. Miller committed Jan 6, 2014
1 parent da1388d commit 5eeff63
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
2 changes: 1 addition & 1 deletion drivers/net/ethernet/emulex/benet/be.h
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ struct be_adapter {
struct list_head entry;

u32 flash_status;
struct completion flash_compl;
struct completion et_cmd_compl;

struct be_resources res; /* resources available for the func */
u16 num_vfs; /* Number of VFs provisioned by PF */
Expand Down
30 changes: 20 additions & 10 deletions drivers/net/ethernet/emulex/benet/be_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,17 @@ static int be_mcc_compl_process(struct be_adapter *adapter,
subsystem = resp_hdr->subsystem;
}

if (opcode == OPCODE_LOWLEVEL_LOOPBACK_TEST &&
subsystem == CMD_SUBSYSTEM_LOWLEVEL) {
complete(&adapter->et_cmd_compl);
return 0;
}

if (((opcode == OPCODE_COMMON_WRITE_FLASHROM) ||
(opcode == OPCODE_COMMON_WRITE_OBJECT)) &&
(subsystem == CMD_SUBSYSTEM_COMMON)) {
adapter->flash_status = compl_status;
complete(&adapter->flash_compl);
complete(&adapter->et_cmd_compl);
}

if (compl_status == MCC_STATUS_SUCCESS) {
Expand Down Expand Up @@ -2163,7 +2169,7 @@ int lancer_cmd_write_object(struct be_adapter *adapter, struct be_dma_mem *cmd,
be_mcc_notify(adapter);
spin_unlock_bh(&adapter->mcc_lock);

if (!wait_for_completion_timeout(&adapter->flash_compl,
if (!wait_for_completion_timeout(&adapter->et_cmd_compl,
msecs_to_jiffies(60000)))
status = -1;
else
Expand Down Expand Up @@ -2258,8 +2264,8 @@ int be_cmd_write_flashrom(struct be_adapter *adapter, struct be_dma_mem *cmd,
be_mcc_notify(adapter);
spin_unlock_bh(&adapter->mcc_lock);

if (!wait_for_completion_timeout(&adapter->flash_compl,
msecs_to_jiffies(40000)))
if (!wait_for_completion_timeout(&adapter->et_cmd_compl,
msecs_to_jiffies(40000)))
status = -1;
else
status = adapter->flash_status;
Expand Down Expand Up @@ -2370,6 +2376,7 @@ int be_cmd_loopback_test(struct be_adapter *adapter, u32 port_num,
{
struct be_mcc_wrb *wrb;
struct be_cmd_req_loopback_test *req;
struct be_cmd_resp_loopback_test *resp;
int status;

spin_lock_bh(&adapter->mcc_lock);
Expand All @@ -2384,21 +2391,24 @@ int be_cmd_loopback_test(struct be_adapter *adapter, u32 port_num,

be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_LOWLEVEL,
OPCODE_LOWLEVEL_LOOPBACK_TEST, sizeof(*req), wrb, NULL);
req->hdr.timeout = cpu_to_le32(4);

req->hdr.timeout = cpu_to_le32(15);
req->pattern = cpu_to_le64(pattern);
req->src_port = cpu_to_le32(port_num);
req->dest_port = cpu_to_le32(port_num);
req->pkt_size = cpu_to_le32(pkt_size);
req->num_pkts = cpu_to_le32(num_pkts);
req->loopback_type = cpu_to_le32(loopback_type);

status = be_mcc_notify_wait(adapter);
if (!status) {
struct be_cmd_resp_loopback_test *resp = embedded_payload(wrb);
status = le32_to_cpu(resp->status);
}
be_mcc_notify(adapter);

spin_unlock_bh(&adapter->mcc_lock);

wait_for_completion(&adapter->et_cmd_compl);
resp = embedded_payload(wrb);
status = le32_to_cpu(resp->status);

return status;
err:
spin_unlock_bh(&adapter->mcc_lock);
return status;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/emulex/benet/be_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4208,7 +4208,7 @@ static int be_ctrl_init(struct be_adapter *adapter)
spin_lock_init(&adapter->mcc_lock);
spin_lock_init(&adapter->mcc_cq_lock);

init_completion(&adapter->flash_compl);
init_completion(&adapter->et_cmd_compl);
pci_save_state(adapter->pdev);
return 0;

Expand Down

0 comments on commit 5eeff63

Please sign in to comment.