Skip to content

Commit

Permalink
modify some drawbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
wqlxx committed Apr 21, 2013
1 parent fbc4402 commit b680813
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 71 deletions.
5 changes: 3 additions & 2 deletions drv_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ drv_tbl_ioctl(uint8 chip_id, int32 index, uint32 cmd, void* val)
}

extern int32
drv_reg_ioctl(uint8 chip_id, int32 index, uint32 cmd, void* val);
drv_reg_ioctl(uint8 chip_id, int32 index, uint32 cmd, void* val)
{
int32 action;
tbl_id_t tbl_id;
Expand Down Expand Up @@ -196,7 +196,8 @@ drv_reg_ioctl(uint8 chip_id, int32 index, uint32 cmd, void* val);
}
DRV_IF_ERROR_RETURN(drv_io_api[chip_id].drv_sram_reg_entry_to_ds(reg_id, entry, val));
break;

}
}
}


Expand Down
4 changes: 2 additions & 2 deletions sram_model.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ int32 sram_model_release(uint8 chip_id)
int32 sram_model_read(uint8 chip_id,
uint32 sw_model_addr,
uint32 *data,
int32 len);
int32 len)
{
/*cmodel only support up to 2 same chip*/
SRAM_CHIP_ID_VALID_CHECK(chip_id);
Expand All @@ -222,7 +222,7 @@ int32 sram_model_read(uint8 chip_id,
int32 sram_model_write(uint8 chip_id,
uint32 sw_model_addr,
uint32 *data,
int32 len);
int32 len)
{
/*cmodel only support up to 2 same chip*/
SRAM_CHIP_ID_VALID_CHECK(chip_id);
Expand Down
43 changes: 22 additions & 21 deletions tcam_model.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,31 +338,32 @@ int32 tcam_model_lookup(uin8 chip_id, uint32 tbl_id, uin32 *data, uin32 *idx)
uint32 entry_num = i*(tbl->key_size/EACH_TCAM_ENTRY_SW_SIM_BYTES)
+ (tbl->hw_data_base - hw_data_base)/EACH_TCAM_ENTRY_SW_SIM_BYTES;

/*check the tcam entry's Wbit*/
if(!(IS_BIT_SET(*(sw_vbit_base + entry_num/32), entry_num%32)))
{
continue;
}

/*compare key according to the word uint*/
for(j = 0; j < tbl->key_size/4; ++j)
{
uint32 mask = *(key_mask_base + i * tbl->key_size/4 + j);
uint32 data = *(key_data_base + i * tbl->key_size/4 + j);
uint32 key = *(data + j);

if((record & mask) != (key & mask))
/*check the tcam entry's Wbit*/
if(!(IS_BIT_SET(*(sw_vbit_base + entry_num/32), entry_num%32)))
{
break;
continue;
}

if(j == tbl->key_size/4 - 1)

/*compare key according to the word uint*/
for(j = 0; j < tbl->key_size/4; ++j)
{
*idx = (tbl->hw_data_base - hw_data_base)/EACH_TCAM_ENTRY_SW_SIM_BYTES
+ i*(tbl->key_size/EACH_TCAM_ENTRY_SW_SIM_BYTES);
return DRV_E_NONE;
uint32 mask = *(key_mask_base + i * tbl->key_size/4 + j);
uint32 data = *(key_data_base + i * tbl->key_size/4 + j);
uint32 key = *(data + j);

if((record & mask) != (key & mask))
{
break;
}

if(j == tbl->key_size/4 - 1)
{
*idx = (tbl->hw_data_base - hw_data_base)/EACH_TCAM_ENTRY_SW_SIM_BYTES
+ i*(tbl->key_size/EACH_TCAM_ENTRY_SW_SIM_BYTES);
return DRV_E_NONE;
}
}
}
}//20130421 CHECK this symbol is right
*idx = 0xffffffff;
return DRV_E_NOT_FOUND;
}
Expand Down
59 changes: 20 additions & 39 deletions tcam_write.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
#include "tcam_write.h"

#define DO_REORDER(move_num, all) ((move_num) >= ((all)/g_sys_humber_acl_reorder_ratio))
uint16 g_sys_humber_acl_reorder_ratio = 100;
#define DO_REORDER(move_num, all) ((move_num) >= ((all)/g_sys_humber_acl_reorder_ratio))


static sys_aclqos_entry_ctl_t sys_aclqos_entry_ctl;
static ctc_hash_t *p_sys_acl_redirect_hash[MAX_LOCAL_CHIP_NUM];
static sys_aclqos_entry_ctl_t *acl_master = &sys_aclqos_entry_ctl;

static sys_chip_master_t *p_chip_master = NULL;


/*brief acl global entry hash key hook*/
static inline uint32
Expand Down Expand Up @@ -34,7 +42,6 @@ _sys_humber_acl_get_sys_entry_by_eid(uint32 eid, sys_acl_entry_t **sys_entry_out
sys_acl_entry_t sys_entry;

CTC_PTR_VALID_CHECK(sys_entry_out);
SYS_ACL_DBG_FUNC();

memset(&sys_entry, 0, sizeof(sys_acl_entry_t));
sys_entry.entry_id = eid;
Expand All @@ -52,7 +59,6 @@ _sys_humber_acl_entry_move_hw(sys_acl_entry_t *pe, int32 tcam_idx_new)
sys_aclqos_sub_entry_info_t sub_info;

CTC_PTR_VALID_CHECK(pe);
SYS_ACL_DBG_FUNC();

/*add first*/
memset(&sub_info, 0, sizeof(sub_info));
Expand All @@ -78,14 +84,12 @@ _sys_humber_acl_entry_move(sys_acl_entry_t* pe, int32 amount)

uint8 asic_type;

SYS_ACL_DBG_FUNC();
CTC_PTR_VALID_CHECK(pe);

asic_type = acl_master->asic_type[pe->key.type];
pb = &acl_master->block[asic_type];
if(amount == 0)
{
SYS_ACL_DBG_INFO("amount == 0\m");
return(CTC_E_NONE);
}

Expand All @@ -110,7 +114,6 @@ _sys_humber_acl_entry_shift_up(sys_acl_block_t* pb, int32 target_index, int32 pr
int32 temp;

CTC_PTR_VALID_CHECK(pb);
SYS_ACL_DBG_FUNC();

temp = prev_null_index;
/*start from prev - 1
Expand Down Expand Up @@ -147,12 +150,6 @@ _sys_humber_acl_entry_shift_down(sys_acl_entry_t* pb, int32 target_index, int32
return CTC_E_NONE;
}

typedef struct
{
uint16 t_idx;//target index
uint16 o_idx;//old index
}_fpa_target_t;

static int32
_sys_humber_acl_reorder(sys_acl_block_t* pb, int32 bottom_index, uint8 extra_num)
{
Expand Down Expand Up @@ -345,9 +342,6 @@ _sys_humber_acl_shift_all_entries_up(sys_acl_block_t* pb)
return CTC_E_NONE;
}

#define SYS_ACL_REMEMBER_BASE 10
#define CTC_ACLQOS_ENTRY_ID_HEAD 0
#define CTC_ACLQOS_ENTRY_ID_TAIL 0xffffffff
/*worst is bset*/
static int32
_sys_humber_acl_magic_reorder(sys_acl_block_t* pb, uint32 after_entry_id)
Expand Down Expand Up @@ -391,7 +385,7 @@ _sys_humber_acl_get_block_index(sys_acl_block_t *pb, uint32 after_entry_id, uint
int32 prev_null_idx = 0;
int32 next_null_idx = 0;
int32 shift_up_amount = 0;
int32 shift_dowm_amounr = 0;
int32 shift_down_amount = 0;
int16 after_idx = 0;

CTC_PTR_VALID_CHECK(pb);
Expand All @@ -407,7 +401,7 @@ _sys_humber_acl_get_block_index(sys_acl_block_t *pb, uint32 after_entry_id, uint
_sys_humber_acl_magic_reorder(pb, after_entry_id);
if(after_entry_id == CTC_ACLQOS_ENTRY_ID_TAIL)
{
next_null_idx = SYS_ACl_INVALID_INDEX;
next_null_idx = SYS_ACL_INVALID_INDEX;
bottom_idx = pb->entry_count + pb->entry_dft_max - 1;

for(idx = pb->entry_count; idx <= bottom_idx; idx++)
Expand All @@ -416,17 +410,17 @@ _sys_humber_acl_get_block_index(sys_acl_block_t *pb, uint32 after_entry_id, uint
{
next_null_idx = idx;
break;
{
{
}
}
target_idx = next_null_idx;
pb->entry_dft_cnt++;
}else if(pb->entry_count == pb->free_count){
target_idx = pb->entry_count - 1;
}
else if(after_entry_idx == CTC_ACLQOS_ENTRY_ID_HEAD)
else if(after_entry_id == CTC_ACLQOS_ENTRY_ID_HEAD)
{
/*get last not null index*/
first_entry_index = SYS_ACL_INVALID_INDEX;
first_entry_idx = SYS_ACL_INVALID_INDEX;
for( idx = 0; idx < pb->entry_count; idx++)
{
if(pb->entries[idx] != NULL)
Expand Down Expand Up @@ -455,7 +449,7 @@ _sys_humber_acl_get_block_index(sys_acl_block_t *pb, uint32 after_entry_id, uint

CTC_ERROR_RETURN(_sys_humber_acl_entry_shift_down(pb, target_idx, next_null_idx));
*shift_amount = shift_down_amount;
}eles{
}else{
target_idx = first_entry_idx - 1;
}
}else{
Expand Down Expand Up @@ -510,11 +504,8 @@ _sys_humber_acl_get_block_index(sys_acl_block_t *pb, uint32 after_entry_id, uint
}
*block_index = target_idx;
return CTC_E_NONE;
}
}

static sys_aclqos_entry_ctl_t sys_aclqos_entry_ctl;
static ctc_hash_t *p_sys_acl_redirect_hash[CTC_MAX_LOCAL_CHIP_NUM];
static sys_aclqos_entry_ctl_t *acl_master = &sys_aclqos_entry_ctl;

void*
ctc_hash_lookup(ctc_hash_t* hash, void *data)
Expand Down Expand Up @@ -573,16 +564,6 @@ sys_humber_aclqos_label_lookup(uint32 lable_id, uint8 is_service_label, sys_aclq

return CTC_E_NONE;
}

struct sys_chip_master_s
{
uint8 lchip_num;
uint8 resv;
uint8 g_chip_id[CTC_MAX_LOCAL_CHIP_NUM];
}
typedef struct sys_chip_master_s sys_chip_master_t;

static sys_chip_master_t *p_chip_master = NULL;

uint8
sys_humber_get_local_chip_num(void)
Expand Down Expand Up @@ -1174,8 +1155,7 @@ sys_humber_aclqos_entry_action_add(uint32 label_id, ctc_aclqos_label_type_t labe
{
if(IS_ACL_LABEL(p_label->type))
return CTC_E_ACLQOS_DIFFERENT_TYPE;
}else if(CTC_ACL_LABEL == label_type)
{
}else if(CTC_ACL_LABEL == label_type){
if(IS_QOS_LABEL(p_label->type))
return CTC_E_ACLQOS_DIFFERENT_TYPE;
}
Expand Down Expand Up @@ -1206,7 +1186,8 @@ sys_humber_aclqos_entry_action_add(uint32 label_id, ctc_aclqos_label_type_t labe
CTC_ERROR_RETURN(sus_humber_qos_policer_index_get(lchip, p_action->policer_id, &policer_ptr));

//write to chip

}
}
}


35 changes: 28 additions & 7 deletions tcam_write.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,32 @@
#define SYS_ACL_REMEMBER_BASE 10
#define SYS_ACL_INVALID_INDEX -1
#define CTC_ACLQOS_ENTRY_ID_HEAD 0
#define CTC_ACLQOS_ENTRY_ID_TAIL 0xffffffff


struct sys_chip_master_s
{
uint8 lchip_num;
uint8 resv;
uint8 g_chip_id[CTC_MAX_LOCAL_CHIP_NUM];
};
typedef struct sys_chip_master_s sys_chip_master_t;

typedef struct
{
uint16 t_idx;//target index
uint16 o_idx;//old index
}_fpa_target_t;


struct sys_aclqos_flag_s
{
uint32 discard:1,
deny_replace_cos:1,
deny_replace_dscp:1,
deny_bridge:1,
deny_learning:1,
deny_route;1,
deny_route:1,
stats:1,
flow_policer:1,
trust:1,
Expand Down Expand Up @@ -70,7 +91,7 @@ struct sys_aclqos_mac_key_flag_s
cvlan:1,
ctag_cos:1,
ctag_cfi:1,
svlan;1,
svlan:1,
stag_cos:1,
stag_cfi:1,
eth_type:1,
Expand All @@ -80,7 +101,7 @@ struct sys_aclqos_mac_key_flag_s
qos_type:1,
l2_qos_label:1,
l3_qos_label:1,
is_glb_entry;1,
is_glb_entry:1,
rsv:14;
};
typedef struct sys_aclqos_mac_key_flag_s sys_aclqos_mac_key_flag_t;
Expand Down Expand Up @@ -124,9 +145,9 @@ typedef struct sys_aclqos_mac_key_s sys_aclqos_mac_key_t;

struct sys_aclqos_ipv4_key_flag_s
{
uint32 ipda;1,
uint32 ipda:1,
ipsa:1,
l4info_mapped;1,
l4info_mapped:1,
is_application:1,
is_tcp:1,
is_udp:1,
Expand Down Expand Up @@ -328,7 +349,7 @@ struct sys_acl_block_s
uint8 lchip;
uint16 after_0_cnt;//entry count < SYS_REMEMBER_BASE
uint16 after_1_cnt;
}
};
typedef struct sys_acl_block_s sys_acl_block_t;

#define SYS_ACL_ASIC_TYPE_MAX 2
Expand Down Expand Up @@ -363,7 +384,7 @@ struct ctc_hash_s

/*data compare function*/
bool (*hash_cmp)(void* backet_data, void* data);
{
};
typedef struct ctc_hash_s ctc_hash_t;

struct sys_aclqos_entry_ctl_s
Expand Down

0 comments on commit b680813

Please sign in to comment.