ice: allocate devlink for subfunction

Allocate devlink for subfunction instance.

Create header file for subfunction device. Define subfunction device
structure there as it is needed for devlink allocation.

Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: Piotr Raczynski <piotr.raczynski@intel.com>
Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
Tested-by: Rafal Romanowski <rafal.romanowski@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
This commit is contained in:
Piotr Raczynski 2024-08-20 08:57:50 +02:00 committed by Tony Nguyen
parent 747967b0bb
commit f43e3be662
3 changed files with 47 additions and 0 deletions

View File

@ -10,6 +10,7 @@
#include "ice_eswitch.h"
#include "ice_fw_update.h"
#include "ice_dcb_lib.h"
#include "ice_sf_eth.h"
/* context for devlink info version reporting */
struct ice_info_ctx {
@ -1282,6 +1283,8 @@ static const struct devlink_ops ice_devlink_ops = {
.port_new = ice_devlink_port_new,
};
static const struct devlink_ops ice_sf_devlink_ops;
static int
ice_devlink_enable_roce_get(struct devlink *devlink, u32 id,
struct devlink_param_gset_ctx *ctx)
@ -1564,6 +1567,34 @@ struct ice_pf *ice_allocate_pf(struct device *dev)
return devlink_priv(devlink);
}
/**
* ice_allocate_sf - Allocate devlink and return SF structure pointer
* @dev: the device to allocate for
* @pf: pointer to the PF structure
*
* Allocate a devlink instance for SF.
*
* Return: ice_sf_priv pointer to allocated memory or ERR_PTR in case of error
*/
struct ice_sf_priv *ice_allocate_sf(struct device *dev, struct ice_pf *pf)
{
struct devlink *devlink;
int err;
devlink = devlink_alloc(&ice_sf_devlink_ops, sizeof(struct ice_sf_priv),
dev);
if (!devlink)
return ERR_PTR(-ENOMEM);
err = devl_nested_devlink_set(priv_to_devlink(pf), devlink);
if (err) {
devlink_free(devlink);
return ERR_PTR(err);
}
return devlink_priv(devlink);
}
/**
* ice_devlink_register - Register devlink interface for this PF
* @pf: the PF to register the devlink for.

View File

@ -5,6 +5,7 @@
#define _ICE_DEVLINK_H_
struct ice_pf *ice_allocate_pf(struct device *dev);
struct ice_sf_priv *ice_allocate_sf(struct device *dev, struct ice_pf *pf);
void ice_devlink_register(struct ice_pf *pf);
void ice_devlink_unregister(struct ice_pf *pf);

View File

@ -0,0 +1,15 @@
/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright (c) 2024, Intel Corporation. */
#ifndef _ICE_SF_ETH_H_
#define _ICE_SF_ETH_H_
#include <linux/auxiliary_bus.h>
#include "ice.h"
struct ice_sf_priv {
struct ice_sf_dev *dev;
struct devlink_port devlink_port;
};
#endif /* _ICE_SF_ETH_H_ */