net/dpaa2: checksum support as per user config
authorHemant Agrawal <hemant.agrawal@nxp.com>
Sat, 16 Sep 2017 10:52:38 +0000 (16:22 +0530)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 6 Oct 2017 01:24:17 +0000 (03:24 +0200)
Instead of enabling the RX checksum by default, make it
enable only with user ethernet configuration

Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
drivers/net/dpaa2/dpaa2_ethdev.c

index 611f59b..7756c4e 100644 (file)
@@ -334,8 +334,10 @@ fail:
 static int
 dpaa2_eth_dev_configure(struct rte_eth_dev *dev)
 {
-       struct rte_eth_dev_data *data = dev->data;
-       struct rte_eth_conf *eth_conf = &data->dev_conf;
+       struct dpaa2_dev_priv *priv = dev->data->dev_private;
+       struct fsl_mc_io *dpni = priv->hw;
+       struct rte_eth_conf *eth_conf = &dev->data->dev_conf;
+       int rx_ip_csum_offload = false;
        int ret;
 
        PMD_INIT_FUNC_TRACE();
@@ -364,6 +366,37 @@ dpaa2_eth_dev_configure(struct rte_eth_dev *dev)
                }
        }
 
+       if (eth_conf->rxmode.hw_ip_checksum)
+               rx_ip_csum_offload = true;
+
+       ret = dpni_set_offload(dpni, CMD_PRI_LOW, priv->token,
+                              DPNI_OFF_RX_L3_CSUM, rx_ip_csum_offload);
+       if (ret) {
+               PMD_INIT_LOG(ERR, "Error to set RX l3 csum:Error = %d\n", ret);
+               return ret;
+       }
+
+       ret = dpni_set_offload(dpni, CMD_PRI_LOW, priv->token,
+                              DPNI_OFF_RX_L4_CSUM, rx_ip_csum_offload);
+       if (ret) {
+               PMD_INIT_LOG(ERR, "Error to get RX l4 csum:Error = %d\n", ret);
+               return ret;
+       }
+
+       ret = dpni_set_offload(dpni, CMD_PRI_LOW, priv->token,
+                              DPNI_OFF_TX_L3_CSUM, true);
+       if (ret) {
+               PMD_INIT_LOG(ERR, "Error to set TX l3 csum:Error = %d\n", ret);
+               return ret;
+       }
+
+       ret = dpni_set_offload(dpni, CMD_PRI_LOW, priv->token,
+                              DPNI_OFF_TX_L4_CSUM, true);
+       if (ret) {
+               PMD_INIT_LOG(ERR, "Error to get TX l4 csum:Error = %d\n", ret);
+               return ret;
+       }
+
        /* update the current status */
        dpaa2_dev_link_update(dev, 0);
 
@@ -707,34 +740,6 @@ dpaa2_dev_start(struct rte_eth_dev *dev)
                dpaa2_q->fqid = qid.fqid;
        }
 
-       ret = dpni_set_offload(dpni, CMD_PRI_LOW, priv->token,
-                              DPNI_OFF_RX_L3_CSUM, true);
-       if (ret) {
-               PMD_INIT_LOG(ERR, "Error to set RX l3 csum:Error = %d\n", ret);
-               return ret;
-       }
-
-       ret = dpni_set_offload(dpni, CMD_PRI_LOW, priv->token,
-                              DPNI_OFF_RX_L4_CSUM, true);
-       if (ret) {
-               PMD_INIT_LOG(ERR, "Error to get RX l4 csum:Error = %d\n", ret);
-               return ret;
-       }
-
-       ret = dpni_set_offload(dpni, CMD_PRI_LOW, priv->token,
-                              DPNI_OFF_TX_L3_CSUM, true);
-       if (ret) {
-               PMD_INIT_LOG(ERR, "Error to set TX l3 csum:Error = %d\n", ret);
-               return ret;
-       }
-
-       ret = dpni_set_offload(dpni, CMD_PRI_LOW, priv->token,
-                              DPNI_OFF_TX_L4_CSUM, true);
-       if (ret) {
-               PMD_INIT_LOG(ERR, "Error to get TX l4 csum:Error = %d\n", ret);
-               return ret;
-       }
-
        /*checksum errors, send them to normal path and set it in annotation */
        err_cfg.errors = DPNI_ERROR_L3CE | DPNI_ERROR_L4CE;