diff options
author | Matias Elo <matias.elo@nokia.com> | 2020-10-14 10:32:06 +0300 |
---|---|---|
committer | Matias Elo <matias.elo@nokia.com> | 2021-02-08 09:31:17 +0200 |
commit | 92dd2794c6854d572dfd7cc760b8e09f4a3ef0e9 (patch) | |
tree | efbf846e09de3ef25fd6993ce1942751d5b74ebb /platform/linux-generic | |
parent | a167edffba725e80fee6169eca6d3d458cb9bb90 (diff) |
linux-gen: pktio: implement odp_pktio_maxlen_set()
Add implementation for the new odp_pktio_maxlen_set() function.
Signed-off-by: Matias Elo <matias.elo@nokia.com>
Reviewed-by: Petri Savolainen <petri.savolainen@nokia.com>
Diffstat (limited to 'platform/linux-generic')
-rw-r--r-- | platform/linux-generic/include/odp_packet_io_internal.h | 2 | ||||
-rw-r--r-- | platform/linux-generic/odp_packet_io.c | 68 |
2 files changed, 69 insertions, 1 deletions
diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index e184fabbc..c6b916240 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -205,6 +205,8 @@ typedef struct pktio_if_ops { int (*send)(pktio_entry_t *entry, int index, const odp_packet_t packets[], int num); uint32_t (*maxlen_get)(pktio_entry_t *pktio_entry); + int (*maxlen_set)(pktio_entry_t *pktio_entry, uint32_t maxlen_input, + uint32_t maxlen_output); int (*promisc_mode_set)(pktio_entry_t *pktio_entry, int enable); int (*promisc_mode_get)(pktio_entry_t *pktio_entry); int (*mac_get)(pktio_entry_t *pktio_entry, void *mac_addr); diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index b9f7acb8f..846db868c 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -1,5 +1,5 @@ /* Copyright (c) 2013-2018, Linaro Limited - * Copyright (c) 2019-2020, Nokia + * Copyright (c) 2019-2021, Nokia * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -1287,6 +1287,72 @@ uint32_t odp_pktout_maxlen(odp_pktio_t pktio) return pktio_maxlen(pktio); } +int odp_pktio_maxlen_set(odp_pktio_t hdl, uint32_t maxlen_input, + uint32_t maxlen_output) +{ + odp_pktio_capability_t capa; + pktio_entry_t *entry; + int ret = 0; + + entry = get_pktio_entry(hdl); + if (entry == NULL) { + ODP_ERR("Pktio entry %d does not exist\n", hdl); + return -1; + } + + ret = odp_pktio_capability(hdl, &capa); + if (ret) { + ODP_ERR("Reading pktio capability failed\n"); + goto fail; + } + + lock_entry(entry); + + if (odp_unlikely(is_free(entry))) { + ODP_ERR("Pktio already freed\n"); + ret = -1; + goto fail; + } + if (entry->s.state == PKTIO_STATE_STARTED) { + ODP_ERR("Pktio not stopped\n"); + ret = -1; + goto fail; + } + + if (capa.set_op.op.maxlen == 0) { + ODP_ERR("Setting maximum frame length not supported\n"); + ret = -1; + goto fail; + } + + if (capa.maxlen.equal && (maxlen_input != maxlen_output)) { + ODP_ERR("Max input and output lengths don't match\n"); + ret = -1; + goto fail; + } + + if (maxlen_input < capa.maxlen.min_input || + maxlen_input > capa.maxlen.max_input) { + ODP_ERR("Invalid max input length value: %" PRIu32 "\n", maxlen_input); + ret = -1; + goto fail; + } + + if (maxlen_output < capa.maxlen.min_output || + maxlen_output > capa.maxlen.max_output) { + ODP_ERR("Invalid max output length value: %" PRIu32 "\n", maxlen_output); + ret = -1; + goto fail; + } + + if (entry->s.ops->maxlen_set) + ret = entry->s.ops->maxlen_set(entry, maxlen_input, maxlen_output); + +fail: + unlock_entry(entry); + return ret; +} + int odp_pktio_promisc_mode_set(odp_pktio_t hdl, odp_bool_t enable) { pktio_entry_t *entry; |