Commit 23e884a2 authored by Shannon Nelson's avatar Shannon Nelson Committed by Jakub Kicinski

ionic: only save the user set VF attributes

Report the current FW values for the VF attributes, but don't
save the FW values locally, only save the vf attributes that
are given to us from the user.  This allows us to replay user
data, and doesn't end up confusing things like "who set the
mac address".
Signed-off-by: default avatarShannon Nelson <snelson@pensando.io>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent db28adf9
......@@ -2220,7 +2220,7 @@ static int ionic_eth_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd
}
}
static int ionic_update_cached_vf_config(struct ionic *ionic, int vf)
static int ionic_get_fw_vf_config(struct ionic *ionic, int vf, struct ionic_vf *vfdata)
{
struct ionic_vf_getattr_comp comp = { 0 };
int err;
......@@ -2231,14 +2231,14 @@ static int ionic_update_cached_vf_config(struct ionic *ionic, int vf)
if (err && comp.status != IONIC_RC_ENOSUPP)
goto err_out;
if (!err)
ionic->vfs[vf].vlanid = comp.vlanid;
vfdata->vlanid = comp.vlanid;
attr = IONIC_VF_ATTR_SPOOFCHK;
err = ionic_dev_cmd_vf_getattr(ionic, vf, attr, &comp);
if (err && comp.status != IONIC_RC_ENOSUPP)
goto err_out;
if (!err)
ionic->vfs[vf].spoofchk = comp.spoofchk;
vfdata->spoofchk = comp.spoofchk;
attr = IONIC_VF_ATTR_LINKSTATE;
err = ionic_dev_cmd_vf_getattr(ionic, vf, attr, &comp);
......@@ -2247,13 +2247,13 @@ static int ionic_update_cached_vf_config(struct ionic *ionic, int vf)
if (!err) {
switch (comp.linkstate) {
case IONIC_VF_LINK_STATUS_UP:
ionic->vfs[vf].linkstate = IFLA_VF_LINK_STATE_ENABLE;
vfdata->linkstate = IFLA_VF_LINK_STATE_ENABLE;
break;
case IONIC_VF_LINK_STATUS_DOWN:
ionic->vfs[vf].linkstate = IFLA_VF_LINK_STATE_DISABLE;
vfdata->linkstate = IFLA_VF_LINK_STATE_DISABLE;
break;
case IONIC_VF_LINK_STATUS_AUTO:
ionic->vfs[vf].linkstate = IFLA_VF_LINK_STATE_AUTO;
vfdata->linkstate = IFLA_VF_LINK_STATE_AUTO;
break;
default:
dev_warn(ionic->dev, "Unexpected link state %u\n", comp.linkstate);
......@@ -2266,21 +2266,21 @@ static int ionic_update_cached_vf_config(struct ionic *ionic, int vf)
if (err && comp.status != IONIC_RC_ENOSUPP)
goto err_out;
if (!err)
ionic->vfs[vf].maxrate = comp.maxrate;
vfdata->maxrate = comp.maxrate;
attr = IONIC_VF_ATTR_TRUST;
err = ionic_dev_cmd_vf_getattr(ionic, vf, attr, &comp);
if (err && comp.status != IONIC_RC_ENOSUPP)
goto err_out;
if (!err)
ionic->vfs[vf].trusted = comp.trust;
vfdata->trusted = comp.trust;
attr = IONIC_VF_ATTR_MAC;
err = ionic_dev_cmd_vf_getattr(ionic, vf, attr, &comp);
if (err && comp.status != IONIC_RC_ENOSUPP)
goto err_out;
if (!err)
ether_addr_copy(ionic->vfs[vf].macaddr, comp.macaddr);
ether_addr_copy(vfdata->macaddr, comp.macaddr);
err_out:
if (err)
......@@ -2295,6 +2295,7 @@ static int ionic_get_vf_config(struct net_device *netdev,
{
struct ionic_lif *lif = netdev_priv(netdev);
struct ionic *ionic = lif->ionic;
struct ionic_vf vfdata = { 0 };
int ret = 0;
if (!netif_device_present(netdev))
......@@ -2308,14 +2309,14 @@ static int ionic_get_vf_config(struct net_device *netdev,
ivf->vf = vf;
ivf->qos = 0;
ret = ionic_update_cached_vf_config(ionic, vf);
ret = ionic_get_fw_vf_config(ionic, vf, &vfdata);
if (!ret) {
ivf->vlan = le16_to_cpu(ionic->vfs[vf].vlanid);
ivf->spoofchk = ionic->vfs[vf].spoofchk;
ivf->linkstate = ionic->vfs[vf].linkstate;
ivf->max_tx_rate = le32_to_cpu(ionic->vfs[vf].maxrate);
ivf->trusted = ionic->vfs[vf].trusted;
ether_addr_copy(ivf->mac, ionic->vfs[vf].macaddr);
ivf->vlan = le16_to_cpu(vfdata.vlanid);
ivf->spoofchk = vfdata.spoofchk;
ivf->linkstate = vfdata.linkstate;
ivf->max_tx_rate = le32_to_cpu(vfdata.maxrate);
ivf->trusted = vfdata.trusted;
ether_addr_copy(ivf->mac, vfdata.macaddr);
}
}
......
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