i40e: enable Tx checksum only for offloaded packets
authorOlivier Matz <olivier.matz@6wind.com>
Fri, 13 Feb 2015 09:22:34 +0000 (10:22 +0100)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Mon, 16 Feb 2015 18:21:17 +0000 (19:21 +0100)
From i40e datasheet:

  The IP header type and its offload. In case of tunneling, the IIPT
  relates to the inner IP header. See also EIPT field for the outer
  (External) IP header offload.

  00 - non IP packet or packet type is not defined by software
  01 - IPv6 packet
  10 - IPv4 packet with no IP checksum offload
  11 - IPv4 packet with IP checksum offload

Therefore it is not needed to fill the IIPT field if no offload is
requested (we can keep the value to 00). For instance, the linux driver
code does not set it when (skb->ip_summed != CHECKSUM_PARTIAL). We can
do the same in the dpdk driver.

The function i40e_txd_enable_checksum() that fills the offload registers
can only be called for packets requiring an offload.

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Jijiang Liu <jijiang.liu@intel.com>
lib/librte_pmd_i40e/i40e_rxtx.c

index 8e9df96..b467461 100644 (file)
 
 #define I40E_TXD_CMD (I40E_TX_DESC_CMD_EOP | I40E_TX_DESC_CMD_RS)
 
+#define I40E_TX_CKSUM_OFFLOAD_MASK (            \
+               PKT_TX_IP_CKSUM |                \
+               PKT_TX_L4_MASK |                 \
+               PKT_TX_OUTER_IP_CKSUM)
+
 #define RTE_MBUF_DATA_DMA_ADDR_DEFAULT(mb) \
        (uint64_t) ((mb)->buf_physaddr + RTE_PKTMBUF_HEADROOM)
 
@@ -1272,10 +1277,12 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 
                /* Enable checksum offloading */
                cd_tunneling_params = 0;
-               i40e_txd_enable_checksum(ol_flags, &td_cmd, &td_offset,
-                                               l2_len, l3_len, outer_l2_len,
-                                               outer_l3_len,
-                                               &cd_tunneling_params);
+               if (unlikely(ol_flags & I40E_TX_CKSUM_OFFLOAD_MASK)) {
+                       i40e_txd_enable_checksum(ol_flags, &td_cmd, &td_offset,
+                               l2_len, l3_len, outer_l2_len,
+                               outer_l3_len,
+                               &cd_tunneling_params);
+               }
 
                if (unlikely(nb_ctx)) {
                        /* Setup TX context descriptor if required */