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

#ifndef ROHC_DECOMPRESSOR_H
#define ROHC_DECOMPRESSOR_H

#include <linux/types.h>
#include <linux/vmalloc.h>

#include "rohc.h"
#include "net_buf.h"

#define MAX_DECOMPRESSOR_NUM (8) // support at most 8 dedecompressors
typedef u8 rohc_decomp_id_t;

typedef enum {
	ROHC_DECOMP_SUCCESS = 0,
	ROHC_DECOMP_CID_ERROR = 1,
	ROHC_DECOMP_PACKER_TYPE_ERROR = 2,
	ROHC_DECOMP_INPUT_BUFFER_ERROR = 3,
	ROHC_DECOMP_OUTPUT_BUFFER_ERROR = 4,
	ROHC_DECOMP_INVALID_CID = 5,
	ROHC_DECOMP_NO_CONTEXT = 6,
	ROHC_DECOMP_PROFILE_NOT_SUPPORT = 7,
	ROHC_DECOMP_INVALID_COMPRESSOR = 8,
	ROHC_DECOMP_BAD_CRC = 9,
	ROHC_DECOMP_WLSB_DECODE_FAIL = 10,
	ROHC_DECOMP_BUILD_NET_PACKET_FAIL = 11,
	ROHC_DECOMP_ERROR,
} rohc_decomp_status_t;

typedef struct {
	bool en_ip_dyn_ext_1_byte_filed;
} aux_decomp_config_t;

rohc_decomp_status_t rohc_decomp_decompress(
		const rohc_decomp_id_t decomp_idx,
		net_buf_t *const decomp_pkt,
		const net_buf_t  rohc_pkt);

rohc_decomp_id_t rohc_decomp_allocate_decompressor(
		const rohc_cid_type_t cid_type,
		const u8 max_cid,
		const aux_decomp_config_t aux_cfg);

void rohc_decomp_release_decompressor(
		const rohc_decomp_id_t decomp_idx);

#endif /* ROHC_DECOMPRESSOR_H */

