Commit b217127e authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller

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: default avatarJiri Pirko <jiri@nvidia.com>
Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5bade5aa
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
obj-$(CONFIG_MLXSW_CORE) += mlxsw_core.o obj-$(CONFIG_MLXSW_CORE) += mlxsw_core.o
mlxsw_core-objs := core.o core_acl_flex_keys.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_HWMON) += core_hwmon.o
mlxsw_core-$(CONFIG_MLXSW_CORE_THERMAL) += core_thermal.o mlxsw_core-$(CONFIG_MLXSW_CORE_THERMAL) += core_thermal.o
obj-$(CONFIG_MLXSW_PCI) += mlxsw_pci.o obj-$(CONFIG_MLXSW_PCI) += mlxsw_pci.o
......
...@@ -82,6 +82,7 @@ struct mlxsw_core { ...@@ -82,6 +82,7 @@ struct mlxsw_core {
struct mlxsw_res res; struct mlxsw_res res;
struct mlxsw_hwmon *hwmon; struct mlxsw_hwmon *hwmon;
struct mlxsw_thermal *thermal; struct mlxsw_thermal *thermal;
struct mlxsw_linecards *linecards;
struct mlxsw_core_port *ports; struct mlxsw_core_port *ports;
unsigned int max_ports; unsigned int max_ports;
atomic_t active_ports_count; atomic_t active_ports_count;
...@@ -94,6 +95,17 @@ struct mlxsw_core { ...@@ -94,6 +95,17 @@ struct mlxsw_core {
/* driver_priv has to be always the last item */ /* driver_priv has to be always the last item */
}; };
struct mlxsw_linecards *mlxsw_core_linecards(struct mlxsw_core *mlxsw_core)
{
return mlxsw_core->linecards;
}
void mlxsw_core_linecards_set(struct mlxsw_core *mlxsw_core,
struct mlxsw_linecards *linecards)
{
mlxsw_core->linecards = linecards;
}
#define MLXSW_PORT_MAX_PORTS_DEFAULT 0x40 #define MLXSW_PORT_MAX_PORTS_DEFAULT 0x40
static u64 mlxsw_ports_occ_get(void *priv) static u64 mlxsw_ports_occ_get(void *priv)
...@@ -2145,6 +2157,10 @@ __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info, ...@@ -2145,6 +2157,10 @@ __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info,
if (err) if (err)
goto err_fw_rev_validate; goto err_fw_rev_validate;
err = mlxsw_linecards_init(mlxsw_core, mlxsw_bus_info);
if (err)
goto err_linecards_init;
err = mlxsw_core_health_init(mlxsw_core); err = mlxsw_core_health_init(mlxsw_core);
if (err) if (err)
goto err_health_init; goto err_health_init;
...@@ -2183,6 +2199,8 @@ __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info, ...@@ -2183,6 +2199,8 @@ __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info,
err_hwmon_init: err_hwmon_init:
mlxsw_core_health_fini(mlxsw_core); mlxsw_core_health_fini(mlxsw_core);
err_health_init: err_health_init:
mlxsw_linecards_fini(mlxsw_core);
err_linecards_init:
err_fw_rev_validate: err_fw_rev_validate:
if (!reload) if (!reload)
mlxsw_core_params_unregister(mlxsw_core); mlxsw_core_params_unregister(mlxsw_core);
...@@ -2255,6 +2273,7 @@ void mlxsw_core_bus_device_unregister(struct mlxsw_core *mlxsw_core, ...@@ -2255,6 +2273,7 @@ void mlxsw_core_bus_device_unregister(struct mlxsw_core *mlxsw_core,
mlxsw_thermal_fini(mlxsw_core->thermal); mlxsw_thermal_fini(mlxsw_core->thermal);
mlxsw_hwmon_fini(mlxsw_core->hwmon); mlxsw_hwmon_fini(mlxsw_core->hwmon);
mlxsw_core_health_fini(mlxsw_core); mlxsw_core_health_fini(mlxsw_core);
mlxsw_linecards_fini(mlxsw_core);
if (!reload) if (!reload)
mlxsw_core_params_unregister(mlxsw_core); mlxsw_core_params_unregister(mlxsw_core);
mlxsw_emad_fini(mlxsw_core); mlxsw_emad_fini(mlxsw_core);
......
...@@ -35,6 +35,11 @@ unsigned int mlxsw_core_max_ports(const struct mlxsw_core *mlxsw_core); ...@@ -35,6 +35,11 @@ unsigned int mlxsw_core_max_ports(const struct mlxsw_core *mlxsw_core);
void *mlxsw_core_driver_priv(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);
void mlxsw_core_linecards_set(struct mlxsw_core *mlxsw_core,
struct mlxsw_linecards *linecard);
bool bool
mlxsw_core_fw_rev_minor_subminor_validate(const struct mlxsw_fw_rev *rev, mlxsw_core_fw_rev_minor_subminor_validate(const struct mlxsw_fw_rev *rev,
const struct mlxsw_fw_rev *req_rev); const struct mlxsw_fw_rev *req_rev);
...@@ -543,4 +548,45 @@ static inline struct mlxsw_skb_cb *mlxsw_skb_cb(struct sk_buff *skb) ...@@ -543,4 +548,45 @@ static inline struct mlxsw_skb_cb *mlxsw_skb_cb(struct sk_buff *skb)
return (struct mlxsw_skb_cb *) skb->cb; return (struct mlxsw_skb_cb *) skb->cb;
} }
struct mlxsw_linecards;
enum mlxsw_linecard_status_event_type {
MLXSW_LINECARD_STATUS_EVENT_TYPE_PROVISION,
MLXSW_LINECARD_STATUS_EVENT_TYPE_UNPROVISION,
};
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 name[MLXSW_REG_MDDQ_SLOT_ASCII_NAME_LEN];
char mbct_pl[MLXSW_REG_MBCT_LEN]; /* Too big for stack */
enum mlxsw_linecard_status_event_type status_event_type_to;
struct delayed_work status_event_to_dw;
u8 provisioned:1;
u16 hw_revision;
u16 ini_version;
};
struct mlxsw_linecard_types_info;
struct mlxsw_linecards {
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[];
};
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);
void mlxsw_linecards_fini(struct mlxsw_core *mlxsw_core);
#endif #endif
This diff is collapsed.
...@@ -89,6 +89,11 @@ static const struct mlxsw_fw_rev mlxsw_sp3_fw_rev = { ...@@ -89,6 +89,11 @@ static const struct mlxsw_fw_rev mlxsw_sp3_fw_rev = {
"." __stringify(MLXSW_SP_FWREV_MINOR) \ "." __stringify(MLXSW_SP_FWREV_MINOR) \
"." __stringify(MLXSW_SP_FWREV_SUBMINOR) ".mfa2" "." __stringify(MLXSW_SP_FWREV_SUBMINOR) ".mfa2"
#define MLXSW_SP_LINECARDS_INI_BUNDLE_FILENAME \
"mellanox/lc_ini_bundle_" \
__stringify(MLXSW_SP_FWREV_MINOR) "_" \
__stringify(MLXSW_SP_FWREV_SUBMINOR) ".bin"
static const char mlxsw_sp1_driver_name[] = "mlxsw_spectrum"; static const char mlxsw_sp1_driver_name[] = "mlxsw_spectrum";
static const char mlxsw_sp2_driver_name[] = "mlxsw_spectrum2"; static const char mlxsw_sp2_driver_name[] = "mlxsw_spectrum2";
static const char mlxsw_sp3_driver_name[] = "mlxsw_spectrum3"; static const char mlxsw_sp3_driver_name[] = "mlxsw_spectrum3";
...@@ -5159,3 +5164,4 @@ MODULE_DEVICE_TABLE(pci, mlxsw_sp4_pci_id_table); ...@@ -5159,3 +5164,4 @@ MODULE_DEVICE_TABLE(pci, mlxsw_sp4_pci_id_table);
MODULE_FIRMWARE(MLXSW_SP1_FW_FILENAME); MODULE_FIRMWARE(MLXSW_SP1_FW_FILENAME);
MODULE_FIRMWARE(MLXSW_SP2_FW_FILENAME); MODULE_FIRMWARE(MLXSW_SP2_FW_FILENAME);
MODULE_FIRMWARE(MLXSW_SP3_FW_FILENAME); MODULE_FIRMWARE(MLXSW_SP3_FW_FILENAME);
MODULE_FIRMWARE(MLXSW_SP_LINECARDS_INI_BUNDLE_FILENAME);
...@@ -133,6 +133,10 @@ enum mlxsw_event_trap_id { ...@@ -133,6 +133,10 @@ enum mlxsw_event_trap_id {
MLXSW_TRAP_ID_PTP_ING_FIFO = 0x2D, MLXSW_TRAP_ID_PTP_ING_FIFO = 0x2D,
/* PTP Egress FIFO has a new entry */ /* PTP Egress FIFO has a new entry */
MLXSW_TRAP_ID_PTP_EGR_FIFO = 0x2E, MLXSW_TRAP_ID_PTP_EGR_FIFO = 0x2E,
/* Downstream Device Status Change */
MLXSW_TRAP_ID_DSDSC = 0x321,
/* Binary Code Transfer Operation Executed Event */
MLXSW_TRAP_ID_BCTOE = 0x322,
/* Port mapping change */ /* Port mapping change */
MLXSW_TRAP_ID_PMLPE = 0x32E, MLXSW_TRAP_ID_PMLPE = 0x32E,
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment