From: Petri Savolainen <petri.savolai...@linaro.org>

Added interface level flag to optimize checksum insertion
checks. If checksum insertion has not been enabled, further
configuration or packet level checks are not performed.

Signed-off-by: Petri Savolainen <petri.savolai...@linaro.org>
---
/** Email created from pull request 313 (psavol:next-pktout-config)
 ** https://github.com/Linaro/odp/pull/313
 ** Patch: https://github.com/Linaro/odp/pull/313.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: 5d0d0efcb77baf5b9db803a8a8b89450e27aff38
 **/
 platform/linux-generic/include/odp_packet_io_internal.h |  3 ++-
 platform/linux-generic/pktio/dpdk.c                     | 11 +++++++----
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/platform/linux-generic/include/odp_packet_io_internal.h 
b/platform/linux-generic/include/odp_packet_io_internal.h
index f323d5c31..598b1ad50 100644
--- a/platform/linux-generic/include/odp_packet_io_internal.h
+++ b/platform/linux-generic/include/odp_packet_io_internal.h
@@ -113,7 +113,8 @@ struct pktio_entry {
        /* These two locks together lock the whole pktio device */
        odp_ticketlock_t rxl;           /**< RX ticketlock */
        odp_ticketlock_t txl;           /**< TX ticketlock */
-       int cls_enabled;                /**< is classifier enabled */
+       uint8_t cls_enabled;            /**< classifier enabled */
+       uint8_t chksum_insert_ena;      /**< pktout checksum offload enabled */
        odp_pktio_t handle;             /**< pktio handle */
        union {
                pkt_loop_t pkt_loop;            /**< Using loopback for IO */
diff --git a/platform/linux-generic/pktio/dpdk.c 
b/platform/linux-generic/pktio/dpdk.c
index 430eb8df4..7e493ad86 100644
--- a/platform/linux-generic/pktio/dpdk.c
+++ b/platform/linux-generic/pktio/dpdk.c
@@ -546,6 +546,9 @@ static inline void pkt_set_ol_tx(odp_pktout_config_opt_t 
*pktout_cfg,
        odp_bool_t ipv4_chksum_pkt, udp_chksum_pkt, tcp_chksum_pkt;
        packet_parser_t *pkt_p = &pkt_hdr->p;
 
+       if (pkt_p->l3_offset == ODP_PACKET_OFFSET_INVALID)
+               return;
+
        l3_hdr = (void *)(mbuf_data + pkt_p->l3_offset);
 
        if (check_proto(l3_hdr, &l3_proto_v4, &l4_proto))
@@ -633,7 +636,7 @@ static inline int pkt_to_mbuf(pktio_entry_t *pktio_entry,
 
                odp_packet_copy_to_mem(pkt_table[i], 0, pkt_len, data);
 
-               if (pkt_hdr->p.l3_offset != ODP_PACKET_OFFSET_INVALID) {
+               if (odp_unlikely(pktio_entry->s.chksum_insert_ena)) {
                        odp_pktout_config_opt_t *pktout_capa =
                        &pktio_entry->s.capa.config.pktout;
 
@@ -748,7 +751,7 @@ static inline int pkt_to_mbuf_zero(pktio_entry_t 
*pktio_entry,
                               pkt_hdr->extra_type == PKT_EXTRA_TYPE_DPDK)) {
                        mbuf_update(mbuf, pkt_hdr, pkt_len);
 
-                       if (pkt_hdr->p.l3_offset != ODP_PACKET_OFFSET_INVALID)
+                       if (odp_unlikely(pktio_entry->s.chksum_insert_ena))
                                pkt_set_ol_tx(pktout_cfg, pktout_capa, pkt_hdr,
                                              mbuf, _odp_packet_data(pkt));
                } else {
@@ -771,8 +774,7 @@ static inline int pkt_to_mbuf_zero(pktio_entry_t 
*pktio_entry,
                                mbuf_init((struct rte_mempool *)
                                          pool_entry->ext_desc, mbuf, pkt_hdr);
                                mbuf_update(mbuf, pkt_hdr, pkt_len);
-                               if (pkt_hdr->p.l3_offset !=
-                                   ODP_PACKET_OFFSET_INVALID)
+                               if (pktio_entry->s.chksum_insert_ena)
                                        pkt_set_ol_tx(pktout_cfg, pktout_capa,
                                                      pkt_hdr, mbuf,
                                                      _odp_packet_data(pkt));
@@ -1425,6 +1427,7 @@ static int dpdk_start(pktio_entry_t *pktio_entry)
                        rte_eth_dev_info_get(port_id, &dev_info);
                        dev_info.default_txconf.txq_flags = txq_flags;
                        txconf = &dev_info.default_txconf;
+                       pktio_entry->s.chksum_insert_ena = 1;
                }
 
                ret = rte_eth_tx_queue_setup(port_id, i, DPDK_NM_TX_DESC,

Reply via email to