Commit 094ecec9 authored by Jérôme Pouiller's avatar Jérôme Pouiller Committed by Greg Kroah-Hartman

staging: wfx: simplify hif_set_template_frame() usage

The structure hif_mib_template_frame come from hardware API. It is not
intended to be manipulated in upper layers of the driver.

In add, the current code for hif_set_template_frame() is dumb. All the
difficult task is left to the caller. So, there is code to factorize
here.
Signed-off-by: default avatarJérôme Pouiller <jerome.pouiller@silabs.com>
Link: https://lore.kernel.org/r/20191217161318.31402-50-Jerome.Pouiller@silabs.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 397f36c1
...@@ -130,8 +130,17 @@ static inline int hif_set_operational_mode(struct wfx_dev *wdev, ...@@ -130,8 +130,17 @@ static inline int hif_set_operational_mode(struct wfx_dev *wdev,
} }
static inline int hif_set_template_frame(struct wfx_vif *wvif, static inline int hif_set_template_frame(struct wfx_vif *wvif,
struct hif_mib_template_frame *arg) struct sk_buff *skb,
u8 frame_type, int init_rate)
{ {
struct hif_mib_template_frame *arg;
skb_push(skb, 4);
arg = (struct hif_mib_template_frame *)skb->data;
skb_pull(skb, 4);
arg->init_rate = init_rate;
arg->frame_type = frame_type;
arg->frame_length = cpu_to_le16(skb->len);
return hif_write_mib(wvif->wdev, wvif->id, HIF_MIB_ID_TEMPLATE_FRAME, return hif_write_mib(wvif->wdev, wvif->id, HIF_MIB_ID_TEMPLATE_FRAME,
arg, sizeof(*arg)); arg, sizeof(*arg));
} }
......
...@@ -52,7 +52,6 @@ static int wfx_scan_start(struct wfx_vif *wvif, ...@@ -52,7 +52,6 @@ static int wfx_scan_start(struct wfx_vif *wvif,
static int update_probe_tmpl(struct wfx_vif *wvif, static int update_probe_tmpl(struct wfx_vif *wvif,
struct cfg80211_scan_request *req) struct cfg80211_scan_request *req)
{ {
struct hif_mib_template_frame *tmpl;
struct sk_buff *skb; struct sk_buff *skb;
skb = ieee80211_probereq_get(wvif->wdev->hw, wvif->vif->addr, skb = ieee80211_probereq_get(wvif->wdev->hw, wvif->vif->addr,
...@@ -61,11 +60,7 @@ static int update_probe_tmpl(struct wfx_vif *wvif, ...@@ -61,11 +60,7 @@ static int update_probe_tmpl(struct wfx_vif *wvif,
return -ENOMEM; return -ENOMEM;
skb_put_data(skb, req->ie, req->ie_len); skb_put_data(skb, req->ie, req->ie_len);
skb_push(skb, 4); hif_set_template_frame(wvif, skb, HIF_TMPLT_PRBREQ, 0);
tmpl = (struct hif_mib_template_frame *)skb->data;
tmpl->frame_type = HIF_TMPLT_PRBREQ;
tmpl->frame_length = cpu_to_le16(skb->len - 4);
hif_set_template_frame(wvif, tmpl);
dev_kfree_skb(skb); dev_kfree_skb(skb);
return 0; return 0;
} }
......
...@@ -831,32 +831,20 @@ static int wfx_update_beaconing(struct wfx_vif *wvif) ...@@ -831,32 +831,20 @@ static int wfx_update_beaconing(struct wfx_vif *wvif)
static int wfx_upload_beacon(struct wfx_vif *wvif) static int wfx_upload_beacon(struct wfx_vif *wvif)
{ {
int ret = 0; struct sk_buff *skb;
struct sk_buff *skb = NULL;
struct ieee80211_mgmt *mgmt; struct ieee80211_mgmt *mgmt;
struct hif_mib_template_frame *p;
if (wvif->vif->type == NL80211_IFTYPE_STATION || if (wvif->vif->type == NL80211_IFTYPE_STATION ||
wvif->vif->type == NL80211_IFTYPE_MONITOR || wvif->vif->type == NL80211_IFTYPE_MONITOR ||
wvif->vif->type == NL80211_IFTYPE_UNSPECIFIED) wvif->vif->type == NL80211_IFTYPE_UNSPECIFIED)
goto done; return 0;
skb = ieee80211_beacon_get(wvif->wdev->hw, wvif->vif); skb = ieee80211_beacon_get(wvif->wdev->hw, wvif->vif);
if (!skb) if (!skb)
return -ENOMEM; return -ENOMEM;
hif_set_template_frame(wvif, skb, HIF_TMPLT_BCN,
API_RATE_INDEX_B_1MBPS);
p = (struct hif_mib_template_frame *) skb_push(skb, 4);
p->frame_type = HIF_TMPLT_BCN;
p->init_rate = API_RATE_INDEX_B_1MBPS; /* 1Mbps DSSS */
p->frame_length = cpu_to_le16(skb->len - 4);
ret = hif_set_template_frame(wvif, p);
skb_pull(skb, 4);
if (ret)
goto done;
/* TODO: Distill probe resp; remove TIM and any other beacon-specific /* TODO: Distill probe resp; remove TIM and any other beacon-specific
* IEs * IEs
*/ */
...@@ -864,14 +852,11 @@ static int wfx_upload_beacon(struct wfx_vif *wvif) ...@@ -864,14 +852,11 @@ static int wfx_upload_beacon(struct wfx_vif *wvif)
mgmt->frame_control = mgmt->frame_control =
cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP); cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
p->frame_type = HIF_TMPLT_PRBRES; hif_set_template_frame(wvif, skb, HIF_TMPLT_PRBRES,
API_RATE_INDEX_B_1MBPS);
ret = hif_set_template_frame(wvif, p);
wfx_fwd_probe_req(wvif, false); wfx_fwd_probe_req(wvif, false);
done:
dev_kfree_skb(skb); dev_kfree_skb(skb);
return ret; return 0;
} }
static int wfx_is_ht(const struct wfx_ht_info *ht_info) static int wfx_is_ht(const struct wfx_ht_info *ht_info)
......
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