Skip to content

Commit f43e3be

Browse files
praczynsanguy11
authored andcommitted
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 <[email protected]> Reviewed-by: Jiri Pirko <[email protected]> Signed-off-by: Piotr Raczynski <[email protected]> Signed-off-by: Michal Swiatkowski <[email protected]> Tested-by: Rafal Romanowski <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent 747967b commit f43e3be

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

drivers/net/ethernet/intel/ice/devlink/devlink.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "ice_eswitch.h"
1111
#include "ice_fw_update.h"
1212
#include "ice_dcb_lib.h"
13+
#include "ice_sf_eth.h"
1314

1415
/* context for devlink info version reporting */
1516
struct ice_info_ctx {
@@ -1282,6 +1283,8 @@ static const struct devlink_ops ice_devlink_ops = {
12821283
.port_new = ice_devlink_port_new,
12831284
};
12841285

1286+
static const struct devlink_ops ice_sf_devlink_ops;
1287+
12851288
static int
12861289
ice_devlink_enable_roce_get(struct devlink *devlink, u32 id,
12871290
struct devlink_param_gset_ctx *ctx)
@@ -1564,6 +1567,34 @@ struct ice_pf *ice_allocate_pf(struct device *dev)
15641567
return devlink_priv(devlink);
15651568
}
15661569

1570+
/**
1571+
* ice_allocate_sf - Allocate devlink and return SF structure pointer
1572+
* @dev: the device to allocate for
1573+
* @pf: pointer to the PF structure
1574+
*
1575+
* Allocate a devlink instance for SF.
1576+
*
1577+
* Return: ice_sf_priv pointer to allocated memory or ERR_PTR in case of error
1578+
*/
1579+
struct ice_sf_priv *ice_allocate_sf(struct device *dev, struct ice_pf *pf)
1580+
{
1581+
struct devlink *devlink;
1582+
int err;
1583+
1584+
devlink = devlink_alloc(&ice_sf_devlink_ops, sizeof(struct ice_sf_priv),
1585+
dev);
1586+
if (!devlink)
1587+
return ERR_PTR(-ENOMEM);
1588+
1589+
err = devl_nested_devlink_set(priv_to_devlink(pf), devlink);
1590+
if (err) {
1591+
devlink_free(devlink);
1592+
return ERR_PTR(err);
1593+
}
1594+
1595+
return devlink_priv(devlink);
1596+
}
1597+
15671598
/**
15681599
* ice_devlink_register - Register devlink interface for this PF
15691600
* @pf: the PF to register the devlink for.

drivers/net/ethernet/intel/ice/devlink/devlink.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#define _ICE_DEVLINK_H_
66

77
struct ice_pf *ice_allocate_pf(struct device *dev);
8+
struct ice_sf_priv *ice_allocate_sf(struct device *dev, struct ice_pf *pf);
89

910
void ice_devlink_register(struct ice_pf *pf);
1011
void ice_devlink_unregister(struct ice_pf *pf);
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/* Copyright (c) 2024, Intel Corporation. */
3+
4+
#ifndef _ICE_SF_ETH_H_
5+
#define _ICE_SF_ETH_H_
6+
7+
#include <linux/auxiliary_bus.h>
8+
#include "ice.h"
9+
10+
struct ice_sf_priv {
11+
struct ice_sf_dev *dev;
12+
struct devlink_port devlink_port;
13+
};
14+
15+
#endif /* _ICE_SF_ETH_H_ */

0 commit comments

Comments
 (0)