################################################################
# This file is provided under a dual BSD/GPLv2 license.  When using or
#   redistributing this file, you may do so under either license.
# 
#   GPL LICENSE SUMMARY
# 
#   Copyright(c) 2007-2022 Intel Corporation. All rights reserved.
# 
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of version 2 of the GNU General Public License as
#   published by the Free Software Foundation.
# 
#   This program is distributed in the hope that it will be useful, but
#   WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
#   General Public License for more details.
# 
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
#   The full GNU General Public License is included in this distribution
#   in the file called LICENSE.GPL.
# 
#   Contact Information:
#   Intel Corporation
# 
#   BSD LICENSE
# 
#   Copyright(c) 2007-2022 Intel Corporation. All rights reserved.
#   All rights reserved.
# 
#   Redistribution and use in source and binary forms, with or without
#   modification, are permitted provided that the following conditions
#   are met:
# 
#     * Redistributions of source code must retain the above copyright
#       notice, this list of conditions and the following disclaimer.
#     * Redistributions in binary form must reproduce the above copyright
#       notice, this list of conditions and the following disclaimer in
#       the documentation and/or other materials provided with the
#       distribution.
#     * Neither the name of Intel Corporation nor the names of its
#       contributors may be used to endorse or promote products derived
#       from this software without specific prior written permission.
# 
#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
#   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
#   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
#   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
#   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
#   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
#   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
#   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
#   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
#   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
#   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# 
# 
#  version: QAT.B.3.12.0-00004
################################################################
.PATH: ${.CURDIR}
NO_OBJ?=1
DO_CRYPTO=0
ICP_DC_ONLY=1

ICP_ROOT?=$(.CURDIR)/../../../../../../
ICP_API_DIR?=$(ICP_ROOT)/quickassist/include/
ICP_LAC_DIR?=$(ICP_ROOT)/quickassist/lookaside/access_layer/
SAMPLE_PATH?=$(ICP_ROOT)/quickassist/lookaside/access_layer/src/sample_code/performance/
ICP_BUILDSYSTEM_PATH?=$(ICP_ROOT)/quickassist/build_system

ICP_OS?=freebsd
ICP_OS_LEVEL?=kernel_space

OUTPUT_NAME=cpa_sample_code

SOURCES+=	framework/freebsd/kernel_space/cpa_sample_code_utils.c \
	framework/freebsd/kernel_space/cpa_sample_code_module.c \
	framework/cpa_sample_code_framework.c \
	cpa_sample_code_main.c \
	../busy_loop/busy_loop.c \
	qae/freebsd/kernel_space/qae_mem_utils.c \
	qae/freebsd/kernel_space/qae_mem_contig_cache.c \

SOURCES+=	common/qat_perf_buffer_utils.c \
	compression/cpa_sample_code_dc_utils.c \
	compression/cpa_sample_code_dc_dp.c \
	compression/cpa_sample_code_zlib.c \
	common/qat_perf_latency.c \
	common/qat_perf_sleeptime.c \
	common/qat_perf_utils.c \
	compression/qat_compression_main.c \
	compression/qat_compression_utils.c \
	compression/qat_compression_e2e.c \
	compression/qat_dc_update_session.c

.ifdef(DO_CRYPTO)
.if $(DO_CRYPTO)==1
SOURCES+=  crypto/cpa_sample_code_sym_perf_dp.c \
	crypto/cpa_sample_code_crypto_utils.c \
	crypto/cpa_sample_code_sym_perf.c \
	crypto/cpa_sample_code_rsa_perf.c \
	crypto/cpa_sample_code_dsa_perf.c \
	crypto/cpa_sample_code_ecdsa_perf.c \
	crypto/cpa_sample_code_dh_perf.c \
	crypto/qat_sym_main.c \
	crypto/qat_sym_utils.c \
	crypto/cpa_sample_code_sym_update_common.c \
	crypto/cpa_sample_code_sym_update.c \
	crypto/cpa_sample_code_sym_update_dp.c \
	crypto/cpa_sample_code_hkdf_perf.c \
	crypto/cpa_sample_code_hkdf_vectors.c
.endif
.endif

SOURCES+=device_if.h bus_if.h pci_if.h vnode_if.h
CLEANFILES+=device_if.h bus_if.h pci_if.h vnode_if.h

CFLAGS+= -I$(ICP_API_DIR) \
	-I$(ICP_API_DIR)lac \
	-I$(ICP_API_DIR)dc \
	-I$(ICP_LAC_DIR)include \
	-I$(SAMPLE_PATH)framework \
	-I$(SAMPLE_PATH)framework/freebsd/kernel_space \
	-I$(SAMPLE_PATH)common/ \
	-I$(SAMPLE_PATH)compression/ \
	-I$(SAMPLE_PATH)qae \
	-I$(SAMPLE_PATH)qae/freebsd/kernel_space \
	-I$(SAMPLE_PATH)crypto \
	-I$(SAMPLE_PATH)../busy_loop/ \
	-I${SYSDIR}/compat/linuxkpi/common/include


# Limit max threads in kernel space for boards with small amount of memory
MEM_SIZE != sysctl -hn hw.physmem
.if $(MEM_SIZE) < 8589934592
CFLAGS+= -DMAX_KERNEL_THREAD_VARIATION=100
.endif

CFLAGS+= -DKERNEL_SPACE -O0

CWARNFLAGS += -Wno-missing-prototypes

DEBUG_FLAGS= -g
CLEANFILES+=*.o *.ko.* .depend.*

all: module

CFLAGS+= -DSC_ENABLE_DYNAMIC_COMPRESSION -DINCLUDE_COMPRESSION -DSC_EPOLL_DISABLED

#include your $(ICP_OS)_$(ICP_OS_LEVEL).mk file
.include "$(ICP_ENV_DIR)/$(ICP_OS)_$(ICP_OS_LEVEL).mk"
#include the freeBSD compile rules
.include "$(ICP_BUILDSYSTEM_PATH)/build_files/freeBSDrules.mk"

