]> git.karo-electronics.de Git - linux-beck.git/commitdiff
mlxsw: core: Add port type (Eth/IB) set API
authorElad Raz <eladr@mellanox.com>
Fri, 28 Oct 2016 19:35:58 +0000 (21:35 +0200)
committerDavid S. Miller <davem@davemloft.net>
Sun, 30 Oct 2016 20:50:17 +0000 (16:50 -0400)
Add "port_type_set" API to mlxsw core. The core layer send the change type
callback to the port along with it's private information.

Signed-off-by: Elad Raz <eladr@mellanox.com>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/core.c
drivers/net/ethernet/mellanox/mlxsw/core.h

index dcd7202dd47eb0760afe04b4de6eba31e3110a69..600481771c047458471192547911e03f3653f86e 100644 (file)
@@ -93,6 +93,7 @@ struct mlxsw_core_pcpu_stats {
 struct mlxsw_core_port {
        struct devlink_port devlink_port;
        void *port_driver_priv;
+       u8 local_port;
 };
 
 void *mlxsw_core_port_driver_priv(struct mlxsw_core_port *mlxsw_core_port)
@@ -937,6 +938,21 @@ static void *__dl_port(struct devlink_port *devlink_port)
        return container_of(devlink_port, struct mlxsw_core_port, devlink_port);
 }
 
+static int mlxsw_devlink_port_type_set(struct devlink_port *devlink_port,
+                                      enum devlink_port_type port_type)
+{
+       struct mlxsw_core *mlxsw_core = devlink_priv(devlink_port->devlink);
+       struct mlxsw_driver *mlxsw_driver = mlxsw_core->driver;
+       struct mlxsw_core_port *mlxsw_core_port = __dl_port(devlink_port);
+
+       if (!mlxsw_driver->port_type_set)
+               return -EOPNOTSUPP;
+
+       return mlxsw_driver->port_type_set(mlxsw_core,
+                                          mlxsw_core_port->local_port,
+                                          port_type);
+}
+
 static int mlxsw_devlink_sb_port_pool_get(struct devlink_port *devlink_port,
                                          unsigned int sb_index, u16 pool_index,
                                          u32 *p_threshold)
@@ -1060,6 +1076,7 @@ mlxsw_devlink_sb_occ_tc_port_bind_get(struct devlink_port *devlink_port,
 }
 
 static const struct devlink_ops mlxsw_devlink_ops = {
+       .port_type_set                  = mlxsw_devlink_port_type_set,
        .port_split                     = mlxsw_devlink_port_split,
        .port_unsplit                   = mlxsw_devlink_port_unsplit,
        .sb_pool_get                    = mlxsw_devlink_sb_pool_get,
@@ -1687,6 +1704,7 @@ int mlxsw_core_port_init(struct mlxsw_core *mlxsw_core, u8 local_port)
        struct devlink_port *devlink_port = &mlxsw_core_port->devlink_port;
        int err;
 
+       mlxsw_core_port->local_port = local_port;
        err = devlink_port_register(devlink, devlink_port, local_port);
        if (err)
                memset(mlxsw_core_port, 0, sizeof(*mlxsw_core_port));
@@ -1720,6 +1738,18 @@ void mlxsw_core_port_eth_set(struct mlxsw_core *mlxsw_core, u8 local_port,
 }
 EXPORT_SYMBOL(mlxsw_core_port_eth_set);
 
+void mlxsw_core_port_ib_set(struct mlxsw_core *mlxsw_core, u8 local_port,
+                           void *port_driver_priv)
+{
+       struct mlxsw_core_port *mlxsw_core_port =
+                                       &mlxsw_core->ports[local_port];
+       struct devlink_port *devlink_port = &mlxsw_core_port->devlink_port;
+
+       mlxsw_core_port->port_driver_priv = port_driver_priv;
+       devlink_port_type_ib_set(devlink_port, NULL);
+}
+EXPORT_SYMBOL(mlxsw_core_port_ib_set);
+
 void mlxsw_core_port_clear(struct mlxsw_core *mlxsw_core, u8 local_port,
                           void *port_driver_priv)
 {
@@ -1732,6 +1762,17 @@ void mlxsw_core_port_clear(struct mlxsw_core *mlxsw_core, u8 local_port,
 }
 EXPORT_SYMBOL(mlxsw_core_port_clear);
 
+enum devlink_port_type mlxsw_core_port_type_get(struct mlxsw_core *mlxsw_core,
+                                               u8 local_port)
+{
+       struct mlxsw_core_port *mlxsw_core_port =
+                                       &mlxsw_core->ports[local_port];
+       struct devlink_port *devlink_port = &mlxsw_core_port->devlink_port;
+
+       return devlink_port->type;
+}
+EXPORT_SYMBOL(mlxsw_core_port_type_get);
+
 static void mlxsw_core_buf_dump_dbg(struct mlxsw_core *mlxsw_core,
                                    const char *buf, size_t size)
 {
index 82866d5e23c0bd091f12ac8d0e8d1c58c43825a6..c0acc1b9eb2fc5c855bcad9596b9fb6721896cdf 100644 (file)
@@ -148,8 +148,12 @@ void mlxsw_core_port_fini(struct mlxsw_core *mlxsw_core, u8 local_port);
 void mlxsw_core_port_eth_set(struct mlxsw_core *mlxsw_core, u8 local_port,
                             void *port_driver_priv, struct net_device *dev,
                             bool split, u32 split_group);
+void mlxsw_core_port_ib_set(struct mlxsw_core *mlxsw_core, u8 local_port,
+                           void *port_driver_priv);
 void mlxsw_core_port_clear(struct mlxsw_core *mlxsw_core, u8 local_port,
                           void *port_driver_priv);
+enum devlink_port_type mlxsw_core_port_type_get(struct mlxsw_core *mlxsw_core,
+                                               u8 local_port);
 
 int mlxsw_core_schedule_dw(struct delayed_work *dwork, unsigned long delay);
 
@@ -210,6 +214,8 @@ struct mlxsw_driver {
        int (*init)(struct mlxsw_core *mlxsw_core,
                    const struct mlxsw_bus_info *mlxsw_bus_info);
        void (*fini)(struct mlxsw_core *mlxsw_core);
+       int (*port_type_set)(struct mlxsw_core *mlxsw_core, u8 local_port,
+                            enum devlink_port_type new_type);
        int (*port_split)(struct mlxsw_core *mlxsw_core, u8 local_port,
                          unsigned int count);
        int (*port_unsplit)(struct mlxsw_core *mlxsw_core, u8 local_port);