| .. | .. |
|---|
| 6 | 6 | |
|---|
| 7 | 7 | #include <linux/types.h> |
|---|
| 8 | 8 | #include <linux/if_ether.h> |
|---|
| 9 | +#include <linux/refcount.h> |
|---|
| 9 | 10 | |
|---|
| 10 | 11 | #include "spectrum_router.h" |
|---|
| 11 | 12 | |
|---|
| 12 | 13 | struct mlxsw_sp; |
|---|
| 13 | 14 | struct mlxsw_sp_port; |
|---|
| 14 | | - |
|---|
| 15 | | -enum mlxsw_sp_span_type { |
|---|
| 16 | | - MLXSW_SP_SPAN_EGRESS, |
|---|
| 17 | | - MLXSW_SP_SPAN_INGRESS |
|---|
| 18 | | -}; |
|---|
| 19 | | - |
|---|
| 20 | | -struct mlxsw_sp_span_inspected_port { |
|---|
| 21 | | - struct list_head list; |
|---|
| 22 | | - enum mlxsw_sp_span_type type; |
|---|
| 23 | | - u8 local_port; |
|---|
| 24 | | - |
|---|
| 25 | | - /* Whether this is a directly bound mirror (port-to-port) or an ACL. */ |
|---|
| 26 | | - bool bound; |
|---|
| 27 | | -}; |
|---|
| 28 | 15 | |
|---|
| 29 | 16 | struct mlxsw_sp_span_parms { |
|---|
| 30 | 17 | struct mlxsw_sp_port *dest_port; /* NULL for unoffloaded SPAN. */ |
|---|
| .. | .. |
|---|
| 34 | 21 | union mlxsw_sp_l3addr daddr; |
|---|
| 35 | 22 | union mlxsw_sp_l3addr saddr; |
|---|
| 36 | 23 | u16 vid; |
|---|
| 24 | + u16 policer_id; |
|---|
| 25 | + bool policer_enable; |
|---|
| 26 | +}; |
|---|
| 27 | + |
|---|
| 28 | +enum mlxsw_sp_span_trigger { |
|---|
| 29 | + MLXSW_SP_SPAN_TRIGGER_INGRESS, |
|---|
| 30 | + MLXSW_SP_SPAN_TRIGGER_EGRESS, |
|---|
| 31 | + MLXSW_SP_SPAN_TRIGGER_TAIL_DROP, |
|---|
| 32 | + MLXSW_SP_SPAN_TRIGGER_EARLY_DROP, |
|---|
| 33 | + MLXSW_SP_SPAN_TRIGGER_ECN, |
|---|
| 34 | +}; |
|---|
| 35 | + |
|---|
| 36 | +struct mlxsw_sp_span_trigger_parms { |
|---|
| 37 | + int span_id; |
|---|
| 38 | +}; |
|---|
| 39 | + |
|---|
| 40 | +struct mlxsw_sp_span_agent_parms { |
|---|
| 41 | + const struct net_device *to_dev; |
|---|
| 42 | + u16 policer_id; |
|---|
| 43 | + bool policer_enable; |
|---|
| 37 | 44 | }; |
|---|
| 38 | 45 | |
|---|
| 39 | 46 | struct mlxsw_sp_span_entry_ops; |
|---|
| 47 | + |
|---|
| 48 | +struct mlxsw_sp_span_ops { |
|---|
| 49 | + int (*init)(struct mlxsw_sp *mlxsw_sp); |
|---|
| 50 | + int (*policer_id_base_set)(struct mlxsw_sp *mlxsw_sp, |
|---|
| 51 | + u16 policer_id_base); |
|---|
| 52 | +}; |
|---|
| 40 | 53 | |
|---|
| 41 | 54 | struct mlxsw_sp_span_entry { |
|---|
| 42 | 55 | const struct net_device *to_dev; |
|---|
| 43 | 56 | const struct mlxsw_sp_span_entry_ops *ops; |
|---|
| 44 | 57 | struct mlxsw_sp_span_parms parms; |
|---|
| 45 | | - struct list_head bound_ports_list; |
|---|
| 46 | | - int ref_count; |
|---|
| 58 | + refcount_t ref_count; |
|---|
| 47 | 59 | int id; |
|---|
| 48 | 60 | }; |
|---|
| 49 | 61 | |
|---|
| 50 | 62 | struct mlxsw_sp_span_entry_ops { |
|---|
| 63 | + bool is_static; |
|---|
| 51 | 64 | bool (*can_handle)(const struct net_device *to_dev); |
|---|
| 52 | | - int (*parms)(const struct net_device *to_dev, |
|---|
| 53 | | - struct mlxsw_sp_span_parms *sparmsp); |
|---|
| 65 | + int (*parms_set)(struct mlxsw_sp *mlxsw_sp, |
|---|
| 66 | + const struct net_device *to_dev, |
|---|
| 67 | + struct mlxsw_sp_span_parms *sparmsp); |
|---|
| 54 | 68 | int (*configure)(struct mlxsw_sp_span_entry *span_entry, |
|---|
| 55 | 69 | struct mlxsw_sp_span_parms sparms); |
|---|
| 56 | 70 | void (*deconfigure)(struct mlxsw_sp_span_entry *span_entry); |
|---|
| .. | .. |
|---|
| 60 | 74 | void mlxsw_sp_span_fini(struct mlxsw_sp *mlxsw_sp); |
|---|
| 61 | 75 | void mlxsw_sp_span_respin(struct mlxsw_sp *mlxsw_sp); |
|---|
| 62 | 76 | |
|---|
| 63 | | -int mlxsw_sp_span_mirror_add(struct mlxsw_sp_port *from, |
|---|
| 64 | | - const struct net_device *to_dev, |
|---|
| 65 | | - enum mlxsw_sp_span_type type, |
|---|
| 66 | | - bool bind, int *p_span_id); |
|---|
| 67 | | -void mlxsw_sp_span_mirror_del(struct mlxsw_sp_port *from, int span_id, |
|---|
| 68 | | - enum mlxsw_sp_span_type type, bool bind); |
|---|
| 69 | 77 | struct mlxsw_sp_span_entry * |
|---|
| 70 | 78 | mlxsw_sp_span_entry_find_by_port(struct mlxsw_sp *mlxsw_sp, |
|---|
| 71 | 79 | const struct net_device *to_dev); |
|---|
| .. | .. |
|---|
| 74 | 82 | struct mlxsw_sp_span_entry *span_entry); |
|---|
| 75 | 83 | |
|---|
| 76 | 84 | int mlxsw_sp_span_port_mtu_update(struct mlxsw_sp_port *port, u16 mtu); |
|---|
| 85 | +void mlxsw_sp_span_speed_update_work(struct work_struct *work); |
|---|
| 86 | + |
|---|
| 87 | +int mlxsw_sp_span_agent_get(struct mlxsw_sp *mlxsw_sp, int *p_span_id, |
|---|
| 88 | + const struct mlxsw_sp_span_agent_parms *parms); |
|---|
| 89 | +void mlxsw_sp_span_agent_put(struct mlxsw_sp *mlxsw_sp, int span_id); |
|---|
| 90 | +int mlxsw_sp_span_analyzed_port_get(struct mlxsw_sp_port *mlxsw_sp_port, |
|---|
| 91 | + bool ingress); |
|---|
| 92 | +void mlxsw_sp_span_analyzed_port_put(struct mlxsw_sp_port *mlxsw_sp_port, |
|---|
| 93 | + bool ingress); |
|---|
| 94 | +int mlxsw_sp_span_agent_bind(struct mlxsw_sp *mlxsw_sp, |
|---|
| 95 | + enum mlxsw_sp_span_trigger trigger, |
|---|
| 96 | + struct mlxsw_sp_port *mlxsw_sp_port, |
|---|
| 97 | + const struct mlxsw_sp_span_trigger_parms *parms); |
|---|
| 98 | +void |
|---|
| 99 | +mlxsw_sp_span_agent_unbind(struct mlxsw_sp *mlxsw_sp, |
|---|
| 100 | + enum mlxsw_sp_span_trigger trigger, |
|---|
| 101 | + struct mlxsw_sp_port *mlxsw_sp_port, |
|---|
| 102 | + const struct mlxsw_sp_span_trigger_parms *parms); |
|---|
| 103 | +int mlxsw_sp_span_trigger_enable(struct mlxsw_sp_port *mlxsw_sp_port, |
|---|
| 104 | + enum mlxsw_sp_span_trigger trigger, u8 tc); |
|---|
| 105 | +void mlxsw_sp_span_trigger_disable(struct mlxsw_sp_port *mlxsw_sp_port, |
|---|
| 106 | + enum mlxsw_sp_span_trigger trigger, u8 tc); |
|---|
| 107 | + |
|---|
| 108 | +extern const struct mlxsw_sp_span_ops mlxsw_sp1_span_ops; |
|---|
| 109 | +extern const struct mlxsw_sp_span_ops mlxsw_sp2_span_ops; |
|---|
| 110 | +extern const struct mlxsw_sp_span_ops mlxsw_sp3_span_ops; |
|---|
| 77 | 111 | |
|---|
| 78 | 112 | #endif |
|---|