/* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */
/*
 * Copyright (c) 2021 MediaTek Inc.
 */

#ifndef ROHC_DECOMPRESS_INTERNAL_H
#define ROHC_DECOMPRESS_INTERNAL_H

#ifdef __cplusplus
extern "C"
{
#endif

#include "rohc_packet.h"
#include "rohc_decomp.h"
#include "rohc_decomp_network.h"
#include "net_buf.h"

#define DFL_PERIODIC_IR_DOWN_TRANS_TIMEOUT (500U)
#define DFL_PERIODIC_FO_DOWN_TRANS_TIMEOUT (100U)
#define DEFAULT_CONTEXT_NUM_PER_COMPRESSOR (32U) //by default, decompressor support 32 streams.
#define MAX_CONTEXT_NUM_PER_COMPRESSOR (128U) // each decompressor support at most 128 streams

typedef enum {
	NON_CID_SECOND_OCTECT_INDEX_1 = 0X1,
	NON_CID_SECOND_OCTECT_INDEX_2 = 0X2,
} rohc_non_cid_2nd_octect_index_t;

typedef struct {
	u8 max_cid;
	rohc_cid_type_t cid_type;
	u32 wlsb_sn_win_capacity;
	u32 wlsb_ip_id_win_capacity;
	u32 perodic_ir_timeout_cnt;
	u32 perodic_fo_timeout_cnt;
} rohc_decomp_config_t;

typedef struct {
	bool in_use;
	bool en_ip_dyn_ext_field;
	u8 cid;
	u8 header_size;
	rohc_packet_t packet_type;
	network_context_t net_ctx;
} rohc_decomp_context_t;

typedef struct {
	u16 total_num;
	size_t *lru_record;
	rohc_decomp_context_t *ctx_array;
} rohc_decomp_context_management_t;

typedef struct {
	bool in_use;
	u8 max_cid;
	rohc_cid_type_t cid_type;
	aux_decomp_config_t aux_cfg;
	rohc_decomp_context_management_t ctx_mm;
} rohc_decompressor_t;

rohc_decomp_status_t rohc_decomp_priv_decompress(
		rohc_decompressor_t *decomp,
		net_buf_t *uncomp_pkt,
		net_buf_t rohc_pkt);

#endif /* ROHC_DECOMPRESS_INTERNAL_H */
