/******************************************************************************* * tpm_tcam_get_aging_cntr() * * DESCRIPTION: The API get hit counter of specific TCAM entry * * INPUTS: tid - - TCAM entry number * * OUTPUTS: * None * RETURNS: * Hit counter * * COMMENTS: * None * *******************************************************************************/ static inline MV_U32 tpm_tcam_get_aging_cntr(int32_t tid) { unsigned long flags; MV_U32 hit_count; /* Lock the TCAM hit counter */ spin_lock_irqsave(&tpmTcamAgingLock, flags); /* read aging hit counter by TID */ hit_count = mvPncAgingCntrRead(tid); /* Unlock TCAM hit counter */ spin_unlock_irqrestore(&tpmTcamAgingLock, flags); return hit_count; }
static ssize_t tcam_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t len) { const char* name = attr->attr.name; unsigned int err=0, a=0, b=0; unsigned long flags; if (!capable(CAP_NET_ADMIN)) return -EPERM; sscanf(buf,"%x %x",&a, &b); raw_local_irq_save(flags); if (!strcmp(name, "hw_write")) tcam_hw_write(&te, a); else if (!strcmp(name, "hw_read")) tcam_hw_read(&te, a); else if (!strcmp(name, "hw_debug")) tcam_hw_debug(a); else if (!strcmp(name, "hw_inv")) tcam_hw_inv(a); else if (!strcmp(name, "hw_inv_all")) tcam_hw_inv_all(); else if (!strcmp(name, "hw_hits")) tcam_hw_record(a); #ifdef CONFIG_MV_ETH_PNC_AGING else if (!strcmp(name, "age_clear")) mvPncAgingCntrClear(a); else if (!strcmp(name, "age_cntr")) { b = mvPncAgingCntrRead(a); printk("tid=%d: age_cntr = 0x%08x\n", a, b); } #endif /* CONFIG_MV_ETH_PNC_AGING */ else if (!strcmp(name, "sw_clear")) tcam_sw_clear(&te); else if (!strcmp(name, "sw_text")) { /* Remove last byte (new line) from the buffer */ int len = strlen(buf); char* temp = mvOsMalloc(len + 1); strncpy(temp, buf, len-1); temp[len-1] = 0; tcam_sw_text(&te, temp); mvOsFree(temp); } else if (!strcmp(name, "t_port")) tcam_sw_set_port(&te, a, b); else if (!strcmp(name, "t_lookup")) tcam_sw_set_lookup(&te, a); else if (!strcmp(name, "t_ainfo_0")) tcam_sw_set_ainfo(&te, 0<<a, 1<<a); else if (!strcmp(name, "t_ainfo_1")) tcam_sw_set_ainfo(&te, 1<<a, 1<<a); else if (!strcmp(name, "t_ainfo")) tcam_sw_set_ainfo(&te, a, b); else if (!strcmp(name, "t_offset_byte")) tcam_sw_set_byte(&te, a, b); else if (!strcmp(name, "t_offset_mask")) tcam_sw_set_mask(&te, a, b); else if (!strcmp(name, "s_lookup")) sram_sw_set_next_lookup(&te, a); else if (!strcmp(name, "s_ainfo")) sram_sw_set_ainfo(&te, a, b); else if (!strcmp(name, "s_lookup_done")) sram_sw_set_lookup_done(&te, a); else if (!strcmp(name, "s_next_lookup_shift")) sram_sw_set_next_lookup_shift(&te, a); else if (!strcmp(name, "s_rxq")) sram_sw_set_rxq(&te, a, b); else if (!strcmp(name, "s_shift_update")) sram_sw_set_shift_update(&te,a,b); else if (!strcmp(name, "s_rinfo")) sram_sw_set_rinfo(&te, 1 << a); else if (!strcmp(name, "s_rinfo_extra")) sram_sw_set_rinfo_extra(&te, a << (b & ~1)); else if (!strcmp(name, "s_flowid")) sram_sw_set_flowid(&te, a, b); else if (!strcmp(name, "s_flowid_nibble")) sram_sw_set_flowid_nibble(&te, a, b); #ifdef CONFIG_MV_ETH_PNC_AGING else if (!strcmp(name, "age_gr_set")) mvPncAgingCntrGroupSet(a, b); #endif /* CONFIG_MV_ETH_PNC_AGING */ else { err = 1; printk("%s: illegal operation <%s>\n", __FUNCTION__, attr->attr.name); } raw_local_irq_restore(flags); if (err) printk("%s: <%s>, error %d\n", __FUNCTION__, attr->attr.name, err); return err ? -EINVAL : len; }