+bool req_capsule_need_swab(struct req_capsule *pill, enum req_location loc,
+ __u32 index);
+void req_capsule_set_swabbed(struct req_capsule *pill, enum req_location loc,
+ __u32 index);
+
+/**
+ * Returns true if request buffer at offset \a index was already swabbed
+ */
+static inline bool req_capsule_req_swabbed(struct req_capsule *pill,
+ size_t index)
+{
+ LASSERT(index < sizeof(pill->rc_req_swab_mask) * 8);
+ return pill->rc_req_swab_mask & BIT(index);
+}
+
+/**
+ * Returns true if request reply buffer at offset \a index was already swabbed
+ */
+static inline bool req_capsule_rep_swabbed(struct req_capsule *pill,
+ size_t index)
+{
+ LASSERT(index < sizeof(pill->rc_rep_swab_mask) * 8);
+ return pill->rc_rep_swab_mask & BIT(index);
+}
+
+/**
+ * Returns true if request needs to be swabbed into local cpu byteorder
+ */
+static inline bool req_capsule_req_need_swab(struct req_capsule *pill)
+{
+ return req_capsule_req_swabbed(pill, MSG_PTLRPC_HEADER_OFF);
+}
+
+/**
+ * Returns true if request reply needs to be swabbed into local cpu byteorder
+ */
+static inline bool req_capsule_rep_need_swab(struct req_capsule *pill)
+{
+ return req_capsule_rep_swabbed(pill, MSG_PTLRPC_HEADER_OFF);
+}
+
+/**
+ * Mark request buffer at offset \a index that it was already swabbed
+ */
+static inline void req_capsule_set_req_swabbed(struct req_capsule *pill,
+ size_t index)
+{
+ LASSERT(index < sizeof(pill->rc_req_swab_mask) * 8);
+ LASSERT((pill->rc_req_swab_mask & BIT(index)) == 0);
+ pill->rc_req_swab_mask |= BIT(index);
+}
+
+/**
+ * Mark request reply buffer at offset \a index that it was already swabbed
+ */
+static inline void req_capsule_set_rep_swabbed(struct req_capsule *pill,
+ size_t index)
+{
+ LASSERT(index < sizeof(pill->rc_rep_swab_mask) * 8);
+ LASSERT((pill->rc_rep_swab_mask & BIT(index)) == 0);
+ pill->rc_rep_swab_mask |= BIT(index);
+}
+