aboutsummaryrefslogtreecommitdiffstats
path: root/net/dcb
diff options
context:
space:
mode:
authorShmulik Ravid <shmulikr@broadcom.com>2011-02-27 00:04:38 -0500
committerDavid S. Miller <davem@davemloft.net>2011-03-03 00:58:55 -0500
commitdc6ed1df5a5f84e45e77e2acb6fd99b995414956 (patch)
tree3decaad599f29cb097fc370f1ed92a18fa3596ea /net/dcb
parenteed84713bc47ce2f7d675914f297ad9b6227a587 (diff)
dcbnl: add support for retrieving peer configuration - cee
This patch adds the support for retrieving the remote or peer DCBX configuration via dcbnl for embedded DCBX stacks supporting the CEE DCBX standard. Signed-off-by: Shmulik Ravid <shmulikr@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dcb')
-rw-r--r--net/dcb/dcbnl.c85
1 files changed, 81 insertions, 4 deletions
diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c
index 2e6dcf2967e2..d8b4f725b778 100644
--- a/net/dcb/dcbnl.c
+++ b/net/dcb/dcbnl.c
@@ -1224,7 +1224,9 @@ err:
1224 return err; 1224 return err;
1225} 1225}
1226 1226
1227static int dcbnl_build_peer_app(struct net_device *netdev, struct sk_buff* skb) 1227static int dcbnl_build_peer_app(struct net_device *netdev, struct sk_buff* skb,
1228 int app_nested_type, int app_info_type,
1229 int app_entry_type)
1228{ 1230{
1229 struct dcb_peer_app_info info; 1231 struct dcb_peer_app_info info;
1230 struct dcb_app *table = NULL; 1232 struct dcb_app *table = NULL;
@@ -1256,12 +1258,15 @@ static int dcbnl_build_peer_app(struct net_device *netdev, struct sk_buff* skb)
1256 */ 1258 */
1257 err = -EMSGSIZE; 1259 err = -EMSGSIZE;
1258 1260
1259 app = nla_nest_start(skb, DCB_ATTR_IEEE_PEER_APP); 1261 app = nla_nest_start(skb, app_nested_type);
1260 if (!app) 1262 if (!app)
1261 goto nla_put_failure; 1263 goto nla_put_failure;
1262 1264
1265 if (app_info_type)
1266 NLA_PUT(skb, app_info_type, sizeof(info), &info);
1267
1263 for (i = 0; i < app_count; i++) 1268 for (i = 0; i < app_count; i++)
1264 NLA_PUT(skb, DCB_ATTR_IEEE_APP, sizeof(struct dcb_app), 1269 NLA_PUT(skb, app_entry_type, sizeof(struct dcb_app),
1265 &table[i]); 1270 &table[i]);
1266 1271
1267 nla_nest_end(skb, app); 1272 nla_nest_end(skb, app);
@@ -1352,7 +1357,10 @@ static int dcbnl_ieee_get(struct net_device *netdev, struct nlattr **tb,
1352 } 1357 }
1353 1358
1354 if (ops->peer_getappinfo && ops->peer_getapptable) { 1359 if (ops->peer_getappinfo && ops->peer_getapptable) {
1355 err = dcbnl_build_peer_app(netdev, skb); 1360 err = dcbnl_build_peer_app(netdev, skb,
1361 DCB_ATTR_IEEE_PEER_APP,
1362 DCB_ATTR_IEEE_APP_UNSPEC,
1363 DCB_ATTR_IEEE_APP);
1356 if (err) 1364 if (err)
1357 goto nla_put_failure; 1365 goto nla_put_failure;
1358 } 1366 }
@@ -1510,6 +1518,71 @@ err:
1510 return ret; 1518 return ret;
1511} 1519}
1512 1520
1521/* Handle CEE DCBX GET commands. */
1522static int dcbnl_cee_get(struct net_device *netdev, struct nlattr **tb,
1523 u32 pid, u32 seq, u16 flags)
1524{
1525 struct sk_buff *skb;
1526 struct nlmsghdr *nlh;
1527 struct dcbmsg *dcb;
1528 struct nlattr *cee;
1529 const struct dcbnl_rtnl_ops *ops = netdev->dcbnl_ops;
1530 int err;
1531
1532 if (!ops)
1533 return -EOPNOTSUPP;
1534
1535 skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
1536 if (!skb)
1537 return -ENOBUFS;
1538
1539 nlh = NLMSG_NEW(skb, pid, seq, RTM_GETDCB, sizeof(*dcb), flags);
1540
1541 dcb = NLMSG_DATA(nlh);
1542 dcb->dcb_family = AF_UNSPEC;
1543 dcb->cmd = DCB_CMD_CEE_GET;
1544
1545 NLA_PUT_STRING(skb, DCB_ATTR_IFNAME, netdev->name);
1546
1547 cee = nla_nest_start(skb, DCB_ATTR_CEE);
1548 if (!cee)
1549 goto nla_put_failure;
1550
1551 /* get peer info if available */
1552 if (ops->cee_peer_getpg) {
1553 struct cee_pg pg;
1554 err = ops->cee_peer_getpg(netdev, &pg);
1555 if (!err)
1556 NLA_PUT(skb, DCB_ATTR_CEE_PEER_PG, sizeof(pg), &pg);
1557 }
1558
1559 if (ops->cee_peer_getpfc) {
1560 struct cee_pfc pfc;
1561 err = ops->cee_peer_getpfc(netdev, &pfc);
1562 if (!err)
1563 NLA_PUT(skb, DCB_ATTR_CEE_PEER_PFC, sizeof(pfc), &pfc);
1564 }
1565
1566 if (ops->peer_getappinfo && ops->peer_getapptable) {
1567 err = dcbnl_build_peer_app(netdev, skb,
1568 DCB_ATTR_CEE_PEER_APP_TABLE,
1569 DCB_ATTR_CEE_PEER_APP_INFO,
1570 DCB_ATTR_CEE_PEER_APP);
1571 if (err)
1572 goto nla_put_failure;
1573 }
1574
1575 nla_nest_end(skb, cee);
1576 nlmsg_end(skb, nlh);
1577
1578 return rtnl_unicast(skb, &init_net, pid);
1579nla_put_failure:
1580 nlmsg_cancel(skb, nlh);
1581nlmsg_failure:
1582 kfree_skb(skb);
1583 return -1;
1584}
1585
1513static int dcb_doit(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) 1586static int dcb_doit(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
1514{ 1587{
1515 struct net *net = sock_net(skb->sk); 1588 struct net *net = sock_net(skb->sk);
@@ -1639,6 +1712,10 @@ static int dcb_doit(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
1639 ret = dcbnl_setfeatcfg(netdev, tb, pid, nlh->nlmsg_seq, 1712 ret = dcbnl_setfeatcfg(netdev, tb, pid, nlh->nlmsg_seq,
1640 nlh->nlmsg_flags); 1713 nlh->nlmsg_flags);
1641 goto out; 1714 goto out;
1715 case DCB_CMD_CEE_GET:
1716 ret = dcbnl_cee_get(netdev, tb, pid, nlh->nlmsg_seq,
1717 nlh->nlmsg_flags);
1718 goto out;
1642 default: 1719 default:
1643 goto errout; 1720 goto errout;
1644 } 1721 }