aboutsummaryrefslogtreecommitdiffstats
path: root/net/dcb
diff options
context:
space:
mode:
authorAlexander Duyck <alexander.h.duyck@intel.com>2008-11-21 00:10:23 -0500
committerDavid S. Miller <davem@davemloft.net>2008-11-21 00:10:23 -0500
commit859ee3c43812051e21816c6d6d4cc04fb7ce9b2e (patch)
treeef3c3717038b5d4600065550f422fd8abf72de35 /net/dcb
parent0eb3aa9bab20217fb42244ccdcb5bf8a002f504c (diff)
DCB: Add support for DCB BCN
Adds an interface to configure the Backward Congestion Notification (BCN) feature. In a BCN capabale network, congestion notifications from congested points out in the network can cause the end station limit the rate of a given traffic flow. 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>
Diffstat (limited to 'net/dcb')
-rw-r--r--net/dcb/dcbnl.c174
1 files changed, 167 insertions, 7 deletions
diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c
index 758419c6f59b..b2bda3f610df 100644
--- a/net/dcb/dcbnl.c
+++ b/net/dcb/dcbnl.c
@@ -55,14 +55,15 @@ MODULE_LICENSE("GPL");
55 55
56/* DCB netlink attributes policy */ 56/* DCB netlink attributes policy */
57static struct nla_policy dcbnl_rtnl_policy[DCB_ATTR_MAX + 1] = { 57static struct nla_policy dcbnl_rtnl_policy[DCB_ATTR_MAX + 1] = {
58 [DCB_ATTR_IFNAME] = {.type = NLA_STRING, .len = IFNAMSIZ - 1}, 58 [DCB_ATTR_IFNAME] = {.type = NLA_NUL_STRING, .len = IFNAMSIZ - 1},
59 [DCB_ATTR_STATE] = {.type = NLA_U8}, 59 [DCB_ATTR_STATE] = {.type = NLA_U8},
60 [DCB_ATTR_PFC_CFG] = {.type = NLA_NESTED}, 60 [DCB_ATTR_PFC_CFG] = {.type = NLA_NESTED},
61 [DCB_ATTR_PG_CFG] = {.type = NLA_NESTED}, 61 [DCB_ATTR_PG_CFG] = {.type = NLA_NESTED},
62 [DCB_ATTR_SET_ALL] = {.type = NLA_U8}, 62 [DCB_ATTR_SET_ALL] = {.type = NLA_U8},
63 [DCB_ATTR_PERM_HWADDR] = {.type = NLA_FLAG}, 63 [DCB_ATTR_PERM_HWADDR] = {.type = NLA_FLAG},
64 [DCB_ATTR_CAP] = {.type = NLA_NESTED}, 64 [DCB_ATTR_CAP] = {.type = NLA_NESTED},
65 [DCB_ATTR_PFC_STATE] = {.type = NLA_U8}, 65 [DCB_ATTR_PFC_STATE] = {.type = NLA_U8},
66 [DCB_ATTR_BCN] = {.type = NLA_NESTED},
66}; 67};
67 68
68/* DCB priority flow control to User Priority nested attributes */ 69/* DCB priority flow control to User Priority nested attributes */
@@ -128,6 +129,33 @@ static struct nla_policy dcbnl_numtcs_nest[DCB_NUMTCS_ATTR_MAX + 1] = {
128 [DCB_NUMTCS_ATTR_PFC] = {.type = NLA_U8}, 129 [DCB_NUMTCS_ATTR_PFC] = {.type = NLA_U8},
129}; 130};
130 131
132/* DCB BCN nested attributes. */
133static struct nla_policy dcbnl_bcn_nest[DCB_BCN_ATTR_MAX + 1] = {
134 [DCB_BCN_ATTR_RP_0] = {.type = NLA_U8},
135 [DCB_BCN_ATTR_RP_1] = {.type = NLA_U8},
136 [DCB_BCN_ATTR_RP_2] = {.type = NLA_U8},
137 [DCB_BCN_ATTR_RP_3] = {.type = NLA_U8},
138 [DCB_BCN_ATTR_RP_4] = {.type = NLA_U8},
139 [DCB_BCN_ATTR_RP_5] = {.type = NLA_U8},
140 [DCB_BCN_ATTR_RP_6] = {.type = NLA_U8},
141 [DCB_BCN_ATTR_RP_7] = {.type = NLA_U8},
142 [DCB_BCN_ATTR_RP_ALL] = {.type = NLA_FLAG},
143 [DCB_BCN_ATTR_ALPHA] = {.type = NLA_U32},
144 [DCB_BCN_ATTR_BETA] = {.type = NLA_U32},
145 [DCB_BCN_ATTR_GD] = {.type = NLA_U32},
146 [DCB_BCN_ATTR_GI] = {.type = NLA_U32},
147 [DCB_BCN_ATTR_TMAX] = {.type = NLA_U32},
148 [DCB_BCN_ATTR_TD] = {.type = NLA_U32},
149 [DCB_BCN_ATTR_RMIN] = {.type = NLA_U32},
150 [DCB_BCN_ATTR_W] = {.type = NLA_U32},
151 [DCB_BCN_ATTR_RD] = {.type = NLA_U32},
152 [DCB_BCN_ATTR_RU] = {.type = NLA_U32},
153 [DCB_BCN_ATTR_WRTT] = {.type = NLA_U32},
154 [DCB_BCN_ATTR_RI] = {.type = NLA_U32},
155 [DCB_BCN_ATTR_C] = {.type = NLA_U32},
156 [DCB_BCN_ATTR_ALL] = {.type = NLA_FLAG},
157};
158
131/* standard netlink reply call */ 159/* standard netlink reply call */
132static int dcbnl_reply(u8 value, u8 event, u8 cmd, u8 attr, u32 pid, 160static int dcbnl_reply(u8 value, u8 event, u8 cmd, u8 attr, u32 pid,
133 u32 seq, u16 flags) 161 u32 seq, u16 flags)
@@ -843,6 +871,130 @@ static int dcbnl_pgrx_setcfg(struct net_device *netdev, struct nlattr **tb,
843 return __dcbnl_pg_setcfg(netdev, tb, pid, seq, flags, 1); 871 return __dcbnl_pg_setcfg(netdev, tb, pid, seq, flags, 1);
844} 872}
845 873
874static int dcbnl_bcn_getcfg(struct net_device *netdev, struct nlattr **tb,
875 u32 pid, u32 seq, u16 flags)
876{
877 struct sk_buff *dcbnl_skb;
878 struct nlmsghdr *nlh;
879 struct dcbmsg *dcb;
880 struct nlattr *bcn_nest;
881 struct nlattr *bcn_tb[DCB_BCN_ATTR_MAX + 1];
882 u8 value_byte;
883 u32 value_integer;
884 int ret = -EINVAL;
885 bool getall = false;
886 int i;
887
888 if (!tb[DCB_ATTR_BCN] || !netdev->dcbnl_ops->getbcnrp ||
889 !netdev->dcbnl_ops->getbcncfg)
890 return ret;
891
892 ret = nla_parse_nested(bcn_tb, DCB_BCN_ATTR_MAX,
893 tb[DCB_ATTR_BCN], dcbnl_bcn_nest);
894
895 if (ret)
896 goto err_out;
897
898 dcbnl_skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
899 if (!dcbnl_skb)
900 goto err_out;
901
902 nlh = NLMSG_NEW(dcbnl_skb, pid, seq, RTM_GETDCB, sizeof(*dcb), flags);
903
904 dcb = NLMSG_DATA(nlh);
905 dcb->dcb_family = AF_UNSPEC;
906 dcb->cmd = DCB_CMD_BCN_GCFG;
907
908 bcn_nest = nla_nest_start(dcbnl_skb, DCB_ATTR_BCN);
909 if (!bcn_nest)
910 goto err;
911
912 if (bcn_tb[DCB_BCN_ATTR_ALL])
913 getall = true;
914
915 for (i = DCB_BCN_ATTR_RP_0; i <= DCB_BCN_ATTR_RP_7; i++) {
916 if (!getall && !bcn_tb[i])
917 continue;
918
919 netdev->dcbnl_ops->getbcnrp(netdev, i - DCB_BCN_ATTR_RP_0,
920 &value_byte);
921 ret = nla_put_u8(dcbnl_skb, i, value_byte);
922 if (ret)
923 goto err_bcn;
924 }
925
926 for (i = DCB_BCN_ATTR_ALPHA; i <= DCB_BCN_ATTR_RI; i++) {
927 if (!getall && !bcn_tb[i])
928 continue;
929
930 netdev->dcbnl_ops->getbcncfg(netdev, i,
931 &value_integer);
932 ret = nla_put_u32(dcbnl_skb, i, value_integer);
933 if (ret)
934 goto err_bcn;
935 }
936
937 nla_nest_end(dcbnl_skb, bcn_nest);
938
939 nlmsg_end(dcbnl_skb, nlh);
940
941 ret = rtnl_unicast(dcbnl_skb, &init_net, pid);
942 if (ret)
943 goto err;
944
945 return 0;
946
947err_bcn:
948 nla_nest_cancel(dcbnl_skb, bcn_nest);
949nlmsg_failure:
950err:
951 kfree(dcbnl_skb);
952err_out:
953 ret = -EINVAL;
954 return ret;
955}
956
957static int dcbnl_bcn_setcfg(struct net_device *netdev, struct nlattr **tb,
958 u32 pid, u32 seq, u16 flags)
959{
960 struct nlattr *data[DCB_BCN_ATTR_MAX + 1];
961 int i;
962 int ret = -EINVAL;
963 u8 value_byte;
964 u32 value_int;
965
966 if (!tb[DCB_ATTR_BCN] || !netdev->dcbnl_ops->setbcncfg
967 || !netdev->dcbnl_ops->setbcnrp)
968 return ret;
969
970 ret = nla_parse_nested(data, DCB_BCN_ATTR_MAX,
971 tb[DCB_ATTR_BCN],
972 dcbnl_pfc_up_nest);
973 if (ret)
974 goto err;
975
976 for (i = DCB_BCN_ATTR_RP_0; i <= DCB_BCN_ATTR_RP_7; i++) {
977 if (data[i] == NULL)
978 continue;
979 value_byte = nla_get_u8(data[i]);
980 netdev->dcbnl_ops->setbcnrp(netdev,
981 data[i]->nla_type - DCB_BCN_ATTR_RP_0, value_byte);
982 }
983
984 for (i = DCB_BCN_ATTR_ALPHA; i <= DCB_BCN_ATTR_RI; i++) {
985 if (data[i] == NULL)
986 continue;
987 value_int = nla_get_u32(data[i]);
988 netdev->dcbnl_ops->setbcncfg(netdev,
989 i, value_int);
990 }
991
992 ret = dcbnl_reply(0, RTM_SETDCB, DCB_CMD_BCN_SCFG, DCB_ATTR_BCN,
993 pid, seq, flags);
994err:
995 return ret;
996}
997
846static int dcb_doit(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) 998static int dcb_doit(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
847{ 999{
848 struct net *net = sock_net(skb->sk); 1000 struct net *net = sock_net(skb->sk);
@@ -891,6 +1043,10 @@ static int dcb_doit(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
891 ret = dcbnl_pgrx_getcfg(netdev, tb, pid, nlh->nlmsg_seq, 1043 ret = dcbnl_pgrx_getcfg(netdev, tb, pid, nlh->nlmsg_seq,
892 nlh->nlmsg_flags); 1044 nlh->nlmsg_flags);
893 goto out; 1045 goto out;
1046 case DCB_CMD_BCN_GCFG:
1047 ret = dcbnl_bcn_getcfg(netdev, tb, pid, nlh->nlmsg_seq,
1048 nlh->nlmsg_flags);
1049 goto out;
894 case DCB_CMD_SSTATE: 1050 case DCB_CMD_SSTATE:
895 ret = dcbnl_setstate(netdev, tb, pid, nlh->nlmsg_seq, 1051 ret = dcbnl_setstate(netdev, tb, pid, nlh->nlmsg_seq,
896 nlh->nlmsg_flags); 1052 nlh->nlmsg_flags);
@@ -932,6 +1088,10 @@ static int dcb_doit(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
932 ret = dcbnl_setpfcstate(netdev, tb, pid, nlh->nlmsg_seq, 1088 ret = dcbnl_setpfcstate(netdev, tb, pid, nlh->nlmsg_seq,
933 nlh->nlmsg_flags); 1089 nlh->nlmsg_flags);
934 goto out; 1090 goto out;
1091 case DCB_CMD_BCN_SCFG:
1092 ret = dcbnl_bcn_setcfg(netdev, tb, pid, nlh->nlmsg_seq,
1093 nlh->nlmsg_flags);
1094 goto out;
935 default: 1095 default:
936 goto errout; 1096 goto errout;
937 } 1097 }