linux/include/linux/blk-crypto-profile.h

/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright 2019 Google LLC
 */

#ifndef __LINUX_BLK_CRYPTO_PROFILE_H
#define __LINUX_BLK_CRYPTO_PROFILE_H

#include <linux/bio.h>
#include <linux/blk-crypto.h>

struct blk_crypto_profile;

/**
 * struct blk_crypto_ll_ops - functions to control inline encryption hardware
 *
 * Low-level operations for controlling inline encryption hardware.  This
 * interface must be implemented by storage drivers that support inline
 * encryption.  All functions may sleep, are serialized by profile->lock, and
 * are never called while profile->dev (if set) is runtime-suspended.
 */
struct blk_crypto_ll_ops {};

/**
 * struct blk_crypto_profile - inline encryption profile for a device
 *
 * This struct contains a storage device's inline encryption capabilities (e.g.
 * the supported crypto algorithms), driver-provided functions to control the
 * inline encryption hardware (e.g. programming and evicting keys), and optional
 * device-independent keyslot management data.
 */
struct blk_crypto_profile {};

int blk_crypto_profile_init(struct blk_crypto_profile *profile,
			    unsigned int num_slots);

int devm_blk_crypto_profile_init(struct device *dev,
				 struct blk_crypto_profile *profile,
				 unsigned int num_slots);

unsigned int blk_crypto_keyslot_index(struct blk_crypto_keyslot *slot);

void blk_crypto_reprogram_all_keys(struct blk_crypto_profile *profile);

void blk_crypto_profile_destroy(struct blk_crypto_profile *profile);

void blk_crypto_intersect_capabilities(struct blk_crypto_profile *parent,
				       const struct blk_crypto_profile *child);

bool blk_crypto_has_capabilities(const struct blk_crypto_profile *target,
				 const struct blk_crypto_profile *reference);

void blk_crypto_update_capabilities(struct blk_crypto_profile *dst,
				    const struct blk_crypto_profile *src);

#endif /* __LINUX_BLK_CRYPTO_PROFILE_H */