Commit 77043c37 authored by Xiaoliang Yang's avatar Xiaoliang Yang Committed by David S. Miller
Browse files

net: mscc: ocelot: use index to set vcap policer



Policer was previously automatically assigned from the highest index to
the lowest index from policer pool. But police action of tc flower now
uses index to set an police entry. This patch uses the police index to
set vcap policers, so that one policer can be shared by multiple rules.

Signed-off-by: default avatarXiaoliang Yang <xiaoliang.yang_1@nxp.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 23ae3a78
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -989,6 +989,10 @@ static int felix_init_structs(struct felix *felix, int num_phys_ports)
	ocelot->num_stats	= felix->info->num_stats;
	ocelot->num_mact_rows	= felix->info->num_mact_rows;
	ocelot->vcap		= felix->info->vcap;
	ocelot->vcap_pol.base	= felix->info->vcap_pol_base;
	ocelot->vcap_pol.max	= felix->info->vcap_pol_max;
	ocelot->vcap_pol.base2	= felix->info->vcap_pol_base2;
	ocelot->vcap_pol.max2	= felix->info->vcap_pol_max2;
	ocelot->ops		= felix->info->ops;
	ocelot->npi_inj_prefix	= OCELOT_TAG_PREFIX_SHORT;
	ocelot->npi_xtr_prefix	= OCELOT_TAG_PREFIX_SHORT;
+4 −0
Original line number Diff line number Diff line
@@ -21,6 +21,10 @@ struct felix_info {
	int				num_ports;
	int				num_tx_queues;
	struct vcap_props		*vcap;
	u16				vcap_pol_base;
	u16				vcap_pol_max;
	u16				vcap_pol_base2;
	u16				vcap_pol_max2;
	int				switch_pci_bar;
	int				imdio_pci_bar;
	const struct ptp_clock_info	*ptp_caps;
+6 −0
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@
#include "felix.h"

#define VSC9959_TAS_GCL_ENTRY_MAX	63
#define VSC9959_VCAP_POLICER_BASE	63
#define VSC9959_VCAP_POLICER_MAX	383

static const u32 vsc9959_ana_regmap[] = {
	REG(ANA_ADVLEARN,			0x0089a0),
@@ -1986,6 +1988,10 @@ static const struct felix_info felix_info_vsc9959 = {
	.stats_layout		= vsc9959_stats_layout,
	.num_stats		= ARRAY_SIZE(vsc9959_stats_layout),
	.vcap			= vsc9959_vcap_props,
	.vcap_pol_base		= VSC9959_VCAP_POLICER_BASE,
	.vcap_pol_max		= VSC9959_VCAP_POLICER_MAX,
	.vcap_pol_base2		= 0,
	.vcap_pol_max2		= 0,
	.num_mact_rows		= 2048,
	.num_ports		= 6,
	.num_tx_queues		= OCELOT_NUM_TC,
+8 −0
Original line number Diff line number Diff line
@@ -18,6 +18,10 @@
#define MSCC_MIIM_CMD_REGAD_SHIFT		20
#define MSCC_MIIM_CMD_PHYAD_SHIFT		25
#define MSCC_MIIM_CMD_VLD			BIT(31)
#define VSC9953_VCAP_POLICER_BASE		11
#define VSC9953_VCAP_POLICER_MAX		31
#define VSC9953_VCAP_POLICER_BASE2		120
#define VSC9953_VCAP_POLICER_MAX2		161

static const u32 vsc9953_ana_regmap[] = {
	REG(ANA_ADVLEARN,			0x00b500),
@@ -1172,6 +1176,10 @@ static const struct felix_info seville_info_vsc9953 = {
	.stats_layout		= vsc9953_stats_layout,
	.num_stats		= ARRAY_SIZE(vsc9953_stats_layout),
	.vcap			= vsc9953_vcap_props,
	.vcap_pol_base		= VSC9953_VCAP_POLICER_BASE,
	.vcap_pol_max		= VSC9953_VCAP_POLICER_MAX,
	.vcap_pol_base2		= VSC9953_VCAP_POLICER_BASE2,
	.vcap_pol_max2		= VSC9953_VCAP_POLICER_MAX2,
	.num_mact_rows		= 2048,
	.num_ports		= 10,
	.num_tx_queues		= OCELOT_NUM_TC,
+15 −0
Original line number Diff line number Diff line
@@ -222,6 +222,7 @@ static int ocelot_flower_parse_action(struct ocelot *ocelot, int port,
	const struct flow_action_entry *a;
	enum ocelot_tag_tpid_sel tpid;
	int i, chain, egress_port;
	u32 pol_ix, pol_max;
	u64 rate;
	int err;

@@ -301,6 +302,20 @@ static int ocelot_flower_parse_action(struct ocelot *ocelot, int port,
				return -EOPNOTSUPP;
			}
			filter->action.police_ena = true;

			pol_ix = a->police.index + ocelot->vcap_pol.base;
			pol_max = ocelot->vcap_pol.max;

			if (ocelot->vcap_pol.max2 && pol_ix > pol_max) {
				pol_ix += ocelot->vcap_pol.base2 - pol_max - 1;
				pol_max = ocelot->vcap_pol.max2;
			}

			if (pol_ix >= pol_max)
				return -EINVAL;

			filter->action.pol_ix = pol_ix;

			rate = a->police.rate_bytes_ps;
			filter->action.pol.rate = div_u64(rate, 1000) * 8;
			filter->action.pol.burst = a->police.burst;
Loading