Skip to contentSkip to conversation

igc: add support to interrupt, eeprom, registers and link self-tests

PATCH New Vitaly Lifshits 2 participants 3 messages Mar 17, 2020 – Mar 18, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 igc: add support to interrupt, eeprom, registers and link self-tests

Introduced igc_diag.c and igc_diag.h, these files have the diagnostics functionality of igc driver. For the time being these files are being used by ethtool self-test callbacks. Which mean that interrupt, eeprom, registers and link self-tests for ethtool were implemented.

Change-type: ImplementationChange
Title: igc: add support to interrupt, eeprom, registers and link self-tests

---
 drivers/net/ethernet/intel/igc/Makefile      |   2 +-
 drivers/net/ethernet/intel/igc/igc.h         |   4 +
 drivers/net/ethernet/intel/igc/igc_diag.c    | 350 +++++++++++++++++++++++++++
 drivers/net/ethernet/intel/igc/igc_diag.h    |  31 +++
 drivers/net/ethernet/intel/igc/igc_ethtool.c |  81 +++++++
 drivers/net/ethernet/intel/igc/igc_main.c    |   4 +-
 drivers/net/ethernet/intel/igc/igc_regs.h    |   1 +
 7 files changed, 470 insertions(+), 3 deletions(-)
 create mode 100644 drivers/net/ethernet/intel/igc/igc_diag.c
 create mode 100644 drivers/net/ethernet/intel/igc/igc_diag.h
drivers/net/ethernet/intel/igc/Makefile +1 -1
index 3652f211f351..1c3051db9085 100644
@@ -8,4 +8,4 @@
 obj-$(CONFIG_IGC) += igc.o
 
 igc-objs := igc_main.o igc_mac.o igc_i225.o igc_base.o igc_nvm.o igc_phy.o \
-igc_ethtool.o igc_ptp.o igc_dump.o igc_tsn.o
+igc_diag.o igc_ethtool.o igc_ptp.o igc_dump.o igc_tsn.o
drivers/net/ethernet/intel/igc/igc.h +4 -0
index 4823b8ead547..e743f92a27c6 100644
@@ -198,6 +198,8 @@ struct igc_adapter {
 	unsigned long link_check_timeout;
 	struct igc_info ei;
 
+	u32 test_icr;
+
 	struct ptp_clock *ptp_clock;
 	struct ptp_clock_info ptp_caps;
 	struct work_struct ptp_tx_work;
@@ -215,6 +217,8 @@ struct igc_adapter {
 
 void igc_up(struct igc_adapter *adapter);
 void igc_down(struct igc_adapter *adapter);
+int igc_open(struct net_device *netdev);
+int igc_close(struct net_device *netdev);
 int igc_setup_tx_resources(struct igc_ring *ring);
 int igc_setup_rx_resources(struct igc_ring *ring);
 void igc_free_tx_resources(struct igc_ring *ring);
drivers/net/ethernet/intel/igc/igc_diag.c new file +350 -0

350 lines not on this page · raw message

drivers/net/ethernet/intel/igc/igc_diag.h new file +31 -0
new file mode 100644
index 000000000000..8a2ec9f7b338
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (c)  2018 Intel Corporation */
+
+bool igc_reg_test(struct igc_adapter *adapter, u64 *data);
+bool igc_eeprom_test(struct igc_adapter *adapter, u64 *data);
+int igc_intr_test(struct igc_adapter *adapter, u64 *data);
+u64 igc_link_test(struct igc_adapter *adapter, u64 *data);
+
+struct igc_reg_test {
+	u16 reg;
+	u8 array_len;
+	u8 test_type;
+	u32 mask;
+	u32 write;
+};
+
+/* In the hardware, registers are laid out either singly, in arrays
+ * spaced 0x40 bytes apart, or in contiguous tables.  We assume
+ * most tests take place on arrays or single registers (handled
+ * as a single-element array) and special-case the tables.
+ * Table tests are always pattern tests.
+ *
+ * We also make provision for some required setup steps by specifying
+ * registers to be written without any read-back testing.
+ */
+
+#define PATTERN_TEST	1
+#define SET_READ_TEST	2
+#define TABLE32_TEST	3
+#define TABLE64_TEST_LO	4
+#define TABLE64_TEST_HI	5
drivers/net/ethernet/intel/igc/igc_ethtool.c +81 -0

99 lines not on this page · raw message

drivers/net/ethernet/intel/igc/igc_main.c +2 -2
index 1b8023f69f28..a964ef18ac0c 100644
@@ -4449,7 +4449,7 @@ static int __igc_open(struct net_device *netdev, bool resuming)
 	return err;
 }
 
-static int igc_open(struct net_device *netdev)
+int igc_open(struct net_device *netdev)
 {
 	return __igc_open(netdev, false);
 }
@@ -4491,7 +4491,7 @@ static int __igc_close(struct net_device *netdev, bool suspending)
 	return 0;
 }
 
-static int igc_close(struct net_device *netdev)
+int igc_close(struct net_device *netdev)
 {
 	if (netif_device_present(netdev) || netdev->dismantle)
 		return __igc_close(netdev, false);
drivers/net/ethernet/intel/igc/igc_regs.h +1 -0
index 96dee3c1a5f7..7bfba20bf207 100644
@@ -119,6 +119,7 @@
 #define IGC_RLPML		0x05004  /* Rx Long Packet Max Length */
 #define IGC_RFCTL		0x05008  /* Receive Filter Control*/
 #define IGC_MTA			0x05200  /* Multicast Table Array - RW Array */
+#define IGC_RA	0x05400  /* Receive Address - RW Array */
 #define IGC_UTA			0x0A000  /* Unicast Table Array - RW */
 #define IGC_RAL(_n)		(0x05400 + ((_n) * 0x08))
 #define IGC_RAH(_n)		(0x05404 + ((_n) * 0x08))
Signature · 1 line
2.11.0
#1 lore raw
Thank you for the patch! Perhaps something to improve:

Hi Vitaly,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on jkirsher-next-queue/dev-queue]
[cannot apply to v5.6-rc6 next-20200317]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Vitaly-Lifshits/igc-add-support-to-interrupt-eeprom-registers-and-link-self-tests/20200318-025008
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/next-queue.git dev-queue
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.1-180-g0558317d-dirty
        make ARCH=x86_64 allmodconfig
        make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'

If you fix the issue, kindly add following tag

sparse warnings: (new ones prefixed by >>)

>> drivers/net/ethernet/intel/igc/igc_diag.c:7:21: sparse: sparse: symbol 'reg_test' was not declared. Should it be static?

Please review and possibly fold the followup patch.

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#2 lore raw

[RFC PATCH] igc: reg_test[] can be static

In reply to Vitaly Lifshits
Fixes: 3b18d35e6a25 ("igc: add support to interrupt, eeprom, registers and link self-tests")
Fixes 3b18d35e6a25 ("igc: add support to interrupt, eeprom, registers and link self-tests")
---
 igc_diag.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/igc/igc_diag.c +1 -1
index 80f96c9e5a90a..d6a42ab1037fc 100644
@@ -4,7 +4,7 @@
 #include "igc.h"
 #include "igc_diag.h"
 
-struct igc_reg_test reg_test[] = {
+static struct igc_reg_test reg_test[] = {
 	{ IGC_FCAL,	1,	PATTERN_TEST,	0xFFFFFFFF,	0xFFFFFFFF },
 	{ IGC_FCAH,	1,	PATTERN_TEST,	0x0000FFFF,	0xFFFFFFFF },
 	{ IGC_FCT,	1,	PATTERN_TEST,	0x0000FFFF,	0xFFFFFFFF },