Commit c067598a authored by David S. Miller's avatar David S. Miller

Merge branch 'mlxsw-Support-firmware-flash'

Jiri Pirko says:

====================
mlxsw: Support firmware flash

Add support for device firmware flash on mlxsw spectrum. The firmware files
are expected to be in the Mellanox Firmware Archive version 2 (MFA2)
format.

The firmware flash is triggered on driver initialization time if the device
firmware version does not meet the minimum firmware version supported by
the driver.

Currently, to activate the newly flashed firmware, the user needs to
reboot his system.

The first patch introduces the mlxfw module, which implements common logic
needed for the firmware flash process on Mellanox products, such as the
MFA2 format parsing and the firmware flash state machine logic. As the
module implements common logic which will be needed by various different
Mellanox drivers, it defines a set of callbacks needed to interact with the
specific device.

Patches 1-5 implement the needed mlxfw callbacks in the mlxsw spectrum
driver.

Patches 6 and 7 add boot-time firmware upgrade on the mlxsw spectrum
driver.

Patch 8 adds a fix needed for new firmware versions.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents ff5f58f5 03ea01e9
...@@ -8330,6 +8330,14 @@ W: http://www.mellanox.com ...@@ -8330,6 +8330,14 @@ W: http://www.mellanox.com
Q: http://patchwork.ozlabs.org/project/netdev/list/ Q: http://patchwork.ozlabs.org/project/netdev/list/
F: drivers/net/ethernet/mellanox/mlxsw/ F: drivers/net/ethernet/mellanox/mlxsw/
MELLANOX FIRMWARE FLASH LIBRARY (mlxfw)
M: Yotam Gigi <yotamg@mellanox.com>
L: netdev@vger.kernel.org
S: Supported
W: http://www.mellanox.com
Q: http://patchwork.ozlabs.org/project/netdev/list/
F: drivers/net/ethernet/mellanox/mlxfw/
MELLANOX MLXCPLD I2C AND MUX DRIVER MELLANOX MLXCPLD I2C AND MUX DRIVER
M: Vadim Pasternak <vadimp@mellanox.com> M: Vadim Pasternak <vadimp@mellanox.com>
M: Michael Shych <michaelsh@mellanox.com> M: Michael Shych <michaelsh@mellanox.com>
......
...@@ -19,5 +19,6 @@ if NET_VENDOR_MELLANOX ...@@ -19,5 +19,6 @@ if NET_VENDOR_MELLANOX
source "drivers/net/ethernet/mellanox/mlx4/Kconfig" source "drivers/net/ethernet/mellanox/mlx4/Kconfig"
source "drivers/net/ethernet/mellanox/mlx5/core/Kconfig" source "drivers/net/ethernet/mellanox/mlx5/core/Kconfig"
source "drivers/net/ethernet/mellanox/mlxsw/Kconfig" source "drivers/net/ethernet/mellanox/mlxsw/Kconfig"
source "drivers/net/ethernet/mellanox/mlxfw/Kconfig"
endif # NET_VENDOR_MELLANOX endif # NET_VENDOR_MELLANOX
...@@ -5,3 +5,4 @@ ...@@ -5,3 +5,4 @@
obj-$(CONFIG_MLX4_CORE) += mlx4/ obj-$(CONFIG_MLX4_CORE) += mlx4/
obj-$(CONFIG_MLX5_CORE) += mlx5/core/ obj-$(CONFIG_MLX5_CORE) += mlx5/core/
obj-$(CONFIG_MLXSW_CORE) += mlxsw/ obj-$(CONFIG_MLXSW_CORE) += mlxsw/
obj-$(CONFIG_MLXFW) += mlxfw/
#
# Mellanox firmware flash library configuration
#
config MLXFW
tristate "mlxfw" if COMPILE_TEST
obj-$(CONFIG_MLXFW) += mlxfw.o
mlxfw-objs := mlxfw_fsm.o mlxfw_mfa2_tlv_multi.o mlxfw_mfa2.o
/*
* drivers/net/ethernet/mellanox/mlxfw/mlxfw.h
* Copyright (c) 2017 Mellanox Technologies. All rights reserved.
* Copyright (c) 2017 Yotam Gigi <yotamg@mellanox.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the names of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _MLXFW_H
#define _MLXFW_H
#include <linux/firmware.h>
enum mlxfw_fsm_state {
MLXFW_FSM_STATE_IDLE,
MLXFW_FSM_STATE_LOCKED,
MLXFW_FSM_STATE_INITIALIZE,
MLXFW_FSM_STATE_DOWNLOAD,
MLXFW_FSM_STATE_VERIFY,
MLXFW_FSM_STATE_APPLY,
MLXFW_FSM_STATE_ACTIVATE,
};
enum mlxfw_fsm_state_err {
MLXFW_FSM_STATE_ERR_OK,
MLXFW_FSM_STATE_ERR_ERROR,
MLXFW_FSM_STATE_ERR_REJECTED_DIGEST_ERR,
MLXFW_FSM_STATE_ERR_REJECTED_NOT_APPLICABLE,
MLXFW_FSM_STATE_ERR_REJECTED_UNKNOWN_KEY,
MLXFW_FSM_STATE_ERR_REJECTED_AUTH_FAILED,
MLXFW_FSM_STATE_ERR_REJECTED_UNSIGNED,
MLXFW_FSM_STATE_ERR_REJECTED_KEY_NOT_APPLICABLE,
MLXFW_FSM_STATE_ERR_REJECTED_BAD_FORMAT,
MLXFW_FSM_STATE_ERR_BLOCKED_PENDING_RESET,
MLXFW_FSM_STATE_ERR_MAX,
};
struct mlxfw_dev;
struct mlxfw_dev_ops {
int (*component_query)(struct mlxfw_dev *mlxfw_dev, u16 component_index,
u32 *p_max_size, u8 *p_align_bits,
u16 *p_max_write_size);
int (*fsm_lock)(struct mlxfw_dev *mlxfw_dev, u32 *fwhandle);
int (*fsm_component_update)(struct mlxfw_dev *mlxfw_dev, u32 fwhandle,
u16 component_index, u32 component_size);
int (*fsm_block_download)(struct mlxfw_dev *mlxfw_dev, u32 fwhandle,
u8 *data, u16 size, u32 offset);
int (*fsm_component_verify)(struct mlxfw_dev *mlxfw_dev, u32 fwhandle,
u16 component_index);
int (*fsm_activate)(struct mlxfw_dev *mlxfw_dev, u32 fwhandle);
int (*fsm_query_state)(struct mlxfw_dev *mlxfw_dev, u32 fwhandle,
enum mlxfw_fsm_state *fsm_state,
enum mlxfw_fsm_state_err *fsm_state_err);
void (*fsm_cancel)(struct mlxfw_dev *mlxfw_dev, u32 fwhandle);
void (*fsm_release)(struct mlxfw_dev *mlxfw_dev, u32 fwhandle);
};
struct mlxfw_dev {
const struct mlxfw_dev_ops *ops;
const char *psid;
u16 psid_size;
};
int mlxfw_firmware_flash(struct mlxfw_dev *mlxfw_dev,
const struct firmware *firmware);
#endif
/*
* drivers/net/ethernet/mellanox/mlxfw/mlxfw.c
* Copyright (c) 2017 Mellanox Technologies. All rights reserved.
* Copyright (c) 2017 Yotam Gigi <yotamg@mellanox.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the names of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#define pr_fmt(fmt) "mlxfw: " fmt
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/delay.h>
#include "mlxfw.h"
#include "mlxfw_mfa2.h"
#define MLXFW_FSM_STATE_WAIT_CYCLE_MS 200
#define MLXFW_FSM_STATE_WAIT_TIMEOUT_MS 30000
#define MLXFW_FSM_STATE_WAIT_ROUNDS \
(MLXFW_FSM_STATE_WAIT_TIMEOUT_MS / MLXFW_FSM_STATE_WAIT_CYCLE_MS)
#define MLXFW_FSM_MAX_COMPONENT_SIZE (10 * (1 << 20))
static const char * const mlxfw_fsm_state_err_str[] = {
[MLXFW_FSM_STATE_ERR_ERROR] =
"general error",
[MLXFW_FSM_STATE_ERR_REJECTED_DIGEST_ERR] =
"component hash mismatch",
[MLXFW_FSM_STATE_ERR_REJECTED_NOT_APPLICABLE] =
"component not applicable",
[MLXFW_FSM_STATE_ERR_REJECTED_UNKNOWN_KEY] =
"unknown key",
[MLXFW_FSM_STATE_ERR_REJECTED_AUTH_FAILED] =
"authentication failed",
[MLXFW_FSM_STATE_ERR_REJECTED_UNSIGNED] =
"component was not signed",
[MLXFW_FSM_STATE_ERR_REJECTED_KEY_NOT_APPLICABLE] =
"key not applicable",
[MLXFW_FSM_STATE_ERR_REJECTED_BAD_FORMAT] =
"bad format",
[MLXFW_FSM_STATE_ERR_BLOCKED_PENDING_RESET] =
"pending reset",
[MLXFW_FSM_STATE_ERR_MAX] =
"unknown error"
};
static int mlxfw_fsm_state_wait(struct mlxfw_dev *mlxfw_dev, u32 fwhandle,
enum mlxfw_fsm_state fsm_state)
{
enum mlxfw_fsm_state_err fsm_state_err;
enum mlxfw_fsm_state curr_fsm_state;
int times;
int err;
times = MLXFW_FSM_STATE_WAIT_ROUNDS;
retry:
err = mlxfw_dev->ops->fsm_query_state(mlxfw_dev, fwhandle,
&curr_fsm_state, &fsm_state_err);
if (err)
return err;
if (fsm_state_err != MLXFW_FSM_STATE_ERR_OK) {
pr_err("Firmware flash failed: %s\n",
mlxfw_fsm_state_err_str[fsm_state_err]);
return -EINVAL;
}
if (curr_fsm_state != fsm_state) {
if (--times == 0) {
pr_err("Timeout reached on FSM state change");
return -ETIMEDOUT;
}
msleep(MLXFW_FSM_STATE_WAIT_CYCLE_MS);
goto retry;
}
return 0;
}
#define MLXFW_ALIGN_DOWN(x, align_bits) ((x) & ~((1 << (align_bits)) - 1))
#define MLXFW_ALIGN_UP(x, align_bits) \
MLXFW_ALIGN_DOWN((x) + ((1 << (align_bits)) - 1), (align_bits))
static int mlxfw_flash_component(struct mlxfw_dev *mlxfw_dev,
u32 fwhandle,
struct mlxfw_mfa2_component *comp)
{
u16 comp_max_write_size;
u8 comp_align_bits;
u32 comp_max_size;
u16 block_size;
u8 *block_ptr;
u32 offset;
int err;
err = mlxfw_dev->ops->component_query(mlxfw_dev, comp->index,
&comp_max_size, &comp_align_bits,
&comp_max_write_size);
if (err)
return err;
comp_max_size = min_t(u32, comp_max_size, MLXFW_FSM_MAX_COMPONENT_SIZE);
if (comp->data_size > comp_max_size) {
pr_err("Component %d is of size %d which is bigger than limit %d\n",
comp->index, comp->data_size, comp_max_size);
return -EINVAL;
}
comp_max_write_size = MLXFW_ALIGN_DOWN(comp_max_write_size,
comp_align_bits);
pr_debug("Component update\n");
err = mlxfw_dev->ops->fsm_component_update(mlxfw_dev, fwhandle,
comp->index,
comp->data_size);
if (err)
return err;
err = mlxfw_fsm_state_wait(mlxfw_dev, fwhandle,
MLXFW_FSM_STATE_DOWNLOAD);
if (err)
goto err_out;
pr_debug("Component download\n");
for (offset = 0;
offset < MLXFW_ALIGN_UP(comp->data_size, comp_align_bits);
offset += comp_max_write_size) {
block_ptr = comp->data + offset;
block_size = (u16) min_t(u32, comp->data_size - offset,
comp_max_write_size);
err = mlxfw_dev->ops->fsm_block_download(mlxfw_dev, fwhandle,
block_ptr, block_size,
offset);
if (err)
goto err_out;
}
pr_debug("Component verify\n");
err = mlxfw_dev->ops->fsm_component_verify(mlxfw_dev, fwhandle,
comp->index);
if (err)
goto err_out;
err = mlxfw_fsm_state_wait(mlxfw_dev, fwhandle, MLXFW_FSM_STATE_LOCKED);
if (err)
goto err_out;
return 0;
err_out:
mlxfw_dev->ops->fsm_cancel(mlxfw_dev, fwhandle);
return err;
}
static int mlxfw_flash_components(struct mlxfw_dev *mlxfw_dev, u32 fwhandle,
struct mlxfw_mfa2_file *mfa2_file)
{
u32 component_count;
int err;
int i;
err = mlxfw_mfa2_file_component_count(mfa2_file, mlxfw_dev->psid,
mlxfw_dev->psid_size,
&component_count);
if (err) {
pr_err("Could not find device PSID in MFA2 file\n");
return err;
}
for (i = 0; i < component_count; i++) {
struct mlxfw_mfa2_component *comp;
comp = mlxfw_mfa2_file_component_get(mfa2_file, mlxfw_dev->psid,
mlxfw_dev->psid_size, i);
if (IS_ERR(comp))
return PTR_ERR(comp);
pr_info("Flashing component type %d\n", comp->index);
err = mlxfw_flash_component(mlxfw_dev, fwhandle, comp);
mlxfw_mfa2_file_component_put(comp);
if (err)
return err;
}
return 0;
}
int mlxfw_firmware_flash(struct mlxfw_dev *mlxfw_dev,
const struct firmware *firmware)
{
struct mlxfw_mfa2_file *mfa2_file;
u32 fwhandle;
int err;
if (!mlxfw_mfa2_check(firmware)) {
pr_err("Firmware file is not MFA2\n");
return -EINVAL;
}
mfa2_file = mlxfw_mfa2_file_init(firmware);
if (IS_ERR(mfa2_file))
return PTR_ERR(mfa2_file);
pr_info("Initialize firmware flash process\n");
err = mlxfw_dev->ops->fsm_lock(mlxfw_dev, &fwhandle);
if (err) {
pr_err("Could not lock the firmware FSM\n");
goto err_fsm_lock;
}
err = mlxfw_fsm_state_wait(mlxfw_dev, fwhandle,
MLXFW_FSM_STATE_LOCKED);
if (err)
goto err_state_wait_idle_to_locked;
err = mlxfw_flash_components(mlxfw_dev, fwhandle, mfa2_file);
if (err)
goto err_flash_components;
pr_debug("Activate image\n");
err = mlxfw_dev->ops->fsm_activate(mlxfw_dev, fwhandle);
if (err) {
pr_err("Could not activate the downloaded image\n");
goto err_fsm_activate;
}
err = mlxfw_fsm_state_wait(mlxfw_dev, fwhandle, MLXFW_FSM_STATE_LOCKED);
if (err)
goto err_state_wait_activate_to_locked;
pr_debug("Handle release\n");
mlxfw_dev->ops->fsm_release(mlxfw_dev, fwhandle);
pr_info("Firmware flash done.\n");
mlxfw_mfa2_file_fini(mfa2_file);
return 0;
err_state_wait_activate_to_locked:
err_fsm_activate:
err_flash_components:
err_state_wait_idle_to_locked:
mlxfw_dev->ops->fsm_release(mlxfw_dev, fwhandle);
err_fsm_lock:
mlxfw_mfa2_file_fini(mfa2_file);
return err;
}
EXPORT_SYMBOL(mlxfw_firmware_flash);
MODULE_LICENSE("Dual BSD/GPL");
MODULE_AUTHOR("Yotam Gigi <yotamg@mellanox.com>");
MODULE_DESCRIPTION("Mellanox firmware flash lib");
This diff is collapsed.
/*
* drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.h
* Copyright (c) 2017 Mellanox Technologies. All rights reserved.
* Copyright (c) 2017 Yotam Gigi <yotamg@mellanox.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the names of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _MLXFW_MFA2_H
#define _MLXFW_MFA2_H
#include <linux/firmware.h>
#include "mlxfw.h"
struct mlxfw_mfa2_component {
u16 index;
u32 data_size;
u8 *data;
};
struct mlxfw_mfa2_file;
bool mlxfw_mfa2_check(const struct firmware *fw);
struct mlxfw_mfa2_file *mlxfw_mfa2_file_init(const struct firmware *fw);
int mlxfw_mfa2_file_component_count(const struct mlxfw_mfa2_file *mfa2_file,
const char *psid, u32 psid_size,
u32 *p_count);
struct mlxfw_mfa2_component *
mlxfw_mfa2_file_component_get(const struct mlxfw_mfa2_file *mfa2_file,
const char *psid, int psid_size,
int component_index);
void mlxfw_mfa2_file_component_put(struct mlxfw_mfa2_component *component);
void mlxfw_mfa2_file_fini(struct mlxfw_mfa2_file *mfa2_file);
#endif
/*
* drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2_file.h
* Copyright (c) 2017 Mellanox Technologies. All rights reserved.
* Copyright (c) 2017 Yotam Gigi <yotamg@mellanox.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the names of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _MLXFW_MFA2_FILE_H
#define _MLXFW_MFA2_FILE_H
#include <linux/firmware.h>
#include <linux/kernel.h>
struct mlxfw_mfa2_file {
const struct firmware *fw;
const struct mlxfw_mfa2_tlv *first_dev;
u16 dev_count;
const struct mlxfw_mfa2_tlv *first_component;
u16 component_count;
const void *cb; /* components block */
u32 cb_archive_size; /* size of compressed components block */
};
static inline bool mlxfw_mfa2_valid_ptr(const struct mlxfw_mfa2_file *mfa2_file,
const void *ptr)
{
const void *valid_to = mfa2_file->fw->data + mfa2_file->fw->size;
const void *valid_from = mfa2_file->fw->data;
return ptr > valid_from && ptr < valid_to;
}
#endif
/*
* drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2_format.h
* Copyright (c) 2017 Mellanox Technologies. All rights reserved.
* Copyright (c) 2017 Yotam Gigi <yotamg@mellanox.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the names of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _MLXFW_MFA2_FORMAT_H
#define _MLXFW_MFA2_FORMAT_H
#include "mlxfw_mfa2_file.h"
#include "mlxfw_mfa2_tlv.h"
enum mlxfw_mfa2_tlv_type {
MLXFW_MFA2_TLV_MULTI_PART = 0x01,
MLXFW_MFA2_TLV_PACKAGE_DESCRIPTOR = 0x02,
MLXFW_MFA2_TLV_COMPONENT_DESCRIPTOR = 0x04,
MLXFW_MFA2_TLV_COMPONENT_PTR = 0x22,
MLXFW_MFA2_TLV_PSID = 0x2A,
};
enum mlxfw_mfa2_compression_type {
MLXFW_MFA2_COMPRESSION_TYPE_NONE,
MLXFW_MFA2_COMPRESSION_TYPE_XZ,
};
struct mlxfw_mfa2_tlv_package_descriptor {
__be16 num_components;
__be16 num_devices;
__be32 cb_offset;
__be32 cb_archive_size;
__be32 cb_size_h;
__be32 cb_size_l;
u8 padding[3];
u8 cv_compression;
__be32 user_data_offset;
} __packed;
MLXFW_MFA2_TLV(package_descriptor, struct mlxfw_mfa2_tlv_package_descriptor,
MLXFW_MFA2_TLV_PACKAGE_DESCRIPTOR);
struct mlxfw_mfa2_tlv_multi {
__be16 num_extensions;
__be16 total_len;
} __packed;
MLXFW_MFA2_TLV(multi, struct mlxfw_mfa2_tlv_multi,
MLXFW_MFA2_TLV_MULTI_PART);
struct mlxfw_mfa2_tlv_psid {
u8 psid[0];
} __packed;
MLXFW_MFA2_TLV_VARSIZE(psid, struct mlxfw_mfa2_tlv_psid,
MLXFW_MFA2_TLV_PSID);
struct mlxfw_mfa2_tlv_component_ptr {
__be16 storage_id;
__be16 component_index;
__be32 storage_address;
} __packed;
MLXFW_MFA2_TLV(component_ptr, struct mlxfw_mfa2_tlv_component_ptr,
MLXFW_MFA2_TLV_COMPONENT_PTR);
struct mlxfw_mfa2_tlv_component_descriptor {
__be16 pldm_classification;
__be16 identifier;
__be32 cb_offset_h;
__be32 cb_offset_l;
__be32 size;
} __packed;
MLXFW_MFA2_TLV(component_descriptor, struct mlxfw_mfa2_tlv_component_descriptor,
MLXFW_MFA2_TLV_COMPONENT_DESCRIPTOR);
#endif
/*
* drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2_tlv.h
* Copyright (c) 2017 Mellanox Technologies. All rights reserved.
* Copyright (c) 2017 Yotam Gigi <yotamg@mellanox.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the names of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _MLXFW_MFA2_TLV_H
#define _MLXFW_MFA2_TLV_H
#include <linux/kernel.h>
#include "mlxfw_mfa2_file.h"
struct mlxfw_mfa2_tlv {
u8 version;
u8 type;
__be16 len;
u8 data[0];
} __packed;
static inline const struct mlxfw_mfa2_tlv *
mlxfw_mfa2_tlv_get(const struct mlxfw_mfa2_file *mfa2_file, const void *ptr)
{
if (!mlxfw_mfa2_valid_ptr(mfa2_file, ptr) ||
!mlxfw_mfa2_valid_ptr(mfa2_file, ptr + sizeof(struct mlxfw_mfa2_tlv)))
return NULL;
return ptr;
}
static inline const void *
mlxfw_mfa2_tlv_payload_get(const struct mlxfw_mfa2_file *mfa2_file,
const struct mlxfw_mfa2_tlv *tlv, u8 payload_type,
size_t payload_size, bool varsize)
{
void *tlv_top;
tlv_top = (void *) tlv + be16_to_cpu(tlv->len) - 1;
if (!mlxfw_mfa2_valid_ptr(mfa2_file, tlv) ||
!mlxfw_mfa2_valid_ptr(mfa2_file, tlv_top))
return NULL;
if (tlv->type != payload_type)
return NULL;
if (varsize && (be16_to_cpu(tlv->len) < payload_size))
return NULL;
if (!varsize && (be16_to_cpu(tlv->len) != payload_size))
return NULL;
return tlv->data;
}
#define MLXFW_MFA2_TLV(name, payload_type, tlv_type) \
static inline const payload_type * \
mlxfw_mfa2_tlv_ ## name ## _get(const struct mlxfw_mfa2_file *mfa2_file, \
const struct mlxfw_mfa2_tlv *tlv) \
{ \
return mlxfw_mfa2_tlv_payload_get(mfa2_file, tlv, \
tlv_type, sizeof(payload_type), \
false); \
}
#define MLXFW_MFA2_TLV_VARSIZE(name, payload_type, tlv_type) \
static inline const payload_type * \
mlxfw_mfa2_tlv_ ## name ## _get(const struct mlxfw_mfa2_file *mfa2_file, \
const struct mlxfw_mfa2_tlv *tlv) \
{ \
return mlxfw_mfa2_tlv_payload_get(mfa2_file, tlv, \
tlv_type, sizeof(payload_type), \
true); \
}
#endif
/*
* drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2_tlv_multi.c
* Copyright (c) 2017 Mellanox Technologies. All rights reserved.
* Copyright (c) 2017 Yotam Gigi <yotamg@mellanox.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the names of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#define pr_fmt(fmt) "MFA2: " fmt
#include "mlxfw_mfa2_tlv_multi.h"
#include <uapi/linux/netlink.h>
#define MLXFW_MFA2_TLV_TOTAL_SIZE(tlv) \
NLA_ALIGN(sizeof(*(tlv)) + be16_to_cpu((tlv)->len))
const struct mlxfw_mfa2_tlv *
mlxfw_mfa2_tlv_multi_child(const struct mlxfw_mfa2_file *mfa2_file,
const struct mlxfw_mfa2_tlv_multi *multi)
{
size_t multi_len;
multi_len = NLA_ALIGN(sizeof(struct mlxfw_mfa2_tlv_multi));
return mlxfw_mfa2_tlv_get(mfa2_file, (void *) multi + multi_len);
}
const struct mlxfw_mfa2_tlv *
mlxfw_mfa2_tlv_next(const struct mlxfw_mfa2_file *mfa2_file,
const struct mlxfw_mfa2_tlv *tlv)
{
const struct mlxfw_mfa2_tlv_multi *multi;
u16 tlv_len;
void *next;
tlv_len = MLXFW_MFA2_TLV_TOTAL_SIZE(tlv);
if (tlv->type == MLXFW_MFA2_TLV_MULTI_PART) {
multi = mlxfw_mfa2_tlv_multi_get(mfa2_file, tlv);
tlv_len = NLA_ALIGN(tlv_len + be16_to_cpu(multi->total_len));
}
next = (void *) tlv + tlv_len;
return mlxfw_mfa2_tlv_get(mfa2_file, next);
}
const struct mlxfw_mfa2_tlv *
mlxfw_mfa2_tlv_advance(const struct mlxfw_mfa2_file *mfa2_file,
const struct mlxfw_mfa2_tlv *from_tlv, u16 count)
{
const struct mlxfw_mfa2_tlv *tlv;
u16 idx;
mlxfw_mfa2_tlv_foreach(mfa2_file, tlv, idx, from_tlv, count)
if (!tlv)
return NULL;
return tlv;
}
const struct mlxfw_mfa2_tlv *
mlxfw_mfa2_tlv_multi_child_find(const struct mlxfw_mfa2_file *mfa2_file,
const struct mlxfw_mfa2_tlv_multi *multi,
enum mlxfw_mfa2_tlv_type type, u16 index)
{
const struct mlxfw_mfa2_tlv *tlv;
u16 skip = 0;
u16 idx;
mlxfw_mfa2_tlv_multi_foreach(mfa2_file, tlv, idx, multi) {
if (!tlv) {
pr_err("TLV parsing error\n");
return NULL;
}
if (tlv->type == type)
if (skip++ == index)
return tlv;
}
return NULL;
}
int mlxfw_mfa2_tlv_multi_child_count(const struct mlxfw_mfa2_file *mfa2_file,
const struct mlxfw_mfa2_tlv_multi *multi,
enum mlxfw_mfa2_tlv_type type,
u16 *p_count)
{
const struct mlxfw_mfa2_tlv *tlv;
u16 count = 0;
u16 idx;
mlxfw_mfa2_tlv_multi_foreach(mfa2_file, tlv, idx, multi) {
if (!tlv) {
pr_err("TLV parsing error\n");
return -EINVAL;
}
if (tlv->type == type)
count++;
}
*p_count = count;
return 0;
}
/*
* drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2_tlv_multi.h
* Copyright (c) 2017 Mellanox Technologies. All rights reserved.
* Copyright (c) 2017 Yotam Gigi <yotamg@mellanox.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the names of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _MLXFW_MFA2_TLV_MULTI_H
#define _MLXFW_MFA2_TLV_MULTI_H
#include "mlxfw_mfa2_tlv.h"
#include "mlxfw_mfa2_format.h"
#include "mlxfw_mfa2_file.h"
const struct mlxfw_mfa2_tlv *
mlxfw_mfa2_tlv_multi_child(const struct mlxfw_mfa2_file *mfa2_file,
const struct mlxfw_mfa2_tlv_multi *multi);
const struct mlxfw_mfa2_tlv *
mlxfw_mfa2_tlv_next(const struct mlxfw_mfa2_file *mfa2_file,
const struct mlxfw_mfa2_tlv *tlv);
const struct mlxfw_mfa2_tlv *
mlxfw_mfa2_tlv_advance(const struct mlxfw_mfa2_file *mfa2_file,
const struct mlxfw_mfa2_tlv *from_tlv, u16 count);
const struct mlxfw_mfa2_tlv *
mlxfw_mfa2_tlv_multi_child_find(const struct mlxfw_mfa2_file *mfa2_file,
const struct mlxfw_mfa2_tlv_multi *multi,
enum mlxfw_mfa2_tlv_type type, u16 index);
int mlxfw_mfa2_tlv_multi_child_count(const struct mlxfw_mfa2_file *mfa2_file,
const struct mlxfw_mfa2_tlv_multi *multi,
enum mlxfw_mfa2_tlv_type type,
u16 *p_count);
#define mlxfw_mfa2_tlv_foreach(mfa2_file, tlv, idx, from_tlv, count) \
for (idx = 0, tlv = from_tlv; idx < (count); \
idx++, tlv = mlxfw_mfa2_tlv_next(mfa2_file, tlv))
#define mlxfw_mfa2_tlv_multi_foreach(mfa2_file, tlv, idx, multi) \
mlxfw_mfa2_tlv_foreach(mfa2_file, tlv, idx, \
mlxfw_mfa2_tlv_multi_child(mfa2_file, multi), \
be16_to_cpu(multi->num_extensions) + 1)
#endif
...@@ -75,6 +75,7 @@ config MLXSW_SPECTRUM ...@@ -75,6 +75,7 @@ config MLXSW_SPECTRUM
depends on MLXSW_CORE && MLXSW_PCI && NET_SWITCHDEV && VLAN_8021Q depends on MLXSW_CORE && MLXSW_PCI && NET_SWITCHDEV && VLAN_8021Q
depends on PSAMPLE || PSAMPLE=n depends on PSAMPLE || PSAMPLE=n
select PARMAN select PARMAN
select MLXFW
default m default m
---help--- ---help---
This driver supports Mellanox Technologies Spectrum Ethernet This driver supports Mellanox Technologies Spectrum Ethernet
......
...@@ -344,15 +344,17 @@ struct mlxsw_bus { ...@@ -344,15 +344,17 @@ struct mlxsw_bus {
u8 features; u8 features;
}; };
struct mlxsw_fw_rev {
u16 major;
u16 minor;
u16 subminor;
};
struct mlxsw_bus_info { struct mlxsw_bus_info {
const char *device_kind; const char *device_kind;
const char *device_name; const char *device_name;
struct device *dev; struct device *dev;
struct { struct mlxsw_fw_rev fw_rev;
u16 major;
u16 minor;
u16 subminor;
} fw_rev;
u8 vsd[MLXSW_CMD_BOARDINFO_VSD_LEN]; u8 vsd[MLXSW_CMD_BOARDINFO_VSD_LEN];
u8 psid[MLXSW_CMD_BOARDINFO_PSID_LEN]; u8 psid[MLXSW_CMD_BOARDINFO_PSID_LEN];
}; };
......
...@@ -5643,6 +5643,222 @@ static inline void mlxsw_reg_mlcr_pack(char *payload, u8 local_port, ...@@ -5643,6 +5643,222 @@ static inline void mlxsw_reg_mlcr_pack(char *payload, u8 local_port,
MLXSW_REG_MLCR_DURATION_MAX : 0); MLXSW_REG_MLCR_DURATION_MAX : 0);
} }
/* MCQI - Management Component Query Information
* ---------------------------------------------
* This register allows querying information about firmware components.
*/
#define MLXSW_REG_MCQI_ID 0x9061
#define MLXSW_REG_MCQI_BASE_LEN 0x18
#define MLXSW_REG_MCQI_CAP_LEN 0x14
#define MLXSW_REG_MCQI_LEN (MLXSW_REG_MCQI_BASE_LEN + MLXSW_REG_MCQI_CAP_LEN)
MLXSW_REG_DEFINE(mcqi, MLXSW_REG_MCQI_ID, MLXSW_REG_MCQI_LEN);
/* reg_mcqi_component_index
* Index of the accessed component.
* Access: Index
*/
MLXSW_ITEM32(reg, mcqi, component_index, 0x00, 0, 16);
enum mlxfw_reg_mcqi_info_type {
MLXSW_REG_MCQI_INFO_TYPE_CAPABILITIES,
};
/* reg_mcqi_info_type
* Component properties set.
* Access: RW
*/
MLXSW_ITEM32(reg, mcqi, info_type, 0x08, 0, 5);
/* reg_mcqi_offset
* The requested/returned data offset from the section start, given in bytes.
* Must be DWORD aligned.
* Access: RW
*/
MLXSW_ITEM32(reg, mcqi, offset, 0x10, 0, 32);
/* reg_mcqi_data_size
* The requested/returned data size, given in bytes. If data_size is not DWORD
* aligned, the last bytes are zero padded.
* Access: RW
*/
MLXSW_ITEM32(reg, mcqi, data_size, 0x14, 0, 16);
/* reg_mcqi_cap_max_component_size
* Maximum size for this component, given in bytes.
* Access: RO
*/
MLXSW_ITEM32(reg, mcqi, cap_max_component_size, 0x20, 0, 32);
/* reg_mcqi_cap_log_mcda_word_size
* Log 2 of the access word size in bytes. Read and write access must be aligned
* to the word size. Write access must be done for an integer number of words.
* Access: RO
*/
MLXSW_ITEM32(reg, mcqi, cap_log_mcda_word_size, 0x24, 28, 4);
/* reg_mcqi_cap_mcda_max_write_size
* Maximal write size for MCDA register
* Access: RO
*/
MLXSW_ITEM32(reg, mcqi, cap_mcda_max_write_size, 0x24, 0, 16);
static inline void mlxsw_reg_mcqi_pack(char *payload, u16 component_index)
{
MLXSW_REG_ZERO(mcqi, payload);
mlxsw_reg_mcqi_component_index_set(payload, component_index);
mlxsw_reg_mcqi_info_type_set(payload,
MLXSW_REG_MCQI_INFO_TYPE_CAPABILITIES);
mlxsw_reg_mcqi_offset_set(payload, 0);
mlxsw_reg_mcqi_data_size_set(payload, MLXSW_REG_MCQI_CAP_LEN);
}
static inline void mlxsw_reg_mcqi_unpack(char *payload,
u32 *p_cap_max_component_size,
u8 *p_cap_log_mcda_word_size,
u16 *p_cap_mcda_max_write_size)
{
*p_cap_max_component_size =
mlxsw_reg_mcqi_cap_max_component_size_get(payload);
*p_cap_log_mcda_word_size =
mlxsw_reg_mcqi_cap_log_mcda_word_size_get(payload);
*p_cap_mcda_max_write_size =
mlxsw_reg_mcqi_cap_mcda_max_write_size_get(payload);
}
/* MCC - Management Component Control
* ----------------------------------
* Controls the firmware component and updates the FSM.
*/
#define MLXSW_REG_MCC_ID 0x9062
#define MLXSW_REG_MCC_LEN 0x1C
MLXSW_REG_DEFINE(mcc, MLXSW_REG_MCC_ID, MLXSW_REG_MCC_LEN);
enum mlxsw_reg_mcc_instruction {
MLXSW_REG_MCC_INSTRUCTION_LOCK_UPDATE_HANDLE = 0x01,
MLXSW_REG_MCC_INSTRUCTION_RELEASE_UPDATE_HANDLE = 0x02,
MLXSW_REG_MCC_INSTRUCTION_UPDATE_COMPONENT = 0x03,
MLXSW_REG_MCC_INSTRUCTION_VERIFY_COMPONENT = 0x04,
MLXSW_REG_MCC_INSTRUCTION_ACTIVATE = 0x06,
MLXSW_REG_MCC_INSTRUCTION_CANCEL = 0x08,
};
/* reg_mcc_instruction
* Command to be executed by the FSM.
* Applicable for write operation only.
* Access: RW
*/
MLXSW_ITEM32(reg, mcc, instruction, 0x00, 0, 8);
/* reg_mcc_component_index
* Index of the accessed component. Applicable only for commands that
* refer to components. Otherwise, this field is reserved.
* Access: Index
*/
MLXSW_ITEM32(reg, mcc, component_index, 0x04, 0, 16);
/* reg_mcc_update_handle
* Token representing the current flow executed by the FSM.
* Access: WO
*/
MLXSW_ITEM32(reg, mcc, update_handle, 0x08, 0, 24);
/* reg_mcc_error_code
* Indicates the successful completion of the instruction, or the reason it
* failed
* Access: RO
*/
MLXSW_ITEM32(reg, mcc, error_code, 0x0C, 8, 8);
/* reg_mcc_control_state
* Current FSM state
* Access: RO
*/
MLXSW_ITEM32(reg, mcc, control_state, 0x0C, 0, 4);
/* reg_mcc_component_size
* Component size in bytes. Valid for UPDATE_COMPONENT instruction. Specifying
* the size may shorten the update time. Value 0x0 means that size is
* unspecified.
* Access: WO
*/
MLXSW_ITEM32(reg, mcc, component_size, 0x10, 0, 32);
static inline void mlxsw_reg_mcc_pack(char *payload,
enum mlxsw_reg_mcc_instruction instr,
u16 component_index, u32 update_handle,
u32 component_size)
{
MLXSW_REG_ZERO(mcc, payload);
mlxsw_reg_mcc_instruction_set(payload, instr);
mlxsw_reg_mcc_component_index_set(payload, component_index);
mlxsw_reg_mcc_update_handle_set(payload, update_handle);
mlxsw_reg_mcc_component_size_set(payload, component_size);
}
static inline void mlxsw_reg_mcc_unpack(char *payload, u32 *p_update_handle,
u8 *p_error_code, u8 *p_control_state)
{
if (p_update_handle)
*p_update_handle = mlxsw_reg_mcc_update_handle_get(payload);
if (p_error_code)
*p_error_code = mlxsw_reg_mcc_error_code_get(payload);
if (p_control_state)
*p_control_state = mlxsw_reg_mcc_control_state_get(payload);
}
/* MCDA - Management Component Data Access
* ---------------------------------------
* This register allows reading and writing a firmware component.
*/
#define MLXSW_REG_MCDA_ID 0x9063
#define MLXSW_REG_MCDA_BASE_LEN 0x10
#define MLXSW_REG_MCDA_MAX_DATA_LEN 0x80
#define MLXSW_REG_MCDA_LEN \
(MLXSW_REG_MCDA_BASE_LEN + MLXSW_REG_MCDA_MAX_DATA_LEN)
MLXSW_REG_DEFINE(mcda, MLXSW_REG_MCDA_ID, MLXSW_REG_MCDA_LEN);
/* reg_mcda_update_handle
* Token representing the current flow executed by the FSM.
* Access: RW
*/
MLXSW_ITEM32(reg, mcda, update_handle, 0x00, 0, 24);
/* reg_mcda_offset
* Offset of accessed address relative to component start. Accesses must be in
* accordance to log_mcda_word_size in MCQI reg.
* Access: RW
*/
MLXSW_ITEM32(reg, mcda, offset, 0x04, 0, 32);
/* reg_mcda_size
* Size of the data accessed, given in bytes.
* Access: RW
*/
MLXSW_ITEM32(reg, mcda, size, 0x08, 0, 16);
/* reg_mcda_data
* Data block accessed.
* Access: RW
*/
MLXSW_ITEM32_INDEXED(reg, mcda, data, 0x10, 0, 32, 4, 0, false);
static inline void mlxsw_reg_mcda_pack(char *payload, u32 update_handle,
u32 offset, u16 size, u8 *data)
{
int i;
MLXSW_REG_ZERO(mcda, payload);
mlxsw_reg_mcda_update_handle_set(payload, update_handle);
mlxsw_reg_mcda_offset_set(payload, offset);
mlxsw_reg_mcda_size_set(payload, size);
for (i = 0; i < size / 4; i++)
mlxsw_reg_mcda_data_set(payload, i, *(u32 *) &data[i * 4]);
}
/* MPSC - Monitoring Packet Sampling Configuration Register /* MPSC - Monitoring Packet Sampling Configuration Register
* -------------------------------------------------------- * --------------------------------------------------------
* MPSC Register is used to configure the Packet Sampling mechanism. * MPSC Register is used to configure the Packet Sampling mechanism.
...@@ -6221,6 +6437,9 @@ static const struct mlxsw_reg_info *mlxsw_reg_infos[] = { ...@@ -6221,6 +6437,9 @@ static const struct mlxsw_reg_info *mlxsw_reg_infos[] = {
MLXSW_REG(mpar), MLXSW_REG(mpar),
MLXSW_REG(mlcr), MLXSW_REG(mlcr),
MLXSW_REG(mpsc), MLXSW_REG(mpsc),
MLXSW_REG(mcqi),
MLXSW_REG(mcc),
MLXSW_REG(mcda),
MLXSW_REG(mgpc), MLXSW_REG(mgpc),
MLXSW_REG(sbpr), MLXSW_REG(sbpr),
MLXSW_REG(sbcm), MLXSW_REG(sbcm),
......
...@@ -68,6 +68,22 @@ ...@@ -68,6 +68,22 @@
#include "txheader.h" #include "txheader.h"
#include "spectrum_cnt.h" #include "spectrum_cnt.h"
#include "spectrum_dpipe.h" #include "spectrum_dpipe.h"
#include "../mlxfw/mlxfw.h"
#define MLXSW_FWREV_MAJOR 13
#define MLXSW_FWREV_MINOR 1420
#define MLXSW_FWREV_SUBMINOR 122
static const struct mlxsw_fw_rev mlxsw_sp_supported_fw_rev = {
.major = MLXSW_FWREV_MAJOR,
.minor = MLXSW_FWREV_MINOR,
.subminor = MLXSW_FWREV_SUBMINOR
};
#define MLXSW_SP_FW_FILENAME \
"mlxsw_spectrum-" __stringify(MLXSW_FWREV_MAJOR) \
"." __stringify(MLXSW_FWREV_MINOR) \
"." __stringify(MLXSW_FWREV_SUBMINOR) ".mfa2"
static const char mlxsw_sp_driver_name[] = "mlxsw_spectrum"; static const char mlxsw_sp_driver_name[] = "mlxsw_spectrum";
static const char mlxsw_sp_driver_version[] = "1.0"; static const char mlxsw_sp_driver_version[] = "1.0";
...@@ -140,6 +156,216 @@ MLXSW_ITEM32(tx, hdr, fid, 0x08, 0, 16); ...@@ -140,6 +156,216 @@ MLXSW_ITEM32(tx, hdr, fid, 0x08, 0, 16);
*/ */
MLXSW_ITEM32(tx, hdr, type, 0x0C, 0, 4); MLXSW_ITEM32(tx, hdr, type, 0x0C, 0, 4);
struct mlxsw_sp_mlxfw_dev {
struct mlxfw_dev mlxfw_dev;
struct mlxsw_sp *mlxsw_sp;
};
static int mlxsw_sp_component_query(struct mlxfw_dev *mlxfw_dev,
u16 component_index, u32 *p_max_size,
u8 *p_align_bits, u16 *p_max_write_size)
{
struct mlxsw_sp_mlxfw_dev *mlxsw_sp_mlxfw_dev =
container_of(mlxfw_dev, struct mlxsw_sp_mlxfw_dev, mlxfw_dev);
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_mlxfw_dev->mlxsw_sp;
char mcqi_pl[MLXSW_REG_MCQI_LEN];
int err;
mlxsw_reg_mcqi_pack(mcqi_pl, component_index);
err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(mcqi), mcqi_pl);
if (err)
return err;
mlxsw_reg_mcqi_unpack(mcqi_pl, p_max_size, p_align_bits,
p_max_write_size);
*p_align_bits = max_t(u8, *p_align_bits, 2);
*p_max_write_size = min_t(u16, *p_max_write_size,
MLXSW_REG_MCDA_MAX_DATA_LEN);
return 0;
}
static int mlxsw_sp_fsm_lock(struct mlxfw_dev *mlxfw_dev, u32 *fwhandle)
{
struct mlxsw_sp_mlxfw_dev *mlxsw_sp_mlxfw_dev =
container_of(mlxfw_dev, struct mlxsw_sp_mlxfw_dev, mlxfw_dev);
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_mlxfw_dev->mlxsw_sp;
char mcc_pl[MLXSW_REG_MCC_LEN];
u8 control_state;
int err;
mlxsw_reg_mcc_pack(mcc_pl, 0, 0, 0, 0);
err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(mcc), mcc_pl);
if (err)
return err;
mlxsw_reg_mcc_unpack(mcc_pl, fwhandle, NULL, &control_state);
if (control_state != MLXFW_FSM_STATE_IDLE)
return -EBUSY;
mlxsw_reg_mcc_pack(mcc_pl,
MLXSW_REG_MCC_INSTRUCTION_LOCK_UPDATE_HANDLE,
0, *fwhandle, 0);
return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mcc), mcc_pl);
}
static int mlxsw_sp_fsm_component_update(struct mlxfw_dev *mlxfw_dev,
u32 fwhandle, u16 component_index,
u32 component_size)
{
struct mlxsw_sp_mlxfw_dev *mlxsw_sp_mlxfw_dev =
container_of(mlxfw_dev, struct mlxsw_sp_mlxfw_dev, mlxfw_dev);
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_mlxfw_dev->mlxsw_sp;
char mcc_pl[MLXSW_REG_MCC_LEN];
mlxsw_reg_mcc_pack(mcc_pl, MLXSW_REG_MCC_INSTRUCTION_UPDATE_COMPONENT,
component_index, fwhandle, component_size);
return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mcc), mcc_pl);
}
static int mlxsw_sp_fsm_block_download(struct mlxfw_dev *mlxfw_dev,
u32 fwhandle, u8 *data, u16 size,
u32 offset)
{
struct mlxsw_sp_mlxfw_dev *mlxsw_sp_mlxfw_dev =
container_of(mlxfw_dev, struct mlxsw_sp_mlxfw_dev, mlxfw_dev);
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_mlxfw_dev->mlxsw_sp;
char mcda_pl[MLXSW_REG_MCDA_LEN];
mlxsw_reg_mcda_pack(mcda_pl, fwhandle, offset, size, data);
return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mcda), mcda_pl);
}
static int mlxsw_sp_fsm_component_verify(struct mlxfw_dev *mlxfw_dev,
u32 fwhandle, u16 component_index)
{
struct mlxsw_sp_mlxfw_dev *mlxsw_sp_mlxfw_dev =
container_of(mlxfw_dev, struct mlxsw_sp_mlxfw_dev, mlxfw_dev);
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_mlxfw_dev->mlxsw_sp;
char mcc_pl[MLXSW_REG_MCC_LEN];
mlxsw_reg_mcc_pack(mcc_pl, MLXSW_REG_MCC_INSTRUCTION_VERIFY_COMPONENT,
component_index, fwhandle, 0);
return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mcc), mcc_pl);
}
static int mlxsw_sp_fsm_activate(struct mlxfw_dev *mlxfw_dev, u32 fwhandle)
{
struct mlxsw_sp_mlxfw_dev *mlxsw_sp_mlxfw_dev =
container_of(mlxfw_dev, struct mlxsw_sp_mlxfw_dev, mlxfw_dev);
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_mlxfw_dev->mlxsw_sp;
char mcc_pl[MLXSW_REG_MCC_LEN];
mlxsw_reg_mcc_pack(mcc_pl, MLXSW_REG_MCC_INSTRUCTION_ACTIVATE, 0,
fwhandle, 0);
return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mcc), mcc_pl);
}
static int mlxsw_sp_fsm_query_state(struct mlxfw_dev *mlxfw_dev, u32 fwhandle,
enum mlxfw_fsm_state *fsm_state,
enum mlxfw_fsm_state_err *fsm_state_err)
{
struct mlxsw_sp_mlxfw_dev *mlxsw_sp_mlxfw_dev =
container_of(mlxfw_dev, struct mlxsw_sp_mlxfw_dev, mlxfw_dev);
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_mlxfw_dev->mlxsw_sp;
char mcc_pl[MLXSW_REG_MCC_LEN];
u8 control_state;
u8 error_code;
int err;
mlxsw_reg_mcc_pack(mcc_pl, 0, 0, fwhandle, 0);
err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(mcc), mcc_pl);
if (err)
return err;
mlxsw_reg_mcc_unpack(mcc_pl, NULL, &error_code, &control_state);
*fsm_state = control_state;
*fsm_state_err = min_t(enum mlxfw_fsm_state_err, error_code,
MLXFW_FSM_STATE_ERR_MAX);
return 0;
}
static void mlxsw_sp_fsm_cancel(struct mlxfw_dev *mlxfw_dev, u32 fwhandle)
{
struct mlxsw_sp_mlxfw_dev *mlxsw_sp_mlxfw_dev =
container_of(mlxfw_dev, struct mlxsw_sp_mlxfw_dev, mlxfw_dev);
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_mlxfw_dev->mlxsw_sp;
char mcc_pl[MLXSW_REG_MCC_LEN];
mlxsw_reg_mcc_pack(mcc_pl, MLXSW_REG_MCC_INSTRUCTION_CANCEL, 0,
fwhandle, 0);
mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mcc), mcc_pl);
}
static void mlxsw_sp_fsm_release(struct mlxfw_dev *mlxfw_dev, u32 fwhandle)
{
struct mlxsw_sp_mlxfw_dev *mlxsw_sp_mlxfw_dev =
container_of(mlxfw_dev, struct mlxsw_sp_mlxfw_dev, mlxfw_dev);
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_mlxfw_dev->mlxsw_sp;
char mcc_pl[MLXSW_REG_MCC_LEN];
mlxsw_reg_mcc_pack(mcc_pl,
MLXSW_REG_MCC_INSTRUCTION_RELEASE_UPDATE_HANDLE, 0,
fwhandle, 0);
mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(mcc), mcc_pl);
}
static const struct mlxfw_dev_ops mlxsw_sp_mlxfw_dev_ops = {
.component_query = mlxsw_sp_component_query,
.fsm_lock = mlxsw_sp_fsm_lock,
.fsm_component_update = mlxsw_sp_fsm_component_update,
.fsm_block_download = mlxsw_sp_fsm_block_download,
.fsm_component_verify = mlxsw_sp_fsm_component_verify,
.fsm_activate = mlxsw_sp_fsm_activate,
.fsm_query_state = mlxsw_sp_fsm_query_state,
.fsm_cancel = mlxsw_sp_fsm_cancel,
.fsm_release = mlxsw_sp_fsm_release
};
static bool mlxsw_sp_fw_rev_ge(const struct mlxsw_fw_rev *a,
const struct mlxsw_fw_rev *b)
{
if (a->major != b->major)
return a->major > b->major;
if (a->minor != b->minor)
return a->minor > b->minor;
return a->subminor >= b->subminor;
}
static int mlxsw_sp_fw_rev_validate(struct mlxsw_sp *mlxsw_sp)
{
const struct mlxsw_fw_rev *rev = &mlxsw_sp->bus_info->fw_rev;
struct mlxsw_sp_mlxfw_dev mlxsw_sp_mlxfw_dev = {
.mlxfw_dev = {
.ops = &mlxsw_sp_mlxfw_dev_ops,
.psid = mlxsw_sp->bus_info->psid,
.psid_size = strlen(mlxsw_sp->bus_info->psid),
},
.mlxsw_sp = mlxsw_sp
};
const struct firmware *firmware;
int err;
if (mlxsw_sp_fw_rev_ge(rev, &mlxsw_sp_supported_fw_rev))
return 0;
dev_info(mlxsw_sp->bus_info->dev, "The firmware version %d.%d.%d out of data\n",
rev->major, rev->minor, rev->subminor);
dev_info(mlxsw_sp->bus_info->dev, "Upgrading firmware using file %s\n",
MLXSW_SP_FW_FILENAME);
err = request_firmware_direct(&firmware, MLXSW_SP_FW_FILENAME,
mlxsw_sp->bus_info->dev);
if (err) {
dev_err(mlxsw_sp->bus_info->dev, "Could not request firmware file %s\n",
MLXSW_SP_FW_FILENAME);
return err;
}
err = mlxfw_firmware_flash(&mlxsw_sp_mlxfw_dev.mlxfw_dev, firmware);
release_firmware(firmware);
return err;
}
int mlxsw_sp_flow_counter_get(struct mlxsw_sp *mlxsw_sp, int mlxsw_sp_flow_counter_get(struct mlxsw_sp *mlxsw_sp,
unsigned int counter_index, u64 *packets, unsigned int counter_index, u64 *packets,
u64 *bytes) u64 *bytes)
...@@ -3393,6 +3619,12 @@ static int mlxsw_sp_init(struct mlxsw_core *mlxsw_core, ...@@ -3393,6 +3619,12 @@ static int mlxsw_sp_init(struct mlxsw_core *mlxsw_core,
INIT_LIST_HEAD(&mlxsw_sp->fids); INIT_LIST_HEAD(&mlxsw_sp->fids);
INIT_LIST_HEAD(&mlxsw_sp->vfids.list); INIT_LIST_HEAD(&mlxsw_sp->vfids.list);
err = mlxsw_sp_fw_rev_validate(mlxsw_sp);
if (err) {
dev_err(mlxsw_sp->bus_info->dev, "Could not upgrade firmware\n");
return err;
}
err = mlxsw_sp_base_mac_get(mlxsw_sp); err = mlxsw_sp_base_mac_get(mlxsw_sp);
if (err) { if (err) {
dev_err(mlxsw_sp->bus_info->dev, "Failed to get base mac\n"); dev_err(mlxsw_sp->bus_info->dev, "Failed to get base mac\n");
...@@ -4764,3 +4996,4 @@ MODULE_LICENSE("Dual BSD/GPL"); ...@@ -4764,3 +4996,4 @@ MODULE_LICENSE("Dual BSD/GPL");
MODULE_AUTHOR("Jiri Pirko <jiri@mellanox.com>"); MODULE_AUTHOR("Jiri Pirko <jiri@mellanox.com>");
MODULE_DESCRIPTION("Mellanox Spectrum driver"); MODULE_DESCRIPTION("Mellanox Spectrum driver");
MODULE_DEVICE_TABLE(pci, mlxsw_sp_pci_id_table); MODULE_DEVICE_TABLE(pci, mlxsw_sp_pci_id_table);
MODULE_FIRMWARE(MLXSW_SP_FW_FILENAME);
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include <linux/notifier.h> #include <linux/notifier.h>
#include <linux/inetdevice.h> #include <linux/inetdevice.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/if_bridge.h>
#include <net/netevent.h> #include <net/netevent.h>
#include <net/neighbour.h> #include <net/neighbour.h>
#include <net/arp.h> #include <net/arp.h>
...@@ -3109,7 +3110,9 @@ static int mlxsw_sp_vport_rif_sp_join(struct mlxsw_sp_port *mlxsw_sp_vport, ...@@ -3109,7 +3110,9 @@ static int mlxsw_sp_vport_rif_sp_join(struct mlxsw_sp_port *mlxsw_sp_vport,
struct net_device *l3_dev) struct net_device *l3_dev)
{ {
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_vport->mlxsw_sp; struct mlxsw_sp *mlxsw_sp = mlxsw_sp_vport->mlxsw_sp;
u16 vid = mlxsw_sp_vport_vid_get(mlxsw_sp_vport);
struct mlxsw_sp_rif *rif; struct mlxsw_sp_rif *rif;
int err;
rif = mlxsw_sp_rif_find_by_dev(mlxsw_sp, l3_dev); rif = mlxsw_sp_rif_find_by_dev(mlxsw_sp, l3_dev);
if (!rif) { if (!rif) {
...@@ -3118,20 +3121,39 @@ static int mlxsw_sp_vport_rif_sp_join(struct mlxsw_sp_port *mlxsw_sp_vport, ...@@ -3118,20 +3121,39 @@ static int mlxsw_sp_vport_rif_sp_join(struct mlxsw_sp_port *mlxsw_sp_vport,
return PTR_ERR(rif); return PTR_ERR(rif);
} }
err = mlxsw_sp_port_vid_learning_set(mlxsw_sp_vport, vid, false);
if (err)
goto err_port_vid_learning_set;
err = mlxsw_sp_port_vid_stp_set(mlxsw_sp_vport, vid,
BR_STATE_FORWARDING);
if (err)
goto err_port_vid_stp_set;
mlxsw_sp_vport_fid_set(mlxsw_sp_vport, rif->f); mlxsw_sp_vport_fid_set(mlxsw_sp_vport, rif->f);
rif->f->ref_count++; rif->f->ref_count++;
netdev_dbg(mlxsw_sp_vport->dev, "Joined FID=%d\n", rif->f->fid); netdev_dbg(mlxsw_sp_vport->dev, "Joined FID=%d\n", rif->f->fid);
return 0; return 0;
err_port_vid_stp_set:
mlxsw_sp_port_vid_learning_set(mlxsw_sp_vport, vid, true);
err_port_vid_learning_set:
if (rif->f->ref_count == 0)
mlxsw_sp_vport_rif_sp_destroy(mlxsw_sp_vport, rif);
return err;
} }
static void mlxsw_sp_vport_rif_sp_leave(struct mlxsw_sp_port *mlxsw_sp_vport) static void mlxsw_sp_vport_rif_sp_leave(struct mlxsw_sp_port *mlxsw_sp_vport)
{ {
struct mlxsw_sp_fid *f = mlxsw_sp_vport_fid_get(mlxsw_sp_vport); struct mlxsw_sp_fid *f = mlxsw_sp_vport_fid_get(mlxsw_sp_vport);
u16 vid = mlxsw_sp_vport_vid_get(mlxsw_sp_vport);
netdev_dbg(mlxsw_sp_vport->dev, "Left FID=%d\n", f->fid); netdev_dbg(mlxsw_sp_vport->dev, "Left FID=%d\n", f->fid);
mlxsw_sp_port_vid_stp_set(mlxsw_sp_vport, vid, BR_STATE_BLOCKING);
mlxsw_sp_port_vid_learning_set(mlxsw_sp_vport, vid, true);
mlxsw_sp_vport_fid_set(mlxsw_sp_vport, NULL); mlxsw_sp_vport_fid_set(mlxsw_sp_vport, NULL);
if (--f->ref_count == 0) if (--f->ref_count == 0)
mlxsw_sp_vport_rif_sp_destroy(mlxsw_sp_vport, f->rif); mlxsw_sp_vport_rif_sp_destroy(mlxsw_sp_vport, f->rif);
......
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