nfp: flower: change get/set_eeprom logic and enable for flower reps
The changes in this patch are as follows: - Alter the logic of get/set_eeprom functions to use the helper function nfp_app_from_netdev() which handles differentiating between an nfp_net and a nfp_repr. This allows us to get an agnostic backpointer to the pdev. - Enable the various eeprom commands by adding the 'get_eeprom_len', 'get_eeprom', 'set_eeprom' callbacks to the nfp_port_ethtool_ops struct. This allows the eeprom commands to work on representor interfaces, similar to a previous patch which added it to the vnics. Currently these are being used to configure persistent MAC addresses for the physical ports on the nfp. Signed-off-by: James Hershaw <james.hershaw@corigine.com> Reviewed-by: Louis Peens <louis.peens@corigine.com> Signed-off-by: Simon Horman <simon.horman@corigine.com> Link: https://lore.kernel.org/r/20230123134135.293278-1-simon.horman@corigine.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
90317bcdbd
commit
74b4f1739d
1 changed files with 7 additions and 4 deletions
|
@ -1905,7 +1905,7 @@ static int
|
||||||
nfp_net_get_eeprom(struct net_device *netdev,
|
nfp_net_get_eeprom(struct net_device *netdev,
|
||||||
struct ethtool_eeprom *eeprom, u8 *bytes)
|
struct ethtool_eeprom *eeprom, u8 *bytes)
|
||||||
{
|
{
|
||||||
struct nfp_net *nn = netdev_priv(netdev);
|
struct nfp_app *app = nfp_app_from_netdev(netdev);
|
||||||
u8 buf[NFP_EEPROM_LEN] = {};
|
u8 buf[NFP_EEPROM_LEN] = {};
|
||||||
|
|
||||||
if (eeprom->len == 0)
|
if (eeprom->len == 0)
|
||||||
|
@ -1914,7 +1914,7 @@ nfp_net_get_eeprom(struct net_device *netdev,
|
||||||
if (nfp_net_get_port_mac_by_hwinfo(netdev, buf))
|
if (nfp_net_get_port_mac_by_hwinfo(netdev, buf))
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
|
|
||||||
eeprom->magic = nn->pdev->vendor | (nn->pdev->device << 16);
|
eeprom->magic = app->pdev->vendor | (app->pdev->device << 16);
|
||||||
memcpy(bytes, buf + eeprom->offset, eeprom->len);
|
memcpy(bytes, buf + eeprom->offset, eeprom->len);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1924,13 +1924,13 @@ static int
|
||||||
nfp_net_set_eeprom(struct net_device *netdev,
|
nfp_net_set_eeprom(struct net_device *netdev,
|
||||||
struct ethtool_eeprom *eeprom, u8 *bytes)
|
struct ethtool_eeprom *eeprom, u8 *bytes)
|
||||||
{
|
{
|
||||||
struct nfp_net *nn = netdev_priv(netdev);
|
struct nfp_app *app = nfp_app_from_netdev(netdev);
|
||||||
u8 buf[NFP_EEPROM_LEN] = {};
|
u8 buf[NFP_EEPROM_LEN] = {};
|
||||||
|
|
||||||
if (eeprom->len == 0)
|
if (eeprom->len == 0)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (eeprom->magic != (nn->pdev->vendor | nn->pdev->device << 16))
|
if (eeprom->magic != (app->pdev->vendor | app->pdev->device << 16))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (nfp_net_get_port_mac_by_hwinfo(netdev, buf))
|
if (nfp_net_get_port_mac_by_hwinfo(netdev, buf))
|
||||||
|
@ -1995,6 +1995,9 @@ const struct ethtool_ops nfp_port_ethtool_ops = {
|
||||||
.set_dump = nfp_app_set_dump,
|
.set_dump = nfp_app_set_dump,
|
||||||
.get_dump_flag = nfp_app_get_dump_flag,
|
.get_dump_flag = nfp_app_get_dump_flag,
|
||||||
.get_dump_data = nfp_app_get_dump_data,
|
.get_dump_data = nfp_app_get_dump_data,
|
||||||
|
.get_eeprom_len = nfp_net_get_eeprom_len,
|
||||||
|
.get_eeprom = nfp_net_get_eeprom,
|
||||||
|
.set_eeprom = nfp_net_set_eeprom,
|
||||||
.get_module_info = nfp_port_get_module_info,
|
.get_module_info = nfp_port_get_module_info,
|
||||||
.get_module_eeprom = nfp_port_get_module_eeprom,
|
.get_module_eeprom = nfp_port_get_module_eeprom,
|
||||||
.get_link_ksettings = nfp_net_get_link_ksettings,
|
.get_link_ksettings = nfp_net_get_link_ksettings,
|
||||||
|
|
Loading…
Add table
Reference in a new issue