Commit 1709ff8d authored by Julian Wiedmann's avatar Julian Wiedmann Committed by David S. Miller

s390/qeth: convert bridgeport callbacks

By letting the callbacks deal with error translation, we no longer need
to pass the raw error codes back to the originator. This allows us to
slim down the callback's private data, and nicely simplifies the code.
Signed-off-by: default avatarJulian Wiedmann <jwi@linux.ibm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4b7ae122
...@@ -1407,8 +1407,6 @@ static void qeth_bridge_host_event(struct qeth_card *card, ...@@ -1407,8 +1407,6 @@ static void qeth_bridge_host_event(struct qeth_card *card,
/* SETBRIDGEPORT support; sending commands */ /* SETBRIDGEPORT support; sending commands */
struct _qeth_sbp_cbctl { struct _qeth_sbp_cbctl {
u16 ipa_rc;
u16 cmd_rc;
union { union {
u32 supported; u32 supported;
struct { struct {
...@@ -1418,23 +1416,21 @@ struct _qeth_sbp_cbctl { ...@@ -1418,23 +1416,21 @@ struct _qeth_sbp_cbctl {
} data; } data;
}; };
/**
* qeth_bridgeport_makerc() - derive "traditional" error from hardware codes.
* @card: qeth_card structure pointer, for debug messages.
* @cbctl: state structure with hardware return codes.
* @setcmd: IPA command code
*
* Returns negative errno-compatible error indication or 0 on success.
*/
static int qeth_bridgeport_makerc(struct qeth_card *card, static int qeth_bridgeport_makerc(struct qeth_card *card,
struct _qeth_sbp_cbctl *cbctl, enum qeth_ipa_sbp_cmd setcmd) struct qeth_ipa_cmd *cmd)
{ {
struct qeth_ipacmd_setbridgeport *sbp = &cmd->data.sbp;
enum qeth_ipa_sbp_cmd setcmd = sbp->hdr.command_code;
u16 ipa_rc = cmd->hdr.return_code;
u16 sbp_rc = sbp->hdr.return_code;
int rc; int rc;
int is_iqd = (card->info.type == QETH_CARD_TYPE_IQD);
if ((is_iqd && (cbctl->ipa_rc == IPA_RC_SUCCESS)) || if (ipa_rc == IPA_RC_SUCCESS && sbp_rc == IPA_RC_SUCCESS)
(!is_iqd && (cbctl->ipa_rc == cbctl->cmd_rc))) return 0;
switch (cbctl->cmd_rc) {
if ((IS_IQD(card) && ipa_rc == IPA_RC_SUCCESS) ||
(!IS_IQD(card) && ipa_rc == sbp_rc)) {
switch (sbp_rc) {
case IPA_RC_SUCCESS: case IPA_RC_SUCCESS:
rc = 0; rc = 0;
break; break;
...@@ -1498,8 +1494,8 @@ static int qeth_bridgeport_makerc(struct qeth_card *card, ...@@ -1498,8 +1494,8 @@ static int qeth_bridgeport_makerc(struct qeth_card *card,
default: default:
rc = -EIO; rc = -EIO;
} }
else } else {
switch (cbctl->ipa_rc) { switch (ipa_rc) {
case IPA_RC_NOTSUPP: case IPA_RC_NOTSUPP:
rc = -EOPNOTSUPP; rc = -EOPNOTSUPP;
break; break;
...@@ -1509,10 +1505,11 @@ static int qeth_bridgeport_makerc(struct qeth_card *card, ...@@ -1509,10 +1505,11 @@ static int qeth_bridgeport_makerc(struct qeth_card *card,
default: default:
rc = -EIO; rc = -EIO;
} }
}
if (rc) { if (rc) {
QETH_CARD_TEXT_(card, 2, "SBPi%04x", cbctl->ipa_rc); QETH_CARD_TEXT_(card, 2, "SBPi%04x", ipa_rc);
QETH_CARD_TEXT_(card, 2, "SBPc%04x", cbctl->cmd_rc); QETH_CARD_TEXT_(card, 2, "SBPc%04x", sbp_rc);
} }
return rc; return rc;
} }
...@@ -1544,15 +1541,15 @@ static int qeth_bridgeport_query_support_cb(struct qeth_card *card, ...@@ -1544,15 +1541,15 @@ static int qeth_bridgeport_query_support_cb(struct qeth_card *card,
{ {
struct qeth_ipa_cmd *cmd = (struct qeth_ipa_cmd *) data; struct qeth_ipa_cmd *cmd = (struct qeth_ipa_cmd *) data;
struct _qeth_sbp_cbctl *cbctl = (struct _qeth_sbp_cbctl *)reply->param; struct _qeth_sbp_cbctl *cbctl = (struct _qeth_sbp_cbctl *)reply->param;
int rc;
QETH_CARD_TEXT(card, 2, "brqsupcb"); QETH_CARD_TEXT(card, 2, "brqsupcb");
cbctl->ipa_rc = cmd->hdr.return_code; rc = qeth_bridgeport_makerc(card, cmd);
cbctl->cmd_rc = cmd->data.sbp.hdr.return_code; if (rc)
if ((cbctl->ipa_rc == 0) && (cbctl->cmd_rc == 0)) { return rc;
cbctl->data.supported = cbctl->data.supported =
cmd->data.sbp.data.query_cmds_supp.supported_cmds; cmd->data.sbp.data.query_cmds_supp.supported_cmds;
} else {
cbctl->data.supported = 0;
}
return 0; return 0;
} }
...@@ -1573,12 +1570,11 @@ static void qeth_bridgeport_query_support(struct qeth_card *card) ...@@ -1573,12 +1570,11 @@ static void qeth_bridgeport_query_support(struct qeth_card *card)
sizeof(struct qeth_sbp_query_cmds_supp)); sizeof(struct qeth_sbp_query_cmds_supp));
if (!iob) if (!iob)
return; return;
if (qeth_send_ipa_cmd(card, iob, qeth_bridgeport_query_support_cb, if (qeth_send_ipa_cmd(card, iob, qeth_bridgeport_query_support_cb,
(void *)&cbctl) || &cbctl)) {
qeth_bridgeport_makerc(card, &cbctl,
IPA_SBP_QUERY_COMMANDS_SUPPORTED)) {
/* non-zero makerc signifies failure, and produce messages */
card->options.sbp.role = QETH_SBP_ROLE_NONE; card->options.sbp.role = QETH_SBP_ROLE_NONE;
card->options.sbp.supported_funcs = 0;
return; return;
} }
card->options.sbp.supported_funcs = cbctl.data.supported; card->options.sbp.supported_funcs = cbctl.data.supported;
...@@ -1590,16 +1586,16 @@ static int qeth_bridgeport_query_ports_cb(struct qeth_card *card, ...@@ -1590,16 +1586,16 @@ static int qeth_bridgeport_query_ports_cb(struct qeth_card *card,
struct qeth_ipa_cmd *cmd = (struct qeth_ipa_cmd *) data; struct qeth_ipa_cmd *cmd = (struct qeth_ipa_cmd *) data;
struct qeth_sbp_query_ports *qports = &cmd->data.sbp.data.query_ports; struct qeth_sbp_query_ports *qports = &cmd->data.sbp.data.query_ports;
struct _qeth_sbp_cbctl *cbctl = (struct _qeth_sbp_cbctl *)reply->param; struct _qeth_sbp_cbctl *cbctl = (struct _qeth_sbp_cbctl *)reply->param;
int rc;
QETH_CARD_TEXT(card, 2, "brqprtcb"); QETH_CARD_TEXT(card, 2, "brqprtcb");
cbctl->ipa_rc = cmd->hdr.return_code; rc = qeth_bridgeport_makerc(card, cmd);
cbctl->cmd_rc = cmd->data.sbp.hdr.return_code; if (rc)
if ((cbctl->ipa_rc != 0) || (cbctl->cmd_rc != 0)) return rc;
return 0;
if (qports->entry_length != sizeof(struct qeth_sbp_port_entry)) { if (qports->entry_length != sizeof(struct qeth_sbp_port_entry)) {
cbctl->cmd_rc = 0xffff;
QETH_CARD_TEXT_(card, 2, "SBPs%04x", qports->entry_length); QETH_CARD_TEXT_(card, 2, "SBPs%04x", qports->entry_length);
return 0; return -EINVAL;
} }
/* first entry contains the state of the local port */ /* first entry contains the state of the local port */
if (qports->num_entries > 0) { if (qports->num_entries > 0) {
...@@ -1624,7 +1620,6 @@ static int qeth_bridgeport_query_ports_cb(struct qeth_card *card, ...@@ -1624,7 +1620,6 @@ static int qeth_bridgeport_query_ports_cb(struct qeth_card *card,
int qeth_bridgeport_query_ports(struct qeth_card *card, int qeth_bridgeport_query_ports(struct qeth_card *card,
enum qeth_sbp_roles *role, enum qeth_sbp_states *state) enum qeth_sbp_roles *role, enum qeth_sbp_states *state)
{ {
int rc = 0;
struct qeth_cmd_buffer *iob; struct qeth_cmd_buffer *iob;
struct _qeth_sbp_cbctl cbctl = { struct _qeth_sbp_cbctl cbctl = {
.data = { .data = {
...@@ -1641,22 +1636,18 @@ int qeth_bridgeport_query_ports(struct qeth_card *card, ...@@ -1641,22 +1636,18 @@ int qeth_bridgeport_query_ports(struct qeth_card *card,
iob = qeth_sbp_build_cmd(card, IPA_SBP_QUERY_BRIDGE_PORTS, 0); iob = qeth_sbp_build_cmd(card, IPA_SBP_QUERY_BRIDGE_PORTS, 0);
if (!iob) if (!iob)
return -ENOMEM; return -ENOMEM;
rc = qeth_send_ipa_cmd(card, iob, qeth_bridgeport_query_ports_cb,
(void *)&cbctl); return qeth_send_ipa_cmd(card, iob, qeth_bridgeport_query_ports_cb,
if (rc < 0) &cbctl);
return rc;
return qeth_bridgeport_makerc(card, &cbctl, IPA_SBP_QUERY_BRIDGE_PORTS);
} }
static int qeth_bridgeport_set_cb(struct qeth_card *card, static int qeth_bridgeport_set_cb(struct qeth_card *card,
struct qeth_reply *reply, unsigned long data) struct qeth_reply *reply, unsigned long data)
{ {
struct qeth_ipa_cmd *cmd = (struct qeth_ipa_cmd *)data; struct qeth_ipa_cmd *cmd = (struct qeth_ipa_cmd *)data;
struct _qeth_sbp_cbctl *cbctl = (struct _qeth_sbp_cbctl *)reply->param;
QETH_CARD_TEXT(card, 2, "brsetrcb"); QETH_CARD_TEXT(card, 2, "brsetrcb");
cbctl->ipa_rc = cmd->hdr.return_code; return qeth_bridgeport_makerc(card, cmd);
cbctl->cmd_rc = cmd->data.sbp.hdr.return_code;
return 0;
} }
/** /**
...@@ -1668,10 +1659,8 @@ static int qeth_bridgeport_set_cb(struct qeth_card *card, ...@@ -1668,10 +1659,8 @@ static int qeth_bridgeport_set_cb(struct qeth_card *card,
*/ */
int qeth_bridgeport_setrole(struct qeth_card *card, enum qeth_sbp_roles role) int qeth_bridgeport_setrole(struct qeth_card *card, enum qeth_sbp_roles role)
{ {
int rc = 0;
int cmdlength; int cmdlength;
struct qeth_cmd_buffer *iob; struct qeth_cmd_buffer *iob;
struct _qeth_sbp_cbctl cbctl;
enum qeth_ipa_sbp_cmd setcmd; enum qeth_ipa_sbp_cmd setcmd;
QETH_CARD_TEXT(card, 2, "brsetrol"); QETH_CARD_TEXT(card, 2, "brsetrol");
...@@ -1696,11 +1685,8 @@ int qeth_bridgeport_setrole(struct qeth_card *card, enum qeth_sbp_roles role) ...@@ -1696,11 +1685,8 @@ int qeth_bridgeport_setrole(struct qeth_card *card, enum qeth_sbp_roles role)
iob = qeth_sbp_build_cmd(card, setcmd, cmdlength); iob = qeth_sbp_build_cmd(card, setcmd, cmdlength);
if (!iob) if (!iob)
return -ENOMEM; return -ENOMEM;
rc = qeth_send_ipa_cmd(card, iob, qeth_bridgeport_set_cb,
(void *)&cbctl); return qeth_send_ipa_cmd(card, iob, qeth_bridgeport_set_cb, NULL);
if (rc < 0)
return rc;
return qeth_bridgeport_makerc(card, &cbctl, setcmd);
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment