Lines Matching full:span
46 struct mlxsw_sp_span *span; member
77 return atomic_read(&mlxsw_sp->span->active_entries_count); in mlxsw_sp_span_occ_get()
83 struct mlxsw_sp_span *span; in mlxsw_sp_span_init() local
90 span = kzalloc(struct_size(span, entries, entries_count), GFP_KERNEL); in mlxsw_sp_span_init()
91 if (!span) in mlxsw_sp_span_init()
93 refcount_set(&span->policer_id_base_ref_count, 0); in mlxsw_sp_span_init()
94 span->entries_count = entries_count; in mlxsw_sp_span_init()
95 atomic_set(&span->active_entries_count, 0); in mlxsw_sp_span_init()
96 mutex_init(&span->analyzed_ports_lock); in mlxsw_sp_span_init()
97 INIT_LIST_HEAD(&span->analyzed_ports_list); in mlxsw_sp_span_init()
98 INIT_LIST_HEAD(&span->trigger_entries_list); in mlxsw_sp_span_init()
99 span->mlxsw_sp = mlxsw_sp; in mlxsw_sp_span_init()
100 mlxsw_sp->span = span; in mlxsw_sp_span_init()
102 for (i = 0; i < mlxsw_sp->span->entries_count; i++) in mlxsw_sp_span_init()
103 mlxsw_sp->span->entries[i].id = i; in mlxsw_sp_span_init()
111 INIT_WORK(&span->work, mlxsw_sp_span_respin_work); in mlxsw_sp_span_init()
116 mutex_destroy(&mlxsw_sp->span->analyzed_ports_lock); in mlxsw_sp_span_init()
117 kfree(mlxsw_sp->span); in mlxsw_sp_span_init()
125 cancel_work_sync(&mlxsw_sp->span->work); in mlxsw_sp_span_fini()
128 WARN_ON_ONCE(!list_empty(&mlxsw_sp->span->trigger_entries_list)); in mlxsw_sp_span_fini()
129 WARN_ON_ONCE(!list_empty(&mlxsw_sp->span->analyzed_ports_list)); in mlxsw_sp_span_fini()
130 mutex_destroy(&mlxsw_sp->span->analyzed_ports_lock); in mlxsw_sp_span_fini()
131 kfree(mlxsw_sp->span); in mlxsw_sp_span_fini()
804 static int mlxsw_sp_span_policer_id_base_set(struct mlxsw_sp_span *span, in mlxsw_sp_span_policer_id_base_set() argument
807 struct mlxsw_sp *mlxsw_sp = span->mlxsw_sp; in mlxsw_sp_span_policer_id_base_set()
811 /* Policers set on SPAN agents must be in the range of in mlxsw_sp_span_policer_id_base_set()
816 if (refcount_read(&span->policer_id_base_ref_count)) { in mlxsw_sp_span_policer_id_base_set()
817 if (policer_id < span->policer_id_base || in mlxsw_sp_span_policer_id_base_set()
818 policer_id >= span->policer_id_base + span->entries_count) in mlxsw_sp_span_policer_id_base_set()
821 refcount_inc(&span->policer_id_base_ref_count); in mlxsw_sp_span_policer_id_base_set()
832 span->policer_id_base = policer_id_base; in mlxsw_sp_span_policer_id_base_set()
833 refcount_set(&span->policer_id_base_ref_count, 1); in mlxsw_sp_span_policer_id_base_set()
838 static void mlxsw_sp_span_policer_id_base_unset(struct mlxsw_sp_span *span) in mlxsw_sp_span_policer_id_base_unset() argument
840 if (refcount_dec_and_test(&span->policer_id_base_ref_count)) in mlxsw_sp_span_policer_id_base_unset()
841 span->policer_id_base = 0; in mlxsw_sp_span_policer_id_base_unset()
854 for (i = 0; i < mlxsw_sp->span->entries_count; i++) { in mlxsw_sp_span_entry_create()
855 if (!refcount_read(&mlxsw_sp->span->entries[i].ref_count)) { in mlxsw_sp_span_entry_create()
856 span_entry = &mlxsw_sp->span->entries[i]; in mlxsw_sp_span_entry_create()
866 err = mlxsw_sp_span_policer_id_base_set(mlxsw_sp->span, in mlxsw_sp_span_entry_create()
872 atomic_inc(&mlxsw_sp->span->active_entries_count); in mlxsw_sp_span_entry_create()
885 atomic_dec(&mlxsw_sp->span->active_entries_count); in mlxsw_sp_span_entry_destroy()
887 mlxsw_sp_span_policer_id_base_unset(mlxsw_sp->span); in mlxsw_sp_span_entry_destroy()
896 for (i = 0; i < mlxsw_sp->span->entries_count; i++) { in mlxsw_sp_span_entry_find_by_port()
897 struct mlxsw_sp_span_entry *curr = &mlxsw_sp->span->entries[i]; in mlxsw_sp_span_entry_find_by_port()
917 for (i = 0; i < mlxsw_sp->span->entries_count; i++) { in mlxsw_sp_span_entry_find_by_id()
918 struct mlxsw_sp_span_entry *curr = &mlxsw_sp->span->entries[i]; in mlxsw_sp_span_entry_find_by_id()
933 for (i = 0; i < mlxsw_sp->span->entries_count; i++) { in mlxsw_sp_span_entry_find_by_parms()
934 struct mlxsw_sp_span_entry *curr = &mlxsw_sp->span->entries[i]; in mlxsw_sp_span_entry_find_by_parms()
994 mlxsw_sp_span_analyzed_port_find(struct mlxsw_sp_span *span, u8 local_port, in mlxsw_sp_span_analyzed_port_find() argument
999 list_for_each_entry(analyzed_port, &span->analyzed_ports_list, list) { in mlxsw_sp_span_analyzed_port_find()
1012 struct mlxsw_sp_span *span = mlxsw_sp->span; in mlxsw_sp_span_entry_ops() local
1015 for (i = 0; i < span->span_entry_ops_arr_size; ++i) in mlxsw_sp_span_entry_ops()
1016 if (span->span_entry_ops_arr[i]->can_handle(to_dev)) in mlxsw_sp_span_entry_ops()
1017 return span->span_entry_ops_arr[i]; in mlxsw_sp_span_entry_ops()
1024 struct mlxsw_sp_span *span; in mlxsw_sp_span_respin_work() local
1028 span = container_of(work, struct mlxsw_sp_span, work); in mlxsw_sp_span_respin_work()
1029 mlxsw_sp = span->mlxsw_sp; in mlxsw_sp_span_respin_work()
1032 for (i = 0; i < mlxsw_sp->span->entries_count; i++) { in mlxsw_sp_span_respin_work()
1033 struct mlxsw_sp_span_entry *curr = &mlxsw_sp->span->entries[i]; in mlxsw_sp_span_respin_work()
1053 if (atomic_read(&mlxsw_sp->span->active_entries_count) == 0) in mlxsw_sp_span_respin()
1055 mlxsw_core_schedule_work(&mlxsw_sp->span->work); in mlxsw_sp_span_respin()
1105 mlxsw_sp_span_analyzed_port_create(struct mlxsw_sp_span *span, in mlxsw_sp_span_analyzed_port_create() argument
1119 list_add_tail(&analyzed_port->list, &span->analyzed_ports_list); in mlxsw_sp_span_analyzed_port_create()
1161 mutex_lock(&mlxsw_sp->span->analyzed_ports_lock); in mlxsw_sp_span_analyzed_port_get()
1163 analyzed_port = mlxsw_sp_span_analyzed_port_find(mlxsw_sp->span, in mlxsw_sp_span_analyzed_port_get()
1170 analyzed_port = mlxsw_sp_span_analyzed_port_create(mlxsw_sp->span, in mlxsw_sp_span_analyzed_port_get()
1177 mutex_unlock(&mlxsw_sp->span->analyzed_ports_lock); in mlxsw_sp_span_analyzed_port_get()
1188 mutex_lock(&mlxsw_sp->span->analyzed_ports_lock); in mlxsw_sp_span_analyzed_port_put()
1190 analyzed_port = mlxsw_sp_span_analyzed_port_find(mlxsw_sp->span, in mlxsw_sp_span_analyzed_port_put()
1201 mutex_unlock(&mlxsw_sp->span->analyzed_ports_lock); in mlxsw_sp_span_analyzed_port_put()
1205 __mlxsw_sp_span_trigger_port_bind(struct mlxsw_sp_span *span, in __mlxsw_sp_span_trigger_port_bind() argument
1226 return mlxsw_reg_write(span->mlxsw_sp->core, MLXSW_REG(mpar), mpar_pl); in __mlxsw_sp_span_trigger_port_bind()
1233 return __mlxsw_sp_span_trigger_port_bind(trigger_entry->span, in mlxsw_sp_span_trigger_port_bind()
1241 __mlxsw_sp_span_trigger_port_bind(trigger_entry->span, trigger_entry, in mlxsw_sp_span_trigger_port_unbind()
1340 struct mlxsw_sp *mlxsw_sp = trigger_entry->span->mlxsw_sp; in mlxsw_sp2_span_trigger_global_bind()
1388 struct mlxsw_sp *mlxsw_sp = trigger_entry->span->mlxsw_sp; in __mlxsw_sp2_span_trigger_global_enable()
1459 struct mlxsw_sp_span *span = trigger_entry->span; in mlxsw_sp_span_trigger_ops_set() local
1477 trigger_entry->ops = span->span_trigger_ops_arr[type]; in mlxsw_sp_span_trigger_ops_set()
1481 mlxsw_sp_span_trigger_entry_create(struct mlxsw_sp_span *span, in mlxsw_sp_span_trigger_entry_create() argument
1499 trigger_entry->span = span; in mlxsw_sp_span_trigger_entry_create()
1501 list_add_tail(&trigger_entry->list, &span->trigger_entries_list); in mlxsw_sp_span_trigger_entry_create()
1516 mlxsw_sp_span_trigger_entry_destroy(struct mlxsw_sp_span *span, in mlxsw_sp_span_trigger_entry_destroy() argument
1526 mlxsw_sp_span_trigger_entry_find(struct mlxsw_sp_span *span, in mlxsw_sp_span_trigger_entry_find() argument
1532 list_for_each_entry(trigger_entry, &span->trigger_entries_list, list) { in mlxsw_sp_span_trigger_entry_find()
1554 trigger_entry = mlxsw_sp_span_trigger_entry_find(mlxsw_sp->span, in mlxsw_sp_span_agent_bind()
1564 trigger_entry = mlxsw_sp_span_trigger_entry_create(mlxsw_sp->span, in mlxsw_sp_span_agent_bind()
1588 trigger_entry = mlxsw_sp_span_trigger_entry_find(mlxsw_sp->span, in mlxsw_sp_span_agent_unbind()
1597 mlxsw_sp_span_trigger_entry_destroy(mlxsw_sp->span, trigger_entry); in mlxsw_sp_span_agent_unbind()
1608 trigger_entry = mlxsw_sp_span_trigger_entry_find(mlxsw_sp->span, in mlxsw_sp_span_trigger_enable()
1625 trigger_entry = mlxsw_sp_span_trigger_entry_find(mlxsw_sp->span, in mlxsw_sp_span_trigger_disable()
1645 mlxsw_sp->span->span_trigger_ops_arr = mlxsw_sp1_span_trigger_ops_arr; in mlxsw_sp1_span_init()
1646 mlxsw_sp->span->span_entry_ops_arr = mlxsw_sp1_span_entry_ops_arr; in mlxsw_sp1_span_init()
1647 mlxsw_sp->span->span_entry_ops_arr_size = arr_size; in mlxsw_sp1_span_init()
1674 mlxsw_sp->span->span_trigger_ops_arr = mlxsw_sp2_span_trigger_ops_arr; in mlxsw_sp2_span_init()
1675 mlxsw_sp->span->span_entry_ops_arr = mlxsw_sp2_span_entry_ops_arr; in mlxsw_sp2_span_init()
1676 mlxsw_sp->span->span_entry_ops_arr_size = arr_size; in mlxsw_sp2_span_init()