* [net PATCH 0/2] Octeontx2 minor tc fixes
@ 2022-07-24 8:21 Subbaraya Sundeep
2022-07-24 8:21 ` [net PATCH 1/2] octeontx2-pf: cn10k: Fix egress ratelimit configuration Subbaraya Sundeep
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Subbaraya Sundeep @ 2022-07-24 8:21 UTC (permalink / raw)
To: davem, kuba, sgoutham, netdev; +Cc: Subbaraya Sundeep
This patch set fixes two problems found in tc code
wrt to ratelimiting and when installing UDP/TCP filters.
Patch 1: CN10K has different register format compared to
CN9xx hence fixes that.
Patch 2: Check flow mask also before installing a src/dst
port filter, otherwise installing for one port installs for other one too.
Thanks,
Sundeep
Subbaraya Sundeep (1):
octeontx2-pf: Fix UDP/TCP src and dst port tc filters
Sunil Goutham (1):
octeontx2-pf: cn10k: Fix egress ratelimit configuration
.../net/ethernet/marvell/octeontx2/nic/otx2_tc.c | 106 ++++++++++++++-------
1 file changed, 73 insertions(+), 33 deletions(-)
--
2.7.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* [net PATCH 1/2] octeontx2-pf: cn10k: Fix egress ratelimit configuration
2022-07-24 8:21 [net PATCH 0/2] Octeontx2 minor tc fixes Subbaraya Sundeep
@ 2022-07-24 8:21 ` Subbaraya Sundeep
2022-07-26 13:04 ` Paolo Abeni
2022-07-24 8:21 ` [net PATCH 2/2] octeontx2-pf: Fix UDP/TCP src and dst port tc filters Subbaraya Sundeep
2022-07-26 11:10 ` [net PATCH 0/2] Octeontx2 minor tc fixes patchwork-bot+netdevbpf
2 siblings, 1 reply; 5+ messages in thread
From: Subbaraya Sundeep @ 2022-07-24 8:21 UTC (permalink / raw)
To: davem, kuba, sgoutham, netdev; +Cc: Subbaraya Sundeep
From: Sunil Goutham <sgoutham@marvell.com>
NIX_AF_TLXX_PIR/CIR register format has changed from OcteonTx2
to CN10K. CN10K supports larger burst size. Fix burst exponent
and burst mantissa configuration for CN10K.
Also fixed 'maxrate' from u32 to u64 since 'police.rate_bytes_ps'
passed by stack is also u64.
Fixes: e638a83f167e ("octeontx2-pf: TC_MATCHALL egress ratelimiting offload")
Signed-off-by: Sunil Goutham <sgoutham@marvell.com>
Signed-off-by: Subbaraya Sundeep <sbhatta@marvell.com>
---
.../net/ethernet/marvell/octeontx2/nic/otx2_tc.c | 76 ++++++++++++++++------
1 file changed, 55 insertions(+), 21 deletions(-)
diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c
index 28b1994..fa83cf2 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c
@@ -28,6 +28,9 @@
#define MAX_RATE_EXPONENT 0x0FULL
#define MAX_RATE_MANTISSA 0xFFULL
+#define CN10K_MAX_BURST_MANTISSA 0x7FFFULL
+#define CN10K_MAX_BURST_SIZE 8453888ULL
+
/* Bitfields in NIX_TLX_PIR register */
#define TLX_RATE_MANTISSA GENMASK_ULL(8, 1)
#define TLX_RATE_EXPONENT GENMASK_ULL(12, 9)
@@ -35,6 +38,9 @@
#define TLX_BURST_MANTISSA GENMASK_ULL(36, 29)
#define TLX_BURST_EXPONENT GENMASK_ULL(40, 37)
+#define CN10K_TLX_BURST_MANTISSA GENMASK_ULL(43, 29)
+#define CN10K_TLX_BURST_EXPONENT GENMASK_ULL(47, 44)
+
struct otx2_tc_flow_stats {
u64 bytes;
u64 pkts;
@@ -77,33 +83,42 @@ int otx2_tc_alloc_ent_bitmap(struct otx2_nic *nic)
}
EXPORT_SYMBOL(otx2_tc_alloc_ent_bitmap);
-static void otx2_get_egress_burst_cfg(u32 burst, u32 *burst_exp,
- u32 *burst_mantissa)
+static void otx2_get_egress_burst_cfg(struct otx2_nic *nic, u32 burst,
+ u32 *burst_exp, u32 *burst_mantissa)
{
+ int max_burst, max_mantissa;
unsigned int tmp;
+ if (is_dev_otx2(nic->pdev)) {
+ max_burst = MAX_BURST_SIZE;
+ max_mantissa = MAX_BURST_MANTISSA;
+ } else {
+ max_burst = CN10K_MAX_BURST_SIZE;
+ max_mantissa = CN10K_MAX_BURST_MANTISSA;
+ }
+
/* Burst is calculated as
* ((256 + BURST_MANTISSA) << (1 + BURST_EXPONENT)) / 256
* Max supported burst size is 130,816 bytes.
*/
- burst = min_t(u32, burst, MAX_BURST_SIZE);
+ burst = min_t(u32, burst, max_burst);
if (burst) {
*burst_exp = ilog2(burst) ? ilog2(burst) - 1 : 0;
tmp = burst - rounddown_pow_of_two(burst);
- if (burst < MAX_BURST_MANTISSA)
+ if (burst < max_mantissa)
*burst_mantissa = tmp * 2;
else
*burst_mantissa = tmp / (1ULL << (*burst_exp - 7));
} else {
*burst_exp = MAX_BURST_EXPONENT;
- *burst_mantissa = MAX_BURST_MANTISSA;
+ *burst_mantissa = max_mantissa;
}
}
-static void otx2_get_egress_rate_cfg(u32 maxrate, u32 *exp,
+static void otx2_get_egress_rate_cfg(u64 maxrate, u32 *exp,
u32 *mantissa, u32 *div_exp)
{
- unsigned int tmp;
+ u64 tmp;
/* Rate calculation by hardware
*
@@ -132,21 +147,44 @@ static void otx2_get_egress_rate_cfg(u32 maxrate, u32 *exp,
}
}
-static int otx2_set_matchall_egress_rate(struct otx2_nic *nic, u32 burst, u32 maxrate)
+static u64 otx2_get_txschq_rate_regval(struct otx2_nic *nic,
+ u64 maxrate, u32 burst)
{
- struct otx2_hw *hw = &nic->hw;
- struct nix_txschq_config *req;
u32 burst_exp, burst_mantissa;
u32 exp, mantissa, div_exp;
+ u64 regval = 0;
+
+ /* Get exponent and mantissa values from the desired rate */
+ otx2_get_egress_burst_cfg(nic, burst, &burst_exp, &burst_mantissa);
+ otx2_get_egress_rate_cfg(maxrate, &exp, &mantissa, &div_exp);
+
+ if (is_dev_otx2(nic->pdev)) {
+ regval = FIELD_PREP(TLX_BURST_EXPONENT, (u64)burst_exp) |
+ FIELD_PREP(TLX_BURST_MANTISSA, (u64)burst_mantissa) |
+ FIELD_PREP(TLX_RATE_DIVIDER_EXPONENT, div_exp) |
+ FIELD_PREP(TLX_RATE_EXPONENT, exp) |
+ FIELD_PREP(TLX_RATE_MANTISSA, mantissa) | BIT_ULL(0);
+ } else {
+ regval = FIELD_PREP(CN10K_TLX_BURST_EXPONENT, (u64)burst_exp) |
+ FIELD_PREP(CN10K_TLX_BURST_MANTISSA, (u64)burst_mantissa) |
+ FIELD_PREP(TLX_RATE_DIVIDER_EXPONENT, div_exp) |
+ FIELD_PREP(TLX_RATE_EXPONENT, exp) |
+ FIELD_PREP(TLX_RATE_MANTISSA, mantissa) | BIT_ULL(0);
+ }
+
+ return regval;
+}
+
+static int otx2_set_matchall_egress_rate(struct otx2_nic *nic,
+ u32 burst, u64 maxrate)
+{
+ struct otx2_hw *hw = &nic->hw;
+ struct nix_txschq_config *req;
int txschq, err;
/* All SQs share the same TL4, so pick the first scheduler */
txschq = hw->txschq_list[NIX_TXSCH_LVL_TL4][0];
- /* Get exponent and mantissa values from the desired rate */
- otx2_get_egress_burst_cfg(burst, &burst_exp, &burst_mantissa);
- otx2_get_egress_rate_cfg(maxrate, &exp, &mantissa, &div_exp);
-
mutex_lock(&nic->mbox.lock);
req = otx2_mbox_alloc_msg_nix_txschq_cfg(&nic->mbox);
if (!req) {
@@ -157,11 +195,7 @@ static int otx2_set_matchall_egress_rate(struct otx2_nic *nic, u32 burst, u32 ma
req->lvl = NIX_TXSCH_LVL_TL4;
req->num_regs = 1;
req->reg[0] = NIX_AF_TL4X_PIR(txschq);
- req->regval[0] = FIELD_PREP(TLX_BURST_EXPONENT, burst_exp) |
- FIELD_PREP(TLX_BURST_MANTISSA, burst_mantissa) |
- FIELD_PREP(TLX_RATE_DIVIDER_EXPONENT, div_exp) |
- FIELD_PREP(TLX_RATE_EXPONENT, exp) |
- FIELD_PREP(TLX_RATE_MANTISSA, mantissa) | BIT_ULL(0);
+ req->regval[0] = otx2_get_txschq_rate_regval(nic, maxrate, burst);
err = otx2_sync_mbox_msg(&nic->mbox);
mutex_unlock(&nic->mbox.lock);
@@ -230,7 +264,7 @@ static int otx2_tc_egress_matchall_install(struct otx2_nic *nic,
struct netlink_ext_ack *extack = cls->common.extack;
struct flow_action *actions = &cls->rule->action;
struct flow_action_entry *entry;
- u32 rate;
+ u64 rate;
int err;
err = otx2_tc_validate_flow(nic, actions, extack);
@@ -256,7 +290,7 @@ static int otx2_tc_egress_matchall_install(struct otx2_nic *nic,
}
/* Convert bytes per second to Mbps */
rate = entry->police.rate_bytes_ps * 8;
- rate = max_t(u32, rate / 1000000, 1);
+ rate = max_t(u64, rate / 1000000, 1);
err = otx2_set_matchall_egress_rate(nic, entry->police.burst, rate);
if (err)
return err;
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [net PATCH 2/2] octeontx2-pf: Fix UDP/TCP src and dst port tc filters
2022-07-24 8:21 [net PATCH 0/2] Octeontx2 minor tc fixes Subbaraya Sundeep
2022-07-24 8:21 ` [net PATCH 1/2] octeontx2-pf: cn10k: Fix egress ratelimit configuration Subbaraya Sundeep
@ 2022-07-24 8:21 ` Subbaraya Sundeep
2022-07-26 11:10 ` [net PATCH 0/2] Octeontx2 minor tc fixes patchwork-bot+netdevbpf
2 siblings, 0 replies; 5+ messages in thread
From: Subbaraya Sundeep @ 2022-07-24 8:21 UTC (permalink / raw)
To: davem, kuba, sgoutham, netdev; +Cc: Subbaraya Sundeep
Check the mask for non-zero value before installing tc filters
for L4 source and destination ports. Otherwise installing a
filter for source port installs destination port too and
vice-versa.
Fixes: 1d4d9e42c240 ("octeontx2-pf: Add tc flower hardware offload on ingress traffic")
Signed-off-by: Subbaraya Sundeep <sbhatta@marvell.com>
Signed-off-by: Sunil Goutham <sgoutham@marvell.com>
---
.../net/ethernet/marvell/octeontx2/nic/otx2_tc.c | 30 +++++++++++++---------
1 file changed, 18 insertions(+), 12 deletions(-)
diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c
index fa83cf2..e64318c 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c
@@ -648,21 +648,27 @@ static int otx2_tc_prepare_flow(struct otx2_nic *nic, struct otx2_tc_flow *node,
flow_spec->dport = match.key->dst;
flow_mask->dport = match.mask->dst;
- if (ip_proto == IPPROTO_UDP)
- req->features |= BIT_ULL(NPC_DPORT_UDP);
- else if (ip_proto == IPPROTO_TCP)
- req->features |= BIT_ULL(NPC_DPORT_TCP);
- else if (ip_proto == IPPROTO_SCTP)
- req->features |= BIT_ULL(NPC_DPORT_SCTP);
+
+ if (flow_mask->dport) {
+ if (ip_proto == IPPROTO_UDP)
+ req->features |= BIT_ULL(NPC_DPORT_UDP);
+ else if (ip_proto == IPPROTO_TCP)
+ req->features |= BIT_ULL(NPC_DPORT_TCP);
+ else if (ip_proto == IPPROTO_SCTP)
+ req->features |= BIT_ULL(NPC_DPORT_SCTP);
+ }
flow_spec->sport = match.key->src;
flow_mask->sport = match.mask->src;
- if (ip_proto == IPPROTO_UDP)
- req->features |= BIT_ULL(NPC_SPORT_UDP);
- else if (ip_proto == IPPROTO_TCP)
- req->features |= BIT_ULL(NPC_SPORT_TCP);
- else if (ip_proto == IPPROTO_SCTP)
- req->features |= BIT_ULL(NPC_SPORT_SCTP);
+
+ if (flow_mask->sport) {
+ if (ip_proto == IPPROTO_UDP)
+ req->features |= BIT_ULL(NPC_SPORT_UDP);
+ else if (ip_proto == IPPROTO_TCP)
+ req->features |= BIT_ULL(NPC_SPORT_TCP);
+ else if (ip_proto == IPPROTO_SCTP)
+ req->features |= BIT_ULL(NPC_SPORT_SCTP);
+ }
}
return otx2_tc_parse_actions(nic, &rule->action, req, f, node);
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [net PATCH 0/2] Octeontx2 minor tc fixes
2022-07-24 8:21 [net PATCH 0/2] Octeontx2 minor tc fixes Subbaraya Sundeep
2022-07-24 8:21 ` [net PATCH 1/2] octeontx2-pf: cn10k: Fix egress ratelimit configuration Subbaraya Sundeep
2022-07-24 8:21 ` [net PATCH 2/2] octeontx2-pf: Fix UDP/TCP src and dst port tc filters Subbaraya Sundeep
@ 2022-07-26 11:10 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-07-26 11:10 UTC (permalink / raw)
To: Subbaraya Sundeep; +Cc: davem, kuba, sgoutham, netdev
Hello:
This series was applied to netdev/net-next.git (master)
by Paolo Abeni <pabeni@redhat.com>:
On Sun, 24 Jul 2022 13:51:12 +0530 you wrote:
> This patch set fixes two problems found in tc code
> wrt to ratelimiting and when installing UDP/TCP filters.
>
> Patch 1: CN10K has different register format compared to
> CN9xx hence fixes that.
> Patch 2: Check flow mask also before installing a src/dst
> port filter, otherwise installing for one port installs for other one too.
>
> [...]
Here is the summary with links:
- [net,1/2] octeontx2-pf: cn10k: Fix egress ratelimit configuration
https://git.kernel.org/netdev/net-next/c/5ec9c514d4a0
- [net,2/2] octeontx2-pf: Fix UDP/TCP src and dst port tc filters
https://git.kernel.org/netdev/net-next/c/d351c90ce248
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [net PATCH 1/2] octeontx2-pf: cn10k: Fix egress ratelimit configuration
2022-07-24 8:21 ` [net PATCH 1/2] octeontx2-pf: cn10k: Fix egress ratelimit configuration Subbaraya Sundeep
@ 2022-07-26 13:04 ` Paolo Abeni
0 siblings, 0 replies; 5+ messages in thread
From: Paolo Abeni @ 2022-07-26 13:04 UTC (permalink / raw)
To: Subbaraya Sundeep, davem, kuba, sgoutham, netdev
Hello,
On Sun, 2022-07-24 at 13:51 +0530, Subbaraya Sundeep wrote:
> From: Sunil Goutham <sgoutham@marvell.com>
>
> NIX_AF_TLXX_PIR/CIR register format has changed from OcteonTx2
> to CN10K. CN10K supports larger burst size. Fix burst exponent
> and burst mantissa configuration for CN10K.
>
> Also fixed 'maxrate' from u32 to u64 since 'police.rate_bytes_ps'
> passed by stack is also u64.
>
> Fixes: e638a83f167e ("octeontx2-pf: TC_MATCHALL egress ratelimiting offload")
> Signed-off-by: Sunil Goutham <sgoutham@marvell.com>
> Signed-off-by: Subbaraya Sundeep <sbhatta@marvell.com>
I wrongly applied this series to net-next due to PEBKAC here. I'm going
to rever it and apply to net.
I'm sorry for the confusion,
Paolo
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-07-26 13:04 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-24 8:21 [net PATCH 0/2] Octeontx2 minor tc fixes Subbaraya Sundeep
2022-07-24 8:21 ` [net PATCH 1/2] octeontx2-pf: cn10k: Fix egress ratelimit configuration Subbaraya Sundeep
2022-07-26 13:04 ` Paolo Abeni
2022-07-24 8:21 ` [net PATCH 2/2] octeontx2-pf: Fix UDP/TCP src and dst port tc filters Subbaraya Sundeep
2022-07-26 11:10 ` [net PATCH 0/2] Octeontx2 minor tc fixes patchwork-bot+netdevbpf
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.