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 <raspl@linux.vnet.ibm.com>
Signed-off-by: Frank Blaschka <blaschka@linux.vnet.ibm.com>
Reviewed-by: Ursula Braun <ursula.braun@de.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Stefan Raspl
2014-07-21 12:54:43 +02:00
committed by David S. Miller
parent 240524089d
commit 45cbb2e499
4 changed files with 100 additions and 1 deletions

View File

@@ -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 = {