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
168 mlxsw_sp_span_entry_phys_parms(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_span_entry_phys_parms() argument
181 struct mlxsw_sp *mlxsw_sp = dest_port->mlxsw_sp; in mlxsw_sp_span_entry_phys_configure() local
193 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mpat), mpat_pl); in mlxsw_sp_span_entry_phys_configure()
201 struct mlxsw_sp *mlxsw_sp = dest_port->mlxsw_sp; in mlxsw_sp_span_entry_deconfigure_common() local
208 mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mpat), mpat_pl); in mlxsw_sp_span_entry_deconfigure_common()
318 bridge_port = mlxsw_sp_bridge_port_find(port->mlxsw_sp->bridge, dev); in mlxsw_sp_span_entry_bridge()
450 mlxsw_sp_span_entry_gretap4_parms(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_span_entry_gretap4_parms() argument
482 struct mlxsw_sp *mlxsw_sp = dest_port->mlxsw_sp; in mlxsw_sp_span_entry_gretap4_configure() local
501 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mpat), mpat_pl); in mlxsw_sp_span_entry_gretap4_configure()
554 mlxsw_sp_span_entry_gretap6_parms(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_span_entry_gretap6_parms() argument
586 struct mlxsw_sp *mlxsw_sp = dest_port->mlxsw_sp; in mlxsw_sp_span_entry_gretap6_configure() local
604 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mpat), mpat_pl); in mlxsw_sp_span_entry_gretap6_configure()
631 mlxsw_sp_span_entry_vlan_parms(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_span_entry_vlan_parms() argument
652 struct mlxsw_sp *mlxsw_sp = dest_port->mlxsw_sp; in mlxsw_sp_span_entry_vlan_configure() local
663 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mpat), mpat_pl); in mlxsw_sp_span_entry_vlan_configure()
699 static int mlxsw_sp2_span_entry_cpu_parms(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp2_span_entry_cpu_parms() argument
703 sparmsp->dest_port = mlxsw_sp->ports[MLXSW_PORT_CPU_PORT]; in mlxsw_sp2_span_entry_cpu_parms()
749 mlxsw_sp_span_entry_nop_parms(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_span_entry_nop_parms() argument
775 mlxsw_sp_span_entry_configure(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_span_entry_configure() argument
784 if (sparms.dest_port->mlxsw_sp != mlxsw_sp) { in mlxsw_sp_span_entry_configure()
785 dev_err(mlxsw_sp->bus_info->dev, in mlxsw_sp_span_entry_configure()
793 dev_err(mlxsw_sp->bus_info->dev, "Failed to offload mirror\n"); in mlxsw_sp_span_entry_configure()
812 struct mlxsw_sp *mlxsw_sp = span->mlxsw_sp; in mlxsw_sp_span_policer_id_base_set() local
832 err = mlxsw_sp->span_ops->policer_id_base_set(mlxsw_sp, in mlxsw_sp_span_policer_id_base_set()
850 mlxsw_sp_span_entry_create(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_span_entry_create() argument
859 for (i = 0; i < mlxsw_sp->span->entries_count; i++) { in mlxsw_sp_span_entry_create()
860 if (!refcount_read(&mlxsw_sp->span->entries[i].ref_count)) { in mlxsw_sp_span_entry_create()
861 span_entry = &mlxsw_sp->span->entries[i]; in mlxsw_sp_span_entry_create()
871 err = mlxsw_sp_span_policer_id_base_set(mlxsw_sp->span, in mlxsw_sp_span_entry_create()
877 atomic_inc(&mlxsw_sp->span->active_entries_count); in mlxsw_sp_span_entry_create()
881 mlxsw_sp_span_entry_configure(mlxsw_sp, span_entry, sparms); in mlxsw_sp_span_entry_create()
886 static void mlxsw_sp_span_entry_destroy(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_span_entry_destroy() argument
890 atomic_dec(&mlxsw_sp->span->active_entries_count); in mlxsw_sp_span_entry_destroy()
892 mlxsw_sp_span_policer_id_base_unset(mlxsw_sp->span); in mlxsw_sp_span_entry_destroy()
896 mlxsw_sp_span_entry_find_by_port(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_span_entry_find_by_port() argument
901 for (i = 0; i < mlxsw_sp->span->entries_count; i++) { in mlxsw_sp_span_entry_find_by_port()
902 struct mlxsw_sp_span_entry *curr = &mlxsw_sp->span->entries[i]; in mlxsw_sp_span_entry_find_by_port()
910 void mlxsw_sp_span_entry_invalidate(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_span_entry_invalidate() argument
918 mlxsw_sp_span_entry_find_by_id(struct mlxsw_sp *mlxsw_sp, int span_id) in mlxsw_sp_span_entry_find_by_id() argument
922 for (i = 0; i < mlxsw_sp->span->entries_count; i++) { in mlxsw_sp_span_entry_find_by_id()
923 struct mlxsw_sp_span_entry *curr = &mlxsw_sp->span->entries[i]; in mlxsw_sp_span_entry_find_by_id()
932 mlxsw_sp_span_entry_find_by_parms(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_span_entry_find_by_parms() argument
938 for (i = 0; i < mlxsw_sp->span->entries_count; i++) { in mlxsw_sp_span_entry_find_by_parms()
939 struct mlxsw_sp_span_entry *curr = &mlxsw_sp->span->entries[i]; in mlxsw_sp_span_entry_find_by_parms()
951 mlxsw_sp_span_entry_get(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_span_entry_get() argument
958 span_entry = mlxsw_sp_span_entry_find_by_parms(mlxsw_sp, to_dev, in mlxsw_sp_span_entry_get()
966 return mlxsw_sp_span_entry_create(mlxsw_sp, to_dev, ops, sparms); in mlxsw_sp_span_entry_get()
969 static int mlxsw_sp_span_entry_put(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_span_entry_put() argument
973 mlxsw_sp_span_entry_destroy(mlxsw_sp, span_entry); in mlxsw_sp_span_entry_put()
1015 mlxsw_sp_span_entry_ops(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_span_entry_ops() argument
1018 struct mlxsw_sp_span *span = mlxsw_sp->span; in mlxsw_sp_span_entry_ops()
1031 struct mlxsw_sp *mlxsw_sp; in mlxsw_sp_span_respin_work() local
1035 mlxsw_sp = span->mlxsw_sp; in mlxsw_sp_span_respin_work()
1038 for (i = 0; i < mlxsw_sp->span->entries_count; i++) { in mlxsw_sp_span_respin_work()
1039 struct mlxsw_sp_span_entry *curr = &mlxsw_sp->span->entries[i]; in mlxsw_sp_span_respin_work()
1048 err = curr->ops->parms_set(mlxsw_sp, curr->to_dev, &sparms); in mlxsw_sp_span_respin_work()
1054 mlxsw_sp_span_entry_configure(mlxsw_sp, curr, sparms); in mlxsw_sp_span_respin_work()
1060 void mlxsw_sp_span_respin(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_span_respin() argument
1062 if (atomic_read(&mlxsw_sp->span->active_entries_count) == 0) in mlxsw_sp_span_respin()
1064 mlxsw_core_schedule_work(&mlxsw_sp->span->work); in mlxsw_sp_span_respin()
1067 int mlxsw_sp_span_agent_get(struct mlxsw_sp *mlxsw_sp, int *p_span_id, in mlxsw_sp_span_agent_get() argument
1078 ops = mlxsw_sp_span_entry_ops(mlxsw_sp, to_dev); in mlxsw_sp_span_agent_get()
1080 dev_err(mlxsw_sp->bus_info->dev, "Cannot mirror to requested destination\n"); in mlxsw_sp_span_agent_get()
1085 err = ops->parms_set(mlxsw_sp, to_dev, &sparms); in mlxsw_sp_span_agent_get()
1092 span_entry = mlxsw_sp_span_entry_get(mlxsw_sp, to_dev, ops, sparms); in mlxsw_sp_span_agent_get()
1101 void mlxsw_sp_span_agent_put(struct mlxsw_sp *mlxsw_sp, int span_id) in mlxsw_sp_span_agent_put() argument
1107 span_entry = mlxsw_sp_span_entry_find_by_id(mlxsw_sp, span_id); in mlxsw_sp_span_agent_put()
1111 mlxsw_sp_span_entry_put(mlxsw_sp, span_entry); in mlxsw_sp_span_agent_put()
1166 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_span_analyzed_port_get() local
1171 mutex_lock(&mlxsw_sp->span->analyzed_ports_lock); in mlxsw_sp_span_analyzed_port_get()
1173 analyzed_port = mlxsw_sp_span_analyzed_port_find(mlxsw_sp->span, in mlxsw_sp_span_analyzed_port_get()
1180 analyzed_port = mlxsw_sp_span_analyzed_port_create(mlxsw_sp->span, in mlxsw_sp_span_analyzed_port_get()
1187 mutex_unlock(&mlxsw_sp->span->analyzed_ports_lock); in mlxsw_sp_span_analyzed_port_get()
1194 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_span_analyzed_port_put() local
1198 mutex_lock(&mlxsw_sp->span->analyzed_ports_lock); in mlxsw_sp_span_analyzed_port_put()
1200 analyzed_port = mlxsw_sp_span_analyzed_port_find(mlxsw_sp->span, in mlxsw_sp_span_analyzed_port_put()
1211 mutex_unlock(&mlxsw_sp->span->analyzed_ports_lock); in mlxsw_sp_span_analyzed_port_put()
1240 return mlxsw_reg_write(span->mlxsw_sp->core, MLXSW_REG(mpar), mpar_pl); in __mlxsw_sp_span_trigger_port_bind()
1354 struct mlxsw_sp *mlxsw_sp = trigger_entry->span->mlxsw_sp; in mlxsw_sp2_span_trigger_global_bind() local
1378 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mpagr), mpagr_pl); in mlxsw_sp2_span_trigger_global_bind()
1405 struct mlxsw_sp *mlxsw_sp = trigger_entry->span->mlxsw_sp; in __mlxsw_sp2_span_trigger_global_enable() local
1429 err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(momte), momte_pl); in __mlxsw_sp2_span_trigger_global_enable()
1434 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(momte), momte_pl); in __mlxsw_sp2_span_trigger_global_enable()
1558 int mlxsw_sp_span_agent_bind(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_span_agent_bind() argument
1568 if (!mlxsw_sp_span_entry_find_by_id(mlxsw_sp, parms->span_id)) in mlxsw_sp_span_agent_bind()
1571 trigger_entry = mlxsw_sp_span_trigger_entry_find(mlxsw_sp->span, in mlxsw_sp_span_agent_bind()
1583 trigger_entry = mlxsw_sp_span_trigger_entry_create(mlxsw_sp->span, in mlxsw_sp_span_agent_bind()
1594 void mlxsw_sp_span_agent_unbind(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_span_agent_unbind() argument
1603 if (WARN_ON_ONCE(!mlxsw_sp_span_entry_find_by_id(mlxsw_sp, in mlxsw_sp_span_agent_unbind()
1607 trigger_entry = mlxsw_sp_span_trigger_entry_find(mlxsw_sp->span, in mlxsw_sp_span_agent_unbind()
1616 mlxsw_sp_span_trigger_entry_destroy(mlxsw_sp->span, trigger_entry); in mlxsw_sp_span_agent_unbind()
1622 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_span_trigger_enable() local
1627 trigger_entry = mlxsw_sp_span_trigger_entry_find(mlxsw_sp->span, in mlxsw_sp_span_trigger_enable()
1639 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_span_trigger_disable() local
1644 trigger_entry = mlxsw_sp_span_trigger_entry_find(mlxsw_sp->span, in mlxsw_sp_span_trigger_disable()
1669 static int mlxsw_sp1_span_init(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp1_span_init() argument
1680 mlxsw_sp->span->span_trigger_ops_arr = mlxsw_sp1_span_trigger_ops_arr; in mlxsw_sp1_span_init()
1681 mlxsw_sp->span->span_entry_ops_arr = mlxsw_sp1_span_entry_ops_arr; in mlxsw_sp1_span_init()
1682 mlxsw_sp->span->span_entry_ops_arr_size = arr_size; in mlxsw_sp1_span_init()
1687 static int mlxsw_sp1_span_policer_id_base_set(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp1_span_policer_id_base_set() argument
1698 static int mlxsw_sp2_span_init(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp2_span_init() argument
1709 mlxsw_sp->span->span_trigger_ops_arr = mlxsw_sp2_span_trigger_ops_arr; in mlxsw_sp2_span_init()
1710 mlxsw_sp->span->span_entry_ops_arr = mlxsw_sp2_span_entry_ops_arr; in mlxsw_sp2_span_init()
1711 mlxsw_sp->span->span_entry_ops_arr_size = arr_size; in mlxsw_sp2_span_init()
1719 static int mlxsw_sp2_span_policer_id_base_set(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp2_span_policer_id_base_set() argument
1725 err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(mogcr), mogcr_pl); in mlxsw_sp2_span_policer_id_base_set()
1730 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mogcr), mogcr_pl); in mlxsw_sp2_span_policer_id_base_set()