Skip to content
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

[PATCH v3] abi: dma: increase default transfer ID size #1942

Merged
merged 2 commits into from
Nov 1, 2023
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
2 changes: 1 addition & 1 deletion include/odp/api/abi-default/dma_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ typedef _odp_abi_dma_t *odp_dma_compl_t;

#define ODP_DMA_COMPL_INVALID ((odp_dma_compl_t)0)

typedef uint32_t odp_dma_transfer_id_t;
typedef uint64_t odp_dma_transfer_id_t;

#define ODP_DMA_TRANSFER_ID_INVALID ((odp_dma_transfer_id_t)0)

Expand Down
28 changes: 15 additions & 13 deletions platform/linux-generic/odp_dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <odp/api/queue.h>

#include <odp/api/plat/std_inlines.h>
#include <odp/api/plat/strong_types.h>

#include <odp_global_data.h>
#include <odp_debug_internal.h>
Expand All @@ -31,6 +32,8 @@
#define MAX_SEGS 16
#define MAX_SEG_LEN (128 * 1024)

ODP_STATIC_ASSERT(MAX_TRANSFERS < UINT32_MAX, "Too many inflight transfers");

typedef struct segment_t {
void *addr;
uint32_t len;
Expand Down Expand Up @@ -597,6 +600,7 @@ int odp_dma_transfer_start(odp_dma_t dma, const odp_dma_transfer_param_t *transf
{
int ret;
dma_session_t *session = dma_session_from_handle(dma);
const uint32_t transfer_id = compl->transfer_id;

if (odp_unlikely(dma == ODP_DMA_INVALID)) {
_ODP_ERR("Bad DMA handle\n");
Expand All @@ -608,9 +612,8 @@ int odp_dma_transfer_start(odp_dma_t dma, const odp_dma_transfer_param_t *transf
case ODP_DMA_COMPL_NONE:
break;
case ODP_DMA_COMPL_POLL:
if (compl->transfer_id == ODP_DMA_TRANSFER_ID_INVALID ||
compl->transfer_id > MAX_TRANSFERS) {
_ODP_ERR("Bad transfer ID: %u\n", compl->transfer_id);
if (transfer_id == ODP_DMA_TRANSFER_ID_INVALID || transfer_id > MAX_TRANSFERS) {
_ODP_ERR("Bad transfer ID: %u\n", transfer_id);
return -1;
}
break;
Expand All @@ -632,7 +635,7 @@ int odp_dma_transfer_start(odp_dma_t dma, const odp_dma_transfer_param_t *transf
return ret;

if (compl->compl_mode == ODP_DMA_COMPL_POLL) {
uint32_t index = index_from_transfer_id(compl->transfer_id);
uint32_t index = index_from_transfer_id(transfer_id);

session->result[index].user_ptr = compl->user_ptr;

Expand Down Expand Up @@ -687,20 +690,20 @@ int odp_dma_transfer_done(odp_dma_t dma, odp_dma_transfer_id_t transfer_id,
odp_dma_result_t *result)
{
dma_session_t *session = dma_session_from_handle(dma);
const uint32_t id = transfer_id;

if (odp_unlikely(dma == ODP_DMA_INVALID)) {
_ODP_ERR("Bad DMA handle\n");
return -1;
}

if (odp_unlikely(transfer_id == ODP_DMA_TRANSFER_ID_INVALID ||
transfer_id > MAX_TRANSFERS)) {
_ODP_ERR("Bad transfer ID: %u\n", transfer_id);
if (odp_unlikely(id == ODP_DMA_TRANSFER_ID_INVALID || id > MAX_TRANSFERS)) {
_ODP_ERR("Bad transfer ID: %u\n", id);
return -1;
}

if (result) {
uint32_t index = index_from_transfer_id(transfer_id);
uint32_t index = index_from_transfer_id(id);

result->success = 1;
result->user_ptr = session->result[index].user_ptr;
Expand Down Expand Up @@ -756,12 +759,12 @@ odp_pool_t odp_dma_pool_create(const char *name, const odp_dma_pool_param_t *dma

uint64_t odp_dma_to_u64(odp_dma_t dma)
{
return (uint64_t)(uintptr_t)dma;
return _odp_pri(dma);
}

uint64_t odp_dma_compl_to_u64(odp_dma_compl_t dma_compl)
{
return (uint64_t)(uintptr_t)dma_compl;
return _odp_pri(dma_compl);
}

void odp_dma_print(odp_dma_t dma)
Expand Down Expand Up @@ -794,12 +797,11 @@ void odp_dma_compl_print(odp_dma_compl_t dma_compl)

_ODP_PRINT("\nDMA completion\n");
_ODP_PRINT("--------------\n");
_ODP_PRINT(" Compl event handle: 0x%" PRIx64 "\n", (uint64_t)(uintptr_t)dma_compl);
_ODP_PRINT(" Compl event handle: 0x%" PRIx64 "\n", _odp_pri(dma_compl));

if (ret == 0) {
_ODP_PRINT(" Result: %s\n", result.success ? "success" : "fail");
_ODP_PRINT(" User pointer: 0x%" PRIx64 "\n",
(uint64_t)(uintptr_t)result.user_ptr);
_ODP_PRINT(" User pointer: 0x%" PRIx64 "\n", _odp_pri(result.user_ptr));
} else {
_ODP_PRINT(" No result metadata\n");
}
Expand Down