summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuyang Huang <yuyanghuang@google.com>2023-12-12 04:03:43 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2023-12-12 04:03:43 +0000
commit5da843d7746d8caf27ca84d74e4255cf302ccc79 (patch)
treecf1d231a740ee1500e0e40b912c95f09a165ecda
parent02671b084dd06815f06fc2a6bdbc2c36333a4e69 (diff)
parent1ddea3a1908f5d005b90dde746a3db148bd290df (diff)
downloadapf-5da843d7746d8caf27ca84d74e4255cf302ccc79.tar.gz
Update allocate/transmit API parameter type am: 1ddea3a190
Original change: https://android-review.googlesource.com/c/platform/hardware/google/apf/+/2866854 Change-Id: Ibd863f3bfc93c4c903a4bb620e2f03334a3d232b Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--v5/apf_interpreter.c15
-rw-r--r--v5/apf_interpreter.h4
-rw-r--r--v5/test_buf_allocator.c6
-rw-r--r--v5/test_buf_allocator.h2
4 files changed, 13 insertions, 14 deletions
diff --git a/v5/apf_interpreter.c b/v5/apf_interpreter.c
index fb63b1b..9e9317b 100644
--- a/v5/apf_interpreter.c
+++ b/v5/apf_interpreter.c
@@ -46,7 +46,7 @@ extern void APF_TRACE_HOOK(uint32_t pc, const uint32_t* regs, const uint8_t* pro
#define ENFORCE_UNSIGNED(c) ((c)==(uint32_t)(c))
uint32_t apf_version() {
- return 20231207;
+ return 20231211;
}
int apf_run(void* ctx, uint8_t* const program, const uint32_t program_len,
@@ -101,11 +101,11 @@ int apf_run(void* ctx, uint8_t* const program, const uint32_t program_len,
// The output buffer pointer
uint8_t* allocated_buffer = NULL;
// The length of the output buffer
- int allocate_buffer_len = 0;
+ uint32_t allocated_buffer_len = 0;
// Is access to offset |p| length |size| within output buffer bounds?
#define IN_OUTPUT_BOUNDS(p, size) (ENFORCE_UNSIGNED(p) && \
ENFORCE_UNSIGNED(size) && \
- (p) + (size) <= (uint32_t) allocate_buffer_len && \
+ (p) + (size) <= allocated_buffer_len && \
(p) + (size) >= (p))
// Accept packet if not write within allocated output buffer
#define ASSERT_IN_OUTPUT_BOUNDS(p, size) ASSERT_RETURN(IN_OUTPUT_BOUNDS(p, size))
@@ -300,19 +300,18 @@ int apf_run(void* ctx, uint8_t* const program, const uint32_t program_len,
break;
case ALLOC_EXT_OPCODE:
ASSERT_RETURN(allocated_buffer == NULL);
- allocate_buffer_len = (int) REG;
+ allocated_buffer_len = REG;
allocated_buffer =
- apf_allocate_buffer(ctx, allocate_buffer_len);
+ apf_allocate_buffer(ctx, allocated_buffer_len);
ASSERT_RETURN(allocated_buffer != NULL);
memory[MEMORY_OFFSET_OUTPUT_BUFFER_OFFSET] = 0;
break;
case TRANS_EXT_OPCODE:
ASSERT_RETURN(allocated_buffer != NULL);
- int pkt_len =
- (int) memory[MEMORY_OFFSET_OUTPUT_BUFFER_OFFSET];
+ uint32_t pkt_len = memory[MEMORY_OFFSET_OUTPUT_BUFFER_OFFSET];
// If pkt_len > allocate_buffer_len, it means sth. wrong
// happened and the allocated_buffer should be deallocated.
- if (pkt_len > allocate_buffer_len) {
+ if (pkt_len > allocated_buffer_len) {
apf_transmit_buffer(
ctx,
allocated_buffer,
diff --git a/v5/apf_interpreter.h b/v5/apf_interpreter.h
index a64a68e..9954d37 100644
--- a/v5/apf_interpreter.h
+++ b/v5/apf_interpreter.h
@@ -52,7 +52,7 @@ uint32_t apf_version();
* pending transmit. Returning NULL will most likely result in the
* apf_run() returning PASS.
*/
-uint8_t* apf_allocate_buffer(void* ctx, int size);
+uint8_t* apf_allocate_buffer(void* ctx, uint32_t size);
/**
* Transmits the allocated buffer and deallocates it.
@@ -84,7 +84,7 @@ uint8_t* apf_allocate_buffer(void* ctx, int size);
* the firmware thinks the transmit will succeed. Returning an error
* will likely result in apf_run() returning PASS.
*/
-int apf_transmit_buffer(void* ctx, uint8_t* ptr, int len, uint8_t dscp);
+int apf_transmit_buffer(void* ctx, uint8_t* ptr, uint32_t len, uint8_t dscp);
/**
* Runs an APF program over a packet.
diff --git a/v5/test_buf_allocator.c b/v5/test_buf_allocator.c
index a8c789b..a889dea 100644
--- a/v5/test_buf_allocator.c
+++ b/v5/test_buf_allocator.c
@@ -21,7 +21,7 @@
uint8_t apf_test_buffer[APF_TX_BUFFER_SIZE];
uint8_t apf_test_tx_packet[APF_TX_BUFFER_SIZE];
-int apf_test_tx_packet_len;
+uint32_t apf_test_tx_packet_len;
uint8_t apf_test_tx_dscp;
/**
@@ -29,7 +29,7 @@ uint8_t apf_test_tx_dscp;
*
* Clean up the apf_test_buffer and return the pointer to beginning of the buffer region.
*/
-uint8_t* apf_allocate_buffer(__attribute__ ((unused)) void* ctx, int size) {
+uint8_t* apf_allocate_buffer(__attribute__ ((unused)) void* ctx, uint32_t size) {
if (size > APF_TX_BUFFER_SIZE) {
return NULL;
}
@@ -43,7 +43,7 @@ uint8_t* apf_allocate_buffer(__attribute__ ((unused)) void* ctx, int size) {
* Copy the content of allocated buffer to the apf_test_tx_packet region.
*/
int apf_transmit_buffer(__attribute__((unused)) void* ctx, uint8_t* ptr,
- int len, uint8_t dscp) {
+ uint32_t len, uint8_t dscp) {
apf_test_tx_packet_len = len;
apf_test_tx_dscp = dscp;
memcpy(apf_test_tx_packet, ptr, (size_t) len);
diff --git a/v5/test_buf_allocator.h b/v5/test_buf_allocator.h
index 287c8bc..3916cf8 100644
--- a/v5/test_buf_allocator.h
+++ b/v5/test_buf_allocator.h
@@ -23,7 +23,7 @@
extern uint8_t apf_test_buffer[APF_TX_BUFFER_SIZE];
extern uint8_t apf_test_tx_packet[APF_TX_BUFFER_SIZE];
-extern int apf_test_tx_packet_len;
+extern uint32_t apf_test_tx_packet_len;
extern uint8_t apf_test_tx_dscp;
#endif // TEST_BUF_ALLOCATOR