net/dcb: Add IEEE QCN attribute

As specified in 802.1Qau spec. Add this optional attribute to the
DCB netlink layer. To allow for application to use the new attribute,
NIC drivers should implement and register the  callbacks ieee_getqcn,
ieee_setqcn and ieee_getqcnstats.

The QCN attribute holds a set of parameters for management, and
a set of statistics to provide informative data on Congestion-Control
defined by this spec.

Signed-off-by: Shani Michaeli <shanim@mellanox.com>
Signed-off-by: Shachar Raindel <raindel@mellanox.com>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Acked-by: John Fastabend <john.r.fastabend@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Shani Michaeli
2015-03-05 20:16:11 +02:00
committed by David S. Miller
parent 34de26d366
commit c93682477b
3 changed files with 110 additions and 3 deletions

View File

@@ -177,6 +177,8 @@ static const struct nla_policy dcbnl_ieee_policy[DCB_ATTR_IEEE_MAX + 1] = {
[DCB_ATTR_IEEE_PFC] = {.len = sizeof(struct ieee_pfc)},
[DCB_ATTR_IEEE_APP_TABLE] = {.type = NLA_NESTED},
[DCB_ATTR_IEEE_MAXRATE] = {.len = sizeof(struct ieee_maxrate)},
[DCB_ATTR_IEEE_QCN] = {.len = sizeof(struct ieee_qcn)},
[DCB_ATTR_IEEE_QCN_STATS] = {.len = sizeof(struct ieee_qcn_stats)},
};
static const struct nla_policy dcbnl_ieee_app[DCB_ATTR_IEEE_APP_MAX + 1] = {
@@ -1030,7 +1032,7 @@ nla_put_failure:
return err;
}
/* Handle IEEE 802.1Qaz GET commands. */
/* Handle IEEE 802.1Qaz/802.1Qau/802.1Qbb GET commands. */
static int dcbnl_ieee_fill(struct sk_buff *skb, struct net_device *netdev)
{
struct nlattr *ieee, *app;
@@ -1067,6 +1069,32 @@ static int dcbnl_ieee_fill(struct sk_buff *skb, struct net_device *netdev)
}
}
if (ops->ieee_getqcn) {
struct ieee_qcn qcn;
memset(&qcn, 0, sizeof(qcn));
err = ops->ieee_getqcn(netdev, &qcn);
if (!err) {
err = nla_put(skb, DCB_ATTR_IEEE_QCN,
sizeof(qcn), &qcn);
if (err)
return -EMSGSIZE;
}
}
if (ops->ieee_getqcnstats) {
struct ieee_qcn_stats qcn_stats;
memset(&qcn_stats, 0, sizeof(qcn_stats));
err = ops->ieee_getqcnstats(netdev, &qcn_stats);
if (!err) {
err = nla_put(skb, DCB_ATTR_IEEE_QCN_STATS,
sizeof(qcn_stats), &qcn_stats);
if (err)
return -EMSGSIZE;
}
}
if (ops->ieee_getpfc) {
struct ieee_pfc pfc;
memset(&pfc, 0, sizeof(pfc));
@@ -1379,8 +1407,9 @@ int dcbnl_cee_notify(struct net_device *dev, int event, int cmd,
}
EXPORT_SYMBOL(dcbnl_cee_notify);
/* Handle IEEE 802.1Qaz SET commands. If any requested operation can not
* be completed the entire msg is aborted and error value is returned.
/* Handle IEEE 802.1Qaz/802.1Qau/802.1Qbb SET commands.
* If any requested operation can not be completed
* the entire msg is aborted and error value is returned.
* No attempt is made to reconcile the case where only part of the
* cmd can be completed.
*/
@@ -1417,6 +1446,15 @@ static int dcbnl_ieee_set(struct net_device *netdev, struct nlmsghdr *nlh,
goto err;
}
if (ieee[DCB_ATTR_IEEE_QCN] && ops->ieee_setqcn) {
struct ieee_qcn *qcn =
nla_data(ieee[DCB_ATTR_IEEE_QCN]);
err = ops->ieee_setqcn(netdev, qcn);
if (err)
goto err;
}
if (ieee[DCB_ATTR_IEEE_PFC] && ops->ieee_setpfc) {
struct ieee_pfc *pfc = nla_data(ieee[DCB_ATTR_IEEE_PFC]);
err = ops->ieee_setpfc(netdev, pfc);