2019-06-25 11:12:58 +00:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
* Copyright(c) 2017 Intel Corporation
|
2018-05-15 09:49:22 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _GRO_TCP4_H_
|
|
|
|
#define _GRO_TCP4_H_
|
|
|
|
|
2025-01-10 11:50:43 +00:00
|
|
|
#include "gro_tcp.h"
|
2019-06-25 11:12:58 +00:00
|
|
|
|
2018-05-15 09:49:22 +00:00
|
|
|
#define GRO_TCP4_TBL_MAX_ITEM_NUM (1024UL * 1024UL)
|
|
|
|
|
2025-01-10 11:50:43 +00:00
|
|
|
/* Header fields representing common fields in TCP flow */
|
2019-06-25 11:12:58 +00:00
|
|
|
struct tcp4_flow_key {
|
2025-01-10 11:50:43 +00:00
|
|
|
struct cmn_tcp_key cmn_key;
|
2018-05-15 09:49:22 +00:00
|
|
|
uint32_t ip_src_addr;
|
|
|
|
uint32_t ip_dst_addr;
|
|
|
|
};
|
|
|
|
|
2019-06-25 11:12:58 +00:00
|
|
|
struct gro_tcp4_flow {
|
|
|
|
struct tcp4_flow_key key;
|
2018-05-15 09:49:22 +00:00
|
|
|
/*
|
2019-06-25 11:12:58 +00:00
|
|
|
* The index of the first packet in the flow.
|
|
|
|
* INVALID_ARRAY_INDEX indicates an empty flow.
|
2018-05-15 09:49:22 +00:00
|
|
|
*/
|
|
|
|
uint32_t start_index;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* TCP/IPv4 reassembly table structure.
|
|
|
|
*/
|
|
|
|
struct gro_tcp4_tbl {
|
|
|
|
/* item array */
|
2025-01-10 11:50:43 +00:00
|
|
|
struct gro_tcp_item *items;
|
2019-06-25 11:12:58 +00:00
|
|
|
/* flow array */
|
|
|
|
struct gro_tcp4_flow *flows;
|
2018-05-15 09:49:22 +00:00
|
|
|
/* current item number */
|
|
|
|
uint32_t item_num;
|
2019-06-25 11:12:58 +00:00
|
|
|
/* current flow num */
|
|
|
|
uint32_t flow_num;
|
2018-05-15 09:49:22 +00:00
|
|
|
/* item array size */
|
|
|
|
uint32_t max_item_num;
|
2019-06-25 11:12:58 +00:00
|
|
|
/* flow array size */
|
|
|
|
uint32_t max_flow_num;
|
2018-05-15 09:49:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This function creates a TCP/IPv4 reassembly table.
|
|
|
|
*
|
|
|
|
* @param socket_id
|
2019-06-25 11:12:58 +00:00
|
|
|
* Socket index for allocating the TCP/IPv4 reassemble table
|
2018-05-15 09:49:22 +00:00
|
|
|
* @param max_flow_num
|
2019-06-25 11:12:58 +00:00
|
|
|
* The maximum number of flows in the TCP/IPv4 GRO table
|
2018-05-15 09:49:22 +00:00
|
|
|
* @param max_item_per_flow
|
2019-06-25 11:12:58 +00:00
|
|
|
* The maximum number of packets per flow
|
2018-05-15 09:49:22 +00:00
|
|
|
*
|
|
|
|
* @return
|
2019-06-25 11:12:58 +00:00
|
|
|
* - Return the table pointer on success.
|
|
|
|
* - Return NULL on failure.
|
2018-05-15 09:49:22 +00:00
|
|
|
*/
|
|
|
|
void *gro_tcp4_tbl_create(uint16_t socket_id,
|
|
|
|
uint16_t max_flow_num,
|
|
|
|
uint16_t max_item_per_flow);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This function destroys a TCP/IPv4 reassembly table.
|
|
|
|
*
|
|
|
|
* @param tbl
|
2019-06-25 11:12:58 +00:00
|
|
|
* Pointer pointing to the TCP/IPv4 reassembly table.
|
2018-05-15 09:49:22 +00:00
|
|
|
*/
|
|
|
|
void gro_tcp4_tbl_destroy(void *tbl);
|
|
|
|
|
|
|
|
/**
|
2019-06-25 11:12:58 +00:00
|
|
|
* This function merges a TCP/IPv4 packet. It doesn't process the packet,
|
|
|
|
* which has SYN, FIN, RST, PSH, CWR, ECE or URG set, or doesn't have
|
|
|
|
* payload.
|
2018-05-15 09:49:22 +00:00
|
|
|
*
|
2019-06-25 11:12:58 +00:00
|
|
|
* This function doesn't check if the packet has correct checksums and
|
|
|
|
* doesn't re-calculate checksums for the merged packet. Additionally,
|
|
|
|
* it assumes the packets are complete (i.e., MF==0 && frag_off==0),
|
|
|
|
* when IP fragmentation is possible (i.e., DF==0). It returns the
|
|
|
|
* packet, if the packet has invalid parameters (e.g. SYN bit is set)
|
|
|
|
* or there is no available space in the table.
|
2018-05-15 09:49:22 +00:00
|
|
|
*
|
|
|
|
* @param pkt
|
2019-06-25 11:12:58 +00:00
|
|
|
* Packet to reassemble
|
2018-05-15 09:49:22 +00:00
|
|
|
* @param tbl
|
2019-06-25 11:12:58 +00:00
|
|
|
* Pointer pointing to the TCP/IPv4 reassembly table
|
2018-05-15 09:49:22 +00:00
|
|
|
* @start_time
|
2019-06-25 11:12:58 +00:00
|
|
|
* The time when the packet is inserted into the table
|
2018-05-15 09:49:22 +00:00
|
|
|
*
|
|
|
|
* @return
|
2019-06-25 11:12:58 +00:00
|
|
|
* - Return a positive value if the packet is merged.
|
|
|
|
* - Return zero if the packet isn't merged but stored in the table.
|
|
|
|
* - Return a negative value for invalid parameters or no available
|
|
|
|
* space in the table.
|
2018-05-15 09:49:22 +00:00
|
|
|
*/
|
|
|
|
int32_t gro_tcp4_reassemble(struct rte_mbuf *pkt,
|
|
|
|
struct gro_tcp4_tbl *tbl,
|
|
|
|
uint64_t start_time);
|
|
|
|
|
|
|
|
/**
|
2019-06-25 11:12:58 +00:00
|
|
|
* This function flushes timeout packets in a TCP/IPv4 reassembly table,
|
|
|
|
* and without updating checksums.
|
2018-05-15 09:49:22 +00:00
|
|
|
*
|
|
|
|
* @param tbl
|
2019-06-25 11:12:58 +00:00
|
|
|
* TCP/IPv4 reassembly table pointer
|
2018-05-15 09:49:22 +00:00
|
|
|
* @param flush_timestamp
|
2019-06-25 11:12:58 +00:00
|
|
|
* Flush packets which are inserted into the table before or at the
|
|
|
|
* flush_timestamp.
|
2018-05-15 09:49:22 +00:00
|
|
|
* @param out
|
2019-06-25 11:12:58 +00:00
|
|
|
* Pointer array used to keep flushed packets
|
2018-05-15 09:49:22 +00:00
|
|
|
* @param nb_out
|
2019-06-25 11:12:58 +00:00
|
|
|
* The element number in 'out'. It also determines the maximum number of
|
2018-05-15 09:49:22 +00:00
|
|
|
* packets that can be flushed finally.
|
|
|
|
*
|
|
|
|
* @return
|
2019-06-25 11:12:58 +00:00
|
|
|
* The number of flushed packets
|
2018-05-15 09:49:22 +00:00
|
|
|
*/
|
|
|
|
uint16_t gro_tcp4_tbl_timeout_flush(struct gro_tcp4_tbl *tbl,
|
|
|
|
uint64_t flush_timestamp,
|
|
|
|
struct rte_mbuf **out,
|
|
|
|
uint16_t nb_out);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This function returns the number of the packets in a TCP/IPv4
|
|
|
|
* reassembly table.
|
|
|
|
*
|
|
|
|
* @param tbl
|
2019-06-25 11:12:58 +00:00
|
|
|
* TCP/IPv4 reassembly table pointer
|
2018-05-15 09:49:22 +00:00
|
|
|
*
|
|
|
|
* @return
|
2019-06-25 11:12:58 +00:00
|
|
|
* The number of packets in the table
|
2018-05-15 09:49:22 +00:00
|
|
|
*/
|
|
|
|
uint32_t gro_tcp4_tbl_pkt_count(void *tbl);
|
2019-06-25 11:12:58 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Check if two TCP/IPv4 packets belong to the same flow.
|
|
|
|
*/
|
|
|
|
static inline int
|
|
|
|
is_same_tcp4_flow(struct tcp4_flow_key k1, struct tcp4_flow_key k2)
|
|
|
|
{
|
2025-01-10 11:50:43 +00:00
|
|
|
return ((k1.ip_src_addr == k2.ip_src_addr) &&
|
2019-06-25 11:12:58 +00:00
|
|
|
(k1.ip_dst_addr == k2.ip_dst_addr) &&
|
2025-01-10 11:50:43 +00:00
|
|
|
is_same_common_tcp_key(&k1.cmn_key, &k2.cmn_key));
|
2019-06-25 11:12:58 +00:00
|
|
|
}
|
|
|
|
|
2018-05-15 09:49:22 +00:00
|
|
|
#endif
|