Lines Matching +full:sparx +full:- +full:5
1 // SPDX-License-Identifier: GPL-2.0+
7 * https://github.com/microchip-ung/sparx-5_reginfo
66 .vtype = VCAP_TYPE_IS0, /* CLM-0 */
72 .last_cid = SPARX5_VCAP_CID_IS0_L2 - 1,
73 .blockno = 8, /* Maps block 8-9 */
78 .vtype = VCAP_TYPE_IS0, /* CLM-1 */
84 .last_cid = SPARX5_VCAP_CID_IS0_L4 - 1,
85 .blockno = 6, /* Maps block 6-7 */
90 .vtype = VCAP_TYPE_IS0, /* CLM-2 */
97 .blockno = 4, /* Maps block 4-5 */
102 .vtype = VCAP_TYPE_IS2, /* IS2-0 */
108 .last_cid = SPARX5_VCAP_CID_IS2_L2 - 1,
109 .blockno = 0, /* Maps block 0-1 */
114 .vtype = VCAP_TYPE_IS2, /* IS2-1 */
116 .map_id = 5,
121 .blockno = 2, /* Maps block 2-3 */
173 fname, sparx5_vcaps[admin->vtype].name); in sparx5_vcap_type_err()
211 u32 size = count - 1; in _sparx5_vcap_range_init()
213 switch (admin->vtype) { in _sparx5_vcap_range_init()
267 _sparx5_vcap_range_init(sparx5, admin, admin->first_valid_addr, in sparx5_vcap_block_init()
268 admin->last_valid_addr - in sparx5_vcap_block_init()
269 admin->first_valid_addr); in sparx5_vcap_block_init()
278 return vcap_keyset_name(port->sparx5->vcap_ctrl, keyset); in sparx5_vcap_keyset_name()
284 return (rule->vcap_chain_id >= SPARX5_VCAP_CID_IS0_L0 && in sparx5_vcap_is0_is_first_chain()
285 rule->vcap_chain_id < SPARX5_VCAP_CID_IS0_L1) || in sparx5_vcap_is0_is_first_chain()
286 ((rule->vcap_chain_id >= SPARX5_VCAP_CID_IS0_L2 && in sparx5_vcap_is0_is_first_chain()
287 rule->vcap_chain_id < SPARX5_VCAP_CID_IS0_L3)) || in sparx5_vcap_is0_is_first_chain()
288 ((rule->vcap_chain_id >= SPARX5_VCAP_CID_IS0_L4 && in sparx5_vcap_is0_is_first_chain()
289 rule->vcap_chain_id < SPARX5_VCAP_CID_IS0_L5)); in sparx5_vcap_is0_is_first_chain()
295 return (rule->vcap_chain_id >= SPARX5_VCAP_CID_IS2_L0 && in sparx5_vcap_is2_is_first_chain()
296 rule->vcap_chain_id < SPARX5_VCAP_CID_IS2_L1) || in sparx5_vcap_is2_is_first_chain()
297 ((rule->vcap_chain_id >= SPARX5_VCAP_CID_IS2_L2 && in sparx5_vcap_is2_is_first_chain()
298 rule->vcap_chain_id < SPARX5_VCAP_CID_IS2_L3)); in sparx5_vcap_is2_is_first_chain()
303 return (rule->vcap_chain_id >= SPARX5_VCAP_CID_ES2_L0 && in sparx5_vcap_es2_is_first_chain()
304 rule->vcap_chain_id < SPARX5_VCAP_CID_ES2_L1); in sparx5_vcap_es2_is_first_chain()
315 range = port->portno / BITS_PER_TYPE(u32); in sparx5_vcap_add_ingress_range_port_mask()
316 /* Port bit set to match-any */ in sparx5_vcap_add_ingress_range_port_mask()
317 port_mask = ~BIT(port->portno % BITS_PER_TYPE(u32)); in sparx5_vcap_add_ingress_range_port_mask()
331 /* Port bit set to match-any */ in sparx5_vcap_add_wide_port_mask()
334 range = port->portno / BITS_PER_BYTE; in sparx5_vcap_add_wide_port_mask()
335 port_mask.mask[range] = ~BIT(port->portno % BITS_PER_BYTE); in sparx5_vcap_add_wide_port_mask()
347 * 0-2: Physical/Logical egress port number 0-31, 32–63, 64. in sparx5_vcap_add_egress_range_port_mask()
348 * 3-5: Virtual Interface Number 0-31, 32-63, 64. in sparx5_vcap_add_egress_range_port_mask()
349 * 6: CPU queue Number 0-7. in sparx5_vcap_add_egress_range_port_mask()
351 * Use physical/logical port ranges (0-2) in sparx5_vcap_add_egress_range_port_mask()
353 range = port->portno / BITS_PER_TYPE(u32); in sparx5_vcap_add_egress_range_port_mask()
354 /* Port bit set to match-any */ in sparx5_vcap_add_egress_range_port_mask()
355 port_mask = ~BIT(port->portno % BITS_PER_TYPE(u32)); in sparx5_vcap_add_egress_range_port_mask()
374 lookup = 5; in sparx5_vcap_is0_cid_to_lookup()
427 struct sparx5 *sparx5 = port->sparx5; in sparx5_vcap_is0_get_port_keysets()
428 int portno = port->portno; in sparx5_vcap_is0_get_port_keysets()
481 struct sparx5 *sparx5 = port->sparx5; in sparx5_vcap_is2_get_port_keysets()
482 int portno = port->portno; in sparx5_vcap_is2_get_port_keysets()
568 /* IS2 non-classified frames generate MAC_ETYPE */ in sparx5_vcap_is2_get_port_keysets()
610 struct sparx5 *sparx5 = port->sparx5; in sparx5_vcap_es0_get_port_keysets()
611 int portno = port->portno; in sparx5_vcap_es0_get_port_keysets()
635 struct sparx5 *sparx5 = port->sparx5; in sparx5_vcap_es2_get_port_keysets()
636 int portno = port->portno; in sparx5_vcap_es2_get_port_keysets()
698 int lookup, err = -EINVAL; in sparx5_vcap_get_port_keyset()
701 switch (admin->vtype) { in sparx5_vcap_get_port_keyset()
722 sparx5_vcap_type_err(port->sparx5, admin, __func__); in sparx5_vcap_get_port_keyset()
734 switch (admin->vtype) { in sparx5_vcap_is_known_etype()
771 if (!kslist || kslist->cnt == 0) in sparx5_vcap_validate_keyset()
778 switch (admin->vtype) { in sparx5_vcap_validate_keyset()
780 lookup = sparx5_vcap_is0_cid_to_lookup(rule->vcap_chain_id); in sparx5_vcap_validate_keyset()
785 lookup = sparx5_vcap_is2_cid_to_lookup(rule->vcap_chain_id); in sparx5_vcap_validate_keyset()
793 lookup = sparx5_vcap_es2_cid_to_lookup(rule->vcap_chain_id); in sparx5_vcap_validate_keyset()
799 sparx5_vcap_type_err(port->sparx5, admin, __func__); in sparx5_vcap_validate_keyset()
804 for (idx = 0; idx < kslist->cnt; ++idx) in sparx5_vcap_validate_keyset()
806 if (kslist->keysets[idx] == keysets[jdx]) in sparx5_vcap_validate_keyset()
807 return kslist->keysets[idx]; in sparx5_vcap_validate_keyset()
811 sparx5_vcap_keyset_name(ndev, kslist->keysets[0])); in sparx5_vcap_validate_keyset()
813 return -ENOENT; in sparx5_vcap_validate_keyset()
825 if (field && field->width == SPX5_PORTS) in sparx5_vcap_ingress_add_default_fields()
827 else if (field && field->width == BITS_PER_TYPE(u32)) in sparx5_vcap_ingress_add_default_fields()
832 sparx5_vcap_keyset_name(ndev, rule->keyset)); in sparx5_vcap_ingress_add_default_fields()
834 if (admin->vtype == VCAP_TYPE_IS0) in sparx5_vcap_ingress_add_default_fields()
854 vcap_rule_add_key_u32(rule, VCAP_KF_IF_EGR_PORT_NO, port->portno, ~0); in sparx5_vcap_es0_add_default_fields()
891 switch (admin->vtype) { in sparx5_vcap_add_default_fields()
904 sparx5_vcap_type_err(port->sparx5, admin, __func__); in sparx5_vcap_add_default_fields()
912 memset(admin->cache.keystream, 0, STREAMSIZE); in sparx5_vcap_cache_erase()
913 memset(admin->cache.maskstream, 0, STREAMSIZE); in sparx5_vcap_cache_erase()
914 memset(admin->cache.actionstream, 0, STREAMSIZE); in sparx5_vcap_cache_erase()
915 memset(&admin->cache.counter, 0, sizeof(admin->cache.counter)); in sparx5_vcap_cache_erase()
927 keystr = &admin->cache.keystream[start]; in sparx5_vcap_is0_cache_write()
928 mskstr = &admin->cache.maskstream[start]; in sparx5_vcap_is0_cache_write()
929 actstr = &admin->cache.actionstream[start]; in sparx5_vcap_is0_cache_write()
934 /* Avoid 'match-off' by setting value & mask */ in sparx5_vcap_is0_cache_write()
955 spx5_wr(admin->cache.counter, sparx5, in sparx5_vcap_is0_cache_write()
968 keystr = &admin->cache.keystream[start]; in sparx5_vcap_is2_cache_write()
969 mskstr = &admin->cache.maskstream[start]; in sparx5_vcap_is2_cache_write()
970 actstr = &admin->cache.actionstream[start]; in sparx5_vcap_is2_cache_write()
975 /* Avoid 'match-off' by setting value & mask */ in sparx5_vcap_is2_cache_write()
996 if (admin->vinst == 0) in sparx5_vcap_is2_cache_write()
997 spx5_wr(admin->cache.counter, sparx5, in sparx5_vcap_is2_cache_write()
1000 spx5_wr(admin->cache.counter, sparx5, in sparx5_vcap_is2_cache_write()
1002 spx5_wr(admin->cache.sticky, sparx5, in sparx5_vcap_is2_cache_write()
1011 mutex_lock(&sparx5->queue_stats_lock); in sparx5_es0_write_esdx_counter()
1013 spx5_wr(admin->cache.counter, sparx5, in sparx5_es0_write_esdx_counter()
1016 mutex_unlock(&sparx5->queue_stats_lock); in sparx5_es0_write_esdx_counter()
1028 keystr = &admin->cache.keystream[start]; in sparx5_vcap_es0_cache_write()
1029 mskstr = &admin->cache.maskstream[start]; in sparx5_vcap_es0_cache_write()
1030 actstr = &admin->cache.actionstream[start]; in sparx5_vcap_es0_cache_write()
1035 /* Avoid 'match-off' by setting value & mask */ in sparx5_vcap_es0_cache_write()
1055 spx5_wr(admin->cache.counter, sparx5, VCAP_ES0_VCAP_CNT_DAT(0)); in sparx5_vcap_es0_cache_write()
1069 keystr = &admin->cache.keystream[start]; in sparx5_vcap_es2_cache_write()
1070 mskstr = &admin->cache.maskstream[start]; in sparx5_vcap_es2_cache_write()
1071 actstr = &admin->cache.actionstream[start]; in sparx5_vcap_es2_cache_write()
1076 /* Avoid 'match-off' by setting value & mask */ in sparx5_vcap_es2_cache_write()
1097 spx5_wr(admin->cache.counter, sparx5, EACL_ES2_CNT(start)); in sparx5_vcap_es2_cache_write()
1098 spx5_wr(admin->cache.sticky, sparx5, VCAP_ES2_VCAP_CNT_DAT(0)); in sparx5_vcap_es2_cache_write()
1110 struct sparx5 *sparx5 = port->sparx5; in sparx5_vcap_cache_write()
1112 switch (admin->vtype) { in sparx5_vcap_cache_write()
1140 keystr = &admin->cache.keystream[start]; in sparx5_vcap_is0_cache_read()
1141 mskstr = &admin->cache.maskstream[start]; in sparx5_vcap_is0_cache_read()
1142 actstr = &admin->cache.actionstream[start]; in sparx5_vcap_is0_cache_read()
1159 admin->cache.counter = in sparx5_vcap_is0_cache_read()
1161 admin->cache.sticky = in sparx5_vcap_is0_cache_read()
1175 keystr = &admin->cache.keystream[start]; in sparx5_vcap_is2_cache_read()
1176 mskstr = &admin->cache.maskstream[start]; in sparx5_vcap_is2_cache_read()
1177 actstr = &admin->cache.actionstream[start]; in sparx5_vcap_is2_cache_read()
1195 if (admin->vinst == 0) in sparx5_vcap_is2_cache_read()
1196 admin->cache.counter = in sparx5_vcap_is2_cache_read()
1199 admin->cache.counter = in sparx5_vcap_is2_cache_read()
1201 admin->cache.sticky = in sparx5_vcap_is2_cache_read()
1212 mutex_lock(&sparx5->queue_stats_lock); in sparx5_es0_read_esdx_counter()
1216 mutex_unlock(&sparx5->queue_stats_lock); in sparx5_es0_read_esdx_counter()
1218 admin->cache.counter = counter; in sparx5_es0_read_esdx_counter()
1230 keystr = &admin->cache.keystream[start]; in sparx5_vcap_es0_cache_read()
1231 mskstr = &admin->cache.maskstream[start]; in sparx5_vcap_es0_cache_read()
1232 actstr = &admin->cache.actionstream[start]; in sparx5_vcap_es0_cache_read()
1249 admin->cache.counter = in sparx5_vcap_es0_cache_read()
1251 admin->cache.sticky = admin->cache.counter; in sparx5_vcap_es0_cache_read()
1265 keystr = &admin->cache.keystream[start]; in sparx5_vcap_es2_cache_read()
1266 mskstr = &admin->cache.maskstream[start]; in sparx5_vcap_es2_cache_read()
1267 actstr = &admin->cache.actionstream[start]; in sparx5_vcap_es2_cache_read()
1285 admin->cache.counter = in sparx5_vcap_es2_cache_read()
1287 admin->cache.sticky = in sparx5_vcap_es2_cache_read()
1300 struct sparx5 *sparx5 = port->sparx5; in sparx5_vcap_cache_read()
1302 switch (admin->vtype) { in sparx5_vcap_cache_read()
1327 struct sparx5 *sparx5 = port->sparx5; in sparx5_vcap_range_init()
1395 struct sparx5 *sparx5 = port->sparx5; in sparx5_vcap_update()
1397 switch (admin->vtype) { in sparx5_vcap_update()
1479 struct sparx5 *sparx5 = port->sparx5; in sparx5_vcap_move()
1484 mv_size = count - 1; in sparx5_vcap_move()
1486 mv_num_pos = offset - 1; in sparx5_vcap_move()
1489 mv_num_pos = -offset - 1; in sparx5_vcap_move()
1493 switch (admin->vtype) { in sparx5_vcap_move()
1539 struct sparx5 *sparx5 = port->sparx5; in sparx5_vcap_is0_set_port_keyset()
1540 int portno = port->portno; in sparx5_vcap_is0_set_port_keyset()
1628 struct sparx5 *sparx5 = port->sparx5; in sparx5_vcap_is2_set_port_keyset()
1629 int portno = port->portno; in sparx5_vcap_is2_set_port_keyset()
1721 struct sparx5 *sparx5 = port->sparx5; in sparx5_vcap_es2_set_port_keyset()
1722 int portno = port->portno; in sparx5_vcap_es2_set_port_keyset()
1761 switch (admin->vtype) { in sparx5_vcap_set_port_keyset()
1787 sparx5_vcap_type_err(port->sparx5, admin, __func__); in sparx5_vcap_set_port_keyset()
1806 for (lookup = 0; lookup < admin->lookups; ++lookup) { in sparx5_vcap_is0_port_key_selection()
1831 for (lookup = 0; lookup < admin->lookups; ++lookup) { in sparx5_vcap_is2_port_key_selection()
1871 for (lookup = 0; lookup < admin->lookups; ++lookup) in sparx5_vcap_es2_port_key_selection()
1881 switch (admin->vtype) { in sparx5_vcap_port_key_selection()
1906 switch (admin->vtype) { in sparx5_vcap_port_key_deselection()
1908 for (lookup = 0; lookup < admin->lookups; ++lookup) in sparx5_vcap_port_key_deselection()
1927 for (lookup = 0; lookup < admin->lookups; ++lookup) in sparx5_vcap_port_key_deselection()
1944 mutex_destroy(&admin->lock); in sparx5_vcap_admin_free()
1945 kfree(admin->cache.keystream); in sparx5_vcap_admin_free()
1946 kfree(admin->cache.maskstream); in sparx5_vcap_admin_free()
1947 kfree(admin->cache.actionstream); in sparx5_vcap_admin_free()
1960 return ERR_PTR(-ENOMEM); in sparx5_vcap_admin_alloc()
1961 INIT_LIST_HEAD(&admin->list); in sparx5_vcap_admin_alloc()
1962 INIT_LIST_HEAD(&admin->rules); in sparx5_vcap_admin_alloc()
1963 INIT_LIST_HEAD(&admin->enabled); in sparx5_vcap_admin_alloc()
1964 mutex_init(&admin->lock); in sparx5_vcap_admin_alloc()
1965 admin->vtype = cfg->vtype; in sparx5_vcap_admin_alloc()
1966 admin->vinst = cfg->vinst; in sparx5_vcap_admin_alloc()
1967 admin->ingress = cfg->ingress; in sparx5_vcap_admin_alloc()
1968 admin->lookups = cfg->lookups; in sparx5_vcap_admin_alloc()
1969 admin->lookups_per_instance = cfg->lookups_per_instance; in sparx5_vcap_admin_alloc()
1970 admin->first_cid = cfg->first_cid; in sparx5_vcap_admin_alloc()
1971 admin->last_cid = cfg->last_cid; in sparx5_vcap_admin_alloc()
1972 admin->cache.keystream = in sparx5_vcap_admin_alloc()
1974 admin->cache.maskstream = in sparx5_vcap_admin_alloc()
1976 admin->cache.actionstream = in sparx5_vcap_admin_alloc()
1978 if (!admin->cache.keystream || !admin->cache.maskstream || in sparx5_vcap_admin_alloc()
1979 !admin->cache.actionstream) { in sparx5_vcap_admin_alloc()
1981 return ERR_PTR(-ENOMEM); in sparx5_vcap_admin_alloc()
1993 switch (admin->vtype) { in sparx5_vcap_block_alloc()
2000 for (idx = cfg->blockno; idx < cfg->blockno + cfg->blocks; in sparx5_vcap_block_alloc()
2004 spx5_wr(VCAP_SUPER_MAP_CORE_MAP_SET(cfg->map_id), in sparx5_vcap_block_alloc()
2007 admin->first_valid_addr = cfg->blockno * SUPER_VCAP_BLK_SIZE; in sparx5_vcap_block_alloc()
2008 admin->last_used_addr = admin->first_valid_addr + in sparx5_vcap_block_alloc()
2009 cfg->blocks * SUPER_VCAP_BLK_SIZE; in sparx5_vcap_block_alloc()
2010 admin->last_valid_addr = admin->last_used_addr - 1; in sparx5_vcap_block_alloc()
2013 admin->first_valid_addr = 0; in sparx5_vcap_block_alloc()
2014 admin->last_used_addr = cfg->count; in sparx5_vcap_block_alloc()
2015 admin->last_valid_addr = cfg->count - 1; in sparx5_vcap_block_alloc()
2025 admin->first_valid_addr = 0; in sparx5_vcap_block_alloc()
2026 admin->last_used_addr = cfg->count; in sparx5_vcap_block_alloc()
2027 admin->last_valid_addr = cfg->count - 1; in sparx5_vcap_block_alloc()
2054 * - Create administrative state for each available VCAP in sparx5_vcap_init()
2055 * - Lists of rules in sparx5_vcap_init()
2056 * - Address information in sparx5_vcap_init()
2057 * - Initialize VCAP blocks in sparx5_vcap_init()
2058 * - Configure port keysets in sparx5_vcap_init()
2062 return -ENOMEM; in sparx5_vcap_init()
2064 sparx5->vcap_ctrl = ctrl; in sparx5_vcap_init()
2066 ctrl->vcaps = sparx5_vcaps; in sparx5_vcap_init()
2067 ctrl->stats = &sparx5_vcap_stats; in sparx5_vcap_init()
2069 ctrl->ops = &sparx5_vcap_ops; in sparx5_vcap_init()
2071 INIT_LIST_HEAD(&ctrl->list); in sparx5_vcap_init()
2083 if (cfg->vinst == 0) in sparx5_vcap_init()
2085 list_add_tail(&admin->list, &ctrl->list); in sparx5_vcap_init()
2087 dir = vcap_debugfs(sparx5->dev, sparx5->debugfs_root, ctrl); in sparx5_vcap_init()
2089 if (sparx5->ports[idx]) in sparx5_vcap_init()
2090 vcap_port_debugfs(sparx5->dev, dir, ctrl, in sparx5_vcap_init()
2091 sparx5->ports[idx]->ndev); in sparx5_vcap_init()
2098 struct vcap_control *ctrl = sparx5->vcap_ctrl; in sparx5_vcap_destroy()
2104 list_for_each_entry_safe(admin, admin_next, &ctrl->list, list) { in sparx5_vcap_destroy()
2107 list_del(&admin->list); in sparx5_vcap_destroy()