Skip to content

Commit 0eb3aa9

Browse files
Alexander Duyckdavem330
authored andcommitted
DCB: Add interface to query the state of PFC feature.
Adds a netlink interface for Data Center Bridging (DCB) to get and set the enable state of the Priority Flow Control (PFC) feature. Primarily, this is a way to turn off PFC in the driver while DCB remains enabled. Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com> Signed-off-by: Peter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 33dbabc commit 0eb3aa9

4 files changed

Lines changed: 62 additions & 1 deletion

File tree

‎drivers/net/ixgbe/ixgbe_dcb_nl.c‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,18 @@ static u8 ixgbe_dcbnl_setnumtcs(struct net_device *netdev, int tcid, u8 num)
405405
return -EINVAL;
406406
}
407407

408+
static u8 ixgbe_dcbnl_getpfcstate(struct net_device *netdev)
409+
{
410+
struct ixgbe_adapter *adapter = netdev_priv(netdev);
411+
412+
return !!(adapter->flags & IXGBE_FLAG_DCB_ENABLED);
413+
}
414+
415+
static void ixgbe_dcbnl_setpfcstate(struct net_device *netdev, u8 state)
416+
{
417+
return;
418+
}
419+
408420
struct dcbnl_rtnl_ops dcbnl_ops = {
409421
.getstate = ixgbe_dcbnl_get_state,
410422
.setstate = ixgbe_dcbnl_set_state,
@@ -422,6 +434,8 @@ struct dcbnl_rtnl_ops dcbnl_ops = {
422434
.setall = ixgbe_dcbnl_set_all,
423435
.getcap = ixgbe_dcbnl_getcap,
424436
.getnumtcs = ixgbe_dcbnl_getnumtcs,
425-
.setnumtcs = ixgbe_dcbnl_setnumtcs
437+
.setnumtcs = ixgbe_dcbnl_setnumtcs,
438+
.getpfcstate = ixgbe_dcbnl_getpfcstate,
439+
.setpfcstate = ixgbe_dcbnl_setpfcstate
426440
};
427441

‎include/linux/dcbnl.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ enum dcbnl_commands {
6666
DCB_CMD_GCAP,
6767
DCB_CMD_GNUMTCS,
6868
DCB_CMD_SNUMTCS,
69+
DCB_CMD_PFC_GSTATE,
70+
DCB_CMD_PFC_SSTATE,
6971

7072
__DCB_CMD_ENUM_MAX,
7173
DCB_CMD_MAX = __DCB_CMD_ENUM_MAX - 1,

‎include/net/dcbnl.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ struct dcbnl_rtnl_ops {
4242
u8 (*getcap)(struct net_device *, int, u8 *);
4343
u8 (*getnumtcs)(struct net_device *, int, u8 *);
4444
u8 (*setnumtcs)(struct net_device *, int, u8);
45+
u8 (*getpfcstate)(struct net_device *);
46+
void (*setpfcstate)(struct net_device *, u8);
4547
};
4648

4749
#endif /* __NET_DCBNL_H__ */

‎net/dcb/dcbnl.c‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ static struct nla_policy dcbnl_rtnl_policy[DCB_ATTR_MAX + 1] = {
6262
[DCB_ATTR_SET_ALL] = {.type = NLA_U8},
6363
[DCB_ATTR_PERM_HWADDR] = {.type = NLA_FLAG},
6464
[DCB_ATTR_CAP] = {.type = NLA_NESTED},
65+
[DCB_ATTR_PFC_STATE] = {.type = NLA_U8},
6566
};
6667

6768
/* DCB priority flow control to User Priority nested attributes */
@@ -471,6 +472,40 @@ static int dcbnl_setnumtcs(struct net_device *netdev, struct nlattr **tb,
471472
return ret;
472473
}
473474

475+
static int dcbnl_getpfcstate(struct net_device *netdev, struct nlattr **tb,
476+
u32 pid, u32 seq, u16 flags)
477+
{
478+
int ret = -EINVAL;
479+
480+
if (!netdev->dcbnl_ops->getpfcstate)
481+
return ret;
482+
483+
ret = dcbnl_reply(netdev->dcbnl_ops->getpfcstate(netdev), RTM_GETDCB,
484+
DCB_CMD_PFC_GSTATE, DCB_ATTR_PFC_STATE,
485+
pid, seq, flags);
486+
487+
return ret;
488+
}
489+
490+
static int dcbnl_setpfcstate(struct net_device *netdev, struct nlattr **tb,
491+
u32 pid, u32 seq, u16 flags)
492+
{
493+
int ret = -EINVAL;
494+
u8 value;
495+
496+
if (!tb[DCB_ATTR_PFC_STATE] || !netdev->dcbnl_ops->setpfcstate)
497+
return ret;
498+
499+
value = nla_get_u8(tb[DCB_ATTR_PFC_STATE]);
500+
501+
netdev->dcbnl_ops->setpfcstate(netdev, value);
502+
503+
ret = dcbnl_reply(0, RTM_SETDCB, DCB_CMD_PFC_SSTATE, DCB_ATTR_PFC_STATE,
504+
pid, seq, flags);
505+
506+
return ret;
507+
}
508+
474509
static int __dcbnl_pg_getcfg(struct net_device *netdev, struct nlattr **tb,
475510
u32 pid, u32 seq, u16 flags, int dir)
476511
{
@@ -889,6 +924,14 @@ static int dcb_doit(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
889924
ret = dcbnl_setnumtcs(netdev, tb, pid, nlh->nlmsg_seq,
890925
nlh->nlmsg_flags);
891926
goto out;
927+
case DCB_CMD_PFC_GSTATE:
928+
ret = dcbnl_getpfcstate(netdev, tb, pid, nlh->nlmsg_seq,
929+
nlh->nlmsg_flags);
930+
goto out;
931+
case DCB_CMD_PFC_SSTATE:
932+
ret = dcbnl_setpfcstate(netdev, tb, pid, nlh->nlmsg_seq,
933+
nlh->nlmsg_flags);
934+
goto out;
892935
default:
893936
goto errout;
894937
}

0 commit comments

Comments
 (0)