static int qlcnic_loopback_test(struct net_device *netdev)
{
	struct qlcnic_adapter *adapter = netdev_priv(netdev);
	int max_sds_rings = adapter->max_sds_rings;
	int ret;

	if (test_and_set_bit(__QLCNIC_RESETTING, &adapter->state))
		return -EIO;

	ret = qlcnic_diag_alloc_res(netdev, QLCNIC_LOOPBACK_TEST);
	if (ret)
		goto clear_it;

	ret = qlcnic_set_ilb_mode(adapter);
	if (ret)
		goto done;

	ret = qlcnic_do_ilb_test(adapter);

	qlcnic_clear_ilb_mode(adapter);

done:
	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;
}
Example #2
0
static int qlcnic_loopback_test(struct net_device *netdev)
{
	struct qlcnic_adapter *adapter = netdev_priv(netdev);
	int max_sds_rings = adapter->max_sds_rings;
	int ret;

	if (adapter->op_mode == QLCNIC_NON_PRIV_FUNC) {
		dev_warn(&adapter->pdev->dev, "Loopback test not supported"
				"for non privilege function\n");
		return 0;
	}

	if (test_and_set_bit(__QLCNIC_RESETTING, &adapter->state))
		return -EIO;

	if (qlcnic_request_quiscent_mode(adapter)) {
		clear_bit(__QLCNIC_RESETTING, &adapter->state);
		return -EIO;
	}

	ret = qlcnic_diag_alloc_res(netdev, QLCNIC_LOOPBACK_TEST);
	if (ret)
		goto clear_it;

	ret = qlcnic_set_ilb_mode(adapter);
	if (ret)
		goto done;

	ret = qlcnic_do_ilb_test(adapter);

	qlcnic_clear_ilb_mode(adapter);

done:
	qlcnic_diag_free_res(netdev, max_sds_rings);

clear_it:
	qlcnic_clear_quiscent_mode(adapter);
	adapter->max_sds_rings = max_sds_rings;
	clear_bit(__QLCNIC_RESETTING, &adapter->state);
	return ret;
}