Skip to content
Merged
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: 5 additions & 4 deletions include/dpusm/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ typedef enum {
DPUSM_OPTIONAL_COPY_TO_PTR = 1 << 1,
DPUSM_OPTIONAL_COPY_FROM_SCATTERLIST = 1 << 2,
DPUSM_OPTIONAL_COPY_TO_SCATTERLIST = 1 << 3,
DPUSM_OPTIONAL_MEM_STATS = 1 << 4,
DPUSM_OPTIONAL_ZERO_FILL = 1 << 5,
DPUSM_OPTIONAL_ALL_ZEROS = 1 << 6,
DPUSM_OPTIONAL_ASSOCIATE_HANDLE = 1 << 4,
DPUSM_OPTIONAL_MEM_STATS = 1 << 5,
DPUSM_OPTIONAL_ZERO_FILL = 1 << 6,
DPUSM_OPTIONAL_ALL_ZEROS = 1 << 7,

DPUSM_OPTIONAL_MAX = 1 << 7,
DPUSM_OPTIONAL_MAX = 1 << 8,
} dpusm_optional_t;

extern const char *DPUSM_OPTIONAL_STR[];
Expand Down
3 changes: 3 additions & 0 deletions include/dpusm/provider_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ typedef struct dpusm_provider_functions {
/* free an offloader handle */
int (*free)(void *handle);

/* associate a pointer with a pre-existing handle */
int (*associate_handle)(void *handle, void *ptr);

struct {
/* memory -> offloader */
struct {
Expand Down
3 changes: 3 additions & 0 deletions include/dpusm/user_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ typedef struct dpusm_user_functions {
/* free a handle */
int (*free)(void *handle);

/* associate a pointer with a pre-existing handle */
int (*associate_handle)(void *handle, void *ptr);

struct {
/* memory -> offloader */
struct {
Expand Down
1 change: 1 addition & 0 deletions src/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const char *DPUSM_OPTIONAL_STR[] = {
"copy_to_ptr",
"copy_from_scatterlist",
"copy_to_scatterlist",
"associate_handle",
"mem_stats",
"zero_fill",
"all_zeros",
Expand Down
5 changes: 5 additions & 0 deletions src/provider.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ dpusmph_init(struct module *module, const dpusm_pf_t *funcs)
print_supported(name, enum2str(DPUSM_OPTIONAL_STR, DPUSM_OPTIONAL_COPY_TO_SCATTERLIST));
}

if (funcs->associate_handle) {
dpusmph->capabilities.optional |= DPUSM_OPTIONAL_ASSOCIATE_HANDLE;
print_supported(name, enum2str(DPUSM_OPTIONAL_STR, DPUSM_OPTIONAL_ASSOCIATE_HANDLE));
}

if (funcs->mem_stats) {
dpusmph->capabilities.optional |= DPUSM_OPTIONAL_MEM_STATS;
print_supported(name, enum2str(DPUSM_OPTIONAL_STR, DPUSM_OPTIONAL_MEM_STATS));
Expand Down
92 changes: 51 additions & 41 deletions src/user.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,15 @@ dpusm_free(void *handle) {
return rc;
}

static int
dpusm_associate_handle(void *handle, void *ptr) {
CHECK_HANDLE(handle, dpusmh, DPUSM_ERROR);
if (!FUNCS(dpusmh->provider)->associate_handle) {
return (DPUSM_NOT_IMPLEMENTED);
}
return (FUNCS(dpusmh->provider)->associate_handle(dpusmh->handle, ptr));
}

static int
dpusm_copy_from_generic(dpusm_mv_t *mv, const void *buf, size_t size) {
if (!mv || !buf) {
Expand Down Expand Up @@ -677,54 +686,55 @@ dpusm_disk_close(void *disk) {
}

static const dpusm_uf_t user_functions = {
.get = dpusm_get_provider,
.get_name = dpusm_get_provider_name,
.put = dpusm_put_provider,
.extract = dpusm_extract_provider,
.capabilities = dpusm_get_capabilities,
.alloc = dpusm_alloc,
.alloc_ref = dpusm_alloc_ref,
.get_size = dpusm_get_size,
.free = dpusm_free,
.copy = {
.from = {
.get = dpusm_get_provider,
.get_name = dpusm_get_provider_name,
.put = dpusm_put_provider,
.extract = dpusm_extract_provider,
.capabilities = dpusm_get_capabilities,
.alloc = dpusm_alloc,
.alloc_ref = dpusm_alloc_ref,
.get_size = dpusm_get_size,
.free = dpusm_free,
.associate_handle = dpusm_associate_handle,
.copy = {
.from = {
.generic = dpusm_copy_from_generic,
.ptr = dpusm_copy_from_ptr,
.scatterlist = dpusm_copy_from_scatterlist,
},
.to = {
},
.to = {
.generic = dpusm_copy_to_generic,
.ptr = dpusm_copy_to_ptr,
.scatterlist = dpusm_copy_to_scatterlist,
},
},
.mem_stats = dpusm_provider_mem_stats,
.zero_fill = dpusm_zero_fill,
.all_zeros = dpusm_all_zeros,
.compress = dpusm_compress,
.decompress = dpusm_decompress,
.checksum = dpusm_checksum,
.raid = {
.can_compute = dpusm_raid_can_compute,
.alloc = dpusm_raid_alloc,
.set_column = dpusm_raid_set_column,
.free = dpusm_raid_free,
.gen = dpusm_raid_gen,
.cmp = dpusm_raid_cmp,
.rec = dpusm_raid_rec,
},
.file = {
.open = dpusm_file_open,
.write = dpusm_file_write,
.close = dpusm_file_close,
},
.disk = {
.open = dpusm_disk_open,
.invalidate = dpusm_disk_invalidate,
.write = dpusm_disk_write,
.flush = dpusm_disk_flush,
.close = dpusm_disk_close,
},
},
.mem_stats = dpusm_provider_mem_stats,
.zero_fill = dpusm_zero_fill,
.all_zeros = dpusm_all_zeros,
.compress = dpusm_compress,
.decompress = dpusm_decompress,
.checksum = dpusm_checksum,
.raid = {
.can_compute = dpusm_raid_can_compute,
.alloc = dpusm_raid_alloc,
.set_column = dpusm_raid_set_column,
.free = dpusm_raid_free,
.gen = dpusm_raid_gen,
.cmp = dpusm_raid_cmp,
.rec = dpusm_raid_rec,
},
.file = {
.open = dpusm_file_open,
.write = dpusm_file_write,
.close = dpusm_file_close,
},
.disk = {
.open = dpusm_disk_open,
.invalidate = dpusm_disk_invalidate,
.write = dpusm_disk_write,
.flush = dpusm_disk_flush,
.close = dpusm_disk_close,
},
};

const dpusm_uf_t *
Expand Down
Loading