From 45cbb2e499cf4686e809206b29377a7e15037bcc Mon Sep 17 00:00:00 2001 From: Stefan Raspl Date: Mon, 21 Jul 2014 12:54:43 +0200 Subject: qeth: Display adjacent switch attributes Add support to display the adjacent switch port's forwarding attributes. Currently supports info on forwarding modes '802.1' and 'rr' (reflective relay). Signed-off-by: Stefan Raspl Signed-off-by: Frank Blaschka Reviewed-by: Ursula Braun Signed-off-by: David S. Miller --- drivers/s390/net/qeth_core_sys.c | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'drivers/s390/net/qeth_core_sys.c') diff --git a/drivers/s390/net/qeth_core_sys.c b/drivers/s390/net/qeth_core_sys.c index 8a25a2be9890..15523f0e4c03 100644 --- a/drivers/s390/net/qeth_core_sys.c +++ b/drivers/s390/net/qeth_core_sys.c @@ -543,7 +543,42 @@ out: } static DEVICE_ATTR(isolation, 0644, qeth_dev_isolation_show, - qeth_dev_isolation_store); + qeth_dev_isolation_store); + +static ssize_t qeth_dev_switch_attrs_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct qeth_card *card = dev_get_drvdata(dev); + struct qeth_switch_info sw_info; + int rc = 0; + + if (!card) + return -EINVAL; + + if (card->state != CARD_STATE_SOFTSETUP && card->state != CARD_STATE_UP) + return sprintf(buf, "n/a\n"); + + rc = qeth_query_switch_attributes(card, &sw_info); + if (rc) + return rc; + + if (!sw_info.capabilities) + rc = sprintf(buf, "unknown"); + + if (sw_info.capabilities & QETH_SWITCH_FORW_802_1) + rc = sprintf(buf, (sw_info.settings & QETH_SWITCH_FORW_802_1 ? + "[802.1]" : "802.1")); + if (sw_info.capabilities & QETH_SWITCH_FORW_REFL_RELAY) + rc += sprintf(buf + rc, + (sw_info.settings & QETH_SWITCH_FORW_REFL_RELAY ? + " [rr]" : " rr")); + rc += sprintf(buf + rc, "\n"); + + return rc; +} + +static DEVICE_ATTR(switch_attrs, 0444, + qeth_dev_switch_attrs_show, NULL); static ssize_t qeth_hw_trap_show(struct device *dev, struct device_attribute *attr, char *buf) @@ -728,6 +763,7 @@ static struct attribute *qeth_device_attrs[] = { &dev_attr_layer2.attr, &dev_attr_isolation.attr, &dev_attr_hw_trap.attr, + &dev_attr_switch_attrs.attr, NULL, }; static struct attribute_group qeth_device_attr_group = { -- cgit v1.2.3