examples/ipsec-secgw: support security offload
[dpdk.git] / examples / ipsec-secgw / ipsec-secgw.c
index 39f81cb..6201d85 100644 (file)
@@ -1132,7 +1132,8 @@ add_mapping(struct rte_hash *map, const char *str, uint16_t cdev_id,
                uint16_t qp, struct lcore_params *params,
                struct ipsec_ctx *ipsec_ctx,
                const struct rte_cryptodev_capabilities *cipher,
-               const struct rte_cryptodev_capabilities *auth)
+               const struct rte_cryptodev_capabilities *auth,
+               const struct rte_cryptodev_capabilities *aead)
 {
        int32_t ret = 0;
        unsigned long i;
@@ -1143,6 +1144,8 @@ add_mapping(struct rte_hash *map, const char *str, uint16_t cdev_id,
                key.cipher_algo = cipher->sym.cipher.algo;
        if (auth)
                key.auth_algo = auth->sym.auth.algo;
+       if (aead)
+               key.aead_algo = aead->sym.aead.algo;
 
        ret = rte_hash_lookup(map, &key);
        if (ret != -ENOENT)
@@ -1211,6 +1214,12 @@ add_cdev_mapping(struct rte_cryptodev_info *dev_info, uint16_t cdev_id,
                if (i->op != RTE_CRYPTO_OP_TYPE_SYMMETRIC)
                        continue;
 
+               if (i->sym.xform_type == RTE_CRYPTO_SYM_XFORM_AEAD) {
+                       ret |= add_mapping(map, str, cdev_id, qp, params,
+                                       ipsec_ctx, NULL, NULL, i);
+                       continue;
+               }
+
                if (i->sym.xform_type != RTE_CRYPTO_SYM_XFORM_CIPHER)
                        continue;
 
@@ -1223,7 +1232,7 @@ add_cdev_mapping(struct rte_cryptodev_info *dev_info, uint16_t cdev_id,
                                continue;
 
                        ret |= add_mapping(map, str, cdev_id, qp, params,
-                                       ipsec_ctx, i, j);
+                                               ipsec_ctx, i, j, NULL);
                }
        }
 
@@ -1381,6 +1390,11 @@ port_init(uint16_t portid)
                port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
        }
 
+       if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_SECURITY)
+               port_conf.rxmode.offloads |= DEV_RX_OFFLOAD_SECURITY;
+       if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_SECURITY)
+               port_conf.txmode.offloads |= DEV_TX_OFFLOAD_SECURITY;
+
        ret = rte_eth_dev_configure(portid, nb_rx_queue, nb_tx_queue,
                        &port_conf);
        if (ret < 0)