lib/raid/raid6/powerpc/vpermxor.uc

Source file repositories/reference/linux-study-clean/lib/raid/raid6/powerpc/vpermxor.uc

File Facts

System
Linux kernel
Corpus path
lib/raid/raid6/powerpc/vpermxor.uc
Extension
.uc
Size
2365 bytes
Lines
83
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

#include <altivec.h>
#include <asm/ppc-opcode.h>
#include <asm/cputable.h>
#include <asm/switch_to.h>
#include "algos.h"

typedef vector unsigned char unative_t;
#define NSIZE sizeof(unative_t)

static const vector unsigned char gf_low = {0x1e, 0x1c, 0x1a, 0x18, 0x16, 0x14,
					    0x12, 0x10, 0x0e, 0x0c, 0x0a, 0x08,
					    0x06, 0x04, 0x02,0x00};
static const vector unsigned char gf_high = {0xfd, 0xdd, 0xbd, 0x9d, 0x7d, 0x5d,
					     0x3d, 0x1d, 0xe0, 0xc0, 0xa0, 0x80,
					     0x60, 0x40, 0x20, 0x00};

static void noinline raid6_vpermxor$#_gen_syndrome_real(int disks, size_t bytes,
							void **ptrs)
{
	u8 **dptr = (u8 **)ptrs;
	u8 *p, *q;
	int d, z, z0;
	unative_t wp$$, wq$$, wd$$;

	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*$#) {
		wp$$ = wq$$ = *(unative_t *)&dptr[z0][d+$$*NSIZE];

		for (z = z0-1; z>=0; z--) {
			wd$$ = *(unative_t *)&dptr[z][d+$$*NSIZE];
			/* P syndrome */
			wp$$ = vec_xor(wp$$, wd$$);

			/* Q syndrome */
			asm(VPERMXOR(%0,%1,%2,%3):"=v"(wq$$):"v"(gf_high), "v"(gf_low), "v"(wq$$));
			wq$$ = vec_xor(wq$$, wd$$);
		}
		*(unative_t *)&p[d+NSIZE*$$] = wp$$;
		*(unative_t *)&q[d+NSIZE*$$] = wq$$;
	}
}

static void raid6_vpermxor$#_gen_syndrome(int disks, size_t bytes, void **ptrs)
{
	preempt_disable();
	enable_kernel_altivec();

	raid6_vpermxor$#_gen_syndrome_real(disks, bytes, ptrs);

	disable_kernel_altivec();
	preempt_enable();
}

const struct raid6_calls raid6_vpermxor$# = {
	.gen_syndrome	= raid6_vpermxor$#_gen_syndrome,
	.name		= "vpermxor$#",
};

Annotation

Implementation Notes