DPDK  22.11.0-rc0
rte_ip_frag.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2014 Intel Corporation
3  */
4 
5 #ifndef _RTE_IP_FRAG_H_
6 #define _RTE_IP_FRAG_H_
7 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 #include <stdint.h>
20 #include <stdio.h>
21 
22 #include <rte_config.h>
23 #include <rte_malloc.h>
24 #include <rte_memory.h>
25 #include <rte_ip.h>
26 #include <rte_byteorder.h>
27 
28 struct rte_mbuf;
29 
31 #define RTE_IP_FRAG_DEATH_ROW_LEN 32
32 
34 #define RTE_IP_FRAG_DEATH_ROW_MBUF_LEN \
35  (RTE_IP_FRAG_DEATH_ROW_LEN * (RTE_LIBRTE_IP_FRAG_MAX_FRAG + 1))
36 
39  uint32_t cnt;
42 };
43 
63 struct rte_ip_frag_tbl * rte_ip_frag_table_create(uint32_t bucket_num,
64  uint32_t bucket_entries, uint32_t max_entries,
65  uint64_t max_cycles, int socket_id);
66 
73 void
74 rte_ip_frag_table_destroy(struct rte_ip_frag_tbl *tbl);
75 
97 int32_t
98 rte_ipv6_fragment_packet(struct rte_mbuf *pkt_in,
99  struct rte_mbuf **pkts_out,
100  uint16_t nb_pkts_out,
101  uint16_t mtu_size,
102  struct rte_mempool *pool_direct,
103  struct rte_mempool *pool_indirect);
104 
126 struct rte_mbuf *rte_ipv6_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl,
127  struct rte_ip_frag_death_row *dr,
128  struct rte_mbuf *mb, uint64_t tms, struct rte_ipv6_hdr *ip_hdr,
129  struct rte_ipv6_fragment_ext *frag_hdr);
130 
142 static inline struct rte_ipv6_fragment_ext *
144 {
145  if (hdr->proto == IPPROTO_FRAGMENT) {
146  return (struct rte_ipv6_fragment_ext *) ++hdr;
147  }
148  else
149  return NULL;
150 }
151 
175 int32_t rte_ipv4_fragment_packet(struct rte_mbuf *pkt_in,
176  struct rte_mbuf **pkts_out,
177  uint16_t nb_pkts_out, uint16_t mtu_size,
178  struct rte_mempool *pool_direct,
179  struct rte_mempool *pool_indirect);
180 
207 __rte_experimental
208 int32_t
210  struct rte_mbuf **pkts_out,
211  uint16_t nb_pkts_out,
212  uint16_t mtu_size,
213  struct rte_mempool *pool_direct);
214 
234 struct rte_mbuf * rte_ipv4_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl,
235  struct rte_ip_frag_death_row *dr,
236  struct rte_mbuf *mb, uint64_t tms, struct rte_ipv4_hdr *ip_hdr);
237 
246 static inline int
248 {
249  uint16_t flag_offset, ip_flag, ip_ofs;
250 
251  flag_offset = rte_be_to_cpu_16(hdr->fragment_offset);
252  ip_ofs = (uint16_t)(flag_offset & RTE_IPV4_HDR_OFFSET_MASK);
253  ip_flag = (uint16_t)(flag_offset & RTE_IPV4_HDR_MF_FLAG);
254 
255  return ip_flag != 0 || ip_ofs != 0;
256 }
257 
267  uint32_t prefetch);
268 
269 
278 void
279 rte_ip_frag_table_statistics_dump(FILE * f, const struct rte_ip_frag_tbl *tbl);
280 
291 __rte_experimental
292 void
293 rte_ip_frag_table_del_expired_entries(struct rte_ip_frag_tbl *tbl,
294  struct rte_ip_frag_death_row *dr, uint64_t tms);
295 
300 #define IP_FRAG_DEATH_ROW_LEN RTE_IP_FRAG_DEATH_ROW_LEN
301 
302 #define IP_FRAG_DEATH_ROW_MBUF_LEN RTE_IP_FRAG_DEATH_ROW_MBUF_LEN
303 
304 #define ipv6_extension_fragment rte_ipv6_fragment_ext
305 
307 #ifdef __cplusplus
308 }
309 #endif
310 
311 #endif /* _RTE_IP_FRAG_H_ */
struct rte_mbuf * row[RTE_IP_FRAG_DEATH_ROW_MBUF_LEN]
Definition: rte_ip_frag.h:40
struct rte_mbuf * rte_ipv4_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl, struct rte_ip_frag_death_row *dr, struct rte_mbuf *mb, uint64_t tms, struct rte_ipv4_hdr *ip_hdr)
rte_be16_t fragment_offset
Definition: rte_ip.h:58
static struct rte_ipv6_fragment_ext * rte_ipv6_frag_get_ipv6_fragment_header(struct rte_ipv6_hdr *hdr)
Definition: rte_ip_frag.h:143
void rte_ip_frag_table_destroy(struct rte_ip_frag_tbl *tbl)
void rte_ip_frag_free_death_row(struct rte_ip_frag_death_row *dr, uint32_t prefetch)
__rte_experimental void rte_ip_frag_table_del_expired_entries(struct rte_ip_frag_tbl *tbl, struct rte_ip_frag_death_row *dr, uint64_t tms)
__rte_experimental int32_t rte_ipv4_fragment_copy_nonseg_packet(struct rte_mbuf *pkt_in, struct rte_mbuf **pkts_out, uint16_t nb_pkts_out, uint16_t mtu_size, struct rte_mempool *pool_direct)
uint8_t proto
Definition: rte_ip.h:537
int32_t rte_ipv4_fragment_packet(struct rte_mbuf *pkt_in, struct rte_mbuf **pkts_out, uint16_t nb_pkts_out, uint16_t mtu_size, struct rte_mempool *pool_direct, struct rte_mempool *pool_indirect)
struct rte_ip_frag_tbl * rte_ip_frag_table_create(uint32_t bucket_num, uint32_t bucket_entries, uint32_t max_entries, uint64_t max_cycles, int socket_id)
static int rte_ipv4_frag_pkt_is_fragmented(const struct rte_ipv4_hdr *hdr)
Definition: rte_ip_frag.h:247
struct rte_mbuf * rte_ipv6_frag_reassemble_packet(struct rte_ip_frag_tbl *tbl, struct rte_ip_frag_death_row *dr, struct rte_mbuf *mb, uint64_t tms, struct rte_ipv6_hdr *ip_hdr, struct rte_ipv6_fragment_ext *frag_hdr)
#define RTE_IP_FRAG_DEATH_ROW_MBUF_LEN
Definition: rte_ip_frag.h:34
int32_t rte_ipv6_fragment_packet(struct rte_mbuf *pkt_in, struct rte_mbuf **pkts_out, uint16_t nb_pkts_out, uint16_t mtu_size, struct rte_mempool *pool_direct, struct rte_mempool *pool_indirect)
static uint16_t rte_be_to_cpu_16(rte_be16_t x)
void rte_ip_frag_table_statistics_dump(FILE *f, const struct rte_ip_frag_tbl *tbl)