blob: 8c1716f520d6885dbd6c5a960653f6a70dcefe1e [file] [log] [blame]
/*****************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2018
*
* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/
/*******************************************************************************
* Filename:
* ---------
* dpfm_struct.h
*
* Project:
* --------
* VMOLY
*
* Description:
* ------------
*
*
* Author:
* -------
* -------
*
*==============================================================================
* HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* removed!
*
* removed!
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*==============================================================================
*******************************************************************************/
#ifndef __DPFM_STRUCT_H
#define __DPFM_STRUCT_H
#include "hif_lhif.h"
/*------------------------------------------------------------------------------
* Constant definition.
*----------------------------------------------------------------------------*/
#define DPFM_MAX_FILTER_CNT 128
#define DPFM_MAX_LAN_DEV_USER_NUM 16
#define DPFM_HASH_TABLE_SIZE 128
#define DPFM_MAX_HW_FILTER_CNT 128
#define DPFM_MAX_HW_CMD_CNT 128
#define DPFM_DECLARE_OBJECT \
kal_int32 ref_count; \
kal_int32 reader_cnt; \
kal_int32 writer_cnt;
/*------------------------------------------------------------------------------
* Data Structure.
*----------------------------------------------------------------------------*/
typedef struct _dpfm_ipv4_rule_t {
kal_uint32 private_ip;
kal_uint32 public_ip;
kal_uint32 remote_ip;
kal_uint16 private_port;
kal_uint16 public_port;
kal_uint16 remote_port;
kal_uint8 protocol;
kal_uint8 reserved;
kal_uint32 lan_netif_id;
kal_uint32 wan_netif_id;
} dpfm_ipv4_rule_t;
typedef struct _dpfm_ipv6_rule_t {
kal_uint32 private_ip[4];
kal_uint32 remote_ip[4];
kal_uint16 private_port;
kal_uint16 remote_port;
kal_uint8 protocol;
kal_uint8 reserved[3];
kal_uint32 lan_netif_id;
kal_uint32 wan_netif_id;
} dpfm_ipv6_rule_t;
typedef struct _dpfm_tag_packet_t {
kal_uint16 guard_pattern;
kal_uint8 version;
kal_uint8 tag_len;
union {
struct {
kal_uint8 in_netif_id;
kal_uint8 out_netif_id;
kal_uint16 port;
} v1;
struct {
kal_uint8 tag_info;
kal_uint8 reserved;
kal_uint16 port;
kal_uint32 lan_netif_id;
kal_uint32 ip;
} v2;
} type;
} dpfm_tag_packet_t;
typedef struct _dpfm_lan_dev_info_t {
kal_uint32 netif_id;
kal_uint8 net_type;
kal_bool (*notify_add_rule)(kal_int16 filter_id, kal_uint8 *tag);
kal_bool (*notify_match_rule)(kal_bool is_uplink, kal_int16 filter_id);
kal_bool (*notify_del_rule)(kal_int16 filter_id);
} dpfm_lan_dev_info_t;
typedef struct _dpfm_filter_t {
DPFM_DECLARE_OBJECT
kal_int16 id;
kal_uint8 ip_type;
kal_uint8 reserved;
union {
dpfm_ipv4_rule_t ipv4_rule;
dpfm_ipv6_rule_t ipv6_rule;
} rule;
kal_uint32 lan_netif_id;
kal_uint32 wan_netif_id;
struct _dpfm_filter_t *next_filter[2];
kal_uint32 last_access_time;
dpfm_filter_state_e state;
} dpfm_filter_t;
typedef struct _dpfm_ipv6_filter_t {
DPFM_DECLARE_OBJECT
kal_uint32 ip[4];
kal_uint8 is_valid;
kal_uint8 reserved[3];
kal_uint32 netif_id;
} dpfm_ipv6_filter_t;
typedef struct _dpfm_filter_list_t {
DPFM_DECLARE_OBJECT
dpfm_filter_t *filter;
} dpfm_filter_list_t;
typedef struct _dpfm_ipv6_dl_filter_cbk_context_t {
kal_uint8 lan_dev_id;
kal_uint8 reserved[3];
kal_uint32 lan_dev_user_id;
} dpfm_ipv6_dl_filter_cbk_context_t;
typedef struct _dpfm_lan_dev_t {
kal_bool is_activated;
dpfm_lan_dev_info_t info;
kal_uint32 private_ip;
kal_int32 ipv6_dl_filter_id[DPFM_MAX_LAN_DEV_USER_NUM][DPFM_CT_PROTOCOL_CNT];
kal_uint32 ipv6_dl_filter_cnt[DPFM_MAX_LAN_DEV_USER_NUM];
dpfm_ipv6_filter_t ipv6_dl_filters[DPFM_MAX_LAN_DEV_USER_NUM];
dpfm_ipv6_dl_filter_cbk_context_t ipv6_dl_filter_cbk_context[DPFM_MAX_LAN_DEV_USER_NUM];
} dpfm_lan_dev_t;
typedef struct _dpfm_ct_timeout_t {
kal_uint32 value;
kal_uint32 cnt;
} dpfm_ct_timeout_t;
typedef struct _dpfm_hw_cmd_q_t {
kal_bool is_send_ilm;
kal_uint32 read_idx;
kal_uint32 write_idx;
kal_int16 filter_id[DPFM_MAX_FILTER_CNT];
lhif_ul_nat_inband_data_t cmd[DPFM_MAX_FILTER_CNT];
} dpfm_hw_cmd_q_t;
typedef struct _dpfm_t {
kal_bool is_activated;
kal_uint32 user_cnt;
kal_uint32 ccmni_lan_netif_id;
kal_int16 filter_cmd_read_index;
kal_int16 filter_cmd_write_index;
kal_int16 filter_id_by_cmd_id[DPFM_MAX_HW_CMD_CNT];
kal_int16 filter_id_by_index[DPFM_MAX_HW_FILTER_CNT];
kal_uint32 filter_cnt;
dpfm_filter_t filters[DPFM_MAX_FILTER_CNT];
dpfm_filter_list_t hash_table[2][DPFM_HASH_TABLE_SIZE]; // uplink & downlink
dpfm_lan_dev_t lan_dev[DPFM_LAN_DEV_CNT];
dpfm_ct_timeout_t ct_timeout[DPFM_CT_PROTOCOL_CNT];
kal_bool is_filter_send_hw_cmd[DPFM_MAX_FILTER_CNT];
dpfm_hw_cmd_q_t hw_cmd_q;
} dpfm_t;
#ifdef __TEMP_MDDP_WH_SUPPORT__
typedef struct _dpfm_ct_nat_table_entry_t {
kal_uint32 private_ip;
kal_uint32 target_ip;
kal_uint32 public_ip;
kal_uint16 private_port;
kal_uint16 target_port;
kal_uint16 public_port;
kal_uint8 protocol;
kal_uint8 reserved;
kal_uint32 timestamp;
kal_bool dst_nat;
} dpfm_ct_nat_table_entry_t;
#else
typedef struct _dpfm_ct_nat_table_entry_t {
kal_uint32 private_ip;
kal_uint16 private_port;
kal_uint32 target_ip;
kal_uint16 target_port;
kal_uint32 public_ip;
kal_uint16 public_port;
kal_uint8 protocol;
kal_uint8 reserved;
kal_uint32 timestamp;
kal_bool dst_nat;
} dpfm_ct_nat_table_entry_t;
#endif
/* ILM structures definition for Data Usage */
typedef struct _dpfm_global_alert_t {
kal_uint32 trans_id;
kal_uint32 status; //unused
kal_uint64 measure_buffer_size;
kal_int8 dpfm_id;
kal_uint8 reserved[3];
} dpfm_global_alert_t;
typedef struct _dpfm_iquota_t {
kal_uint32 trans_id;
kal_uint32 status; //unused
kal_uint64 limit_buffer_size;
kal_int8 dpfm_id;
kal_uint8 reserved[3];
} dpfm_iquota_t;
typedef struct _dpfm_data_usage_cmd_struct {
LOCAL_PARA_HDR
kal_uint32 cmd;
} dpfm_data_usage_cmd_struct;
typedef struct _dpfm_alert_global_alert_ind_struct {
LOCAL_PARA_HDR
kal_uint32 cmd;
dpfm_global_alert_t ga;
} dpfm_alert_global_alert_ind_struct;
typedef struct _dpfm_set_iquota_req_struct {
LOCAL_PARA_HDR
kal_uint32 cmd;
dpfm_iquota_t iq;
} dpfm_set_iquota_req_struct;
typedef struct _dpfm_alert_iquota_ind_struct {
LOCAL_PARA_HDR
kal_uint32 cmd;
dpfm_iquota_t iq;
} dpfm_alert_iquota_ind_struct;
typedef struct _dpfm_del_iquota_req_struct {
LOCAL_PARA_HDR
kal_uint32 cmd;
dpfm_iquota_t iq;
} dpfm_del_iquota_req_struct;
#ifdef __TEMP_MDDP_WH_SUPPORT__
typedef struct _dpfm_set_ct_timeout_req_struct {
LOCAL_PARA_HDR
kal_uint32 udp_timeout_value;
kal_uint32 tcp_timeout_value;
kal_uint8 reserved[4];
} dpfm_set_ct_timeout_req_struct;
typedef struct _dpfm_set_ct_timeout_rsp_struct {
LOCAL_PARA_HDR
kal_uint32 udp_timeout_value;
kal_uint32 tcp_timeout_value;
kal_uint8 result; //bool
kal_uint8 reserved[3];
} dpfm_set_ct_timeout_rsp_struct;
#else
typedef struct _dpfm_set_ct_timeout_req_struct {
LOCAL_PARA_HDR
kal_uint32 tcp_timeout_value;
kal_uint32 udp_timeout_value;
kal_uint8 reserved[4];
} dpfm_set_ct_timeout_req_struct;
typedef struct _dpfm_set_ct_timeout_rsp_struct {
LOCAL_PARA_HDR
kal_uint32 tcp_timeout_value;
kal_uint32 udp_timeout_value;
kal_uint8 result; //bool
kal_uint8 reserved[3];
} dpfm_set_ct_timeout_rsp_struct;
#endif
typedef struct _dpfm_lan_dev_del_filter_ind_struct {
LOCAL_PARA_HDR
kal_int16 filter_id;
kal_uint8 reserved[2];
} dpfm_lan_dev_del_filter_ind_struct;
#endif