igc: add support to interrupt, eeprom, registers and link self-tests
Subsystems (2)
PATCH v3 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.
---
v2: Fix return 0/1 to boolean value in igc_reg_test function
v3: Address community comments
--- drivers/net/ethernet/intel/igc/Makefile | 2 +- drivers/net/ethernet/intel/igc/igc.h | 12 + drivers/net/ethernet/intel/igc/igc_diag.c | 326 +++++++++++++++++++++++++++ drivers/net/ethernet/intel/igc/igc_diag.h | 37 +++ drivers/net/ethernet/intel/igc/igc_ethtool.c | 68 ++++++ drivers/net/ethernet/intel/igc/igc_main.c | 4 +- drivers/net/ethernet/intel/igc/igc_regs.h | 1 + 7 files changed, 447 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
@@ -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 +12 -0
@@ -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);
@@ -580,4 +584,12 @@ void igc_ptp_tx_hang(struct igc_adapter *adapter);#define IGC_TX_CTXTDESC (R , i) \ (&(((struct igc_adv_tx_context_desc *)((R)->desc))[i])) +enum igc_ethtool_test_id { +IGC_ETH_TEST_REG =0 , +IGC_ETH_TEST_EEPROM , +IGC_ETH_TEST_INTR , +IGC_ETH_TEST_LOOP , +IGC_ETH_TEST_LINK , +}; +#endif /* _IGC_H_ */
drivers/net/ethernet/intel/igc/igc_diag.c new file +326 -0
326 lines not on this page · raw message
drivers/net/ethernet/intel/igc/igc_diag.h new file +37 -0
@@ -0,0 +1,37 @@ +/* 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 + +#define ETH_REG_TEST 0 +#define ETH_EEPROM_TEST 1 +#define ETH_INTR_TEST 2 +#define ETH_LOOP_TEST 3 +#define ETH_LINK_TEST 4
drivers/net/ethernet/intel/igc/igc_ethtool.c +68 -0
86 lines not on this page · raw message
drivers/net/ethernet/intel/igc/igc_main.c +2 -2
@@ -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
@@ -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
PATCH v3 1/1 igc: add support to interrupt, eeprom, registers and link self-tests
Hi Vitaly,
Quoting Vitaly Lifshits (2020-03-22 11:49:09)
Quoted 11 lines
Introduced
igc_diag.candigc_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.Signed-off-by Vitaly Lifshits <[email protected]>Reported-by kbuild test robot <[email protected]>---
v2: Fix return 0/1 to boolean value inigc_reg_testfunction
v3: Address community comments
When I run the offline tests, the interrupt test fails:
$ sudo ethtool -t enp2s0 offline The test result is FAIL The test extra info: Register test (offline) 0 Eeprom test (offline) 0 Interrupt test (offline) 4 Loopback test (offline) 0 Link test (on/offline) 0
Is this expected?
Quoted 2 lines
drivers/net/ethernet/intel/igc/igc.h +0
-0
...
drivers/net/ethernet/intel/igc/igc.h void igc_ptp_tx_hang(struct igc_adapter *adapter); · line 593
Quoted 7 lines
drivers/net/ethernet/intel/igc/igc.h +7
-0+enum igc_ethtool_test_id { +IGC_ETH_TEST_REG =0 , +IGC_ETH_TEST_EEPROM , +IGC_ETH_TEST_INTR , +IGC_ETH_TEST_LOOP , +IGC_ETH_TEST_LINK , +};
I seems this enum is only used in igc_ethtool.c so how about we defined it there intead of in igc.h?
drivers/net/ethernet/intel/igc/igc_diag.c line 2
Quoted 8 lines
drivers/net/ethernet/intel/igc/igc_diag.c new file +2
-0@@ -0,0 +1,326 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright (c) 2018 Intel Corporation */
s/2018/2020/
drivers/net/ethernet/intel/igc/igc_diag.h line 2
Quoted 8 lines
drivers/net/ethernet/intel/igc/igc_diag.h new file +2
-0@@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (c) 2018 Intel Corporation */
s/2018/2020/
drivers/net/ethernet/intel/igc/igc_diag.h line 7
Quoted 4 lines
drivers/net/ethernet/intel/igc/igc_diag.h new file +4
-0+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);
These APIs return different types (bool, int, u64)? They all could return bool, making them more consistent and easier to read.
drivers/net/ethernet/intel/igc/igc_diag.h line 15
Quoted 7 lines
drivers/net/ethernet/intel/igc/igc_diag.h new file +7
-0+struct igc_reg_test { +u16 reg; +u8 array_len; +u8 test_type; +u32 mask; +u32 write; +};
It seems this struct is used only in igc_diag.c, so how about we define it there instead of here?
Quoted 5 lines
drivers/net/ethernet/intel/igc/igc_diag.h new file +5
-0+/* 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.
drivers/net/ethernet/intel/igc/igc_diag.h line 31
Quoted 10 lines
drivers/net/ethernet/intel/igc/igc_diag.h new file +10
-0+* +* 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
The comment above applies to these macros here as well.
drivers/net/ethernet/intel/igc/igc_diag.h line 37
Quoted 6 lines
drivers/net/ethernet/intel/igc/igc_diag.h new file +6
-0+ +#define ETH_REG_TEST 0 +#define ETH_EEPROM_TEST 1 +#define ETH_INTR_TEST 2 +#define ETH_LOOP_TEST 3 +#define ETH_LINK_TEST 4
None of the macros above are used in this patch.
Regards,
Andre
PATCH v3 1/1 igc: add support to interrupt, eeprom, registers and link self-tests
Hi Andre,
Sorry for the late response. I needed to debug the fails.
Quoted 26 lines · Andre Guedes
Hi Vitaly,
Quoting Vitaly Lifshits (2020-03-22 11:49:09)
Quoted 11 lines
Introduced
igc_diag.candigc_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.Signed-off-by Vitaly Lifshits <[email protected]>Reported-by kbuild test robot <[email protected]>---
v2: Fix return 0/1 to boolean value inigc_reg_testfunction
v3: Address community commentsWhen I run the offline tests, the interrupt test fails:
$ sudo ethtool -t enp2s0 offline The test result is FAIL The test extra info: Register test (offline) 0 Eeprom test (offline) 0 Interrupt test (offline) 4 Loopback test (offline) 0 Link test (on/offline) 0
Quoted 1 line
Is this expected?
No, it means that the test failed for MSI-X interrupts.
I debugged it and found the issue, I'll send a new patch that doesn't fail soon.
Quoted 4 lines
Quoted 3 lines
drivers/net/ethernet/intel/igc/igc.h +0
-0...
Quoted 10 lines
drivers/net/ethernet/intel/igc/igc.h void igc_ptp_tx_hang(struct igc_adapter *adapter); · line 593
Quoted 7 lines
drivers/net/ethernet/intel/igc/igc.h +7
-0+enum igc_ethtool_test_id { +IGC_ETH_TEST_REG =0 , +IGC_ETH_TEST_EEPROM , +IGC_ETH_TEST_INTR , +IGC_ETH_TEST_LOOP , +IGC_ETH_TEST_LINK , +};I seems this enum is only used in
igc_ethtool.cso how about we defined it
there intead of in igc.h?I'd rather leave it inigc.h, I think it is more natural for structs to
be defined in .h files and not .c.
Quoted 12 lines
drivers/net/ethernet/intel/igc/igc_diag.c line 2
Quoted 9 lines
drivers/net/ethernet/intel/igc/igc_diag.c new file +2
-0@@ -0,0 +1,326 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright (c) 2018 Intel Corporation */ s/2018/2020/
Quoted 10 lines
drivers/net/ethernet/intel/igc/igc_diag.h line 2
Quoted 8 lines
drivers/net/ethernet/intel/igc/igc_diag.h new file +2
-0@@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (c) 2018 Intel Corporation */ s/2018/2020/
Thanks for noticing it, it will be updated in v4.
Quoted 8 lines
drivers/net/ethernet/intel/igc/igc_diag.h line 7
Quoted 5 lines
drivers/net/ethernet/intel/igc/igc_diag.h new file +4
-0+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);These APIs return different types (bool, int, u64)? They all could return bool, making them more consistent and easier to read.
After reviewing it, it can be changed to bool. I'll fix it as well.
Quoted 11 lines
drivers/net/ethernet/intel/igc/igc_diag.h line 15
Quoted 8 lines
drivers/net/ethernet/intel/igc/igc_diag.h new file +7
-0+struct igc_reg_test { +u16 reg; +u8 array_len; +u8 test_type; +u32 mask; +u32 write; +};It seems this struct is used only in
igc_diag.c, so how about we define it there instead of here?
I prefer to leave it in igc_diag.h.
Quoted 19 lines
Quoted 6 lines
drivers/net/ethernet/intel/igc/igc_diag.h new file +5
-0+/* 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. drivers/net/ethernet/intel/igc/igc_diag.h line 31
Quoted 10 lines
drivers/net/ethernet/intel/igc/igc_diag.h new file +10
-0+* +* 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 5The comment above applies to these macros here as well.
Quoted 8 lines
drivers/net/ethernet/intel/igc/igc_diag.h line 37
Quoted 6 lines
drivers/net/ethernet/intel/igc/igc_diag.h new file +6
-0+ +#define ETH_REG_TEST 0 +#define ETH_EEPROM_TEST 1 +#define ETH_INTR_TEST 2 +#define ETH_LOOP_TEST 3 +#define ETH_LINK_TEST 4None of the macros above are used in this patch.
You are right! Thanks for noticing.
Quoted 5 lines
Regards,
Andre