qeth: clean up error handling
In the functions that are registering and unregistering MAC addresses in the qeth-handled hardware, remove callback functions that are unnesessary, as only the return code is analyzed. Translate hardware response codes to semi-standard 'errno'-like codes for readability. Add kernel-doc description to the internal API function qeth_send_control_data(). Signed-off-by: Eugene Crosser <Eugene.Crosser@ru.ibm.com> Signed-off-by: Ursula Braun <ursula.braun@de.ibm.com> Reviewed-by: Thomas-Mich Richter <tmricht@linux.vnet.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
b0a1ba5992
commit
efbbc1d567
|
@ -2021,10 +2021,36 @@ void qeth_prepare_control_data(struct qeth_card *card, int len,
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(qeth_prepare_control_data);
|
EXPORT_SYMBOL_GPL(qeth_prepare_control_data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* qeth_send_control_data() - send control command to the card
|
||||||
|
* @card: qeth_card structure pointer
|
||||||
|
* @len: size of the command buffer
|
||||||
|
* @iob: qeth_cmd_buffer pointer
|
||||||
|
* @reply_cb: callback function pointer
|
||||||
|
* @cb_card: pointer to the qeth_card structure
|
||||||
|
* @cb_reply: pointer to the qeth_reply structure
|
||||||
|
* @cb_cmd: pointer to the original iob for non-IPA
|
||||||
|
* commands, or to the qeth_ipa_cmd structure
|
||||||
|
* for the IPA commands.
|
||||||
|
* @reply_param: private pointer passed to the callback
|
||||||
|
*
|
||||||
|
* Returns the value of the `return_code' field of the response
|
||||||
|
* block returned from the hardware, or other error indication.
|
||||||
|
* Value of zero indicates successful execution of the command.
|
||||||
|
*
|
||||||
|
* Callback function gets called one or more times, with cb_cmd
|
||||||
|
* pointing to the response returned by the hardware. Callback
|
||||||
|
* function must return non-zero if more reply blocks are expected,
|
||||||
|
* and zero if the last or only reply block is received. Callback
|
||||||
|
* function can get the value of the reply_param pointer from the
|
||||||
|
* field 'param' of the structure qeth_reply.
|
||||||
|
*/
|
||||||
|
|
||||||
int qeth_send_control_data(struct qeth_card *card, int len,
|
int qeth_send_control_data(struct qeth_card *card, int len,
|
||||||
struct qeth_cmd_buffer *iob,
|
struct qeth_cmd_buffer *iob,
|
||||||
int (*reply_cb)(struct qeth_card *, struct qeth_reply *,
|
int (*reply_cb)(struct qeth_card *cb_card,
|
||||||
unsigned long),
|
struct qeth_reply *cb_reply,
|
||||||
|
unsigned long cb_cmd),
|
||||||
void *reply_param)
|
void *reply_param)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
@ -2932,6 +2958,12 @@ void qeth_prepare_ipa_cmd(struct qeth_card *card, struct qeth_cmd_buffer *iob,
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(qeth_prepare_ipa_cmd);
|
EXPORT_SYMBOL_GPL(qeth_prepare_ipa_cmd);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* qeth_send_ipa_cmd() - send an IPA command
|
||||||
|
*
|
||||||
|
* See qeth_send_control_data() for explanation of the arguments.
|
||||||
|
*/
|
||||||
|
|
||||||
int qeth_send_ipa_cmd(struct qeth_card *card, struct qeth_cmd_buffer *iob,
|
int qeth_send_ipa_cmd(struct qeth_card *card, struct qeth_cmd_buffer *iob,
|
||||||
int (*reply_cb)(struct qeth_card *, struct qeth_reply*,
|
int (*reply_cb)(struct qeth_card *, struct qeth_reply*,
|
||||||
unsigned long),
|
unsigned long),
|
||||||
|
|
|
@ -27,10 +27,7 @@ static int qeth_l2_set_offline(struct ccwgroup_device *);
|
||||||
static int qeth_l2_stop(struct net_device *);
|
static int qeth_l2_stop(struct net_device *);
|
||||||
static int qeth_l2_send_delmac(struct qeth_card *, __u8 *);
|
static int qeth_l2_send_delmac(struct qeth_card *, __u8 *);
|
||||||
static int qeth_l2_send_setdelmac(struct qeth_card *, __u8 *,
|
static int qeth_l2_send_setdelmac(struct qeth_card *, __u8 *,
|
||||||
enum qeth_ipa_cmds,
|
enum qeth_ipa_cmds);
|
||||||
int (*reply_cb) (struct qeth_card *,
|
|
||||||
struct qeth_reply*,
|
|
||||||
unsigned long));
|
|
||||||
static void qeth_l2_set_multicast_list(struct net_device *);
|
static void qeth_l2_set_multicast_list(struct net_device *);
|
||||||
static int qeth_l2_recover(void *);
|
static int qeth_l2_recover(void *);
|
||||||
static void qeth_bridgeport_query_support(struct qeth_card *card);
|
static void qeth_bridgeport_query_support(struct qeth_card *card);
|
||||||
|
@ -130,56 +127,68 @@ static struct net_device *qeth_l2_netdev_by_devno(unsigned char *read_dev_no)
|
||||||
return ndev;
|
return ndev;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int qeth_l2_send_setgroupmac_cb(struct qeth_card *card,
|
static int qeth_setdel_makerc(struct qeth_card *card, int retcode)
|
||||||
struct qeth_reply *reply,
|
|
||||||
unsigned long data)
|
|
||||||
{
|
{
|
||||||
struct qeth_ipa_cmd *cmd;
|
int rc;
|
||||||
__u8 *mac;
|
|
||||||
|
|
||||||
QETH_CARD_TEXT(card, 2, "L2Sgmacb");
|
if (retcode)
|
||||||
cmd = (struct qeth_ipa_cmd *) data;
|
QETH_CARD_TEXT_(card, 2, "err%d", retcode);
|
||||||
mac = &cmd->data.setdelmac.mac[0];
|
switch (retcode) {
|
||||||
/* MAC already registered, needed in couple/uncouple case */
|
case IPA_RC_SUCCESS:
|
||||||
if (cmd->hdr.return_code == IPA_RC_L2_DUP_MAC) {
|
rc = 0;
|
||||||
QETH_DBF_MESSAGE(2, "Group MAC %pM already existing on %s \n",
|
break;
|
||||||
mac, QETH_CARD_IFNAME(card));
|
case IPA_RC_L2_UNSUPPORTED_CMD:
|
||||||
cmd->hdr.return_code = 0;
|
rc = -ENOSYS;
|
||||||
|
break;
|
||||||
|
case IPA_RC_L2_ADDR_TABLE_FULL:
|
||||||
|
rc = -ENOSPC;
|
||||||
|
break;
|
||||||
|
case IPA_RC_L2_DUP_MAC:
|
||||||
|
case IPA_RC_L2_DUP_LAYER3_MAC:
|
||||||
|
rc = -EEXIST;
|
||||||
|
break;
|
||||||
|
case IPA_RC_L2_MAC_NOT_AUTH_BY_HYP:
|
||||||
|
case IPA_RC_L2_MAC_NOT_AUTH_BY_ADP:
|
||||||
|
rc = -EPERM;
|
||||||
|
break;
|
||||||
|
case IPA_RC_L2_MAC_NOT_FOUND:
|
||||||
|
rc = -ENOENT;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
rc = -EIO;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (cmd->hdr.return_code)
|
return rc;
|
||||||
QETH_DBF_MESSAGE(2, "Could not set group MAC %pM on %s: %x\n",
|
|
||||||
mac, QETH_CARD_IFNAME(card), cmd->hdr.return_code);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int qeth_l2_send_setgroupmac(struct qeth_card *card, __u8 *mac)
|
static int qeth_l2_send_setgroupmac(struct qeth_card *card, __u8 *mac)
|
||||||
{
|
{
|
||||||
|
int rc;
|
||||||
|
|
||||||
QETH_CARD_TEXT(card, 2, "L2Sgmac");
|
QETH_CARD_TEXT(card, 2, "L2Sgmac");
|
||||||
return qeth_l2_send_setdelmac(card, mac, IPA_CMD_SETGMAC,
|
rc = qeth_setdel_makerc(card, qeth_l2_send_setdelmac(card, mac,
|
||||||
qeth_l2_send_setgroupmac_cb);
|
IPA_CMD_SETGMAC));
|
||||||
}
|
if (rc == -EEXIST)
|
||||||
|
QETH_DBF_MESSAGE(2, "Group MAC %pM already existing on %s\n",
|
||||||
static int qeth_l2_send_delgroupmac_cb(struct qeth_card *card,
|
mac, QETH_CARD_IFNAME(card));
|
||||||
struct qeth_reply *reply,
|
else if (rc)
|
||||||
unsigned long data)
|
QETH_DBF_MESSAGE(2, "Could not set group MAC %pM on %s: %d\n",
|
||||||
{
|
mac, QETH_CARD_IFNAME(card), rc);
|
||||||
struct qeth_ipa_cmd *cmd;
|
return rc;
|
||||||
__u8 *mac;
|
|
||||||
|
|
||||||
QETH_CARD_TEXT(card, 2, "L2Dgmacb");
|
|
||||||
cmd = (struct qeth_ipa_cmd *) data;
|
|
||||||
mac = &cmd->data.setdelmac.mac[0];
|
|
||||||
if (cmd->hdr.return_code)
|
|
||||||
QETH_DBF_MESSAGE(2, "Could not delete group MAC %pM on %s: %x\n",
|
|
||||||
mac, QETH_CARD_IFNAME(card), cmd->hdr.return_code);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int qeth_l2_send_delgroupmac(struct qeth_card *card, __u8 *mac)
|
static int qeth_l2_send_delgroupmac(struct qeth_card *card, __u8 *mac)
|
||||||
{
|
{
|
||||||
|
int rc;
|
||||||
|
|
||||||
QETH_CARD_TEXT(card, 2, "L2Dgmac");
|
QETH_CARD_TEXT(card, 2, "L2Dgmac");
|
||||||
return qeth_l2_send_setdelmac(card, mac, IPA_CMD_DELGMAC,
|
rc = qeth_setdel_makerc(card, qeth_l2_send_setdelmac(card, mac,
|
||||||
qeth_l2_send_delgroupmac_cb);
|
IPA_CMD_DELGMAC));
|
||||||
|
if (rc)
|
||||||
|
QETH_DBF_MESSAGE(2,
|
||||||
|
"Could not delete group MAC %pM on %s: %d\n",
|
||||||
|
mac, QETH_CARD_IFNAME(card), rc);
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void qeth_l2_add_mc(struct qeth_card *card, __u8 *mac, int vmac)
|
static void qeth_l2_add_mc(struct qeth_card *card, __u8 *mac, int vmac)
|
||||||
|
@ -197,10 +206,11 @@ static void qeth_l2_add_mc(struct qeth_card *card, __u8 *mac, int vmac)
|
||||||
mc->is_vmac = vmac;
|
mc->is_vmac = vmac;
|
||||||
|
|
||||||
if (vmac) {
|
if (vmac) {
|
||||||
rc = qeth_l2_send_setdelmac(card, mac, IPA_CMD_SETVMAC,
|
rc = qeth_setdel_makerc(card,
|
||||||
NULL);
|
qeth_l2_send_setdelmac(card, mac, IPA_CMD_SETVMAC));
|
||||||
} else {
|
} else {
|
||||||
rc = qeth_l2_send_setgroupmac(card, mac);
|
rc = qeth_setdel_makerc(card,
|
||||||
|
qeth_l2_send_setgroupmac(card, mac));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!rc)
|
if (!rc)
|
||||||
|
@ -218,7 +228,7 @@ static void qeth_l2_del_all_mc(struct qeth_card *card, int del)
|
||||||
if (del) {
|
if (del) {
|
||||||
if (mc->is_vmac)
|
if (mc->is_vmac)
|
||||||
qeth_l2_send_setdelmac(card, mc->mc_addr,
|
qeth_l2_send_setdelmac(card, mc->mc_addr,
|
||||||
IPA_CMD_DELVMAC, NULL);
|
IPA_CMD_DELVMAC);
|
||||||
else
|
else
|
||||||
qeth_l2_send_delgroupmac(card, mc->mc_addr);
|
qeth_l2_send_delgroupmac(card, mc->mc_addr);
|
||||||
}
|
}
|
||||||
|
@ -539,10 +549,7 @@ out:
|
||||||
}
|
}
|
||||||
|
|
||||||
static int qeth_l2_send_setdelmac(struct qeth_card *card, __u8 *mac,
|
static int qeth_l2_send_setdelmac(struct qeth_card *card, __u8 *mac,
|
||||||
enum qeth_ipa_cmds ipacmd,
|
enum qeth_ipa_cmds ipacmd)
|
||||||
int (*reply_cb) (struct qeth_card *,
|
|
||||||
struct qeth_reply*,
|
|
||||||
unsigned long))
|
|
||||||
{
|
{
|
||||||
struct qeth_ipa_cmd *cmd;
|
struct qeth_ipa_cmd *cmd;
|
||||||
struct qeth_cmd_buffer *iob;
|
struct qeth_cmd_buffer *iob;
|
||||||
|
@ -552,78 +559,50 @@ static int qeth_l2_send_setdelmac(struct qeth_card *card, __u8 *mac,
|
||||||
cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE);
|
cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE);
|
||||||
cmd->data.setdelmac.mac_length = OSA_ADDR_LEN;
|
cmd->data.setdelmac.mac_length = OSA_ADDR_LEN;
|
||||||
memcpy(&cmd->data.setdelmac.mac, mac, OSA_ADDR_LEN);
|
memcpy(&cmd->data.setdelmac.mac, mac, OSA_ADDR_LEN);
|
||||||
return qeth_send_ipa_cmd(card, iob, reply_cb, NULL);
|
return qeth_send_ipa_cmd(card, iob, NULL, NULL);
|
||||||
}
|
|
||||||
|
|
||||||
static int qeth_l2_send_setmac_cb(struct qeth_card *card,
|
|
||||||
struct qeth_reply *reply,
|
|
||||||
unsigned long data)
|
|
||||||
{
|
|
||||||
struct qeth_ipa_cmd *cmd;
|
|
||||||
|
|
||||||
QETH_CARD_TEXT(card, 2, "L2Smaccb");
|
|
||||||
cmd = (struct qeth_ipa_cmd *) data;
|
|
||||||
if (cmd->hdr.return_code) {
|
|
||||||
QETH_CARD_TEXT_(card, 2, "L2er%x", cmd->hdr.return_code);
|
|
||||||
card->info.mac_bits &= ~QETH_LAYER2_MAC_REGISTERED;
|
|
||||||
switch (cmd->hdr.return_code) {
|
|
||||||
case IPA_RC_L2_DUP_MAC:
|
|
||||||
case IPA_RC_L2_DUP_LAYER3_MAC:
|
|
||||||
dev_warn(&card->gdev->dev,
|
|
||||||
"MAC address %pM already exists\n",
|
|
||||||
cmd->data.setdelmac.mac);
|
|
||||||
break;
|
|
||||||
case IPA_RC_L2_MAC_NOT_AUTH_BY_HYP:
|
|
||||||
case IPA_RC_L2_MAC_NOT_AUTH_BY_ADP:
|
|
||||||
dev_warn(&card->gdev->dev,
|
|
||||||
"MAC address %pM is not authorized\n",
|
|
||||||
cmd->data.setdelmac.mac);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
card->info.mac_bits |= QETH_LAYER2_MAC_REGISTERED;
|
|
||||||
memcpy(card->dev->dev_addr, cmd->data.setdelmac.mac,
|
|
||||||
OSA_ADDR_LEN);
|
|
||||||
dev_info(&card->gdev->dev,
|
|
||||||
"MAC address %pM successfully registered on device %s\n",
|
|
||||||
card->dev->dev_addr, card->dev->name);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int qeth_l2_send_setmac(struct qeth_card *card, __u8 *mac)
|
static int qeth_l2_send_setmac(struct qeth_card *card, __u8 *mac)
|
||||||
{
|
{
|
||||||
|
int rc;
|
||||||
|
|
||||||
QETH_CARD_TEXT(card, 2, "L2Setmac");
|
QETH_CARD_TEXT(card, 2, "L2Setmac");
|
||||||
return qeth_l2_send_setdelmac(card, mac, IPA_CMD_SETVMAC,
|
rc = qeth_setdel_makerc(card, qeth_l2_send_setdelmac(card, mac,
|
||||||
qeth_l2_send_setmac_cb);
|
IPA_CMD_SETVMAC));
|
||||||
}
|
if (rc == 0) {
|
||||||
|
card->info.mac_bits |= QETH_LAYER2_MAC_REGISTERED;
|
||||||
static int qeth_l2_send_delmac_cb(struct qeth_card *card,
|
memcpy(card->dev->dev_addr, mac, OSA_ADDR_LEN);
|
||||||
struct qeth_reply *reply,
|
dev_info(&card->gdev->dev,
|
||||||
unsigned long data)
|
"MAC address %pM successfully registered on device %s\n",
|
||||||
{
|
card->dev->dev_addr, card->dev->name);
|
||||||
struct qeth_ipa_cmd *cmd;
|
} else {
|
||||||
|
card->info.mac_bits &= ~QETH_LAYER2_MAC_REGISTERED;
|
||||||
QETH_CARD_TEXT(card, 2, "L2Dmaccb");
|
switch (rc) {
|
||||||
cmd = (struct qeth_ipa_cmd *) data;
|
case -EEXIST:
|
||||||
if (cmd->hdr.return_code) {
|
dev_warn(&card->gdev->dev,
|
||||||
QETH_CARD_TEXT_(card, 2, "err%d", cmd->hdr.return_code);
|
"MAC address %pM already exists\n", mac);
|
||||||
return 0;
|
break;
|
||||||
|
case -EPERM:
|
||||||
|
dev_warn(&card->gdev->dev,
|
||||||
|
"MAC address %pM is not authorized\n", mac);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
card->info.mac_bits &= ~QETH_LAYER2_MAC_REGISTERED;
|
return rc;
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int qeth_l2_send_delmac(struct qeth_card *card, __u8 *mac)
|
static int qeth_l2_send_delmac(struct qeth_card *card, __u8 *mac)
|
||||||
{
|
{
|
||||||
|
int rc;
|
||||||
|
|
||||||
QETH_CARD_TEXT(card, 2, "L2Delmac");
|
QETH_CARD_TEXT(card, 2, "L2Delmac");
|
||||||
if (!(card->info.mac_bits & QETH_LAYER2_MAC_REGISTERED))
|
if (!(card->info.mac_bits & QETH_LAYER2_MAC_REGISTERED))
|
||||||
return 0;
|
return 0;
|
||||||
return qeth_l2_send_setdelmac(card, mac, IPA_CMD_DELVMAC,
|
rc = qeth_setdel_makerc(card, qeth_l2_send_setdelmac(card, mac,
|
||||||
qeth_l2_send_delmac_cb);
|
IPA_CMD_DELVMAC));
|
||||||
|
if (rc == 0)
|
||||||
|
card->info.mac_bits &= ~QETH_LAYER2_MAC_REGISTERED;
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int qeth_l2_request_initial_mac(struct qeth_card *card)
|
static int qeth_l2_request_initial_mac(struct qeth_card *card)
|
||||||
|
@ -687,7 +666,7 @@ static int qeth_l2_set_mac_address(struct net_device *dev, void *p)
|
||||||
return -ERESTARTSYS;
|
return -ERESTARTSYS;
|
||||||
}
|
}
|
||||||
rc = qeth_l2_send_delmac(card, &card->dev->dev_addr[0]);
|
rc = qeth_l2_send_delmac(card, &card->dev->dev_addr[0]);
|
||||||
if (!rc || (rc == IPA_RC_L2_MAC_NOT_FOUND))
|
if (!rc || (rc == -ENOENT))
|
||||||
rc = qeth_l2_send_setmac(card, addr->sa_data);
|
rc = qeth_l2_send_setmac(card, addr->sa_data);
|
||||||
return rc ? -EINVAL : 0;
|
return rc ? -EINVAL : 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue