lib/raid/raid6/s390/s390vx.uc

Source file repositories/reference/linux-study-clean/lib/raid/raid6/s390/s390vx.uc

File Facts

System
Linux kernel
Corpus path
lib/raid/raid6/s390/s390vx.uc
Extension
.uc
Size
3122 bytes
Lines
129
Domain
Kernel Services
Bucket
lib
Inferred role
Kernel Services: lib
Status
atlas-only

Why This File Exists

Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.

Dependency Surface

Detected Declarations

Annotated Snippet

// SPDX-License-Identifier: GPL-2.0
/*
 * raid6_vx$#.c
 *
 * $#-way unrolled RAID6 gen/xor functions for s390
 * based on the vector facility
 *
 * Copyright IBM Corp. 2016
 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
 *
 * This file is postprocessed using unroll.awk.
 */

#include <linux/cpufeature.h>
#include <asm/fpu.h>
#include "algos.h"

#define NSIZE 16

static __always_inline void LOAD_CONST(void)
{
	fpu_vrepib(24, 0x07);
	fpu_vrepib(25, 0x1d);
}

/*
 * The SHLBYTE() operation shifts each of the 16 bytes in
 * vector register y left by 1 bit and stores the result in
 * vector register x.
 */
#define SHLBYTE(x, y)		fpu_vab(x, y, y)

/*
 * For each of the 16 bytes in the vector register y the MASK()
 * operation returns 0xFF if the high bit of the byte is 1,
 * or 0x00 if the high bit is 0. The result is stored in vector
 * register x.
 */
#define MASK(x, y)		fpu_vesravb(x, y, 24)

#define AND(x, y, z)		fpu_vn(x, y, z)
#define XOR(x, y, z)		fpu_vx(x, y, z)
#define LOAD_DATA(x, ptr)	fpu_vlm(x, x + $# - 1, ptr)
#define STORE_DATA(x, ptr)	fpu_vstm(x, x + $# - 1, ptr)
#define COPY_VEC(x, y)		fpu_vlr(x, y)

static void raid6_s390vx$#_gen_syndrome(int disks, size_t bytes, void **ptrs)
{
	DECLARE_KERNEL_FPU_ONSTACK32(vxstate);
	u8 **dptr, *p, *q;
	int d, z, z0;

	kernel_fpu_begin(&vxstate, KERNEL_VXR);
	LOAD_CONST();

	dptr = (u8 **) ptrs;
	z0 = disks - 3;		/* Highest data disk */
	p = dptr[z0 + 1];	/* XOR parity */
	q = dptr[z0 + 2];	/* RS syndrome */

	for (d = 0; d < bytes; d += $#*NSIZE) {
		LOAD_DATA(0,&dptr[z0][d]);
		COPY_VEC(8+$$,0+$$);
		for (z = z0 - 1; z >= 0; z--) {
			MASK(16+$$,8+$$);
			AND(16+$$,16+$$,25);
			SHLBYTE(8+$$,8+$$);
			XOR(8+$$,8+$$,16+$$);
			LOAD_DATA(16,&dptr[z][d]);
			XOR(0+$$,0+$$,16+$$);

Annotation

Implementation Notes