Lines Matching +full:lan966x +full:- +full:switch

1 // SPDX-License-Identifier: GPL-2.0+
38 .vtype = VCAP_TYPE_IS1, /* IS1-0 */
47 .vtype = VCAP_TYPE_IS2, /* IS2-0 */
58 struct lan966x *lan966x; member
64 return lan_rd(cb->lan966x, VCAP_UPDATE_CTRL(cb->instance)); in lan966x_vcap_read_update_ctrl()
67 static void lan966x_vcap_wait_update(struct lan966x *lan966x, int instance) in lan966x_vcap_wait_update() argument
69 const struct lan966x_vcap_cmd_cb cb = { .lan966x = lan966x, in lan966x_vcap_wait_update()
78 static void __lan966x_vcap_range_init(struct lan966x *lan966x, in __lan966x_vcap_range_init() argument
84 VCAP_MV_CFG_MV_SIZE_SET(count - 1), in __lan966x_vcap_range_init()
85 lan966x, VCAP_MV_CFG(admin->tgt_inst)); in __lan966x_vcap_range_init()
94 lan966x, VCAP_UPDATE_CTRL(admin->tgt_inst)); in __lan966x_vcap_range_init()
96 lan966x_vcap_wait_update(lan966x, admin->tgt_inst); in __lan966x_vcap_range_init()
129 struct lan966x *lan966x = port->lan966x; in lan966x_vcap_is1_get_port_keysets() local
132 val = lan_rd(lan966x, ANA_VCAP_S1_CFG(port->chip_port, lookup)); in lan966x_vcap_is1_get_port_keysets()
136 switch (ANA_VCAP_S1_CFG_KEY_IP4_CFG_GET(val)) { in lan966x_vcap_is1_get_port_keysets()
150 switch (ANA_VCAP_S1_CFG_KEY_IP6_CFG_GET(val)) { in lan966x_vcap_is1_get_port_keysets()
171 switch (ANA_VCAP_S1_CFG_KEY_OTHER_CFG_GET(val)) { in lan966x_vcap_is1_get_port_keysets()
189 struct lan966x *lan966x = port->lan966x; in lan966x_vcap_is2_get_port_keysets() local
193 val = lan_rd(lan966x, ANA_VCAP_S2_CFG(port->chip_port)); in lan966x_vcap_is2_get_port_keysets()
241 switch (ANA_VCAP_S2_CFG_IP6_CFG_GET(val) & (0x3 << lookup)) { in lan966x_vcap_is2_get_port_keysets()
279 if (!kslist || kslist->cnt == 0) in lan966x_vcap_validate_keyset()
285 switch (admin->vtype) { in lan966x_vcap_validate_keyset()
287 lookup = lan966x_vcap_is1_cid_to_lookup(rule->vcap_chain_id); in lan966x_vcap_validate_keyset()
292 lookup = lan966x_vcap_is2_cid_to_lookup(rule->vcap_chain_id); in lan966x_vcap_validate_keyset()
297 return kslist->keysets[0]; in lan966x_vcap_validate_keyset()
300 lan966x_vcaps[admin->vtype].name); in lan966x_vcap_validate_keyset()
308 for (int i = 0; i < kslist->cnt; ++i) in lan966x_vcap_validate_keyset()
310 if (kslist->keysets[i] == keysets[j]) in lan966x_vcap_validate_keyset()
311 return kslist->keysets[i]; in lan966x_vcap_validate_keyset()
318 return (rule->vcap_chain_id >= LAN966X_VCAP_CID_IS2_L0 && in lan966x_vcap_is2_is_first_chain()
319 rule->vcap_chain_id < LAN966X_VCAP_CID_IS2_L1); in lan966x_vcap_is2_is_first_chain()
332 ~BIT(port->chip_port)); in lan966x_vcap_is1_add_default_fields()
334 lookup = lan966x_vcap_is1_cid_to_lookup(rule->vcap_chain_id); in lan966x_vcap_is1_add_default_fields()
347 ~BIT(port->chip_port)); in lan966x_vcap_is2_add_default_fields()
362 port->chip_port, GENMASK(4, 0)); in lan966x_vcap_es0_add_default_fields()
371 switch (admin->vtype) { in lan966x_vcap_add_default_fields()
383 lan966x_vcaps[admin->vtype].name); in lan966x_vcap_add_default_fields()
390 memset(admin->cache.keystream, 0, STREAMSIZE); in lan966x_vcap_cache_erase()
391 memset(admin->cache.maskstream, 0, STREAMSIZE); in lan966x_vcap_cache_erase()
392 memset(admin->cache.actionstream, 0, STREAMSIZE); in lan966x_vcap_cache_erase()
393 memset(&admin->cache.counter, 0, sizeof(admin->cache.counter)); in lan966x_vcap_cache_erase()
400 static void lan966x_es0_read_esdx_counter(struct lan966x *lan966x, in lan966x_es0_read_esdx_counter() argument
406 mutex_lock(&lan966x->stats_lock); in lan966x_es0_read_esdx_counter()
407 lan_wr(SYS_STAT_CFG_STAT_VIEW_SET(id), lan966x, SYS_STAT_CFG); in lan966x_es0_read_esdx_counter()
408 counter = lan_rd(lan966x, SYS_CNT(LAN966X_STAT_ESDX_GRN_PKTS)) + in lan966x_es0_read_esdx_counter()
409 lan_rd(lan966x, SYS_CNT(LAN966X_STAT_ESDX_YEL_PKTS)); in lan966x_es0_read_esdx_counter()
410 mutex_unlock(&lan966x->stats_lock); in lan966x_es0_read_esdx_counter()
412 admin->cache.counter = counter; in lan966x_es0_read_esdx_counter()
415 static void lan966x_es0_write_esdx_counter(struct lan966x *lan966x, in lan966x_es0_write_esdx_counter() argument
420 mutex_lock(&lan966x->stats_lock); in lan966x_es0_write_esdx_counter()
421 lan_wr(SYS_STAT_CFG_STAT_VIEW_SET(id), lan966x, SYS_STAT_CFG); in lan966x_es0_write_esdx_counter()
422 lan_wr(0, lan966x, SYS_CNT(LAN966X_STAT_ESDX_GRN_BYTES)); in lan966x_es0_write_esdx_counter()
423 lan_wr(admin->cache.counter, lan966x, in lan966x_es0_write_esdx_counter()
425 lan_wr(0, lan966x, SYS_CNT(LAN966X_STAT_ESDX_YEL_BYTES)); in lan966x_es0_write_esdx_counter()
426 lan_wr(0, lan966x, SYS_CNT(LAN966X_STAT_ESDX_YEL_PKTS)); in lan966x_es0_write_esdx_counter()
427 mutex_unlock(&lan966x->stats_lock); in lan966x_es0_write_esdx_counter()
437 struct lan966x *lan966x = port->lan966x; in lan966x_vcap_cache_write() local
440 keystr = &admin->cache.keystream[start]; in lan966x_vcap_cache_write()
441 mskstr = &admin->cache.maskstream[start]; in lan966x_vcap_cache_write()
442 actstr = &admin->cache.actionstream[start]; in lan966x_vcap_cache_write()
444 switch (sel) { in lan966x_vcap_cache_write()
447 lan_wr(keystr[i] & mskstr[i], lan966x, in lan966x_vcap_cache_write()
448 VCAP_ENTRY_DAT(admin->tgt_inst, i)); in lan966x_vcap_cache_write()
449 lan_wr(~mskstr[i], lan966x, in lan966x_vcap_cache_write()
450 VCAP_MASK_DAT(admin->tgt_inst, i)); in lan966x_vcap_cache_write()
455 lan_wr(actstr[i], lan966x, in lan966x_vcap_cache_write()
456 VCAP_ACTION_DAT(admin->tgt_inst, i)); in lan966x_vcap_cache_write()
459 admin->cache.sticky = admin->cache.counter > 0; in lan966x_vcap_cache_write()
460 lan_wr(admin->cache.counter, lan966x, in lan966x_vcap_cache_write()
461 VCAP_CNT_DAT(admin->tgt_inst, 0)); in lan966x_vcap_cache_write()
463 if (admin->vtype == VCAP_TYPE_ES0) in lan966x_vcap_cache_write()
464 lan966x_es0_write_esdx_counter(lan966x, admin, start); in lan966x_vcap_cache_write()
478 struct lan966x *lan966x = port->lan966x; in lan966x_vcap_cache_read() local
479 int instance = admin->tgt_inst; in lan966x_vcap_cache_read()
482 keystr = &admin->cache.keystream[start]; in lan966x_vcap_cache_read()
483 mskstr = &admin->cache.maskstream[start]; in lan966x_vcap_cache_read()
484 actstr = &admin->cache.actionstream[start]; in lan966x_vcap_cache_read()
489 lan_rd(lan966x, VCAP_ENTRY_DAT(instance, i)); in lan966x_vcap_cache_read()
491 ~lan_rd(lan966x, VCAP_MASK_DAT(instance, i)); in lan966x_vcap_cache_read()
498 lan_rd(lan966x, VCAP_ACTION_DAT(instance, i)); in lan966x_vcap_cache_read()
501 admin->cache.counter = in lan966x_vcap_cache_read()
502 lan_rd(lan966x, VCAP_CNT_DAT(instance, 0)); in lan966x_vcap_cache_read()
503 admin->cache.sticky = admin->cache.counter > 0; in lan966x_vcap_cache_read()
505 if (admin->vtype == VCAP_TYPE_ES0) in lan966x_vcap_cache_read()
506 lan966x_es0_read_esdx_counter(lan966x, admin, start); in lan966x_vcap_cache_read()
516 struct lan966x *lan966x = port->lan966x; in lan966x_vcap_range_init() local
518 __lan966x_vcap_range_init(lan966x, admin, addr, count); in lan966x_vcap_range_init()
528 struct lan966x *lan966x = port->lan966x; in lan966x_vcap_update() local
535 lan966x, VCAP_MV_CFG(admin->tgt_inst)); in lan966x_vcap_update()
544 lan966x, VCAP_UPDATE_CTRL(admin->tgt_inst)); in lan966x_vcap_update()
546 lan966x_vcap_wait_update(lan966x, admin->tgt_inst); in lan966x_vcap_update()
554 struct lan966x *lan966x = port->lan966x; in lan966x_vcap_move() local
559 mv_size = count - 1; in lan966x_vcap_move()
561 mv_num_pos = offset - 1; in lan966x_vcap_move()
564 mv_num_pos = -offset - 1; in lan966x_vcap_move()
570 lan966x, VCAP_MV_CFG(admin->tgt_inst)); in lan966x_vcap_move()
579 lan966x, VCAP_UPDATE_CTRL(admin->tgt_inst)); in lan966x_vcap_move()
581 lan966x_vcap_wait_update(lan966x, admin->tgt_inst); in lan966x_vcap_move()
601 kfree(admin->cache.keystream); in lan966x_vcap_admin_free()
602 kfree(admin->cache.maskstream); in lan966x_vcap_admin_free()
603 kfree(admin->cache.actionstream); in lan966x_vcap_admin_free()
604 mutex_destroy(&admin->lock); in lan966x_vcap_admin_free()
609 lan966x_vcap_admin_alloc(struct lan966x *lan966x, struct vcap_control *ctrl, in lan966x_vcap_admin_alloc() argument
616 return ERR_PTR(-ENOMEM); in lan966x_vcap_admin_alloc()
618 mutex_init(&admin->lock); in lan966x_vcap_admin_alloc()
619 INIT_LIST_HEAD(&admin->list); in lan966x_vcap_admin_alloc()
620 INIT_LIST_HEAD(&admin->rules); in lan966x_vcap_admin_alloc()
621 INIT_LIST_HEAD(&admin->enabled); in lan966x_vcap_admin_alloc()
623 admin->vtype = cfg->vtype; in lan966x_vcap_admin_alloc()
624 admin->vinst = 0; in lan966x_vcap_admin_alloc()
625 admin->ingress = cfg->ingress; in lan966x_vcap_admin_alloc()
626 admin->w32be = true; in lan966x_vcap_admin_alloc()
627 admin->tgt_inst = cfg->tgt_inst; in lan966x_vcap_admin_alloc()
629 admin->lookups = cfg->lookups; in lan966x_vcap_admin_alloc()
630 admin->lookups_per_instance = cfg->lookups; in lan966x_vcap_admin_alloc()
632 admin->first_cid = cfg->first_cid; in lan966x_vcap_admin_alloc()
633 admin->last_cid = cfg->last_cid; in lan966x_vcap_admin_alloc()
635 admin->cache.keystream = kzalloc(STREAMSIZE, GFP_KERNEL); in lan966x_vcap_admin_alloc()
636 admin->cache.maskstream = kzalloc(STREAMSIZE, GFP_KERNEL); in lan966x_vcap_admin_alloc()
637 admin->cache.actionstream = kzalloc(STREAMSIZE, GFP_KERNEL); in lan966x_vcap_admin_alloc()
638 if (!admin->cache.keystream || in lan966x_vcap_admin_alloc()
639 !admin->cache.maskstream || in lan966x_vcap_admin_alloc()
640 !admin->cache.actionstream) { in lan966x_vcap_admin_alloc()
642 return ERR_PTR(-ENOMEM); in lan966x_vcap_admin_alloc()
648 static void lan966x_vcap_block_init(struct lan966x *lan966x, in lan966x_vcap_block_init() argument
652 admin->first_valid_addr = 0; in lan966x_vcap_block_init()
653 admin->last_used_addr = cfg->count; in lan966x_vcap_block_init()
654 admin->last_valid_addr = cfg->count - 1; in lan966x_vcap_block_init()
657 lan966x, VCAP_CORE_IDX(admin->tgt_inst)); in lan966x_vcap_block_init()
659 lan966x, VCAP_CORE_MAP(admin->tgt_inst)); in lan966x_vcap_block_init()
661 __lan966x_vcap_range_init(lan966x, admin, admin->first_valid_addr, in lan966x_vcap_block_init()
662 admin->last_valid_addr - in lan966x_vcap_block_init()
663 admin->first_valid_addr); in lan966x_vcap_block_init()
666 static void lan966x_vcap_port_key_deselection(struct lan966x *lan966x, in lan966x_vcap_port_key_deselection() argument
671 switch (admin->vtype) { in lan966x_vcap_port_key_deselection()
677 for (int p = 0; p < lan966x->num_phys_ports; ++p) { in lan966x_vcap_port_key_deselection()
678 if (!lan966x->ports[p]) in lan966x_vcap_port_key_deselection()
682 lan_wr(val, lan966x, ANA_VCAP_S1_CFG(p, l)); in lan966x_vcap_port_key_deselection()
685 ANA_VCAP_CFG_S1_ENA, lan966x, in lan966x_vcap_port_key_deselection()
691 for (int p = 0; p < lan966x->num_phys_ports; ++p) in lan966x_vcap_port_key_deselection()
692 lan_wr(0, lan966x, ANA_VCAP_S2_CFG(p)); in lan966x_vcap_port_key_deselection()
696 for (int p = 0; p < lan966x->num_phys_ports; ++p) in lan966x_vcap_port_key_deselection()
698 REW_PORT_CFG_ES0_EN, lan966x, in lan966x_vcap_port_key_deselection()
703 lan966x_vcaps[admin->vtype].name); in lan966x_vcap_port_key_deselection()
708 int lan966x_vcap_init(struct lan966x *lan966x) in lan966x_vcap_init() argument
717 return -ENOMEM; in lan966x_vcap_init()
719 ctrl->vcaps = lan966x_vcaps; in lan966x_vcap_init()
720 ctrl->stats = &lan966x_vcap_stats; in lan966x_vcap_init()
721 ctrl->ops = &lan966x_vcap_ops; in lan966x_vcap_init()
723 INIT_LIST_HEAD(&ctrl->list); in lan966x_vcap_init()
727 admin = lan966x_vcap_admin_alloc(lan966x, ctrl, cfg); in lan966x_vcap_init()
731 lan966x_vcap_block_init(lan966x, admin, cfg); in lan966x_vcap_init()
732 lan966x_vcap_port_key_deselection(lan966x, admin); in lan966x_vcap_init()
734 list_add_tail(&admin->list, &ctrl->list); in lan966x_vcap_init()
737 dir = vcap_debugfs(lan966x->dev, lan966x->debugfs_root, ctrl); in lan966x_vcap_init()
738 for (int p = 0; p < lan966x->num_phys_ports; ++p) { in lan966x_vcap_init()
739 if (lan966x->ports[p]) { in lan966x_vcap_init()
740 vcap_port_debugfs(lan966x->dev, dir, ctrl, in lan966x_vcap_init()
741 lan966x->ports[p]->dev); in lan966x_vcap_init()
744 ANA_VCAP_S2_CFG_ENA, lan966x, in lan966x_vcap_init()
745 ANA_VCAP_S2_CFG(lan966x->ports[p]->chip_port)); in lan966x_vcap_init()
748 ANA_VCAP_CFG_S1_ENA, lan966x, in lan966x_vcap_init()
749 ANA_VCAP_CFG(lan966x->ports[p]->chip_port)); in lan966x_vcap_init()
752 REW_PORT_CFG_ES0_EN, lan966x, in lan966x_vcap_init()
753 REW_PORT_CFG(lan966x->ports[p]->chip_port)); in lan966x_vcap_init()
759 REW_STAT_CFG_STAT_MODE, lan966x, in lan966x_vcap_init()
762 lan966x->vcap_ctrl = ctrl; in lan966x_vcap_init()
767 void lan966x_vcap_deinit(struct lan966x *lan966x) in lan966x_vcap_deinit() argument
772 ctrl = lan966x->vcap_ctrl; in lan966x_vcap_deinit()
776 list_for_each_entry_safe(admin, admin_next, &ctrl->list, list) { in lan966x_vcap_deinit()
777 lan966x_vcap_port_key_deselection(lan966x, admin); in lan966x_vcap_deinit()
779 list_del(&admin->list); in lan966x_vcap_deinit()