Skip to contentSkip to conversation

i40e: add tracepoints for nvmupdate troubleshooting

PATCH Superseded Aleksandr Loktionov 2 participants 3 messages Aug 14, 2023 – Aug 17, 2023

Subsystems (2)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 i40e: add tracepoints for nvmupdate troubleshooting

Improve nvmupdate troubleshooting with bpftrace utility.
Add 'stable' static tracepoints to decode nvmupdate commands compatible even for future driver versions.
Remove 'static' from eeprom functions declarations, make them public to enable dynamic kernel tracing and profiling.

Example:
echo "i40e_*" >/sys/kernel/tracing/set_ftrace_filter echo "i40e_*" >/sys/kernel/tracing/events/i40e/filter echo 1 >/sys/kernel/tracing/tracing_on echo 1 >/sys/kernel/tracing/events/i40e/enable
...
cat /sys/kernel/tracing/trace

---
v2->v3 apply on dev-queue branch

---
 drivers/net/ethernet/intel/i40e/i40e.h        |   5 +
 .../net/ethernet/intel/i40e/i40e_ethtool.c    |  30 ++-
 drivers/net/ethernet/intel/i40e/i40e_main.c   |  20 +-
 drivers/net/ethernet/intel/i40e/i40e_trace.h  | 212 ++++++++++++++++++
 4 files changed, 256 insertions(+), 11 deletions(-)
drivers/net/ethernet/intel/i40e/i40e.h +5 -0
index 6e310a5..d48f9fd 100644
@@ -1170,6 +1170,11 @@ u32 i40e_get_current_atr_cnt(struct i40e_pf *pf);
 u32 i40e_get_global_fd_count(struct i40e_pf *pf);
 bool i40e_set_ntuple(struct i40e_pf *pf, netdev_features_t features);
 void i40e_set_ethtool_ops(struct net_device *netdev);
+int i40e_get_eeprom(struct net_device *netdev,
+		    struct ethtool_eeprom *eeprom, u8 *bytes);
+int i40e_get_eeprom_len(struct net_device *netdev);
+int i40e_set_eeprom(struct net_device *netdev,
+		    struct ethtool_eeprom *eeprom, u8 *bytes);
 struct i40e_mac_filter *i40e_add_filter(struct i40e_vsi *vsi,
 					const u8 *macaddr, s16 vlan);
 void __i40e_del_filter(struct i40e_vsi *vsi, struct i40e_mac_filter *f);
drivers/net/ethernet/intel/i40e/i40e_ethtool.c +21 -9
index bd1321b..259301c 100644
@@ -4,6 +4,7 @@
 /* ethtool support for i40e */
 
 #include "i40e.h"
+#include "i40e_trace.h"
 #include "i40e_diag.h"
 #include "i40e_txrx_common.h"
 
@@ -1848,8 +1849,8 @@ static void i40e_get_regs(struct net_device *netdev, struct ethtool_regs *regs,
 
 }
 
-static int i40e_get_eeprom(struct net_device *netdev,
-			   struct ethtool_eeprom *eeprom, u8 *bytes)
+int i40e_get_eeprom(struct net_device *netdev,
+		    struct ethtool_eeprom *eeprom, u8 *bytes)
 {
 	struct i40e_netdev_priv *np = netdev_priv(netdev);
 	struct i40e_hw *hw = &np->vsi->back->hw;
@@ -1860,6 +1861,8 @@ static int i40e_get_eeprom(struct net_device *netdev,
 	bool last;
 	u32 magic;
 
+	i40e_trace(ioctl_get_eeprom, pf,  ((u64)eeprom->offset << 32) |
+		   eeprom->len);
 #define I40E_NVM_SECTOR_SIZE  4096
 	if (eeprom->len == 0)
 		return -EINVAL;
@@ -1874,10 +1877,12 @@ static int i40e_get_eeprom(struct net_device *netdev,
 		if ((eeprom->magic >> 16) != hw->device_id)
 			errno = -EINVAL;
 		else if (test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state) ||
-			 test_bit(__I40E_RESET_INTR_RECEIVED, pf->state))
+			 test_bit(__I40E_RESET_INTR_RECEIVED, pf->state)) {
 			errno = -EBUSY;
-		else
+		} else {
 			ret_val = i40e_nvmupd_command(hw, cmd, bytes, &errno);
+			i40e_trace(nvmupd_read, hw, cmd, ret_val, errno);
+		}
 
 		if ((errno || ret_val) && (hw->debug_mask & I40E_DEBUG_NVM))
 			dev_info(&pf->pdev->dev,
@@ -1943,7 +1948,7 @@ static int i40e_get_eeprom(struct net_device *netdev,
 	return ret_val;
 }
 
-static int i40e_get_eeprom_len(struct net_device *netdev)
+int i40e_get_eeprom_len(struct net_device *netdev)
 {
 	struct i40e_netdev_priv *np = netdev_priv(netdev);
 	struct i40e_hw *hw = &np->vsi->back->hw;
@@ -1952,6 +1957,7 @@ static int i40e_get_eeprom_len(struct net_device *netdev)
 #define X722_EEPROM_SCOPE_LIMIT 0x5B9FFF
 	if (hw->mac.type == I40E_MAC_X722) {
 		val = X722_EEPROM_SCOPE_LIMIT + 1;
+		i40e_trace(ioctl_get_eeprom_len, np->vsi->back, val);
 		return val;
 	}
 	val = (rd32(hw, I40E_GLPCI_LBARCTRL)
@@ -1959,11 +1965,12 @@ static int i40e_get_eeprom_len(struct net_device *netdev)
 		>> I40E_GLPCI_LBARCTRL_FL_SIZE_SHIFT;
 	/* register returns value in power of 2, 64Kbyte chunks. */
 	val = (64 * 1024) * BIT(val);
+	i40e_trace(ioctl_get_eeprom_len, np->vsi->back, val);
 	return val;
 }
 
-static int i40e_set_eeprom(struct net_device *netdev,
-			   struct ethtool_eeprom *eeprom, u8 *bytes)
+int i40e_set_eeprom(struct net_device *netdev,
+		    struct ethtool_eeprom *eeprom, u8 *bytes)
 {
 	struct i40e_netdev_priv *np = netdev_priv(netdev);
 	struct i40e_hw *hw = &np->vsi->back->hw;
@@ -1973,6 +1980,8 @@ static int i40e_set_eeprom(struct net_device *netdev,
 	int errno = 0;
 	u32 magic;
 
+	i40e_trace(ioctl_set_eeprom, pf,  ((u64)eeprom->offset << 32) |
+		   eeprom->len);
 	/* normal ethtool set_eeprom is not supported */
 	magic = hw->vendor_id | (hw->device_id << 16);
 	if (eeprom->magic == magic)
@@ -1981,10 +1990,12 @@ static int i40e_set_eeprom(struct net_device *netdev,
 	else if (!eeprom->magic || (eeprom->magic >> 16) != hw->device_id)
 		errno = -EINVAL;
 	else if (test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state) ||
-		 test_bit(__I40E_RESET_INTR_RECEIVED, pf->state))
+		 test_bit(__I40E_RESET_INTR_RECEIVED, pf->state)) {
 		errno = -EBUSY;
-	else
+	} else {
 		ret_val = i40e_nvmupd_command(hw, cmd, bytes, &errno);
+		i40e_trace(nvmupd_write, hw, cmd, ret_val, errno);
+	}
 
 	if ((errno || ret_val) && (hw->debug_mask & I40E_DEBUG_NVM))
 		dev_info(&pf->pdev->dev,
@@ -2011,6 +2022,7 @@ static void i40e_get_drvinfo(struct net_device *netdev,
 	drvinfo->n_priv_flags = I40E_PRIV_FLAGS_STR_LEN;
 	if (pf->hw.pf_id == 0)
 		drvinfo->n_priv_flags += I40E_GL_PRIV_FLAGS_STR_LEN;
+	i40e_trace(ioctl_get_drvinfo, pf, drvinfo->n_priv_flags);
 }
 
 static void i40e_get_ringparam(struct net_device *netdev,
drivers/net/ethernet/intel/i40e/i40e_main.c +18 -2
index 506e11d..540eae4 100644
@@ -4331,20 +4331,27 @@ static irqreturn_t i40e_intr(int irq, void *data)
 		       >> I40E_GLGEN_RSTAT_RESET_TYPE_SHIFT;
 		if (val == I40E_RESET_CORER) {
 			pf->corer_count++;
+			i40e_trace(state_reset_corer, pf, pf->corer_count);
 		} else if (val == I40E_RESET_GLOBR) {
 			pf->globr_count++;
+			i40e_trace(state_reset_globr, pf, pf->globr_count);
 		} else if (val == I40E_RESET_EMPR) {
 			pf->empr_count++;
 			set_bit(__I40E_EMP_RESET_INTR_RECEIVED, pf->state);
+			i40e_trace(state_reset_empr, pf, pf->empr_count);
 		}
 	}
 
 	if (icr0 & I40E_PFINT_ICR0_HMC_ERR_MASK) {
+		const u32 err_info = rd32(hw, I40E_PFHMC_ERRORINFO);
+		const u32 err_data = rd32(hw, I40E_PFHMC_ERRORDATA);
+
 		icr0 &= ~I40E_PFINT_ICR0_HMC_ERR_MASK;
+		i40e_trace(state_hmc_error, pf,
+			   ((u64)err_info << 32) | err_data);
 		dev_info(&pf->pdev->dev, "HMC error interrupt\n");
 		dev_info(&pf->pdev->dev, "HMC error info 0x%x, HMC error data 0x%x\n",
-			 rd32(hw, I40E_PFHMC_ERRORINFO),
-			 rd32(hw, I40E_PFHMC_ERRORDATA));
+			 err_info, err_data);
 	}
 
 	if (icr0 & I40E_PFINT_ICR0_TIMESYNC_MASK) {
@@ -9908,11 +9915,13 @@ static void i40e_link_event(struct i40e_pf *pf)
 	/* On success, disable temp link polling */
 	if (status == 0) {
 		clear_bit(__I40E_TEMP_LINK_POLLING, pf->state);
+		i40e_trace(state_link, pf, pf->hw.phy.link_info.link_speed);
 	} else {
 		/* Enable link polling temporarily until i40e_get_link_status
 		 * returns 0
 		 */
 		set_bit(__I40E_TEMP_LINK_POLLING, pf->state);
+		i40e_trace(state_link, pf, pf->hw.phy.link_info.link_speed);
 		dev_dbg(&pf->pdev->dev, "couldn't get link state, status: %d\n",
 			status);
 		return;
@@ -9987,6 +9996,7 @@ static void i40e_watchdog_subtask(struct i40e_pf *pf)
 				  pf->service_timer_period)))
 		return;
 	pf->service_timer_previous = jiffies;
+	i40e_trace(state_watchdog, pf, pf->service_timer_previous);
 
 	if ((pf->flags & I40E_FLAG_LINK_POLLING_ENABLED) ||
 	    test_bit(__I40E_TEMP_LINK_POLLING, pf->state))
@@ -10039,6 +10049,8 @@ static void i40e_reset_subtask(struct i40e_pf *pf)
 
 	rtnl_lock();
 
+	i40e_trace(state_reset, pf, reset_flags);
+
 	/* If there's a recovery already waiting, it takes
 	 * precedence before starting a new reset sequence.
 	 */
@@ -10119,6 +10131,7 @@ static void i40e_clean_adminq_subtask(struct i40e_pf *pf)
 
 	/* check for error indications */
 	val = rd32(&pf->hw, pf->hw.aq.arq.len);
+	i40e_trace(state_arq, pf, val);
 	oldval = val;
 	if (val & I40E_PF_ARQLEN_ARQVFE_MASK) {
 		if (hw->debug_mask & I40E_DEBUG_AQ)
@@ -10140,6 +10153,7 @@ static void i40e_clean_adminq_subtask(struct i40e_pf *pf)
 		wr32(&pf->hw, pf->hw.aq.arq.len, val);
 
 	val = rd32(&pf->hw, pf->hw.aq.asq.len);
+	i40e_trace(state_asq, pf, val);
 	oldval = val;
 	if (val & I40E_PF_ATQLEN_ATQVFE_MASK) {
 		if (pf->hw.debug_mask & I40E_DEBUG_AQ)
@@ -11112,6 +11126,7 @@ static void i40e_rebuild(struct i40e_pf *pf, bool reinit, bool lock_acquired)
 end_core_reset:
 	clear_bit(__I40E_RESET_FAILED, pf->state);
 clear_recovery:
+	i40e_trace(state_rebuild, pf, ret);
 	clear_bit(__I40E_RESET_RECOVERY_PENDING, pf->state);
 	clear_bit(__I40E_TIMEOUT_RECOVERY_PENDING, pf->state);
 }
@@ -15430,6 +15445,7 @@ static bool i40e_check_recovery_mode(struct i40e_pf *pf)
 		dev_crit(&pf->pdev->dev, "Firmware recovery mode detected. Limiting functionality.\n");
 		dev_crit(&pf->pdev->dev, "Refer to the Intel(R) Ethernet Adapters and Devices User Guide for details on firmware recovery mode.\n");
 		set_bit(__I40E_RECOVERY_MODE, pf->state);
+		i40e_trace(state_recovery, pf, val);
 
 		return true;
 	}
drivers/net/ethernet/intel/i40e/i40e_trace.h +212 -0

218 lines not on this page · raw message

Signature · 6 lines
2.25.1

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
maintainer
#1 lore raw
Quoted 6 lines · Aleksandr Loktionov

Improve nvmupdate troubleshooting with bpftrace utility.
Add 'stable' static tracepoints to decode nvmupdate commands compatible even for future driver versions.
Remove 'static' from eeprom functions declarations, make them public to enable dynamic kernel tracing and profiling.

Quoted 7 lines

Example:
echo "i40e_*" >/sys/kernel/tracing/set_ftrace_filter echo "i40e_*" >/sys/kernel/tracing/events/i40e/filter echo 1 >/sys/kernel/tracing/tracing_on echo 1 >/sys/kernel/tracing/events/i40e/enable
...
cat /sys/kernel/tracing/trace

checkpatch reports multiple instances of:

CHECK: Lines should not end with a '('

and it has clang issues:

+../drivers/net/ethernet/intel/i40e/i40e_main.c:10854:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
+ if (test_bit(__I40E_DOWN, pf->state) &&
+ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+../include/linux/bitops.h:61:29: note: expanded from macro 'test_bit'
+#define test_bit(nr, addr) bitop(_test_bit, nr, addr)
+ ^
+../include/linux/bitops.h:49:2: note: expanded from macro 'bitop'
+ ((__builtin_constant_p(nr) && \
+ ^
+../drivers/net/ethernet/intel/i40e/i40e_main.c:11129:32: note: uninitialized use occurs here
+ i40e_trace(state_rebuild, pf, ret);
+ ^~~
+../drivers/net/ethernet/intel/i40e/./i40e_trace.h:48:69: note: expanded from macro 'i40e_trace'
+#define i40e_trace(trace_name, args...) I40E_TRACE_NAME(trace_name)(args)
+ ^~~~
+../drivers/net/ethernet/intel/i40e/i40e_main.c:10854:2: note: remove the 'if' if its condition is always false
+ if (test_bit(__I40E_DOWN, pf->state) &&
+ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+../drivers/net/ethernet/intel/i40e/i40e_main.c:10846:9: note: initialize the variable 'ret' to silence this warning
+ int ret;
+ ^
+ = 0
+1 warning generated.

Quoted 447 lines

---
v2->v3 apply on dev-queue branch

---
  drivers/net/ethernet/intel/i40e/i40e.h        |   5 +
  .../net/ethernet/intel/i40e/i40e_ethtool.c    |  30 ++-
  drivers/net/ethernet/intel/i40e/i40e_main.c   |  20 +-
  drivers/net/ethernet/intel/i40e/i40e_trace.h  | 212 ++++++++++++++++++
  4 files changed, 256 insertions(+), 11 deletions(-)
drivers/net/ethernet/intel/i40e/i40e.h +5 -0
index 6e310a5..d48f9fd 100644
@@ -1170,6 +1170,11 @@ u32 i40e_get_current_atr_cnt(struct i40e_pf *pf);
  u32 i40e_get_global_fd_count(struct i40e_pf *pf);
  bool i40e_set_ntuple(struct i40e_pf *pf, netdev_features_t features);
  void i40e_set_ethtool_ops(struct net_device *netdev);
+int i40e_get_eeprom(struct net_device *netdev,
+		    struct ethtool_eeprom *eeprom, u8 *bytes);
+int i40e_get_eeprom_len(struct net_device *netdev);
+int i40e_set_eeprom(struct net_device *netdev,
+		    struct ethtool_eeprom *eeprom, u8 *bytes);
  struct i40e_mac_filter *i40e_add_filter(struct i40e_vsi *vsi,
  					const u8 *macaddr, s16 vlan);
  void __i40e_del_filter(struct i40e_vsi *vsi, struct i40e_mac_filter *f);
drivers/net/ethernet/intel/i40e/i40e_ethtool.c +21 -9
index bd1321b..259301c 100644
@@ -4,6 +4,7 @@
  /* ethtool support for i40e */
 
  #include "i40e.h"
+#include "i40e_trace.h"
  #include "i40e_diag.h"
  #include "i40e_txrx_common.h"
 
@@ -1848,8 +1849,8 @@ static void i40e_get_regs(struct net_device *netdev, struct ethtool_regs *regs,
 
  }
 
-static int i40e_get_eeprom(struct net_device *netdev,
-			   struct ethtool_eeprom *eeprom, u8 *bytes)
+int i40e_get_eeprom(struct net_device *netdev,
+		    struct ethtool_eeprom *eeprom, u8 *bytes)
  {
  	struct i40e_netdev_priv *np = netdev_priv(netdev);
  	struct i40e_hw *hw = &np->vsi->back->hw;
@@ -1860,6 +1861,8 @@ static int i40e_get_eeprom(struct net_device *netdev,
  	bool last;
  	u32 magic;
 
+	i40e_trace(ioctl_get_eeprom, pf,  ((u64)eeprom->offset << 32) |
+		   eeprom->len);
  #define I40E_NVM_SECTOR_SIZE  4096
  	if (eeprom->len == 0)
  		return -EINVAL;
@@ -1874,10 +1877,12 @@ static int i40e_get_eeprom(struct net_device *netdev,
  		if ((eeprom->magic >> 16) != hw->device_id)
  			errno = -EINVAL;
  		else if (test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state) ||
-			 test_bit(__I40E_RESET_INTR_RECEIVED, pf->state))
+			 test_bit(__I40E_RESET_INTR_RECEIVED, pf->state)) {
  			errno = -EBUSY;
-		else
+		} else {
  			ret_val = i40e_nvmupd_command(hw, cmd, bytes, &errno);
+			i40e_trace(nvmupd_read, hw, cmd, ret_val, errno);
+		}
 
  		if ((errno || ret_val) && (hw->debug_mask & I40E_DEBUG_NVM))
  			dev_info(&pf->pdev->dev,
@@ -1943,7 +1948,7 @@ static int i40e_get_eeprom(struct net_device *netdev,
  	return ret_val;
  }
 
-static int i40e_get_eeprom_len(struct net_device *netdev)
+int i40e_get_eeprom_len(struct net_device *netdev)
  {
  	struct i40e_netdev_priv *np = netdev_priv(netdev);
  	struct i40e_hw *hw = &np->vsi->back->hw;
@@ -1952,6 +1957,7 @@ static int i40e_get_eeprom_len(struct net_device *netdev)
  #define X722_EEPROM_SCOPE_LIMIT 0x5B9FFF
  	if (hw->mac.type == I40E_MAC_X722) {
  		val = X722_EEPROM_SCOPE_LIMIT + 1;
+		i40e_trace(ioctl_get_eeprom_len, np->vsi->back, val);
  		return val;
  	}
  	val = (rd32(hw, I40E_GLPCI_LBARCTRL)
@@ -1959,11 +1965,12 @@ static int i40e_get_eeprom_len(struct net_device *netdev)
  		>> I40E_GLPCI_LBARCTRL_FL_SIZE_SHIFT;
  	/* register returns value in power of 2, 64Kbyte chunks. */
  	val = (64 * 1024) * BIT(val);
+	i40e_trace(ioctl_get_eeprom_len, np->vsi->back, val);
  	return val;
  }
 
-static int i40e_set_eeprom(struct net_device *netdev,
-			   struct ethtool_eeprom *eeprom, u8 *bytes)
+int i40e_set_eeprom(struct net_device *netdev,
+		    struct ethtool_eeprom *eeprom, u8 *bytes)
  {
  	struct i40e_netdev_priv *np = netdev_priv(netdev);
  	struct i40e_hw *hw = &np->vsi->back->hw;
@@ -1973,6 +1980,8 @@ static int i40e_set_eeprom(struct net_device *netdev,
  	int errno = 0;
  	u32 magic;
 
+	i40e_trace(ioctl_set_eeprom, pf,  ((u64)eeprom->offset << 32) |
+		   eeprom->len);
  	/* normal ethtool set_eeprom is not supported */
  	magic = hw->vendor_id | (hw->device_id << 16);
  	if (eeprom->magic == magic)
@@ -1981,10 +1990,12 @@ static int i40e_set_eeprom(struct net_device *netdev,
  	else if (!eeprom->magic || (eeprom->magic >> 16) != hw->device_id)
  		errno = -EINVAL;
  	else if (test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state) ||
-		 test_bit(__I40E_RESET_INTR_RECEIVED, pf->state))
+		 test_bit(__I40E_RESET_INTR_RECEIVED, pf->state)) {
  		errno = -EBUSY;
-	else
+	} else {
  		ret_val = i40e_nvmupd_command(hw, cmd, bytes, &errno);
+		i40e_trace(nvmupd_write, hw, cmd, ret_val, errno);
+	}
 
  	if ((errno || ret_val) && (hw->debug_mask & I40E_DEBUG_NVM))
  		dev_info(&pf->pdev->dev,
@@ -2011,6 +2022,7 @@ static void i40e_get_drvinfo(struct net_device *netdev,
  	drvinfo->n_priv_flags = I40E_PRIV_FLAGS_STR_LEN;
  	if (pf->hw.pf_id == 0)
  		drvinfo->n_priv_flags += I40E_GL_PRIV_FLAGS_STR_LEN;
+	i40e_trace(ioctl_get_drvinfo, pf, drvinfo->n_priv_flags);
  }
 
  static void i40e_get_ringparam(struct net_device *netdev,
drivers/net/ethernet/intel/i40e/i40e_main.c +18 -2
index 506e11d..540eae4 100644
@@ -4331,20 +4331,27 @@ static irqreturn_t i40e_intr(int irq, void *data)
  		       >> I40E_GLGEN_RSTAT_RESET_TYPE_SHIFT;
  		if (val == I40E_RESET_CORER) {
  			pf->corer_count++;
+			i40e_trace(state_reset_corer, pf, pf->corer_count);
  		} else if (val == I40E_RESET_GLOBR) {
  			pf->globr_count++;
+			i40e_trace(state_reset_globr, pf, pf->globr_count);
  		} else if (val == I40E_RESET_EMPR) {
  			pf->empr_count++;
  			set_bit(__I40E_EMP_RESET_INTR_RECEIVED, pf->state);
+			i40e_trace(state_reset_empr, pf, pf->empr_count);
  		}
  	}
 
  	if (icr0 & I40E_PFINT_ICR0_HMC_ERR_MASK) {
+		const u32 err_info = rd32(hw, I40E_PFHMC_ERRORINFO);
+		const u32 err_data = rd32(hw, I40E_PFHMC_ERRORDATA);
+
  		icr0 &= ~I40E_PFINT_ICR0_HMC_ERR_MASK;
+		i40e_trace(state_hmc_error, pf,
+			   ((u64)err_info << 32) | err_data);
  		dev_info(&pf->pdev->dev, "HMC error interrupt\n");
  		dev_info(&pf->pdev->dev, "HMC error info 0x%x, HMC error data 0x%x\n",
-			 rd32(hw, I40E_PFHMC_ERRORINFO),
-			 rd32(hw, I40E_PFHMC_ERRORDATA));
+			 err_info, err_data);
  	}
 
  	if (icr0 & I40E_PFINT_ICR0_TIMESYNC_MASK) {
@@ -9908,11 +9915,13 @@ static void i40e_link_event(struct i40e_pf *pf)
  	/* On success, disable temp link polling */
  	if (status == 0) {
  		clear_bit(__I40E_TEMP_LINK_POLLING, pf->state);
+		i40e_trace(state_link, pf, pf->hw.phy.link_info.link_speed);
  	} else {
  		/* Enable link polling temporarily until i40e_get_link_status
  		 * returns 0
  		 */
  		set_bit(__I40E_TEMP_LINK_POLLING, pf->state);
+		i40e_trace(state_link, pf, pf->hw.phy.link_info.link_speed);
  		dev_dbg(&pf->pdev->dev, "couldn't get link state, status: %d\n",
  			status);
  		return;
@@ -9987,6 +9996,7 @@ static void i40e_watchdog_subtask(struct i40e_pf *pf)
  				  pf->service_timer_period)))
  		return;
  	pf->service_timer_previous = jiffies;
+	i40e_trace(state_watchdog, pf, pf->service_timer_previous);
 
  	if ((pf->flags & I40E_FLAG_LINK_POLLING_ENABLED) ||
  	    test_bit(__I40E_TEMP_LINK_POLLING, pf->state))
@@ -10039,6 +10049,8 @@ static void i40e_reset_subtask(struct i40e_pf *pf)
 
  	rtnl_lock();
 
+	i40e_trace(state_reset, pf, reset_flags);
+
  	/* If there's a recovery already waiting, it takes
  	 * precedence before starting a new reset sequence.
  	 */
@@ -10119,6 +10131,7 @@ static void i40e_clean_adminq_subtask(struct i40e_pf *pf)
 
  	/* check for error indications */
  	val = rd32(&pf->hw, pf->hw.aq.arq.len);
+	i40e_trace(state_arq, pf, val);
  	oldval = val;
  	if (val & I40E_PF_ARQLEN_ARQVFE_MASK) {
  		if (hw->debug_mask & I40E_DEBUG_AQ)
@@ -10140,6 +10153,7 @@ static void i40e_clean_adminq_subtask(struct i40e_pf *pf)
  		wr32(&pf->hw, pf->hw.aq.arq.len, val);
 
  	val = rd32(&pf->hw, pf->hw.aq.asq.len);
+	i40e_trace(state_asq, pf, val);
  	oldval = val;
  	if (val & I40E_PF_ATQLEN_ATQVFE_MASK) {
  		if (pf->hw.debug_mask & I40E_DEBUG_AQ)
@@ -11112,6 +11126,7 @@ static void i40e_rebuild(struct i40e_pf *pf, bool reinit, bool lock_acquired)
  end_core_reset:
  	clear_bit(__I40E_RESET_FAILED, pf->state);
  clear_recovery:
+	i40e_trace(state_rebuild, pf, ret);
  	clear_bit(__I40E_RESET_RECOVERY_PENDING, pf->state);
  	clear_bit(__I40E_TIMEOUT_RECOVERY_PENDING, pf->state);
  }
@@ -15430,6 +15445,7 @@ static bool i40e_check_recovery_mode(struct i40e_pf *pf)
  		dev_crit(&pf->pdev->dev, "Firmware recovery mode detected. Limiting functionality.\n");
  		dev_crit(&pf->pdev->dev, "Refer to the Intel(R) Ethernet Adapters and Devices User Guide for details on firmware recovery mode.\n");
  		set_bit(__I40E_RECOVERY_MODE, pf->state);
+		i40e_trace(state_recovery, pf, val);
 
  		return true;
  	}
drivers/net/ethernet/intel/i40e/i40e_trace.h +205 -0
index 33b4e30..38bbe4d 100644
@@ -54,6 +54,218 @@
   * macro above will select the right trace point name for the driver
   * being built from shared code.
   */
+DECLARE_EVENT_CLASS(
+	i40e_state_template,
+
+	TP_PROTO(struct i40e_pf *pf, u64 val),
+
+	TP_ARGS(pf, val),
+
+	TP_STRUCT__entry(
+		__field(u64, val)
+		__field(u64, state)
+		__field(u64, bus)
+	),
+
+	TP_fast_assign(
+		__entry->val = val;
+		__entry->state = *(u64 *)pf->state;
+		__entry->bus = (((u64)pf->hw.bus.bus_id) << 32) |
+			(((u64)pf->hw.bus.device) << 16) | pf->hw.bus.func;
+	),
+
+	TP_printk(
+		"state: bus %02x:%02x.%1x state=%016llx val=%llx",
+		(unsigned int)(__entry->bus >> 32),
+		0xffff & (unsigned int)(__entry->bus >> 16),
+		0xffff & (unsigned int)__entry->bus,
+		 __entry->state, __entry->val)
+);
+
+DEFINE_EVENT(
+	i40e_state_template, i40e_state_reset,
+	TP_PROTO(struct i40e_pf *pf, u64 val),
+
+	TP_ARGS(pf, val));
+
+DEFINE_EVENT(
+	i40e_state_template, i40e_state_reset_corer,
+	TP_PROTO(struct i40e_pf *pf, u64 val),
+
+	TP_ARGS(pf, val));
+
+DEFINE_EVENT(
+	i40e_state_template, i40e_state_reset_globr,
+	TP_PROTO(struct i40e_pf *pf, u64 val),
+
+	TP_ARGS(pf, val));
+
+DEFINE_EVENT(
+	i40e_state_template, i40e_state_reset_empr,
+	TP_PROTO(struct i40e_pf *pf, u64 val),
+
+	TP_ARGS(pf, val));
+
+DEFINE_EVENT(
+	i40e_state_template, i40e_state_hmc_error,
+	TP_PROTO(struct i40e_pf *pf, u64 val),
+
+	TP_ARGS(pf, val));
+
+DEFINE_EVENT(
+	i40e_state_template, i40e_state_rebuild,
+	TP_PROTO(struct i40e_pf *pf, u64 val),
+
+	TP_ARGS(pf, val));
+
+DEFINE_EVENT(
+	i40e_state_template, i40e_state_arq,
+	TP_PROTO(struct i40e_pf *pf, u64 val),
+
+	TP_ARGS(pf, val));
+
+DEFINE_EVENT(
+	i40e_state_template, i40e_state_asq,
+	TP_PROTO(struct i40e_pf *pf, u64 val),
+
+	TP_ARGS(pf, val));
+
+DEFINE_EVENT(
+	i40e_state_template, i40e_state_udp_sync,
+	TP_PROTO(struct i40e_pf *pf, u64 val),
+
+	TP_ARGS(pf, val));
+
+DEFINE_EVENT(
+	i40e_state_template, i40e_state_watchdog,
+	TP_PROTO(struct i40e_pf *pf, u64 val),
+
+	TP_ARGS(pf, val));
+
+DEFINE_EVENT(
+	i40e_state_template, i40e_state_link,
+	TP_PROTO(struct i40e_pf *pf, u64 val),
+
+	TP_ARGS(pf, val));
+
+DEFINE_EVENT(
+	i40e_state_template, i40e_state_recovery,
+	TP_PROTO(struct i40e_pf *pf, u64 val),
+
+	TP_ARGS(pf, val));
+
+DECLARE_EVENT_CLASS(
+	i40e_ioctl_template,
+
+	TP_PROTO(struct i40e_pf *pf, u64 val),
+
+	TP_ARGS(pf, val),
+
+	TP_STRUCT__entry(
+		__field(u64, val)
+		__field(u64, state)
+		__field(u64, bus)
+		__field(pid_t, pid)
+		__array(char, comm, TASK_COMM_LEN)
+	),
+
+	TP_fast_assign(
+		__entry->val = val;
+		__entry->state = *(u64 *)pf->state;
+		__entry->bus = (((u64)pf->hw.bus.bus_id) << 32) |
+			(((u64)pf->hw.bus.device) << 16) | pf->hw.bus.func;
+		__entry->pid = current->pid;
+		memcpy(__entry->comm, current->comm, sizeof(__entry->comm) - 1);
+		__entry->comm[TASK_COMM_LEN - 1] = 0;
+	),
+
+	TP_printk(
+		"state: bus %02x:%02x.%1x state=%016llx val=%llx %5d:%s",
+		(unsigned int)(__entry->bus >> 32),
+		0xffff & (unsigned int)(__entry->bus >> 16),
+		0xffff & (unsigned int)__entry->bus,
+		__entry->state, __entry->val,
+		__entry->pid, __entry->comm)
+);
+
+DEFINE_EVENT(
+	i40e_ioctl_template, i40e_ioctl_get_drvinfo,
+	TP_PROTO(struct i40e_pf *pf, u64 val),
+
+	TP_ARGS(pf, val));
+
+DEFINE_EVENT(
+	i40e_ioctl_template, i40e_ioctl_get_eeprom_len,
+	TP_PROTO(struct i40e_pf *pf, u64 val),
+
+	TP_ARGS(pf, val));
+
+DEFINE_EVENT(
+	i40e_ioctl_template, i40e_ioctl_get_eeprom,
+	TP_PROTO(struct i40e_pf *pf, u64 val),
+
+	TP_ARGS(pf, val));
+
+DEFINE_EVENT(
+	i40e_ioctl_template, i40e_ioctl_set_eeprom,
+	TP_PROTO(struct i40e_pf *pf, u64 val),
+
+	TP_ARGS(pf, val));
+
+DECLARE_EVENT_CLASS(
+	i40e_nvmupd_template,
+
+	TP_PROTO(struct i40e_hw *hw,
+		 struct i40e_nvm_access *cmd, int ret_val, int err),
+
+	TP_ARGS(hw, cmd, ret_val, err),
+
+	TP_STRUCT__entry(
+		__field(int, ret_val)
+		__field(int, err)
+		__field(int, status)
+		__field(u64, bus)
+		__field(u32, command)
+		__field(u32, config)
+		__field(u32, offset)
+		__field(u32, data_size)
+	),
+
+	TP_fast_assign(
+		__entry->ret_val = ret_val;
+		__entry->err = err;
+		__entry->status = hw->aq.asq_last_status;
+		__entry->bus = (((u64)hw->bus.bus_id) << 32) |
+			(((u64)hw->bus.device) << 16) | hw->bus.func;
+		__entry->command = cmd->command;
+		__entry->config = cmd->config;
+		__entry->offset = cmd->offset;
+		__entry->data_size = cmd->data_size;
+	),
+
+	TP_printk(
+		"nvmupd: bus %02x:%02x.%1x err=%d status=0x%x errno=%d module=%d offset=0x%x size=%d",
+		(unsigned int)(__entry->bus >> 32),
+		0xffff & (unsigned int)(__entry->bus >> 16),
+		0xffff & (unsigned int)__entry->bus,
+		__entry->ret_val, __entry->status, __entry->err,
+		(__entry->config & I40E_NVM_MOD_PNT_MASK),
+		__entry->offset, __entry->data_size)
+);
+
+DEFINE_EVENT(
+	i40e_nvmupd_template, i40e_nvmupd_write,
+	TP_PROTO(struct i40e_hw *hw,
+		 struct i40e_nvm_access *cmd, int ret_val, int err),
+
+	TP_ARGS(hw, cmd, ret_val, err));

drivers/net/ethernet/intel/i40e/i40e_trace.h line 271

Quoted 10 lines
drivers/net/ethernet/intel/i40e/i40e_trace.h +7 -0
+
+DEFINE_EVENT(
+	i40e_nvmupd_template, i40e_nvmupd_read,
+	TP_PROTO(struct i40e_hw *hw,
+		 struct i40e_nvm_access *cmd, int ret_val, int err),
+
+	TP_ARGS(hw, cmd, ret_val, err));
 
  #define NO_DEV "(i40e no_device)"
 

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#2 lore raw
Quoted 27 lines

-----Original Message-----
From: Nguyen, Anthony L <[email protected]>
Sent: Tuesday, August 15, 2023 7:51 PM
To: Loktionov, Aleksandr <[email protected]>; intel-wired- [email protected]
Subject: Re: [PATCH iwl-next v3] i40e: add tracepoints for nvmupdate troubleshooting

Quoted 6 lines · Aleksandr Loktionov

Improve nvmupdate troubleshooting with bpftrace utility. Add 'stable' static tracepoints to decode nvmupdate commands compatible even for future driver versions.
Remove 'static' from eeprom functions declarations, make them public to enable dynamic kernel tracing and profiling.

Quoted 7 lines

Example:
echo "i40e_*" >/sys/kernel/tracing/set_ftrace_filter echo "i40e_*" >/sys/kernel/tracing/events/i40e/filter echo 1 >/sys/kernel/tracing/tracing_on echo 1 >/sys/kernel/tracing/events/i40e/enable
...
cat /sys/kernel/tracing/trace

Quoted 4 lines

checkpatch reports multiple instances of:

CHECK: Lines should not end with a '('

This is file full of macros, I don't break the style of exiting kernel code, so please ignore this warnings.

Quoted 2 lines

and it has clang issues:

Is fixed in v4

Quoted 518 lines

+../drivers/net/ethernet/intel/i40e/i40e_main.c:10854:6: warning:
variable 'ret' is used uninitialized whenever 'if' condition is true [- Wsometimes-uninitialized]

(quoted diff) +9 -0
+        if (test_bit(__I40E_DOWN, pf->state) &&
+            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+../include/linux/bitops.h:61:29: note: expanded from macro 'test_bit'
+#define test_bit(nr, addr)              bitop(_test_bit, nr, addr)
+                                        ^
+../include/linux/bitops.h:49:2: note: expanded from macro 'bitop'
+        ((__builtin_constant_p(nr) &&                                   \
+        ^
+../drivers/net/ethernet/intel/i40e/i40e_main.c:11129:32: note:

uninitialized use occurs here

(quoted diff) +3 -0
+        i40e_trace(state_rebuild, pf, ret);
+                                      ^~~
+../drivers/net/ethernet/intel/i40e/./i40e_trace.h:48:69: note: expanded

from macro 'i40e_trace'
+#define i40e_trace(trace_name, args...) I40E_TRACE_NAME(trace_name)(args)
+
+^~~~ +../drivers/net/ethernet/intel/i40e/i40e_main.c:10854:2: note: remove the 'if' if its condition is always false

(quoted diff) +3 -0
+        if (test_bit(__I40E_DOWN, pf->state) &&
+        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+../drivers/net/ethernet/intel/i40e/i40e_main.c:10846:9: note:

initialize the variable 'ret' to silence this warning

(quoted diff) +4 -0
+        int ret;
+               ^
+                = 0
+1 warning generated.
Quoted 10 lines

---
v2->v3 apply on dev-queue branch

---
  drivers/net/ethernet/intel/i40e/i40e.h        |   5 +
  .../net/ethernet/intel/i40e/i40e_ethtool.c    |  30 ++-
  drivers/net/ethernet/intel/i40e/i40e_main.c   |  20 +-
  drivers/net/ethernet/intel/i40e/i40e_trace.h  | 212

++++++++++++++++++

drivers/net/ethernet/intel/i40e/i40e.h u32 i40e_get_current_atr_cnt(struct i40e_pf

Quoted 8 lines
  4 files changed, 256 insertions(+), 11 deletions(-)
drivers/net/ethernet/intel/i40e/i40e.h +0 -0
index 6e310a5..d48f9fd 100644
@@ -1170,6 +1170,11 @@ u32 i40e_get_current_atr_cnt(struct i40e_pf

*pf);

drivers/net/ethernet/intel/i40e/i40e_ethtool.c static int i40e_get_eeprom(struct net_device

Quoted 46 lines
drivers/net/ethernet/intel/i40e/i40e.h +5 -0
  u32 i40e_get_global_fd_count(struct i40e_pf *pf);
  bool i40e_set_ntuple(struct i40e_pf *pf, netdev_features_t features);
  void i40e_set_ethtool_ops(struct net_device *netdev);
+int i40e_get_eeprom(struct net_device *netdev,
+		    struct ethtool_eeprom *eeprom, u8 *bytes); int
+i40e_get_eeprom_len(struct net_device *netdev); int
+i40e_set_eeprom(struct net_device *netdev,
+		    struct ethtool_eeprom *eeprom, u8 *bytes);
  struct i40e_mac_filter *i40e_add_filter(struct i40e_vsi *vsi,
  					const u8 *macaddr, s16 vlan);
  void __i40e_del_filter(struct i40e_vsi *vsi, struct i40e_mac_filter

*f); diff --git a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
index bd1321b..259301c 100644

drivers/net/ethernet/intel/i40e/i40e_ethtool.c +3 -2
@@ -4,6 +4,7 @@
  /* ethtool support for i40e */
 
  #include "i40e.h"
+#include "i40e_trace.h"
  #include "i40e_diag.h"
  #include "i40e_txrx_common.h"
 
@@ -1848,8 +1849,8 @@ static void i40e_get_regs(struct net_device
 *netdev, struct ethtool_regs *regs,
 
  }
 
-static int i40e_get_eeprom(struct net_device *netdev,
-			   struct ethtool_eeprom *eeprom, u8 *bytes)
+int i40e_get_eeprom(struct net_device *netdev,
+		    struct ethtool_eeprom *eeprom, u8 *bytes)
  {
  	struct i40e_netdev_priv *np = netdev_priv(netdev);

struct i40e_hw *hw = &np->vsi->back->hw; @@ -1860,6 +1861,8 @@
static int i40e_get_eeprom(struct net_device *netdev,
bool last;
u32 magic;

drivers/net/ethernet/intel/i40e/i40e_ethtool.c +2 -0
+	i40e_trace(ioctl_get_eeprom, pf,  ((u64)eeprom->offset << 32) |
+		   eeprom->len);
  #define I40E_NVM_SECTOR_SIZE  4096
  	if (eeprom->len == 0)
  		return -EINVAL;
@@ -1874,10 +1877,12 @@ static int i40e_get_eeprom(struct net_device

*netdev,

drivers/net/ethernet/intel/i40e/i40e_ethtool.c

Quoted 6 lines
drivers/net/ethernet/intel/i40e/i40e_ethtool.c +0 -0
  		if ((eeprom->magic >> 16) != hw->device_id)
  			errno = -EINVAL;
  		else if (test_bit(__I40E_RESET_RECOVERY_PENDING, pf-

state) ||

drivers/net/ethernet/intel/i40e/i40e_ethtool.c +1 -1
-			 test_bit(__I40E_RESET_INTR_RECEIVED, pf->state))
+			 test_bit(__I40E_RESET_INTR_RECEIVED, pf->state))

{

drivers/net/ethernet/intel/i40e/i40e_ethtool.c static int i40e_get_eeprom(struct net_device *netdev,

Quoted 4 lines
  			errno = -EBUSY;
drivers/net/ethernet/intel/i40e/i40e_ethtool.c +1 -1
-		else
+		} else {
  			ret_val = i40e_nvmupd_command(hw, cmd, bytes,

&errno);

drivers/net/ethernet/intel/i40e/i40e_ethtool.c static int i40e_get_eeprom(struct net_device *netdev,

Quoted 4 lines
drivers/net/ethernet/intel/i40e/i40e_ethtool.c +2 -0
+			i40e_trace(nvmupd_read, hw, cmd, ret_val, errno);
+		}
 
  		if ((errno || ret_val) && (hw->debug_mask &

I40E_DEBUG_NVM))

drivers/net/ethernet/intel/i40e/i40e_ethtool.c static int i40e_get_eeprom(struct net_device

Quoted 2 lines

dev_info(&pf->pdev->dev,

drivers/net/ethernet/intel/i40e/i40e_ethtool.c +0 -0
@@ -1943,7 +1948,7 @@ static int i40e_get_eeprom(struct net_device

*netdev,

Quoted 12 lines
drivers/net/ethernet/intel/i40e/i40e_ethtool.c +1 -1
  	return ret_val;
  }
 
-static int i40e_get_eeprom_len(struct net_device *netdev)
+int i40e_get_eeprom_len(struct net_device *netdev)
  {
  	struct i40e_netdev_priv *np = netdev_priv(netdev);
  	struct i40e_hw *hw = &np->vsi->back->hw; @@ -1952,6 +1957,7 @@

static int i40e_get_eeprom_len(struct net_device *netdev)
#define X722_EEPROM_SCOPE_LIMIT 0x5B9FFF
if (hw->mac.type == I40E_MAC_X722) {
val = X722_EEPROM_SCOPE_LIMIT + 1;

drivers/net/ethernet/intel/i40e/i40e_ethtool.c static int i40e_get_eeprom_len(struct net_device *netdev)

Quoted 4 lines
drivers/net/ethernet/intel/i40e/i40e_ethtool.c +1 -0
+		i40e_trace(ioctl_get_eeprom_len, np->vsi->back, val);
  		return val;
  	}
  	val = (rd32(hw, I40E_GLPCI_LBARCTRL) @@ -1959,11 +1965,12 @@

static

drivers/net/ethernet/intel/i40e/i40e_ethtool.c static int i40e_set_eeprom(struct net_device

Quoted 25 lines

int i40e_get_eeprom_len(struct net_device *netdev)
>> I40E_GLPCI_LBARCTRL_FL_SIZE_SHIFT;
/* register returns value in power of 2, 64Kbyte chunks. */ val = (64 * 1024) * BIT(val);

drivers/net/ethernet/intel/i40e/i40e_ethtool.c +3 -2
+	i40e_trace(ioctl_get_eeprom_len, np->vsi->back, val);
  	return val;
  }
 
-static int i40e_set_eeprom(struct net_device *netdev,
-			   struct ethtool_eeprom *eeprom, u8 *bytes)
+int i40e_set_eeprom(struct net_device *netdev,
+		    struct ethtool_eeprom *eeprom, u8 *bytes)
  {
  	struct i40e_netdev_priv *np = netdev_priv(netdev);
  	struct i40e_hw *hw = &np->vsi->back->hw; @@ -1973,6 +1980,8 @@

static int i40e_set_eeprom(struct net_device *netdev,
int errno = 0;
u32 magic;

drivers/net/ethernet/intel/i40e/i40e_ethtool.c +2 -0
+	i40e_trace(ioctl_set_eeprom, pf,  ((u64)eeprom->offset << 32) |
+		   eeprom->len);
  	/* normal ethtool set_eeprom is not supported */
  	magic = hw->vendor_id | (hw->device_id << 16);
  	if (eeprom->magic == magic)
@@ -1981,10 +1990,12 @@ static int i40e_set_eeprom(struct net_device

*netdev,

drivers/net/ethernet/intel/i40e/i40e_ethtool.c static void i40e_get_drvinfo(struct net_device

Quoted 16 lines
drivers/net/ethernet/intel/i40e/i40e_ethtool.c +4 -2
  	else if (!eeprom->magic || (eeprom->magic >> 16) != hw-
 device_id)
  		errno = -EINVAL;
  	else if (test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state) ||
-		 test_bit(__I40E_RESET_INTR_RECEIVED, pf->state))
+		 test_bit(__I40E_RESET_INTR_RECEIVED, pf->state)) {
  		errno = -EBUSY;
-	else
+	} else {
  		ret_val = i40e_nvmupd_command(hw, cmd, bytes, &errno);
+		i40e_trace(nvmupd_write, hw, cmd, ret_val, errno);
+	}
 
  	if ((errno || ret_val) && (hw->debug_mask & I40E_DEBUG_NVM))

dev_info(&pf->pdev->dev,

drivers/net/ethernet/intel/i40e/i40e_ethtool.c +0 -0
@@ -2011,6 +2022,7 @@ static void i40e_get_drvinfo(struct net_device

*netdev,

Quoted 27 lines
drivers/net/ethernet/intel/i40e/i40e_ethtool.c +1 -0
  	drvinfo->n_priv_flags = I40E_PRIV_FLAGS_STR_LEN;
  	if (pf->hw.pf_id == 0)
  		drvinfo->n_priv_flags += I40E_GL_PRIV_FLAGS_STR_LEN;
+	i40e_trace(ioctl_get_drvinfo, pf, drvinfo->n_priv_flags);
  }
 
  static void i40e_get_ringparam(struct net_device *netdev, diff --git

a/drivers/net/ethernet/intel/i40e/i40e_main.c
b/drivers/net/ethernet/intel/i40e/i40e_main.c
index 506e11d..540eae4 100644

drivers/net/ethernet/intel/i40e/i40e_main.c +3 -0
@@ -4331,20 +4331,27 @@ static irqreturn_t i40e_intr(int irq, void *data)
  		       >> I40E_GLGEN_RSTAT_RESET_TYPE_SHIFT;
  		if (val == I40E_RESET_CORER) {
  			pf->corer_count++;
+			i40e_trace(state_reset_corer, pf, pf->corer_count);
  		} else if (val == I40E_RESET_GLOBR) {
  			pf->globr_count++;
+			i40e_trace(state_reset_globr, pf, pf->globr_count);
  		} else if (val == I40E_RESET_EMPR) {
  			pf->empr_count++;
  			set_bit(__I40E_EMP_RESET_INTR_RECEIVED, pf-
 state);
+			i40e_trace(state_reset_empr, pf, pf->empr_count);
  		}
  	}

drivers/net/ethernet/intel/i40e/i40e_main.c static irqreturn_t i40e_intr(int irq, void *data) · line 4354

Quoted 10 lines
drivers/net/ethernet/intel/i40e/i40e_main.c +5 -0
 
  	if (icr0 & I40E_PFINT_ICR0_HMC_ERR_MASK) {
+		const u32 err_info = rd32(hw, I40E_PFHMC_ERRORINFO);
+		const u32 err_data = rd32(hw, I40E_PFHMC_ERRORDATA);
+
  		icr0 &= ~I40E_PFINT_ICR0_HMC_ERR_MASK;
+		i40e_trace(state_hmc_error, pf,
+			   ((u64)err_info << 32) | err_data);
  		dev_info(&pf->pdev->dev, "HMC error interrupt\n");
  		dev_info(&pf->pdev->dev, "HMC error info 0x%x, HMC error

data 0x%x\n",

Quoted 6 lines
drivers/net/ethernet/intel/i40e/i40e_main.c +1 -2
-			 rd32(hw, I40E_PFHMC_ERRORINFO),
-			 rd32(hw, I40E_PFHMC_ERRORDATA));
+			 err_info, err_data);
  	}
 

if (icr0 & I40E_PFINT_ICR0_TIMESYNC_MASK) { @@ -9908,11

+9915,13 @@

drivers/net/ethernet/intel/i40e/i40e_main.c static void i40e_link_event(struct i40e_pf *pf)

Quoted 12 lines

static void i40e_link_event(struct i40e_pf *pf)
/* On success, disable temp link polling */ if (status == 0) {
clear_bit(__I40E_TEMP_LINK_POLLING, pf->state);

drivers/net/ethernet/intel/i40e/i40e_main.c +2 -0
+		i40e_trace(state_link, pf, pf->hw.phy.link_info.link_speed);
  	} else {
  		/* Enable link polling temporarily until i40e_get_link_status
  		 * returns 0
  		 */
  		set_bit(__I40E_TEMP_LINK_POLLING, pf->state);
+		i40e_trace(state_link, pf, pf->hw.phy.link_info.link_speed);
  		dev_dbg(&pf->pdev->dev, "couldn't get link state, status:

%d\n",

drivers/net/ethernet/intel/i40e/i40e_main.c static void i40e_watchdog_subtask(struct i40e_pf

Quoted 3 lines

status);
return;

drivers/net/ethernet/intel/i40e/i40e_main.c +0 -0
@@ -9987,6 +9996,7 @@ static void i40e_watchdog_subtask(struct i40e_pf

*pf)

Quoted 24 lines
drivers/net/ethernet/intel/i40e/i40e_main.c +5 -0
  				  pf->service_timer_period)))
  		return;
  	pf->service_timer_previous = jiffies;
+	i40e_trace(state_watchdog, pf, pf->service_timer_previous);
 
  	if ((pf->flags & I40E_FLAG_LINK_POLLING_ENABLED) ||
  	    test_bit(__I40E_TEMP_LINK_POLLING, pf->state)) @@ -10039,6
+10049,8 @@ static void i40e_reset_subtask(struct i40e_pf *pf)
 
  	rtnl_lock();
 
+	i40e_trace(state_reset, pf, reset_flags);
+
  	/* If there's a recovery already waiting, it takes
  	 * precedence before starting a new reset sequence.
  	 */
@@ -10119,6 +10131,7 @@ static void i40e_clean_adminq_subtask(struct
 i40e_pf *pf)
 
  	/* check for error indications */
  	val = rd32(&pf->hw, pf->hw.aq.arq.len);
+	i40e_trace(state_arq, pf, val);
  	oldval = val;
  	if (val & I40E_PF_ARQLEN_ARQVFE_MASK) {
Quoted 1 line

if (hw->debug_mask & I40E_DEBUG_AQ) @@ -10140,6

+10153,7 @@ static

drivers/net/ethernet/intel/i40e/i40e_main.c static void i40e_clean_adminq_subtask(struct i40e_pf *pf)

Quoted 8 lines

void i40e_clean_adminq_subtask(struct i40e_pf *pf)
wr32(&pf->hw, pf->hw.aq.arq.len, val);

  	val = rd32(&pf->hw, pf->hw.aq.asq.len);
drivers/net/ethernet/intel/i40e/i40e_main.c +1 -0
+	i40e_trace(state_asq, pf, val);
  	oldval = val;
  	if (val & I40E_PF_ATQLEN_ATQVFE_MASK) {
  		if (pf->hw.debug_mask & I40E_DEBUG_AQ) @@ -11112,6

+11126,7 @@

drivers/net/ethernet/intel/i40e/i40e_main.c static bool i40e_check_recovery_mode(struct

Quoted 9 lines

static void i40e_rebuild(struct i40e_pf *pf, bool reinit, bool lock_acquired)
end_core_reset:
clear_bit(__I40E_RESET_FAILED, pf->state);
clear_recovery:

drivers/net/ethernet/intel/i40e/i40e_main.c +1 -0
+	i40e_trace(state_rebuild, pf, ret);
  	clear_bit(__I40E_RESET_RECOVERY_PENDING, pf->state);
  	clear_bit(__I40E_TIMEOUT_RECOVERY_PENDING, pf->state);
  }
@@ -15430,6 +15445,7 @@ static bool i40e_check_recovery_mode(struct

i40e_pf *pf)

drivers/net/ethernet/intel/i40e/i40e_main.c static bool i40e_check_recovery_mode(struct · line 15445

Quoted 1 line
drivers/net/ethernet/intel/i40e/i40e_main.c +0 -0
  		dev_crit(&pf->pdev->dev, "Firmware recovery mode

detected. Limiting functionality.\n");

drivers/net/ethernet/intel/i40e/i40e_main.c static bool i40e_check_recovery_mode(struct · line 15446

Quoted 1 line
drivers/net/ethernet/intel/i40e/i40e_main.c +0 -0
  		dev_crit(&pf->pdev->dev, "Refer to the Intel(R) Ethernet

Adapters and Devices User Guide for details on firmware recovery mode.\n");

Quoted 196 lines
drivers/net/ethernet/intel/i40e/i40e_main.c +1 -0
  		set_bit(__I40E_RECOVERY_MODE, pf->state);
+		i40e_trace(state_recovery, pf, val);
 
  		return true;
  	}
drivers/net/ethernet/intel/i40e/i40e_trace.h +181 -0
index 33b4e30..38bbe4d 100644
@@ -54,6 +54,218 @@
   * macro above will select the right trace point name for the driver
   * being built from shared code.
   */
+DECLARE_EVENT_CLASS(
+	i40e_state_template,
+
+	TP_PROTO(struct i40e_pf *pf, u64 val),
+
+	TP_ARGS(pf, val),
+
+	TP_STRUCT__entry(
+		__field(u64, val)
+		__field(u64, state)
+		__field(u64, bus)
+	),
+
+	TP_fast_assign(
+		__entry->val = val;
+		__entry->state = *(u64 *)pf->state;
+		__entry->bus = (((u64)pf->hw.bus.bus_id) << 32) |
+			(((u64)pf->hw.bus.device) << 16) | pf->hw.bus.func;
+	),
+
+	TP_printk(
+		"state: bus %02x:%02x.%1x state=%016llx val=%llx",
+		(unsigned int)(__entry->bus >> 32),
+		0xffff & (unsigned int)(__entry->bus >> 16),
+		0xffff & (unsigned int)__entry->bus,
+		 __entry->state, __entry->val)
+);
+
+DEFINE_EVENT(
+	i40e_state_template, i40e_state_reset,
+	TP_PROTO(struct i40e_pf *pf, u64 val),
+
+	TP_ARGS(pf, val));
+
+DEFINE_EVENT(
+	i40e_state_template, i40e_state_reset_corer,
+	TP_PROTO(struct i40e_pf *pf, u64 val),
+
+	TP_ARGS(pf, val));
+
+DEFINE_EVENT(
+	i40e_state_template, i40e_state_reset_globr,
+	TP_PROTO(struct i40e_pf *pf, u64 val),
+
+	TP_ARGS(pf, val));
+
+DEFINE_EVENT(
+	i40e_state_template, i40e_state_reset_empr,
+	TP_PROTO(struct i40e_pf *pf, u64 val),
+
+	TP_ARGS(pf, val));
+
+DEFINE_EVENT(
+	i40e_state_template, i40e_state_hmc_error,
+	TP_PROTO(struct i40e_pf *pf, u64 val),
+
+	TP_ARGS(pf, val));
+
+DEFINE_EVENT(
+	i40e_state_template, i40e_state_rebuild,
+	TP_PROTO(struct i40e_pf *pf, u64 val),
+
+	TP_ARGS(pf, val));
+
+DEFINE_EVENT(
+	i40e_state_template, i40e_state_arq,
+	TP_PROTO(struct i40e_pf *pf, u64 val),
+
+	TP_ARGS(pf, val));
+
+DEFINE_EVENT(
+	i40e_state_template, i40e_state_asq,
+	TP_PROTO(struct i40e_pf *pf, u64 val),
+
+	TP_ARGS(pf, val));
+
+DEFINE_EVENT(
+	i40e_state_template, i40e_state_udp_sync,
+	TP_PROTO(struct i40e_pf *pf, u64 val),
+
+	TP_ARGS(pf, val));
+
+DEFINE_EVENT(
+	i40e_state_template, i40e_state_watchdog,
+	TP_PROTO(struct i40e_pf *pf, u64 val),
+
+	TP_ARGS(pf, val));
+
+DEFINE_EVENT(
+	i40e_state_template, i40e_state_link,
+	TP_PROTO(struct i40e_pf *pf, u64 val),
+
+	TP_ARGS(pf, val));
+
+DEFINE_EVENT(
+	i40e_state_template, i40e_state_recovery,
+	TP_PROTO(struct i40e_pf *pf, u64 val),
+
+	TP_ARGS(pf, val));
+
+DECLARE_EVENT_CLASS(
+	i40e_ioctl_template,
+
+	TP_PROTO(struct i40e_pf *pf, u64 val),
+
+	TP_ARGS(pf, val),
+
+	TP_STRUCT__entry(
+		__field(u64, val)
+		__field(u64, state)
+		__field(u64, bus)
+		__field(pid_t, pid)
+		__array(char, comm, TASK_COMM_LEN)
+	),
+
+	TP_fast_assign(
+		__entry->val = val;
+		__entry->state = *(u64 *)pf->state;
+		__entry->bus = (((u64)pf->hw.bus.bus_id) << 32) |
+			(((u64)pf->hw.bus.device) << 16) | pf->hw.bus.func;
+		__entry->pid = current->pid;
+		memcpy(__entry->comm, current->comm, sizeof(__entry-
 comm) - 1);
+		__entry->comm[TASK_COMM_LEN - 1] = 0;
+	),
+
+	TP_printk(
+		"state: bus %02x:%02x.%1x state=%016llx val=%llx %5d:%s",
+		(unsigned int)(__entry->bus >> 32),
+		0xffff & (unsigned int)(__entry->bus >> 16),
+		0xffff & (unsigned int)__entry->bus,
+		__entry->state, __entry->val,
+		__entry->pid, __entry->comm)
+);
+
+DEFINE_EVENT(
+	i40e_ioctl_template, i40e_ioctl_get_drvinfo,
+	TP_PROTO(struct i40e_pf *pf, u64 val),
+
+	TP_ARGS(pf, val));
+
+DEFINE_EVENT(
+	i40e_ioctl_template, i40e_ioctl_get_eeprom_len,
+	TP_PROTO(struct i40e_pf *pf, u64 val),
+
+	TP_ARGS(pf, val));
+
+DEFINE_EVENT(
+	i40e_ioctl_template, i40e_ioctl_get_eeprom,
+	TP_PROTO(struct i40e_pf *pf, u64 val),
+
+	TP_ARGS(pf, val));
+
+DEFINE_EVENT(
+	i40e_ioctl_template, i40e_ioctl_set_eeprom,
+	TP_PROTO(struct i40e_pf *pf, u64 val),
+
+	TP_ARGS(pf, val));
+
+DECLARE_EVENT_CLASS(
+	i40e_nvmupd_template,
+
+	TP_PROTO(struct i40e_hw *hw,
+		 struct i40e_nvm_access *cmd, int ret_val, int err),
+
+	TP_ARGS(hw, cmd, ret_val, err),
+
+	TP_STRUCT__entry(
+		__field(int, ret_val)
+		__field(int, err)
+		__field(int, status)
+		__field(u64, bus)
+		__field(u32, command)
+		__field(u32, config)
+		__field(u32, offset)
+		__field(u32, data_size)
+	),
+
+	TP_fast_assign(
+		__entry->ret_val = ret_val;
+		__entry->err = err;
+		__entry->status = hw->aq.asq_last_status;

drivers/net/ethernet/intel/i40e/i40e_trace.h line 248

Quoted 10 lines
drivers/net/ethernet/intel/i40e/i40e_trace.h +10 -0
+		__entry->bus = (((u64)hw->bus.bus_id) << 32) |
+			(((u64)hw->bus.device) << 16) | hw->bus.func;
+		__entry->command = cmd->command;
+		__entry->config = cmd->config;
+		__entry->offset = cmd->offset;
+		__entry->data_size = cmd->data_size;
+	),
+
+	TP_printk(
+		"nvmupd: bus %02x:%02x.%1x err=%d status=0x%x

errno=%d module=%d offset=0x%x size=%d",

Quoted 21 lines
drivers/net/ethernet/intel/i40e/i40e_trace.h +20 -0
+		(unsigned int)(__entry->bus >> 32),
+		0xffff & (unsigned int)(__entry->bus >> 16),
+		0xffff & (unsigned int)__entry->bus,
+		__entry->ret_val, __entry->status, __entry->err,
+		(__entry->config & I40E_NVM_MOD_PNT_MASK),
+		__entry->offset, __entry->data_size) );
+
+DEFINE_EVENT(
+	i40e_nvmupd_template, i40e_nvmupd_write,
+	TP_PROTO(struct i40e_hw *hw,
+		 struct i40e_nvm_access *cmd, int ret_val, int err),
+
+	TP_ARGS(hw, cmd, ret_val, err));
+
+DEFINE_EVENT(
+	i40e_nvmupd_template, i40e_nvmupd_read,
+	TP_PROTO(struct i40e_hw *hw,
+		 struct i40e_nvm_access *cmd, int ret_val, int err),
+
+	TP_ARGS(hw, cmd, ret_val, err));
 
Quoted 2 lines

drivers/net/ethernet/intel/i40e/i40e_trace.h line 270

Quoted 2 lines
drivers/net/ethernet/intel/i40e/i40e_trace.h +0 -0
  #define NO_DEV "(i40e no_device)"

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan