File Index
Files and directories
Sign in
FILE

mapping.h

File preview with syntax highlighting.

linux-6.19.14/drivers/net/ethernet/mellanox/mlx5/core/en/mapping.h C
 1/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
 2/* Copyright (c) 2019 Mellanox Technologies */
 3
 4#ifndef __MLX5_MAPPING_H__
 5#define __MLX5_MAPPING_H__
 6
 7struct mapping_ctx;
 8
 9int mapping_add(struct mapping_ctx *ctx, void *data, u32 *id);
10int mapping_remove(struct mapping_ctx *ctx, u32 id);
11int mapping_find(struct mapping_ctx *ctx, u32 id, void *data);
12
13/* mapping uses an xarray to map data to ids in add(), and for find().
14 * For locking, it uses a internal xarray spin lock for add()/remove(),
15 * find() uses rcu_read_lock().
16 * Choosing delayed_removal postpones the removal of a previously mapped
17 * id by MAPPING_GRACE_PERIOD milliseconds.
18 * This is to avoid races against hardware, where we mark the packet in
19 * hardware with a previous id, and quick remove() and add() reusing the same
20 * previous id. Then find() will get the new mapping instead of the old
21 * which was used to mark the packet.
22 */
23struct mapping_ctx *mapping_create(size_t data_size, u32 max_id,
24				   bool delayed_removal);
25void mapping_destroy(struct mapping_ctx *ctx);
26
27/* adds mapping with an id or get an existing mapping with the same id
28 */
29struct mapping_ctx *
30mapping_create_for_id(u8 *id, u8 id_len, u8 type, size_t data_size, u32 max_id,
31		      bool delayed_removal);
32
33#endif /* __MLX5_MAPPING_H__ */
~/ Read-only file preview.