···11+/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */22+/* Copyright (c) 2019 Mellanox Technologies */33+44+#ifndef __MLX5_MAPPING_H__55+#define __MLX5_MAPPING_H__66+77+struct mapping_ctx;88+99+int mapping_add(struct mapping_ctx *ctx, void *data, u32 *id);1010+int mapping_remove(struct mapping_ctx *ctx, u32 id);1111+int mapping_find(struct mapping_ctx *ctx, u32 id, void *data);1212+1313+/* mapping uses an xarray to map data to ids in add(), and for find().1414+ * For locking, it uses a internal xarray spin lock for add()/remove(),1515+ * find() uses rcu_read_lock().1616+ * Choosing delayed_removal postpones the removal of a previously mapped1717+ * id by MAPPING_GRACE_PERIOD milliseconds.1818+ * This is to avoid races against hardware, where we mark the packet in1919+ * hardware with a previous id, and quick remove() and add() reusing the same2020+ * previous id. Then find() will get the new mapping instead of the old2121+ * which was used to mark the packet.2222+ */2323+struct mapping_ctx *mapping_create(size_t data_size, u32 max_id,2424+ bool delayed_removal);2525+void mapping_destroy(struct mapping_ctx *ctx);2626+2727+#endif /* __MLX5_MAPPING_H__ */