Lines Matching +full:3 +full:- +full:port
1 // SPDX-License-Identifier: (GPL-2.0 OR MIT)
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, int port, 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()
47 cir = conf->cir; in qos_policer_conf_set()
48 cbs = conf->cbs; in qos_policer_conf_set()
54 cir *= 3; /* 33 1/3 kbps */ in qos_policer_conf_set()
58 cf = conf->cf; in qos_policer_conf_set()
60 pir += conf->cir; in qos_policer_conf_set()
68 pir *= 3; /* 33 1/3 kbps */ in qos_policer_conf_set()
78 pir *= 3; /* 33 1/3 fps */ in qos_policer_conf_set()
89 pir *= 3; /* 1/3 fps */ in qos_policer_conf_set()
90 pbs = (pbs * 10) / 3; /* 0.3 frames */ in qos_policer_conf_set()
105 dev_err(ocelot->dev, "Invalid pir for port %d: %u (max %lu)\n", in qos_policer_conf_set()
106 port, pir, GENMASK(15, 0)); in qos_policer_conf_set()
107 return -EINVAL; in qos_policer_conf_set()
111 dev_err(ocelot->dev, "Invalid cir for port %d: %u (max %lu)\n", in qos_policer_conf_set()
112 port, cir, GENMASK(15, 0)); in qos_policer_conf_set()
113 return -EINVAL; in qos_policer_conf_set()
117 dev_err(ocelot->dev, "Invalid pbs for port %d: %u (max %u)\n", in qos_policer_conf_set()
118 port, pbs, pbs_max); in qos_policer_conf_set()
119 return -EINVAL; in qos_policer_conf_set()
123 dev_err(ocelot->dev, "Invalid cbs for port %d: %u (max %u)\n", in qos_policer_conf_set()
124 port, cbs, cbs_max); in qos_policer_conf_set()
125 return -EINVAL; in qos_policer_conf_set()
157 int ocelot_port_policer_add(struct ocelot *ocelot, int port, in ocelot_port_policer_add() argument
164 return -EINVAL; in ocelot_port_policer_add()
167 pp.pir = pol->rate; in ocelot_port_policer_add()
168 pp.pbs = pol->burst; in ocelot_port_policer_add()
170 dev_dbg(ocelot->dev, "%s: port %u pir %u kbps, pbs %u bytes\n", in ocelot_port_policer_add()
171 __func__, port, pp.pir, pp.pbs); in ocelot_port_policer_add()
173 err = qos_policer_conf_set(ocelot, port, POL_IX_PORT + port, &pp); in ocelot_port_policer_add()
182 ANA_PORT_POL_CFG, port); in ocelot_port_policer_add()
188 int ocelot_port_policer_del(struct ocelot *ocelot, int port) in ocelot_port_policer_del() argument
193 dev_dbg(ocelot->dev, "%s: port %u\n", __func__, port); in ocelot_port_policer_del()
197 err = qos_policer_conf_set(ocelot, port, POL_IX_PORT + port, &pp); in ocelot_port_policer_del()
205 ANA_PORT_POL_CFG, port); in ocelot_port_policer_del()