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 (!qeth_card_hw_is_reachable(card)) 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 ssize_t qeth_bridge_port_role_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct qeth_card *card = dev_get_drvdata(dev); int rc = 0; enum qeth_sbp_roles role; if (!card) return -EINVAL; if (sysfs_streq(buf, "primary")) role = QETH_SBP_ROLE_PRIMARY; else if (sysfs_streq(buf, "secondary")) role = QETH_SBP_ROLE_SECONDARY; else if (sysfs_streq(buf, "none")) role = QETH_SBP_ROLE_NONE; else return -EINVAL; mutex_lock(&card->conf_mutex); if (card->options.sbp.reflect_promisc) /* Forbid direct manipulation */ rc = -EPERM; else if (qeth_card_hw_is_reachable(card)) { rc = qeth_bridgeport_setrole(card, role); if (!rc) card->options.sbp.role = role; } else card->options.sbp.role = role; mutex_unlock(&card->conf_mutex); return rc ? rc : count; }
static ssize_t qeth_bridgeport_hostnotification_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct qeth_card *card = dev_get_drvdata(dev); int rc = 0; int enable; if (!card) return -EINVAL; if (sysfs_streq(buf, "0")) enable = 0; else if (sysfs_streq(buf, "1")) enable = 1; else return -EINVAL; mutex_lock(&card->conf_mutex); if (qeth_card_hw_is_reachable(card)) { rc = qeth_bridgeport_an_set(card, enable); if (!rc) card->options.sbp.hostnotification = enable; } else card->options.sbp.hostnotification = enable; mutex_unlock(&card->conf_mutex); return rc ? rc : count; }
static ssize_t qeth_bridge_port_role_state_show(struct device *dev, struct device_attribute *attr, char *buf, int show_state) { struct qeth_card *card = dev_get_drvdata(dev); enum qeth_sbp_states state = QETH_SBP_STATE_INACTIVE; int rc = 0; char *word; if (!card) return -EINVAL; mutex_lock(&card->conf_mutex); if (qeth_card_hw_is_reachable(card) && card->options.sbp.supported_funcs) rc = qeth_bridgeport_query_ports(card, &card->options.sbp.role, &state); if (!rc) { if (show_state) switch (state) { case QETH_SBP_STATE_INACTIVE: word = "inactive"; break; case QETH_SBP_STATE_STANDBY: word = "standby"; break; case QETH_SBP_STATE_ACTIVE: word = "active"; break; default: rc = -EIO; } else switch (card->options.sbp.role) { case QETH_SBP_ROLE_NONE: word = "none"; break; case QETH_SBP_ROLE_PRIMARY: word = "primary"; break; case QETH_SBP_ROLE_SECONDARY: word = "secondary"; break; default: rc = -EIO; } if (rc) QETH_CARD_TEXT_(card, 2, "SBP%02x:%02x", card->options.sbp.role, state); else rc = sprintf(buf, "%s\n", word); } mutex_unlock(&card->conf_mutex); return rc; }
static ssize_t qeth_dev_isolation_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct qeth_card *card = dev_get_drvdata(dev); enum qeth_ipa_isolation_modes isolation; int rc = 0; if (!card) return -EINVAL; mutex_lock(&card->conf_mutex); /* check for unknown, too, in case we do not yet know who we are */ if (card->info.type != QETH_CARD_TYPE_OSD && card->info.type != QETH_CARD_TYPE_OSX && card->info.type != QETH_CARD_TYPE_UNKNOWN) { rc = -EOPNOTSUPP; dev_err(&card->gdev->dev, "Adapter does not " "support QDIO data connection isolation\n"); goto out; } /* parse input into isolation mode */ if (sysfs_streq(buf, ATTR_QETH_ISOLATION_NONE)) { isolation = ISOLATION_MODE_NONE; } else if (sysfs_streq(buf, ATTR_QETH_ISOLATION_FWD)) { isolation = ISOLATION_MODE_FWD; } else if (sysfs_streq(buf, ATTR_QETH_ISOLATION_DROP)) { isolation = ISOLATION_MODE_DROP; } else { rc = -EINVAL; goto out; } rc = count; /* defer IP assist if device is offline (until discipline->set_online)*/ card->options.prev_isolation = card->options.isolation; card->options.isolation = isolation; if (qeth_card_hw_is_reachable(card)) { int ipa_rc = qeth_set_access_ctrl_online(card, 1); if (ipa_rc != 0) rc = ipa_rc; } out: mutex_unlock(&card->conf_mutex); return rc; }
static ssize_t qeth_dev_recover_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct qeth_card *card = dev_get_drvdata(dev); char *tmp; int i; if (!card) return -EINVAL; if (!qeth_card_hw_is_reachable(card)) return -EPERM; i = simple_strtoul(buf, &tmp, 16); if (i == 1) qeth_schedule_recovery(card); return count; }
static ssize_t qeth_hw_trap_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct qeth_card *card = dev_get_drvdata(dev); int rc = 0; int state = 0; if (!card) return -EINVAL; mutex_lock(&card->conf_mutex); if (qeth_card_hw_is_reachable(card)) state = 1; if (sysfs_streq(buf, "arm") && !card->info.hwtrap) { if (state) { if (qeth_is_diagass_supported(card, QETH_DIAGS_CMD_TRAP)) { rc = qeth_hw_trap(card, QETH_DIAGS_TRAP_ARM); if (!rc) card->info.hwtrap = 1; } else rc = -EINVAL; } else card->info.hwtrap = 1; } else if (sysfs_streq(buf, "disarm") && card->info.hwtrap) { if (state) { rc = qeth_hw_trap(card, QETH_DIAGS_TRAP_DISARM); if (!rc) card->info.hwtrap = 0; } else card->info.hwtrap = 0; } else if (sysfs_streq(buf, "trap") && state && card->info.hwtrap) rc = qeth_hw_trap(card, QETH_DIAGS_TRAP_CAPTURE); else rc = -EINVAL; mutex_unlock(&card->conf_mutex); return rc ? rc : count; }