Skip to content

Commit b217127

Browse files
Jiri Pirkodavem330
Jiri Pirko
authored andcommitted
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 <[email protected]> Signed-off-by: Ido Schimmel <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 5bade5a commit b217127

File tree

6 files changed

+1006
-1
lines changed

6 files changed

+1006
-1
lines changed

drivers/net/ethernet/mellanox/mlxsw/Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# SPDX-License-Identifier: GPL-2.0
22
obj-$(CONFIG_MLXSW_CORE) += mlxsw_core.o
33
mlxsw_core-objs := core.o core_acl_flex_keys.o \
4-
core_acl_flex_actions.o core_env.o
4+
core_acl_flex_actions.o core_env.o \
5+
core_linecards.o
56
mlxsw_core-$(CONFIG_MLXSW_CORE_HWMON) += core_hwmon.o
67
mlxsw_core-$(CONFIG_MLXSW_CORE_THERMAL) += core_thermal.o
78
obj-$(CONFIG_MLXSW_PCI) += mlxsw_pci.o

drivers/net/ethernet/mellanox/mlxsw/core.c

+19
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ struct mlxsw_core {
8282
struct mlxsw_res res;
8383
struct mlxsw_hwmon *hwmon;
8484
struct mlxsw_thermal *thermal;
85+
struct mlxsw_linecards *linecards;
8586
struct mlxsw_core_port *ports;
8687
unsigned int max_ports;
8788
atomic_t active_ports_count;
@@ -94,6 +95,17 @@ struct mlxsw_core {
9495
/* driver_priv has to be always the last item */
9596
};
9697

98+
struct mlxsw_linecards *mlxsw_core_linecards(struct mlxsw_core *mlxsw_core)
99+
{
100+
return mlxsw_core->linecards;
101+
}
102+
103+
void mlxsw_core_linecards_set(struct mlxsw_core *mlxsw_core,
104+
struct mlxsw_linecards *linecards)
105+
{
106+
mlxsw_core->linecards = linecards;
107+
}
108+
97109
#define MLXSW_PORT_MAX_PORTS_DEFAULT 0x40
98110

99111
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,
21452157
if (err)
21462158
goto err_fw_rev_validate;
21472159

2160+
err = mlxsw_linecards_init(mlxsw_core, mlxsw_bus_info);
2161+
if (err)
2162+
goto err_linecards_init;
2163+
21482164
err = mlxsw_core_health_init(mlxsw_core);
21492165
if (err)
21502166
goto err_health_init;
@@ -2183,6 +2199,8 @@ __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info,
21832199
err_hwmon_init:
21842200
mlxsw_core_health_fini(mlxsw_core);
21852201
err_health_init:
2202+
mlxsw_linecards_fini(mlxsw_core);
2203+
err_linecards_init:
21862204
err_fw_rev_validate:
21872205
if (!reload)
21882206
mlxsw_core_params_unregister(mlxsw_core);
@@ -2255,6 +2273,7 @@ void mlxsw_core_bus_device_unregister(struct mlxsw_core *mlxsw_core,
22552273
mlxsw_thermal_fini(mlxsw_core->thermal);
22562274
mlxsw_hwmon_fini(mlxsw_core->hwmon);
22572275
mlxsw_core_health_fini(mlxsw_core);
2276+
mlxsw_linecards_fini(mlxsw_core);
22582277
if (!reload)
22592278
mlxsw_core_params_unregister(mlxsw_core);
22602279
mlxsw_emad_fini(mlxsw_core);

drivers/net/ethernet/mellanox/mlxsw/core.h

+46
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ unsigned int mlxsw_core_max_ports(const struct mlxsw_core *mlxsw_core);
3535

3636
void *mlxsw_core_driver_priv(struct mlxsw_core *mlxsw_core);
3737

38+
struct mlxsw_linecards *mlxsw_core_linecards(struct mlxsw_core *mlxsw_core);
39+
40+
void mlxsw_core_linecards_set(struct mlxsw_core *mlxsw_core,
41+
struct mlxsw_linecards *linecard);
42+
3843
bool
3944
mlxsw_core_fw_rev_minor_subminor_validate(const struct mlxsw_fw_rev *rev,
4045
const struct mlxsw_fw_rev *req_rev);
@@ -543,4 +548,45 @@ static inline struct mlxsw_skb_cb *mlxsw_skb_cb(struct sk_buff *skb)
543548
return (struct mlxsw_skb_cb *) skb->cb;
544549
}
545550

551+
struct mlxsw_linecards;
552+
553+
enum mlxsw_linecard_status_event_type {
554+
MLXSW_LINECARD_STATUS_EVENT_TYPE_PROVISION,
555+
MLXSW_LINECARD_STATUS_EVENT_TYPE_UNPROVISION,
556+
};
557+
558+
struct mlxsw_linecard {
559+
u8 slot_index;
560+
struct mlxsw_linecards *linecards;
561+
struct devlink_linecard *devlink_linecard;
562+
struct mutex lock; /* Locks accesses to the linecard structure */
563+
char name[MLXSW_REG_MDDQ_SLOT_ASCII_NAME_LEN];
564+
char mbct_pl[MLXSW_REG_MBCT_LEN]; /* Too big for stack */
565+
enum mlxsw_linecard_status_event_type status_event_type_to;
566+
struct delayed_work status_event_to_dw;
567+
u8 provisioned:1;
568+
u16 hw_revision;
569+
u16 ini_version;
570+
};
571+
572+
struct mlxsw_linecard_types_info;
573+
574+
struct mlxsw_linecards {
575+
struct mlxsw_core *mlxsw_core;
576+
const struct mlxsw_bus_info *bus_info;
577+
u8 count;
578+
struct mlxsw_linecard_types_info *types_info;
579+
struct mlxsw_linecard linecards[];
580+
};
581+
582+
static inline struct mlxsw_linecard *
583+
mlxsw_linecard_get(struct mlxsw_linecards *linecards, u8 slot_index)
584+
{
585+
return &linecards->linecards[slot_index - 1];
586+
}
587+
588+
int mlxsw_linecards_init(struct mlxsw_core *mlxsw_core,
589+
const struct mlxsw_bus_info *bus_info);
590+
void mlxsw_linecards_fini(struct mlxsw_core *mlxsw_core);
591+
546592
#endif

0 commit comments

Comments
 (0)