drivers/crypto/nx/nx-842.h

Source file repositories/reference/linux-study-clean/drivers/crypto/nx/nx-842.h

File Facts

System
Linux kernel
Corpus path
drivers/crypto/nx/nx-842.h
Extension
.h
Size
6350 bytes
Lines
196
Domain
Driver Families
Bucket
drivers/crypto
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct nx842_constraints {
	int alignment;
	int multiple;
	int minimum;
	int maximum;
};

struct nx842_driver {
	char *name;
	struct module *owner;
	size_t workmem_size;

	struct nx842_constraints *constraints;

	int (*compress)(const unsigned char *in, unsigned int in_len,
			unsigned char *out, unsigned int *out_len,
			void *wrkmem);
	int (*decompress)(const unsigned char *in, unsigned int in_len,
			  unsigned char *out, unsigned int *out_len,
			  void *wrkmem);
};

struct nx842_crypto_header_group {
	__be16 padding;			/* unused bytes at start of group */
	__be32 compressed_length;	/* compressed bytes in group */
	__be32 uncompressed_length;	/* bytes after decompression */
} __packed;

struct nx842_crypto_header {
	/* New members MUST be added within the struct_group() macro below. */
	__struct_group(nx842_crypto_header_hdr, hdr, __packed,
		__be16 magic;		/* NX842_CRYPTO_MAGIC */
		__be16 ignore;		/* decompressed end bytes to ignore */
		u8 groups;		/* total groups in this header */
	);
	struct nx842_crypto_header_group group[] __counted_by(groups);
} __packed;
static_assert(offsetof(struct nx842_crypto_header, group) == sizeof(struct nx842_crypto_header_hdr),
	      "struct member likely outside of __struct_group()");

#define NX842_CRYPTO_GROUP_MAX	(0x20)

struct nx842_crypto_ctx {
	spinlock_t lock;

	u8 *wmem;
	u8 *sbounce, *dbounce;

	struct nx842_crypto_header_hdr header;
	struct nx842_crypto_header_group group[NX842_CRYPTO_GROUP_MAX];

	struct nx842_driver *driver;
};

void *nx842_crypto_alloc_ctx(struct nx842_driver *driver);
void nx842_crypto_free_ctx(void *ctx);
int nx842_crypto_compress(struct crypto_scomp *tfm,
			  const u8 *src, unsigned int slen,
			  u8 *dst, unsigned int *dlen, void *ctx);
int nx842_crypto_decompress(struct crypto_scomp *tfm,
			    const u8 *src, unsigned int slen,
			    u8 *dst, unsigned int *dlen, void *ctx);

#endif /* __NX_842_H__ */

Annotation

Implementation Notes