Commit 8b965f3f authored by Arjun Vynipadath's avatar Arjun Vynipadath Committed by David S. Miller

cxgb4: Add VF Link state support

Use ndo_set_vf_link_state to control the link states associated
with the virtual interfaces.
Signed-off-by: default avatarArjun Vynipadath <arjun@chelsio.com>
Signed-off-by: default avatarVishal Kulkarni <vishal@chelsio.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3d78bfaa
...@@ -885,6 +885,7 @@ struct vf_info { ...@@ -885,6 +885,7 @@ struct vf_info {
unsigned int tx_rate; unsigned int tx_rate;
bool pf_set_mac; bool pf_set_mac;
u16 vlan; u16 vlan;
int link_state;
}; };
enum { enum {
......
...@@ -2740,6 +2740,7 @@ static int cxgb4_mgmt_get_vf_config(struct net_device *dev, ...@@ -2740,6 +2740,7 @@ static int cxgb4_mgmt_get_vf_config(struct net_device *dev,
ivi->min_tx_rate = 0; ivi->min_tx_rate = 0;
ether_addr_copy(ivi->mac, vfinfo->vf_mac_addr); ether_addr_copy(ivi->mac, vfinfo->vf_mac_addr);
ivi->vlan = vfinfo->vlan; ivi->vlan = vfinfo->vlan;
ivi->linkstate = vfinfo->link_state;
return 0; return 0;
} }
...@@ -2879,6 +2880,49 @@ static int cxgb4_mgmt_set_vf_vlan(struct net_device *dev, int vf, ...@@ -2879,6 +2880,49 @@ static int cxgb4_mgmt_set_vf_vlan(struct net_device *dev, int vf,
ret, (vlan ? "setting" : "clearing"), adap->pf, vf); ret, (vlan ? "setting" : "clearing"), adap->pf, vf);
return ret; return ret;
} }
static int cxgb4_mgmt_set_vf_link_state(struct net_device *dev, int vf,
int link)
{
struct port_info *pi = netdev_priv(dev);
struct adapter *adap = pi->adapter;
u32 param, val;
int ret = 0;
if (vf >= adap->num_vfs)
return -EINVAL;
switch (link) {
case IFLA_VF_LINK_STATE_AUTO:
val = FW_VF_LINK_STATE_AUTO;
break;
case IFLA_VF_LINK_STATE_ENABLE:
val = FW_VF_LINK_STATE_ENABLE;
break;
case IFLA_VF_LINK_STATE_DISABLE:
val = FW_VF_LINK_STATE_DISABLE;
break;
default:
return -EINVAL;
}
param = (FW_PARAMS_MNEM_V(FW_PARAMS_MNEM_PFVF) |
FW_PARAMS_PARAM_X_V(FW_PARAMS_PARAM_PFVF_LINK_STATE));
ret = t4_set_params(adap, adap->mbox, adap->pf, vf + 1, 1,
&param, &val);
if (ret) {
dev_err(adap->pdev_dev,
"Error %d in setting PF %d VF %d link state\n",
ret, adap->pf, vf);
return -EINVAL;
}
adap->vfinfo[vf].link_state = link;
return ret;
}
#endif /* CONFIG_PCI_IOV */ #endif /* CONFIG_PCI_IOV */
static int cxgb_set_mac_addr(struct net_device *dev, void *p) static int cxgb_set_mac_addr(struct net_device *dev, void *p)
...@@ -3300,6 +3344,7 @@ static const struct net_device_ops cxgb4_mgmt_netdev_ops = { ...@@ -3300,6 +3344,7 @@ static const struct net_device_ops cxgb4_mgmt_netdev_ops = {
.ndo_set_vf_rate = cxgb4_mgmt_set_vf_rate, .ndo_set_vf_rate = cxgb4_mgmt_set_vf_rate,
.ndo_get_phys_port_id = cxgb4_mgmt_get_phys_port_id, .ndo_get_phys_port_id = cxgb4_mgmt_get_phys_port_id,
.ndo_set_vf_vlan = cxgb4_mgmt_set_vf_vlan, .ndo_set_vf_vlan = cxgb4_mgmt_set_vf_vlan,
.ndo_set_vf_link_state = cxgb4_mgmt_set_vf_link_state,
}; };
#endif #endif
......
...@@ -1312,6 +1312,14 @@ enum fw_params_param_pfvf { ...@@ -1312,6 +1312,14 @@ enum fw_params_param_pfvf {
FW_PARAMS_PARAM_PFVF_RAWF_END = 0x37, FW_PARAMS_PARAM_PFVF_RAWF_END = 0x37,
FW_PARAMS_PARAM_PFVF_NCRYPTO_LOOKASIDE = 0x39, FW_PARAMS_PARAM_PFVF_NCRYPTO_LOOKASIDE = 0x39,
FW_PARAMS_PARAM_PFVF_PORT_CAPS32 = 0x3A, FW_PARAMS_PARAM_PFVF_PORT_CAPS32 = 0x3A,
FW_PARAMS_PARAM_PFVF_LINK_STATE = 0x40,
};
/* Virtual link state as seen by the specified VF */
enum vf_link_states {
FW_VF_LINK_STATE_AUTO = 0x00,
FW_VF_LINK_STATE_ENABLE = 0x01,
FW_VF_LINK_STATE_DISABLE = 0x02,
}; };
/* /*
......
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