aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/devlink.c
diff options
context:
space:
mode:
authorJiri Pirko <jiri@mellanox.com>2018-05-18 03:29:00 -0400
committerDavid S. Miller <davem@davemloft.net>2018-05-19 16:30:39 -0400
commitb9ffcbaf56d3040efee64d3818688083c29b2a44 (patch)
treeb9ecd9e63e51be84e5050ba94b754de9ea9050a8 /net/core/devlink.c
parenteb38401c779d350e9e31396471ea072fa29aec9b (diff)
devlink: introduce devlink_port_attrs_set
Change existing setter for split port information into more generic attrs setter. Alongside with that, allow to set port number and subport number for split ports. Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/devlink.c')
-rw-r--r--net/core/devlink.c46
1 files changed, 36 insertions, 10 deletions
diff --git a/net/core/devlink.c b/net/core/devlink.c
index ad1317376798..8fde7d2df9b0 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -453,6 +453,25 @@ static void devlink_notify(struct devlink *devlink, enum devlink_command cmd)
453 msg, 0, DEVLINK_MCGRP_CONFIG, GFP_KERNEL); 453 msg, 0, DEVLINK_MCGRP_CONFIG, GFP_KERNEL);
454} 454}
455 455
456static int devlink_nl_port_attrs_put(struct sk_buff *msg,
457 struct devlink_port *devlink_port)
458{
459 struct devlink_port_attrs *attrs = &devlink_port->attrs;
460
461 if (!attrs->set)
462 return 0;
463 if (nla_put_u32(msg, DEVLINK_ATTR_PORT_NUMBER, attrs->port_number))
464 return -EMSGSIZE;
465 if (!attrs->split)
466 return 0;
467 if (nla_put_u32(msg, DEVLINK_ATTR_PORT_SPLIT_GROUP, attrs->port_number))
468 return -EMSGSIZE;
469 if (nla_put_u32(msg, DEVLINK_ATTR_PORT_SPLIT_SUBPORT_NUMBER,
470 attrs->split_subport_number))
471 return -EMSGSIZE;
472 return 0;
473}
474
456static int devlink_nl_port_fill(struct sk_buff *msg, struct devlink *devlink, 475static int devlink_nl_port_fill(struct sk_buff *msg, struct devlink *devlink,
457 struct devlink_port *devlink_port, 476 struct devlink_port *devlink_port,
458 enum devlink_command cmd, u32 portid, 477 enum devlink_command cmd, u32 portid,
@@ -492,9 +511,7 @@ static int devlink_nl_port_fill(struct sk_buff *msg, struct devlink *devlink,
492 ibdev->name)) 511 ibdev->name))
493 goto nla_put_failure; 512 goto nla_put_failure;
494 } 513 }
495 if (devlink_port->split && 514 if (devlink_nl_port_attrs_put(msg, devlink_port))
496 nla_put_u32(msg, DEVLINK_ATTR_PORT_SPLIT_GROUP,
497 devlink_port->split_group))
498 goto nla_put_failure; 515 goto nla_put_failure;
499 516
500 genlmsg_end(msg, hdr); 517 genlmsg_end(msg, hdr);
@@ -2971,19 +2988,28 @@ void devlink_port_type_clear(struct devlink_port *devlink_port)
2971EXPORT_SYMBOL_GPL(devlink_port_type_clear); 2988EXPORT_SYMBOL_GPL(devlink_port_type_clear);
2972 2989
2973/** 2990/**
2974 * devlink_port_split_set - Set port is split 2991 * devlink_port_attrs_set - Set port attributes
2975 * 2992 *
2976 * @devlink_port: devlink port 2993 * @devlink_port: devlink port
2977 * @split_group: split group - identifies group split port is part of 2994 * @port_number: number of the port that is facing user, for example
2995 * the front panel port number
2996 * @split: indicates if this is split port
2997 * @split_subport_number: if the port is split, this is the number
2998 * of subport.
2978 */ 2999 */
2979void devlink_port_split_set(struct devlink_port *devlink_port, 3000void devlink_port_attrs_set(struct devlink_port *devlink_port,
2980 u32 split_group) 3001 u32 port_number, bool split,
3002 u32 split_subport_number)
2981{ 3003{
2982 devlink_port->split = true; 3004 struct devlink_port_attrs *attrs = &devlink_port->attrs;
2983 devlink_port->split_group = split_group; 3005
3006 attrs->set = true;
3007 attrs->port_number = port_number;
3008 attrs->split = split;
3009 attrs->split_subport_number = split_subport_number;
2984 devlink_port_notify(devlink_port, DEVLINK_CMD_PORT_NEW); 3010 devlink_port_notify(devlink_port, DEVLINK_CMD_PORT_NEW);
2985} 3011}
2986EXPORT_SYMBOL_GPL(devlink_port_split_set); 3012EXPORT_SYMBOL_GPL(devlink_port_attrs_set);
2987 3013
2988int devlink_sb_register(struct devlink *devlink, unsigned int sb_index, 3014int devlink_sb_register(struct devlink *devlink, unsigned int sb_index,
2989 u32 size, u16 ingress_pools_count, 3015 u32 size, u16 ingress_pools_count,