@@ -371,6 +371,22 @@ static inline void ethtool_stats_init(u64 *stats, unsigned int n)
stats[n] = ETHTOOL_STAT_NOT_SET;
}
+/**
+ * ethtool_stat_add - Add a value to a u64 statistic with wraparound handling
+ * @stat: Pointer to the statistic to update
+ * @value: Value to add to the statistic
+ *
+ * Adds the specified value to a u64 statistic. If the result of the addition
+ * equals the reserved value (`ETHTOOL_STAT_NOT_SET`), it increments the result
+ * by 1 to avoid the reserved value.
+ */
+static inline void ethtool_stat_add(u64 *stat, u64 value)
+{
+ *stat += value;
+ if (*stat == ETHTOOL_STAT_NOT_SET)
+ (*stat)++;
+}
+
/* Basic IEEE 802.3 MAC statistics (30.3.1.1.*), not otherwise exposed
* via a more targeted API.
*/