From: Daniel Machon <daniel.machon@microchip.com>
To: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Lars Povlsen <lars.povlsen@microchip.com>,
"Steen Hegelund" <Steen.Hegelund@microchip.com>,
<horatiu.vultur@microchip.com>,
<jensemil.schulzostergaard@microchip.com>,
<UNGLinuxDriver@microchip.com>,
Richard Cochran <richardcochran@gmail.com>, <horms@kernel.org>,
<justinstitt@google.com>, <gal@nvidia.com>,
<aakash.r.menon@gmail.com>, <jacob.e.keller@intel.com>,
<ast@fiberby.net>
Cc: <netdev@vger.kernel.org>, <linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>
Subject: [PATCH net-next v2 09/15] net: sparx5: ops out chip port to device index/bit functions
Date: Fri, 4 Oct 2024 15:19:35 +0200 [thread overview]
Message-ID: <20241004-b4-sparx5-lan969x-switch-driver-v2-9-d3290f581663@microchip.com> (raw)
In-Reply-To: <20241004-b4-sparx5-lan969x-switch-driver-v2-0-d3290f581663@microchip.com>
The chip port device index and mode bit can be obtained using the port
number. However the mapping of port number to chip device index and
mode bit differs on Sparx5 and lan969x. Therefore ops out the function.
Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: Daniel Machon <daniel.machon@microchip.com>
---
drivers/net/ethernet/microchip/sparx5/sparx5_main.c | 2 ++
drivers/net/ethernet/microchip/sparx5/sparx5_main.h | 2 ++
drivers/net/ethernet/microchip/sparx5/sparx5_port.c | 4 +++-
drivers/net/ethernet/microchip/sparx5/sparx5_port.h | 7 ++++++-
4 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_main.c b/drivers/net/ethernet/microchip/sparx5/sparx5_main.c
index 77abb966b6b5..c30ccca72c78 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_main.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_main.c
@@ -988,6 +988,8 @@ static const struct sparx5_ops sparx5_ops = {
.is_port_5g = &sparx5_port_is_5g,
.is_port_10g = &sparx5_port_is_10g,
.is_port_25g = &sparx5_port_is_25g,
+ .get_port_dev_index = &sparx5_port_dev_mapping,
+ .get_port_dev_bit = &sparx5_port_dev_mapping,
};
static const struct sparx5_match_data sparx5_desc = {
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_main.h b/drivers/net/ethernet/microchip/sparx5/sparx5_main.h
index f3716bd2f9a2..f7e1b7d18f81 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_main.h
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_main.h
@@ -263,6 +263,8 @@ struct sparx5_ops {
bool (*is_port_5g)(int portno);
bool (*is_port_10g)(int portno);
bool (*is_port_25g)(int portno);
+ u32 (*get_port_dev_index)(struct sparx5 *sparx5, int port);
+ u32 (*get_port_dev_bit)(struct sparx5 *sparx5, int port);
};
struct sparx5_main_io_resource {
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_port.c b/drivers/net/ethernet/microchip/sparx5/sparx5_port.c
index c5dfe0fa847b..49ff94db0e63 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_port.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_port.c
@@ -847,8 +847,10 @@ static int sparx5_port_pcs_high_set(struct sparx5 *sparx5,
/* Switch between 1G/2500 and 5G/10G/25G devices */
static void sparx5_dev_switch(struct sparx5 *sparx5, int port, bool hsd)
{
- int bt_indx = BIT(sparx5_port_dev_index(sparx5, port));
const struct sparx5_ops *ops = sparx5->data->ops;
+ int bt_indx;
+
+ bt_indx = BIT(ops->get_port_dev_bit(sparx5, port));
if (ops->is_port_5g(port)) {
spx5_rmw(hsd ? 0 : bt_indx,
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_port.h b/drivers/net/ethernet/microchip/sparx5/sparx5_port.h
index 934e2d3dedbb..9b9bcc6834bc 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_port.h
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_port.h
@@ -62,7 +62,7 @@ static inline u32 sparx5_to_pcs_dev(struct sparx5 *sparx5, int port)
return TARGET_PCS25G_BR;
}
-static inline int sparx5_port_dev_index(struct sparx5 *sparx5, int port)
+static inline u32 sparx5_port_dev_mapping(struct sparx5 *sparx5, int port)
{
if (sparx5_port_is_2g5(port))
return port;
@@ -74,6 +74,11 @@ static inline int sparx5_port_dev_index(struct sparx5 *sparx5, int port)
return (port - 56);
}
+static inline u32 sparx5_port_dev_index(struct sparx5 *sparx5, int port)
+{
+ return sparx5->data->ops->get_port_dev_index(sparx5, port);
+}
+
int sparx5_port_init(struct sparx5 *sparx5,
struct sparx5_port *spx5_port,
struct sparx5_port_config *conf);
--
2.34.1
next prev parent reply other threads:[~2024-10-04 13:20 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-04 13:19 [PATCH net-next v2 00/15] net: sparx5: prepare for lan969x switch driver Daniel Machon
2024-10-04 13:19 ` [PATCH net-next v2 01/15] net: sparx5: add support for private match data Daniel Machon
2024-10-04 13:19 ` [PATCH net-next v2 02/15] net: sparx5: add indirection layer to register macros Daniel Machon
2024-10-04 13:19 ` [PATCH net-next v2 03/15] net: sparx5: modify SPX5_PORTS_ALL macro Daniel Machon
2024-10-04 13:19 ` [PATCH net-next v2 04/15] net: sparx5: add *sparx5 argument to a few functions Daniel Machon
2024-10-04 13:19 ` [PATCH net-next v2 05/15] net: sparx5: add constants to match data Daniel Machon
2024-10-04 13:19 ` [PATCH net-next v2 06/15] net: sparx5: use SPX5_CONST for constants which already have a symbol Daniel Machon
2024-10-04 13:19 ` [PATCH net-next v2 07/15] net: sparx5: use SPX5_CONST for constants which do not " Daniel Machon
2024-10-04 13:19 ` [PATCH net-next v2 08/15] net: sparx5: add ops to match data Daniel Machon
2024-10-04 13:19 ` Daniel Machon [this message]
2024-10-04 13:19 ` [PATCH net-next v2 10/15] net: sparx5: ops out functions for getting certain array values Daniel Machon
2024-10-04 13:19 ` [PATCH net-next v2 11/15] net: sparx5: ops out function for setting the port mux Daniel Machon
2024-10-04 13:19 ` [PATCH net-next v2 12/15] net: sparx5: ops out PTP IRQ handler Daniel Machon
2024-10-04 13:19 ` [PATCH net-next v2 13/15] net: sparx5: ops out function for DSM calendar calculation Daniel Machon
2024-10-04 13:19 ` [PATCH net-next v2 14/15] net: sparx5: add is_sparx5 macro and use it throughout Daniel Machon
2024-10-04 13:19 ` [PATCH net-next v2 15/15] net: sparx5: redefine internal ports and PGID's as offsets Daniel Machon
2024-10-08 10:20 ` [PATCH net-next v2 00/15] net: sparx5: prepare for lan969x switch driver 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=20241004-b4-sparx5-lan969x-switch-driver-v2-9-d3290f581663@microchip.com \
--to=daniel.machon@microchip.com \
--cc=Steen.Hegelund@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=aakash.r.menon@gmail.com \
--cc=ast@fiberby.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gal@nvidia.com \
--cc=horatiu.vultur@microchip.com \
--cc=horms@kernel.org \
--cc=jacob.e.keller@intel.com \
--cc=jensemil.schulzostergaard@microchip.com \
--cc=justinstitt@google.com \
--cc=kuba@kernel.org \
--cc=lars.povlsen@microchip.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.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
all inboxes | Powered by JetHome®