Commit 36e8c538 authored by Igor Mitsyanko's avatar Igor Mitsyanko Committed by Kalle Valo
Browse files

qtnfmac: decode error codes from firmware replies



Introduce a function that will map an error code reported in reply
to a firmware command, into one of standard errno codes.
Use additional error codes to improve error reporting
for MAC address changes.

Signed-off-by: default avatarIgor Mitsyanko <igor.mitsyanko.os@quantenna.com>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
parent d62b622c
Loading
Loading
Loading
Loading
+24 −2
Original line number Diff line number Diff line
@@ -55,6 +55,28 @@ static int qtnf_cmd_check_reply_header(const struct qlink_resp *resp,
	return 0;
}

static int qtnf_cmd_resp_result_decode(enum qlink_cmd_result qcode)
{
	switch (qcode) {
	case QLINK_CMD_RESULT_OK:
		return 0;
	case QLINK_CMD_RESULT_INVALID:
		return -EINVAL;
	case QLINK_CMD_RESULT_ENOTSUPP:
		return -ENOTSUPP;
	case QLINK_CMD_RESULT_ENOTFOUND:
		return -ENOENT;
	case QLINK_CMD_RESULT_EALREADY:
		return -EALREADY;
	case QLINK_CMD_RESULT_EADDRINUSE:
		return -EADDRINUSE;
	case QLINK_CMD_RESULT_EADDRNOTAVAIL:
		return -EADDRNOTAVAIL;
	default:
		return -EFAULT;
	}
}

static int qtnf_cmd_send_with_reply(struct qtnf_bus *bus,
				    struct sk_buff *cmd_skb,
				    struct sk_buff **response_skb,
@@ -810,10 +832,10 @@ static int qtnf_cmd_send_add_change_intf(struct qtnf_vif *vif,
	if (unlikely(ret))
		goto out;

	if (unlikely(res_code != QLINK_CMD_RESULT_OK)) {
	ret = qtnf_cmd_resp_result_decode(res_code);
	if (ret) {
		pr_err("VIF%u.%u: CMD %d failed: %u\n", vif->mac->macid,
		       vif->vifid, cmd_type, res_code);
		ret = -EFAULT;
		goto out;
	}

+2 −0
Original line number Diff line number Diff line
@@ -674,6 +674,8 @@ enum qlink_cmd_result {
	QLINK_CMD_RESULT_ENOTSUPP,
	QLINK_CMD_RESULT_ENOTFOUND,
	QLINK_CMD_RESULT_EALREADY,
	QLINK_CMD_RESULT_EADDRINUSE,
	QLINK_CMD_RESULT_EADDRNOTAVAIL,
};

/**