On 9/16/2026 1:18 PM, Anatoly Burakov wrote:
A lot of parsers will rely on doing the same things over and over, so
create a header with utility functions to aid in writing parsers.
Signed-off-by: Anatoly Burakov<[email protected]>
---
<snip>
+
+/**
+ * Check if a value has no bits outside the mask, and within the mask is
+ * either all-zero or all-one.
+ *
+ * This is intended for bitfields e.g. VLAN_TCI. For byte-aligned fields,
+ * use CI_FIELD_IS_ZERO_OR_MASKED below.
+ *
+ * @param value
+ * Data value to check.
+ * @param mask
+ * Mask to compare against.
+ * @return
+ * true if (value & ~mask) == 0 AND (value & mask) is 0 or mask,
+ * false otherwise.
+ */
+static inline bool
+ci_is_zero_or_masked(uint64_t value, uint64_t mask)
+{
+ uint64_t masked = value & mask;
+ uint64_t unmasked = value & ~mask;
+
+ return unmasked == 0 && (masked == 0 || masked == mask);
I think it can be done in a more simple way:
return value == 0 || value == mask
+}
+
<snip>
+
+#endif /* _INTEL_COMMON_FLOW_UTIL_H_ */
"_COMMON_INTEL_FLOW_UTIL_H_" I guess?
--
Regards,
Vladimir