New upstream version 18.11-rc1
[deb_dpdk.git] / drivers / net / ixgbe / ixgbe_ipsec.c
index 176ec0f..5a41688 100644 (file)
@@ -364,6 +364,7 @@ ixgbe_crypto_create_session(void *device,
                        conf->crypto_xform->aead.algo !=
                                        RTE_CRYPTO_AEAD_AES_GCM) {
                PMD_DRV_LOG(ERR, "Unsupported crypto transformation mode\n");
+               rte_mempool_put(mempool, (void *)ic_session);
                return -ENOTSUP;
        }
        aead_xform = &conf->crypto_xform->aead;
@@ -373,6 +374,7 @@ ixgbe_crypto_create_session(void *device,
                        ic_session->op = IXGBE_OP_AUTHENTICATED_DECRYPTION;
                } else {
                        PMD_DRV_LOG(ERR, "IPsec decryption not enabled\n");
+                       rte_mempool_put(mempool, (void *)ic_session);
                        return -ENOTSUP;
                }
        } else {
@@ -380,6 +382,7 @@ ixgbe_crypto_create_session(void *device,
                        ic_session->op = IXGBE_OP_AUTHENTICATED_ENCRYPTION;
                } else {
                        PMD_DRV_LOG(ERR, "IPsec encryption not enabled\n");
+                       rte_mempool_put(mempool, (void *)ic_session);
                        return -ENOTSUP;
                }
        }
@@ -395,6 +398,7 @@ ixgbe_crypto_create_session(void *device,
        if (ic_session->op == IXGBE_OP_AUTHENTICATED_ENCRYPTION) {
                if (ixgbe_crypto_add_sa(ic_session)) {
                        PMD_DRV_LOG(ERR, "Failed to add SA\n");
+                       rte_mempool_put(mempool, (void *)ic_session);
                        return -EPERM;
                }
        }
@@ -598,13 +602,18 @@ ixgbe_crypto_enable_ipsec(struct rte_eth_dev *dev)
 {
        struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
        uint32_t reg;
+       uint64_t rx_offloads;
+       uint64_t tx_offloads;
+
+       rx_offloads = dev->data->dev_conf.rxmode.offloads;
+       tx_offloads = dev->data->dev_conf.txmode.offloads;
 
        /* sanity checks */
-       if (dev->data->dev_conf.rxmode.enable_lro) {
+       if (rx_offloads & DEV_RX_OFFLOAD_TCP_LRO) {
                PMD_DRV_LOG(ERR, "RSC and IPsec not supported");
                return -1;
        }
-       if (!dev->data->dev_conf.rxmode.hw_strip_crc) {
+       if (rx_offloads & DEV_RX_OFFLOAD_KEEP_CRC) {
                PMD_DRV_LOG(ERR, "HW CRC strip needs to be enabled for IPsec");
                return -1;
        }
@@ -624,7 +633,7 @@ ixgbe_crypto_enable_ipsec(struct rte_eth_dev *dev)
        reg |= IXGBE_HLREG0_TXCRCEN | IXGBE_HLREG0_RXCRCSTRP;
        IXGBE_WRITE_REG(hw, IXGBE_HLREG0, reg);
 
-       if (dev->data->dev_conf.rxmode.offloads & DEV_RX_OFFLOAD_SECURITY) {
+       if (rx_offloads & DEV_RX_OFFLOAD_SECURITY) {
                IXGBE_WRITE_REG(hw, IXGBE_SECRXCTRL, 0);
                reg = IXGBE_READ_REG(hw, IXGBE_SECRXCTRL);
                if (reg != 0) {
@@ -632,7 +641,7 @@ ixgbe_crypto_enable_ipsec(struct rte_eth_dev *dev)
                        return -1;
                }
        }
-       if (dev->data->dev_conf.txmode.offloads & DEV_TX_OFFLOAD_SECURITY) {
+       if (tx_offloads & DEV_TX_OFFLOAD_SECURITY) {
                IXGBE_WRITE_REG(hw, IXGBE_SECTXCTRL,
                                IXGBE_SECTXCTRL_STORE_FORWARD);
                reg = IXGBE_READ_REG(hw, IXGBE_SECTXCTRL);