From: Jiri Pirko <jiri@resnulli.us>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, arkadis@mellanox.com, idosch@mellanox.com,
mlxsw@mellanox.com
Subject: [patch net-next 05/12] devlink: Move dpipe entry clear function into devlink
Date: Thu, 24 Aug 2017 08:40:03 +0200 [thread overview]
Message-ID: <20170824064010.1646-6-jiri@resnulli.us> (raw)
In-Reply-To: <20170824064010.1646-1-jiri@resnulli.us>
From: Arkadi Sharshevsky <arkadis@mellanox.com>
The entry clear routine can be shared between the drivers, thus it is
moved inside devlink.
Signed-off-by: Arkadi Sharshevsky <arkadis@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
.../net/ethernet/mellanox/mlxsw/spectrum_dpipe.c | 24 ++--------------------
include/net/devlink.h | 6 ++++++
net/core/devlink.c | 22 ++++++++++++++++++++
3 files changed, 30 insertions(+), 22 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.c
index 9eb265b..1305df9 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_dpipe.c
@@ -114,26 +114,6 @@ static int mlxsw_sp_dpipe_table_erif_matches_dump(void *priv,
return devlink_dpipe_match_put(skb, &match);
}
-static void mlxsw_sp_erif_entry_clear(struct devlink_dpipe_entry *entry)
-{
- unsigned int value_count, value_index;
- struct devlink_dpipe_value *value;
-
- value = entry->action_values;
- value_count = entry->action_values_count;
- for (value_index = 0; value_index < value_count; value_index++) {
- kfree(value[value_index].value);
- kfree(value[value_index].mask);
- }
-
- value = entry->match_values;
- value_count = entry->match_values_count;
- for (value_index = 0; value_index < value_count; value_index++) {
- kfree(value[value_index].value);
- kfree(value[value_index].mask);
- }
-}
-
static void
mlxsw_sp_erif_match_action_prepare(struct devlink_dpipe_match *match,
struct devlink_dpipe_action *action)
@@ -270,12 +250,12 @@ mlxsw_sp_dpipe_table_erif_entries_dump(void *priv, bool counters_enabled,
goto start_again;
rtnl_unlock();
- mlxsw_sp_erif_entry_clear(&entry);
+ devlink_dpipe_entry_clear(&entry);
return 0;
err_entry_append:
err_entry_get:
rtnl_unlock();
- mlxsw_sp_erif_entry_clear(&entry);
+ devlink_dpipe_entry_clear(&entry);
return err;
}
diff --git a/include/net/devlink.h b/include/net/devlink.h
index e96272b..047a0c5 100644
--- a/include/net/devlink.h
+++ b/include/net/devlink.h
@@ -323,6 +323,7 @@ int devlink_dpipe_entry_ctx_prepare(struct devlink_dpipe_dump_ctx *dump_ctx);
int devlink_dpipe_entry_ctx_append(struct devlink_dpipe_dump_ctx *dump_ctx,
struct devlink_dpipe_entry *entry);
int devlink_dpipe_entry_ctx_close(struct devlink_dpipe_dump_ctx *dump_ctx);
+void devlink_dpipe_entry_clear(struct devlink_dpipe_entry *entry);
int devlink_dpipe_action_put(struct sk_buff *skb,
struct devlink_dpipe_action *action);
int devlink_dpipe_match_put(struct sk_buff *skb,
@@ -448,6 +449,11 @@ devlink_dpipe_entry_ctx_close(struct devlink_dpipe_dump_ctx *dump_ctx)
return 0;
}
+static inline void
+devlink_dpipe_entry_clear(struct devlink_dpipe_entry *entry)
+{
+}
+
static inline int
devlink_dpipe_action_put(struct sk_buff *skb,
struct devlink_dpipe_action *action)
diff --git a/net/core/devlink.c b/net/core/devlink.c
index 87062ff..194708a 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -1996,6 +1996,28 @@ int devlink_dpipe_entry_ctx_close(struct devlink_dpipe_dump_ctx *dump_ctx)
}
EXPORT_SYMBOL_GPL(devlink_dpipe_entry_ctx_close);
+void devlink_dpipe_entry_clear(struct devlink_dpipe_entry *entry)
+
+{
+ unsigned int value_count, value_index;
+ struct devlink_dpipe_value *value;
+
+ value = entry->action_values;
+ value_count = entry->action_values_count;
+ for (value_index = 0; value_index < value_count; value_index++) {
+ kfree(value[value_index].value);
+ kfree(value[value_index].mask);
+ }
+
+ value = entry->match_values;
+ value_count = entry->match_values_count;
+ for (value_index = 0; value_index < value_count; value_index++) {
+ kfree(value[value_index].value);
+ kfree(value[value_index].mask);
+ }
+}
+EXPORT_SYMBOL(devlink_dpipe_entry_clear);
+
static int devlink_dpipe_entries_fill(struct genl_info *info,
enum devlink_command cmd, int flags,
struct devlink_dpipe_table *table)
--
2.9.3
next prev parent reply other threads:[~2017-08-24 6:40 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-24 6:39 [patch net-next 00/12] mlxsw: Add IPv4 host dpipe table Jiri Pirko
2017-08-24 6:39 ` [patch net-next 01/12] devlink: Add Ethernet header for dpipe Jiri Pirko
2017-08-24 6:40 ` [patch net-next 02/12] devlink: Add IPv4 " Jiri Pirko
2017-08-24 6:40 ` [patch net-next 03/12] mlxsw: spectrum_dpipe: Fix erif table op name space Jiri Pirko
2017-08-24 6:40 ` [patch net-next 04/12] devlink: Add support for dynamic table size Jiri Pirko
2017-08-24 6:40 ` Jiri Pirko [this message]
2017-08-24 6:40 ` [patch net-next 06/12] mlxsw: spectrum_router: Add helpers for neighbor access Jiri Pirko
2017-08-24 6:40 ` [patch net-next 07/12] mlxsw: spectrum_dpipe: Fix label name Jiri Pirko
2017-08-24 6:40 ` [patch net-next 08/12] mlxsw: spectrum_dpipe: Add IPv4 host table initial support Jiri Pirko
2017-08-24 6:40 ` [patch net-next 09/12] mlxsw: reg: Make flow counter set type enum to be shared Jiri Pirko
2017-08-24 6:40 ` [patch net-next 10/12] mlxsw: spectrum_router: Add support for setting counters on neighbors Jiri Pirko
2017-08-24 6:40 ` [patch net-next 11/12] mlxsw: spectrum_dpipe: Add support for IPv4 host table dump Jiri Pirko
2017-08-24 19:26 ` David Ahern
2017-08-25 9:26 ` Arkadi Sharshevsky
2017-08-25 19:51 ` David Ahern
2017-08-27 8:31 ` Arkadi Sharshevsky
2017-08-29 2:57 ` David Ahern
2017-08-29 7:55 ` Jiri Pirko
2017-08-24 6:40 ` [patch net-next 12/12] mlxsw: spectrum_dpipe: Add support for controlling neighbor counters Jiri Pirko
2017-08-24 19:28 ` David Ahern
2017-08-24 16:33 ` [patch net-next 00/12] mlxsw: Add IPv4 host dpipe table 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=20170824064010.1646-6-jiri@resnulli.us \
--to=jiri@resnulli.us \
--cc=arkadis@mellanox.com \
--cc=davem@davemloft.net \
--cc=idosch@mellanox.com \
--cc=mlxsw@mellanox.com \
--cc=netdev@vger.kernel.org \
/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).