Commit 2c33360b authored by Jaehee Park's avatar Jaehee Park Committed by Kalle Valo
Browse files

wfx: use container_of() to get vif



Currently, upon virtual interface creation, wfx_add_interface() stores
a reference to the corresponding struct ieee80211_vif in private data,
for later usage. This is not needed when using the container_of
construct. This construct already has all the info it needs to retrieve
the reference to the corresponding struct from the offset that is
already available, inherent in container_of(), between its type and
member inputs (struct ieee80211_vif and drv_priv, respectively).
Remove vif (which was previously storing the reference to the struct
ieee80211_vif) from the struct wfx_vif, define a function
wvif_to_vif(wvif) for container_of(), and replace all wvif->vif with
the newly defined container_of construct.

Signed-off-by: default avatarJaehee Park <jhpark1013@gmail.com>
Signed-off-by: default avatarKalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220506170046.GA1297231@jaehee-ThinkPad-X1-Extreme
parent dadb2086
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@

static void wfx_rx_handle_ba(struct wfx_vif *wvif, struct ieee80211_mgmt *mgmt)
{
	struct ieee80211_vif *vif = wvif_to_vif(wvif);
	int params, tid;

	if (wfx_api_older_than(wvif->wdev, 3, 6))
@@ -24,12 +25,12 @@ static void wfx_rx_handle_ba(struct wfx_vif *wvif, struct ieee80211_mgmt *mgmt)
	case WLAN_ACTION_ADDBA_REQ:
		params = le16_to_cpu(mgmt->u.action.u.addba_req.capab);
		tid = (params & IEEE80211_ADDBA_PARAM_TID_MASK) >> 2;
		ieee80211_start_rx_ba_session_offl(wvif->vif, mgmt->sa, tid);
		ieee80211_start_rx_ba_session_offl(vif, mgmt->sa, tid);
		break;
	case WLAN_ACTION_DELBA:
		params = le16_to_cpu(mgmt->u.action.u.delba.params);
		tid = (params &  IEEE80211_DELBA_PARAM_TID_MASK) >> 12;
		ieee80211_stop_rx_ba_session_offl(wvif->vif, mgmt->sa, tid);
		ieee80211_stop_rx_ba_session_offl(vif, mgmt->sa, tid);
		break;
	}
}
+2 −1
Original line number Diff line number Diff line
@@ -212,11 +212,12 @@ static u8 wfx_tx_get_link_id(struct wfx_vif *wvif, struct ieee80211_sta *sta,
			     struct ieee80211_hdr *hdr)
{
	struct wfx_sta_priv *sta_priv = sta ? (struct wfx_sta_priv *)&sta->drv_priv : NULL;
	struct ieee80211_vif *vif = wvif_to_vif(wvif);
	const u8 *da = ieee80211_get_DA(hdr);

	if (sta_priv && sta_priv->link_id)
		return sta_priv->link_id;
	if (wvif->vif->type != NL80211_IFTYPE_AP)
	if (vif->type != NL80211_IFTYPE_AP)
		return 0;
	if (is_multicast_ether_addr(da))
		return 0;
+2 −2
Original line number Diff line number Diff line
@@ -156,6 +156,7 @@ static int wfx_add_key(struct wfx_vif *wvif, struct ieee80211_sta *sta,
	struct wfx_dev *wdev = wvif->wdev;
	int idx = wfx_alloc_key(wvif->wdev);
	bool pairwise = key->flags & IEEE80211_KEY_FLAG_PAIRWISE;
	struct ieee80211_vif *vif = wvif_to_vif(wvif);

	WARN(key->flags & IEEE80211_KEY_FLAG_PAIRWISE && !sta, "inconsistent data");
	ieee80211_get_key_rx_seq(key, 0, &seq);
@@ -174,7 +175,7 @@ static int wfx_add_key(struct wfx_vif *wvif, struct ieee80211_sta *sta,
			k.type = fill_tkip_pair(&k.key.tkip_pairwise_key, key, sta->addr);
		else
			k.type = fill_tkip_group(&k.key.tkip_group_key, key, &seq,
						 wvif->vif->type);
						 vif->type);
	} else if (key->cipher == WLAN_CIPHER_SUITE_CCMP) {
		if (pairwise)
			k.type = fill_ccmp_pair(&k.key.aes_pairwise_key, key, sta->addr);
@@ -224,4 +225,3 @@ int wfx_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, struct ieee80211_
	mutex_unlock(&wvif->wdev->conf_mutex);
	return ret;
}
+2 −1
Original line number Diff line number Diff line
@@ -205,9 +205,10 @@ unsigned int wfx_pending_get_pkt_us_delay(struct wfx_dev *wdev, struct sk_buff *

bool wfx_tx_queues_has_cab(struct wfx_vif *wvif)
{
	struct ieee80211_vif *vif = wvif_to_vif(wvif);
	int i;

	if (wvif->vif->type != NL80211_IFTYPE_AP)
	if (vif->type != NL80211_IFTYPE_AP)
		return false;
	for (i = 0; i < IEEE80211_NUM_ACS; ++i)
		/* Note: since only AP can have mcast frames in queue and only one vif can be AP,
+7 −4
Original line number Diff line number Diff line
@@ -23,9 +23,11 @@ static void wfx_ieee80211_scan_completed_compat(struct ieee80211_hw *hw, bool ab

static int update_probe_tmpl(struct wfx_vif *wvif, struct cfg80211_scan_request *req)
{
	struct ieee80211_vif *vif = wvif_to_vif(wvif);
	struct sk_buff *skb;

	skb = ieee80211_probereq_get(wvif->wdev->hw, wvif->vif->addr, NULL, 0, req->ie_len);
	skb = ieee80211_probereq_get(wvif->wdev->hw, vif->addr, NULL, 0,
				     req->ie_len);
	if (!skb)
		return -ENOMEM;

@@ -37,8 +39,9 @@ static int update_probe_tmpl(struct wfx_vif *wvif, struct cfg80211_scan_request

static int send_scan_req(struct wfx_vif *wvif, struct cfg80211_scan_request *req, int start_idx)
{
	int i, ret;
	struct ieee80211_vif *vif = wvif_to_vif(wvif);
	struct ieee80211_channel *ch_start, *ch_cur;
	int i, ret;

	for (i = start_idx; i < req->n_channels; i++) {
		ch_start = req->channels[start_idx];
@@ -75,8 +78,8 @@ static int send_scan_req(struct wfx_vif *wvif, struct cfg80211_scan_request *req
	} else {
		ret = wvif->scan_nb_chan_done;
	}
	if (req->channels[start_idx]->max_power != wvif->vif->bss_conf.txpower)
		wfx_hif_set_output_power(wvif, wvif->vif->bss_conf.txpower);
	if (req->channels[start_idx]->max_power != vif->bss_conf.txpower)
		wfx_hif_set_output_power(wvif, vif->bss_conf.txpower);
	wfx_tx_unlock(wvif->wdev);
	return ret;
}
Loading