Skip to content
Permalink
Browse files
mlxsw: core_linecards: Add line card objects and implement provisioning
Introduce objects for line cards and an infrastructure around that.
Use devlink_linecard_create/destroy() to register the line card with
devlink core. Implement provisioning ops with a list of supported
line cards.

Signed-off-by: Jiri Pirko <jiri@nvidia.com>
  • Loading branch information
Jiri Pirko committed Dec 13, 2021
1 parent 97aae0b commit 8693f5ee04deacc07510585fee350a2e30f7d4fc
Show file tree
Hide file tree
Showing 6 changed files with 916 additions and 1 deletion.
@@ -1,7 +1,8 @@
# SPDX-License-Identifier: GPL-2.0
obj-$(CONFIG_MLXSW_CORE) += mlxsw_core.o
mlxsw_core-objs := core.o core_acl_flex_keys.o \
core_acl_flex_actions.o core_env.o
core_acl_flex_actions.o core_env.o \
core_linecards.o
mlxsw_core-$(CONFIG_MLXSW_CORE_HWMON) += core_hwmon.o
mlxsw_core-$(CONFIG_MLXSW_CORE_THERMAL) += core_thermal.o
obj-$(CONFIG_MLXSW_PCI) += mlxsw_pci.o
@@ -82,6 +82,7 @@ struct mlxsw_core {
struct mlxsw_res res;
struct mlxsw_hwmon *hwmon;
struct mlxsw_thermal *thermal;
struct mlxsw_linecards *linecards;
struct mlxsw_core_port *ports;
unsigned int max_ports;
atomic_t active_ports_count;
@@ -94,6 +95,11 @@ struct mlxsw_core {
/* driver_priv has to be always the last item */
};

struct mlxsw_linecards *mlxsw_core_linecards(struct mlxsw_core *mlxsw_core)
{
return mlxsw_core->linecards;
}

#define MLXSW_PORT_MAX_PORTS_DEFAULT 0x40

static u64 mlxsw_ports_occ_get(void *priv)
@@ -1973,6 +1979,11 @@ __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info,
if (err)
goto err_emad_init;

err = mlxsw_linecards_init(mlxsw_core, mlxsw_bus_info,
&mlxsw_core->linecards);
if (err)
goto err_linecards_init;

if (!reload) {
err = mlxsw_core_params_register(mlxsw_core);
if (err)
@@ -2007,12 +2018,19 @@ __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info,
goto err_driver_init;
}

err = mlxsw_linecards_post_init(mlxsw_core, mlxsw_core->linecards);
if (err)
goto err_linecards_post_init;

if (!reload) {
devlink_set_features(devlink, DEVLINK_F_RELOAD);
devlink_register(devlink);
}
return 0;

err_linecards_post_init:
if (mlxsw_core->driver->fini)
mlxsw_core->driver->fini(mlxsw_core);
err_driver_init:
mlxsw_env_fini(mlxsw_core->env);
err_env_init:
@@ -2026,6 +2044,8 @@ __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info,
if (!reload)
mlxsw_core_params_unregister(mlxsw_core);
err_register_params:
mlxsw_linecards_fini(mlxsw_core, mlxsw_core->linecards);
err_linecards_init:
mlxsw_emad_fini(mlxsw_core);
err_emad_init:
kfree(mlxsw_core->lag.mapping);
@@ -2087,6 +2107,7 @@ void mlxsw_core_bus_device_unregister(struct mlxsw_core *mlxsw_core,
return;
}

mlxsw_linecards_pre_fini(mlxsw_core, mlxsw_core->linecards);
if (mlxsw_core->driver->fini)
mlxsw_core->driver->fini(mlxsw_core);
mlxsw_env_fini(mlxsw_core->env);
@@ -2095,6 +2116,7 @@ void mlxsw_core_bus_device_unregister(struct mlxsw_core *mlxsw_core,
mlxsw_core_health_fini(mlxsw_core);
if (!reload)
mlxsw_core_params_unregister(mlxsw_core);
mlxsw_linecards_fini(mlxsw_core, mlxsw_core->linecards);
mlxsw_emad_fini(mlxsw_core);
kfree(mlxsw_core->lag.mapping);
mlxsw_ports_fini(mlxsw_core, reload);
@@ -35,6 +35,8 @@ unsigned int mlxsw_core_max_ports(const struct mlxsw_core *mlxsw_core);

void *mlxsw_core_driver_priv(struct mlxsw_core *mlxsw_core);

struct mlxsw_linecards *mlxsw_core_linecards(struct mlxsw_core *mlxsw_core);

bool mlxsw_core_res_query_enabled(const struct mlxsw_core *mlxsw_core);

bool mlxsw_core_temp_warn_enabled(const struct mlxsw_core *mlxsw_core);
@@ -542,4 +544,48 @@ static inline struct mlxsw_skb_cb *mlxsw_skb_cb(struct sk_buff *skb)
return (struct mlxsw_skb_cb *) skb->cb;
}

struct mlxsw_linecards;

struct mlxsw_linecard {
u8 slot_index;
struct mlxsw_linecards *linecards;
struct devlink_linecard *devlink_linecard;
struct mutex lock; /* Locks accesses to the linecard structure */
char read_name[MLXSW_REG_MDDQ_SLOT_ACII_NAME_LEN];
char mbct_pl[MLXSW_REG_MBCT_LEN]; /* too big for stack */
bool provisioned;
};

struct mlxsw_linecard_types_info;

struct mlxsw_linecards {
struct list_head event_ops_list;
struct workqueue_struct *wq;
struct mlxsw_core *mlxsw_core;
const struct mlxsw_bus_info *bus_info;
u8 count;
struct mlxsw_linecard_types_info *types_info;
struct mlxsw_linecard linecards[0];
};

static inline struct mlxsw_linecard *
mlxsw_linecard_get(struct mlxsw_linecards *linecards, u8 slot_index)
{
return &linecards->linecards[slot_index - 1];
}

int mlxsw_linecards_init(struct mlxsw_core *mlxsw_core,
const struct mlxsw_bus_info *bus_info,
struct mlxsw_linecards **p_linecards);
int mlxsw_linecards_post_init(struct mlxsw_core *mlxsw_core,
struct mlxsw_linecards *linecards);
void mlxsw_linecards_pre_fini(struct mlxsw_core *mlxsw_core,
struct mlxsw_linecards *linecards);
void mlxsw_linecards_fini(struct mlxsw_core *mlxsw_core,
struct mlxsw_linecards *linecards);
int mlxsw_linecard_status_process(struct mlxsw_core *mlxsw_core,
const char *mddq_pl);
int mlxsw_linecard_bct_process(struct mlxsw_core *mlxsw_core,
const char *mbct_pl);

#endif

0 comments on commit 8693f5e

Please sign in to comment.