static int qlcnic_do_ilb_test(struct qlcnic_adapter *adapter) { struct qlcnic_recv_context *recv_ctx = &adapter->recv_ctx; struct qlcnic_host_sds_ring *sds_ring = &recv_ctx->sds_rings[0]; struct sk_buff *skb; int i; for (i = 0; i < 16; i++) { skb = dev_alloc_skb(QLC_ILB_PKT_SIZE); qlcnic_create_loopback_buff(skb->data); skb_put(skb, QLC_ILB_PKT_SIZE); adapter->diag_cnt = 0; qlcnic_xmit_frame(skb, adapter->netdev); msleep(5); qlcnic_process_rcv_ring_diag(sds_ring); dev_kfree_skb_any(skb); if (!adapter->diag_cnt) return -1; } return 0; }
static int qlcnic_do_lb_test(struct qlcnic_adapter *adapter, u8 mode) { struct qlcnic_recv_context *recv_ctx = adapter->recv_ctx; struct qlcnic_host_sds_ring *sds_ring = &recv_ctx->sds_rings[0]; struct sk_buff *skb; int i, loop, cnt = 0; for (i = 0; i < QLCNIC_NUM_ILB_PKT; i++) { skb = netdev_alloc_skb(adapter->netdev, QLCNIC_ILB_PKT_SIZE); qlcnic_create_loopback_buff(skb->data, adapter->mac_addr); skb_put(skb, QLCNIC_ILB_PKT_SIZE); adapter->diag_cnt = 0; qlcnic_xmit_frame(skb, adapter->netdev); loop = 0; do { msleep(1); qlcnic_process_rcv_ring_diag(sds_ring); if (loop++ > QLCNIC_ILB_MAX_RCV_LOOP) break; } while (!adapter->diag_cnt); dev_kfree_skb_any(skb); if (!adapter->diag_cnt) QLCDB(adapter, DRV, "LB Test: packet #%d was not received\n", i + 1); else cnt++; } if (cnt != i) { dev_warn(&adapter->pdev->dev, "LB Test failed\n"); if (mode != QLCNIC_ILB_MODE) { dev_warn(&adapter->pdev->dev, "WARNING: Please make sure external" "loopback connector is plugged in\n"); } return -1; } return 0; }
int qlcnic_do_lb_test(struct qlcnic_adapter *adapter, u8 mode) { struct qlcnic_recv_context *recv_ctx = adapter->recv_ctx; struct qlcnic_host_sds_ring *sds_ring = &recv_ctx->sds_rings[0]; struct sk_buff *skb; int i, loop, cnt = 0; for (i = 0; i < QLCNIC_NUM_ILB_PKT; i++) { skb = netdev_alloc_skb(adapter->netdev, QLCNIC_ILB_PKT_SIZE); qlcnic_create_loopback_buff(skb->data, adapter->mac_addr); skb_put(skb, QLCNIC_ILB_PKT_SIZE); adapter->ahw->diag_cnt = 0; qlcnic_xmit_frame(skb, adapter->netdev); loop = 0; do { msleep(QLCNIC_LB_PKT_POLL_DELAY_MSEC); qlcnic_process_rcv_ring_diag(sds_ring); if (loop++ > QLCNIC_LB_PKT_POLL_COUNT) break; } while (!adapter->ahw->diag_cnt); dev_kfree_skb_any(skb); if (!adapter->ahw->diag_cnt) dev_warn(&adapter->pdev->dev, "LB Test: packet #%d was not received\n", i + 1); else cnt++; } if (cnt != i) { dev_err(&adapter->pdev->dev, "LB Test: failed, TX[%d], RX[%d]\n", i, cnt); if (mode != QLCNIC_ILB_MODE) dev_warn(&adapter->pdev->dev, "WARNING: Please check loopback cable\n"); return -1; } return 0; }
static int qlcnic_do_ilb_test(struct qlcnic_adapter *adapter) { struct qlcnic_recv_context *recv_ctx = &adapter->recv_ctx; struct qlcnic_host_sds_ring *sds_ring = &recv_ctx->sds_rings[0]; struct sk_buff *skb; int i, loop, cnt = 0; for (i = 0; i < QLC_NUM_ILB_PKT; i++) { skb = dev_alloc_skb(QLC_ILB_PKT_SIZE); qlcnic_create_loopback_buff(skb->data); skb_put(skb, QLC_ILB_PKT_SIZE); adapter->diag_cnt = 0; qlcnic_xmit_frame(skb, adapter->netdev); loop = 0; do { msleep(1); qlcnic_process_rcv_ring_diag(sds_ring); } while (loop++ < QLC_ILB_MAX_RCV_LOOP && !adapter->diag_cnt); dev_kfree_skb_any(skb); if (!adapter->diag_cnt) dev_warn(&adapter->pdev->dev, "ILB Test: %dth packet" " not recevied\n", i + 1); else cnt++; } if (cnt != i) { dev_warn(&adapter->pdev->dev, "ILB Test failed\n"); return -1; } return 0; }
int qlcnic_loopback_test(struct net_device *netdev, u8 mode) { struct qlcnic_adapter *adapter = netdev_priv(netdev); int max_sds_rings = adapter->max_sds_rings; struct qlcnic_host_sds_ring *sds_ring; struct qlcnic_hardware_context *ahw = adapter->ahw; int loop = 0; int ret; if (qlcnic_83xx_check(adapter)) return qlcnic_83xx_loopback_test(netdev, mode); if (!(ahw->capabilities & QLCNIC_FW_CAPABILITY_MULTI_LOOPBACK)) { dev_info(&adapter->pdev->dev, "Firmware do not support loopback test\n"); return -EOPNOTSUPP; } dev_warn(&adapter->pdev->dev, "%s loopback test in progress\n", mode == QLCNIC_ILB_MODE ? "internal" : "external"); if (ahw->op_mode == QLCNIC_NON_PRIV_FUNC) { dev_warn(&adapter->pdev->dev, "Loopback test not supported in nonprivileged mode\n"); return 0; } if (test_and_set_bit(__QLCNIC_RESETTING, &adapter->state)) return -EBUSY; ret = qlcnic_diag_alloc_res(netdev, QLCNIC_LOOPBACK_TEST); if (ret) goto clear_it; sds_ring = &adapter->recv_ctx->sds_rings[0]; ret = qlcnic_set_lb_mode(adapter, mode); if (ret) goto free_res; ahw->diag_cnt = 0; do { msleep(500); qlcnic_process_rcv_ring_diag(sds_ring); if (loop++ > QLCNIC_ILB_MAX_RCV_LOOP) { netdev_info(netdev, "firmware didnt respond to loopback" " configure request\n"); ret = -QLCNIC_FW_NOT_RESPOND; goto free_res; } else if (adapter->ahw->diag_cnt) { ret = adapter->ahw->diag_cnt; goto free_res; } } while (!QLCNIC_IS_LB_CONFIGURED(ahw->loopback_state)); ret = qlcnic_do_lb_test(adapter, mode); qlcnic_clear_lb_mode(adapter, mode); free_res: qlcnic_diag_free_res(netdev, max_sds_rings); clear_it: adapter->max_sds_rings = max_sds_rings; clear_bit(__QLCNIC_RESETTING, &adapter->state); return ret; }