[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200929222733.770926-10-vladimir.oltean@nxp.com>
Date: Wed, 30 Sep 2020 01:27:29 +0300
From: Vladimir Oltean <vladimir.oltean@....com>
To: davem@...emloft.net
Cc: alexandre.belloni@...tlin.com, andrew@...n.ch,
f.fainelli@...il.com, vivien.didelot@...il.com,
horatiu.vultur@...rochip.com, joergen.andreasen@...rochip.com,
allan.nielsen@...rochip.com, alexandru.marginean@....com,
claudiu.manoil@....com, xiaoliang.yang_1@....com,
hongbo.wang@....com, netdev@...r.kernel.org, kuba@...nel.org,
UNGLinuxDriver@...rochip.com
Subject: [PATCH net-next 09/13] net: mscc: ocelot: calculate vcap offsets correctly for full and quarter entries
From: Xiaoliang Yang <xiaoliang.yang_1@....com>
When calculating the offsets for the current entry within the row and
placing them inside struct vcap_data, the function assumes half key
entry (2 keys per row).
This patch modifies the vcap_data_offset_get() function to calculate a
correct data offset when the setting VCAP Type-Group of a key to
VCAP_TG_FULL or VCAP_TG_QUARTER.
This is needed because, for example, VCAP ES0 only supports full keys.
Also rename the 'count' variable to 'num_entries_per_row' to make the
function just one tiny bit easier to follow.
Signed-off-by: Xiaoliang Yang <xiaoliang.yang_1@....com>
Signed-off-by: Vladimir Oltean <vladimir.oltean@....com>
---
Changes since RFC v2:
Replaced the obscure 2 ^ n formula with something that is more obviously
correct.
drivers/net/ethernet/mscc/ocelot_vcap.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/mscc/ocelot_vcap.c b/drivers/net/ethernet/mscc/ocelot_vcap.c
index b736c3d3df2f..3f7d3fbaa1fc 100644
--- a/drivers/net/ethernet/mscc/ocelot_vcap.c
+++ b/drivers/net/ethernet/mscc/ocelot_vcap.c
@@ -177,8 +177,21 @@ static void vcap_data_offset_get(const struct vcap_props *vcap,
int i, col, offset, count, cnt, base;
u32 width = vcap->tg_width;
- count = (data->tg_sw == VCAP_TG_HALF ? 2 : 4);
- col = (ix % 2);
+ switch (data->tg_sw) {
+ case VCAP_TG_FULL:
+ count = 1;
+ break;
+ case VCAP_TG_HALF:
+ count = 2;
+ break;
+ case VCAP_TG_QUARTER:
+ count = 4;
+ break;
+ default:
+ return;
+ }
+
+ col = (ix % count);
cnt = (vcap->sw_count / count);
base = (vcap->sw_count - col * cnt - cnt);
data->tg_value = 0;
--
2.25.1
Powered by blists - more mailing lists