Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Stefan Raspl and committed by
David S. Miller
45cbb2e4 24052408

+100 -1
+7
drivers/s390/net/qeth_core.h
··· 766 766 __u32 port_speed; 767 767 }; 768 768 769 + struct qeth_switch_info { 770 + __u32 capabilities; 771 + __u32 settings; 772 + }; 773 + 769 774 #define QETH_NAPI_WEIGHT NAPI_POLL_WEIGHT 770 775 771 776 struct qeth_card { ··· 951 946 int qeth_mdio_read(struct net_device *, int, int); 952 947 int qeth_snmp_command(struct qeth_card *, char __user *); 953 948 int qeth_query_oat_command(struct qeth_card *, char __user *); 949 + int qeth_query_switch_attributes(struct qeth_card *card, 950 + struct qeth_switch_info *sw_info); 954 951 int qeth_query_card_info(struct qeth_card *card, 955 952 struct carrier_info *carrier_info); 956 953 int qeth_send_control_data(struct qeth_card *, int, struct qeth_cmd_buffer *,
+39
drivers/s390/net/qeth_core_main.c
··· 3037 3037 } 3038 3038 EXPORT_SYMBOL_GPL(qeth_query_ipassists); 3039 3039 3040 + static int qeth_query_switch_attributes_cb(struct qeth_card *card, 3041 + struct qeth_reply *reply, unsigned long data) 3042 + { 3043 + struct qeth_ipa_cmd *cmd; 3044 + struct qeth_switch_info *sw_info; 3045 + struct qeth_query_switch_attributes *attrs; 3046 + 3047 + QETH_CARD_TEXT(card, 2, "qswiatcb"); 3048 + cmd = (struct qeth_ipa_cmd *) data; 3049 + sw_info = (struct qeth_switch_info *)reply->param; 3050 + if (cmd->data.setadapterparms.hdr.return_code == 0) { 3051 + attrs = &cmd->data.setadapterparms.data.query_switch_attributes; 3052 + sw_info->capabilities = attrs->capabilities; 3053 + sw_info->settings = attrs->settings; 3054 + QETH_CARD_TEXT_(card, 2, "%04x%04x", sw_info->capabilities, 3055 + sw_info->settings); 3056 + } 3057 + qeth_default_setadapterparms_cb(card, reply, (unsigned long) cmd); 3058 + 3059 + return 0; 3060 + } 3061 + 3062 + int qeth_query_switch_attributes(struct qeth_card *card, 3063 + struct qeth_switch_info *sw_info) 3064 + { 3065 + struct qeth_cmd_buffer *iob; 3066 + 3067 + QETH_CARD_TEXT(card, 2, "qswiattr"); 3068 + if (!qeth_adp_supported(card, IPA_SETADP_QUERY_SWITCH_ATTRIBUTES)) 3069 + return -EOPNOTSUPP; 3070 + if (!netif_carrier_ok(card->dev)) 3071 + return -ENOMEDIUM; 3072 + iob = qeth_get_adapter_cmd(card, IPA_SETADP_QUERY_SWITCH_ATTRIBUTES, 3073 + sizeof(struct qeth_ipacmd_setadpparms_hdr)); 3074 + return qeth_send_ipa_cmd(card, iob, 3075 + qeth_query_switch_attributes_cb, sw_info); 3076 + } 3077 + EXPORT_SYMBOL_GPL(qeth_query_switch_attributes); 3078 + 3040 3079 static int qeth_query_setdiagass_cb(struct qeth_card *card, 3041 3080 struct qeth_reply *reply, unsigned long data) 3042 3081 {
+17
drivers/s390/net/qeth_core_mpc.h
··· 242 242 IPA_SETADP_SET_DIAG_ASSIST = 0x00002000L, 243 243 IPA_SETADP_SET_ACCESS_CONTROL = 0x00010000L, 244 244 IPA_SETADP_QUERY_OAT = 0x00080000L, 245 + IPA_SETADP_QUERY_SWITCH_ATTRIBUTES = 0x00100000L, 245 246 }; 246 247 enum qeth_ipa_mac_ops { 247 248 CHANGE_ADDR_READ_MAC = 0, ··· 432 431 __u32 reserved2; 433 432 }; 434 433 434 + #define QETH_SWITCH_FORW_802_1 0x00000001 435 + #define QETH_SWITCH_FORW_REFL_RELAY 0x00000002 436 + #define QETH_SWITCH_CAP_RTE 0x00000004 437 + #define QETH_SWITCH_CAP_ECP 0x00000008 438 + #define QETH_SWITCH_CAP_VDP 0x00000010 439 + 440 + struct qeth_query_switch_attributes { 441 + __u8 version; 442 + __u8 reserved1; 443 + __u16 reserved2; 444 + __u32 capabilities; 445 + __u32 settings; 446 + __u8 reserved3[8]; 447 + }; 448 + 435 449 struct qeth_ipacmd_setadpparms_hdr { 436 450 __u32 supp_hw_cmds; 437 451 __u32 reserved1; ··· 468 452 struct qeth_set_access_ctrl set_access_ctrl; 469 453 struct qeth_query_oat query_oat; 470 454 struct qeth_query_card_info card_info; 455 + struct qeth_query_switch_attributes query_switch_attributes; 471 456 __u32 mode; 472 457 } data; 473 458 } __attribute__ ((packed));
+37 -1
drivers/s390/net/qeth_core_sys.c
··· 543 543 } 544 544 545 545 static DEVICE_ATTR(isolation, 0644, qeth_dev_isolation_show, 546 - qeth_dev_isolation_store); 546 + qeth_dev_isolation_store); 547 + 548 + static ssize_t qeth_dev_switch_attrs_show(struct device *dev, 549 + struct device_attribute *attr, char *buf) 550 + { 551 + struct qeth_card *card = dev_get_drvdata(dev); 552 + struct qeth_switch_info sw_info; 553 + int rc = 0; 554 + 555 + if (!card) 556 + return -EINVAL; 557 + 558 + if (card->state != CARD_STATE_SOFTSETUP && card->state != CARD_STATE_UP) 559 + return sprintf(buf, "n/a\n"); 560 + 561 + rc = qeth_query_switch_attributes(card, &sw_info); 562 + if (rc) 563 + return rc; 564 + 565 + if (!sw_info.capabilities) 566 + rc = sprintf(buf, "unknown"); 567 + 568 + if (sw_info.capabilities & QETH_SWITCH_FORW_802_1) 569 + rc = sprintf(buf, (sw_info.settings & QETH_SWITCH_FORW_802_1 ? 570 + "[802.1]" : "802.1")); 571 + if (sw_info.capabilities & QETH_SWITCH_FORW_REFL_RELAY) 572 + rc += sprintf(buf + rc, 573 + (sw_info.settings & QETH_SWITCH_FORW_REFL_RELAY ? 574 + " [rr]" : " rr")); 575 + rc += sprintf(buf + rc, "\n"); 576 + 577 + return rc; 578 + } 579 + 580 + static DEVICE_ATTR(switch_attrs, 0444, 581 + qeth_dev_switch_attrs_show, NULL); 547 582 548 583 static ssize_t qeth_hw_trap_show(struct device *dev, 549 584 struct device_attribute *attr, char *buf) ··· 763 728 &dev_attr_layer2.attr, 764 729 &dev_attr_isolation.attr, 765 730 &dev_attr_hw_trap.attr, 731 + &dev_attr_switch_attrs.attr, 766 732 NULL, 767 733 }; 768 734 static struct attribute_group qeth_device_attr_group = {