Search Linux Wireless

Re: [PATCH 2/2] wifi: mac80211_hwsim: add support for switch_vif_chanctx callback

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2/16/24 01:20, Johannes Berg wrote:
On Thu, 2024-02-15 at 21:58 +0530, Aditya Kumar Singh wrote:
+static int mac80211_hwsim_switch_vif_chanctx(struct ieee80211_hw *hw,
+					     struct ieee80211_vif_chanctx_switch *vifs,
+					     int n_vifs,
+					     enum ieee80211_chanctx_switch_mode mode)
+{
+	int i;
+
+	if (n_vifs <= 0)
+		return -EINVAL;
+
+	wiphy_dbg(hw->wiphy,
+		  "switch vif channel context mode: %u\n", mode);
+
+	for (i = 0; i < n_vifs; i++) {
+		hwsim_check_chanctx_magic(vifs[i].old_ctx);
+		wiphy_dbg(hw->wiphy,
+			  "switch vif channel context: %d MHz/width: %d/cfreqs:%d/%d MHz -> %d MHz/width: %d/cfreqs:%d/%d MHz\n",
+			  vifs[i].old_ctx->def.chan->center_freq,
+			  vifs[i].old_ctx->def.width,
+			  vifs[i].old_ctx->def.center_freq1,
+			  vifs[i].old_ctx->def.center_freq2,
+			  vifs[i].new_ctx->def.chan->center_freq,
+			  vifs[i].new_ctx->def.width,
+			  vifs[i].new_ctx->def.center_freq1,
+			  vifs[i].new_ctx->def.center_freq2);
+		hwsim_set_chanctx_magic(vifs[i].new_ctx);


hwsim_set_chanctx_magic() is only partially correct, I think, this
depends on the mode? For CHANCTX_SWMODE_REASSIGN_VIF the chanctx should
already exist as well, so should also be hwsim_check_chanctx_magic() in
that case?


Oh yeah missed the mode dependency here. Thanks for pointing it out. So it should be something like -

...

/* old already exist so check magic */
hwsim_check_chanctx_magic(vifs[i].old_ctx);

if (mode == CHANCTX_SWMODE_REASSIGN_VIF) {
	/* Reassign then new would also exist, just interface is
	 * switching
	 */
	hwsim_check_chanctx_magic(vifs[i].new_ctx);
} else {
	/* SWAP_* then new context does not exist hence set magic.
	 * Also old will no longer exist so clear the magic
	 */
	hwsim_set_chanctx_magic(vifs[i].new_ctx);
	hwsim_clear_chanctx_magic(vifs[i].old_ctx);
}

...

One thing, in patch should I keep those comments or those are noisy? Seems noisy to me (if at least mode documentation is referred then things are clear already)?




[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Wireless Regulations]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux