diff options
author | Shmulik Ravid <shmulikr@broadcom.com> | 2010-12-30 01:26:48 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-12-31 13:50:54 -0500 |
commit | 6241b6259b16aa390ff4bf50f520685b3801200b (patch) | |
tree | e80fbdd538b1edd1220b93103b66271194a0653d | |
parent | 96b99684e365f28d49bdb1221ca022b75cb91a98 (diff) |
dcbnl: adding DCBX engine capability
Adding an optional DCBX capability and a pair for get-set routines for
setting the device DCBX mode. The DCBX capability is a bit field of
supported attributes. The user is expected to set the DCBX mode with a
subset of the advertised attributes.
This patch is dependent on the following patches:
[net-next-2.6 PATCH 1/3] dcbnl: add support for ieee8021Qaz attributes
[net-next-2.6 PATCH 2/3] dcbnl: add appliction tlv handlers
[net-next-2.6 PATCH 3/3] net_dcb: add application notifiers
Signed-off-by: Shmulik Ravid <shmulikr@broadcom.com>
Acked-by: John Fastabend <john.r.fastabend@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/linux/dcbnl.h | 43 | ||||
-rw-r--r-- | include/net/dcbnl.h | 5 | ||||
-rw-r--r-- | net/dcb/dcbnl.c | 43 |
3 files changed, 91 insertions, 0 deletions
diff --git a/include/linux/dcbnl.h b/include/linux/dcbnl.h index 775bdb4465bf..16eea36d8934 100644 --- a/include/linux/dcbnl.h +++ b/include/linux/dcbnl.h | |||
@@ -135,6 +135,8 @@ struct dcbmsg { | |||
135 | * @DCB_CMD_SAPP: set application protocol configuration | 135 | * @DCB_CMD_SAPP: set application protocol configuration |
136 | * @DCB_CMD_IEEE_SET: set IEEE 802.1Qaz configuration | 136 | * @DCB_CMD_IEEE_SET: set IEEE 802.1Qaz configuration |
137 | * @DCB_CMD_IEEE_GET: get IEEE 802.1Qaz configuration | 137 | * @DCB_CMD_IEEE_GET: get IEEE 802.1Qaz configuration |
138 | * @DCB_CMD_GDCBX: get DCBX engine configuration | ||
139 | * @DCB_CMD_SDCBX: set DCBX engine configuration | ||
138 | */ | 140 | */ |
139 | enum dcbnl_commands { | 141 | enum dcbnl_commands { |
140 | DCB_CMD_UNDEFINED, | 142 | DCB_CMD_UNDEFINED, |
@@ -171,6 +173,9 @@ enum dcbnl_commands { | |||
171 | DCB_CMD_IEEE_SET, | 173 | DCB_CMD_IEEE_SET, |
172 | DCB_CMD_IEEE_GET, | 174 | DCB_CMD_IEEE_GET, |
173 | 175 | ||
176 | DCB_CMD_GDCBX, | ||
177 | DCB_CMD_SDCBX, | ||
178 | |||
174 | __DCB_CMD_ENUM_MAX, | 179 | __DCB_CMD_ENUM_MAX, |
175 | DCB_CMD_MAX = __DCB_CMD_ENUM_MAX - 1, | 180 | DCB_CMD_MAX = __DCB_CMD_ENUM_MAX - 1, |
176 | }; | 181 | }; |
@@ -191,6 +196,7 @@ enum dcbnl_commands { | |||
191 | * @DCB_ATTR_NUMTCS: number of traffic classes supported (NLA_NESTED) | 196 | * @DCB_ATTR_NUMTCS: number of traffic classes supported (NLA_NESTED) |
192 | * @DCB_ATTR_BCN: backward congestion notification configuration (NLA_NESTED) | 197 | * @DCB_ATTR_BCN: backward congestion notification configuration (NLA_NESTED) |
193 | * @DCB_ATTR_IEEE: IEEE 802.1Qaz supported attributes (NLA_NESTED) | 198 | * @DCB_ATTR_IEEE: IEEE 802.1Qaz supported attributes (NLA_NESTED) |
199 | * @DCB_ATTR_DCBX: DCBX engine configuration in the device (NLA_U8) | ||
194 | */ | 200 | */ |
195 | enum dcbnl_attrs { | 201 | enum dcbnl_attrs { |
196 | DCB_ATTR_UNDEFINED, | 202 | DCB_ATTR_UNDEFINED, |
@@ -211,6 +217,8 @@ enum dcbnl_attrs { | |||
211 | /* IEEE std attributes */ | 217 | /* IEEE std attributes */ |
212 | DCB_ATTR_IEEE, | 218 | DCB_ATTR_IEEE, |
213 | 219 | ||
220 | DCB_ATTR_DCBX, | ||
221 | |||
214 | __DCB_ATTR_ENUM_MAX, | 222 | __DCB_ATTR_ENUM_MAX, |
215 | DCB_ATTR_MAX = __DCB_ATTR_ENUM_MAX - 1, | 223 | DCB_ATTR_MAX = __DCB_ATTR_ENUM_MAX - 1, |
216 | }; | 224 | }; |
@@ -370,6 +378,8 @@ enum dcbnl_tc_attrs { | |||
370 | * @DCB_CAP_ATTR_GSP: (NLA_U8) device supports group strict priority | 378 | * @DCB_CAP_ATTR_GSP: (NLA_U8) device supports group strict priority |
371 | * @DCB_CAP_ATTR_BCN: (NLA_U8) device supports Backwards Congestion | 379 | * @DCB_CAP_ATTR_BCN: (NLA_U8) device supports Backwards Congestion |
372 | * Notification | 380 | * Notification |
381 | * @DCB_CAP_ATTR_DCBX: (NLA_U8) device supports DCBX engine | ||
382 | * | ||
373 | */ | 383 | */ |
374 | enum dcbnl_cap_attrs { | 384 | enum dcbnl_cap_attrs { |
375 | DCB_CAP_ATTR_UNDEFINED, | 385 | DCB_CAP_ATTR_UNDEFINED, |
@@ -381,12 +391,45 @@ enum dcbnl_cap_attrs { | |||
381 | DCB_CAP_ATTR_PFC_TCS, | 391 | DCB_CAP_ATTR_PFC_TCS, |
382 | DCB_CAP_ATTR_GSP, | 392 | DCB_CAP_ATTR_GSP, |
383 | DCB_CAP_ATTR_BCN, | 393 | DCB_CAP_ATTR_BCN, |
394 | DCB_CAP_ATTR_DCBX, | ||
384 | 395 | ||
385 | __DCB_CAP_ATTR_ENUM_MAX, | 396 | __DCB_CAP_ATTR_ENUM_MAX, |
386 | DCB_CAP_ATTR_MAX = __DCB_CAP_ATTR_ENUM_MAX - 1, | 397 | DCB_CAP_ATTR_MAX = __DCB_CAP_ATTR_ENUM_MAX - 1, |
387 | }; | 398 | }; |
388 | 399 | ||
389 | /** | 400 | /** |
401 | * DCBX capability flags | ||
402 | * | ||
403 | * @DCB_CAP_DCBX_HOST: DCBX negotiation is performed by the host LLDP agent. | ||
404 | * 'set' routines are used to configure the device with | ||
405 | * the negotiated parameters | ||
406 | * | ||
407 | * @DCB_CAP_DCBX_LLD_MANAGED: DCBX negotiation is not performed in the host but | ||
408 | * by another entity | ||
409 | * 'get' routines are used to retrieve the | ||
410 | * negotiated parameters | ||
411 | * 'set' routines can be used to set the initial | ||
412 | * negotiation configuration | ||
413 | * | ||
414 | * @DCB_CAP_DCBX_VER_CEE: for a non-host DCBX engine, indicates the engine | ||
415 | * supports the CEE protocol flavor | ||
416 | * | ||
417 | * @DCB_CAP_DCBX_VER_IEEE: for a non-host DCBX engine, indicates the engine | ||
418 | * supports the IEEE protocol flavor | ||
419 | * | ||
420 | * @DCB_CAP_DCBX_STATIC: for a non-host DCBX engine, indicates the engine | ||
421 | * supports static configuration (i.e no actual | ||
422 | * negotiation is performed negotiated parameters equal | ||
423 | * the initial configuration) | ||
424 | * | ||
425 | */ | ||
426 | #define DCB_CAP_DCBX_HOST 0x01 | ||
427 | #define DCB_CAP_DCBX_LLD_MANAGED 0x02 | ||
428 | #define DCB_CAP_DCBX_VER_CEE 0x04 | ||
429 | #define DCB_CAP_DCBX_VER_IEEE 0x08 | ||
430 | #define DCB_CAP_DCBX_STATIC 0x10 | ||
431 | |||
432 | /** | ||
390 | * enum dcbnl_numtcs_attrs - number of traffic classes | 433 | * enum dcbnl_numtcs_attrs - number of traffic classes |
391 | * | 434 | * |
392 | * @DCB_NUMTCS_ATTR_UNDEFINED: unspecified attribute to catch errors | 435 | * @DCB_NUMTCS_ATTR_UNDEFINED: unspecified attribute to catch errors |
diff --git a/include/net/dcbnl.h b/include/net/dcbnl.h index ab7d623a2793..c65347b3cbbf 100644 --- a/include/net/dcbnl.h +++ b/include/net/dcbnl.h | |||
@@ -70,6 +70,11 @@ struct dcbnl_rtnl_ops { | |||
70 | void (*setbcnrp)(struct net_device *, int, u8); | 70 | void (*setbcnrp)(struct net_device *, int, u8); |
71 | u8 (*setapp)(struct net_device *, u8, u16, u8); | 71 | u8 (*setapp)(struct net_device *, u8, u16, u8); |
72 | u8 (*getapp)(struct net_device *, u8, u16); | 72 | u8 (*getapp)(struct net_device *, u8, u16); |
73 | |||
74 | /* DCBX configuration */ | ||
75 | u8 (*getdcbx)(struct net_device *); | ||
76 | u8 (*setdcbx)(struct net_device *, u8); | ||
77 | |||
73 | }; | 78 | }; |
74 | 79 | ||
75 | #endif /* __NET_DCBNL_H__ */ | 80 | #endif /* __NET_DCBNL_H__ */ |
diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c index 69144125fc4f..8f83ad859d9b 100644 --- a/net/dcb/dcbnl.c +++ b/net/dcb/dcbnl.c | |||
@@ -68,6 +68,7 @@ static const struct nla_policy dcbnl_rtnl_policy[DCB_ATTR_MAX + 1] = { | |||
68 | [DCB_ATTR_BCN] = {.type = NLA_NESTED}, | 68 | [DCB_ATTR_BCN] = {.type = NLA_NESTED}, |
69 | [DCB_ATTR_APP] = {.type = NLA_NESTED}, | 69 | [DCB_ATTR_APP] = {.type = NLA_NESTED}, |
70 | [DCB_ATTR_IEEE] = {.type = NLA_NESTED}, | 70 | [DCB_ATTR_IEEE] = {.type = NLA_NESTED}, |
71 | [DCB_ATTR_DCBX] = {.type = NLA_U8}, | ||
71 | }; | 72 | }; |
72 | 73 | ||
73 | /* DCB priority flow control to User Priority nested attributes */ | 74 | /* DCB priority flow control to User Priority nested attributes */ |
@@ -124,6 +125,7 @@ static const struct nla_policy dcbnl_cap_nest[DCB_CAP_ATTR_MAX + 1] = { | |||
124 | [DCB_CAP_ATTR_PFC_TCS] = {.type = NLA_U8}, | 125 | [DCB_CAP_ATTR_PFC_TCS] = {.type = NLA_U8}, |
125 | [DCB_CAP_ATTR_GSP] = {.type = NLA_U8}, | 126 | [DCB_CAP_ATTR_GSP] = {.type = NLA_U8}, |
126 | [DCB_CAP_ATTR_BCN] = {.type = NLA_U8}, | 127 | [DCB_CAP_ATTR_BCN] = {.type = NLA_U8}, |
128 | [DCB_CAP_ATTR_DCBX] = {.type = NLA_U8}, | ||
127 | }; | 129 | }; |
128 | 130 | ||
129 | /* DCB capabilities nested attributes. */ | 131 | /* DCB capabilities nested attributes. */ |
@@ -1271,6 +1273,39 @@ nlmsg_failure: | |||
1271 | return -1; | 1273 | return -1; |
1272 | } | 1274 | } |
1273 | 1275 | ||
1276 | /* DCBX configuration */ | ||
1277 | static int dcbnl_getdcbx(struct net_device *netdev, struct nlattr **tb, | ||
1278 | u32 pid, u32 seq, u16 flags) | ||
1279 | { | ||
1280 | int ret = -EINVAL; | ||
1281 | |||
1282 | if (!netdev->dcbnl_ops->getdcbx) | ||
1283 | return ret; | ||
1284 | |||
1285 | ret = dcbnl_reply(netdev->dcbnl_ops->getdcbx(netdev), RTM_GETDCB, | ||
1286 | DCB_CMD_GDCBX, DCB_ATTR_DCBX, pid, seq, flags); | ||
1287 | |||
1288 | return ret; | ||
1289 | } | ||
1290 | |||
1291 | static int dcbnl_setdcbx(struct net_device *netdev, struct nlattr **tb, | ||
1292 | u32 pid, u32 seq, u16 flags) | ||
1293 | { | ||
1294 | int ret = -EINVAL; | ||
1295 | u8 value; | ||
1296 | |||
1297 | if (!tb[DCB_ATTR_DCBX] || !netdev->dcbnl_ops->setdcbx) | ||
1298 | return ret; | ||
1299 | |||
1300 | value = nla_get_u8(tb[DCB_ATTR_DCBX]); | ||
1301 | |||
1302 | ret = dcbnl_reply(netdev->dcbnl_ops->setdcbx(netdev, value), | ||
1303 | RTM_SETDCB, DCB_CMD_SDCBX, DCB_ATTR_DCBX, | ||
1304 | pid, seq, flags); | ||
1305 | |||
1306 | return ret; | ||
1307 | } | ||
1308 | |||
1274 | static int dcb_doit(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) | 1309 | static int dcb_doit(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) |
1275 | { | 1310 | { |
1276 | struct net *net = sock_net(skb->sk); | 1311 | struct net *net = sock_net(skb->sk); |
@@ -1384,6 +1419,14 @@ static int dcb_doit(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) | |||
1384 | ret = dcbnl_ieee_get(netdev, tb, pid, nlh->nlmsg_seq, | 1419 | ret = dcbnl_ieee_get(netdev, tb, pid, nlh->nlmsg_seq, |
1385 | nlh->nlmsg_flags); | 1420 | nlh->nlmsg_flags); |
1386 | goto out; | 1421 | goto out; |
1422 | case DCB_CMD_GDCBX: | ||
1423 | ret = dcbnl_getdcbx(netdev, tb, pid, nlh->nlmsg_seq, | ||
1424 | nlh->nlmsg_flags); | ||
1425 | goto out; | ||
1426 | case DCB_CMD_SDCBX: | ||
1427 | ret = dcbnl_setdcbx(netdev, tb, pid, nlh->nlmsg_seq, | ||
1428 | nlh->nlmsg_flags); | ||
1429 | goto out; | ||
1387 | default: | 1430 | default: |
1388 | goto errout; | 1431 | goto errout; |
1389 | } | 1432 | } |