From: Jiri Pirko <jiri@resnulli.us>
To: netdev@vger.kernel.org
Cc: kuba@kernel.org, pabeni@redhat.com, davem@davemloft.net,
edumazet@google.com, idosch@nvidia.com, petrm@nvidia.com,
jacob.e.keller@intel.com, moshe@nvidia.com, shayd@nvidia.com,
saeedm@nvidia.com, horms@kernel.org
Subject: [patch net-next v2 01/12] devlink: move linecard struct into linecard.c
Date: Wed, 13 Sep 2023 09:12:32 +0200 [thread overview]
Message-ID: <20230913071243.930265-2-jiri@resnulli.us> (raw)
In-Reply-To: <20230913071243.930265-1-jiri@resnulli.us>
From: Jiri Pirko <jiri@nvidia.com>
Instead of exposing linecard struct, expose a simple helper to get the
linecard index, which is all is needed outside linecard.c. Move the
linecard struct to linecard.c and keep it private similar to the rest of
the devlink objects.
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
---
v1->v2:
- new patch
---
net/devlink/devl_internal.h | 14 +-------------
net/devlink/linecard.c | 19 +++++++++++++++++++
net/devlink/port.c | 4 ++--
3 files changed, 22 insertions(+), 15 deletions(-)
diff --git a/net/devlink/devl_internal.h b/net/devlink/devl_internal.h
index f6b5fea2e13c..1b05c2c09e27 100644
--- a/net/devlink/devl_internal.h
+++ b/net/devlink/devl_internal.h
@@ -206,19 +206,7 @@ int devlink_rate_nodes_check(struct devlink *devlink, u16 mode,
struct netlink_ext_ack *extack);
/* Linecards */
-struct devlink_linecard {
- struct list_head list;
- struct devlink *devlink;
- unsigned int index;
- const struct devlink_linecard_ops *ops;
- void *priv;
- enum devlink_linecard_state state;
- struct mutex state_lock; /* Protects state */
- const char *type;
- struct devlink_linecard_type *types;
- unsigned int types_count;
- struct devlink *nested_devlink;
-};
+unsigned int devlink_linecard_index(struct devlink_linecard *linecard);
/* Devlink nl cmds */
int devlink_nl_cmd_reload(struct sk_buff *skb, struct genl_info *info);
diff --git a/net/devlink/linecard.c b/net/devlink/linecard.c
index 85c32c314b0f..a0210ba56f2d 100644
--- a/net/devlink/linecard.c
+++ b/net/devlink/linecard.c
@@ -6,6 +6,25 @@
#include "devl_internal.h"
+struct devlink_linecard {
+ struct list_head list;
+ struct devlink *devlink;
+ unsigned int index;
+ const struct devlink_linecard_ops *ops;
+ void *priv;
+ enum devlink_linecard_state state;
+ struct mutex state_lock; /* Protects state */
+ const char *type;
+ struct devlink_linecard_type *types;
+ unsigned int types_count;
+ struct devlink *nested_devlink;
+};
+
+unsigned int devlink_linecard_index(struct devlink_linecard *linecard)
+{
+ return linecard->index;
+}
+
static struct devlink_linecard *
devlink_linecard_get_by_index(struct devlink *devlink,
unsigned int linecard_index)
diff --git a/net/devlink/port.c b/net/devlink/port.c
index 4763b42885fb..7b300a322ed9 100644
--- a/net/devlink/port.c
+++ b/net/devlink/port.c
@@ -483,7 +483,7 @@ static int devlink_nl_port_fill(struct sk_buff *msg,
goto nla_put_failure;
if (devlink_port->linecard &&
nla_put_u32(msg, DEVLINK_ATTR_LINECARD_INDEX,
- devlink_port->linecard->index))
+ devlink_linecard_index(devlink_port->linecard)))
goto nla_put_failure;
genlmsg_end(msg, hdr);
@@ -1420,7 +1420,7 @@ static int __devlink_port_phys_port_name_get(struct devlink_port *devlink_port,
case DEVLINK_PORT_FLAVOUR_PHYSICAL:
if (devlink_port->linecard)
n = snprintf(name, len, "l%u",
- devlink_port->linecard->index);
+ devlink_linecard_index(devlink_port->linecard));
if (n < len)
n += snprintf(name + n, len - n, "p%u",
attrs->phys.port_number);
--
2.41.0
next prev parent reply other threads:[~2023-09-13 7:12 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-13 7:12 [patch net-next v2 00/12] expose devlink instances relationships Jiri Pirko
2023-09-13 7:12 ` Jiri Pirko [this message]
2023-09-13 7:12 ` [patch net-next v2 02/12] net/mlx5: Disable eswitch as the first thing in mlx5_unload() Jiri Pirko
2023-09-13 7:12 ` [patch net-next v2 03/12] net/mlx5: Lift reload limitation when SFs are present Jiri Pirko
2023-09-13 7:12 ` [patch net-next v2 04/12] devlink: put netnsid to nested handle Jiri Pirko
2023-09-13 7:12 ` [patch net-next v2 05/12] devlink: move devlink_nl_put_nested_handle() into netlink.c Jiri Pirko
2023-09-13 7:12 ` [patch net-next v2 06/12] devlink: extend devlink_nl_put_nested_handle() with attrtype arg Jiri Pirko
2023-09-13 7:12 ` [patch net-next v2 07/12] devlink: introduce object and nested devlink relationship infra Jiri Pirko
2023-09-13 7:12 ` [patch net-next v2 08/12] devlink: expose peer SF devlink instance Jiri Pirko
2023-09-13 7:12 ` [patch net-next v2 09/12] net/mlx5: SF, Implement peer devlink set for SF representor devlink port Jiri Pirko
2023-09-13 7:12 ` [patch net-next v2 10/12] devlink: convert linecard nested devlink to new rel infrastructure Jiri Pirko
2023-09-13 7:12 ` [patch net-next v2 11/12] devlink: introduce possibility to expose info about nested devlinks Jiri Pirko
2023-09-13 7:12 ` [patch net-next v2 12/12] net/mlx5e: Set en auxiliary devlink instance as nested Jiri Pirko
2023-09-14 13:57 ` [patch net-next v2 00/12] expose devlink instances relationships Simon Horman
2023-09-17 13:30 ` patchwork-bot+netdevbpf
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=20230913071243.930265-2-jiri@resnulli.us \
--to=jiri@resnulli.us \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=jacob.e.keller@intel.com \
--cc=kuba@kernel.org \
--cc=moshe@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=petrm@nvidia.com \
--cc=saeedm@nvidia.com \
--cc=shayd@nvidia.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).