|
10 | 10 | #include "ice_eswitch.h" |
11 | 11 | #include "ice_fw_update.h" |
12 | 12 | #include "ice_dcb_lib.h" |
| 13 | +#include "ice_sf_eth.h" |
13 | 14 |
|
14 | 15 | /* context for devlink info version reporting */ |
15 | 16 | struct ice_info_ctx { |
@@ -1282,6 +1283,8 @@ static const struct devlink_ops ice_devlink_ops = { |
1282 | 1283 | .port_new = ice_devlink_port_new, |
1283 | 1284 | }; |
1284 | 1285 |
|
| 1286 | +static const struct devlink_ops ice_sf_devlink_ops; |
| 1287 | + |
1285 | 1288 | static int |
1286 | 1289 | ice_devlink_enable_roce_get(struct devlink *devlink, u32 id, |
1287 | 1290 | struct devlink_param_gset_ctx *ctx) |
@@ -1564,6 +1567,34 @@ struct ice_pf *ice_allocate_pf(struct device *dev) |
1564 | 1567 | return devlink_priv(devlink); |
1565 | 1568 | } |
1566 | 1569 |
|
| 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 | + |
1567 | 1598 | /** |
1568 | 1599 | * ice_devlink_register - Register devlink interface for this PF |
1569 | 1600 | * @pf: the PF to register the devlink for. |
|
0 commit comments