1/* SPDX-License-Identifier: GPL-2.0-only */
2/****************************************************************************
3 * Driver for Solarflare network controllers and boards
4 * Copyright 2005-2006 Fen Systems Ltd.
5 * Copyright 2006-2012 Solarflare Communications Inc.
6 */
7
8#ifndef EF4_SELFTEST_H
9#define EF4_SELFTEST_H
10
11#include "net_driver.h"
12
13/*
14 * Self tests
15 */
16
17struct ef4_loopback_self_tests {
18	int tx_sent[EF4_TXQ_TYPES];
19	int tx_done[EF4_TXQ_TYPES];
20	int rx_good;
21	int rx_bad;
22};
23
24#define EF4_MAX_PHY_TESTS 20
25
26/* Efx self test results
27 * For fields which are not counters, 1 indicates success and -1
28 * indicates failure; 0 indicates test could not be run.
29 */
30struct ef4_self_tests {
31	/* online tests */
32	int phy_alive;
33	int nvram;
34	int interrupt;
35	int eventq_dma[EF4_MAX_CHANNELS];
36	int eventq_int[EF4_MAX_CHANNELS];
37	/* offline tests */
38	int memory;
39	int registers;
40	int phy_ext[EF4_MAX_PHY_TESTS];
41	struct ef4_loopback_self_tests loopback[LOOPBACK_TEST_MAX + 1];
42};
43
44void ef4_loopback_rx_packet(struct ef4_nic *efx, const char *buf_ptr,
45			    int pkt_len);
46int ef4_selftest(struct ef4_nic *efx, struct ef4_self_tests *tests,
47		 unsigned flags);
48void ef4_selftest_async_start(struct ef4_nic *efx);
49void ef4_selftest_async_cancel(struct ef4_nic *efx);
50void ef4_selftest_async_work(struct work_struct *data);
51
52#endif /* EF4_SELFTEST_H */
53