From: Ido Schimmel <idosch@idosch.org>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, jiri@mellanox.com, shalomt@mellanox.com,
mlxsw@mellanox.com, Ido Schimmel <idosch@mellanox.com>
Subject: [PATCH net-next 4/6] mlxsw: core: Add support for EMAD string TLV parsing
Date: Sun, 3 Nov 2019 10:35:52 +0200 [thread overview]
Message-ID: <20191103083554.6317-5-idosch@idosch.org> (raw)
In-Reply-To: <20191103083554.6317-1-idosch@idosch.org>
From: Shalom Toledo <shalomt@mellanox.com>
During parsing of incoming EMADs, fill the string TLV's offset when it is
used.
Signed-off-by: Shalom Toledo <shalomt@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
drivers/net/ethernet/mellanox/mlxsw/core.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c
index 1803b246d9b4..e166ce745150 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core.c
@@ -382,17 +382,32 @@ static void mlxsw_emad_construct(struct sk_buff *skb,
struct mlxsw_emad_tlv_offsets {
u16 op_tlv;
+ u16 string_tlv;
u16 reg_tlv;
};
+static bool mlxsw_emad_tlv_is_string_tlv(const char *tlv)
+{
+ u8 tlv_type = mlxsw_emad_string_tlv_type_get(tlv);
+
+ return tlv_type == MLXSW_EMAD_TLV_TYPE_STRING;
+}
+
static void mlxsw_emad_tlv_parse(struct sk_buff *skb)
{
struct mlxsw_emad_tlv_offsets *offsets =
(struct mlxsw_emad_tlv_offsets *) skb->cb;
offsets->op_tlv = MLXSW_EMAD_ETH_HDR_LEN;
+ offsets->string_tlv = 0;
offsets->reg_tlv = MLXSW_EMAD_ETH_HDR_LEN +
MLXSW_EMAD_OP_TLV_LEN * sizeof(u32);
+
+ /* If string TLV is present, it must come after the operation TLV. */
+ if (mlxsw_emad_tlv_is_string_tlv(skb->data + offsets->reg_tlv)) {
+ offsets->string_tlv = offsets->reg_tlv;
+ offsets->reg_tlv += MLXSW_EMAD_STRING_TLV_LEN * sizeof(u32);
+ }
}
static char *mlxsw_emad_op_tlv(const struct sk_buff *skb)
--
2.21.0
next prev parent reply other threads:[~2019-11-03 8:38 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-03 8:35 [PATCH net-next 0/6] mlxsw: Add extended ACK for EMADs Ido Schimmel
2019-11-03 8:35 ` [PATCH net-next 1/6] mlxsw: core: Parse TLVs' offsets of incoming EMADs Ido Schimmel
2019-11-03 8:35 ` [PATCH net-next 2/6] mlxsw: emad: Remove deprecated EMAD TLVs Ido Schimmel
2019-11-03 8:35 ` [PATCH net-next 3/6] mlxsw: core: Add EMAD string TLV Ido Schimmel
2019-11-03 8:35 ` Ido Schimmel [this message]
2019-11-03 8:35 ` [PATCH net-next 5/6] mlxsw: core: Add support for using " Ido Schimmel
2019-11-03 8:35 ` [PATCH net-next 6/6] mlxsw: spectrum: Enable " Ido Schimmel
2019-11-04 20:39 ` [PATCH net-next 0/6] mlxsw: Add extended ACK for EMADs Jakub Kicinski
2019-11-04 21:04 ` Ido Schimmel
2019-11-04 22:44 ` Jakub Kicinski
2019-11-04 23:20 ` Ido Schimmel
2019-11-04 23:33 ` Jakub Kicinski
2019-11-05 7:46 ` Ido Schimmel
2019-11-05 17:54 ` Jakub Kicinski
2019-11-05 20:48 ` Ido Schimmel
2019-11-05 21:48 ` Jakub Kicinski
2019-11-06 8:20 ` Jiri Pirko
2019-11-06 17:26 ` Jakub Kicinski
2019-11-07 9:42 ` Jiri Pirko
2019-11-06 1:58 ` David Miller
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=20191103083554.6317-5-idosch@idosch.org \
--to=idosch@idosch.org \
--cc=davem@davemloft.net \
--cc=idosch@mellanox.com \
--cc=jiri@mellanox.com \
--cc=mlxsw@mellanox.com \
--cc=netdev@vger.kernel.org \
--cc=shalomt@mellanox.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).