diff options
author | Zoltan Kiss <zoltan.kiss@linaro.org> | 2016-05-05 16:35:09 +0100 |
---|---|---|
committer | Mike Holmes <mike.holmes@linaro.org> | 2016-05-06 12:50:49 -0400 |
commit | 12520b241bee42f61ff062283ef23459596f4426 (patch) | |
tree | 719ef3a699ee6e081769198f0bd80e78cab5c90a /platform/linux-generic | |
parent | 1255821265c5e762367dca8b3bf74b9f9366deee (diff) |
linux-generic: pktio: don't return packet after failed enqueue
If queue_enq() fails, there is a serious internal error, the packet
should be released instead of passing it back to pktin_poll() for
enqueueing on an another one.
Also return the error if there is any, not just the queue_enq() ones.
If CoS drops the packet, doesn't report it as an error
Signed-off-by: Zoltan Kiss <zoltan.kiss@linaro.org>
Reviewed-by: Balasubramanian Manoharan <bala.manoharan@linaro.org>
Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
Diffstat (limited to 'platform/linux-generic')
-rw-r--r-- | platform/linux-generic/include/odp_packet_io_internal.h | 3 | ||||
-rw-r--r-- | platform/linux-generic/pktio/dpdk.c | 11 | ||||
-rw-r--r-- | platform/linux-generic/pktio/netmap.c | 8 | ||||
-rw-r--r-- | platform/linux-generic/pktio/pktio_common.c | 36 | ||||
-rw-r--r-- | platform/linux-generic/pktio/socket.c | 9 | ||||
-rw-r--r-- | platform/linux-generic/pktio/socket_mmap.c | 7 |
6 files changed, 47 insertions, 27 deletions
diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index de6dab6f9..7dd578b1b 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -211,8 +211,7 @@ typedef struct pktio_if_ops { } pktio_if_ops_t; int _odp_packet_cls_enq(pktio_entry_t *pktio_entry, const uint8_t *base, - uint16_t buf_len, odp_time_t *ts, - odp_packet_t *pkt_ret); + uint16_t buf_len, odp_time_t *ts); extern void *pktio_entry_ptr[]; diff --git a/platform/linux-generic/pktio/dpdk.c b/platform/linux-generic/pktio/dpdk.c index 531529745..e6af8fb9e 100644 --- a/platform/linux-generic/pktio/dpdk.c +++ b/platform/linux-generic/pktio/dpdk.c @@ -712,10 +712,13 @@ static inline int mbuf_to_pkt(pktio_entry_t *pktio_entry, pkt_len = rte_pktmbuf_pkt_len(mbuf); if (pktio_cls_enabled(pktio_entry)) { - if (_odp_packet_cls_enq(pktio_entry, - (const uint8_t *)buf, pkt_len, - ts, &pkt_table[nb_pkts])) - nb_pkts++; + int ret; + + ret = _odp_packet_cls_enq(pktio_entry, + (const uint8_t *)buf, + pkt_len, ts); + if (ret && ret != -ENOENT) + nb_pkts = ret; } else { pkt = packet_alloc(pktio_entry->s.pkt_dpdk.pool, pkt_len, 1); diff --git a/platform/linux-generic/pktio/netmap.c b/platform/linux-generic/pktio/netmap.c index 606592226..3e6a4f0ba 100644 --- a/platform/linux-generic/pktio/netmap.c +++ b/platform/linux-generic/pktio/netmap.c @@ -608,10 +608,10 @@ static inline int netmap_pkt_to_odp(pktio_entry_t *pktio_entry, if (pktio_cls_enabled(pktio_entry)) { ret = _odp_packet_cls_enq(pktio_entry, (const uint8_t *)buf, - len, ts, pkt_out); - if (ret) - return 0; - return -1; + len, ts); + if (ret && ret != -ENOENT) + return ret; + return 0; } else { odp_packet_hdr_t *pkt_hdr; diff --git a/platform/linux-generic/pktio/pktio_common.c b/platform/linux-generic/pktio/pktio_common.c index 942ea8ca5..8a01477f5 100644 --- a/platform/linux-generic/pktio/pktio_common.c +++ b/platform/linux-generic/pktio/pktio_common.c @@ -7,10 +7,27 @@ #include <odp_packet_io_internal.h> #include <odp_classification_internal.h> +#include <errno.h> +/** + * Classify packet, copy it in a odp_packet_t and enqueue to the right queue + * + * pktio_entry pktio where it arrived + * base packet data + * buf_len packet length + * + * Return values: + * 0 on success, packet is consumed + * -ENOENT CoS dropped the packet + * -EFAULT Bug + * -EINVAL Config error + * -ENOMEM Target CoS pool exhausted + * + * Note: *base is not released, only pkt if there is an error + * + */ int _odp_packet_cls_enq(pktio_entry_t *pktio_entry, - const uint8_t *base, uint16_t buf_len, - odp_time_t *ts, odp_packet_t *pkt_ret) + const uint8_t *base, uint16_t buf_len, odp_time_t *ts) { cos_t *cos; odp_packet_t pkt; @@ -25,14 +42,17 @@ int _odp_packet_cls_enq(pktio_entry_t *pktio_entry, cos = pktio_select_cos(pktio_entry, base, &src_pkt_hdr); /* if No CoS found then drop the packet */ - if (cos == NULL || cos->s.queue == NULL || cos->s.pool == NULL) - return 0; + if (cos == NULL) + return -EINVAL; + + if (cos->s.queue == NULL || cos->s.pool == NULL) + return -EFAULT; pool = cos->s.pool->s.pool_hdl; pkt = odp_packet_alloc(pool, buf_len); if (odp_unlikely(pkt == ODP_PACKET_INVALID)) - return 0; + return -ENOMEM; pkt_hdr = odp_packet_hdr(pkt); copy_packet_parser_metadata(&src_pkt_hdr, pkt_hdr); @@ -40,7 +60,7 @@ int _odp_packet_cls_enq(pktio_entry_t *pktio_entry, if (odp_packet_copy_from_mem(pkt, 0, buf_len, base) != 0) { odp_packet_free(pkt); - return 0; + return -EFAULT; } packet_set_ts(pkt_hdr, ts); @@ -49,8 +69,8 @@ int _odp_packet_cls_enq(pktio_entry_t *pktio_entry, odp_packet_pull_tail(pkt, odp_packet_len(pkt) - buf_len); ret = queue_enq(cos->s.queue, odp_buf_to_hdr((odp_buffer_t)pkt), 0); if (ret < 0) { - *pkt_ret = pkt; - return 1; + odp_packet_free(pkt); + return -EFAULT; } return 0; diff --git a/platform/linux-generic/pktio/socket.c b/platform/linux-generic/pktio/socket.c index 6f061704e..a0aa9afdd 100644 --- a/platform/linux-generic/pktio/socket.c +++ b/platform/linux-generic/pktio/socket.c @@ -659,11 +659,10 @@ static int sock_mmsg_recv(pktio_entry_t *pktio_entry, eth_hdr->h_source))) continue; - ret = _odp_packet_cls_enq(pktio_entry, base, - pkt_len, ts, - &pkt_table[nb_rx]); - if (ret) - nb_rx++; + ret = _odp_packet_cls_enq(pktio_entry, base, pkt_len, + ts); + if (ret && ret != -ENOENT) + nb_rx = ret; } } else { struct iovec iovecs[ODP_PACKET_SOCKET_MAX_BURST_RX] diff --git a/platform/linux-generic/pktio/socket_mmap.c b/platform/linux-generic/pktio/socket_mmap.c index cbd71ba47..41704569b 100644 --- a/platform/linux-generic/pktio/socket_mmap.c +++ b/platform/linux-generic/pktio/socket_mmap.c @@ -195,10 +195,9 @@ static inline unsigned pkt_mmap_v2_rx(pktio_entry_t *pktio_entry, if (pktio_cls_enabled(pktio_entry)) { ret = _odp_packet_cls_enq(pktio_entry, pkt_buf, - pkt_len, ts, - &pkt_table[nb_rx]); - if (ret) - nb_rx++; + pkt_len, ts); + if (ret && ret != -ENOENT) + nb_rx = ret; } else { odp_packet_hdr_t *hdr; |