Skip to content

Commit

Permalink
linux-gen: dpdk: implement don't free option
Browse files Browse the repository at this point in the history
Implemented packet output don't free option for DPDK packet IO.
Option is available only when not using zero copy mode.

Signed-off-by: Petri Savolainen <petri.savolainen@nokia.com>
Reviewed-by: Matias Elo <matias.elo@nokia.com>
  • Loading branch information
psavol committed Sep 14, 2023
1 parent 2867a30 commit 014e609
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
1 change: 0 additions & 1 deletion platform/linux-generic/odp_packet_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -1600,7 +1600,6 @@ int odp_pktio_capability(odp_pktio_t pktio, odp_pktio_capability_t *capa)
capa->tx_compl.queue_type_sched = 1;
capa->tx_compl.queue_type_plain = 1;
capa->tx_compl.max_compl_id = UINT32_MAX - 1;
capa->free_ctrl.dont_free = 0;

capa->config.pktout.bit.aging_ena = 1;
capa->max_tx_aging_tmo_ns = MAX_TX_AGING_TMO_NS;
Expand Down
30 changes: 27 additions & 3 deletions platform/linux-generic/pktio/dpdk.c
Original file line number Diff line number Diff line change
Expand Up @@ -1821,6 +1821,7 @@ static int dpdk_init_capability(pktio_entry_t *pktio_entry,
capa->tx_compl.mode_all = 1;
capa->tx_compl.mode_event = 1;
capa->tx_compl.mode_poll = 1;
capa->free_ctrl.dont_free = 1;
}

/* Copy for fast path access */
Expand Down Expand Up @@ -2258,13 +2259,36 @@ static int dpdk_send(pktio_entry_t *pktio_entry, int index,
}
}
} else {
int i;
int first = tx_pkts;

if (odp_unlikely(tx_pkts < mbufs)) {
for (uint16_t i = tx_pkts; i < mbufs; i++)
for (i = tx_pkts; i < mbufs; i++)
rte_pktmbuf_free(tx_mbufs[i]);
}

if (odp_likely(tx_pkts))
odp_packet_free_multi(pkt_table, tx_pkts);
if (odp_unlikely(tx_pkts == 0))
return 0;

/* Find the first packet with (possible) don't free flag */
for (i = 0; i < tx_pkts; i++) {
if (odp_packet_free_ctrl(pkt_table[i]) == ODP_PACKET_FREE_CTRL_DONT_FREE) {
first = i;
break;
}
}

/* Free first N packets that don't have the flag */
if (odp_likely(first > 0))
odp_packet_free_multi(pkt_table, first);

/* Free rest of the packets (according to the flag) */
for (i = first; i < tx_pkts; i++) {
if (odp_packet_free_ctrl(pkt_table[i]) == ODP_PACKET_FREE_CTRL_DONT_FREE)
continue;

odp_packet_free(pkt_table[i]);
}
}

return tx_pkts;
Expand Down

0 comments on commit 014e609

Please sign in to comment.