Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/ztest.c
Original file line number Diff line number Diff line change
Expand Up @@ -6413,7 +6413,7 @@ ztest_blake3(ztest_ds_t *zd, uint64_t id)
void *res2 = &zc_res2;

/* BLAKE3_KEY_LEN = 32 */
VERIFY0(blake3_set_impl_name("generic"));
VERIFY0(blake3_impl_setname("generic"));
templ = abd_checksum_blake3_tmpl_init(&salt);
Blake3_InitKeyed(&ctx, salt_ptr);
Blake3_Update(&ctx, buf, size);
Expand All @@ -6422,7 +6422,7 @@ ztest_blake3(ztest_ds_t *zd, uint64_t id)
ZIO_CHECKSUM_BSWAP(&zc_ref2);
abd_checksum_blake3_tmpl_free(templ);

VERIFY0(blake3_set_impl_name("cycle"));
VERIFY0(blake3_impl_setname("cycle"));
while (run_count-- > 0) {

/* Test current implementation */
Expand Down
1 change: 1 addition & 0 deletions include/os/freebsd/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ noinst_HEADERS = \
%D%/spl/sys/sid.h \
%D%/spl/sys/sig.h \
%D%/spl/sys/simd.h \
%D%/spl/sys/simd_powerpc.h \
%D%/spl/sys/simd_x86.h \
%D%/spl/sys/spl_condvar.h \
%D%/spl/sys/string.h \
Expand Down
7 changes: 3 additions & 4 deletions include/os/freebsd/spl/sys/mod_os.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@

#include <sys/sysctl.h>

#define EXPORT_SYMBOL(x)
#define module_param(a, b, c)
#define MODULE_PARM_DESC(a, b)

#define ZMOD_RW CTLFLAG_RWTUN
#define ZMOD_RD CTLFLAG_RDTUN

Expand Down Expand Up @@ -98,6 +94,9 @@
#define fletcher_4_param_set_args(var) \
CTLTYPE_STRING, NULL, 0, fletcher_4_param, "A"

#define blake3_param_set_args(var) \
CTLTYPE_STRING, NULL, 0, blake3_param, "A"

#include <sys/kernel.h>
#define module_init(fn) \
static void \
Expand Down
8 changes: 6 additions & 2 deletions include/os/freebsd/spl/sys/simd.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,22 @@
* $FreeBSD$
*/


#ifndef _FREEBSD_SIMD_H
#define _FREEBSD_SIMD_H

#if defined(__amd64__) || defined(__i386__)
#include <sys/simd_x86.h>
#else

#elif defined(__powerpc__)
#include <sys/simd_powerpc.h>

#else
#define kfpu_allowed() 0
#define kfpu_initialize(tsk) do {} while (0)
#define kfpu_begin() do {} while (0)
#define kfpu_end() do {} while (0)
#define kfpu_init() (0)
#define kfpu_fini() do {} while (0)
#endif

#endif
90 changes: 90 additions & 0 deletions include/os/freebsd/spl/sys/simd_powerpc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or https://opensource.org/licenses/CDDL-1.0.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/

/*
* Copyright (C) 2022 Tino Reichardt <milky-zfs@mcmilk.de>
*/

/*
* USER API:
*
* Kernel fpu methods:
* kfpu_allowed()
* kfpu_begin()
* kfpu_end()
* kfpu_init()
* kfpu_fini()
*
* SIMD support:
*
* Following functions should be called to determine whether CPU feature
* is supported. All functions are usable in kernel and user space.
* If a SIMD algorithm is using more than one instruction set
* all relevant feature test functions should be called.
*
* Supported features:
* zfs_altivec_available()
* zfs_vsx_available()
* zfs_isa207_available()
*/

#ifndef _FREEBSD_SIMD_POWERPC_H
#define _FREEBSD_SIMD_POWERPC_H

#include <sys/types.h>
#include <sys/cdefs.h>

#include <machine/pcb.h>
#include <powerpc/cpu.h>

#define kfpu_allowed() 1
#define kfpu_initialize(tsk) do {} while (0)
#define kfpu_begin() do {} while (0)
#define kfpu_end() do {} while (0)
#define kfpu_init() (0)
#define kfpu_fini() do {} while (0)

/*
* Check if Altivec is available
*/
static inline boolean_t
zfs_altivec_available(void)
{
return ((cpu_features & PPC_FEATURE_HAS_ALTIVEC) != 0);
}

/*
* Check if VSX is available
*/
static inline boolean_t
zfs_vsx_available(void)
{
return ((cpu_features & PPC_FEATURE_HAS_VSX) != 0);
}

/*
* Check if POWER ISA 2.07 is available (SHA2)
*/
static inline boolean_t
zfs_isa207_available(void)
{
return ((cpu_features2 & PPC_FEATURE2_ARCH_2_07) != 0);
}
50 changes: 25 additions & 25 deletions include/os/freebsd/spl/sys/simd_x86.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ __simd_state_enabled(const uint64_t state)
boolean_t has_osxsave;
uint64_t xcr0;

has_osxsave = !!(cpu_feature2 & CPUID2_OSXSAVE);
has_osxsave = (cpu_feature2 & CPUID2_OSXSAVE) != 0;

if (!has_osxsave)
return (B_FALSE);
Expand All @@ -99,7 +99,7 @@ __simd_state_enabled(const uint64_t state)
static inline boolean_t
zfs_sse_available(void)
{
return (!!(cpu_feature & CPUID_SSE));
return ((cpu_feature & CPUID_SSE) != 0);
}

/*
Expand All @@ -108,7 +108,7 @@ zfs_sse_available(void)
static inline boolean_t
zfs_sse2_available(void)
{
return (!!(cpu_feature & CPUID_SSE2));
return ((cpu_feature & CPUID_SSE2) != 0);
}

/*
Expand All @@ -117,7 +117,7 @@ zfs_sse2_available(void)
static inline boolean_t
zfs_sse3_available(void)
{
return (!!(cpu_feature2 & CPUID2_SSE3));
return ((cpu_feature2 & CPUID2_SSE3) != 0);
}

/*
Expand All @@ -126,7 +126,7 @@ zfs_sse3_available(void)
static inline boolean_t
zfs_ssse3_available(void)
{
return (!!(cpu_feature2 & CPUID2_SSSE3));
return ((cpu_feature2 & CPUID2_SSSE3) != 0);
}

/*
Expand All @@ -135,7 +135,7 @@ zfs_ssse3_available(void)
static inline boolean_t
zfs_sse4_1_available(void)
{
return (!!(cpu_feature2 & CPUID2_SSE41));
return ((cpu_feature2 & CPUID2_SSE41) != 0);
}

/*
Expand All @@ -144,7 +144,7 @@ zfs_sse4_1_available(void)
static inline boolean_t
zfs_sse4_2_available(void)
{
return (!!(cpu_feature2 & CPUID2_SSE42));
return ((cpu_feature2 & CPUID2_SSE42) != 0);
}

/*
Expand All @@ -155,7 +155,7 @@ zfs_avx_available(void)
{
boolean_t has_avx;

has_avx = !!(cpu_feature2 & CPUID2_AVX);
has_avx = (cpu_feature2 & CPUID2_AVX) != 0;

return (has_avx && __ymm_enabled());
}
Expand All @@ -168,7 +168,7 @@ zfs_avx2_available(void)
{
boolean_t has_avx2;

has_avx2 = !!(cpu_stdext_feature & CPUID_STDEXT_AVX2);
has_avx2 = (cpu_stdext_feature & CPUID_STDEXT_AVX2) != 0;

return (has_avx2 && __ymm_enabled());
}
Expand Down Expand Up @@ -196,7 +196,7 @@ zfs_avx512f_available(void)
{
boolean_t has_avx512;

has_avx512 = !!(cpu_stdext_feature & CPUID_STDEXT_AVX512F);
has_avx512 = (cpu_stdext_feature & CPUID_STDEXT_AVX512F) != 0;

return (has_avx512 && __zmm_enabled());
}
Expand All @@ -207,8 +207,8 @@ zfs_avx512cd_available(void)
{
boolean_t has_avx512;

has_avx512 = !!(cpu_stdext_feature & CPUID_STDEXT_AVX512F) &&
!!(cpu_stdext_feature & CPUID_STDEXT_AVX512CD);
has_avx512 = (cpu_stdext_feature & CPUID_STDEXT_AVX512F) != 0 &&
(cpu_stdext_feature & CPUID_STDEXT_AVX512CD) != 0;

return (has_avx512 && __zmm_enabled());
}
Expand All @@ -219,8 +219,8 @@ zfs_avx512er_available(void)
{
boolean_t has_avx512;

has_avx512 = !!(cpu_stdext_feature & CPUID_STDEXT_AVX512F) &&
!!(cpu_stdext_feature & CPUID_STDEXT_AVX512CD);
has_avx512 = (cpu_stdext_feature & CPUID_STDEXT_AVX512F) != 0 &&
(cpu_stdext_feature & CPUID_STDEXT_AVX512CD) != 0;

return (has_avx512 && __zmm_enabled());
}
Expand All @@ -231,8 +231,8 @@ zfs_avx512pf_available(void)
{
boolean_t has_avx512;

has_avx512 = !!(cpu_stdext_feature & CPUID_STDEXT_AVX512F) &&
!!(cpu_stdext_feature & CPUID_STDEXT_AVX512PF);
has_avx512 = (cpu_stdext_feature & CPUID_STDEXT_AVX512F) != 0 &&
(cpu_stdext_feature & CPUID_STDEXT_AVX512PF) != 0;

return (has_avx512 && __zmm_enabled());
}
Expand All @@ -243,7 +243,7 @@ zfs_avx512bw_available(void)
{
boolean_t has_avx512 = B_FALSE;

has_avx512 = !!(cpu_stdext_feature & CPUID_STDEXT_AVX512BW);
has_avx512 = (cpu_stdext_feature & CPUID_STDEXT_AVX512BW) != 0;

return (has_avx512 && __zmm_enabled());
}
Expand All @@ -254,8 +254,8 @@ zfs_avx512dq_available(void)
{
boolean_t has_avx512;

has_avx512 = !!(cpu_stdext_feature & CPUID_STDEXT_AVX512F) &&
!!(cpu_stdext_feature & CPUID_STDEXT_AVX512DQ);
has_avx512 = (cpu_stdext_feature & CPUID_STDEXT_AVX512F) != 0 &&
(cpu_stdext_feature & CPUID_STDEXT_AVX512DQ) != 0;

return (has_avx512 && __zmm_enabled());
}
Expand All @@ -266,8 +266,8 @@ zfs_avx512vl_available(void)
{
boolean_t has_avx512;

has_avx512 = !!(cpu_stdext_feature & CPUID_STDEXT_AVX512F) &&
!!(cpu_stdext_feature & CPUID_STDEXT_AVX512VL);
has_avx512 = (cpu_stdext_feature & CPUID_STDEXT_AVX512F) != 0 &&
(cpu_stdext_feature & CPUID_STDEXT_AVX512VL) != 0;

return (has_avx512 && __zmm_enabled());
}
Expand All @@ -278,8 +278,8 @@ zfs_avx512ifma_available(void)
{
boolean_t has_avx512;

has_avx512 = !!(cpu_stdext_feature & CPUID_STDEXT_AVX512F) &&
!!(cpu_stdext_feature & CPUID_STDEXT_AVX512IFMA);
has_avx512 = (cpu_stdext_feature & CPUID_STDEXT_AVX512F) != 0 &&
(cpu_stdext_feature & CPUID_STDEXT_AVX512IFMA) != 0;

return (has_avx512 && __zmm_enabled());
}
Expand All @@ -290,8 +290,8 @@ zfs_avx512vbmi_available(void)
{
boolean_t has_avx512;

has_avx512 = !!(cpu_stdext_feature & CPUID_STDEXT_AVX512F) &&
!!(cpu_stdext_feature & CPUID_STDEXT_BMI1);
has_avx512 = (cpu_stdext_feature & CPUID_STDEXT_AVX512F) != 0 &&
(cpu_stdext_feature & CPUID_STDEXT_BMI1) != 0;

return (has_avx512 && __zmm_enabled());
}
Loading