aboutsummaryrefslogtreecommitdiffstats
path: root/net/core
diff options
context:
space:
mode:
authorSucheta Chakraborty <sucheta.chakraborty@qlogic.com>2014-05-22 09:59:05 -0400
committerDavid S. Miller <davem@davemloft.net>2014-05-23 15:04:02 -0400
commited616689a3d95eb6c9bdbb1ef74b0f50cbdf276a (patch)
tree50be50b40071bd5307b7a1efbfe04b3c06e178b3 /net/core
parent307f099520b66504cf6c5638f3f404c48b9fb45b (diff)
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 Signed-off-by: Sucheta Chakraborty <sucheta.chakraborty@qlogic.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r--net/core/rtnetlink.c38
1 files changed, 32 insertions, 6 deletions
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 9837bebf93ce..d6417464dc66 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -767,8 +767,8 @@ static inline int rtnl_vfinfo_size(const struct net_device *dev,
767 size += num_vfs * 767 size += num_vfs *
768 (nla_total_size(sizeof(struct ifla_vf_mac)) + 768 (nla_total_size(sizeof(struct ifla_vf_mac)) +
769 nla_total_size(sizeof(struct ifla_vf_vlan)) + 769 nla_total_size(sizeof(struct ifla_vf_vlan)) +
770 nla_total_size(sizeof(struct ifla_vf_tx_rate)) + 770 nla_total_size(sizeof(struct ifla_vf_spoofchk)) +
771 nla_total_size(sizeof(struct ifla_vf_spoofchk))); 771 nla_total_size(sizeof(struct ifla_vf_rate)));
772 return size; 772 return size;
773 } else 773 } else
774 return 0; 774 return 0;
@@ -1034,6 +1034,7 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
1034 struct ifla_vf_info ivi; 1034 struct ifla_vf_info ivi;
1035 struct ifla_vf_mac vf_mac; 1035 struct ifla_vf_mac vf_mac;
1036 struct ifla_vf_vlan vf_vlan; 1036 struct ifla_vf_vlan vf_vlan;
1037 struct ifla_vf_rate vf_rate;
1037 struct ifla_vf_tx_rate vf_tx_rate; 1038 struct ifla_vf_tx_rate vf_tx_rate;
1038 struct ifla_vf_spoofchk vf_spoofchk; 1039 struct ifla_vf_spoofchk vf_spoofchk;
1039 struct ifla_vf_link_state vf_linkstate; 1040 struct ifla_vf_link_state vf_linkstate;
@@ -1054,6 +1055,7 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
1054 break; 1055 break;
1055 vf_mac.vf = 1056 vf_mac.vf =
1056 vf_vlan.vf = 1057 vf_vlan.vf =
1058 vf_rate.vf =
1057 vf_tx_rate.vf = 1059 vf_tx_rate.vf =
1058 vf_spoofchk.vf = 1060 vf_spoofchk.vf =
1059 vf_linkstate.vf = ivi.vf; 1061 vf_linkstate.vf = ivi.vf;
@@ -1061,7 +1063,9 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
1061 memcpy(vf_mac.mac, ivi.mac, sizeof(ivi.mac)); 1063 memcpy(vf_mac.mac, ivi.mac, sizeof(ivi.mac));
1062 vf_vlan.vlan = ivi.vlan; 1064 vf_vlan.vlan = ivi.vlan;
1063 vf_vlan.qos = ivi.qos; 1065 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;
1065 vf_spoofchk.setting = ivi.spoofchk; 1069 vf_spoofchk.setting = ivi.spoofchk;
1066 vf_linkstate.link_state = ivi.linkstate; 1070 vf_linkstate.link_state = ivi.linkstate;
1067 vf = nla_nest_start(skb, IFLA_VF_INFO); 1071 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,
1071 } 1075 }
1072 if (nla_put(skb, IFLA_VF_MAC, sizeof(vf_mac), &vf_mac) || 1076 if (nla_put(skb, IFLA_VF_MAC, sizeof(vf_mac), &vf_mac) ||
1073 nla_put(skb, IFLA_VF_VLAN, sizeof(vf_vlan), &vf_vlan) || 1077 nla_put(skb, IFLA_VF_VLAN, sizeof(vf_vlan), &vf_vlan) ||
1078 nla_put(skb, IFLA_VF_RATE, sizeof(vf_rate),
1079 &vf_rate) ||
1074 nla_put(skb, IFLA_VF_TX_RATE, sizeof(vf_tx_rate), 1080 nla_put(skb, IFLA_VF_TX_RATE, sizeof(vf_tx_rate),
1075 &vf_tx_rate) || 1081 &vf_tx_rate) ||
1076 nla_put(skb, IFLA_VF_SPOOFCHK, sizeof(vf_spoofchk), 1082 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] = {
1177 .len = sizeof(struct ifla_vf_tx_rate) }, 1183 .len = sizeof(struct ifla_vf_tx_rate) },
1178 [IFLA_VF_SPOOFCHK] = { .type = NLA_BINARY, 1184 [IFLA_VF_SPOOFCHK] = { .type = NLA_BINARY,
1179 .len = sizeof(struct ifla_vf_spoofchk) }, 1185 .len = sizeof(struct ifla_vf_spoofchk) },
1186 [IFLA_VF_RATE] = { .type = NLA_BINARY,
1187 .len = sizeof(struct ifla_vf_rate) },
1180}; 1188};
1181 1189
1182static const struct nla_policy ifla_port_policy[IFLA_PORT_MAX+1] = { 1190static 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)
1336 } 1344 }
1337 case IFLA_VF_TX_RATE: { 1345 case IFLA_VF_TX_RATE: {
1338 struct ifla_vf_tx_rate *ivt; 1346 struct ifla_vf_tx_rate *ivt;
1347 struct ifla_vf_info ivf;
1339 ivt = nla_data(vf); 1348 ivt = nla_data(vf);
1340 err = -EOPNOTSUPP; 1349 err = -EOPNOTSUPP;
1341 if (ops->ndo_set_vf_tx_rate) 1350 if (ops->ndo_get_vf_config)
1342 err = ops->ndo_set_vf_tx_rate(dev, ivt->vf, 1351 err = ops->ndo_get_vf_config(dev, ivt->vf,
1343 ivt->rate); 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);
1344 break; 1370 break;
1345 } 1371 }
1346 case IFLA_VF_SPOOFCHK: { 1372 case IFLA_VF_SPOOFCHK: {