Commit 5f035af7 authored by Po Liu's avatar Po Liu Committed by David S. Miller
Browse files

net:qos: police action offloading parameter 'burst' change to the original value



Since 'tcfp_burst' with TICK factor, driver side always need to recover
it to the original value, this patch moves the generic calculation and
recover to the 'burst' original value before offloading to device driver.

Signed-off-by: default avatarPo Liu <po.liu@nxp.com>
Acked-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 13f1555c
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -746,9 +746,7 @@ static int felix_port_policer_add(struct dsa_switch *ds, int port,
	struct ocelot *ocelot = ds->priv;
	struct ocelot_policer pol = {
		.rate = div_u64(policer->rate_bytes_per_sec, 1000) * 8,
		.burst = div_u64(policer->rate_bytes_per_sec *
				 PSCHED_NS2TICKS(policer->burst),
				 PSCHED_TICKS_PER_SEC),
		.burst = policer->burst,
	};

	return ocelot_port_policer_add(ocelot, port, &pol);
+7 −9
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ static int sja1105_setup_bcast_policer(struct sja1105_private *priv,
				       struct netlink_ext_ack *extack,
				       unsigned long cookie, int port,
				       u64 rate_bytes_per_sec,
				       s64 burst)
				       u32 burst)
{
	struct sja1105_rule *rule = sja1105_rule_find(priv, cookie);
	struct sja1105_l2_policing_entry *policing;
@@ -79,9 +79,8 @@ static int sja1105_setup_bcast_policer(struct sja1105_private *priv,

	policing[rule->bcast_pol.sharindx].rate = div_u64(rate_bytes_per_sec *
							  512, 1000000);
	policing[rule->bcast_pol.sharindx].smax = div_u64(rate_bytes_per_sec *
							  PSCHED_NS2TICKS(burst),
							  PSCHED_TICKS_PER_SEC);
	policing[rule->bcast_pol.sharindx].smax = burst;

	/* TODO: support per-flow MTU */
	policing[rule->bcast_pol.sharindx].maxlen = VLAN_ETH_FRAME_LEN +
						    ETH_FCS_LEN;
@@ -103,7 +102,7 @@ static int sja1105_setup_tc_policer(struct sja1105_private *priv,
				    struct netlink_ext_ack *extack,
				    unsigned long cookie, int port, int tc,
				    u64 rate_bytes_per_sec,
				    s64 burst)
				    u32 burst)
{
	struct sja1105_rule *rule = sja1105_rule_find(priv, cookie);
	struct sja1105_l2_policing_entry *policing;
@@ -152,9 +151,8 @@ static int sja1105_setup_tc_policer(struct sja1105_private *priv,

	policing[rule->tc_pol.sharindx].rate = div_u64(rate_bytes_per_sec *
						       512, 1000000);
	policing[rule->tc_pol.sharindx].smax = div_u64(rate_bytes_per_sec *
						       PSCHED_NS2TICKS(burst),
						       PSCHED_TICKS_PER_SEC);
	policing[rule->tc_pol.sharindx].smax = burst;

	/* TODO: support per-flow MTU */
	policing[rule->tc_pol.sharindx].maxlen = VLAN_ETH_FRAME_LEN +
						 ETH_FCS_LEN;
@@ -177,7 +175,7 @@ static int sja1105_flower_policer(struct sja1105_private *priv, int port,
				  unsigned long cookie,
				  struct sja1105_key *key,
				  u64 rate_bytes_per_sec,
				  s64 burst)
				  u32 burst)
{
	switch (key->type) {
	case SJA1105_KEY_BCAST:
+1 −3
Original line number Diff line number Diff line
@@ -3324,9 +3324,7 @@ static int sja1105_port_policer_add(struct dsa_switch *ds, int port,
	 */
	policing[port].rate = div_u64(512 * policer->rate_bytes_per_sec,
				      1000000);
	policing[port].smax = div_u64(policer->rate_bytes_per_sec *
				      PSCHED_NS2TICKS(policer->burst),
				      PSCHED_TICKS_PER_SEC);
	policing[port].smax = policer->burst;

	return sja1105_static_config_reload(priv, SJA1105_BEST_EFFORT_POLICING);
}
+1 −7
Original line number Diff line number Diff line
@@ -1241,8 +1241,6 @@ static int enetc_psfp_parse_clsflower(struct enetc_ndev_priv *priv,
	/* Flow meter and max frame size */
	if (entryp) {
		if (entryp->police.burst) {
			u64 temp;

			fmi = kzalloc(sizeof(*fmi), GFP_KERNEL);
			if (!fmi) {
				err = -ENOMEM;
@@ -1250,11 +1248,7 @@ static int enetc_psfp_parse_clsflower(struct enetc_ndev_priv *priv,
			}
			refcount_set(&fmi->refcount, 1);
			fmi->cir = entryp->police.rate_bytes_ps;
			/* Convert to original burst value */
			temp = entryp->police.burst * fmi->cir;
			temp = div_u64(temp, 1000000000ULL);

			fmi->cbs = temp;
			fmi->cbs = entryp->police.burst;
			fmi->index = entryp->police.index;
			filter->flags |= ENETC_PSFP_FLAGS_FMI;
			filter->fmi_index = fmi->index;
+1 −3
Original line number Diff line number Diff line
@@ -12,7 +12,6 @@ static int ocelot_flower_parse_action(struct flow_cls_offload *f,
				      struct ocelot_vcap_filter *filter)
{
	const struct flow_action_entry *a;
	s64 burst;
	u64 rate;
	int i;

@@ -35,8 +34,7 @@ static int ocelot_flower_parse_action(struct flow_cls_offload *f,
			filter->action = OCELOT_VCAP_ACTION_POLICE;
			rate = a->police.rate_bytes_ps;
			filter->pol.rate = div_u64(rate, 1000) * 8;
			burst = rate * PSCHED_NS2TICKS(a->police.burst);
			filter->pol.burst = div_u64(burst, PSCHED_TICKS_PER_SEC);
			filter->pol.burst = a->police.burst;
			break;
		default:
			return -EOPNOTSUPP;
Loading