199a2dd95SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause 299a2dd95SBruce Richardson * Copyright(c) 2018 Intel Corporation 399a2dd95SBruce Richardson */ 499a2dd95SBruce Richardson 599a2dd95SBruce Richardson #ifndef _GRO_VXLAN_TCP4_H_ 699a2dd95SBruce Richardson #define _GRO_VXLAN_TCP4_H_ 799a2dd95SBruce Richardson 899a2dd95SBruce Richardson #include "gro_tcp4.h" 999a2dd95SBruce Richardson 1099a2dd95SBruce Richardson #define GRO_VXLAN_TCP4_TBL_MAX_ITEM_NUM (1024UL * 1024UL) 1199a2dd95SBruce Richardson 1299a2dd95SBruce Richardson /* Header fields representing a VxLAN flow */ 1399a2dd95SBruce Richardson struct vxlan_tcp4_flow_key { 1499a2dd95SBruce Richardson struct tcp4_flow_key inner_key; 1599a2dd95SBruce Richardson struct rte_vxlan_hdr vxlan_hdr; 1699a2dd95SBruce Richardson 1799a2dd95SBruce Richardson struct rte_ether_addr outer_eth_saddr; 1899a2dd95SBruce Richardson struct rte_ether_addr outer_eth_daddr; 1999a2dd95SBruce Richardson 2099a2dd95SBruce Richardson uint32_t outer_ip_src_addr; 2199a2dd95SBruce Richardson uint32_t outer_ip_dst_addr; 2299a2dd95SBruce Richardson 2399a2dd95SBruce Richardson /* Outer UDP ports */ 2499a2dd95SBruce Richardson uint16_t outer_src_port; 2599a2dd95SBruce Richardson uint16_t outer_dst_port; 2699a2dd95SBruce Richardson 2799a2dd95SBruce Richardson }; 2899a2dd95SBruce Richardson 2999a2dd95SBruce Richardson struct gro_vxlan_tcp4_flow { 3099a2dd95SBruce Richardson struct vxlan_tcp4_flow_key key; 3199a2dd95SBruce Richardson /* 3299a2dd95SBruce Richardson * The index of the first packet in the flow. INVALID_ARRAY_INDEX 3399a2dd95SBruce Richardson * indicates an empty flow. 3499a2dd95SBruce Richardson */ 3599a2dd95SBruce Richardson uint32_t start_index; 3699a2dd95SBruce Richardson }; 3799a2dd95SBruce Richardson 3899a2dd95SBruce Richardson struct gro_vxlan_tcp4_item { 39*5c55e819SKumara Parameshwaran struct gro_tcp_item inner_item; 4099a2dd95SBruce Richardson /* IPv4 ID in the outer IPv4 header */ 4199a2dd95SBruce Richardson uint16_t outer_ip_id; 4299a2dd95SBruce Richardson /* Indicate if outer IPv4 ID can be ignored */ 4399a2dd95SBruce Richardson uint8_t outer_is_atomic; 4499a2dd95SBruce Richardson }; 4599a2dd95SBruce Richardson 4699a2dd95SBruce Richardson /* 4799a2dd95SBruce Richardson * VxLAN (with an outer IPv4 header and an inner TCP/IPv4 packet) 4899a2dd95SBruce Richardson * reassembly table structure 4999a2dd95SBruce Richardson */ 5099a2dd95SBruce Richardson struct gro_vxlan_tcp4_tbl { 5199a2dd95SBruce Richardson /* item array */ 5299a2dd95SBruce Richardson struct gro_vxlan_tcp4_item *items; 5399a2dd95SBruce Richardson /* flow array */ 5499a2dd95SBruce Richardson struct gro_vxlan_tcp4_flow *flows; 5599a2dd95SBruce Richardson /* current item number */ 5699a2dd95SBruce Richardson uint32_t item_num; 5799a2dd95SBruce Richardson /* current flow number */ 5899a2dd95SBruce Richardson uint32_t flow_num; 5999a2dd95SBruce Richardson /* the maximum item number */ 6099a2dd95SBruce Richardson uint32_t max_item_num; 6199a2dd95SBruce Richardson /* the maximum flow number */ 6299a2dd95SBruce Richardson uint32_t max_flow_num; 6399a2dd95SBruce Richardson }; 6499a2dd95SBruce Richardson 6599a2dd95SBruce Richardson /** 6699a2dd95SBruce Richardson * This function creates a VxLAN reassembly table for VxLAN packets 6799a2dd95SBruce Richardson * which have an outer IPv4 header and an inner TCP/IPv4 packet. 6899a2dd95SBruce Richardson * 6999a2dd95SBruce Richardson * @param socket_id 7099a2dd95SBruce Richardson * Socket index for allocating the table 7199a2dd95SBruce Richardson * @param max_flow_num 7299a2dd95SBruce Richardson * The maximum number of flows in the table 7399a2dd95SBruce Richardson * @param max_item_per_flow 7499a2dd95SBruce Richardson * The maximum number of packets per flow 7599a2dd95SBruce Richardson * 7699a2dd95SBruce Richardson * @return 7799a2dd95SBruce Richardson * - Return the table pointer on success. 7899a2dd95SBruce Richardson * - Return NULL on failure. 7999a2dd95SBruce Richardson */ 8099a2dd95SBruce Richardson void *gro_vxlan_tcp4_tbl_create(uint16_t socket_id, 8199a2dd95SBruce Richardson uint16_t max_flow_num, 8299a2dd95SBruce Richardson uint16_t max_item_per_flow); 8399a2dd95SBruce Richardson 8499a2dd95SBruce Richardson /** 8599a2dd95SBruce Richardson * This function destroys a VxLAN reassembly table. 8699a2dd95SBruce Richardson * 8799a2dd95SBruce Richardson * @param tbl 8899a2dd95SBruce Richardson * Pointer pointing to the VxLAN reassembly table 8999a2dd95SBruce Richardson */ 9099a2dd95SBruce Richardson void gro_vxlan_tcp4_tbl_destroy(void *tbl); 9199a2dd95SBruce Richardson 9299a2dd95SBruce Richardson /** 9399a2dd95SBruce Richardson * This function merges a VxLAN packet which has an outer IPv4 header and 9499a2dd95SBruce Richardson * an inner TCP/IPv4 packet. It doesn't process the packet, whose TCP 9599a2dd95SBruce Richardson * header has SYN, FIN, RST, PSH, CWR, ECE or URG bit set, or which 9699a2dd95SBruce Richardson * doesn't have payload. 9799a2dd95SBruce Richardson * 9899a2dd95SBruce Richardson * This function doesn't check if the packet has correct checksums and 9999a2dd95SBruce Richardson * doesn't re-calculate checksums for the merged packet. Additionally, 10099a2dd95SBruce Richardson * it assumes the packets are complete (i.e., MF==0 && frag_off==0), when 10199a2dd95SBruce Richardson * IP fragmentation is possible (i.e., DF==0). It returns the packet, if 10299a2dd95SBruce Richardson * the packet has invalid parameters (e.g. SYN bit is set) or there is no 10399a2dd95SBruce Richardson * available space in the table. 10499a2dd95SBruce Richardson * 10599a2dd95SBruce Richardson * @param pkt 10699a2dd95SBruce Richardson * Packet to reassemble 10799a2dd95SBruce Richardson * @param tbl 10899a2dd95SBruce Richardson * Pointer pointing to the VxLAN reassembly table 10999a2dd95SBruce Richardson * @start_time 11099a2dd95SBruce Richardson * The time when the packet is inserted into the table 11199a2dd95SBruce Richardson * 11299a2dd95SBruce Richardson * @return 11399a2dd95SBruce Richardson * - Return a positive value if the packet is merged. 11499a2dd95SBruce Richardson * - Return zero if the packet isn't merged but stored in the table. 11599a2dd95SBruce Richardson * - Return a negative value for invalid parameters or no available 11699a2dd95SBruce Richardson * space in the table. 11799a2dd95SBruce Richardson */ 11899a2dd95SBruce Richardson int32_t gro_vxlan_tcp4_reassemble(struct rte_mbuf *pkt, 11999a2dd95SBruce Richardson struct gro_vxlan_tcp4_tbl *tbl, 12099a2dd95SBruce Richardson uint64_t start_time); 12199a2dd95SBruce Richardson 12299a2dd95SBruce Richardson /** 12399a2dd95SBruce Richardson * This function flushes timeout packets in the VxLAN reassembly table, 12499a2dd95SBruce Richardson * and without updating checksums. 12599a2dd95SBruce Richardson * 12699a2dd95SBruce Richardson * @param tbl 12799a2dd95SBruce Richardson * Pointer pointing to a VxLAN GRO table 12899a2dd95SBruce Richardson * @param flush_timestamp 12999a2dd95SBruce Richardson * This function flushes packets which are inserted into the table 13099a2dd95SBruce Richardson * before or at the flush_timestamp. 13199a2dd95SBruce Richardson * @param out 13299a2dd95SBruce Richardson * Pointer array used to keep flushed packets 13399a2dd95SBruce Richardson * @param nb_out 13499a2dd95SBruce Richardson * The element number in 'out'. It also determines the maximum number of 13599a2dd95SBruce Richardson * packets that can be flushed finally. 13699a2dd95SBruce Richardson * 13799a2dd95SBruce Richardson * @return 13899a2dd95SBruce Richardson * The number of flushed packets 13999a2dd95SBruce Richardson */ 14099a2dd95SBruce Richardson uint16_t gro_vxlan_tcp4_tbl_timeout_flush(struct gro_vxlan_tcp4_tbl *tbl, 14199a2dd95SBruce Richardson uint64_t flush_timestamp, 14299a2dd95SBruce Richardson struct rte_mbuf **out, 14399a2dd95SBruce Richardson uint16_t nb_out); 14499a2dd95SBruce Richardson 14599a2dd95SBruce Richardson /** 14699a2dd95SBruce Richardson * This function returns the number of the packets in a VxLAN 14799a2dd95SBruce Richardson * reassembly table. 14899a2dd95SBruce Richardson * 14999a2dd95SBruce Richardson * @param tbl 15099a2dd95SBruce Richardson * Pointer pointing to the VxLAN reassembly table 15199a2dd95SBruce Richardson * 15299a2dd95SBruce Richardson * @return 15399a2dd95SBruce Richardson * The number of packets in the table 15499a2dd95SBruce Richardson */ 15599a2dd95SBruce Richardson uint32_t gro_vxlan_tcp4_tbl_pkt_count(void *tbl); 15699a2dd95SBruce Richardson #endif 157