Skip to content

Master #316

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
9 changes: 9 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,11 @@ AC_ARG_ENABLE(qat_hw_kpt,
[Enable QAT HW Key Protection technology(KPT) support]))
AC_SUBST(enable_qat_hw_kpt)

AC_ARG_WITH(fstack_dir,
AS_HELP_STRING([--with-fstack_dir],
[Path to where the F-stack libraries are installed to.]))
AC_SUBST(with_fstack_dir)

#Default library name is qatengine
AC_SUBST([LIBQATNAME], "qatengine")

Expand Down Expand Up @@ -650,6 +655,10 @@ then
fi

#Enable additional QAT_HW & QAT_SW flags

AS_IF([test "x$with_fstack_dir" != "x"],
[cflags_common="${cflags_common} -DFSTACK -I\$(with_fstack_dir)/lib"; AC_MSG_NOTICE([FSTACK enabled])])

AS_IF([test "x$enable_qat_debug" = "xyes"],
[cflags_common="${cflags_common} -DQAT_DEBUG"; AC_MSG_NOTICE([Debug messages enabled])])

Expand Down
63 changes: 48 additions & 15 deletions qat_events.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#ifndef __FreeBSD__
#if defined(FSTACK)
# include <ff_api.h>
#elif defined(__FreeBSD__)
# include <sys/epoll.h>
# include <sys/eventfd.h>
#else
Expand Down Expand Up @@ -99,10 +101,17 @@ static void qat_fd_cleanup(ASYNC_WAIT_CTX *ctx, const void *key,
return;
}
#endif
#ifndef FSTACK
if (close(readfd) != 0) {
WARN("Failed to close readfd: %d - error: %d\n", readfd, errno);
QATerr(QAT_F_QAT_FD_CLEANUP, QAT_R_CLOSE_READFD_FAILURE);
}
#else
if (ff_close(readfd) != 0) {
WARN("Failed to close readfd: %d - error: %d\n", readfd, errno);
QATerr(QAT_F_QAT_FD_CLEANUP, QAT_R_CLOSE_READFD_FAILURE);
}
#endif
}

int qat_setup_async_event_notification(volatile ASYNC_JOB *job)
Expand All @@ -115,7 +124,7 @@ int qat_setup_async_event_notification(volatile ASYNC_JOB *job)
OSSL_ASYNC_FD efd;
void *custom = NULL;

#ifdef __FreeBSD__
#if defined(__FreeBSD__) || defined(FSTACK)
struct kevent event;
#endif

Expand Down Expand Up @@ -146,7 +155,20 @@ int qat_setup_async_event_notification(volatile ASYNC_JOB *job)
close(efd);
return 0;
}

#elif defined(FSTACK)
efd = ff_kqueue();
if (efd == -1) {
WARN("Failed to get kqueue fd = %d\n", errno);
return 0;
}
/* Initialize the event */
EV_SET(&event, QAT_EVENT_NUM, EVFILT_USER, EV_ADD | EV_CLEAR, NOTE_WRITE,
0, NULL);
if (ff_kevent(efd, &event, QAT_EVENT_NUM, NULL, 0, NULL) == -1) {
WARN("Failed to register event for the fd = %d\n", efd);
ff_close(efd);
return 0;
}
#else
efd = eventfd(0, EFD_NONBLOCK);
if (efd == -1) {
Expand Down Expand Up @@ -231,7 +253,7 @@ int qat_pause_job(volatile ASYNC_JOB *job, int jobStatus)
#endif
OSSL_ASYNC_FD readfd;
void *custom = NULL;
#ifdef __FreeBSD__
#if defined(__FreeBSD__) || defined(FSTACK)
struct kevent event;
#else
uint64_t buf = 0;
Expand Down Expand Up @@ -261,20 +283,26 @@ int qat_pause_job(volatile ASYNC_JOB *job, int jobStatus)
#endif
if ((ret = ASYNC_WAIT_CTX_get_fd(waitctx, engine_qat_id, &readfd,
&custom)) > 0) {
#ifndef __FreeBSD__
if (read(readfd, &buf, sizeof(uint64_t)) == -1) {
if (errno != EAGAIN) {
WARN("Failed to read from fd: %d - error: %d\n", readfd, errno);
}
#if defined(FSTACK)
if (ff_kevent(readfd, NULL, 0, &event, QAT_EVENT_NUM, NULL) == -1) {
WARN("Failed to get event from fd: %d - error: %d\n", readfd, errno);
/* Not resumed by the expected qat_wake_job() */
return QAT_JOB_RESUMED_UNEXPECTEDLY;
}
#else
#elif defined(__FreeBSD__)
if (kevent(readfd, NULL, 0, &event, QAT_EVENT_NUM, NULL) == -1) {
WARN("Failed to get event from fd: %d - error: %d\n", readfd, errno);
/* Not resumed by the expected qat_wake_job() */
return QAT_JOB_RESUMED_UNEXPECTEDLY;
}
#else
if (read(readfd, &buf, sizeof(uint64_t)) == -1) {
if (errno != EAGAIN) {
WARN("Failed to read from fd: %d - error: %d\n", readfd, errno);
}
/* Not resumed by the expected qat_wake_job() */
return QAT_JOB_RESUMED_UNEXPECTEDLY;
}
#endif
}
return ret;
Expand All @@ -290,7 +318,7 @@ int qat_wake_job(volatile ASYNC_JOB *job, int jobStatus)
#endif
OSSL_ASYNC_FD efd;
void *custom = NULL;
#ifdef __FreeBSD__
#if defined(__FreeBSD__) || defined(FSTACK)
struct kevent event;
#else
/* Arbitrary value '1' to write down the pipe to trigger event */
Expand Down Expand Up @@ -319,15 +347,20 @@ int qat_wake_job(volatile ASYNC_JOB *job, int jobStatus)

if ((ret = ASYNC_WAIT_CTX_get_fd(waitctx, engine_qat_id, &efd,
&custom)) > 0) {
#ifndef __FreeBSD__
if (write(efd, &buf, sizeof(uint64_t)) == -1) {
WARN("Failed to write to fd: %d - error: %d\n", efd, errno);
#if defined(FSTACK)
EV_SET(&event, QAT_EVENT_NUM, EVFILT_USER, EV_ADD, NOTE_TRIGGER, 0, NULL);
if (ff_kevent(efd, &event, QAT_EVENT_NUM, NULL, 0, NULL) == -1) {
WARN("Failed to trigger event to fd: %d - error: %d\n", efd, errno);
}
#else
#elif defined(__FreeBSD__)
EV_SET(&event, QAT_EVENT_NUM, EVFILT_USER, EV_ADD, NOTE_TRIGGER, 0, NULL);
if (kevent(efd, &event, QAT_EVENT_NUM, NULL, 0, NULL) == -1) {
WARN("Failed to trigger event to fd: %d - error: %d\n", efd, errno);
}
#else
if (write(efd, &buf, sizeof(uint64_t)) == -1) {
WARN("Failed to write to fd: %d - error: %d\n", efd, errno);
}
#endif
}
return ret;
Expand Down
2 changes: 1 addition & 1 deletion qat_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
# define ASYNC_STATUS_EAGAIN 3
#endif

#ifdef __FreeBSD__
#if defined(__FreeBSD__) || defined(FSTACK)
# define QAT_EVENT_NUM 1
#endif

Expand Down