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

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
Loading
Loading
Loading
Loading
+31 −0
Original line number Diff line number Diff line
@@ -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.
+1 −0
Original line number Diff line number Diff line
@@ -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);
+15 −0
Original line number Diff line number Diff line
/* 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_ */