Skip to content

Commit 37cf4d1

Browse files
Shmulik Raviddavem330
authored andcommitted
dcbnl: Aggregated CEE GET operation
The following couple of patches add dcbnl an unsolicited notification of the the DCB configuration for the CEE flavor of the DCBX protocol. This is useful when the user-mode DCB client is not responsible for conducting and resolving the DCBX negotiation (either because the DCBX stack is embedded in the HW or the negotiation is handled by another agent in the host), but still needs to get the negotiated parameters. This functionality already exists for the IEEE flavor of the DCBX protocol and these patches add it to the older CEE flavor. The first patch extends the CEE attribute GET operation to include not only the peer information, but also all the pertinent local configuration (negotiated parameters). The second patch adds and export a CEE specific notification routine. Signed-off-by: Shmulik Ravid <shmulikr@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent e12fe68 commit 37cf4d1

File tree

2 files changed

+173
-9
lines changed

2 files changed

+173
-9
lines changed

include/linux/dcbnl.h

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,18 +333,30 @@ enum ieee_attrs_app {
333333
#define DCB_ATTR_IEEE_APP_MAX (__DCB_ATTR_IEEE_APP_MAX - 1)
334334

335335
/**
336-
* enum cee_attrs - CEE DCBX get attributes
336+
* enum cee_attrs - CEE DCBX get attributes.
337337
*
338338
* @DCB_ATTR_CEE_UNSPEC: unspecified
339339
* @DCB_ATTR_CEE_PEER_PG: peer PG configuration - get only
340340
* @DCB_ATTR_CEE_PEER_PFC: peer PFC configuration - get only
341-
* @DCB_ATTR_CEE_PEER_APP: peer APP tlv - get only
341+
* @DCB_ATTR_CEE_PEER_APP_TABLE: peer APP tlv - get only
342+
* @DCB_ATTR_CEE_TX_PG: TX PG configuration (DCB_CMD_PGTX_GCFG)
343+
* @DCB_ATTR_CEE_RX_PG: RX PG configuration (DCB_CMD_PGRX_GCFG)
344+
* @DCB_ATTR_CEE_PFC: PFC configuration (DCB_CMD_PFC_GCFG)
345+
* @DCB_ATTR_CEE_APP_TABLE: APP configuration (multi DCB_CMD_GAPP)
346+
* @DCB_ATTR_CEE_FEAT: DCBX features flags (DCB_CMD_GFEATCFG)
347+
*
348+
* An aggregated collection of the cee std negotiated parameters.
342349
*/
343350
enum cee_attrs {
344351
DCB_ATTR_CEE_UNSPEC,
345352
DCB_ATTR_CEE_PEER_PG,
346353
DCB_ATTR_CEE_PEER_PFC,
347354
DCB_ATTR_CEE_PEER_APP_TABLE,
355+
DCB_ATTR_CEE_TX_PG,
356+
DCB_ATTR_CEE_RX_PG,
357+
DCB_ATTR_CEE_PFC,
358+
DCB_ATTR_CEE_APP_TABLE,
359+
DCB_ATTR_CEE_FEAT,
348360
__DCB_ATTR_CEE_MAX
349361
};
350362
#define DCB_ATTR_CEE_MAX (__DCB_ATTR_CEE_MAX - 1)
@@ -357,6 +369,13 @@ enum peer_app_attr {
357369
};
358370
#define DCB_ATTR_CEE_PEER_APP_MAX (__DCB_ATTR_CEE_PEER_APP_MAX - 1)
359371

372+
enum cee_attrs_app {
373+
DCB_ATTR_CEE_APP_UNSPEC,
374+
DCB_ATTR_CEE_APP,
375+
__DCB_ATTR_CEE_APP_MAX
376+
};
377+
#define DCB_ATTR_CEE_APP_MAX (__DCB_ATTR_CEE_APP_MAX - 1)
378+
360379
/**
361380
* enum dcbnl_pfc_attrs - DCB Priority Flow Control user priority nested attrs
362381
*

net/dcb/dcbnl.c

Lines changed: 152 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1642,16 +1642,72 @@ static int dcbnl_setfeatcfg(struct net_device *netdev, struct nlattr **tb,
16421642
return ret;
16431643
}
16441644

1645+
static int dcbnl_cee_pg_fill(struct sk_buff *skb, struct net_device *dev,
1646+
int dir)
1647+
{
1648+
u8 pgid, up_map, prio, tc_pct;
1649+
const struct dcbnl_rtnl_ops *ops = dev->dcbnl_ops;
1650+
int i = dir ? DCB_ATTR_CEE_TX_PG : DCB_ATTR_CEE_RX_PG;
1651+
struct nlattr *pg = nla_nest_start(skb, i);
1652+
1653+
if (!pg)
1654+
goto nla_put_failure;
1655+
1656+
for (i = DCB_PG_ATTR_TC_0; i <= DCB_PG_ATTR_TC_7; i++) {
1657+
struct nlattr *tc_nest = nla_nest_start(skb, i);
1658+
1659+
if (!tc_nest)
1660+
goto nla_put_failure;
1661+
1662+
pgid = DCB_ATTR_VALUE_UNDEFINED;
1663+
prio = DCB_ATTR_VALUE_UNDEFINED;
1664+
tc_pct = DCB_ATTR_VALUE_UNDEFINED;
1665+
up_map = DCB_ATTR_VALUE_UNDEFINED;
1666+
1667+
if (!dir)
1668+
ops->getpgtccfgrx(dev, i - DCB_PG_ATTR_TC_0,
1669+
&prio, &pgid, &tc_pct, &up_map);
1670+
else
1671+
ops->getpgtccfgtx(dev, i - DCB_PG_ATTR_TC_0,
1672+
&prio, &pgid, &tc_pct, &up_map);
1673+
1674+
NLA_PUT_U8(skb, DCB_TC_ATTR_PARAM_PGID, pgid);
1675+
NLA_PUT_U8(skb, DCB_TC_ATTR_PARAM_UP_MAPPING, up_map);
1676+
NLA_PUT_U8(skb, DCB_TC_ATTR_PARAM_STRICT_PRIO, prio);
1677+
NLA_PUT_U8(skb, DCB_TC_ATTR_PARAM_BW_PCT, tc_pct);
1678+
nla_nest_end(skb, tc_nest);
1679+
}
1680+
1681+
for (i = DCB_PG_ATTR_BW_ID_0; i <= DCB_PG_ATTR_BW_ID_7; i++) {
1682+
tc_pct = DCB_ATTR_VALUE_UNDEFINED;
1683+
1684+
if (!dir)
1685+
ops->getpgbwgcfgrx(dev, i - DCB_PG_ATTR_BW_ID_0,
1686+
&tc_pct);
1687+
else
1688+
ops->getpgbwgcfgtx(dev, i - DCB_PG_ATTR_BW_ID_0,
1689+
&tc_pct);
1690+
NLA_PUT_U8(skb, i, tc_pct);
1691+
}
1692+
nla_nest_end(skb, pg);
1693+
return 0;
1694+
1695+
nla_put_failure:
1696+
return -EMSGSIZE;
1697+
}
1698+
16451699
/* Handle CEE DCBX GET commands. */
16461700
static int dcbnl_cee_get(struct net_device *netdev, struct nlattr **tb,
16471701
u32 pid, u32 seq, u16 flags)
16481702
{
16491703
struct sk_buff *skb;
16501704
struct nlmsghdr *nlh;
16511705
struct dcbmsg *dcb;
1652-
struct nlattr *cee;
1706+
struct nlattr *cee, *app;
1707+
struct dcb_app_type *itr;
16531708
const struct dcbnl_rtnl_ops *ops = netdev->dcbnl_ops;
1654-
int err;
1709+
int dcbx, i, err = -EMSGSIZE;
1710+
u8 value;
16551711

16561712
if (!ops)
16571713
return -EOPNOTSUPP;
@@ -1672,7 +1728,88 @@ static int dcbnl_cee_get(struct net_device *netdev, struct nlattr **tb,
16721728
if (!cee)
16731729
goto nla_put_failure;
16741730

1675-
/* get peer info if available */
1731+
/* local pg */
1732+
if (ops->getpgtccfgtx && ops->getpgbwgcfgtx) {
1733+
err = dcbnl_cee_pg_fill(skb, netdev, 1);
1734+
if (err)
1735+
goto nla_put_failure;
1736+
}
1737+
1738+
if (ops->getpgtccfgrx && ops->getpgbwgcfgrx) {
1739+
err = dcbnl_cee_pg_fill(skb, netdev, 0);
1740+
if (err)
1741+
goto nla_put_failure;
1742+
}
1743+
1744+
/* local pfc */
1745+
if (ops->getpfccfg) {
1746+
struct nlattr *pfc_nest = nla_nest_start(skb, DCB_ATTR_CEE_PFC);
1747+
1748+
if (!pfc_nest)
1749+
goto nla_put_failure;
1750+
1751+
for (i = DCB_PFC_UP_ATTR_0; i <= DCB_PFC_UP_ATTR_7; i++) {
1752+
ops->getpfccfg(netdev, i - DCB_PFC_UP_ATTR_0, &value);
1753+
NLA_PUT_U8(skb, i, value);
1754+
}
1755+
nla_nest_end(skb, pfc_nest);
1756+
}
1757+
1758+
/* local app */
1759+
spin_lock(&dcb_lock);
1760+
app = nla_nest_start(skb, DCB_ATTR_CEE_APP_TABLE);
1761+
if (!app)
1762+
goto nla_put_failure;
1763+
1764+
list_for_each_entry(itr, &dcb_app_list, list) {
1765+
if (strncmp(itr->name, netdev->name, IFNAMSIZ) == 0) {
1766+
struct nlattr *app_nest = nla_nest_start(skb,
1767+
DCB_ATTR_APP);
1768+
if (!app_nest)
1769+
goto dcb_unlock;
1770+
1771+
err = nla_put_u8(skb, DCB_APP_ATTR_IDTYPE,
1772+
itr->app.selector);
1773+
if (err)
1774+
goto dcb_unlock;
1775+
1776+
err = nla_put_u16(skb, DCB_APP_ATTR_ID,
1777+
itr->app.protocol);
1778+
if (err)
1779+
goto dcb_unlock;
1780+
1781+
err = nla_put_u8(skb, DCB_APP_ATTR_PRIORITY,
1782+
itr->app.priority);
1783+
if (err)
1784+
goto dcb_unlock;
1785+
1786+
nla_nest_end(skb, app_nest);
1787+
}
1788+
}
1789+
nla_nest_end(skb, app);
1790+
1791+
if (netdev->dcbnl_ops->getdcbx)
1792+
dcbx = netdev->dcbnl_ops->getdcbx(netdev);
1793+
else
1794+
dcbx = -EOPNOTSUPP;
1795+
1796+
spin_unlock(&dcb_lock);
1797+
1798+
/* features flags */
1799+
if (ops->getfeatcfg) {
1800+
struct nlattr *feat = nla_nest_start(skb, DCB_ATTR_CEE_FEAT);
1801+
if (!feat)
1802+
goto nla_put_failure;
1803+
1804+
for (i = DCB_FEATCFG_ATTR_ALL + 1; i <= DCB_FEATCFG_ATTR_MAX;
1805+
i++)
1806+
if (!ops->getfeatcfg(netdev, i, &value))
1807+
NLA_PUT_U8(skb, i, value);
1808+
1809+
nla_nest_end(skb, feat);
1810+
}
1811+
1812+
/* peer info if available */
16761813
if (ops->cee_peer_getpg) {
16771814
struct cee_pg pg;
16781815
err = ops->cee_peer_getpg(netdev, &pg);
@@ -1695,16 +1832,24 @@ static int dcbnl_cee_get(struct net_device *netdev, struct nlattr **tb,
16951832
if (err)
16961833
goto nla_put_failure;
16971834
}
1698-
16991835
nla_nest_end(skb, cee);
1700-
nlmsg_end(skb, nlh);
17011836

1837+
/* DCBX state */
1838+
if (dcbx >= 0) {
1839+
err = nla_put_u8(skb, DCB_ATTR_DCBX, dcbx);
1840+
if (err)
1841+
goto nla_put_failure;
1842+
}
1843+
nlmsg_end(skb, nlh);
17021844
return rtnl_unicast(skb, &init_net, pid);
1845+
1846+
dcb_unlock:
1847+
spin_unlock(&dcb_lock);
17031848
nla_put_failure:
17041849
nlmsg_cancel(skb, nlh);
17051850
nlmsg_failure:
1706-
kfree_skb(skb);
1707-
return -1;
1851+
nlmsg_free(skb);
1852+
return err;
17081853
}
17091854

17101855
static int dcb_doit(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)

0 commit comments

Comments
 (0)