Lines Matching +full:per +full:- +full:port

1 // SPDX-License-Identifier: GPL-2.0+
5 /* 0-8 : 9 port policers */
8 /* Policer order: Serial (QoS -> Port -> VCAP) */
12 /* kilobit per second */
18 static int lan966x_police_add(struct lan966x_port *port, in lan966x_police_add() argument
22 struct lan966x *lan966x = port->lan966x; in lan966x_police_add()
25 pol->rate = DIV_ROUND_UP(pol->rate * 3, 100); in lan966x_police_add()
27 pol->burst = pol->burst ?: 1; in lan966x_police_add()
29 pol->burst = DIV_ROUND_UP(pol->burst, 4096); in lan966x_police_add()
31 if (pol->rate > GENMASK(15, 0) || in lan966x_police_add()
32 pol->burst > GENMASK(6, 0)) in lan966x_police_add()
33 return -EINVAL; in lan966x_police_add()
45 lan_wr(ANA_POL_PIR_CFG_PIR_RATE_SET(pol->rate) | in lan966x_police_add()
46 ANA_POL_PIR_CFG_PIR_BURST_SET(pol->burst), in lan966x_police_add()
52 static void lan966x_police_del(struct lan966x_port *port, u16 pol_idx) in lan966x_police_del() argument
54 struct lan966x *lan966x = port->lan966x; in lan966x_police_del()
71 static int lan966x_police_validate(struct lan966x_port *port, in lan966x_police_validate() argument
78 if (act->police.exceed.act_id != FLOW_ACTION_DROP) { in lan966x_police_validate()
81 return -EOPNOTSUPP; in lan966x_police_validate()
84 if (act->police.notexceed.act_id != FLOW_ACTION_PIPE && in lan966x_police_validate()
85 act->police.notexceed.act_id != FLOW_ACTION_ACCEPT) { in lan966x_police_validate()
88 return -EOPNOTSUPP; in lan966x_police_validate()
91 if (act->police.notexceed.act_id == FLOW_ACTION_ACCEPT && in lan966x_police_validate()
95 return -EOPNOTSUPP; in lan966x_police_validate()
98 if (act->police.peakrate_bytes_ps || in lan966x_police_validate()
99 act->police.avrate || act->police.overhead) { in lan966x_police_validate()
102 return -EOPNOTSUPP; in lan966x_police_validate()
105 if (act->police.rate_pkt_ps) { in lan966x_police_validate()
107 "QoS offload not support packets per second"); in lan966x_police_validate()
108 return -EOPNOTSUPP; in lan966x_police_validate()
114 return -EOPNOTSUPP; in lan966x_police_validate()
117 if (port->tc.ingress_shared_block) { in lan966x_police_validate()
120 return -EOPNOTSUPP; in lan966x_police_validate()
123 if (port->tc.police_id && port->tc.police_id != police_id) { in lan966x_police_validate()
125 "Only one policer per port is supported"); in lan966x_police_validate()
126 return -EEXIST; in lan966x_police_validate()
132 int lan966x_police_port_add(struct lan966x_port *port, in lan966x_police_port_add() argument
139 struct lan966x *lan966x = port->lan966x; in lan966x_police_port_add()
145 err = lan966x_police_validate(port, action, act, police_id, ingress, in lan966x_police_port_add()
152 pol.rate = div_u64(act->police.rate_bytes_ps, 1000) * 8; in lan966x_police_port_add()
153 pol.burst = act->police.burst; in lan966x_police_port_add()
155 err = lan966x_police_add(port, &pol, POL_IDX_PORT + port->chip_port); in lan966x_police_port_add()
158 "Failed to add policer to port"); in lan966x_police_port_add()
166 lan966x, ANA_POL_CFG(port->chip_port)); in lan966x_police_port_add()
168 port->tc.police_id = police_id; in lan966x_police_port_add()
171 old_stats = &port->tc.police_stat; in lan966x_police_port_add()
172 lan966x_stats_get(port->dev, &new_stats); in lan966x_police_port_add()
173 old_stats->bytes = new_stats.rx_bytes; in lan966x_police_port_add()
174 old_stats->pkts = new_stats.rx_packets; in lan966x_police_port_add()
175 old_stats->drops = new_stats.rx_dropped; in lan966x_police_port_add()
176 old_stats->lastused = jiffies; in lan966x_police_port_add()
181 int lan966x_police_port_del(struct lan966x_port *port, in lan966x_police_port_del() argument
185 struct lan966x *lan966x = port->lan966x; in lan966x_police_port_del()
187 if (port->tc.police_id != police_id) { in lan966x_police_port_del()
190 return -EINVAL; in lan966x_police_port_del()
193 lan966x_police_del(port, POL_IDX_PORT + port->chip_port); in lan966x_police_port_del()
199 lan966x, ANA_POL_CFG(port->chip_port)); in lan966x_police_port_del()
201 port->tc.police_id = 0; in lan966x_police_port_del()
206 void lan966x_police_port_stats(struct lan966x_port *port, in lan966x_police_port_stats() argument
212 old_stats = &port->tc.police_stat; in lan966x_police_port_stats()
213 lan966x_stats_get(port->dev, &new_stats); in lan966x_police_port_stats()
216 new_stats.rx_bytes - old_stats->bytes, in lan966x_police_port_stats()
217 new_stats.rx_packets - old_stats->pkts, in lan966x_police_port_stats()
218 new_stats.rx_dropped - old_stats->drops, in lan966x_police_port_stats()
219 old_stats->lastused, in lan966x_police_port_stats()
222 old_stats->bytes = new_stats.rx_bytes; in lan966x_police_port_stats()
223 old_stats->pkts = new_stats.rx_packets; in lan966x_police_port_stats()
224 old_stats->drops = new_stats.rx_dropped; in lan966x_police_port_stats()
225 old_stats->lastused = jiffies; in lan966x_police_port_stats()