devlink: refactor region_read_snapshot_fill to use a callback function
authorJacob Keller <jacob.e.keller@intel.com>
Mon, 28 Nov 2022 20:36:43 +0000 (12:36 -0800)
committerJakub Kicinski <kuba@kernel.org>
Thu, 1 Dec 2022 04:54:30 +0000 (20:54 -0800)
commit2d4caf0988bd3e9663c300e95cead91f2f954fae
tree8b57063cb00c967cff34ff9e54f449aa6909f319
parent284e9d1ebbe2944d95120f85054d161a6fccbf7f
devlink: refactor region_read_snapshot_fill to use a callback function

The devlink_nl_region_read_snapshot_fill is used to copy the contents of
a snapshot into a message for reporting to userspace via the
DEVLINK_CMG_REGION_READ netlink message.

A future change is going to add support for directly reading from
a region. Almost all of the logic for this new capability is identical.

To help reduce code duplication and make this logic more generic,
refactor the function to take a cb and cb_priv pointer for doing the
actual copy.

Add a devlink_region_snapshot_fill implementation that will simply copy
the relevant chunk of the region. This does require allocating some
storage for the chunk as opposed to simply passing the correct address
forward to the devlink_nl_cmg_region_read_chunk_fill function.

A future change to implement support for directly reading from a region
without a snapshot will provide a separate implementation that calls the
newly added devlink region operation.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Acked-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/core/devlink.c