The devlink core recently gained support for checking whether the driver supports a flash_update parameter, via `supported_flash_update_params`. However, parameters are specified as function arguments. Adding a new parameter still requires modifying the signature of the .flash_update callback in all drivers. Convert the .flash_update function to take a new `struct devlink_flash_update_params` instead. By using this structure, and the `supported_flash_update_params` bit field, a new parameter to flash_update can be added without requiring modification to existing drivers. As before, all parameters except file_name will require driver opt-in. Because file_name is a necessary field to for the flash_update to make sense, no "SUPPORTED" bitflag is provided and it is always considered valid. All future additional parameters will require a new bit in the supported_flash_update_params bitfield. Signed-off-by: Jacob Keller <jacob.e.keller@intel.com> Reviewed-by: Jakub Kicinski <kuba@kernel.org> Cc: Jiri Pirko <jiri@mellanox.com> Cc: Jakub Kicinski <kuba@kernel.org> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Michael Chan <michael.chan@broadcom.com> Cc: Bin Luo <luobin9@huawei.com> Cc: Saeed Mahameed <saeedm@mellanox.com> Cc: Leon Romanovsky <leon@kernel.org> Cc: Ido Schimmel <idosch@mellanox.com> Cc: Danielle Ratson <danieller@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
111 lines
2.6 KiB
C
111 lines
2.6 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/* Copyright(c) 2017 - 2019 Pensando Systems, Inc */
|
|
|
|
#include <linux/module.h>
|
|
#include <linux/netdevice.h>
|
|
|
|
#include "ionic.h"
|
|
#include "ionic_bus.h"
|
|
#include "ionic_lif.h"
|
|
#include "ionic_devlink.h"
|
|
|
|
static int ionic_dl_flash_update(struct devlink *dl,
|
|
struct devlink_flash_update_params *params,
|
|
struct netlink_ext_ack *extack)
|
|
{
|
|
struct ionic *ionic = devlink_priv(dl);
|
|
|
|
return ionic_firmware_update(ionic->lif, params->file_name, extack);
|
|
}
|
|
|
|
static int ionic_dl_info_get(struct devlink *dl, struct devlink_info_req *req,
|
|
struct netlink_ext_ack *extack)
|
|
{
|
|
struct ionic *ionic = devlink_priv(dl);
|
|
struct ionic_dev *idev = &ionic->idev;
|
|
char buf[16];
|
|
int err = 0;
|
|
|
|
err = devlink_info_driver_name_put(req, IONIC_DRV_NAME);
|
|
if (err)
|
|
return err;
|
|
|
|
err = devlink_info_version_running_put(req,
|
|
DEVLINK_INFO_VERSION_GENERIC_FW,
|
|
idev->dev_info.fw_version);
|
|
if (err)
|
|
return err;
|
|
|
|
snprintf(buf, sizeof(buf), "0x%x", idev->dev_info.asic_type);
|
|
err = devlink_info_version_fixed_put(req,
|
|
DEVLINK_INFO_VERSION_GENERIC_ASIC_ID,
|
|
buf);
|
|
if (err)
|
|
return err;
|
|
|
|
snprintf(buf, sizeof(buf), "0x%x", idev->dev_info.asic_rev);
|
|
err = devlink_info_version_fixed_put(req,
|
|
DEVLINK_INFO_VERSION_GENERIC_ASIC_REV,
|
|
buf);
|
|
if (err)
|
|
return err;
|
|
|
|
err = devlink_info_serial_number_put(req, idev->dev_info.serial_num);
|
|
|
|
return err;
|
|
}
|
|
|
|
static const struct devlink_ops ionic_dl_ops = {
|
|
.info_get = ionic_dl_info_get,
|
|
.flash_update = ionic_dl_flash_update,
|
|
};
|
|
|
|
struct ionic *ionic_devlink_alloc(struct device *dev)
|
|
{
|
|
struct devlink *dl;
|
|
|
|
dl = devlink_alloc(&ionic_dl_ops, sizeof(struct ionic));
|
|
|
|
return devlink_priv(dl);
|
|
}
|
|
|
|
void ionic_devlink_free(struct ionic *ionic)
|
|
{
|
|
struct devlink *dl = priv_to_devlink(ionic);
|
|
|
|
devlink_free(dl);
|
|
}
|
|
|
|
int ionic_devlink_register(struct ionic *ionic)
|
|
{
|
|
struct devlink *dl = priv_to_devlink(ionic);
|
|
struct devlink_port_attrs attrs = {};
|
|
int err;
|
|
|
|
err = devlink_register(dl, ionic->dev);
|
|
if (err) {
|
|
dev_warn(ionic->dev, "devlink_register failed: %d\n", err);
|
|
return err;
|
|
}
|
|
|
|
attrs.flavour = DEVLINK_PORT_FLAVOUR_PHYSICAL;
|
|
devlink_port_attrs_set(&ionic->dl_port, &attrs);
|
|
err = devlink_port_register(dl, &ionic->dl_port, 0);
|
|
if (err)
|
|
dev_err(ionic->dev, "devlink_port_register failed: %d\n", err);
|
|
else
|
|
devlink_port_type_eth_set(&ionic->dl_port,
|
|
ionic->lif->netdev);
|
|
|
|
return err;
|
|
}
|
|
|
|
void ionic_devlink_unregister(struct ionic *ionic)
|
|
{
|
|
struct devlink *dl = priv_to_devlink(ionic);
|
|
|
|
if (ionic->dl_port.registered)
|
|
devlink_port_unregister(&ionic->dl_port);
|
|
devlink_unregister(dl);
|
|
}
|