Lines Matching refs:mlxsw_sp
23 struct mlxsw_sp *mlxsw_sp; member
75 const struct mlxsw_sp *mlxsw_sp = priv; in mlxsw_sp_span_occ_get() local
77 return atomic_read(&mlxsw_sp->span->active_entries_count); in mlxsw_sp_span_occ_get()
80 int mlxsw_sp_span_init(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_span_init() argument
82 struct devlink *devlink = priv_to_devlink(mlxsw_sp->core); in mlxsw_sp_span_init()
86 if (!MLXSW_CORE_RES_VALID(mlxsw_sp->core, MAX_SPAN)) in mlxsw_sp_span_init()
89 entries_count = MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_SPAN); 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()
105 err = mlxsw_sp->span_ops->init(mlxsw_sp); in mlxsw_sp_span_init()
110 mlxsw_sp_span_occ_get, mlxsw_sp); 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()
121 void mlxsw_sp_span_fini(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_span_fini() argument
123 struct devlink *devlink = priv_to_devlink(mlxsw_sp->core); in mlxsw_sp_span_fini()
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()
139 static int mlxsw_sp1_span_entry_cpu_parms(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp1_span_entry_cpu_parms() argument
167 mlxsw_sp_span_entry_phys_parms(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_span_entry_phys_parms() argument
180 struct mlxsw_sp *mlxsw_sp = dest_port->mlxsw_sp; in mlxsw_sp_span_entry_phys_configure() local
191 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mpat), mpat_pl); in mlxsw_sp_span_entry_phys_configure()
199 struct mlxsw_sp *mlxsw_sp = dest_port->mlxsw_sp; in mlxsw_sp_span_entry_deconfigure_common() local
205 mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mpat), mpat_pl); in mlxsw_sp_span_entry_deconfigure_common()
315 bridge_port = mlxsw_sp_bridge_port_find(port->mlxsw_sp->bridge, dev); in mlxsw_sp_span_entry_bridge()
446 mlxsw_sp_span_entry_gretap4_parms(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_span_entry_gretap4_parms() argument
478 struct mlxsw_sp *mlxsw_sp = dest_port->mlxsw_sp; in mlxsw_sp_span_entry_gretap4_configure() local
497 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mpat), mpat_pl); in mlxsw_sp_span_entry_gretap4_configure()
550 mlxsw_sp_span_entry_gretap6_parms(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_span_entry_gretap6_parms() argument
582 struct mlxsw_sp *mlxsw_sp = dest_port->mlxsw_sp; in mlxsw_sp_span_entry_gretap6_configure() local
600 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mpat), mpat_pl); in mlxsw_sp_span_entry_gretap6_configure()
627 mlxsw_sp_span_entry_vlan_parms(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_span_entry_vlan_parms() argument
648 struct mlxsw_sp *mlxsw_sp = dest_port->mlxsw_sp; in mlxsw_sp_span_entry_vlan_configure() local
659 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mpat), mpat_pl); in mlxsw_sp_span_entry_vlan_configure()
695 static int mlxsw_sp2_span_entry_cpu_parms(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp2_span_entry_cpu_parms() argument
699 sparmsp->dest_port = mlxsw_sp->ports[MLXSW_PORT_CPU_PORT]; in mlxsw_sp2_span_entry_cpu_parms()
744 mlxsw_sp_span_entry_nop_parms(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_span_entry_nop_parms() argument
770 mlxsw_sp_span_entry_configure(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_span_entry_configure() argument
779 if (sparms.dest_port->mlxsw_sp != mlxsw_sp) { in mlxsw_sp_span_entry_configure()
780 dev_err(mlxsw_sp->bus_info->dev, in mlxsw_sp_span_entry_configure()
788 dev_err(mlxsw_sp->bus_info->dev, "Failed to offload mirror\n"); in mlxsw_sp_span_entry_configure()
807 struct mlxsw_sp *mlxsw_sp = span->mlxsw_sp; in mlxsw_sp_span_policer_id_base_set() local
827 err = mlxsw_sp->span_ops->policer_id_base_set(mlxsw_sp, in mlxsw_sp_span_policer_id_base_set()
845 mlxsw_sp_span_entry_create(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_span_entry_create() argument
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()
876 mlxsw_sp_span_entry_configure(mlxsw_sp, span_entry, sparms); in mlxsw_sp_span_entry_create()
881 static void mlxsw_sp_span_entry_destroy(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_span_entry_destroy() argument
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()
891 mlxsw_sp_span_entry_find_by_port(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_span_entry_find_by_port() argument
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()
905 void mlxsw_sp_span_entry_invalidate(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_span_entry_invalidate() argument
913 mlxsw_sp_span_entry_find_by_id(struct mlxsw_sp *mlxsw_sp, int span_id) in mlxsw_sp_span_entry_find_by_id() argument
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()
927 mlxsw_sp_span_entry_find_by_parms(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_span_entry_find_by_parms() argument
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()
945 mlxsw_sp_span_entry_get(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_span_entry_get() argument
952 span_entry = mlxsw_sp_span_entry_find_by_parms(mlxsw_sp, to_dev, in mlxsw_sp_span_entry_get()
960 return mlxsw_sp_span_entry_create(mlxsw_sp, to_dev, ops, sparms); in mlxsw_sp_span_entry_get()
963 static int mlxsw_sp_span_entry_put(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_span_entry_put() argument
967 mlxsw_sp_span_entry_destroy(mlxsw_sp, span_entry); in mlxsw_sp_span_entry_put()
1009 mlxsw_sp_span_entry_ops(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_span_entry_ops() argument
1012 struct mlxsw_sp_span *span = mlxsw_sp->span; in mlxsw_sp_span_entry_ops()
1025 struct mlxsw_sp *mlxsw_sp; in mlxsw_sp_span_respin_work() local
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()
1039 err = curr->ops->parms_set(mlxsw_sp, curr->to_dev, &sparms); in mlxsw_sp_span_respin_work()
1045 mlxsw_sp_span_entry_configure(mlxsw_sp, curr, sparms); in mlxsw_sp_span_respin_work()
1051 void mlxsw_sp_span_respin(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_span_respin() argument
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()
1058 int mlxsw_sp_span_agent_get(struct mlxsw_sp *mlxsw_sp, int *p_span_id, in mlxsw_sp_span_agent_get() argument
1069 ops = mlxsw_sp_span_entry_ops(mlxsw_sp, to_dev); in mlxsw_sp_span_agent_get()
1071 dev_err(mlxsw_sp->bus_info->dev, "Cannot mirror to requested destination\n"); in mlxsw_sp_span_agent_get()
1076 err = ops->parms_set(mlxsw_sp, to_dev, &sparms); in mlxsw_sp_span_agent_get()
1082 span_entry = mlxsw_sp_span_entry_get(mlxsw_sp, to_dev, ops, sparms); in mlxsw_sp_span_agent_get()
1091 void mlxsw_sp_span_agent_put(struct mlxsw_sp *mlxsw_sp, int span_id) in mlxsw_sp_span_agent_put() argument
1097 span_entry = mlxsw_sp_span_entry_find_by_id(mlxsw_sp, span_id); in mlxsw_sp_span_agent_put()
1101 mlxsw_sp_span_entry_put(mlxsw_sp, span_entry); in mlxsw_sp_span_agent_put()
1156 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_span_analyzed_port_get() local
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()
1184 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_span_analyzed_port_put() local
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()
1226 return mlxsw_reg_write(span->mlxsw_sp->core, MLXSW_REG(mpar), mpar_pl); in __mlxsw_sp_span_trigger_port_bind()
1340 struct mlxsw_sp *mlxsw_sp = trigger_entry->span->mlxsw_sp; in mlxsw_sp2_span_trigger_global_bind() local
1361 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mpagr), mpagr_pl); 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() local
1412 err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(momte), momte_pl); in __mlxsw_sp2_span_trigger_global_enable()
1417 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(momte), momte_pl); in __mlxsw_sp2_span_trigger_global_enable()
1541 int mlxsw_sp_span_agent_bind(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_span_agent_bind() argument
1551 if (!mlxsw_sp_span_entry_find_by_id(mlxsw_sp, parms->span_id)) in mlxsw_sp_span_agent_bind()
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()
1575 void mlxsw_sp_span_agent_unbind(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_span_agent_unbind() argument
1584 if (WARN_ON_ONCE(!mlxsw_sp_span_entry_find_by_id(mlxsw_sp, in mlxsw_sp_span_agent_unbind()
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()
1603 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_span_trigger_enable() local
1608 trigger_entry = mlxsw_sp_span_trigger_entry_find(mlxsw_sp->span, in mlxsw_sp_span_trigger_enable()
1620 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_span_trigger_disable() local
1625 trigger_entry = mlxsw_sp_span_trigger_entry_find(mlxsw_sp->span, in mlxsw_sp_span_trigger_disable()
1634 static int mlxsw_sp1_span_init(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp1_span_init() argument
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()
1652 static int mlxsw_sp1_span_policer_id_base_set(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp1_span_policer_id_base_set() argument
1663 static int mlxsw_sp2_span_init(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp2_span_init() argument
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()
1684 static int mlxsw_sp2_span_policer_id_base_set(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp2_span_policer_id_base_set() argument
1690 err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(mogcr), mogcr_pl); in mlxsw_sp2_span_policer_id_base_set()
1695 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mogcr), mogcr_pl); in mlxsw_sp2_span_policer_id_base_set()