Lines Matching +full:ocelot +full:- +full:1
1 // SPDX-License-Identifier: (GPL-2.0 OR MIT)
2 /* Microsemi Ocelot Switch driver
7 #include <soc/mscc/ocelot.h>
10 /* Types for ANA:POL[0-192]:POL_MODE_CFG.FRM_MODE */
11 #define POL_MODE_LINERATE 0 /* Incl IPG. Unit: 33 1/3 kbps, 4096 bytes */
12 #define POL_MODE_DATARATE 1 /* Excl IPG. Unit: 33 1/3 kbps, 4096 bytes */
13 #define POL_MODE_FRMRATE_HI 2 /* Unit: 33 1/3 fps, 32.8 frames */
14 #define POL_MODE_FRMRATE_LO 3 /* Unit: 1/3 fps, 0.3 frames */
17 #define POL_IX_PORT 0 /* 0-11 : Port policers */
18 #define POL_IX_QUEUE 32 /* 32-127 : Queue policers */
21 #define POL_ORDER 0x1d3 /* Ocelot policer order: Serial (QoS -> Port -> VCAP) */
23 int qos_policer_conf_set(struct ocelot *ocelot, u32 pol_ix, in qos_policer_conf_set() argument
33 pir = conf->pir; in qos_policer_conf_set()
34 pbs = conf->pbs; in qos_policer_conf_set()
36 switch (conf->mode) { in qos_policer_conf_set()
39 if (conf->mode == MSCC_QOS_RATE_MODE_LINE) { in qos_policer_conf_set()
41 ipg = min_t(u8, GENMASK(4, 0), conf->ipg); in qos_policer_conf_set()
45 if (conf->dlb) { in qos_policer_conf_set()
46 cir_ena = 1; in qos_policer_conf_set()
47 cir = conf->cir; in qos_policer_conf_set()
48 cbs = conf->cbs; in qos_policer_conf_set()
51 cir_discard = 1; in qos_policer_conf_set()
54 cir *= 3; /* 33 1/3 kbps */ in qos_policer_conf_set()
56 cbs = (cbs ? cbs : 1); /* No zero burst size */ in qos_policer_conf_set()
58 cf = conf->cf; in qos_policer_conf_set()
60 pir += conf->cir; in qos_policer_conf_set()
65 pir_discard = 1; in qos_policer_conf_set()
68 pir *= 3; /* 33 1/3 kbps */ in qos_policer_conf_set()
70 pbs = (pbs ? pbs : 1); /* No zero burst size */ in qos_policer_conf_set()
78 pir *= 3; /* 33 1/3 fps */ in qos_policer_conf_set()
80 pbs = (pbs ? pbs : 1); /* No zero burst size */ in qos_policer_conf_set()
86 pir_discard = 1; in qos_policer_conf_set()
87 cir_discard = 1; in qos_policer_conf_set()
89 pir *= 3; /* 1/3 fps */ in qos_policer_conf_set()
91 pbs = (pbs ? pbs : 1); /* No zero burst size */ in qos_policer_conf_set()
105 dev_err(ocelot->dev, in qos_policer_conf_set()
108 return -EINVAL; in qos_policer_conf_set()
112 dev_err(ocelot->dev, in qos_policer_conf_set()
115 return -EINVAL; in qos_policer_conf_set()
119 dev_err(ocelot->dev, in qos_policer_conf_set()
122 return -EINVAL; in qos_policer_conf_set()
126 dev_err(ocelot->dev, in qos_policer_conf_set()
129 return -EINVAL; in qos_policer_conf_set()
138 ocelot_write_gix(ocelot, value, ANA_POL_MODE_CFG, pol_ix); in qos_policer_conf_set()
140 ocelot_write_gix(ocelot, in qos_policer_conf_set()
145 ocelot_write_gix(ocelot, in qos_policer_conf_set()
149 ocelot_write_gix(ocelot, in qos_policer_conf_set()
154 ocelot_write_gix(ocelot, in qos_policer_conf_set()
165 if (a->police.exceed.act_id != FLOW_ACTION_DROP) { in ocelot_policer_validate()
168 return -EOPNOTSUPP; in ocelot_policer_validate()
171 if (a->police.notexceed.act_id != FLOW_ACTION_PIPE && in ocelot_policer_validate()
172 a->police.notexceed.act_id != FLOW_ACTION_ACCEPT) { in ocelot_policer_validate()
175 return -EOPNOTSUPP; in ocelot_policer_validate()
178 if (a->police.notexceed.act_id == FLOW_ACTION_ACCEPT && in ocelot_policer_validate()
182 return -EOPNOTSUPP; in ocelot_policer_validate()
185 if (a->police.peakrate_bytes_ps || in ocelot_policer_validate()
186 a->police.avrate || a->police.overhead) { in ocelot_policer_validate()
189 return -EOPNOTSUPP; in ocelot_policer_validate()
192 if (a->police.rate_pkt_ps) { in ocelot_policer_validate()
195 return -EOPNOTSUPP; in ocelot_policer_validate()
202 int ocelot_port_policer_add(struct ocelot *ocelot, int port, in ocelot_port_policer_add() argument
209 return -EINVAL; in ocelot_port_policer_add()
212 pp.pir = pol->rate; in ocelot_port_policer_add()
213 pp.pbs = pol->burst; in ocelot_port_policer_add()
215 dev_dbg(ocelot->dev, "%s: port %u pir %u kbps, pbs %u bytes\n", in ocelot_port_policer_add()
218 err = qos_policer_conf_set(ocelot, POL_IX_PORT + port, &pp); in ocelot_port_policer_add()
222 ocelot_rmw_gix(ocelot, in ocelot_port_policer_add()
233 int ocelot_port_policer_del(struct ocelot *ocelot, int port) in ocelot_port_policer_del() argument
238 dev_dbg(ocelot->dev, "%s: port %u\n", __func__, port); in ocelot_port_policer_del()
242 err = qos_policer_conf_set(ocelot, POL_IX_PORT + port, &pp); in ocelot_port_policer_del()
246 ocelot_rmw_gix(ocelot, in ocelot_port_policer_del()