mac80211-hwsim: support creating wiphy w/out creating wlanX
[cascardo/linux.git] / drivers / net / wireless / mac80211_hwsim.c
index 23f184d..d109e50 100644 (file)
@@ -2023,7 +2023,8 @@ static int mac80211_hwsim_create_radio(int channels, const char *reg_alpha2,
                                       const struct ieee80211_regdomain *regd,
                                       bool reg_strict, bool p2p_device,
                                       bool use_chanctx, bool destroy_on_close,
-                                      u32 portid, const char *hwname)
+                                      u32 portid, const char *hwname,
+                                      bool no_vif)
 {
        int err;
        u8 addr[ETH_ALEN];
@@ -2230,6 +2231,9 @@ static int mac80211_hwsim_create_radio(int channels, const char *reg_alpha2,
                schedule_timeout_interruptible(1);
        }
 
+       if (no_vif)
+               hw->flags |= IEEE80211_HW_NO_AUTO_VIF;
+
        err = ieee80211_register_hw(hw);
        if (err < 0) {
                printk(KERN_DEBUG "mac80211_hwsim: ieee80211_register_hw failed (%d)\n",
@@ -2516,11 +2520,15 @@ static int hwsim_create_radio_nl(struct sk_buff *msg, struct genl_info *info)
        bool p2p_device = info->attrs[HWSIM_ATTR_SUPPORT_P2P_DEVICE];
        bool destroy_on_close = info->attrs[HWSIM_ATTR_DESTROY_RADIO_ON_CLOSE];
        bool use_chanctx;
+       bool no_vif = false;
        const char *hwname = NULL;
 
        if (info->attrs[HWSIM_ATTR_CHANNELS])
                chans = nla_get_u32(info->attrs[HWSIM_ATTR_CHANNELS]);
 
+       if (info->attrs[HWSIM_ATTR_NO_VIF])
+               no_vif = true;
+
        if (info->attrs[HWSIM_ATTR_RADIO_NAME])
                hwname = nla_data(info->attrs[HWSIM_ATTR_RADIO_NAME]);
 
@@ -2543,7 +2551,7 @@ static int hwsim_create_radio_nl(struct sk_buff *msg, struct genl_info *info)
        return mac80211_hwsim_create_radio(chans, alpha2, regd, reg_strict,
                                           p2p_device, use_chanctx,
                                           destroy_on_close, info->snd_portid,
-                                          hwname);
+                                          hwname, no_vif);
 }
 
 static int hwsim_destroy_radio_nl(struct sk_buff *msg, struct genl_info *info)
@@ -2799,7 +2807,8 @@ static int __init init_mac80211_hwsim(void)
                err = mac80211_hwsim_create_radio(channels, reg_alpha2,
                                                  regd, reg_strict,
                                                  support_p2p_device,
-                                                 channels > 1, false, 0, NULL);
+                                                 channels > 1, false, 0, NULL,
+                                                 false);
                if (err < 0)
                        goto out_free_radios;
        }