162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
262306a36Sopenharmony_ci/****************************************************************************
362306a36Sopenharmony_ci * Driver for Solarflare network controllers and boards
462306a36Sopenharmony_ci * Copyright 2005-2006 Fen Systems Ltd.
562306a36Sopenharmony_ci * Copyright 2006-2012 Solarflare Communications Inc.
662306a36Sopenharmony_ci */
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci#ifndef EFX_SELFTEST_H
962306a36Sopenharmony_ci#define EFX_SELFTEST_H
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ci#include "net_driver.h"
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci/*
1462306a36Sopenharmony_ci * Self tests
1562306a36Sopenharmony_ci */
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_cistruct efx_loopback_self_tests {
1862306a36Sopenharmony_ci	int tx_sent[EFX_MAX_TXQ_PER_CHANNEL];
1962306a36Sopenharmony_ci	int tx_done[EFX_MAX_TXQ_PER_CHANNEL];
2062306a36Sopenharmony_ci	int rx_good;
2162306a36Sopenharmony_ci	int rx_bad;
2262306a36Sopenharmony_ci};
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci#define EFX_MAX_PHY_TESTS 20
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ci/* Efx self test results
2762306a36Sopenharmony_ci * For fields which are not counters, 1 indicates success and -1
2862306a36Sopenharmony_ci * indicates failure; 0 indicates test could not be run.
2962306a36Sopenharmony_ci */
3062306a36Sopenharmony_cistruct efx_self_tests {
3162306a36Sopenharmony_ci	/* online tests */
3262306a36Sopenharmony_ci	int phy_alive;
3362306a36Sopenharmony_ci	int nvram;
3462306a36Sopenharmony_ci	int interrupt;
3562306a36Sopenharmony_ci	int eventq_dma[EFX_MAX_CHANNELS];
3662306a36Sopenharmony_ci	int eventq_int[EFX_MAX_CHANNELS];
3762306a36Sopenharmony_ci	/* offline tests */
3862306a36Sopenharmony_ci	int memory;
3962306a36Sopenharmony_ci	int registers;
4062306a36Sopenharmony_ci	int phy_ext[EFX_MAX_PHY_TESTS];
4162306a36Sopenharmony_ci	struct efx_loopback_self_tests loopback[LOOPBACK_TEST_MAX + 1];
4262306a36Sopenharmony_ci};
4362306a36Sopenharmony_ci
4462306a36Sopenharmony_civoid efx_siena_loopback_rx_packet(struct efx_nic *efx, const char *buf_ptr,
4562306a36Sopenharmony_ci				  int pkt_len);
4662306a36Sopenharmony_ciint efx_siena_selftest(struct efx_nic *efx, struct efx_self_tests *tests,
4762306a36Sopenharmony_ci		       unsigned int flags);
4862306a36Sopenharmony_civoid efx_siena_selftest_async_init(struct efx_nic *efx);
4962306a36Sopenharmony_civoid efx_siena_selftest_async_start(struct efx_nic *efx);
5062306a36Sopenharmony_civoid efx_siena_selftest_async_cancel(struct efx_nic *efx);
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ci#endif /* EFX_SELFTEST_H */
53