@@ -169,7 +169,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_packet_t *pkt_ret);
+ uint16_t buf_len);
extern void *pktio_entry_ptr[];
@@ -9,8 +9,7 @@
#include <odp_classification_internal.h>
int _odp_packet_cls_enq(pktio_entry_t *pktio_entry,
- const uint8_t *base, uint16_t buf_len,
- odp_packet_t *pkt_ret)
+ const uint8_t *base, uint16_t buf_len)
{
cos_t *cos;
odp_packet_t pkt;
@@ -25,28 +24,28 @@ int _odp_packet_cls_enq(pktio_entry_t *pktio_entry,
/* if No CoS found then drop the packet */
if (cos == NULL || cos->s.queue == NULL || cos->s.pool == NULL)
- return 0;
+ return -1;
pool = cos->s.pool->s.pool_hdl;
pkt = odp_packet_alloc(pool, buf_len);
if (odp_unlikely(pkt == ODP_PACKET_INVALID))
- return 0;
+ return -1;
copy_packet_parser_metadata(&pkt_hdr, odp_packet_hdr(pkt));
odp_packet_hdr(pkt)->input = pktio_entry->s.handle;
if (odp_packet_copydata_in(pkt, 0, buf_len, base) != 0) {
odp_packet_free(pkt);
- return 0;
+ return -1;
}
/* Parse and set packet header data */
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 -1;
}
return 0;
@@ -649,10 +649,9 @@ 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, &pkt_table[nb_rx]);
+ ret = _odp_packet_cls_enq(pktio_entry, base, pkt_len);
if (ret)
- nb_rx++;
+ nb_rx = -1;
}
} else {
struct iovec iovecs[ODP_PACKET_SOCKET_MAX_BURST_RX]
@@ -149,9 +149,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, &pkt_table[nb_rx]);
+ pkt_len);
if (ret)
- nb_rx++;
+ nb_rx = -1;
} else {
odp_packet_hdr_t *hdr;
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. Signed-off-by: Zoltan Kiss <zoltan.kiss@linaro.org> --- platform/linux-generic/include/odp_packet_io_internal.h | 2 +- platform/linux-generic/pktio/pktio_common.c | 13 ++++++------- platform/linux-generic/pktio/socket.c | 5 ++--- platform/linux-generic/pktio/socket_mmap.c | 4 ++-- 4 files changed, 11 insertions(+), 13 deletions(-)