History

net-next:v4: Add support to configure SR-IOV VF minimum and maximum Tx rate through ip tool.

o min_tx_rate puts lower limit on the VF bandwidth. VF is guaranteed to have a bandwidth of at least this value. max_tx_rate puts cap on the VF bandwidth. VF can have a bandwidth of up to this value. o A new handler set_vf_rate for attr IFLA_VF_RATE has been introduced which takes 4 arguments: netdev, VF number, min_tx_rate, max_tx_rate o ndo_set_vf_rate replaces ndo_set_vf_tx_rate handler. o Drivers that currently implement ndo_set_vf_tx_rate should now call ndo_set_vf_rate instead and reject attempt to set a minimum bandwidth greater than 0 for IFLA_VF_TX_RATE when IFLA_VF_RATE is not yet implemented by driver. o If user enters only one of either min_tx_rate or max_tx_rate, then, userland should read back the other value from driver and set both for IFLA_VF_RATE. Drivers that have not yet implemented IFLA_VF_RATE should always return min_tx_rate as 0 when read from ip tool. o If both IFLA_VF_TX_RATE and IFLA_VF_RATE options are specified, then IFLA_VF_RATE should override. o Idea is to have consistent display of rate values to user. o Usage example: - ./ip link set p4p1 vf 0 rate 900 ./ip link show p4p1 32: p4p1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000 link/ether 00:0e:1e:08:b0:f0 brd ff:ff:ff:ff:ff:ff vf 0 MAC 3e:a0:ca:bd:ae:5a, tx rate 900 (Mbps), max_tx_rate 900Mbps vf 1 MAC f6:c6:7c:3f:3d:6c vf 2 MAC 56:32:43:98:d7:71 vf 3 MAC d6:be:c3:b5:85:ff vf 4 MAC ee:a9:9a:1e:19:14 vf 5 MAC 4a:d0:4c:07:52:18 vf 6 MAC 3a:76:44:93:62:f9 vf 7 MAC 82:e9:e7:e3:15:1a ./ip link set p4p1 vf 0 max_tx_rate 300 min_tx_rate 200 ./ip link show p4p1 32: p4p1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000 link/ether 00:0e:1e:08:b0:f0 brd ff:ff:ff:ff:ff:ff vf 0 MAC 3e:a0:ca:bd:ae:5a, tx rate 300 (Mbps), max_tx_rate 300Mbps, min_tx_rate 200Mbps vf 1 MAC f6:c6:7c:3f:3d:6c vf 2 MAC 56:32:43:98:d7:71 vf 3 MAC d6:be:c3:b5:85:ff vf 4 MAC ee:a9:9a:1e:19:14 vf 5 MAC 4a:d0:4c:07:52:18 vf 6 MAC 3a:76:44:93:62:f9 vf 7 MAC 82:e9:e7:e3:15:1a ./ip link set p4p1 vf 0 max_tx_rate 600 rate 300 ./ip link show p4p1 32: p4p1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT qlen 1000 link/ether 00:0e:1e:08:b0:f brd ff:ff:ff:ff:ff:ff vf 0 MAC 3e:a0:ca:bd:ae:5, tx rate 600 (Mbps), max_tx_rate 600Mbps, min_tx_rate 200Mbps vf 1 MAC f6:c6:7c:3f:3d:6c vf 2 MAC 56:32:43:98:d7:71 vf 3 MAC d6:be:c3:b5:85:ff vf 4 MAC ee:a9:9a:1e:19:14 vf 5 MAC 4a:d0:4c:07:52:18 vf 6 MAC 3a:76:44:93:62:f9 vf 7 MAC 82:e9:e7:e3:15:1a

Sucheta Chakraborty committed 12 years ago

Commit ed616681 parent 307f09920 files · +156 −67Browse files

Unified · Split

20 files
  1. drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c +2 −1
  2. drivers/net/ethernet/emulex/benet/be_main.c +13 −8
  3. drivers/net/ethernet/intel/i40e/i40e_main.c +1 −1
  4. drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +17 −9
  5. drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h +2 −1
  6. drivers/net/ethernet/intel/igb/igb_main.c +13 −7
  7. drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +1 −1
  8. drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c +9 −4
  9. drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.h +2 −1
  10. drivers/net/ethernet/mellanox/mlx4/cmd.c +6 −5
  11. drivers/net/ethernet/qlogic/qlcnic/qlcnic.h +1 −0
  12. drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +1 −1
  13. drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov.h +1 −1
  14. drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c +1 −0
  15. drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_pf.c +37 −15
  16. drivers/net/ethernet/sfc/siena_sriov.c +2 −1
  17. include/linux/if_link.h +2 −1
  18. include/linux/netdevice.h +5 −3
  19. include/uapi/linux/if_link.h +8 −1
  20. net/core/rtnetlink.c +32 −6
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c+2−1
@@ -2576,7 +2576,8 @@ int bnx2x_get_vf_config(struct net_device *dev, int vfidx, · 2575 unmodified lines
25762576
25772577 ivi->vf = vfidx;
25782578 ivi->qos = 0;
2579− ivi->tx_rate = 10000; /* always 10G. TBA take from link struct */
2579+ ivi->max_tx_rate = 10000; /* always 10G. TBA take from link struct */
2580+ ivi->min_tx_rate = 0;
25802581 ivi->spoofchk = 1; /*always enabled */
25812582 if (vf->state == VF_ENABLED) {
25822583 /* mac and vlan are in vlan_mac objects */
drivers/net/ethernet/emulex/benet/be_main.c+13−8
@@ -1302,7 +1302,8 @@ static int be_get_vf_config(struct net_device *netdev, int vf, · 1301 unmodified lines
13021302 return -EINVAL;
13031303
13041304 vi->vf = vf;
1305− vi->tx_rate = vf_cfg->tx_rate;
1305+ vi->max_tx_rate = vf_cfg->tx_rate;
1306+ vi->min_tx_rate = 0;
13061307 vi->vlan = vf_cfg->vlan_tag & VLAN_VID_MASK;
13071308 vi->qos = vf_cfg->vlan_tag >> VLAN_PRIO_SHIFT;
13081309 memcpy(&vi->mac, vf_cfg->mac_addr, ETH_ALEN);
@@ -1342,7 +1343,8 @@ static int be_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan, u8 qos) · 33 unmodified lines
13421343 return status;
13431344 }
13441345
1345−static int be_set_vf_tx_rate(struct net_device *netdev, int vf, int rate)
1346+static int be_set_vf_tx_rate(struct net_device *netdev, int vf,
1347+ int min_tx_rate, int max_tx_rate)
13461348 {
13471349 struct be_adapter *adapter = netdev_priv(netdev);
13481350 int status = 0;
@@ -1353,18 +1355,21 @@ static int be_set_vf_tx_rate(struct net_device *netdev, int vf, int rate) · 4 unmodified lines
13531355 if (vf >= adapter->num_vfs)
13541356 return -EINVAL;
13551357
1356− if (rate < 100 || rate > 10000) {
1358+ if (min_tx_rate)
1359+ return -EINVAL;
1360+
1361+ if (max_tx_rate < 100 || max_tx_rate > 10000) {
13571362 dev_err(&adapter->pdev->dev,
1358− "tx rate must be between 100 and 10000 Mbps\n");
1363+ "max tx rate must be between 100 and 10000 Mbps\n");
13591364 return -EINVAL;
13601365 }
13611366
1362− status = be_cmd_config_qos(adapter, rate / 10, vf + 1);
1367+ status = be_cmd_config_qos(adapter, max_tx_rate / 10, vf + 1);
13631368 if (status)
13641369 dev_err(&adapter->pdev->dev,
1365− "tx rate %d on VF %d failed\n", rate, vf);
1370+ "max tx rate %d on VF %d failed\n", max_tx_rate, vf);
13661371 else
1367− adapter->vf_cfg[vf].tx_rate = rate;
1372+ adapter->vf_cfg[vf].tx_rate = max_tx_rate;
13681373 return status;
13691374 }
13701375 static int be_set_vf_link_state(struct net_device *netdev, int vf,
@@ -4257,7 +4262,7 @@ static const struct net_device_ops be_netdev_ops = { · 2886 unmodified lines
42574262 .ndo_vlan_rx_kill_vid = be_vlan_rem_vid,
42584263 .ndo_set_vf_mac = be_set_vf_mac,
42594264 .ndo_set_vf_vlan = be_set_vf_vlan,
4260− .ndo_set_vf_tx_rate = be_set_vf_tx_rate,
4265+ .ndo_set_vf_rate = be_set_vf_tx_rate,
42614266 .ndo_get_vf_config = be_get_vf_config,
42624267 .ndo_set_vf_link_state = be_set_vf_link_state,
42634268 #ifdef CONFIG_NET_POLL_CONTROLLER
drivers/net/ethernet/intel/i40e/i40e_main.c+1−1
@@ -6724,7 +6724,7 @@ static const struct net_device_ops i40e_netdev_ops = { · 6723 unmodified lines
67246724 .ndo_set_features = i40e_set_features,
67256725 .ndo_set_vf_mac = i40e_ndo_set_vf_mac,
67266726 .ndo_set_vf_vlan = i40e_ndo_set_vf_port_vlan,
6727− .ndo_set_vf_tx_rate = i40e_ndo_set_vf_bw,
6727+ .ndo_set_vf_rate = i40e_ndo_set_vf_bw,
67286728 .ndo_get_vf_config = i40e_ndo_get_vf_config,
67296729 .ndo_set_vf_link_state = i40e_ndo_set_vf_link_state,
67306730 #ifdef CONFIG_I40E_VXLAN
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c+17−9
@@ -2205,7 +2205,8 @@ error_pvid: · 2204 unmodified lines
22052205 *
22062206 * configure vf tx rate
22072207 **/
2208−int i40e_ndo_set_vf_bw(struct net_device *netdev, int vf_id, int tx_rate)
2208+int i40e_ndo_set_vf_bw(struct net_device *netdev, int vf_id, int min_tx_rate,
2209+ int max_tx_rate)
22092210 {
22102211 struct i40e_netdev_priv *np = netdev_priv(netdev);
22112212 struct i40e_pf *pf = np->vsi->back;
@@ -2221,6 +2222,12 @@ int i40e_ndo_set_vf_bw(struct net_device *netdev, int vf_id, int tx_rate) · 9 unmodified lines
22212222 goto error;
22222223 }
22232224
2225+ if (min_tx_rate) {
2226+ dev_err(&pf->pdev->dev, "Invalid min tx rate (%d) (greater than 0) specified for vf %d.\n",
2227+ min_tx_rate, vf_id);
2228+ return -EINVAL;
2229+ }
2230+
22242231 vf = &(pf->vf[vf_id]);
22252232 vsi = pf->vsi[vf->lan_vsi_index];
22262233 if (!test_bit(I40E_VF_STAT_INIT, &vf->vf_states)) {
@@ -2243,23 +2250,23 @@ int i40e_ndo_set_vf_bw(struct net_device *netdev, int vf_id, int tx_rate) · 16 unmodified lines
22432250 break;
22442251 }
22452252
2246− if (tx_rate > speed) {
2247− dev_err(&pf->pdev->dev, "Invalid tx rate %d specified for vf %d.",
2248− tx_rate, vf->vf_id);
2253+ if (max_tx_rate > speed) {
2254+ dev_err(&pf->pdev->dev, "Invalid max tx rate %d specified for vf %d.",
2255+ max_tx_rate, vf->vf_id);
22492256 ret = -EINVAL;
22502257 goto error;
22512258 }
22522259
22532260 /* Tx rate credits are in values of 50Mbps, 0 is disabled*/
2254− ret = i40e_aq_config_vsi_bw_limit(&pf->hw, vsi->seid, tx_rate / 50, 0,
2255− NULL);
2261+ ret = i40e_aq_config_vsi_bw_limit(&pf->hw, vsi->seid, max_tx_rate / 50,
2262+ 0, NULL);
22562263 if (ret) {
2257− dev_err(&pf->pdev->dev, "Unable to set tx rate, error code %d.\n",
2264+ dev_err(&pf->pdev->dev, "Unable to set max tx rate, error code %d.\n",
22582265 ret);
22592266 ret = -EIO;
22602267 goto error;
22612268 }
2262− vf->tx_rate = tx_rate;
2269+ vf->tx_rate = max_tx_rate;
22632270 error:
22642271 return ret;
22652272 }
@@ -2301,7 +2308,8 @@ int i40e_ndo_get_vf_config(struct net_device *netdev, · 35 unmodified lines
23012308
23022309 memcpy(&ivi->mac, vf->default_lan_addr.addr, ETH_ALEN);
23032310
2304− ivi->tx_rate = vf->tx_rate;
2311+ ivi->max_tx_rate = vf->tx_rate;
2312+ ivi->min_tx_rate = 0;
23052313 ivi->vlan = le16_to_cpu(vsi->info.pvid) & I40E_VLAN_MASK;
23062314 ivi->qos = (le16_to_cpu(vsi->info.pvid) & I40E_PRIORITY_MASK) >>
23072315 I40E_VLAN_PRIORITY_SHIFT;
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.h+2−1
@@ -116,7 +116,8 @@ void i40e_vc_notify_vf_reset(struct i40e_vf *vf); · 115 unmodified lines
116116 int i40e_ndo_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac);
117117 int i40e_ndo_set_vf_port_vlan(struct net_device *netdev,
118118 int vf_id, u16 vlan_id, u8 qos);
119−int i40e_ndo_set_vf_bw(struct net_device *netdev, int vf_id, int tx_rate);
119+int i40e_ndo_set_vf_bw(struct net_device *netdev, int vf_id, int min_tx_rate,
120+ int max_tx_rate);
120121 int i40e_ndo_get_vf_config(struct net_device *netdev,
121122 int vf_id, struct ifla_vf_info *ivi);
122123 int i40e_ndo_set_vf_link_state(struct net_device *netdev, int vf_id, int link);
drivers/net/ethernet/intel/igb/igb_main.c+13−7
@@ -169,7 +169,7 @@ static void igb_restore_vf_multicasts(struct igb_adapter *adapter); · 168 unmodified lines
169169 static int igb_ndo_set_vf_mac(struct net_device *netdev, int vf, u8 *mac);
170170 static int igb_ndo_set_vf_vlan(struct net_device *netdev,
171171 int vf, u16 vlan, u8 qos);
172−static int igb_ndo_set_vf_bw(struct net_device *netdev, int vf, int tx_rate);
172+static int igb_ndo_set_vf_bw(struct net_device *, int, int, int);
173173 static int igb_ndo_set_vf_spoofchk(struct net_device *netdev, int vf,
174174 bool setting);
175175 static int igb_ndo_get_vf_config(struct net_device *netdev, int vf,
@@ -2084,7 +2084,7 @@ static const struct net_device_ops igb_netdev_ops = { · 1908 unmodified lines
20842084 .ndo_vlan_rx_kill_vid = igb_vlan_rx_kill_vid,
20852085 .ndo_set_vf_mac = igb_ndo_set_vf_mac,
20862086 .ndo_set_vf_vlan = igb_ndo_set_vf_vlan,
2087− .ndo_set_vf_tx_rate = igb_ndo_set_vf_bw,
2087+ .ndo_set_vf_rate = igb_ndo_set_vf_bw,
20882088 .ndo_set_vf_spoofchk = igb_ndo_set_vf_spoofchk,
20892089 .ndo_get_vf_config = igb_ndo_get_vf_config,
20902090 #ifdef CONFIG_NET_POLL_CONTROLLER
@@ -7879,7 +7879,8 @@ static void igb_check_vf_rate_limit(struct igb_adapter *adapter) · 5788 unmodified lines
78797879 }
78807880 }
78817881
7882−static int igb_ndo_set_vf_bw(struct net_device *netdev, int vf, int tx_rate)
7882+static int igb_ndo_set_vf_bw(struct net_device *netdev, int vf,
7883+ int min_tx_rate, int max_tx_rate)
78837884 {
78847885 struct igb_adapter *adapter = netdev_priv(netdev);
78857886 struct e1000_hw *hw = &adapter->hw;
@@ -7888,15 +7889,19 @@ static int igb_ndo_set_vf_bw(struct net_device *netdev, int vf, int tx_rate) · 2 unmodified lines
78887889 if (hw->mac.type != e1000_82576)
78897890 return -EOPNOTSUPP;
78907891
7892+ if (min_tx_rate)
7893+ return -EINVAL;
7894+
78917895 actual_link_speed = igb_link_mbps(adapter->link_speed);
78927896 if ((vf >= adapter->vfs_allocated_count) ||
78937897 (!(rd32(E1000_STATUS) & E1000_STATUS_LU)) ||
7894− (tx_rate < 0) || (tx_rate > actual_link_speed))
7898+ (max_tx_rate < 0) ||
7899+ (max_tx_rate > actual_link_speed))
78957900 return -EINVAL;
78967901
78977902 adapter->vf_rate_link_speed = actual_link_speed;
7898− adapter->vf_data[vf].tx_rate = (u16)tx_rate;
7899− igb_set_vf_rate_limit(hw, vf, tx_rate, actual_link_speed);
7903+ adapter->vf_data[vf].tx_rate = (u16)max_tx_rate;
7904+ igb_set_vf_rate_limit(hw, vf, max_tx_rate, actual_link_speed);
79007905
79017906 return 0;
79027907 }
@@ -7936,7 +7941,8 @@ static int igb_ndo_get_vf_config(struct net_device *netdev, · 33 unmodified lines
79367941 return -EINVAL;
79377942 ivi->vf = vf;
79387943 memcpy(&ivi->mac, adapter->vf_data[vf].vf_mac_addresses, ETH_ALEN);
7939− ivi->tx_rate = adapter->vf_data[vf].tx_rate;
7944+ ivi->max_tx_rate = adapter->vf_data[vf].tx_rate;
7945+ ivi->min_tx_rate = 0;
79407946 ivi->vlan = adapter->vf_data[vf].pf_vlan;
79417947 ivi->qos = adapter->vf_data[vf].pf_qos;
79427948 ivi->spoofchk = adapter->vf_data[vf].spoofchk_enabled;
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c+1−1
@@ -7926,7 +7926,7 @@ static const struct net_device_ops ixgbe_netdev_ops = { · 7925 unmodified lines
79267926 .ndo_do_ioctl = ixgbe_ioctl,
79277927 .ndo_set_vf_mac = ixgbe_ndo_set_vf_mac,
79287928 .ndo_set_vf_vlan = ixgbe_ndo_set_vf_vlan,
7929− .ndo_set_vf_tx_rate = ixgbe_ndo_set_vf_bw,
7929+ .ndo_set_vf_rate = ixgbe_ndo_set_vf_bw,
79307930 .ndo_set_vf_spoofchk = ixgbe_ndo_set_vf_spoofchk,
79317931 .ndo_get_vf_config = ixgbe_ndo_get_vf_config,
79327932 .ndo_get_stats64 = ixgbe_get_stats64,
drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c+9−4
@@ -1222,7 +1222,8 @@ void ixgbe_check_vf_rate_limit(struct ixgbe_adapter *adapter) · 1221 unmodified lines
12221222 }
12231223 }
12241224
1225−int ixgbe_ndo_set_vf_bw(struct net_device *netdev, int vf, int tx_rate)
1225+int ixgbe_ndo_set_vf_bw(struct net_device *netdev, int vf, int min_tx_rate,
1226+ int max_tx_rate)
12261227 {
12271228 struct ixgbe_adapter *adapter = netdev_priv(netdev);
12281229 int link_speed;
@@ -1240,13 +1241,16 @@ int ixgbe_ndo_set_vf_bw(struct net_device *netdev, int vf, int tx_rate) · 11 unmodified lines
12401241 if (link_speed != 10000)
12411242 return -EINVAL;
12421243
1244+ if (min_tx_rate)
1245+ return -EINVAL;
1246+
12431247 /* rate limit cannot be less than 10Mbs or greater than link speed */
1244− if (tx_rate && ((tx_rate <= 10) || (tx_rate > link_speed)))
1248+ if (max_tx_rate && ((max_tx_rate <= 10) || (max_tx_rate > link_speed)))
12451249 return -EINVAL;
12461250
12471251 /* store values */
12481252 adapter->vf_rate_link_speed = link_speed;
1249− adapter->vfinfo[vf].tx_rate = tx_rate;
1253+ adapter->vfinfo[vf].tx_rate = max_tx_rate;
12501254
12511255 /* update hardware configuration */
12521256 ixgbe_set_vf_rate_limit(adapter, vf);
@@ -1288,7 +1292,8 @@ int ixgbe_ndo_get_vf_config(struct net_device *netdev, · 35 unmodified lines
12881292 return -EINVAL;
12891293 ivi->vf = vf;
12901294 memcpy(&ivi->mac, adapter->vfinfo[vf].vf_mac_addresses, ETH_ALEN);
1291− ivi->tx_rate = adapter->vfinfo[vf].tx_rate;
1295+ ivi->max_tx_rate = adapter->vfinfo[vf].tx_rate;
1296+ ivi->min_tx_rate = 0;
12921297 ivi->vlan = adapter->vfinfo[vf].pf_vlan;
12931298 ivi->qos = adapter->vfinfo[vf].pf_qos;
12941299 ivi->spoofchk = adapter->vfinfo[vf].spoofchk_enabled;
drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.h+2−1
@@ -44,7 +44,8 @@ void ixgbe_ping_all_vfs(struct ixgbe_adapter *adapter); · 43 unmodified lines
4444 int ixgbe_ndo_set_vf_mac(struct net_device *netdev, int queue, u8 *mac);
4545 int ixgbe_ndo_set_vf_vlan(struct net_device *netdev, int queue, u16 vlan,
4646 u8 qos);
47−int ixgbe_ndo_set_vf_bw(struct net_device *netdev, int vf, int tx_rate);
47+int ixgbe_ndo_set_vf_bw(struct net_device *netdev, int vf, int min_tx_rate,
48+ int max_tx_rate);
4849 int ixgbe_ndo_set_vf_spoofchk(struct net_device *netdev, int vf, bool setting);
4950 int ixgbe_ndo_get_vf_config(struct net_device *netdev,
5051 int vf, struct ifla_vf_info *ivi);
drivers/net/ethernet/mellanox/mlx4/cmd.c+6−5
@@ -2486,11 +2486,12 @@ int mlx4_get_vf_config(struct mlx4_dev *dev, int port, int vf, struct ifla_vf_in · 2485 unmodified lines
24862486 ivf->mac[4] = ((s_info->mac >> (1*8)) & 0xff);
24872487 ivf->mac[5] = ((s_info->mac) & 0xff);
24882488
2489− ivf->vlan = s_info->default_vlan;
2490− ivf->qos = s_info->default_qos;
2491− ivf->tx_rate = s_info->tx_rate;
2492− ivf->spoofchk = s_info->spoofchk;
2493− ivf->linkstate = s_info->link_state;
2489+ ivf->vlan = s_info->default_vlan;
2490+ ivf->qos = s_info->default_qos;
2491+ ivf->max_tx_rate = s_info->tx_rate;
2492+ ivf->min_tx_rate = 0;
2493+ ivf->spoofchk = s_info->spoofchk;
2494+ ivf->linkstate = s_info->link_state;
24942495
24952496 return 0;
24962497 }
drivers/net/ethernet/qlogic/qlcnic/qlcnic.h+1−0
@@ -1319,6 +1319,7 @@ struct qlcnic_eswitch { · 1318 unmodified lines
13191319 #define QL_STATUS_INVALID_PARAM -1
13201320
13211321 #define MAX_BW 100 /* % of link speed */
1322+#define MIN_BW 1 /* % of link speed */
13221323 #define MAX_VLAN_ID 4095
13231324 #define MIN_VLAN_ID 2
13241325 #define DEFAULT_MAC_LEARN 1
drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c+1−1
@@ -525,7 +525,7 @@ static const struct net_device_ops qlcnic_netdev_ops = { · 524 unmodified lines
525525 #endif
526526 #ifdef CONFIG_QLCNIC_SRIOV
527527 .ndo_set_vf_mac = qlcnic_sriov_set_vf_mac,
528− .ndo_set_vf_tx_rate = qlcnic_sriov_set_vf_tx_rate,
528+ .ndo_set_vf_rate = qlcnic_sriov_set_vf_tx_rate,
529529 .ndo_get_vf_config = qlcnic_sriov_get_vf_config,
530530 .ndo_set_vf_vlan = qlcnic_sriov_set_vf_vlan,
531531 .ndo_set_vf_spoofchk = qlcnic_sriov_set_vf_spoofchk,
drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov.h+1−1
@@ -233,7 +233,7 @@ bool qlcnic_sriov_soft_flr_check(struct qlcnic_adapter *, · 232 unmodified lines
233233 void qlcnic_sriov_pf_reset(struct qlcnic_adapter *);
234234 int qlcnic_sriov_pf_reinit(struct qlcnic_adapter *);
235235 int qlcnic_sriov_set_vf_mac(struct net_device *, int, u8 *);
236−int qlcnic_sriov_set_vf_tx_rate(struct net_device *, int, int);
236+int qlcnic_sriov_set_vf_tx_rate(struct net_device *, int, int, int);
237237 int qlcnic_sriov_get_vf_config(struct net_device *, int ,
238238 struct ifla_vf_info *);
239239 int qlcnic_sriov_set_vf_vlan(struct net_device *, int, u16, u8);
drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c+1−0
@@ -201,6 +201,7 @@ int qlcnic_sriov_init(struct qlcnic_adapter *adapter, int num_vfs) · 200 unmodified lines
201201 sriov->vf_info[i].vp = vp;
202202 vp->vlan_mode = QLC_GUEST_VLAN_MODE;
203203 vp->max_tx_bw = MAX_BW;
204+ vp->min_tx_bw = MIN_BW;
204205 vp->spoofchk = false;
205206 random_ether_addr(vp->mac);
206207 dev_info(&adapter->pdev->dev,
drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_pf.c+37−15
@@ -1848,7 +1848,8 @@ int qlcnic_sriov_set_vf_mac(struct net_device *netdev, int vf, u8 *mac) · 1847 unmodified lines
18481848 return 0;
18491849 }
18501850
1851−int qlcnic_sriov_set_vf_tx_rate(struct net_device *netdev, int vf, int tx_rate)
1851+int qlcnic_sriov_set_vf_tx_rate(struct net_device *netdev, int vf,
1852+ int min_tx_rate, int max_tx_rate)
18521853 {
18531854 struct qlcnic_adapter *adapter = netdev_priv(netdev);
18541855 struct qlcnic_sriov *sriov = adapter->ahw->sriov;
@@ -1863,35 +1864,52 @@ int qlcnic_sriov_set_vf_tx_rate(struct net_device *netdev, int vf, int tx_rate) · 8 unmodified lines
18631864 if (vf >= sriov->num_vfs)
18641865 return -EINVAL;
18651866
1866− if (tx_rate >= 10000 || tx_rate < 100) {
1867+ vf_info = &sriov->vf_info[vf];
1868+ vp = vf_info->vp;
1869+ vpid = vp->handle;
1870+
1871+ if (!min_tx_rate)
1872+ min_tx_rate = QLC_VF_MIN_TX_RATE;
1873+
1874+ if (max_tx_rate &&
1875+ (max_tx_rate >= 10000 || max_tx_rate < min_tx_rate)) {
18671876 netdev_err(netdev,
1868− "Invalid Tx rate, allowed range is [%d - %d]",
1869− QLC_VF_MIN_TX_RATE, QLC_VF_MAX_TX_RATE);
1877+ "Invalid max Tx rate, allowed range is [%d - %d]",
1878+ min_tx_rate, QLC_VF_MAX_TX_RATE);
18701879 return -EINVAL;
18711880 }
18721881
1873− if (tx_rate == 0)
1874− tx_rate = 10000;
1882+ if (!max_tx_rate)
1883+ max_tx_rate = 10000;
18751884
1876− vf_info = &sriov->vf_info[vf];
1877− vp = vf_info->vp;
1878− vpid = vp->handle;
1885+ if (min_tx_rate &&
1886+ (min_tx_rate > max_tx_rate || min_tx_rate < QLC_VF_MIN_TX_RATE)) {
1887+ netdev_err(netdev,
1888+ "Invalid min Tx rate, allowed range is [%d - %d]",
1889+ QLC_VF_MIN_TX_RATE, max_tx_rate);
1890+ return -EINVAL;
1891+ }
18791892
18801893 if (test_bit(QLC_BC_VF_STATE, &vf_info->state)) {
18811894 if (qlcnic_sriov_get_vf_vport_info(adapter, &nic_info, vpid))
18821895 return -EIO;
18831896
1884− nic_info.max_tx_bw = tx_rate / 100;
1897+ nic_info.max_tx_bw = max_tx_rate / 100;
1898+ nic_info.min_tx_bw = min_tx_rate / 100;
18851899 nic_info.bit_offsets = BIT_0;
18861900
18871901 if (qlcnic_sriov_pf_set_vport_info(adapter, &nic_info, vpid))
18881902 return -EIO;
18891903 }
18901904
1891− vp->max_tx_bw = tx_rate / 100;
1905+ vp->max_tx_bw = max_tx_rate / 100;
1906+ netdev_info(netdev,
1907+ "Setting Max Tx rate %d (Mbps), %d %% of PF bandwidth, for VF %d\n",
1908+ max_tx_rate, vp->max_tx_bw, vf);
1909+ vp->min_tx_bw = min_tx_rate / 100;
18921910 netdev_info(netdev,
1893− "Setting Tx rate %d (Mbps), %d %% of PF bandwidth, for VF %d\n",
1894− tx_rate, vp->max_tx_bw, vf);
1911+ "Setting Min Tx rate %d (Mbps), %d %% of PF bandwidth, for VF %d\n",
1912+ min_tx_rate, vp->min_tx_bw, vf);
18951913 return 0;
18961914 }
18971915
@@ -1990,9 +2008,13 @@ int qlcnic_sriov_get_vf_config(struct net_device *netdev, · 92 unmodified lines
19902008 ivi->qos = vp->qos;
19912009 ivi->spoofchk = vp->spoofchk;
19922010 if (vp->max_tx_bw == MAX_BW)
1993− ivi->tx_rate = 0;
2011+ ivi->max_tx_rate = 0;
2012+ else
2013+ ivi->max_tx_rate = vp->max_tx_bw * 100;
2014+ if (vp->min_tx_bw == MIN_BW)
2015+ ivi->min_tx_rate = 0;
19942016 else
1995− ivi->tx_rate = vp->max_tx_bw * 100;
2017+ ivi->min_tx_rate = vp->min_tx_bw * 100;
19962018
19972019 ivi->vf = vf;
19982020 return 0;
drivers/net/ethernet/sfc/siena_sriov.c+2−1
@@ -1633,7 +1633,8 @@ int efx_sriov_get_vf_config(struct net_device *net_dev, int vf_i, · 1632 unmodified lines
16331633
16341634 ivi->vf = vf_i;
16351635 ether_addr_copy(ivi->mac, vf->addr.mac_addr);
1636− ivi->tx_rate = 0;
1636+ ivi->max_tx_rate = 0;
1637+ ivi->min_tx_rate = 0;
16371638 tci = ntohs(vf->addr.tci);
16381639 ivi->vlan = tci & VLAN_VID_MASK;
16391640 ivi->qos = (tci >> VLAN_PRIO_SHIFT) & 0x7;
include/linux/if_link.h+2−1
@@ -10,8 +10,9 @@ struct ifla_vf_info { · 9 unmodified lines
1010 __u8 mac[32];
1111 __u32 vlan;
1212 __u32 qos;
13− __u32 tx_rate;
1413 __u32 spoofchk;
1514 __u32 linkstate;
15+ __u32 min_tx_rate;
16+ __u32 max_tx_rate;
1617 };
1718 #endif /* _LINUX_IF_LINK_H */
include/linux/netdevice.h+5−3
@@ -850,7 +850,8 @@ typedef u16 (*select_queue_fallback_t)(struct net_device *dev, · 849 unmodified lines
850850 * SR-IOV management functions.
851851 * int (*ndo_set_vf_mac)(struct net_device *dev, int vf, u8* mac);
852852 * int (*ndo_set_vf_vlan)(struct net_device *dev, int vf, u16 vlan, u8 qos);
853− * int (*ndo_set_vf_tx_rate)(struct net_device *dev, int vf, int rate);
853+ * int (*ndo_set_vf_rate)(struct net_device *dev, int vf, int min_tx_rate,
854+ * int max_tx_rate);
854855 * int (*ndo_set_vf_spoofchk)(struct net_device *dev, int vf, bool setting);
855856 * int (*ndo_get_vf_config)(struct net_device *dev,
856857 * int vf, struct ifla_vf_info *ivf);
@@ -1044,8 +1045,9 @@ struct net_device_ops { · 187 unmodified lines
10441045 int queue, u8 *mac);
10451046 int (*ndo_set_vf_vlan)(struct net_device *dev,
10461047 int queue, u16 vlan, u8 qos);
1047− int (*ndo_set_vf_tx_rate)(struct net_device *dev,
1048− int vf, int rate);
1048+ int (*ndo_set_vf_rate)(struct net_device *dev,
1049+ int vf, int min_tx_rate,
1050+ int max_tx_rate);
10491051 int (*ndo_set_vf_spoofchk)(struct net_device *dev,
10501052 int vf, bool setting);
10511053 int (*ndo_get_vf_config)(struct net_device *dev,
include/uapi/linux/if_link.h+8−1
@@ -399,9 +399,10 @@ enum { · 398 unmodified lines
399399 IFLA_VF_UNSPEC,
400400 IFLA_VF_MAC, /* Hardware queue specific attributes */
401401 IFLA_VF_VLAN,
402− IFLA_VF_TX_RATE, /* TX Bandwidth Allocation */
402+ IFLA_VF_TX_RATE, /* Max TX Bandwidth Allocation */
403403 IFLA_VF_SPOOFCHK, /* Spoof Checking on/off switch */
404404 IFLA_VF_LINK_STATE, /* link state enable/disable/auto switch */
405+ IFLA_VF_RATE, /* Min and Max TX Bandwidth Allocation */
405406 __IFLA_VF_MAX,
406407 };
407408
@@ -423,6 +424,12 @@ struct ifla_vf_tx_rate { · 15 unmodified lines
423424 __u32 rate; /* Max TX bandwidth in Mbps, 0 disables throttling */
424425 };
425426
427+struct ifla_vf_rate {
428+ __u32 vf;
429+ __u32 min_tx_rate; /* Min Bandwidth in Mbps */
430+ __u32 max_tx_rate; /* Max Bandwidth in Mbps */
431+};
432+
426433 struct ifla_vf_spoofchk {
427434 __u32 vf;
428435 __u32 setting;
net/core/rtnetlink.c+32−6
@@ -767,8 +767,8 @@ static inline int rtnl_vfinfo_size(const struct net_device *dev, · 766 unmodified lines
767767 size += num_vfs *
768768 (nla_total_size(sizeof(struct ifla_vf_mac)) +
769769 nla_total_size(sizeof(struct ifla_vf_vlan)) +
770− nla_total_size(sizeof(struct ifla_vf_tx_rate)) +
771− nla_total_size(sizeof(struct ifla_vf_spoofchk)));
770+ nla_total_size(sizeof(struct ifla_vf_spoofchk)) +
771+ nla_total_size(sizeof(struct ifla_vf_rate)));
772772 return size;
773773 } else
774774 return 0;
@@ -1034,6 +1034,7 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev, · 259 unmodified lines
10341034 struct ifla_vf_info ivi;
10351035 struct ifla_vf_mac vf_mac;
10361036 struct ifla_vf_vlan vf_vlan;
1037+ struct ifla_vf_rate vf_rate;
10371038 struct ifla_vf_tx_rate vf_tx_rate;
10381039 struct ifla_vf_spoofchk vf_spoofchk;
10391040 struct ifla_vf_link_state vf_linkstate;
@@ -1054,6 +1055,7 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev, · 14 unmodified lines
10541055 break;
10551056 vf_mac.vf =
10561057 vf_vlan.vf =
1058+ vf_rate.vf =
10571059 vf_tx_rate.vf =
10581060 vf_spoofchk.vf =
10591061 vf_linkstate.vf = ivi.vf;
@@ -1061,7 +1063,9 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev, · 1 unmodified line
10611063 memcpy(vf_mac.mac, ivi.mac, sizeof(ivi.mac));
10621064 vf_vlan.vlan = ivi.vlan;
10631065 vf_vlan.qos = ivi.qos;
1064− vf_tx_rate.rate = ivi.tx_rate;
1066+ vf_tx_rate.rate = ivi.max_tx_rate;
1067+ vf_rate.min_tx_rate = ivi.min_tx_rate;
1068+ vf_rate.max_tx_rate = ivi.max_tx_rate;
10651069 vf_spoofchk.setting = ivi.spoofchk;
10661070 vf_linkstate.link_state = ivi.linkstate;
10671071 vf = nla_nest_start(skb, IFLA_VF_INFO);
@@ -1071,6 +1075,8 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev, · 3 unmodified lines
10711075 }
10721076 if (nla_put(skb, IFLA_VF_MAC, sizeof(vf_mac), &vf_mac) ||
10731077 nla_put(skb, IFLA_VF_VLAN, sizeof(vf_vlan), &vf_vlan) ||
1078+ nla_put(skb, IFLA_VF_RATE, sizeof(vf_rate),
1079+ &vf_rate) ||
10741080 nla_put(skb, IFLA_VF_TX_RATE, sizeof(vf_tx_rate),
10751081 &vf_tx_rate) ||
10761082 nla_put(skb, IFLA_VF_SPOOFCHK, sizeof(vf_spoofchk),
@@ -1177,6 +1183,8 @@ static const struct nla_policy ifla_vf_policy[IFLA_VF_MAX+1] = { · 100 unmodified lines
11771183 .len = sizeof(struct ifla_vf_tx_rate) },
11781184 [IFLA_VF_SPOOFCHK] = { .type = NLA_BINARY,
11791185 .len = sizeof(struct ifla_vf_spoofchk) },
1186+ [IFLA_VF_RATE] = { .type = NLA_BINARY,
1187+ .len = sizeof(struct ifla_vf_rate) },
11801188 };
11811189
11821190 static const struct nla_policy ifla_port_policy[IFLA_PORT_MAX+1] = {
@@ -1336,11 +1344,29 @@ static int do_setvfinfo(struct net_device *dev, struct nlattr *attr) · 153 unmodified lines
13361344 }
13371345 case IFLA_VF_TX_RATE: {
13381346 struct ifla_vf_tx_rate *ivt;
1347+ struct ifla_vf_info ivf;
13391348 ivt = nla_data(vf);
13401349 err = -EOPNOTSUPP;
1341− if (ops->ndo_set_vf_tx_rate)
1342− err = ops->ndo_set_vf_tx_rate(dev, ivt->vf,
1343− ivt->rate);
1350+ if (ops->ndo_get_vf_config)
1351+ err = ops->ndo_get_vf_config(dev, ivt->vf,
1352+ &ivf);
1353+ if (err)
1354+ break;
1355+ err = -EOPNOTSUPP;
1356+ if (ops->ndo_set_vf_rate)
1357+ err = ops->ndo_set_vf_rate(dev, ivt->vf,
1358+ ivf.min_tx_rate,
1359+ ivt->rate);
1360+ break;
1361+ }
1362+ case IFLA_VF_RATE: {
1363+ struct ifla_vf_rate *ivt;
1364+ ivt = nla_data(vf);
1365+ err = -EOPNOTSUPP;
1366+ if (ops->ndo_set_vf_rate)
1367+ err = ops->ndo_set_vf_rate(dev, ivt->vf,
1368+ ivt->min_tx_rate,
1369+ ivt->max_tx_rate);
13441370 break;
13451371 }
13461372 case IFLA_VF_SPOOFCHK: {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t