examples/ipsec-secgw: add poll mode worker for inline proto
[dpdk.git] / examples / ipsec-secgw / ipsec_worker.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright (C) 2020 Marvell International Ltd.
3  */
4 #ifndef _IPSEC_WORKER_H_
5 #define _IPSEC_WORKER_H_
6
7 #include <rte_acl.h>
8 #include <rte_ethdev.h>
9 #include <rte_lpm.h>
10 #include <rte_lpm6.h>
11
12 #include "ipsec.h"
13
14 /* Configure how many packets ahead to prefetch, when reading packets */
15 #define PREFETCH_OFFSET 3
16 #define BURST_TX_DRAIN_US 100 /* TX drain every ~100us */
17
18 enum pkt_type {
19         PKT_TYPE_PLAIN_IPV4 = 1,
20         PKT_TYPE_IPSEC_IPV4,
21         PKT_TYPE_PLAIN_IPV6,
22         PKT_TYPE_IPSEC_IPV6,
23         PKT_TYPE_INVALID
24 };
25
26 enum {
27         PKT_DROPPED = 0,
28         PKT_FORWARDED,
29         PKT_POSTED      /* for lookaside case */
30 };
31
32 struct route_table {
33         struct rt_ctx *rt4_ctx;
34         struct rt_ctx *rt6_ctx;
35 };
36
37 /*
38  * Conf required by event mode worker with tx internal port
39  */
40 struct lcore_conf_ev_tx_int_port_wrkr {
41         struct ipsec_ctx inbound;
42         struct ipsec_ctx outbound;
43         struct route_table rt;
44 } __rte_cache_aligned;
45
46 void ipsec_poll_mode_worker(void);
47 void ipsec_poll_mode_wrkr_inl_pr(void);
48 void ipsec_poll_mode_wrkr_inl_pr_ss(void);
49
50 int ipsec_launch_one_lcore(void *args);
51
52 /*
53  * helper routine for inline and cpu(synchronous) processing
54  * this is just to satisfy inbound_sa_check() and get_hop_for_offload_pkt().
55  * Should be removed in future.
56  */
57 static inline void
58 prep_process_group(void *sa, struct rte_mbuf *mb[], uint32_t cnt)
59 {
60         uint32_t j;
61         struct ipsec_mbuf_metadata *priv;
62
63         for (j = 0; j != cnt; j++) {
64                 priv = get_priv(mb[j]);
65                 priv->sa = sa;
66                 /* setup TSO related fields if TSO enabled*/
67                 if (priv->sa->mss) {
68                         uint32_t ptype = mb[j]->packet_type;
69                         /* only TCP is supported */
70                         if ((ptype & RTE_PTYPE_L4_MASK) == RTE_PTYPE_L4_TCP) {
71                                 mb[j]->tso_segsz = priv->sa->mss;
72                                 if ((IS_TUNNEL(priv->sa->flags))) {
73                                         mb[j]->outer_l3_len = mb[j]->l3_len;
74                                         mb[j]->outer_l2_len = mb[j]->l2_len;
75                                         mb[j]->ol_flags |=
76                                                 RTE_MBUF_F_TX_TUNNEL_ESP;
77                                         if (RTE_ETH_IS_IPV4_HDR(ptype))
78                                                 mb[j]->ol_flags |=
79                                                 RTE_MBUF_F_TX_OUTER_IP_CKSUM;
80                                 }
81                                 mb[j]->l4_len = sizeof(struct rte_tcp_hdr);
82                                 mb[j]->ol_flags |= (RTE_MBUF_F_TX_TCP_SEG |
83                                                 RTE_MBUF_F_TX_TCP_CKSUM);
84                                 if (RTE_ETH_IS_IPV4_HDR(ptype))
85                                         mb[j]->ol_flags |=
86                                                 RTE_MBUF_F_TX_OUTER_IPV4;
87                                 else
88                                         mb[j]->ol_flags |=
89                                                 RTE_MBUF_F_TX_OUTER_IPV6;
90                         }
91                 }
92         }
93 }
94
95 static __rte_always_inline void
96 adjust_ipv4_pktlen(struct rte_mbuf *m, const struct rte_ipv4_hdr *iph,
97         uint32_t l2_len)
98 {
99         uint32_t plen, trim;
100
101         plen = rte_be_to_cpu_16(iph->total_length) + l2_len;
102         if (plen < m->pkt_len) {
103                 trim = m->pkt_len - plen;
104                 rte_pktmbuf_trim(m, trim);
105         }
106 }
107
108 static __rte_always_inline void
109 adjust_ipv6_pktlen(struct rte_mbuf *m, const struct rte_ipv6_hdr *iph,
110         uint32_t l2_len)
111 {
112         uint32_t plen, trim;
113
114         plen = rte_be_to_cpu_16(iph->payload_len) + sizeof(*iph) + l2_len;
115         if (plen < m->pkt_len) {
116                 trim = m->pkt_len - plen;
117                 rte_pktmbuf_trim(m, trim);
118         }
119 }
120
121 static __rte_always_inline void
122 prepare_one_packet(struct rte_security_ctx *ctx, struct rte_mbuf *pkt,
123                    struct ipsec_traffic *t)
124 {
125         uint32_t ptype = pkt->packet_type;
126         const struct rte_ether_hdr *eth;
127         const struct rte_ipv4_hdr *iph4;
128         const struct rte_ipv6_hdr *iph6;
129         uint32_t tun_type, l3_type;
130         uint64_t tx_offload;
131         uint16_t l3len;
132
133         tun_type = ptype & RTE_PTYPE_TUNNEL_MASK;
134         l3_type = ptype & RTE_PTYPE_L3_MASK;
135
136         eth = rte_pktmbuf_mtod(pkt, const struct rte_ether_hdr *);
137         if (RTE_ETH_IS_IPV4_HDR(l3_type)) {
138                 iph4 = (const struct rte_ipv4_hdr *)rte_pktmbuf_adj(pkt,
139                         RTE_ETHER_HDR_LEN);
140                 adjust_ipv4_pktlen(pkt, iph4, 0);
141
142                 if (tun_type == RTE_PTYPE_TUNNEL_ESP) {
143                         t->ipsec.pkts[(t->ipsec.num)++] = pkt;
144                 } else {
145                         t->ip4.data[t->ip4.num] = &iph4->next_proto_id;
146                         t->ip4.pkts[(t->ip4.num)++] = pkt;
147                 }
148                 tx_offload = sizeof(*iph4) << RTE_MBUF_L2_LEN_BITS;
149         } else if (RTE_ETH_IS_IPV6_HDR(l3_type)) {
150                 int next_proto;
151                 size_t ext_len;
152                 uint8_t *p;
153
154                 /* get protocol type */
155                 iph6 = (const struct rte_ipv6_hdr *)rte_pktmbuf_adj(pkt,
156                         RTE_ETHER_HDR_LEN);
157                 adjust_ipv6_pktlen(pkt, iph6, 0);
158
159                 l3len = sizeof(struct ip6_hdr);
160
161                 if (tun_type == RTE_PTYPE_TUNNEL_ESP) {
162                         t->ipsec.pkts[(t->ipsec.num)++] = pkt;
163                 } else {
164                         t->ip6.data[t->ip6.num] = &iph6->proto;
165                         t->ip6.pkts[(t->ip6.num)++] = pkt;
166                 }
167
168                 /* Determine l3 header size up to ESP extension by walking
169                  * through extension headers.
170                  */
171                 if (l3_type == RTE_PTYPE_L3_IPV6_EXT ||
172                      l3_type == RTE_PTYPE_L3_IPV6_EXT_UNKNOWN) {
173                         p = rte_pktmbuf_mtod(pkt, uint8_t *);
174                         next_proto = iph6->proto;
175                         while (next_proto != IPPROTO_ESP &&
176                                l3len < pkt->data_len &&
177                                (next_proto = rte_ipv6_get_next_ext(p + l3len,
178                                                 next_proto, &ext_len)) >= 0)
179                                 l3len += ext_len;
180
181                         /* Drop pkt when IPv6 header exceeds first seg size */
182                         if (unlikely(l3len > pkt->data_len)) {
183                                 free_pkts(&pkt, 1);
184                                 return;
185                         }
186                 }
187                 tx_offload = l3len << RTE_MBUF_L2_LEN_BITS;
188         } else {
189                 /* Unknown/Unsupported type, drop the packet */
190                 RTE_LOG(ERR, IPSEC, "Unsupported packet type 0x%x\n",
191                         rte_be_to_cpu_16(eth->ether_type));
192                 free_pkts(&pkt, 1);
193                 return;
194         }
195
196         if  ((ptype & RTE_PTYPE_L4_MASK) == RTE_PTYPE_L4_TCP)
197                 tx_offload |= (sizeof(struct rte_tcp_hdr) <<
198                                (RTE_MBUF_L2_LEN_BITS + RTE_MBUF_L3_LEN_BITS));
199         else if ((ptype & RTE_PTYPE_L4_MASK) == RTE_PTYPE_L4_UDP)
200                 tx_offload |= (sizeof(struct rte_udp_hdr) <<
201                                (RTE_MBUF_L2_LEN_BITS + RTE_MBUF_L3_LEN_BITS));
202         pkt->tx_offload = tx_offload;
203
204         /* Check if the packet has been processed inline. For inline protocol
205          * processed packets, the metadata in the mbuf can be used to identify
206          * the security processing done on the packet. The metadata will be
207          * used to retrieve the application registered userdata associated
208          * with the security session.
209          */
210
211         if (ctx && pkt->ol_flags & RTE_MBUF_F_RX_SEC_OFFLOAD) {
212                 struct ipsec_sa *sa;
213                 struct ipsec_mbuf_metadata *priv;
214
215                 /* Retrieve the userdata registered. Here, the userdata
216                  * registered is the SA pointer.
217                  */
218                 sa = (struct ipsec_sa *)rte_security_get_userdata(ctx,
219                                 *rte_security_dynfield(pkt));
220                 if (sa == NULL) {
221                         /* userdata could not be retrieved */
222                         return;
223                 }
224
225                 /* Save SA as priv member in mbuf. This will be used in the
226                  * IPsec selector(SP-SA) check.
227                  */
228
229                 priv = get_priv(pkt);
230                 priv->sa = sa;
231         }
232 }
233
234 static __rte_always_inline void
235 prepare_traffic(struct rte_security_ctx *ctx, struct rte_mbuf **pkts,
236                 struct ipsec_traffic *t, uint16_t nb_pkts)
237 {
238         int32_t i;
239
240         t->ipsec.num = 0;
241         t->ip4.num = 0;
242         t->ip6.num = 0;
243
244         for (i = 0; i < (nb_pkts - PREFETCH_OFFSET); i++) {
245                 rte_prefetch0(rte_pktmbuf_mtod(pkts[i + PREFETCH_OFFSET],
246                                         void *));
247                 prepare_one_packet(ctx, pkts[i], t);
248         }
249         /* Process left packets */
250         for (; i < nb_pkts; i++)
251                 prepare_one_packet(ctx, pkts[i], t);
252 }
253
254 /* Send burst of packets on an output interface */
255 static __rte_always_inline int32_t
256 send_burst(struct lcore_conf *qconf, uint16_t n, uint16_t port)
257 {
258         struct rte_mbuf **m_table;
259         int32_t ret;
260         uint16_t queueid;
261
262         queueid = qconf->tx_queue_id[port];
263         m_table = (struct rte_mbuf **)qconf->tx_mbufs[port].m_table;
264
265         ret = rte_eth_tx_burst(port, queueid, m_table, n);
266
267         core_stats_update_tx(ret);
268
269         if (unlikely(ret < n)) {
270                 do {
271                         free_pkts(&m_table[ret], 1);
272                 } while (++ret < n);
273         }
274
275         return 0;
276 }
277
278 /*
279  * Helper function to fragment and queue for TX one packet.
280  */
281 static __rte_always_inline uint32_t
282 send_fragment_packet(struct lcore_conf *qconf, struct rte_mbuf *m,
283         uint16_t port, uint8_t proto)
284 {
285         struct rte_ether_hdr *ethhdr;
286         struct rte_ipv4_hdr *ip;
287         struct rte_mbuf *pkt;
288         struct buffer *tbl;
289         uint32_t len, n, i;
290         int32_t rc;
291
292         tbl =  qconf->tx_mbufs + port;
293         len = tbl->len;
294
295         /* free space for new fragments */
296         if (len + RTE_LIBRTE_IP_FRAG_MAX_FRAG >=  RTE_DIM(tbl->m_table)) {
297                 send_burst(qconf, len, port);
298                 len = 0;
299         }
300
301         n = RTE_DIM(tbl->m_table) - len;
302
303         /* Strip the ethernet header that was prepended earlier */
304         rte_pktmbuf_adj(m, RTE_ETHER_HDR_LEN);
305
306         if (proto == IPPROTO_IP)
307                 rc = rte_ipv4_fragment_packet(m, tbl->m_table + len,
308                         n, mtu_size, m->pool, qconf->frag.pool_indir);
309         else
310                 rc = rte_ipv6_fragment_packet(m, tbl->m_table + len,
311                         n, mtu_size, m->pool, qconf->frag.pool_indir);
312
313         if (rc < 0) {
314                 RTE_LOG(ERR, IPSEC,
315                         "%s: failed to fragment packet with size %u, "
316                         "error code: %d\n",
317                         __func__, m->pkt_len, rte_errno);
318                 rc = 0;
319         }
320
321         i = len;
322         len += rc;
323         for (; i < len; i++) {
324                 pkt = tbl->m_table[i];
325
326                 /* Update Ethernet header */
327                 ethhdr = (struct rte_ether_hdr *)
328                         rte_pktmbuf_prepend(pkt, RTE_ETHER_HDR_LEN);
329                 pkt->l2_len = RTE_ETHER_HDR_LEN;
330
331                 if (proto == IPPROTO_IP) {
332                         ethhdr->ether_type =
333                                 rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
334                         /* Update minimum offload data */
335                         pkt->l3_len = sizeof(struct rte_ipv4_hdr);
336                         pkt->ol_flags |= qconf->outbound.ipv4_offloads;
337
338                         ip = (struct rte_ipv4_hdr *)(ethhdr + 1);
339                         ip->hdr_checksum = 0;
340
341                         /* calculate IPv4 cksum in SW */
342                         if ((pkt->ol_flags & RTE_MBUF_F_TX_IP_CKSUM) == 0)
343                                 ip->hdr_checksum = rte_ipv4_cksum(ip);
344                 } else {
345                         ethhdr->ether_type =
346                                 rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
347
348                         /* Update minimum offload data */
349                         pkt->l3_len = sizeof(struct rte_ipv6_hdr);
350                         pkt->ol_flags |= qconf->outbound.ipv6_offloads;
351                 }
352
353                 memcpy(&ethhdr->src_addr, &ethaddr_tbl[port].src,
354                        sizeof(struct rte_ether_addr));
355                 memcpy(&ethhdr->dst_addr, &ethaddr_tbl[port].dst,
356                        sizeof(struct rte_ether_addr));
357         }
358
359         free_pkts(&m, 1);
360         return len;
361 }
362
363 /* Enqueue a single packet, and send burst if queue is filled */
364 static __rte_always_inline int32_t
365 send_single_packet(struct rte_mbuf *m, uint16_t port, uint8_t proto)
366 {
367         uint32_t lcore_id;
368         uint16_t len;
369         struct lcore_conf *qconf;
370
371         lcore_id = rte_lcore_id();
372
373         qconf = &lcore_conf[lcore_id];
374         len = qconf->tx_mbufs[port].len;
375
376         /* L2 header is already part of packet */
377         if (m->pkt_len - RTE_ETHER_HDR_LEN <= mtu_size) {
378                 qconf->tx_mbufs[port].m_table[len] = m;
379                 len++;
380
381         /* need to fragment the packet */
382         } else if (frag_tbl_sz > 0)
383                 len = send_fragment_packet(qconf, m, port, proto);
384         else
385                 free_pkts(&m, 1);
386
387         /* enough pkts to be sent */
388         if (unlikely(len == MAX_PKT_BURST)) {
389                 send_burst(qconf, MAX_PKT_BURST, port);
390                 len = 0;
391         }
392
393         qconf->tx_mbufs[port].len = len;
394         return 0;
395 }
396
397 static __rte_always_inline void
398 inbound_sp_sa(struct sp_ctx *sp, struct sa_ctx *sa, struct traffic_type *ip,
399                 uint16_t lim, struct ipsec_spd_stats *stats)
400 {
401         struct rte_mbuf *m;
402         uint32_t i, j, res, sa_idx;
403
404         if (ip->num == 0 || sp == NULL)
405                 return;
406
407         rte_acl_classify((struct rte_acl_ctx *)sp, ip->data, ip->res,
408                         ip->num, DEFAULT_MAX_CATEGORIES);
409
410         j = 0;
411         for (i = 0; i < ip->num; i++) {
412                 m = ip->pkts[i];
413                 res = ip->res[i];
414                 if (res == BYPASS) {
415                         ip->pkts[j++] = m;
416                         stats->bypass++;
417                         continue;
418                 }
419                 if (res == DISCARD) {
420                         free_pkts(&m, 1);
421                         stats->discard++;
422                         continue;
423                 }
424
425                 /* Only check SPI match for processed IPSec packets */
426                 if (i < lim && ((m->ol_flags & RTE_MBUF_F_RX_SEC_OFFLOAD) == 0)) {
427                         stats->discard++;
428                         free_pkts(&m, 1);
429                         continue;
430                 }
431
432                 sa_idx = res - 1;
433                 if (!inbound_sa_check(sa, m, sa_idx)) {
434                         stats->discard++;
435                         free_pkts(&m, 1);
436                         continue;
437                 }
438                 ip->pkts[j++] = m;
439                 stats->protect++;
440         }
441         ip->num = j;
442 }
443
444 static __rte_always_inline int32_t
445 get_hop_for_offload_pkt(struct rte_mbuf *pkt, int is_ipv6)
446 {
447         struct ipsec_mbuf_metadata *priv;
448         struct ipsec_sa *sa;
449
450         priv = get_priv(pkt);
451
452         sa = priv->sa;
453         if (unlikely(sa == NULL)) {
454                 RTE_LOG(ERR, IPSEC, "SA not saved in private data\n");
455                 goto fail;
456         }
457
458         if (is_ipv6)
459                 return sa->portid;
460
461         /* else */
462         return (sa->portid | RTE_LPM_LOOKUP_SUCCESS);
463
464 fail:
465         if (is_ipv6)
466                 return -1;
467
468         /* else */
469         return 0;
470 }
471
472 static __rte_always_inline void
473 route4_pkts(struct rt_ctx *rt_ctx, struct rte_mbuf *pkts[],
474             uint8_t nb_pkts, uint64_t tx_offloads, bool ip_cksum)
475 {
476         uint32_t hop[MAX_PKT_BURST * 2];
477         uint32_t dst_ip[MAX_PKT_BURST * 2];
478         struct rte_ether_hdr *ethhdr;
479         int32_t pkt_hop = 0;
480         uint16_t i, offset;
481         uint16_t lpm_pkts = 0;
482         unsigned int lcoreid = rte_lcore_id();
483         struct rte_mbuf *pkt;
484         uint16_t port;
485
486         if (nb_pkts == 0)
487                 return;
488
489         /* Need to do an LPM lookup for non-inline packets. Inline packets will
490          * have port ID in the SA
491          */
492
493         for (i = 0; i < nb_pkts; i++) {
494                 pkt = pkts[i];
495                 if (!(pkt->ol_flags & RTE_MBUF_F_TX_SEC_OFFLOAD)) {
496                         /* Security offload not enabled. So an LPM lookup is
497                          * required to get the hop
498                          */
499                         offset = offsetof(struct ip, ip_dst);
500                         dst_ip[lpm_pkts] = *rte_pktmbuf_mtod_offset(pkt,
501                                         uint32_t *, offset);
502                         dst_ip[lpm_pkts] = rte_be_to_cpu_32(dst_ip[lpm_pkts]);
503                         lpm_pkts++;
504                 }
505         }
506
507         rte_lpm_lookup_bulk((struct rte_lpm *)rt_ctx, dst_ip, hop, lpm_pkts);
508
509         lpm_pkts = 0;
510
511         for (i = 0; i < nb_pkts; i++) {
512                 pkt = pkts[i];
513                 if (pkt->ol_flags & RTE_MBUF_F_TX_SEC_OFFLOAD) {
514                         /* Read hop from the SA */
515                         pkt_hop = get_hop_for_offload_pkt(pkt, 0);
516                 } else {
517                         /* Need to use hop returned by lookup */
518                         pkt_hop = hop[lpm_pkts++];
519                 }
520
521                 if ((pkt_hop & RTE_LPM_LOOKUP_SUCCESS) == 0) {
522                         core_statistics[lcoreid].lpm4.miss++;
523                         free_pkts(&pkt, 1);
524                         continue;
525                 }
526
527                 port = pkt_hop & 0xff;
528
529                 /* Update minimum offload data */
530                 pkt->l3_len = sizeof(struct rte_ipv4_hdr);
531                 pkt->l2_len = RTE_ETHER_HDR_LEN;
532                 pkt->ol_flags |= RTE_MBUF_F_TX_IPV4;
533
534                 /* Update Ethernet header */
535                 ethhdr = (struct rte_ether_hdr *)
536                         rte_pktmbuf_prepend(pkt, RTE_ETHER_HDR_LEN);
537
538                 if (ip_cksum) {
539                         struct rte_ipv4_hdr *ip;
540
541                         pkt->ol_flags |= tx_offloads;
542
543                         ip = (struct rte_ipv4_hdr *)(ethhdr + 1);
544                         ip->hdr_checksum = 0;
545
546                         /* calculate IPv4 cksum in SW */
547                         if ((pkt->ol_flags & RTE_MBUF_F_TX_IP_CKSUM) == 0)
548                                 ip->hdr_checksum = rte_ipv4_cksum(ip);
549                 }
550
551                 ethhdr->ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
552                 memcpy(&ethhdr->src_addr, &ethaddr_tbl[port].src,
553                        sizeof(struct rte_ether_addr));
554                 memcpy(&ethhdr->dst_addr, &ethaddr_tbl[port].dst,
555                        sizeof(struct rte_ether_addr));
556
557                 send_single_packet(pkt, port, IPPROTO_IP);
558         }
559 }
560
561 static __rte_always_inline void
562 route6_pkts(struct rt_ctx *rt_ctx, struct rte_mbuf *pkts[], uint8_t nb_pkts)
563 {
564         int32_t hop[MAX_PKT_BURST * 2];
565         uint8_t dst_ip[MAX_PKT_BURST * 2][16];
566         struct rte_ether_hdr *ethhdr;
567         uint8_t *ip6_dst;
568         int32_t pkt_hop = 0;
569         uint16_t i, offset;
570         uint16_t lpm_pkts = 0;
571         unsigned int lcoreid = rte_lcore_id();
572         struct rte_mbuf *pkt;
573         uint16_t port;
574
575         if (nb_pkts == 0)
576                 return;
577
578         /* Need to do an LPM lookup for non-inline packets. Inline packets will
579          * have port ID in the SA
580          */
581
582         for (i = 0; i < nb_pkts; i++) {
583                 pkt = pkts[i];
584                 if (!(pkt->ol_flags & RTE_MBUF_F_TX_SEC_OFFLOAD)) {
585                         /* Security offload not enabled. So an LPM lookup is
586                          * required to get the hop
587                          */
588                         offset = offsetof(struct ip6_hdr, ip6_dst);
589                         ip6_dst = rte_pktmbuf_mtod_offset(pkt, uint8_t *,
590                                         offset);
591                         memcpy(&dst_ip[lpm_pkts][0], ip6_dst, 16);
592                         lpm_pkts++;
593                 }
594         }
595
596         rte_lpm6_lookup_bulk_func((struct rte_lpm6 *)rt_ctx, dst_ip, hop,
597                         lpm_pkts);
598
599         lpm_pkts = 0;
600
601         for (i = 0; i < nb_pkts; i++) {
602                 pkt = pkts[i];
603                 if (pkt->ol_flags & RTE_MBUF_F_TX_SEC_OFFLOAD) {
604                         /* Read hop from the SA */
605                         pkt_hop = get_hop_for_offload_pkt(pkt, 1);
606                 } else {
607                         /* Need to use hop returned by lookup */
608                         pkt_hop = hop[lpm_pkts++];
609                 }
610
611                 if (pkt_hop == -1) {
612                         core_statistics[lcoreid].lpm6.miss++;
613                         free_pkts(&pkt, 1);
614                         continue;
615                 }
616
617                 port = pkt_hop & 0xff;
618
619                 /* Update minimum offload data */
620                 pkt->ol_flags |= RTE_MBUF_F_TX_IPV6;
621                 pkt->l3_len = sizeof(struct ip6_hdr);
622                 pkt->l2_len = RTE_ETHER_HDR_LEN;
623
624                 /* Update Ethernet header */
625                 ethhdr = (struct rte_ether_hdr *)
626                         rte_pktmbuf_prepend(pkt, RTE_ETHER_HDR_LEN);
627
628                 ethhdr->ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
629                 memcpy(&ethhdr->src_addr, &ethaddr_tbl[port].src,
630                        sizeof(struct rte_ether_addr));
631                 memcpy(&ethhdr->dst_addr, &ethaddr_tbl[port].dst,
632                        sizeof(struct rte_ether_addr));
633
634                 send_single_packet(pkt, port, IPPROTO_IPV6);
635         }
636 }
637
638 static __rte_always_inline void
639 drain_tx_buffers(struct lcore_conf *qconf)
640 {
641         struct buffer *buf;
642         uint32_t portid;
643
644         for (portid = 0; portid < RTE_MAX_ETHPORTS; portid++) {
645                 buf = &qconf->tx_mbufs[portid];
646                 if (buf->len == 0)
647                         continue;
648                 send_burst(qconf, buf->len, portid);
649                 buf->len = 0;
650         }
651 }
652
653 #endif /* _IPSEC_WORKER_H_ */