DPDK  21.02.0
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 
30 enum {
34  IP_MAX_FRAG_NUM = RTE_LIBRTE_IP_FRAG_MAX_FRAG,
36 };
37 
39 struct ip_frag {
40  uint16_t ofs;
41  uint16_t len;
42  struct rte_mbuf *mb;
43 };
44 
46 struct ip_frag_key {
47  uint64_t src_dst[4];
50  union {
51  uint64_t id_key_len;
52  __extension__
53  struct {
54  uint32_t id;
55  uint32_t key_len;
56  };
57  };
58 };
59 
64 struct ip_frag_pkt {
65  TAILQ_ENTRY(ip_frag_pkt) lru;
66  struct ip_frag_key key;
67  uint64_t start;
68  uint32_t total_size;
69  uint32_t frag_size;
70  uint32_t last_idx;
71  struct ip_frag frags[IP_MAX_FRAG_NUM];
73 
74 #define IP_FRAG_DEATH_ROW_LEN 32
76 /* death row size in mbufs */
77 #define IP_FRAG_DEATH_ROW_MBUF_LEN (IP_FRAG_DEATH_ROW_LEN * (IP_MAX_FRAG_NUM + 1))
78 
81  uint32_t cnt;
82  struct rte_mbuf *row[IP_FRAG_DEATH_ROW_MBUF_LEN];
84 };
85 
86 TAILQ_HEAD(ip_pkt_list, ip_frag_pkt);
90  uint64_t find_num;
91  uint64_t add_num;
92  uint64_t del_num;
93  uint64_t reuse_num;
94  uint64_t fail_total;
95  uint64_t fail_nospace;
97 
100  uint64_t max_cycles;
101  uint32_t entry_mask;
102  uint32_t max_entries;
103  uint32_t use_entries;
104  uint32_t bucket_entries;
105  uint32_t nb_entries;
106  uint32_t nb_buckets;
107  struct ip_frag_pkt *last;
108  struct ip_pkt_list lru;
109  struct ip_frag_tbl_stat stat;
110  __extension__ struct ip_frag_pkt pkt[0];
111 };
112 
113 /* struct ipv6_extension_fragment moved to librte_net/rte_ip.h and renamed. */
114 #define ipv6_extension_fragment rte_ipv6_fragment_ext
115 
135 struct rte_ip_frag_tbl * rte_ip_frag_table_create(uint32_t bucket_num,
136  uint32_t bucket_entries, uint32_t max_entries,
137  uint64_t max_cycles, int socket_id);
138 
145 void
147 
169 int32_t
170 rte_ipv6_fragment_packet(struct rte_mbuf *pkt_in,
171  struct rte_mbuf **pkts_out,
172  uint16_t nb_pkts_out,
173  uint16_t mtu_size,
174  struct rte_mempool *pool_direct,
175  struct rte_mempool *pool_indirect);
176 
199  struct rte_ip_frag_death_row *dr,
200  struct rte_mbuf *mb, uint64_t tms, struct rte_ipv6_hdr *ip_hdr,
201  struct ipv6_extension_fragment *frag_hdr);
202 
214 static inline struct ipv6_extension_fragment *
216 {
217  if (hdr->proto == IPPROTO_FRAGMENT) {
218  return (struct ipv6_extension_fragment *) ++hdr;
219  }
220  else
221  return NULL;
222 }
223 
247 int32_t rte_ipv4_fragment_packet(struct rte_mbuf *pkt_in,
248  struct rte_mbuf **pkts_out,
249  uint16_t nb_pkts_out, uint16_t mtu_size,
250  struct rte_mempool *pool_direct,
251  struct rte_mempool *pool_indirect);
252 
273  struct rte_ip_frag_death_row *dr,
274  struct rte_mbuf *mb, uint64_t tms, struct rte_ipv4_hdr *ip_hdr);
275 
284 static inline int
286 {
287  uint16_t flag_offset, ip_flag, ip_ofs;
288 
289  flag_offset = rte_be_to_cpu_16(hdr->fragment_offset);
290  ip_ofs = (uint16_t)(flag_offset & RTE_IPV4_HDR_OFFSET_MASK);
291  ip_flag = (uint16_t)(flag_offset & RTE_IPV4_HDR_MF_FLAG);
292 
293  return ip_flag != 0 || ip_ofs != 0;
294 }
295 
305  uint32_t prefetch);
306 
307 
316 void
317 rte_ip_frag_table_statistics_dump(FILE * f, const struct rte_ip_frag_tbl *tbl);
318 
329 __rte_experimental
330 void
332  struct rte_ip_frag_death_row *dr, uint64_t tms);
333 
334 #ifdef __cplusplus
335 }
336 #endif
337 
338 #endif /* _RTE_IP_FRAG_H_ */
static struct ipv6_extension_fragment * rte_ipv6_frag_get_ipv6_fragment_header(struct rte_ipv6_hdr *hdr)
Definition: rte_ip_frag.h:215
uint32_t entry_mask
Definition: rte_ip_frag.h:101
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:38
__rte_experimental void rte_frag_table_del_expired_entries(struct rte_ip_frag_tbl *tbl, struct rte_ip_frag_death_row *dr, uint64_t tms)
uint32_t nb_entries
Definition: rte_ip_frag.h:105
void rte_ip_frag_table_destroy(struct rte_ip_frag_tbl *tbl)
uint64_t del_num
Definition: rte_ip_frag.h:92
void rte_ip_frag_free_death_row(struct rte_ip_frag_death_row *dr, uint32_t prefetch)
uint32_t nb_buckets
Definition: rte_ip_frag.h:106
uint64_t fail_nospace
Definition: rte_ip_frag.h:95
uint32_t bucket_entries
Definition: rte_ip_frag.h:104
uint64_t reuse_num
Definition: rte_ip_frag.h:93
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 ipv6_extension_fragment *frag_hdr)
uint64_t add_num
Definition: rte_ip_frag.h:91
uint8_t proto
Definition: rte_ip.h:390
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)
uint32_t max_entries
Definition: rte_ip_frag.h:102
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)
uint32_t use_entries
Definition: rte_ip_frag.h:103
#define __rte_cache_aligned
Definition: rte_common.h:400
uint64_t max_cycles
Definition: rte_ip_frag.h:100
static int rte_ipv4_frag_pkt_is_fragmented(const struct rte_ipv4_hdr *hdr)
Definition: rte_ip_frag.h:285
#define RTE_STD_C11
Definition: rte_common.h:40
struct ip_frag_pkt * last
Definition: rte_ip_frag.h:107
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)
TAILQ_HEAD(vdev_driver_list, rte_vdev_driver)
uint64_t fail_total
Definition: rte_ip_frag.h:94
static uint16_t rte_be_to_cpu_16(rte_be16_t x)
uint64_t find_num
Definition: rte_ip_frag.h:90
void rte_ip_frag_table_statistics_dump(FILE *f, const struct rte_ip_frag_tbl *tbl)