examples/ntb: support more functions
[dpdk.git] / examples / ipsec-secgw / ipsec.c
index dc85adf..51fb22e 100644 (file)
@@ -33,8 +33,20 @@ set_ipsec_conf(struct ipsec_sa *sa, struct rte_security_ipsec_xform *ipsec)
 
                        memcpy((uint8_t *)&tunnel->ipv4.dst_ip,
                                (uint8_t *)&sa->dst.ip.ip4, 4);
+               } else if (IS_IP6_TUNNEL(sa->flags)) {
+                       tunnel->type =
+                               RTE_SECURITY_IPSEC_TUNNEL_IPV6;
+                       tunnel->ipv6.hlimit = IPDEFTTL;
+                       tunnel->ipv6.dscp = 0;
+                       tunnel->ipv6.flabel = 0;
+
+                       memcpy((uint8_t *)&tunnel->ipv6.src_addr,
+                               (uint8_t *)&sa->src.ip.ip6.ip6_b, 16);
+
+                       memcpy((uint8_t *)&tunnel->ipv6.dst_addr,
+                               (uint8_t *)&sa->dst.ip.ip6.ip6_b, 16);
                }
-               /* TODO support for Transport and IPV6 tunnel */
+               /* TODO support for Transport */
        }
        ipsec->esn_soft_limit = IPSEC_OFFLOAD_ESN_SOFTLIMIT;
 }
@@ -243,12 +255,26 @@ create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa)
                        unsigned int i;
                        unsigned int j;
 
-                       rte_eth_dev_info_get(sa->portid, &dev_info);
+                       ret = rte_eth_dev_info_get(sa->portid, &dev_info);
+                       if (ret != 0) {
+                               RTE_LOG(ERR, IPSEC,
+                                       "Error during getting device (port %u) info: %s\n",
+                                       sa->portid, strerror(-ret));
+                               return ret;
+                       }
+
                        sa->action[2].type = RTE_FLOW_ACTION_TYPE_END;
                        /* Try RSS. */
                        sa->action[1].type = RTE_FLOW_ACTION_TYPE_RSS;
                        sa->action[1].conf = &action_rss;
-                       rte_eth_dev_rss_hash_conf_get(sa->portid, &rss_conf);
+                       ret = rte_eth_dev_rss_hash_conf_get(sa->portid,
+                                       &rss_conf);
+                       if (ret != 0) {
+                               RTE_LOG(ERR, IPSEC,
+                                       "rte_eth_dev_rss_hash_conf_get:ret=%d\n",
+                                       ret);
+                               return -1;
+                       }
                        for (i = 0, j = 0; i < dev_info.nb_rx_queues; ++i)
                                queue[j++] = i;
 
@@ -566,6 +592,12 @@ ipsec_dequeue(ipsec_xform_fn xform_func, struct ipsec_ctx *ipsec_ctx,
                                        rte_pktmbuf_free(pkt);
                                        continue;
                                }
+                       } else if (sa->type ==
+                               RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
+                               if (cops[j]->status) {
+                                       rte_pktmbuf_free(pkt);
+                                       continue;
+                               }
                        }
                        pkts[nb_pkts++] = pkt;
                }