Skip to content

Commit 08f10af

Browse files
amirvdavem330
authored andcommitted
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>
1 parent 366cddb commit 08f10af

3 files changed

Lines changed: 34 additions & 0 deletions

File tree

‎include/linux/dcbnl.h‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,17 @@ struct ieee_ets {
6767
__u8 reco_prio_tc[IEEE_8021QAZ_MAX_TCS];
6868
};
6969

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+
7081
/* This structure contains the IEEE 802.1Qaz PFC managed object
7182
*
7283
* @pfc_cap: Indicates the number of traffic classes on the local device
@@ -321,6 +332,7 @@ enum ieee_attrs {
321332
DCB_ATTR_IEEE_PEER_ETS,
322333
DCB_ATTR_IEEE_PEER_PFC,
323334
DCB_ATTR_IEEE_PEER_APP,
335+
DCB_ATTR_IEEE_MAXRATE,
324336
__DCB_ATTR_IEEE_MAX
325337
};
326338
#define DCB_ATTR_IEEE_MAX (__DCB_ATTR_IEEE_MAX - 1)

‎include/net/dcbnl.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ struct dcbnl_rtnl_ops {
4848
/* IEEE 802.1Qaz std */
4949
int (*ieee_getets) (struct net_device *, struct ieee_ets *);
5050
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 *);
5153
int (*ieee_getpfc) (struct net_device *, struct ieee_pfc *);
5254
int (*ieee_setpfc) (struct net_device *, struct ieee_pfc *);
5355
int (*ieee_getapp) (struct net_device *, struct dcb_app *);

‎net/dcb/dcbnl.c‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ static const struct nla_policy dcbnl_ieee_policy[DCB_ATTR_IEEE_MAX + 1] = {
178178
[DCB_ATTR_IEEE_ETS] = {.len = sizeof(struct ieee_ets)},
179179
[DCB_ATTR_IEEE_PFC] = {.len = sizeof(struct ieee_pfc)},
180180
[DCB_ATTR_IEEE_APP_TABLE] = {.type = NLA_NESTED},
181+
[DCB_ATTR_IEEE_MAXRATE] = {.len = sizeof(struct ieee_maxrate)},
181182
};
182183

183184
static const struct nla_policy dcbnl_ieee_app[DCB_ATTR_IEEE_APP_MAX + 1] = {
@@ -1246,6 +1247,17 @@ static int dcbnl_ieee_fill(struct sk_buff *skb, struct net_device *netdev)
12461247
goto nla_put_failure;
12471248
}
12481249

1250+
if (ops->ieee_getmaxrate) {
1251+
struct ieee_maxrate maxrate;
1252+
err = ops->ieee_getmaxrate(netdev, &maxrate);
1253+
if (!err) {
1254+
err = nla_put(skb, DCB_ATTR_IEEE_MAXRATE,
1255+
sizeof(maxrate), &maxrate);
1256+
if (err)
1257+
goto nla_put_failure;
1258+
}
1259+
}
1260+
12491261
if (ops->ieee_getpfc) {
12501262
struct ieee_pfc pfc;
12511263
err = ops->ieee_getpfc(netdev, &pfc);
@@ -1601,6 +1613,14 @@ static int dcbnl_ieee_set(struct net_device *netdev, struct nlattr **tb,
16011613
goto err;
16021614
}
16031615

1616+
if (ieee[DCB_ATTR_IEEE_MAXRATE] && ops->ieee_setmaxrate) {
1617+
struct ieee_maxrate *maxrate =
1618+
nla_data(ieee[DCB_ATTR_IEEE_MAXRATE]);
1619+
err = ops->ieee_setmaxrate(netdev, maxrate);
1620+
if (err)
1621+
goto err;
1622+
}
1623+
16041624
if (ieee[DCB_ATTR_IEEE_PFC] && ops->ieee_setpfc) {
16051625
struct ieee_pfc *pfc = nla_data(ieee[DCB_ATTR_IEEE_PFC]);
16061626
err = ops->ieee_setpfc(netdev, pfc);

0 commit comments

Comments
 (0)