Blame src/vma/lwip/cc.h

Packit 6d2c1b
/*-
Packit 6d2c1b
 * Copyright (c) 2007-2008
Packit 6d2c1b
 * 	Swinburne University of Technology, Melbourne, Australia.
Packit 6d2c1b
 * Copyright (c) 2009-2010 Lawrence Stewart <lstewart@freebsd.org>
Packit 6d2c1b
 * Copyright (c) 2010 The FreeBSD Foundation
Packit 6d2c1b
 * All rights reserved.
Packit 6d2c1b
 *
Packit 6d2c1b
 * This software was developed at the Centre for Advanced Internet
Packit 6d2c1b
 * Architectures, Swinburne University of Technology, by Lawrence Stewart and
Packit 6d2c1b
 * James Healy, made possible in part by a grant from the Cisco University
Packit 6d2c1b
 * Research Program Fund at Community Foundation Silicon Valley.
Packit 6d2c1b
 *
Packit 6d2c1b
 * Portions of this software were developed at the Centre for Advanced
Packit 6d2c1b
 * Internet Architectures, Swinburne University of Technology, Melbourne,
Packit 6d2c1b
 * Australia by David Hayes under sponsorship from the FreeBSD Foundation.
Packit 6d2c1b
 *
Packit 6d2c1b
 * Redistribution and use in source and binary forms, with or without
Packit 6d2c1b
 * modification, are permitted provided that the following conditions
Packit 6d2c1b
 * are met:
Packit 6d2c1b
 * 1. Redistributions of source code must retain the above copyright
Packit 6d2c1b
 *    notice, this list of conditions and the following disclaimer.
Packit 6d2c1b
 * 2. Redistributions in binary form must reproduce the above copyright
Packit 6d2c1b
 *    notice, this list of conditions and the following disclaimer in the
Packit 6d2c1b
 *    documentation and/or other materials provided with the distribution.
Packit 6d2c1b
 *
Packit 6d2c1b
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
Packit 6d2c1b
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Packit 6d2c1b
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
Packit 6d2c1b
 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
Packit 6d2c1b
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Packit 6d2c1b
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
Packit 6d2c1b
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
Packit 6d2c1b
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
Packit 6d2c1b
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
Packit 6d2c1b
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
Packit 6d2c1b
 * SUCH DAMAGE.
Packit 6d2c1b
 *
Packit 6d2c1b
 * $FreeBSD$
Packit 6d2c1b
 */
Packit 6d2c1b
Packit 6d2c1b
/*
Packit 6d2c1b
 * This software was first released in 2007 by James Healy and Lawrence Stewart
Packit 6d2c1b
 * whilst working on the NewTCP research project at Swinburne University of
Packit 6d2c1b
 * Technology's Centre for Advanced Internet Architectures, Melbourne,
Packit 6d2c1b
 * Australia, which was made possible in part by a grant from the Cisco
Packit 6d2c1b
 * University Research Program Fund at Community Foundation Silicon Valley.
Packit 6d2c1b
 * More details are available at:
Packit 6d2c1b
 *   http://caia.swin.edu.au/urp/newtcp/
Packit 6d2c1b
 */
Packit 6d2c1b
Packit 6d2c1b
/*
Packit 6d2c1b
 * Copyright (c) 2001-2020 Mellanox Technologies, Ltd. All rights reserved.
Packit 6d2c1b
 *
Packit 6d2c1b
 * This software is available to you under a choice of one of two
Packit 6d2c1b
 * licenses.  You may choose to be licensed under the terms of the GNU
Packit 6d2c1b
 * General Public License (GPL) Version 2, available from the file
Packit 6d2c1b
 * COPYING in the main directory of this source tree, or the
Packit 6d2c1b
 * BSD license below:
Packit 6d2c1b
 *
Packit 6d2c1b
 *     Redistribution and use in source and binary forms, with or
Packit 6d2c1b
 *     without modification, are permitted provided that the following
Packit 6d2c1b
 *     conditions are met:
Packit 6d2c1b
 *
Packit 6d2c1b
 *      - Redistributions of source code must retain the above
Packit 6d2c1b
 *        copyright notice, this list of conditions and the following
Packit 6d2c1b
 *        disclaimer.
Packit 6d2c1b
 *
Packit 6d2c1b
 *      - Redistributions in binary form must reproduce the above
Packit 6d2c1b
 *        copyright notice, this list of conditions and the following
Packit 6d2c1b
 *        disclaimer in the documentation and/or other materials
Packit 6d2c1b
 *        provided with the distribution.
Packit 6d2c1b
 *
Packit 6d2c1b
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
Packit 6d2c1b
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
Packit 6d2c1b
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
Packit 6d2c1b
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
Packit 6d2c1b
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
Packit 6d2c1b
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
Packit 6d2c1b
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
Packit 6d2c1b
 * SOFTWARE.
Packit 6d2c1b
 */
Packit 6d2c1b
Packit 6d2c1b
#ifndef CC_H_
Packit 6d2c1b
#define CC_H_
Packit 6d2c1b
Packit 6d2c1b
Packit 6d2c1b
struct cc_algo;
Packit 6d2c1b
struct tcp_pcb;
Packit 6d2c1b
Packit 6d2c1b
#include <stdint.h>
Packit 6d2c1b
Packit 6d2c1b
/* types of different cc algorithms */
Packit 6d2c1b
enum cc_algo_mod {
Packit 6d2c1b
	CC_MOD_LWIP,
Packit 6d2c1b
	CC_MOD_CUBIC,
Packit 6d2c1b
	CC_MOD_NONE
Packit 6d2c1b
};
Packit 6d2c1b
Packit 6d2c1b
/* ACK types passed to the ack_received() hook. */
Packit 6d2c1b
#define	CC_ACK		0x0001	/* Regular in sequence ACK. */
Packit 6d2c1b
#define	CC_DUPACK	0x0002	/* Duplicate ACK. */
Packit 6d2c1b
#define	CC_PARTIALACK	0x0004	/* Not yet. */
Packit 6d2c1b
#define	CC_SACK		0x0008	/* Not yet. */
Packit 6d2c1b
Packit 6d2c1b
/*
Packit 6d2c1b
 * Congestion signal types passed to the cong_signal() hook. The highest order 8
Packit 6d2c1b
 * bits (0x01000000 - 0x80000000) are reserved for CC algos to declare their own
Packit 6d2c1b
 * congestion signal types.
Packit 6d2c1b
 */
Packit 6d2c1b
#define	CC_ECN		0x00000001	/* ECN marked packet received. */
Packit 6d2c1b
#define	CC_RTO		0x00000002	/* RTO fired. */
Packit 6d2c1b
#define	CC_RTO_ERR	0x00000004	/* RTO fired in error. */
Packit 6d2c1b
#define	CC_NDUPACK	0x00000008	/* Threshold of dupack's reached. */
Packit 6d2c1b
Packit 6d2c1b
#define	CC_SIGPRIVMASK	0xFF000000	/* Mask to check if sig is private. */
Packit 6d2c1b
Packit 6d2c1b
Packit 6d2c1b
#define	TCP_CA_NAME_MAX	16	/* max congestion control name length */
Packit 6d2c1b
Packit 6d2c1b
/*
Packit 6d2c1b
 * Structure to hold data and function pointers that together represent a
Packit 6d2c1b
 * congestion control algorithm.
Packit 6d2c1b
 */
Packit 6d2c1b
struct cc_algo {
Packit 6d2c1b
	char	name[TCP_CA_NAME_MAX];
Packit 6d2c1b
Packit 6d2c1b
	/* Init cc_data */
Packit 6d2c1b
	int	(*init)(struct tcp_pcb *pcb);
Packit 6d2c1b
Packit 6d2c1b
	/* Destroy cc_data */
Packit 6d2c1b
	void	(*destroy)(struct tcp_pcb *pcb);
Packit 6d2c1b
Packit 6d2c1b
	/* Init variables for a newly established connection. */
Packit 6d2c1b
	void	(*conn_init)(struct tcp_pcb *pcb);
Packit 6d2c1b
Packit 6d2c1b
	/* Called on receipt of an ack. */
Packit 6d2c1b
	void	(*ack_received)(struct tcp_pcb *pcb, uint16_t type);
Packit 6d2c1b
Packit 6d2c1b
	/* Called on detection of a congestion signal. */
Packit 6d2c1b
	void	(*cong_signal)(struct tcp_pcb *pcb, uint32_t type);
Packit 6d2c1b
Packit 6d2c1b
	/* Called after exiting congestion recovery. */
Packit 6d2c1b
	void	(*post_recovery)(struct tcp_pcb *pcb);
Packit 6d2c1b
Packit 6d2c1b
	/* Called when data transfer resumes after an idle period. */
Packit 6d2c1b
	void	(*after_idle)(struct tcp_pcb *pcb);
Packit 6d2c1b
Packit 6d2c1b
};
Packit 6d2c1b
Packit 6d2c1b
extern struct cc_algo lwip_cc_algo;
Packit 6d2c1b
extern struct cc_algo cubic_cc_algo;
Packit 6d2c1b
extern struct cc_algo none_cc_algo;
Packit 6d2c1b
Packit 6d2c1b
void cc_init(struct tcp_pcb *pcb);
Packit 6d2c1b
void cc_destroy(struct tcp_pcb *pcb);
Packit 6d2c1b
void cc_ack_received(struct tcp_pcb *pcb, uint16_t type);
Packit 6d2c1b
void cc_conn_init(struct tcp_pcb *pcb);
Packit 6d2c1b
void cc_cong_signal(struct tcp_pcb *pcb, uint32_t type);
Packit 6d2c1b
void cc_post_recovery(struct tcp_pcb *pcb);
Packit 6d2c1b
Packit 6d2c1b
#endif /* CC_H_ */