1 From b69c1df47281ad47bd2037a42b98f5c7115b7fd5 Mon Sep 17 00:00:00 2001
2 From: Arend Van Spriel <arend.vanspriel@broadcom.com>
3 Date: Mon, 22 Jan 2018 21:46:40 +0100
4 Subject: [PATCH] brcmfmac: separate firmware errors from i/o errors
6 When using the firmware api it can fail simply because firmware does
7 not like the request or it fails due to issues in the host interface.
8 Currently, there is only a single error code which is confusing. So
9 adding a parameter to pass the firmware error separately and in case
10 of a firmware error always return -EBADE to user-space.
12 Reviewed-by: Hante Meuleman <hante.meuleman@broadcom.com>
13 Reviewed-by: Pieter-Paul Giesberts <pieter-paul.giesberts@broadcom.com>
14 Reviewed-by: Franky Lin <franky.lin@broadcom.com>
15 Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
16 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
18 drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcdc.c | 11 ++++++-----
19 drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil.c | 16 +++++++++++-----
20 .../net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c | 10 ++++++----
21 drivers/net/wireless/broadcom/brcm80211/brcmfmac/proto.h | 14 ++++++++------
22 4 files changed, 31 insertions(+), 20 deletions(-)
24 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcdc.c
25 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcdc.c
26 @@ -165,7 +165,7 @@ static int brcmf_proto_bcdc_cmplt(struct
29 brcmf_proto_bcdc_query_dcmd(struct brcmf_pub *drvr, int ifidx, uint cmd,
30 - void *buf, uint len)
31 + void *buf, uint len, int *fwerr)
33 struct brcmf_bcdc *bcdc = (struct brcmf_bcdc *)drvr->proto->pd;
34 struct brcmf_proto_bcdc_dcmd *msg = &bcdc->msg;
35 @@ -175,6 +175,7 @@ brcmf_proto_bcdc_query_dcmd(struct brcmf
37 brcmf_dbg(BCDC, "Enter, cmd %d len %d\n", cmd, len);
40 ret = brcmf_proto_bcdc_msg(drvr, ifidx, cmd, buf, len, false);
42 brcmf_err("brcmf_proto_bcdc_msg failed w/status %d\n",
43 @@ -215,15 +216,14 @@ retry:
45 /* Check the ERROR flag */
46 if (flags & BCDC_DCMD_ERROR)
47 - ret = le32_to_cpu(msg->status);
49 + *fwerr = le32_to_cpu(msg->status);
55 brcmf_proto_bcdc_set_dcmd(struct brcmf_pub *drvr, int ifidx, uint cmd,
56 - void *buf, uint len)
57 + void *buf, uint len, int *fwerr)
59 struct brcmf_bcdc *bcdc = (struct brcmf_bcdc *)drvr->proto->pd;
60 struct brcmf_proto_bcdc_dcmd *msg = &bcdc->msg;
61 @@ -232,6 +232,7 @@ brcmf_proto_bcdc_set_dcmd(struct brcmf_p
63 brcmf_dbg(BCDC, "Enter, cmd %d len %d\n", cmd, len);
66 ret = brcmf_proto_bcdc_msg(drvr, ifidx, cmd, buf, len, true);
69 @@ -255,7 +256,7 @@ brcmf_proto_bcdc_set_dcmd(struct brcmf_p
71 /* Check the ERROR flag */
72 if (flags & BCDC_DCMD_ERROR)
73 - ret = le32_to_cpu(msg->status);
74 + *fwerr = le32_to_cpu(msg->status);
78 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil.c
79 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil.c
80 @@ -107,7 +107,7 @@ static s32
81 brcmf_fil_cmd_data(struct brcmf_if *ifp, u32 cmd, void *data, u32 len, bool set)
83 struct brcmf_pub *drvr = ifp->drvr;
87 if (drvr->bus_if->state != BRCMF_BUS_UP) {
88 brcmf_err("bus is down. we have nothing to do.\n");
89 @@ -117,14 +117,20 @@ brcmf_fil_cmd_data(struct brcmf_if *ifp,
91 len = min_t(uint, len, BRCMF_DCMD_MAXLEN);
93 - err = brcmf_proto_set_dcmd(drvr, ifp->ifidx, cmd, data, len);
94 + err = brcmf_proto_set_dcmd(drvr, ifp->ifidx, cmd,
97 - err = brcmf_proto_query_dcmd(drvr, ifp->ifidx, cmd, data, len);
98 + err = brcmf_proto_query_dcmd(drvr, ifp->ifidx, cmd,
103 brcmf_dbg(FIL, "Failed: %s (%d)\n",
104 brcmf_fil_get_errstr((u32)(-err)), err);
106 + } else if (fwerr < 0) {
107 + brcmf_dbg(FIL, "Firmware error: %s (%d)\n",
108 + brcmf_fil_get_errstr((u32)(-fwerr)), fwerr);
114 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c
115 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c
116 @@ -477,7 +477,7 @@ static void brcmf_msgbuf_ioctl_resp_wake
119 static int brcmf_msgbuf_query_dcmd(struct brcmf_pub *drvr, int ifidx,
120 - uint cmd, void *buf, uint len)
121 + uint cmd, void *buf, uint len, int *fwerr)
123 struct brcmf_msgbuf *msgbuf = (struct brcmf_msgbuf *)drvr->proto->pd;
124 struct sk_buff *skb = NULL;
125 @@ -485,6 +485,7 @@ static int brcmf_msgbuf_query_dcmd(struc
128 brcmf_dbg(MSGBUF, "ifidx=%d, cmd=%d, len=%d\n", ifidx, cmd, len);
130 msgbuf->ctl_completed = false;
131 err = brcmf_msgbuf_tx_ioctl(drvr, ifidx, cmd, buf, len);
133 @@ -508,14 +509,15 @@ static int brcmf_msgbuf_query_dcmd(struc
135 brcmu_pkt_buf_free_skb(skb);
137 - return msgbuf->ioctl_resp_status;
138 + *fwerr = msgbuf->ioctl_resp_status;
143 static int brcmf_msgbuf_set_dcmd(struct brcmf_pub *drvr, int ifidx,
144 - uint cmd, void *buf, uint len)
145 + uint cmd, void *buf, uint len, int *fwerr)
147 - return brcmf_msgbuf_query_dcmd(drvr, ifidx, cmd, buf, len);
148 + return brcmf_msgbuf_query_dcmd(drvr, ifidx, cmd, buf, len, fwerr);
152 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/proto.h
153 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/proto.h
154 @@ -30,9 +30,9 @@ struct brcmf_proto {
155 int (*hdrpull)(struct brcmf_pub *drvr, bool do_fws,
156 struct sk_buff *skb, struct brcmf_if **ifp);
157 int (*query_dcmd)(struct brcmf_pub *drvr, int ifidx, uint cmd,
158 - void *buf, uint len);
159 + void *buf, uint len, int *fwerr);
160 int (*set_dcmd)(struct brcmf_pub *drvr, int ifidx, uint cmd, void *buf,
162 + uint len, int *fwerr);
163 int (*tx_queue_data)(struct brcmf_pub *drvr, int ifidx,
164 struct sk_buff *skb);
165 int (*txdata)(struct brcmf_pub *drvr, int ifidx, u8 offset,
166 @@ -71,14 +71,16 @@ static inline int brcmf_proto_hdrpull(st
167 return drvr->proto->hdrpull(drvr, do_fws, skb, ifp);
169 static inline int brcmf_proto_query_dcmd(struct brcmf_pub *drvr, int ifidx,
170 - uint cmd, void *buf, uint len)
171 + uint cmd, void *buf, uint len,
174 - return drvr->proto->query_dcmd(drvr, ifidx, cmd, buf, len);
175 + return drvr->proto->query_dcmd(drvr, ifidx, cmd, buf, len,fwerr);
177 static inline int brcmf_proto_set_dcmd(struct brcmf_pub *drvr, int ifidx,
178 - uint cmd, void *buf, uint len)
179 + uint cmd, void *buf, uint len,
182 - return drvr->proto->set_dcmd(drvr, ifidx, cmd, buf, len);
183 + return drvr->proto->set_dcmd(drvr, ifidx, cmd, buf, len, fwerr);
186 static inline int brcmf_proto_tx_queue_data(struct brcmf_pub *drvr, int ifidx,