hc
2024-10-12 a5969cabbb4660eab42b6ef0412cbbd1200cf14d
kernel/drivers/net/ethernet/sfc/selftest.c
....@@ -1,11 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /****************************************************************************
23 * Driver for Solarflare network controllers and boards
34 * Copyright 2005-2006 Fen Systems Ltd.
45 * Copyright 2006-2012 Solarflare Communications Inc.
5
- *
6
- * This program is free software; you can redistribute it and/or modify it
7
- * under the terms of the GNU General Public License version 2 as published
8
- * by the Free Software Foundation, incorporated herein by reference.
96 */
107
118 #include <linux/netdevice.h>
....@@ -21,7 +18,10 @@
2118 #include <linux/slab.h>
2219 #include "net_driver.h"
2320 #include "efx.h"
21
+#include "efx_common.h"
22
+#include "efx_channels.h"
2423 #include "nic.h"
24
+#include "mcdi_port_common.h"
2525 #include "selftest.h"
2626 #include "workarounds.h"
2727
....@@ -68,7 +68,7 @@
6868 STRING_TABLE_LOOKUP(efx->interrupt_mode, efx_interrupt_mode)
6969
7070 /**
71
- * efx_loopback_state - persistent state during a loopback selftest
71
+ * struct efx_loopback_state - persistent state during a loopback selftest
7272 * @flush: Drop all packets in efx_loopback_rx_packet
7373 * @packet_count: Number of packets being used in this test
7474 * @skbs: An array of skbs transmitted
....@@ -100,10 +100,8 @@
100100 {
101101 int rc = 0;
102102
103
- if (efx->phy_op->test_alive) {
104
- rc = efx->phy_op->test_alive(efx);
105
- tests->phy_alive = rc ? -1 : 1;
106
- }
103
+ rc = efx_mcdi_phy_test_alive(efx);
104
+ tests->phy_alive = rc ? -1 : 1;
107105
108106 return rc;
109107 }
....@@ -258,11 +256,8 @@
258256 {
259257 int rc;
260258
261
- if (!efx->phy_op->run_tests)
262
- return 0;
263
-
264259 mutex_lock(&efx->mac_lock);
265
- rc = efx->phy_op->run_tests(efx, tests->phy_ext, flags);
260
+ rc = efx_mcdi_phy_run_tests(efx, tests->phy_ext, flags);
266261 mutex_unlock(&efx->mac_lock);
267262 if (rc == -EPERM)
268263 rc = 0;
....@@ -446,7 +441,7 @@
446441 if (rc != NETDEV_TX_OK) {
447442 netif_err(efx, drv, efx->net_dev,
448443 "TX queue %d could not transmit packet %d of "
449
- "%d in %s loopback test\n", tx_queue->queue,
444
+ "%d in %s loopback test\n", tx_queue->label,
450445 i + 1, state->packet_count,
451446 LOOPBACK_MODE(efx));
452447
....@@ -498,7 +493,7 @@
498493 netif_err(efx, drv, efx->net_dev,
499494 "TX queue %d saw only %d out of an expected %d "
500495 "TX completion events in %s loopback test\n",
501
- tx_queue->queue, tx_done, state->packet_count,
496
+ tx_queue->label, tx_done, state->packet_count,
502497 LOOPBACK_MODE(efx));
503498 rc = -ETIMEDOUT;
504499 /* Allow to fall through so we see the RX errors as well */
....@@ -509,15 +504,15 @@
509504 netif_dbg(efx, drv, efx->net_dev,
510505 "TX queue %d saw only %d out of an expected %d "
511506 "received packets in %s loopback test\n",
512
- tx_queue->queue, rx_good, state->packet_count,
507
+ tx_queue->label, rx_good, state->packet_count,
513508 LOOPBACK_MODE(efx));
514509 rc = -ETIMEDOUT;
515510 /* Fall through */
516511 }
517512
518513 /* Update loopback test structure */
519
- lb_tests->tx_sent[tx_queue->queue] += state->packet_count;
520
- lb_tests->tx_done[tx_queue->queue] += tx_done;
514
+ lb_tests->tx_sent[tx_queue->label] += state->packet_count;
515
+ lb_tests->tx_done[tx_queue->label] += tx_done;
521516 lb_tests->rx_good += rx_good;
522517 lb_tests->rx_bad += rx_bad;
523518
....@@ -543,8 +538,8 @@
543538 state->flush = false;
544539
545540 netif_dbg(efx, drv, efx->net_dev,
546
- "TX queue %d testing %s loopback with %d packets\n",
547
- tx_queue->queue, LOOPBACK_MODE(efx),
541
+ "TX queue %d (hw %d) testing %s loopback with %d packets\n",
542
+ tx_queue->label, tx_queue->queue, LOOPBACK_MODE(efx),
548543 state->packet_count);
549544
550545 efx_iterate_state(efx);
....@@ -571,7 +566,7 @@
571566
572567 netif_dbg(efx, drv, efx->net_dev,
573568 "TX queue %d passed %s loopback test with a burst length "
574
- "of %d packets\n", tx_queue->queue, LOOPBACK_MODE(efx),
569
+ "of %d packets\n", tx_queue->label, LOOPBACK_MODE(efx),
575570 state->packet_count);
576571
577572 return 0;
....@@ -661,8 +656,8 @@
661656
662657 /* Test all enabled types of TX queue */
663658 efx_for_each_channel_tx_queue(tx_queue, channel) {
664
- state->offload_csum = (tx_queue->queue &
665
- EFX_TXQ_TYPE_OFFLOAD);
659
+ state->offload_csum = (tx_queue->type &
660
+ EFX_TXQ_TYPE_OUTER_CSUM);
666661 rc = efx_test_loopback(tx_queue,
667662 &tests->loopback[mode]);
668663 if (rc)
....@@ -786,7 +781,7 @@
786781 cancel_delayed_work_sync(&efx->selftest_work);
787782 }
788783
789
-void efx_selftest_async_work(struct work_struct *data)
784
+static void efx_selftest_async_work(struct work_struct *data)
790785 {
791786 struct efx_nic *efx = container_of(data, struct efx_nic,
792787 selftest_work.work);
....@@ -805,3 +800,8 @@
805800 channel->channel, cpu);
806801 }
807802 }
803
+
804
+void efx_selftest_async_init(struct efx_nic *efx)
805
+{
806
+ INIT_DELAYED_WORK(&efx->selftest_work, efx_selftest_async_work);
807
+}