18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/****************************************************************************
38c2ecf20Sopenharmony_ci * Driver for Solarflare network controllers and boards
48c2ecf20Sopenharmony_ci * Copyright 2005-2006 Fen Systems Ltd.
58c2ecf20Sopenharmony_ci * Copyright 2006-2012 Solarflare Communications Inc.
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#ifndef EF4_SELFTEST_H
98c2ecf20Sopenharmony_ci#define EF4_SELFTEST_H
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#include "net_driver.h"
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci/*
148c2ecf20Sopenharmony_ci * Self tests
158c2ecf20Sopenharmony_ci */
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_cistruct ef4_loopback_self_tests {
188c2ecf20Sopenharmony_ci	int tx_sent[EF4_TXQ_TYPES];
198c2ecf20Sopenharmony_ci	int tx_done[EF4_TXQ_TYPES];
208c2ecf20Sopenharmony_ci	int rx_good;
218c2ecf20Sopenharmony_ci	int rx_bad;
228c2ecf20Sopenharmony_ci};
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci#define EF4_MAX_PHY_TESTS 20
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci/* Efx self test results
278c2ecf20Sopenharmony_ci * For fields which are not counters, 1 indicates success and -1
288c2ecf20Sopenharmony_ci * indicates failure; 0 indicates test could not be run.
298c2ecf20Sopenharmony_ci */
308c2ecf20Sopenharmony_cistruct ef4_self_tests {
318c2ecf20Sopenharmony_ci	/* online tests */
328c2ecf20Sopenharmony_ci	int phy_alive;
338c2ecf20Sopenharmony_ci	int nvram;
348c2ecf20Sopenharmony_ci	int interrupt;
358c2ecf20Sopenharmony_ci	int eventq_dma[EF4_MAX_CHANNELS];
368c2ecf20Sopenharmony_ci	int eventq_int[EF4_MAX_CHANNELS];
378c2ecf20Sopenharmony_ci	/* offline tests */
388c2ecf20Sopenharmony_ci	int memory;
398c2ecf20Sopenharmony_ci	int registers;
408c2ecf20Sopenharmony_ci	int phy_ext[EF4_MAX_PHY_TESTS];
418c2ecf20Sopenharmony_ci	struct ef4_loopback_self_tests loopback[LOOPBACK_TEST_MAX + 1];
428c2ecf20Sopenharmony_ci};
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_civoid ef4_loopback_rx_packet(struct ef4_nic *efx, const char *buf_ptr,
458c2ecf20Sopenharmony_ci			    int pkt_len);
468c2ecf20Sopenharmony_ciint ef4_selftest(struct ef4_nic *efx, struct ef4_self_tests *tests,
478c2ecf20Sopenharmony_ci		 unsigned flags);
488c2ecf20Sopenharmony_civoid ef4_selftest_async_start(struct ef4_nic *efx);
498c2ecf20Sopenharmony_civoid ef4_selftest_async_cancel(struct ef4_nic *efx);
508c2ecf20Sopenharmony_civoid ef4_selftest_async_work(struct work_struct *data);
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci#endif /* EF4_SELFTEST_H */
53