All drivers which implement the devlink flash update support, with the exception of netdevsim, use either request_firmware or request_firmware_direct to locate the firmware file. Rather than having each driver do this separately as part of its .flash_update implementation, perform the request_firmware within net/core/devlink.c Replace the file_name parameter in the struct devlink_flash_update_params with a pointer to the fw object. Use request_firmware rather than request_firmware_direct. Although most Linux distributions today do not have the fallback mechanism implemented, only about half the drivers used the _direct request, as compared to the generic request_firmware. In the event that a distribution does support the fallback mechanism, the devlink flash update ought to be able to use it to provide the firmware contents. For distributions which do not support the fallback userspace mechanism, there should be essentially no difference between request_firmware and request_firmware_direct. Signed-off-by: Jacob Keller <jacob.e.keller@intel.com> Acked-by: Shannon Nelson <snelson@pensando.io> Acked-by: Vasundhara Volam <vasundhara-v.volam@broadcom.com> Reviewed-by: Jiri Pirko <jiri@nvidia.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
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->fw, 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);
|
|
}
|