Lines Matching refs:ale
252 static int cpsw_ale_entry_get_fld(struct cpsw_ale *ale, in cpsw_ale_entry_get_fld() argument
260 if (!ale || !ale_entry) in cpsw_ale_entry_get_fld()
265 dev_err(ale->params.dev, "get: wrong ale fld id %d\n", fld_id); in cpsw_ale_entry_get_fld()
271 bits = ale->port_mask_bits; in cpsw_ale_entry_get_fld()
276 static void cpsw_ale_entry_set_fld(struct cpsw_ale *ale, in cpsw_ale_entry_set_fld() argument
285 if (!ale || !ale_entry) in cpsw_ale_entry_set_fld()
290 dev_err(ale->params.dev, "set: wrong ale fld id %d\n", fld_id); in cpsw_ale_entry_set_fld()
296 bits = ale->port_mask_bits; in cpsw_ale_entry_set_fld()
301 static int cpsw_ale_vlan_get_fld(struct cpsw_ale *ale, in cpsw_ale_vlan_get_fld() argument
305 return cpsw_ale_entry_get_fld(ale, ale_entry, in cpsw_ale_vlan_get_fld()
306 ale->vlan_entry_tbl, fld_id); in cpsw_ale_vlan_get_fld()
309 static void cpsw_ale_vlan_set_fld(struct cpsw_ale *ale, in cpsw_ale_vlan_set_fld() argument
314 cpsw_ale_entry_set_fld(ale, ale_entry, in cpsw_ale_vlan_set_fld()
315 ale->vlan_entry_tbl, fld_id, value); in cpsw_ale_vlan_set_fld()
335 static int cpsw_ale_read(struct cpsw_ale *ale, int idx, u32 *ale_entry) in cpsw_ale_read() argument
339 WARN_ON(idx > ale->params.ale_entries); in cpsw_ale_read()
341 writel_relaxed(idx, ale->params.ale_regs + ALE_TABLE_CONTROL); in cpsw_ale_read()
344 ale_entry[i] = readl_relaxed(ale->params.ale_regs + in cpsw_ale_read()
350 static int cpsw_ale_write(struct cpsw_ale *ale, int idx, u32 *ale_entry) in cpsw_ale_write() argument
354 WARN_ON(idx > ale->params.ale_entries); in cpsw_ale_write()
357 writel_relaxed(ale_entry[i], ale->params.ale_regs + in cpsw_ale_write()
360 writel_relaxed(idx | ALE_TABLE_WRITE, ale->params.ale_regs + in cpsw_ale_write()
366 static int cpsw_ale_match_addr(struct cpsw_ale *ale, const u8 *addr, u16 vid) in cpsw_ale_match_addr() argument
371 for (idx = 0; idx < ale->params.ale_entries; idx++) { in cpsw_ale_match_addr()
374 cpsw_ale_read(ale, idx, ale_entry); in cpsw_ale_match_addr()
387 static int cpsw_ale_match_vlan(struct cpsw_ale *ale, u16 vid) in cpsw_ale_match_vlan() argument
392 for (idx = 0; idx < ale->params.ale_entries; idx++) { in cpsw_ale_match_vlan()
393 cpsw_ale_read(ale, idx, ale_entry); in cpsw_ale_match_vlan()
403 static int cpsw_ale_match_free(struct cpsw_ale *ale) in cpsw_ale_match_free() argument
408 for (idx = 0; idx < ale->params.ale_entries; idx++) { in cpsw_ale_match_free()
409 cpsw_ale_read(ale, idx, ale_entry); in cpsw_ale_match_free()
417 static int cpsw_ale_find_ageable(struct cpsw_ale *ale) in cpsw_ale_find_ageable() argument
422 for (idx = 0; idx < ale->params.ale_entries; idx++) { in cpsw_ale_find_ageable()
423 cpsw_ale_read(ale, idx, ale_entry); in cpsw_ale_find_ageable()
437 static void cpsw_ale_flush_mcast(struct cpsw_ale *ale, u32 *ale_entry, in cpsw_ale_flush_mcast() argument
443 ale->port_mask_bits); in cpsw_ale_flush_mcast()
451 ale->port_mask_bits); in cpsw_ale_flush_mcast()
456 int cpsw_ale_flush_multicast(struct cpsw_ale *ale, int port_mask, int vid) in cpsw_ale_flush_multicast() argument
461 for (idx = 0; idx < ale->params.ale_entries; idx++) { in cpsw_ale_flush_multicast()
462 cpsw_ale_read(ale, idx, ale_entry); in cpsw_ale_flush_multicast()
483 cpsw_ale_flush_mcast(ale, ale_entry, port_mask); in cpsw_ale_flush_multicast()
486 cpsw_ale_write(ale, idx, ale_entry); in cpsw_ale_flush_multicast()
502 int cpsw_ale_add_ucast(struct cpsw_ale *ale, const u8 *addr, int port, in cpsw_ale_add_ucast() argument
514 cpsw_ale_set_port_num(ale_entry, port, ale->port_num_bits); in cpsw_ale_add_ucast()
516 idx = cpsw_ale_match_addr(ale, addr, (flags & ALE_VLAN) ? vid : 0); in cpsw_ale_add_ucast()
518 idx = cpsw_ale_match_free(ale); in cpsw_ale_add_ucast()
520 idx = cpsw_ale_find_ageable(ale); in cpsw_ale_add_ucast()
524 cpsw_ale_write(ale, idx, ale_entry); in cpsw_ale_add_ucast()
528 int cpsw_ale_del_ucast(struct cpsw_ale *ale, const u8 *addr, int port, in cpsw_ale_del_ucast() argument
534 idx = cpsw_ale_match_addr(ale, addr, (flags & ALE_VLAN) ? vid : 0); in cpsw_ale_del_ucast()
539 cpsw_ale_write(ale, idx, ale_entry); in cpsw_ale_del_ucast()
543 int cpsw_ale_add_mcast(struct cpsw_ale *ale, const u8 *addr, int port_mask, in cpsw_ale_add_mcast() argument
549 idx = cpsw_ale_match_addr(ale, addr, (flags & ALE_VLAN) ? vid : 0); in cpsw_ale_add_mcast()
551 cpsw_ale_read(ale, idx, ale_entry); in cpsw_ale_add_mcast()
560 ale->port_mask_bits); in cpsw_ale_add_mcast()
563 ale->port_mask_bits); in cpsw_ale_add_mcast()
566 idx = cpsw_ale_match_free(ale); in cpsw_ale_add_mcast()
568 idx = cpsw_ale_find_ageable(ale); in cpsw_ale_add_mcast()
572 cpsw_ale_write(ale, idx, ale_entry); in cpsw_ale_add_mcast()
576 int cpsw_ale_del_mcast(struct cpsw_ale *ale, const u8 *addr, int port_mask, in cpsw_ale_del_mcast() argument
583 idx = cpsw_ale_match_addr(ale, addr, (flags & ALE_VLAN) ? vid : 0); in cpsw_ale_del_mcast()
587 cpsw_ale_read(ale, idx, ale_entry); in cpsw_ale_del_mcast()
591 ale->port_mask_bits); in cpsw_ale_del_mcast()
597 ale->port_mask_bits); in cpsw_ale_del_mcast()
601 cpsw_ale_write(ale, idx, ale_entry); in cpsw_ale_del_mcast()
606 static void cpsw_ale_set_vlan_mcast(struct cpsw_ale *ale, u32 *ale_entry, in cpsw_ale_set_vlan_mcast() argument
612 idx = cpsw_ale_vlan_get_fld(ale, ale_entry, in cpsw_ale_set_vlan_mcast()
614 writel(reg_mcast, ale->params.ale_regs + ALE_VLAN_MASK_MUX(idx)); in cpsw_ale_set_vlan_mcast()
617 idx = cpsw_ale_vlan_get_fld(ale, ale_entry, in cpsw_ale_set_vlan_mcast()
619 writel(unreg_mcast, ale->params.ale_regs + ALE_VLAN_MASK_MUX(idx)); in cpsw_ale_set_vlan_mcast()
622 static void cpsw_ale_set_vlan_untag(struct cpsw_ale *ale, u32 *ale_entry, in cpsw_ale_set_vlan_untag() argument
625 cpsw_ale_vlan_set_fld(ale, ale_entry, in cpsw_ale_set_vlan_untag()
629 bitmap_set(ale->p0_untag_vid_mask, vid, 1); in cpsw_ale_set_vlan_untag()
631 bitmap_clear(ale->p0_untag_vid_mask, vid, 1); in cpsw_ale_set_vlan_untag()
634 int cpsw_ale_add_vlan(struct cpsw_ale *ale, u16 vid, int port_mask, int untag, in cpsw_ale_add_vlan() argument
640 idx = cpsw_ale_match_vlan(ale, vid); in cpsw_ale_add_vlan()
642 cpsw_ale_read(ale, idx, ale_entry); in cpsw_ale_add_vlan()
646 cpsw_ale_set_vlan_untag(ale, ale_entry, vid, untag); in cpsw_ale_add_vlan()
648 if (!ale->params.nu_switch_ale) { in cpsw_ale_add_vlan()
649 cpsw_ale_vlan_set_fld(ale, ale_entry, in cpsw_ale_add_vlan()
651 cpsw_ale_vlan_set_fld(ale, ale_entry, in cpsw_ale_add_vlan()
654 cpsw_ale_vlan_set_fld(ale, ale_entry, in cpsw_ale_add_vlan()
657 cpsw_ale_set_vlan_mcast(ale, ale_entry, reg_mcast, unreg_mcast); in cpsw_ale_add_vlan()
660 cpsw_ale_vlan_set_fld(ale, ale_entry, in cpsw_ale_add_vlan()
664 idx = cpsw_ale_match_free(ale); in cpsw_ale_add_vlan()
666 idx = cpsw_ale_find_ageable(ale); in cpsw_ale_add_vlan()
670 cpsw_ale_write(ale, idx, ale_entry); in cpsw_ale_add_vlan()
674 static void cpsw_ale_vlan_del_modify_int(struct cpsw_ale *ale, u32 *ale_entry, in cpsw_ale_vlan_del_modify_int() argument
680 members = cpsw_ale_vlan_get_fld(ale, ale_entry, in cpsw_ale_vlan_del_modify_int()
684 cpsw_ale_set_vlan_untag(ale, ale_entry, vid, 0); in cpsw_ale_vlan_del_modify_int()
689 untag = cpsw_ale_vlan_get_fld(ale, ale_entry, in cpsw_ale_vlan_del_modify_int()
691 reg_mcast = cpsw_ale_vlan_get_fld(ale, ale_entry, in cpsw_ale_vlan_del_modify_int()
693 unreg_mcast = cpsw_ale_vlan_get_fld(ale, ale_entry, in cpsw_ale_vlan_del_modify_int()
699 cpsw_ale_set_vlan_untag(ale, ale_entry, vid, untag); in cpsw_ale_vlan_del_modify_int()
701 if (!ale->params.nu_switch_ale) { in cpsw_ale_vlan_del_modify_int()
702 cpsw_ale_vlan_set_fld(ale, ale_entry, in cpsw_ale_vlan_del_modify_int()
704 cpsw_ale_vlan_set_fld(ale, ale_entry, in cpsw_ale_vlan_del_modify_int()
707 cpsw_ale_set_vlan_mcast(ale, ale_entry, reg_mcast, in cpsw_ale_vlan_del_modify_int()
710 cpsw_ale_vlan_set_fld(ale, ale_entry, in cpsw_ale_vlan_del_modify_int()
714 int cpsw_ale_vlan_del_modify(struct cpsw_ale *ale, u16 vid, int port_mask) in cpsw_ale_vlan_del_modify() argument
719 idx = cpsw_ale_match_vlan(ale, vid); in cpsw_ale_vlan_del_modify()
723 cpsw_ale_read(ale, idx, ale_entry); in cpsw_ale_vlan_del_modify()
725 cpsw_ale_vlan_del_modify_int(ale, ale_entry, vid, port_mask); in cpsw_ale_vlan_del_modify()
726 cpsw_ale_write(ale, idx, ale_entry); in cpsw_ale_vlan_del_modify()
731 int cpsw_ale_del_vlan(struct cpsw_ale *ale, u16 vid, int port_mask) in cpsw_ale_del_vlan() argument
736 idx = cpsw_ale_match_vlan(ale, vid); in cpsw_ale_del_vlan()
740 cpsw_ale_read(ale, idx, ale_entry); in cpsw_ale_del_vlan()
748 members = cpsw_ale_vlan_get_fld(ale, ale_entry, ALE_ENT_VID_MEMBER_LIST); in cpsw_ale_del_vlan()
753 cpsw_ale_set_vlan_untag(ale, ale_entry, vid, 0); in cpsw_ale_del_vlan()
757 cpsw_ale_vlan_del_modify_int(ale, ale_entry, vid, port_mask); in cpsw_ale_del_vlan()
760 cpsw_ale_write(ale, idx, ale_entry); in cpsw_ale_del_vlan()
765 int cpsw_ale_vlan_add_modify(struct cpsw_ale *ale, u16 vid, int port_mask, in cpsw_ale_vlan_add_modify() argument
773 idx = cpsw_ale_match_vlan(ale, vid); in cpsw_ale_vlan_add_modify()
775 cpsw_ale_read(ale, idx, ale_entry); in cpsw_ale_vlan_add_modify()
777 vlan_members = cpsw_ale_vlan_get_fld(ale, ale_entry, in cpsw_ale_vlan_add_modify()
779 reg_mcast_members = cpsw_ale_vlan_get_fld(ale, ale_entry, in cpsw_ale_vlan_add_modify()
782 cpsw_ale_vlan_get_fld(ale, ale_entry, in cpsw_ale_vlan_add_modify()
784 untag_members = cpsw_ale_vlan_get_fld(ale, ale_entry, in cpsw_ale_vlan_add_modify()
792 ret = cpsw_ale_add_vlan(ale, vid, vlan_members, untag_members, in cpsw_ale_vlan_add_modify()
795 dev_err(ale->params.dev, "Unable to add vlan\n"); in cpsw_ale_vlan_add_modify()
798 dev_dbg(ale->params.dev, "port mask 0x%x untag 0x%x\n", vlan_members, in cpsw_ale_vlan_add_modify()
804 void cpsw_ale_set_unreg_mcast(struct cpsw_ale *ale, int unreg_mcast_mask, in cpsw_ale_set_unreg_mcast() argument
811 for (idx = 0; idx < ale->params.ale_entries; idx++) { in cpsw_ale_set_unreg_mcast()
812 cpsw_ale_read(ale, idx, ale_entry); in cpsw_ale_set_unreg_mcast()
818 cpsw_ale_vlan_get_fld(ale, ale_entry, in cpsw_ale_set_unreg_mcast()
824 cpsw_ale_vlan_set_fld(ale, ale_entry, in cpsw_ale_set_unreg_mcast()
827 cpsw_ale_write(ale, idx, ale_entry); in cpsw_ale_set_unreg_mcast()
831 static void cpsw_ale_vlan_set_unreg_mcast(struct cpsw_ale *ale, u32 *ale_entry, in cpsw_ale_vlan_set_unreg_mcast() argument
836 unreg_mcast = cpsw_ale_vlan_get_fld(ale, ale_entry, in cpsw_ale_vlan_set_unreg_mcast()
843 cpsw_ale_vlan_set_fld(ale, ale_entry, in cpsw_ale_vlan_set_unreg_mcast()
848 cpsw_ale_vlan_set_unreg_mcast_idx(struct cpsw_ale *ale, u32 *ale_entry, in cpsw_ale_vlan_set_unreg_mcast_idx() argument
854 idx = cpsw_ale_vlan_get_fld(ale, ale_entry, in cpsw_ale_vlan_set_unreg_mcast_idx()
857 unreg_mcast = readl(ale->params.ale_regs + ALE_VLAN_MASK_MUX(idx)); in cpsw_ale_vlan_set_unreg_mcast_idx()
864 writel(unreg_mcast, ale->params.ale_regs + ALE_VLAN_MASK_MUX(idx)); in cpsw_ale_vlan_set_unreg_mcast_idx()
867 void cpsw_ale_set_allmulti(struct cpsw_ale *ale, int allmulti, int port) in cpsw_ale_set_allmulti() argument
872 for (idx = 0; idx < ale->params.ale_entries; idx++) { in cpsw_ale_set_allmulti()
875 cpsw_ale_read(ale, idx, ale_entry); in cpsw_ale_set_allmulti()
880 vlan_members = cpsw_ale_vlan_get_fld(ale, ale_entry, in cpsw_ale_set_allmulti()
886 if (!ale->params.nu_switch_ale) in cpsw_ale_set_allmulti()
887 cpsw_ale_vlan_set_unreg_mcast(ale, ale_entry, allmulti); in cpsw_ale_set_allmulti()
889 cpsw_ale_vlan_set_unreg_mcast_idx(ale, ale_entry, in cpsw_ale_set_allmulti()
892 cpsw_ale_write(ale, idx, ale_entry); in cpsw_ale_set_allmulti()
1122 int cpsw_ale_control_set(struct cpsw_ale *ale, int port, int control, in cpsw_ale_control_set() argument
1136 if (port < 0 || port >= ale->params.ale_ports) in cpsw_ale_control_set()
1146 tmp = readl_relaxed(ale->params.ale_regs + offset); in cpsw_ale_control_set()
1148 writel_relaxed(tmp, ale->params.ale_regs + offset); in cpsw_ale_control_set()
1153 int cpsw_ale_control_get(struct cpsw_ale *ale, int port, int control) in cpsw_ale_control_get() argument
1166 if (port < 0 || port >= ale->params.ale_ports) in cpsw_ale_control_get()
1172 tmp = readl_relaxed(ale->params.ale_regs + offset) >> shift; in cpsw_ale_control_get()
1176 int cpsw_ale_rx_ratelimit_mc(struct cpsw_ale *ale, int port, unsigned int ratelimit_pps) in cpsw_ale_rx_ratelimit_mc() argument
1183 dev_err(ale->params.dev, "ALE MC port:%d ratelimit min value 1000pps\n", port); in cpsw_ale_rx_ratelimit_mc()
1188 dev_info(ale->params.dev, "ALE port:%d MC ratelimit set to %dpps (requested %d)\n", in cpsw_ale_rx_ratelimit_mc()
1191 cpsw_ale_control_set(ale, port, ALE_PORT_MCAST_LIMIT, val); in cpsw_ale_rx_ratelimit_mc()
1193 dev_dbg(ale->params.dev, "ALE port:%d MC ratelimit set %d\n", in cpsw_ale_rx_ratelimit_mc()
1198 int cpsw_ale_rx_ratelimit_bc(struct cpsw_ale *ale, int port, unsigned int ratelimit_pps) in cpsw_ale_rx_ratelimit_bc() argument
1205 dev_err(ale->params.dev, "ALE port:%d BC ratelimit min value 1000pps\n", port); in cpsw_ale_rx_ratelimit_bc()
1210 dev_info(ale->params.dev, "ALE port:%d BC ratelimit set to %dpps (requested %d)\n", in cpsw_ale_rx_ratelimit_bc()
1213 cpsw_ale_control_set(ale, port, ALE_PORT_BCAST_LIMIT, val); in cpsw_ale_rx_ratelimit_bc()
1215 dev_dbg(ale->params.dev, "ALE port:%d BC ratelimit set %d\n", in cpsw_ale_rx_ratelimit_bc()
1222 struct cpsw_ale *ale = from_timer(ale, t, timer); in cpsw_ale_timer() local
1224 cpsw_ale_control_set(ale, 0, ALE_AGEOUT, 1); in cpsw_ale_timer()
1226 if (ale->ageout) { in cpsw_ale_timer()
1227 ale->timer.expires = jiffies + ale->ageout; in cpsw_ale_timer()
1228 add_timer(&ale->timer); in cpsw_ale_timer()
1232 static void cpsw_ale_hw_aging_timer_start(struct cpsw_ale *ale) in cpsw_ale_hw_aging_timer_start() argument
1236 aging_timer = ale->params.bus_freq / 1000000; in cpsw_ale_hw_aging_timer_start()
1237 aging_timer *= ale->params.ale_ageout; in cpsw_ale_hw_aging_timer_start()
1241 dev_warn(ale->params.dev, in cpsw_ale_hw_aging_timer_start()
1245 writel(aging_timer, ale->params.ale_regs + ALE_AGING_TIMER); in cpsw_ale_hw_aging_timer_start()
1248 static void cpsw_ale_hw_aging_timer_stop(struct cpsw_ale *ale) in cpsw_ale_hw_aging_timer_stop() argument
1250 writel(0, ale->params.ale_regs + ALE_AGING_TIMER); in cpsw_ale_hw_aging_timer_stop()
1253 static void cpsw_ale_aging_start(struct cpsw_ale *ale) in cpsw_ale_aging_start() argument
1255 if (!ale->params.ale_ageout) in cpsw_ale_aging_start()
1258 if (ale->features & CPSW_ALE_F_HW_AUTOAGING) { in cpsw_ale_aging_start()
1259 cpsw_ale_hw_aging_timer_start(ale); in cpsw_ale_aging_start()
1263 timer_setup(&ale->timer, cpsw_ale_timer, 0); in cpsw_ale_aging_start()
1264 ale->timer.expires = jiffies + ale->ageout; in cpsw_ale_aging_start()
1265 add_timer(&ale->timer); in cpsw_ale_aging_start()
1268 static void cpsw_ale_aging_stop(struct cpsw_ale *ale) in cpsw_ale_aging_stop() argument
1270 if (!ale->params.ale_ageout) in cpsw_ale_aging_stop()
1273 if (ale->features & CPSW_ALE_F_HW_AUTOAGING) { in cpsw_ale_aging_stop()
1274 cpsw_ale_hw_aging_timer_stop(ale); in cpsw_ale_aging_stop()
1278 del_timer_sync(&ale->timer); in cpsw_ale_aging_stop()
1281 void cpsw_ale_start(struct cpsw_ale *ale) in cpsw_ale_start() argument
1295 ale_prescale = ale->params.bus_freq / ALE_RATE_LIMIT_MIN_PPS; in cpsw_ale_start()
1296 writel((u32)ale_prescale, ale->params.ale_regs + ALE_PRESCALE); in cpsw_ale_start()
1301 cpsw_ale_control_set(ale, 0, ALE_RATE_LIMIT, 1); in cpsw_ale_start()
1303 cpsw_ale_control_set(ale, 0, ALE_ENABLE, 1); in cpsw_ale_start()
1304 cpsw_ale_control_set(ale, 0, ALE_CLEAR, 1); in cpsw_ale_start()
1306 cpsw_ale_aging_start(ale); in cpsw_ale_start()
1309 void cpsw_ale_stop(struct cpsw_ale *ale) in cpsw_ale_stop() argument
1311 cpsw_ale_aging_stop(ale); in cpsw_ale_stop()
1312 cpsw_ale_control_set(ale, 0, ALE_CLEAR, 1); in cpsw_ale_stop()
1313 cpsw_ale_control_set(ale, 0, ALE_ENABLE, 0); in cpsw_ale_stop()
1482 static int cpsw_ale_regfield_init(struct cpsw_ale *ale) in cpsw_ale_regfield_init() argument
1484 const struct reg_field *reg_fields = ale->params.reg_fields; in cpsw_ale_regfield_init()
1485 struct device *dev = ale->params.dev; in cpsw_ale_regfield_init()
1486 struct regmap *regmap = ale->regmap; in cpsw_ale_regfield_init()
1489 for (i = 0; i < ale->params.num_fields; i++) { in cpsw_ale_regfield_init()
1490 ale->fields[i] = devm_regmap_field_alloc(dev, regmap, in cpsw_ale_regfield_init()
1492 if (IS_ERR(ale->fields[i])) { in cpsw_ale_regfield_init()
1494 return PTR_ERR(ale->fields[i]); in cpsw_ale_regfield_init()
1505 struct cpsw_ale *ale; in cpsw_ale_create() local
1517 ale = devm_kzalloc(params->dev, sizeof(*ale), GFP_KERNEL); in cpsw_ale_create()
1518 if (!ale) in cpsw_ale_create()
1520 ale->regmap = devm_regmap_init_mmio(params->dev, params->ale_regs, in cpsw_ale_create()
1522 if (IS_ERR(ale->regmap)) { in cpsw_ale_create()
1527 ale->params = *params; in cpsw_ale_create()
1528 ret = cpsw_ale_regfield_init(ale); in cpsw_ale_create()
1532 ale->p0_untag_vid_mask = devm_bitmap_zalloc(params->dev, VLAN_N_VID, in cpsw_ale_create()
1534 if (!ale->p0_untag_vid_mask) in cpsw_ale_create()
1537 ale->ageout = ale->params.ale_ageout * HZ; in cpsw_ale_create()
1538 ale->features = ale_dev_id->features; in cpsw_ale_create()
1539 ale->vlan_entry_tbl = ale_dev_id->vlan_entry_tbl; in cpsw_ale_create()
1541 regmap_field_read(ale->fields[MINOR_VER], &rev_minor); in cpsw_ale_create()
1542 regmap_field_read(ale->fields[MAJOR_VER], &rev_major); in cpsw_ale_create()
1543 ale->version = rev_major << 8 | rev_minor; in cpsw_ale_create()
1544 dev_info(ale->params.dev, "initialized cpsw ale version %d.%d\n", in cpsw_ale_create()
1547 if (ale->features & CPSW_ALE_F_STATUS_REG && in cpsw_ale_create()
1548 !ale->params.ale_entries) { in cpsw_ale_create()
1549 regmap_field_read(ale->fields[ALE_ENTRIES], &ale_entries); in cpsw_ale_create()
1561 ale->params.ale_entries = ale_entries; in cpsw_ale_create()
1564 if (ale->features & CPSW_ALE_F_STATUS_REG && in cpsw_ale_create()
1565 !ale->params.num_policers) { in cpsw_ale_create()
1566 regmap_field_read(ale->fields[ALE_POLICERS], &policers); in cpsw_ale_create()
1571 ale->params.num_policers = policers; in cpsw_ale_create()
1574 dev_info(ale->params.dev, in cpsw_ale_create()
1575 "ALE Table size %ld, Policers %ld\n", ale->params.ale_entries, in cpsw_ale_create()
1576 ale->params.num_policers); in cpsw_ale_create()
1579 ale->port_mask_bits = ale->params.ale_ports; in cpsw_ale_create()
1580 ale->port_num_bits = order_base_2(ale->params.ale_ports); in cpsw_ale_create()
1581 ale->vlan_field_bits = ale->params.ale_ports; in cpsw_ale_create()
1586 if (ale->params.nu_switch_ale) { in cpsw_ale_create()
1592 ale->params.ale_ports; in cpsw_ale_create()
1596 ale->params.ale_ports; in cpsw_ale_create()
1601 ale->params.ale_ports; in cpsw_ale_create()
1606 ale->params.ale_ports; in cpsw_ale_create()
1612 cpsw_ale_control_set(ale, 0, ALE_CLEAR, 1); in cpsw_ale_create()
1613 return ale; in cpsw_ale_create()
1616 void cpsw_ale_dump(struct cpsw_ale *ale, u32 *data) in cpsw_ale_dump() argument
1620 for (i = 0; i < ale->params.ale_entries; i++) { in cpsw_ale_dump()
1621 cpsw_ale_read(ale, i, data); in cpsw_ale_dump()
1626 void cpsw_ale_restore(struct cpsw_ale *ale, u32 *data) in cpsw_ale_restore() argument
1630 for (i = 0; i < ale->params.ale_entries; i++) { in cpsw_ale_restore()
1631 cpsw_ale_write(ale, i, data); in cpsw_ale_restore()
1636 u32 cpsw_ale_get_num_entries(struct cpsw_ale *ale) in cpsw_ale_get_num_entries() argument
1638 return ale ? ale->params.ale_entries : 0; in cpsw_ale_get_num_entries()
1642 static void cpsw_ale_policer_read_idx(struct cpsw_ale *ale, u32 idx) in cpsw_ale_policer_read_idx() argument
1645 writel_relaxed(idx, ale->params.ale_regs + ALE_POLICER_TBL_CTL); in cpsw_ale_policer_read_idx()
1649 static void cpsw_ale_policer_write_idx(struct cpsw_ale *ale, u32 idx) in cpsw_ale_policer_write_idx() argument
1653 writel_relaxed(idx, ale->params.ale_regs + ALE_POLICER_TBL_CTL); in cpsw_ale_policer_write_idx()
1657 static void cpsw_ale_policer_thread_idx_enable(struct cpsw_ale *ale, u32 idx, in cpsw_ale_policer_thread_idx_enable() argument
1660 regmap_field_write(ale->fields[ALE_THREAD_CLASS_INDEX], idx); in cpsw_ale_policer_thread_idx_enable()
1661 regmap_field_write(ale->fields[ALE_THREAD_VALUE], thread_id); in cpsw_ale_policer_thread_idx_enable()
1662 regmap_field_write(ale->fields[ALE_THREAD_ENABLE], enable ? 1 : 0); in cpsw_ale_policer_thread_idx_enable()
1666 static void cpsw_ale_policer_reset(struct cpsw_ale *ale) in cpsw_ale_policer_reset() argument
1670 for (i = 0; i < ale->params.num_policers ; i++) { in cpsw_ale_policer_reset()
1671 cpsw_ale_policer_read_idx(ale, i); in cpsw_ale_policer_reset()
1672 regmap_field_write(ale->fields[POL_PORT_MEN], 0); in cpsw_ale_policer_reset()
1673 regmap_field_write(ale->fields[POL_PRI_MEN], 0); in cpsw_ale_policer_reset()
1674 regmap_field_write(ale->fields[POL_OUI_MEN], 0); in cpsw_ale_policer_reset()
1675 regmap_field_write(ale->fields[POL_DST_MEN], 0); in cpsw_ale_policer_reset()
1676 regmap_field_write(ale->fields[POL_SRC_MEN], 0); in cpsw_ale_policer_reset()
1677 regmap_field_write(ale->fields[POL_OVLAN_MEN], 0); in cpsw_ale_policer_reset()
1678 regmap_field_write(ale->fields[POL_IVLAN_MEN], 0); in cpsw_ale_policer_reset()
1679 regmap_field_write(ale->fields[POL_ETHERTYPE_MEN], 0); in cpsw_ale_policer_reset()
1680 regmap_field_write(ale->fields[POL_IPSRC_MEN], 0); in cpsw_ale_policer_reset()
1681 regmap_field_write(ale->fields[POL_IPDST_MEN], 0); in cpsw_ale_policer_reset()
1682 regmap_field_write(ale->fields[POL_EN], 0); in cpsw_ale_policer_reset()
1683 regmap_field_write(ale->fields[POL_RED_DROP_EN], 0); in cpsw_ale_policer_reset()
1684 regmap_field_write(ale->fields[POL_YELLOW_DROP_EN], 0); in cpsw_ale_policer_reset()
1685 regmap_field_write(ale->fields[POL_PRIORITY_THREAD_EN], 0); in cpsw_ale_policer_reset()
1687 cpsw_ale_policer_thread_idx_enable(ale, i, 0, 0); in cpsw_ale_policer_reset()
1692 void cpsw_ale_classifier_setup_default(struct cpsw_ale *ale, int num_rx_ch) in cpsw_ale_classifier_setup_default() argument
1716 cpsw_ale_policer_reset(ale); in cpsw_ale_classifier_setup_default()
1723 cpsw_ale_policer_read_idx(ale, idx); in cpsw_ale_classifier_setup_default()
1724 regmap_field_write(ale->fields[POL_PRI_VAL], pri); in cpsw_ale_classifier_setup_default()
1725 regmap_field_write(ale->fields[POL_PRI_MEN], 1); in cpsw_ale_classifier_setup_default()
1726 cpsw_ale_policer_write_idx(ale, idx); in cpsw_ale_classifier_setup_default()
1729 cpsw_ale_policer_thread_idx_enable(ale, idx, in cpsw_ale_classifier_setup_default()