net: sparx5: ops out chip port to device index/bit functions
authorDaniel Machon <daniel.machon@microchip.com>
Fri, 4 Oct 2024 13:19:35 +0000 (15:19 +0200)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 8 Oct 2024 10:07:01 +0000 (12:07 +0200)
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>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/ethernet/microchip/sparx5/sparx5_main.c
drivers/net/ethernet/microchip/sparx5/sparx5_main.h
drivers/net/ethernet/microchip/sparx5/sparx5_port.c
drivers/net/ethernet/microchip/sparx5/sparx5_port.h

index 9da9e534e9c07c157be4b410cb44f5b837ac6d79..10074b02a8d2831f2ba09ba5213e64b3a8cd3324 100644 (file)
@@ -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 = {
index f3716bd2f9a2e223136d74a8ffcfb1df73aa03c1..f7e1b7d18f816c323f6e68d7f1098289ba06049f 100644 (file)
@@ -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 {
index c5dfe0fa847b174f4c76fca2655bc169f299fa98..49ff94db0e6312b0650e31753f4304f56e0c9b6b 100644 (file)
@@ -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,
index 934e2d3dedbbed68f02f749a1407d01df4d9f076..9b9bcc6834bcb8ea205e1d382b93a95edbaf8bf8 100644 (file)
@@ -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);