diff mbox series

[API-NEXT,v2,5/5] linux-gen: dpdk: checksum insert enabled flag

Message ID 1512378024-15857-6-git-send-email-odpbot@yandex.ru
State New
Headers show
Series [API-NEXT,v2,1/5] api: pktio: add checksum insert enable bits | expand

Commit Message

Github ODP bot Dec. 4, 2017, 9 a.m. UTC
From: Petri Savolainen <petri.savolainen@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.savolainen@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: bdb7cbf620ada8682c89b5ae5a97cb84f16c0ed0
 ** Merge commit sha: e4a122986c2750ffb044994107b385bd8002cbf4
 **/
 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 mbox series

Patch

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 4a37fe6e5..48c2d0b0e 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));
@@ -1432,6 +1434,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,