summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJakub Kicinski <kuba@kernel.org>2022-05-04 08:40:37 -0700
committerJakub Kicinski <kuba@kernel.org>2022-05-05 15:47:23 -0700
commitc4a67a21a6d255ddcbaa076c0412aad73c7e0c02 (patch)
tree84afb52dffbb084537ad79f9a497a2fda29e6d67 /drivers
parentc8227d568ddf2f38a8806fdcd2e20b9e11747d9a (diff)
downloadlinux-c4a67a21a6d255ddcbaa076c0412aad73c7e0c02.tar.bz2
Revert "Merge branch 'mlxsw-line-card-model'"
This reverts commit 5e927a9f4b9f29d78a7c7d66ea717bb5c8bbad8e, reversing changes made to cfc1d91a7d78cf9de25b043d81efcc16966d55b3. The discussion is still ongoing so let's remove the uAPI until the discussion settles. Link: https://lore.kernel.org/all/20220425090021.32e9a98f@kernel.org/ Reviewed-by: Ido Schimmel <idosch@nvidia.com> Link: https://lore.kernel.org/r/20220504154037.539442-1-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/core.h1
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/core_linecards.c237
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/reg.h87
3 files changed, 4 insertions, 321 deletions
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.h b/drivers/net/ethernet/mellanox/mlxsw/core.h
index d008282d7f2e..c2a891287047 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/core.h
@@ -581,7 +581,6 @@ struct mlxsw_linecard {
active:1;
u16 hw_revision;
u16 ini_version;
- struct list_head device_list;
};
struct mlxsw_linecard_types_info;
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c b/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c
index 2abd31a62776..5c9869dcf674 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c
@@ -87,191 +87,11 @@ static const char *mlxsw_linecard_type_name(struct mlxsw_linecard *linecard)
return linecard->name;
}
-struct mlxsw_linecard_device_info {
- u16 fw_major;
- u16 fw_minor;
- u16 fw_sub_minor;
-};
-
-struct mlxsw_linecard_device {
- struct list_head list;
- u8 index;
- struct mlxsw_linecard *linecard;
- struct devlink_linecard_device *devlink_device;
- struct mlxsw_linecard_device_info info;
-};
-
-static struct mlxsw_linecard_device *
-mlxsw_linecard_device_lookup(struct mlxsw_linecard *linecard, u8 index)
-{
- struct mlxsw_linecard_device *device;
-
- list_for_each_entry(device, &linecard->device_list, list)
- if (device->index == index)
- return device;
- return NULL;
-}
-
-static int mlxsw_linecard_device_attach(struct mlxsw_core *mlxsw_core,
- struct mlxsw_linecard *linecard,
- u8 device_index, bool flash_owner)
-{
- struct mlxsw_linecard_device *device;
- int err;
-
- device = kzalloc(sizeof(*device), GFP_KERNEL);
- if (!device)
- return -ENOMEM;
- device->index = device_index;
- device->linecard = linecard;
-
- device->devlink_device = devlink_linecard_device_create(linecard->devlink_linecard,
- device_index, device);
- if (IS_ERR(device->devlink_device)) {
- err = PTR_ERR(device->devlink_device);
- goto err_devlink_linecard_device_attach;
- }
-
- list_add_tail(&device->list, &linecard->device_list);
- return 0;
-
-err_devlink_linecard_device_attach:
- kfree(device);
- return err;
-}
-
-static void mlxsw_linecard_device_detach(struct mlxsw_core *mlxsw_core,
- struct mlxsw_linecard *linecard,
- struct mlxsw_linecard_device *device)
-{
- list_del(&device->list);
- devlink_linecard_device_destroy(linecard->devlink_linecard,
- device->devlink_device);
- kfree(device);
-}
-
-static void mlxsw_linecard_devices_detach(struct mlxsw_linecard *linecard)
-{
- struct mlxsw_core *mlxsw_core = linecard->linecards->mlxsw_core;
- struct mlxsw_linecard_device *device, *tmp;
-
- list_for_each_entry_safe(device, tmp, &linecard->device_list, list)
- mlxsw_linecard_device_detach(mlxsw_core, linecard, device);
-}
-
-static int mlxsw_linecard_devices_attach(struct mlxsw_linecard *linecard)
-{
- struct mlxsw_core *mlxsw_core = linecard->linecards->mlxsw_core;
- u8 msg_seq = 0;
- int err;
-
- do {
- char mddq_pl[MLXSW_REG_MDDQ_LEN];
- bool flash_owner;
- bool data_valid;
- u8 device_index;
-
- mlxsw_reg_mddq_device_info_pack(mddq_pl, linecard->slot_index,
- msg_seq);
- err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mddq), mddq_pl);
- if (err)
- return err;
- mlxsw_reg_mddq_device_info_unpack(mddq_pl, &msg_seq,
- &data_valid, &flash_owner,
- &device_index, NULL,
- NULL, NULL);
- if (!data_valid)
- break;
- err = mlxsw_linecard_device_attach(mlxsw_core, linecard,
- device_index, flash_owner);
- if (err)
- goto rollback;
- } while (msg_seq);
-
- return 0;
-
-rollback:
- mlxsw_linecard_devices_detach(linecard);
- return err;
-}
-
-static void mlxsw_linecard_device_update(struct mlxsw_linecard *linecard,
- u8 device_index,
- struct mlxsw_linecard_device_info *info)
-{
- struct mlxsw_linecard_device *device;
-
- device = mlxsw_linecard_device_lookup(linecard, device_index);
- if (!device)
- return;
- device->info = *info;
-}
-
-static int mlxsw_linecard_devices_update(struct mlxsw_linecard *linecard)
-{
- struct mlxsw_core *mlxsw_core = linecard->linecards->mlxsw_core;
- u8 msg_seq = 0;
-
- do {
- struct mlxsw_linecard_device_info info;
- char mddq_pl[MLXSW_REG_MDDQ_LEN];
- bool data_valid;
- u8 device_index;
- int err;
-
- mlxsw_reg_mddq_device_info_pack(mddq_pl, linecard->slot_index,
- msg_seq);
- err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mddq), mddq_pl);
- if (err)
- return err;
- mlxsw_reg_mddq_device_info_unpack(mddq_pl, &msg_seq,
- &data_valid, NULL,
- &device_index,
- &info.fw_major,
- &info.fw_minor,
- &info.fw_sub_minor);
- if (!data_valid)
- break;
- mlxsw_linecard_device_update(linecard, device_index, &info);
- } while (msg_seq);
-
- return 0;
-}
-
-static int
-mlxsw_linecard_device_info_get(struct devlink_linecard_device *devlink_linecard_device,
- void *priv, struct devlink_info_req *req,
- struct netlink_ext_ack *extack)
-{
- struct mlxsw_linecard_device *device = priv;
- struct mlxsw_linecard_device_info *info;
- struct mlxsw_linecard *linecard;
- char buf[32];
-
- linecard = device->linecard;
- mutex_lock(&linecard->lock);
- if (!linecard->active) {
- mutex_unlock(&linecard->lock);
- return 0;
- }
-
- info = &device->info;
-
- sprintf(buf, "%u.%u.%u", info->fw_major, info->fw_minor,
- info->fw_sub_minor);
- mutex_unlock(&linecard->lock);
-
- return devlink_info_version_running_put(req,
- DEVLINK_INFO_VERSION_GENERIC_FW,
- buf);
-}
-
static void mlxsw_linecard_provision_fail(struct mlxsw_linecard *linecard)
{
linecard->provisioned = false;
linecard->ready = false;
linecard->active = false;
- mlxsw_linecard_devices_detach(linecard);
devlink_linecard_provision_fail(linecard->devlink_linecard);
}
@@ -412,7 +232,6 @@ mlxsw_linecard_provision_set(struct mlxsw_linecard *linecard, u8 card_type,
{
struct mlxsw_linecards *linecards = linecard->linecards;
const char *type;
- int err;
type = mlxsw_linecard_types_lookup(linecards, card_type);
mlxsw_linecard_status_event_done(linecard,
@@ -430,11 +249,6 @@ mlxsw_linecard_provision_set(struct mlxsw_linecard *linecard, u8 card_type,
return PTR_ERR(type);
}
}
- err = mlxsw_linecard_devices_attach(linecard);
- if (err) {
- mlxsw_linecard_provision_fail(linecard);
- return err;
- }
linecard->provisioned = true;
linecard->hw_revision = hw_revision;
linecard->ini_version = ini_version;
@@ -447,7 +261,6 @@ static void mlxsw_linecard_provision_clear(struct mlxsw_linecard *linecard)
mlxsw_linecard_status_event_done(linecard,
MLXSW_LINECARD_STATUS_EVENT_TYPE_UNPROVISION);
linecard->provisioned = false;
- mlxsw_linecard_devices_detach(linecard);
devlink_linecard_provision_clear(linecard->devlink_linecard);
}
@@ -479,18 +292,11 @@ static int mlxsw_linecard_ready_clear(struct mlxsw_linecard *linecard)
return 0;
}
-static int mlxsw_linecard_active_set(struct mlxsw_linecard *linecard)
+static void mlxsw_linecard_active_set(struct mlxsw_linecard *linecard)
{
- int err;
-
- err = mlxsw_linecard_devices_update(linecard);
- if (err)
- return err;
-
mlxsw_linecard_active_ops_call(linecard);
linecard->active = true;
devlink_linecard_activate(linecard->devlink_linecard);
- return 0;
}
static void mlxsw_linecard_active_clear(struct mlxsw_linecard *linecard)
@@ -539,11 +345,8 @@ static int mlxsw_linecard_status_process(struct mlxsw_linecards *linecards,
goto out;
}
- if (active && linecard->active != active) {
- err = mlxsw_linecard_active_set(linecard);
- if (err)
- goto out;
- }
+ if (active && linecard->active != active)
+ mlxsw_linecard_active_set(linecard);
if (!active && linecard->active != active)
mlxsw_linecard_active_clear(linecard);
@@ -934,44 +737,12 @@ static void mlxsw_linecard_types_get(struct devlink_linecard *devlink_linecard,
*type_priv = ini_file;
}
-static int
-mlxsw_linecard_info_get(struct devlink_linecard *devlink_linecard, void *priv,
- struct devlink_info_req *req,
- struct netlink_ext_ack *extack)
-{
- struct mlxsw_linecard *linecard = priv;
- char buf[32];
- int err;
-
- mutex_lock(&linecard->lock);
- if (!linecard->provisioned) {
- err = 0;
- goto unlock;
- }
-
- sprintf(buf, "%d", linecard->hw_revision);
- err = devlink_info_version_fixed_put(req, "hw.revision", buf);
- if (err)
- goto unlock;
-
- sprintf(buf, "%d", linecard->ini_version);
- err = devlink_info_version_running_put(req, "ini.version", buf);
- if (err)
- goto unlock;
-
-unlock:
- mutex_unlock(&linecard->lock);
- return err;
-}
-
static const struct devlink_linecard_ops mlxsw_linecard_ops = {
.provision = mlxsw_linecard_provision,
.unprovision = mlxsw_linecard_unprovision,
.same_provision = mlxsw_linecard_same_provision,
.types_count = mlxsw_linecard_types_count,
.types_get = mlxsw_linecard_types_get,
- .info_get = mlxsw_linecard_info_get,
- .device_info_get = mlxsw_linecard_device_info_get,
};
struct mlxsw_linecard_status_event {
@@ -1069,7 +840,6 @@ static int mlxsw_linecard_init(struct mlxsw_core *mlxsw_core,
linecard->slot_index = slot_index;
linecard->linecards = linecards;
mutex_init(&linecard->lock);
- INIT_LIST_HEAD(&linecard->device_list);
devlink_linecard = devlink_linecard_create(priv_to_devlink(mlxsw_core),
slot_index, &mlxsw_linecard_ops,
@@ -1115,7 +885,6 @@ static void mlxsw_linecard_fini(struct mlxsw_core *mlxsw_core,
mlxsw_core_flush_owq();
if (linecard->active)
mlxsw_linecard_active_clear(linecard);
- mlxsw_linecard_devices_detach(linecard);
devlink_linecard_destroy(linecard->devlink_linecard);
mutex_destroy(&linecard->lock);
}
diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h
index 078e3aa04383..93af6c974ece 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h
@@ -11643,11 +11643,7 @@ MLXSW_ITEM32(reg, mddq, sie, 0x00, 31, 1);
enum mlxsw_reg_mddq_query_type {
MLXSW_REG_MDDQ_QUERY_TYPE_SLOT_INFO = 1,
- MLXSW_REG_MDDQ_QUERY_TYPE_DEVICE_INFO, /* If there are no devices
- * on the slot, data_valid
- * will be '0'.
- */
- MLXSW_REG_MDDQ_QUERY_TYPE_SLOT_NAME,
+ MLXSW_REG_MDDQ_QUERY_TYPE_SLOT_NAME = 3,
};
/* reg_mddq_query_type
@@ -11661,28 +11657,6 @@ MLXSW_ITEM32(reg, mddq, query_type, 0x00, 16, 8);
*/
MLXSW_ITEM32(reg, mddq, slot_index, 0x00, 0, 4);
-/* reg_mddq_response_msg_seq
- * Response message sequential number. For a specific request, the response
- * message sequential number is the following one. In addition, the last
- * message should be 0.
- * Access: RO
- */
-MLXSW_ITEM32(reg, mddq, response_msg_seq, 0x04, 16, 8);
-
-/* reg_mddq_request_msg_seq
- * Request message sequential number.
- * The first message number should be 0.
- * Access: Index
- */
-MLXSW_ITEM32(reg, mddq, request_msg_seq, 0x04, 0, 8);
-
-/* reg_mddq_data_valid
- * If set, the data in the data field is valid and contain the information
- * for the queried index.
- * Access: RO
- */
-MLXSW_ITEM32(reg, mddq, data_valid, 0x08, 31, 1);
-
/* reg_mddq_slot_info_provisioned
* If set, the INI file is applied and the card is provisioned.
* Access: RO
@@ -11769,65 +11743,6 @@ mlxsw_reg_mddq_slot_info_unpack(const char *payload, u8 *p_slot_index,
*p_card_type = mlxsw_reg_mddq_slot_info_card_type_get(payload);
}
-/* reg_mddq_device_info_flash_owner
- * If set, the device is the flash owner. Otherwise, a shared flash
- * is used by this device (another device is the flash owner).
- * Access: RO
- */
-MLXSW_ITEM32(reg, mddq, device_info_flash_owner, 0x10, 30, 1);
-
-/* reg_mddq_device_info_device_index
- * Device index. The first device should number 0.
- * Access: RO
- */
-MLXSW_ITEM32(reg, mddq, device_info_device_index, 0x10, 0, 8);
-
-/* reg_mddq_device_info_fw_major
- * Major FW version number.
- * Access: RO
- */
-MLXSW_ITEM32(reg, mddq, device_info_fw_major, 0x14, 16, 16);
-
-/* reg_mddq_device_info_fw_minor
- * Minor FW version number.
- * Access: RO
- */
-MLXSW_ITEM32(reg, mddq, device_info_fw_minor, 0x18, 16, 16);
-
-/* reg_mddq_device_info_fw_sub_minor
- * Sub-minor FW version number.
- * Access: RO
- */
-MLXSW_ITEM32(reg, mddq, device_info_fw_sub_minor, 0x18, 0, 16);
-
-static inline void
-mlxsw_reg_mddq_device_info_pack(char *payload, u8 slot_index,
- u8 request_msg_seq)
-{
- __mlxsw_reg_mddq_pack(payload, slot_index,
- MLXSW_REG_MDDQ_QUERY_TYPE_DEVICE_INFO);
- mlxsw_reg_mddq_request_msg_seq_set(payload, request_msg_seq);
-}
-
-static inline void
-mlxsw_reg_mddq_device_info_unpack(const char *payload, u8 *p_response_msg_seq,
- bool *p_data_valid, bool *p_flash_owner,
- u8 *p_device_index, u16 *p_fw_major,
- u16 *p_fw_minor, u16 *p_fw_sub_minor)
-{
- *p_response_msg_seq = mlxsw_reg_mddq_response_msg_seq_get(payload);
- *p_data_valid = mlxsw_reg_mddq_data_valid_get(payload);
- if (p_flash_owner)
- *p_flash_owner = mlxsw_reg_mddq_device_info_flash_owner_get(payload);
- *p_device_index = mlxsw_reg_mddq_device_info_device_index_get(payload);
- if (p_fw_major)
- *p_fw_major = mlxsw_reg_mddq_device_info_fw_major_get(payload);
- if (p_fw_minor)
- *p_fw_minor = mlxsw_reg_mddq_device_info_fw_minor_get(payload);
- if (p_fw_sub_minor)
- *p_fw_sub_minor = mlxsw_reg_mddq_device_info_fw_sub_minor_get(payload);
-}
-
#define MLXSW_REG_MDDQ_SLOT_ASCII_NAME_LEN 20
/* reg_mddq_slot_ascii_name