From: Jerin Jacob <jerinjacobk@gmail.com>
To: netdev@vger.kernel.org, davem@davemloft.net
Cc: sgoutham@marvell.com, lcherian@marvell.com, gakula@marvell.com,
jerinj@marvell.com, Nithin Dabilpuram <ndabilpuram@marvell.com>
Subject: [PATCH v1 net-next 03/14] octeontx2-af: Add support for dynamic flow cfg to RSS field generation
Date: Sat, 1 Dec 2018 14:43:52 +0530 [thread overview]
Message-ID: <20181201091403.30166-4-jerinjacobk@gmail.com> (raw)
In-Reply-To: <20181201091403.30166-1-jerinjacobk@gmail.com>
From: Jerin Jacob <jerinj@marvell.com>
Introduce state-based algorithm to convert the flow_key value
to RSS algo field used by NIX_AF_RX_FLOW_KEY_ALGX_FIELDX register.
The outer `for loop` goes over _all_ protocol field and the following
variables depict the state machine forward progress logic.
a) keyoff_marker - Enabled when hash byte length needs to be accounted
in field->key_offset update.
b) field_marker - Enabled when a new field needs to be selected.
c) group_member - Enabled when a protocol is part of a group.
This would remove the existing hard coding and enable to add
new protocol support seamlessly.
Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Signed-off-by: Nithin Dabilpuram <ndabilpuram@marvell.com>
---
.../net/ethernet/marvell/octeontx2/af/mbox.h | 1 +
.../ethernet/marvell/octeontx2/af/rvu_nix.c | 112 +++++++++++++-----
2 files changed, 86 insertions(+), 27 deletions(-)
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
index 4cce31fb13ab..1e129112cc51 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
+++ b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h
@@ -414,6 +414,7 @@ enum nix_af_status {
NIX_AF_INVAL_TXSCHQ_CFG = -412,
NIX_AF_SMQ_FLUSH_FAILED = -413,
NIX_AF_ERR_LF_RESET = -414,
+ NIX_AF_ERR_RSS_NOSPC_FIELD = -415,
NIX_AF_INVAL_NPA_PF_FUNC = -419,
NIX_AF_INVAL_SSO_PF_FUNC = -420,
};
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
index 76fec9928ab7..5b7a0a04b529 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
@@ -1647,80 +1647,138 @@ int rvu_mbox_handler_nix_rss_flowkey_cfg(struct rvu *rvu,
return 0;
}
-static void set_flowkey_fields(struct nix_rx_flowkey_alg *alg, u32 flow_cfg)
+static int set_flowkey_fields(struct nix_rx_flowkey_alg *alg, u32 flow_cfg)
{
- struct nix_rx_flowkey_alg *field = NULL;
- int idx, key_type;
+ int idx, nr_field, key_off, field_marker, keyoff_marker;
+ int max_key_off, max_bit_pos, group_member;
+ struct nix_rx_flowkey_alg *field;
+ struct nix_rx_flowkey_alg tmp;
+ u32 key_type, valid_key;
if (!alg)
- return;
+ return -EINVAL;
- /* FIELD0: IPv4
- * FIELD1: IPv6
- * FIELD2: TCP/UDP/SCTP/ALL
- * FIELD3: Unused
- * FIELD4: Unused
- *
- * Each of the 32 possible flow key algorithm definitions should
+#define FIELDS_PER_ALG 5
+#define MAX_KEY_OFF 40
+ /* Clear all fields */
+ memset(alg, 0, sizeof(uint64_t) * FIELDS_PER_ALG);
+
+ /* Each of the 32 possible flow key algorithm definitions should
* fall into above incremental config (except ALG0). Otherwise a
* single NPC MCAM entry is not sufficient for supporting RSS.
*
* If a different definition or combination needed then NPC MCAM
* has to be programmed to filter such pkts and it's action should
* point to this definition to calculate flowtag or hash.
+ *
+ * The `for loop` goes over _all_ protocol field and the following
+ * variables depicts the state machine forward progress logic.
+ *
+ * keyoff_marker - Enabled when hash byte length needs to be accounted
+ * in field->key_offset update.
+ * field_marker - Enabled when a new field needs to be selected.
+ * group_member - Enabled when protocol is part of a group.
*/
- for (idx = 0; idx < 32; idx++) {
- key_type = flow_cfg & BIT_ULL(idx);
- if (!key_type)
- continue;
+
+ keyoff_marker = 0; max_key_off = 0; group_member = 0;
+ nr_field = 0; key_off = 0; field_marker = 1;
+ field = &tmp; max_bit_pos = fls(flow_cfg);
+ for (idx = 0;
+ idx < max_bit_pos && nr_field < FIELDS_PER_ALG &&
+ key_off < MAX_KEY_OFF; idx++) {
+ key_type = BIT(idx);
+ valid_key = flow_cfg & key_type;
+ /* Found a field marker, reset the field values */
+ if (field_marker)
+ memset(&tmp, 0, sizeof(tmp));
+
switch (key_type) {
case FLOW_KEY_TYPE_PORT:
- field = &alg[0];
field->sel_chan = true;
/* This should be set to 1, when SEL_CHAN is set */
field->bytesm1 = 1;
+ field_marker = true;
+ keyoff_marker = true;
break;
case FLOW_KEY_TYPE_IPV4:
- field = &alg[0];
field->lid = NPC_LID_LC;
field->ltype_match = NPC_LT_LC_IP;
field->hdr_offset = 12; /* SIP offset */
field->bytesm1 = 7; /* SIP + DIP, 8 bytes */
field->ltype_mask = 0xF; /* Match only IPv4 */
+ field_marker = true;
+ keyoff_marker = false;
break;
case FLOW_KEY_TYPE_IPV6:
- field = &alg[1];
field->lid = NPC_LID_LC;
field->ltype_match = NPC_LT_LC_IP6;
field->hdr_offset = 8; /* SIP offset */
field->bytesm1 = 31; /* SIP + DIP, 32 bytes */
field->ltype_mask = 0xF; /* Match only IPv6 */
+ field_marker = true;
+ keyoff_marker = true;
break;
case FLOW_KEY_TYPE_TCP:
case FLOW_KEY_TYPE_UDP:
case FLOW_KEY_TYPE_SCTP:
- field = &alg[2];
field->lid = NPC_LID_LD;
field->bytesm1 = 3; /* Sport + Dport, 4 bytes */
- if (key_type == FLOW_KEY_TYPE_TCP)
+ if (key_type == FLOW_KEY_TYPE_TCP && valid_key) {
field->ltype_match |= NPC_LT_LD_TCP;
- else if (key_type == FLOW_KEY_TYPE_UDP)
+ group_member = true;
+ } else if (key_type == FLOW_KEY_TYPE_UDP && valid_key) {
field->ltype_match |= NPC_LT_LD_UDP;
- else if (key_type == FLOW_KEY_TYPE_SCTP)
+ group_member = true;
+ } else if (key_type == FLOW_KEY_TYPE_SCTP &&
+ valid_key) {
field->ltype_match |= NPC_LT_LD_SCTP;
- field->key_offset = 32; /* After IPv4/v6 SIP, DIP */
+ group_member = true;
+ }
field->ltype_mask = ~field->ltype_match;
+ if (key_type == FLOW_KEY_TYPE_SCTP) {
+ /* Handle the case where any of the group item
+ * is enabled in the group but not the final one
+ */
+ if (group_member) {
+ valid_key = true;
+ group_member = false;
+ }
+ field_marker = true;
+ keyoff_marker = true;
+ } else {
+ field_marker = false;
+ keyoff_marker = false;
+ }
break;
}
- if (field)
- field->ena = 1;
- field = NULL;
+ field->ena = 1;
+
+ /* Found a valid flow key type */
+ if (valid_key) {
+ field->key_offset = key_off;
+ memcpy(&alg[nr_field], field, sizeof(*field));
+ max_key_off = max(max_key_off, field->bytesm1 + 1);
+
+ /* Found a field marker, get the next field */
+ if (field_marker)
+ nr_field++;
+ }
+
+ /* Found a keyoff marker, update the new key_off */
+ if (keyoff_marker) {
+ key_off += max_key_off;
+ max_key_off = 0;
+ }
}
+ /* Processed all the flow key types */
+ if (idx == max_bit_pos && key_off <= MAX_KEY_OFF)
+ return 0;
+ else
+ return NIX_AF_ERR_RSS_NOSPC_FIELD;
}
static void nix_rx_flowkey_alg_cfg(struct rvu *rvu, int blkaddr)
{
-#define FIELDS_PER_ALG 5
u64 field[FLOW_KEY_ALG_MAX][FIELDS_PER_ALG];
u32 flowkey_cfg, minkey_cfg;
int alg, fid;
--
2.19.2
next prev parent reply other threads:[~2018-12-01 20:27 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-01 9:13 [PATCH v1 net-next 00/14] octeontx2-af: NIX and NPC enhancements Jerin Jacob
2018-12-01 9:13 ` [PATCH v1 net-next 01/14] octeontx2-af: Skip NIXLF check for bcast MCE entry Jerin Jacob
2018-12-01 9:13 ` [PATCH v1 net-next 02/14] octeontx2-af: Add response for RSS flow key cfg message Jerin Jacob
2018-12-02 1:30 ` David Miller
2018-12-01 9:13 ` Jerin Jacob [this message]
2018-12-01 9:13 ` [PATCH v1 net-next 04/14] octeontx2-af: Add support for runtime RSS algo index reservation Jerin Jacob
2018-12-01 9:13 ` [PATCH v1 net-next 05/14] octeontx2-af: Restrict TL1 allocation and configuration Jerin Jacob
2018-12-02 1:31 ` David Miller
2018-12-01 9:13 ` [PATCH v1 net-next 06/14] octeontx2-af: Allow freeing single TLx Tx schedule queue Jerin Jacob
2018-12-01 9:13 ` [PATCH v1 net-next 07/14] octeontx2-af: Enable inner IPv4 checksum and its error code Jerin Jacob
2018-12-01 9:13 ` [PATCH v1 net-next 08/14] octeontx2-af: Define all NIX_AF_RX_DEF_* registers Jerin Jacob
2018-12-01 9:13 ` [PATCH v1 net-next 09/14] octeontx2-af: Enable RSS with promiscuous mode Jerin Jacob
2018-12-01 9:13 ` [PATCH v1 net-next 10/14] octeontx2-af: Add support for Tx packet marking Jerin Jacob
2018-12-01 9:14 ` [PATCH v1 net-next 11/14] octeontx2-af: Configure VLAN TPIDs Jerin Jacob
2018-12-01 9:14 ` [PATCH v1 net-next 12/14] octeontx2-af: Add L3 and L4 packet verification mailbox Jerin Jacob
2018-12-01 9:14 ` [PATCH v1 net-next 13/14] octeontx2-af: Add LSO format configuration mailbox Jerin Jacob
2018-12-01 9:14 ` [PATCH v1 net-next 14/14] octeontx2-af: Enable mkex profile Jerin Jacob
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181201091403.30166-4-jerinjacobk@gmail.com \
--to=jerinjacobk@gmail.com \
--cc=davem@davemloft.net \
--cc=gakula@marvell.com \
--cc=jerinj@marvell.com \
--cc=lcherian@marvell.com \
--cc=ndabilpuram@marvell.com \
--cc=netdev@vger.kernel.org \
--cc=sgoutham@marvell.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).