@@ -74,6 +74,7 @@ static int rx_helper(struct wfx_dev *wdev, size_t read_len, int *is_cnf)
_trace_piggyback(piggyback, false);
hif = (struct hif_msg *)skb->data;
+ le16_to_cpus((__le16 *)&hif->len);
WARN(hif->encrypted & 0x1, "unsupported encryption type");
if (hif->encrypted == 0x2) {
if (wfx_sl_decode(wdev, (void *)hif)) {
@@ -84,12 +85,11 @@ static int rx_helper(struct wfx_dev *wdev, size_t read_len, int *is_cnf)
// piggyback is probably correct.
return piggyback;
}
- le16_to_cpus(&hif->len);
+ le16_to_cpus((__le16 *)&hif->len);
computed_len = round_up(hif->len - sizeof(hif->len), 16)
+ sizeof(struct hif_sl_msg)
+ sizeof(struct hif_sl_tag);
} else {
- le16_to_cpus(&hif->len);
computed_len = round_up(hif->len, 2);
}
if (computed_len != read_len) {
@@ -172,7 +172,7 @@ static void tx_helper(struct wfx_dev *wdev, struct hif_msg *hif)
int ret;
void *data;
bool is_encrypted = false;
- size_t len = le16_to_cpu(hif->len);
+ size_t len = hif->len;
WARN(len < sizeof(*hif), "try to send corrupted data");
@@ -199,6 +199,7 @@ static void tx_helper(struct wfx_dev *wdev, struct hif_msg *hif)
WARN(len > wdev->hw_caps.size_inp_ch_buf,
"%s: request exceed WFx capability: %zu > %d\n", __func__,
len, wdev->hw_caps.size_inp_ch_buf);
+ cpu_to_le16s(((struct hif_msg *)data)->len);
len = wdev->hwbus_ops->align_size(wdev->hwbus_priv, len);
ret = wfx_data_write(wdev, data, len);
if (ret)
@@ -384,7 +384,7 @@ static int wfx_tx_inner(struct wfx_vif *wvif, struct ieee80211_sta *sta,
skb_push(skb, wmsg_len);
memset(skb->data, 0, wmsg_len);
hif_msg = (struct hif_msg *)skb->data;
- hif_msg->len = cpu_to_le16(skb->len);
+ hif_msg->len = skb->len;
hif_msg->id = HIF_REQ_ID_TX;
hif_msg->interface = wvif->id;
if (skb->len > wvif->wdev->hw_caps.size_inp_ch_buf) {
@@ -23,7 +23,10 @@
#define HIF_COUNTER_MAX 7
struct hif_msg {
- __le16 len;
+ // len is in fact little endian. However, it is widely used in the
+ // driver, so we declare it in native byte order and we reorder just
+ // before/after send/receive it (see bh.c).
+ u16 len;
u8 id;
u8 reserved:1;
u8 interface:2;
@@ -277,7 +280,8 @@ struct hif_sl_msg_hdr {
struct hif_sl_msg {
struct hif_sl_msg_hdr hdr;
- __le16 len;
+ // Same note than struct hif_msg
+ u16 len;
u8 payload[];
} __packed;
@@ -33,7 +33,7 @@ static void wfx_fill_header(struct hif_msg *hif, int if_id,
WARN(size > 0xFFF, "requested buffer is too large: %zu bytes", size);
WARN(if_id > 0x3, "invalid interface ID %d", if_id);
- hif->len = cpu_to_le16(size + 4);
+ hif->len = size + 4;
hif->id = cmd;
hif->interface = if_id;
}