Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net/dcb: Add an optional max rate attribute

Although not specified in 8021Qaz spec, it could be useful to enable drivers
whose HW supports setting a rate limit for an ETS TC. This patch adds this
optional attribute to DCB netlink. To use it, drivers should implement and
register the callbacks ieee_setmaxrate and ieee_getmaxrate. The units are 64
bits long and specified in Kbps to enable usage over both slow and very fast
networks.

Signed-off-by: Amir Vadai <amirv@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Amir Vadai and committed by
David S. Miller
08f10aff 366cddb4

+34
+12
include/linux/dcbnl.h
··· 67 67 __u8 reco_prio_tc[IEEE_8021QAZ_MAX_TCS]; 68 68 }; 69 69 70 + /* This structure contains rate limit extension to the IEEE 802.1Qaz ETS 71 + * managed object. 72 + * Values are 64 bits long and specified in Kbps to enable usage over both 73 + * slow and very fast networks. 74 + * 75 + * @tc_maxrate: maximal tc tx bandwidth indexed by traffic class 76 + */ 77 + struct ieee_maxrate { 78 + __u64 tc_maxrate[IEEE_8021QAZ_MAX_TCS]; 79 + }; 80 + 70 81 /* This structure contains the IEEE 802.1Qaz PFC managed object 71 82 * 72 83 * @pfc_cap: Indicates the number of traffic classes on the local device ··· 332 321 DCB_ATTR_IEEE_PEER_ETS, 333 322 DCB_ATTR_IEEE_PEER_PFC, 334 323 DCB_ATTR_IEEE_PEER_APP, 324 + DCB_ATTR_IEEE_MAXRATE, 335 325 __DCB_ATTR_IEEE_MAX 336 326 }; 337 327 #define DCB_ATTR_IEEE_MAX (__DCB_ATTR_IEEE_MAX - 1)
+2
include/net/dcbnl.h
··· 48 48 /* IEEE 802.1Qaz std */ 49 49 int (*ieee_getets) (struct net_device *, struct ieee_ets *); 50 50 int (*ieee_setets) (struct net_device *, struct ieee_ets *); 51 + int (*ieee_getmaxrate) (struct net_device *, struct ieee_maxrate *); 52 + int (*ieee_setmaxrate) (struct net_device *, struct ieee_maxrate *); 51 53 int (*ieee_getpfc) (struct net_device *, struct ieee_pfc *); 52 54 int (*ieee_setpfc) (struct net_device *, struct ieee_pfc *); 53 55 int (*ieee_getapp) (struct net_device *, struct dcb_app *);
+20
net/dcb/dcbnl.c
··· 178 178 [DCB_ATTR_IEEE_ETS] = {.len = sizeof(struct ieee_ets)}, 179 179 [DCB_ATTR_IEEE_PFC] = {.len = sizeof(struct ieee_pfc)}, 180 180 [DCB_ATTR_IEEE_APP_TABLE] = {.type = NLA_NESTED}, 181 + [DCB_ATTR_IEEE_MAXRATE] = {.len = sizeof(struct ieee_maxrate)}, 181 182 }; 182 183 183 184 static const struct nla_policy dcbnl_ieee_app[DCB_ATTR_IEEE_APP_MAX + 1] = { ··· 1247 1246 goto nla_put_failure; 1248 1247 } 1249 1248 1249 + if (ops->ieee_getmaxrate) { 1250 + struct ieee_maxrate maxrate; 1251 + err = ops->ieee_getmaxrate(netdev, &maxrate); 1252 + if (!err) { 1253 + err = nla_put(skb, DCB_ATTR_IEEE_MAXRATE, 1254 + sizeof(maxrate), &maxrate); 1255 + if (err) 1256 + goto nla_put_failure; 1257 + } 1258 + } 1259 + 1250 1260 if (ops->ieee_getpfc) { 1251 1261 struct ieee_pfc pfc; 1252 1262 err = ops->ieee_getpfc(netdev, &pfc); ··· 1609 1597 if (ieee[DCB_ATTR_IEEE_ETS] && ops->ieee_setets) { 1610 1598 struct ieee_ets *ets = nla_data(ieee[DCB_ATTR_IEEE_ETS]); 1611 1599 err = ops->ieee_setets(netdev, ets); 1600 + if (err) 1601 + goto err; 1602 + } 1603 + 1604 + if (ieee[DCB_ATTR_IEEE_MAXRATE] && ops->ieee_setmaxrate) { 1605 + struct ieee_maxrate *maxrate = 1606 + nla_data(ieee[DCB_ATTR_IEEE_MAXRATE]); 1607 + err = ops->ieee_setmaxrate(netdev, maxrate); 1612 1608 if (err) 1613 1609 goto err; 1614 1610 }