Lines Matching +full:sparx5 +full:- +full:switch

1 // SPDX-License-Identifier: GPL-2.0+
2 /* Microchip Sparx5 Switch driver
25 static u64 sparx5_mirror_port_get(struct sparx5 *sparx5, u32 idx) in sparx5_mirror_port_get() argument
27 return (u64)spx5_rd(sparx5, ANA_AC_PROBE_PORT_CFG1(idx)) << 32 | in sparx5_mirror_port_get()
28 spx5_rd(sparx5, ANA_AC_PROBE_PORT_CFG(idx)); in sparx5_mirror_port_get()
32 static void sparx5_mirror_port_add(struct sparx5 *sparx5, u32 idx, u32 portno) in sparx5_mirror_port_add() argument
40 return spx5_rmw(val, val, sparx5, ANA_AC_PROBE_PORT_CFG(idx)); in sparx5_mirror_port_add()
42 return spx5_rmw(val, val, sparx5, ANA_AC_PROBE_PORT_CFG1(idx)); in sparx5_mirror_port_add()
46 static void sparx5_mirror_port_del(struct sparx5 *sparx5, u32 idx, u32 portno) in sparx5_mirror_port_del() argument
54 return spx5_rmw(0, val, sparx5, ANA_AC_PROBE_PORT_CFG(idx)); in sparx5_mirror_port_del()
56 return spx5_rmw(0, val, sparx5, ANA_AC_PROBE_PORT_CFG1(idx)); in sparx5_mirror_port_del()
60 static bool sparx5_mirror_contains(struct sparx5 *sparx5, u32 idx, u32 portno) in sparx5_mirror_contains() argument
62 return (sparx5_mirror_port_get(sparx5, idx) & BIT_ULL(portno)) != 0; in sparx5_mirror_contains()
66 static bool sparx5_mirror_is_empty(struct sparx5 *sparx5, u32 idx) in sparx5_mirror_is_empty() argument
68 return sparx5_mirror_port_get(sparx5, idx) == 0; in sparx5_mirror_is_empty()
72 static u32 sparx5_mirror_dir_get(struct sparx5 *sparx5, u32 idx) in sparx5_mirror_dir_get() argument
74 u32 val = spx5_rd(sparx5, ANA_AC_PROBE_CFG(idx)); in sparx5_mirror_dir_get()
80 static void sparx5_mirror_dir_set(struct sparx5 *sparx5, u32 idx, u32 dir) in sparx5_mirror_dir_set() argument
83 ANA_AC_PROBE_CFG_PROBE_DIRECTION, sparx5, in sparx5_mirror_dir_set()
88 static void sparx5_mirror_monitor_set(struct sparx5 *sparx5, u32 idx, in sparx5_mirror_monitor_set() argument
92 QFWD_FRAME_COPY_CFG_FRMC_PORT_VAL, sparx5, in sparx5_mirror_monitor_set()
97 static u32 sparx5_mirror_monitor_get(struct sparx5 *sparx5, u32 idx) in sparx5_mirror_monitor_get() argument
99 u32 val = spx5_rd(sparx5, in sparx5_mirror_monitor_get()
106 static bool sparx5_mirror_has_monitor(struct sparx5 *sparx5, u32 idx, in sparx5_mirror_has_monitor() argument
109 return sparx5_mirror_monitor_get(sparx5, idx) == portno; in sparx5_mirror_has_monitor()
116 struct sparx5 *sparx5 = sport->sparx5; in sparx5_mirror_get() local
121 if (sparx5_mirror_has_monitor(sparx5, i, sport->portno)) in sparx5_mirror_get()
122 return -EINVAL; in sparx5_mirror_get()
128 if (sparx5_mirror_dir_get(sparx5, i) == dir && in sparx5_mirror_get()
129 sparx5_mirror_has_monitor(sparx5, i, mport->portno)) { in sparx5_mirror_get()
137 if (sparx5_mirror_is_empty(sparx5, i)) { in sparx5_mirror_get()
143 return -ENOENT; in sparx5_mirror_get()
148 u32 mirror_idx, dir = sparx5_mirror_to_dir(entry->ingress); in sparx5_mirror_add()
150 struct sparx5 *sparx5; in sparx5_mirror_add() local
154 sport = entry->port; in sparx5_mirror_add()
156 mport = entry->mirror.port; in sparx5_mirror_add()
157 sparx5 = sport->sparx5; in sparx5_mirror_add()
159 if (sport->portno == mport->portno) in sparx5_mirror_add()
160 return -EINVAL; in sparx5_mirror_add()
166 if (sparx5_mirror_contains(sparx5, mirror_idx, sport->portno)) in sparx5_mirror_add()
167 return -EEXIST; in sparx5_mirror_add()
170 sparx5_mirror_port_add(sparx5, mirror_idx, sport->portno); in sparx5_mirror_add()
173 sparx5_mirror_dir_set(sparx5, mirror_idx, dir); in sparx5_mirror_add()
176 sparx5_mirror_monitor_set(sparx5, mirror_idx, mport->portno); in sparx5_mirror_add()
178 entry->mirror.idx = mirror_idx; in sparx5_mirror_add()
185 struct sparx5_port *port = entry->port; in sparx5_mirror_del()
186 struct sparx5 *sparx5 = port->sparx5; in sparx5_mirror_del() local
187 u32 mirror_idx = entry->mirror.idx; in sparx5_mirror_del()
189 sparx5_mirror_port_del(sparx5, mirror_idx, port->portno); in sparx5_mirror_del()
190 if (!sparx5_mirror_is_empty(sparx5, mirror_idx)) in sparx5_mirror_del()
193 sparx5_mirror_dir_set(sparx5, mirror_idx, SPX5_MIRROR_DISABLED); in sparx5_mirror_del()
195 sparx5_mirror_monitor_set(sparx5, in sparx5_mirror_del()
203 struct sparx5_port *port = entry->port; in sparx5_mirror_stats()
207 old_stats = &entry->port->mirror_stats; in sparx5_mirror_stats()
208 sparx5_get_stats64(port->ndev, &new_stats); in sparx5_mirror_stats()
210 if (entry->ingress) { in sparx5_mirror_stats()
212 new_stats.rx_bytes - old_stats->bytes, in sparx5_mirror_stats()
213 new_stats.rx_packets - old_stats->pkts, in sparx5_mirror_stats()
214 new_stats.rx_dropped - old_stats->drops, in sparx5_mirror_stats()
215 old_stats->lastused, in sparx5_mirror_stats()
218 old_stats->bytes = new_stats.rx_bytes; in sparx5_mirror_stats()
219 old_stats->pkts = new_stats.rx_packets; in sparx5_mirror_stats()
220 old_stats->drops = new_stats.rx_dropped; in sparx5_mirror_stats()
221 old_stats->lastused = jiffies; in sparx5_mirror_stats()
224 new_stats.tx_bytes - old_stats->bytes, in sparx5_mirror_stats()
225 new_stats.tx_packets - old_stats->pkts, in sparx5_mirror_stats()
226 new_stats.tx_dropped - old_stats->drops, in sparx5_mirror_stats()
227 old_stats->lastused, in sparx5_mirror_stats()
230 old_stats->bytes = new_stats.tx_bytes; in sparx5_mirror_stats()
231 old_stats->pkts = new_stats.tx_packets; in sparx5_mirror_stats()
232 old_stats->drops = new_stats.tx_dropped; in sparx5_mirror_stats()
233 old_stats->lastused = jiffies; in sparx5_mirror_stats()