Commit f43e3be6 authored by Piotr Raczynski's avatar Piotr Raczynski Committed by Tony Nguyen

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: default avatarPrzemek Kitszel <przemyslaw.kitszel@intel.com>
Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
Signed-off-by: default avatarPiotr Raczynski <piotr.raczynski@intel.com>
Signed-off-by: default avatarMichal Swiatkowski <michal.swiatkowski@linux.intel.com>
Tested-by: default avatarRafal Romanowski <rafal.romanowski@intel.com>
Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
parent 747967b0
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "ice_eswitch.h" #include "ice_eswitch.h"
#include "ice_fw_update.h" #include "ice_fw_update.h"
#include "ice_dcb_lib.h" #include "ice_dcb_lib.h"
#include "ice_sf_eth.h"
/* context for devlink info version reporting */ /* context for devlink info version reporting */
struct ice_info_ctx { struct ice_info_ctx {
...@@ -1282,6 +1283,8 @@ static const struct devlink_ops ice_devlink_ops = { ...@@ -1282,6 +1283,8 @@ static const struct devlink_ops ice_devlink_ops = {
.port_new = ice_devlink_port_new, .port_new = ice_devlink_port_new,
}; };
static const struct devlink_ops ice_sf_devlink_ops;
static int static int
ice_devlink_enable_roce_get(struct devlink *devlink, u32 id, ice_devlink_enable_roce_get(struct devlink *devlink, u32 id,
struct devlink_param_gset_ctx *ctx) struct devlink_param_gset_ctx *ctx)
...@@ -1564,6 +1567,34 @@ struct ice_pf *ice_allocate_pf(struct device *dev) ...@@ -1564,6 +1567,34 @@ struct ice_pf *ice_allocate_pf(struct device *dev)
return devlink_priv(devlink); 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 * ice_devlink_register - Register devlink interface for this PF
* @pf: the PF to register the devlink for. * @pf: the PF to register the devlink for.
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#define _ICE_DEVLINK_H_ #define _ICE_DEVLINK_H_
struct ice_pf *ice_allocate_pf(struct device *dev); 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_register(struct ice_pf *pf);
void ice_devlink_unregister(struct ice_pf *pf); void ice_devlink_unregister(struct ice_pf *pf);
......
/* 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_ */
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