"configuration (%d).\n", rc);
                        return rc;
                }
-               iwl_clear_ucode_stations(priv);
-               iwl_restore_stations(priv);
+               iwl_clear_ucode_stations(priv,
+                                        &priv->contexts[IWL_RXON_CTX_BSS]);
+               iwl_restore_stations(priv, &priv->contexts[IWL_RXON_CTX_BSS]);
        }
 
        IWL_DEBUG_INFO(priv, "Sending RXON\n"
        memcpy(active_rxon, staging_rxon, sizeof(*active_rxon));
 
        if (!new_assoc) {
-               iwl_clear_ucode_stations(priv);
-               iwl_restore_stations(priv);
+               iwl_clear_ucode_stations(priv,
+                                        &priv->contexts[IWL_RXON_CTX_BSS]);
+               iwl_restore_stations(priv, &priv->contexts[IWL_RXON_CTX_BSS]);
        }
 
        /* If we issue a new RXON command which required a tune then we must
 
                        IWL_ERR(priv, "Error clearing ASSOC_MSK (%d)\n", ret);
                        return ret;
                }
-               iwl_clear_ucode_stations(priv);
-               iwl_restore_stations(priv);
+               iwl_clear_ucode_stations(priv, ctx);
+               iwl_restore_stations(priv, ctx);
                ret = iwl_restore_default_wep_keys(priv);
                if (ret) {
                        IWL_ERR(priv, "Failed to restore WEP keys (%d)\n", ret);
                }
                IWL_DEBUG_INFO(priv, "Return from !new_assoc RXON.\n");
                memcpy(active_rxon, &ctx->staging, sizeof(*active_rxon));
-               iwl_clear_ucode_stations(priv);
-               iwl_restore_stations(priv);
+               iwl_clear_ucode_stations(priv, ctx);
+               iwl_restore_stations(priv, ctx);
                ret = iwl_restore_default_wep_keys(priv);
                if (ret) {
                        IWL_ERR(priv, "Failed to restore WEP keys (%d)\n", ret);
        if (priv->cfg->ops->lib->recover_from_tx_stall)
                del_timer_sync(&priv->monitor_recover);
 
-       iwl_clear_ucode_stations(priv);
+       iwl_clear_ucode_stations(priv, NULL);
        iwl_dealloc_bcast_stations(priv);
        iwl_clear_driver_stations(priv);
 
 
 struct iwl_station_entry {
        struct iwl_addsta_cmd sta;
        struct iwl_tid_data tid[MAX_TID_COUNT];
-       u8 used;
+       u8 used, ctxid;
        struct iwl_hw_key keyinfo;
        struct iwl_link_quality_cmd *lq;
 };
 
        station->sta.mode = 0;
        station->sta.sta.sta_id = sta_id;
        station->sta.station_flags = 0;
+       station->ctxid = ctx->ctxid;
 
        /*
         * OK to call unconditionally, since local stations (IBSS BSSID
  * other than explicit station management would cause this in
  * the ucode, e.g. unassociated RXON.
  */
-void iwl_clear_ucode_stations(struct iwl_priv *priv)
+void iwl_clear_ucode_stations(struct iwl_priv *priv,
+                             struct iwl_rxon_context *ctx)
 {
        int i;
        unsigned long flags_spin;
 
        spin_lock_irqsave(&priv->sta_lock, flags_spin);
        for (i = 0; i < priv->hw_params.max_stations; i++) {
+               if (ctx && ctx->ctxid != priv->stations[i].ctxid)
+                       continue;
+
                if (priv->stations[i].used & IWL_STA_UCODE_ACTIVE) {
                        IWL_DEBUG_INFO(priv, "Clearing ucode active for station %d\n", i);
                        priv->stations[i].used &= ~IWL_STA_UCODE_ACTIVE;
  *
  * Function sleeps.
  */
-void iwl_restore_stations(struct iwl_priv *priv)
+void iwl_restore_stations(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
 {
        struct iwl_addsta_cmd sta_cmd;
        struct iwl_link_quality_cmd lq;
        IWL_DEBUG_ASSOC(priv, "Restoring all known stations ... start.\n");
        spin_lock_irqsave(&priv->sta_lock, flags_spin);
        for (i = 0; i < priv->hw_params.max_stations; i++) {
+               if (ctx->ctxid != priv->stations[i].ctxid)
+                       continue;
                if ((priv->stations[i].used & IWL_STA_DRIVER_ACTIVE) &&
                            !(priv->stations[i].used & IWL_STA_UCODE_ACTIVE)) {
                        IWL_DEBUG_ASSOC(priv, "Restoring sta %pM\n",
 
                         struct ieee80211_key_conf *keyconf,
                         struct ieee80211_sta *sta, u32 iv32, u16 *phase1key);
 
-void iwl_restore_stations(struct iwl_priv *priv);
-void iwl_clear_ucode_stations(struct iwl_priv *priv);
+void iwl_restore_stations(struct iwl_priv *priv, struct iwl_rxon_context *ctx);
+void iwl_clear_ucode_stations(struct iwl_priv *priv,
+                             struct iwl_rxon_context *ctx);
 int iwl_alloc_bcast_station(struct iwl_priv *priv, struct iwl_rxon_context *ctx,
                            bool init_lq);
 void iwl_dealloc_bcast_stations(struct iwl_priv *priv);
 
                del_timer_sync(&priv->monitor_recover);
 
        /* Station information will now be cleared in device */
-       iwl_clear_ucode_stations(priv);
+       iwl_clear_ucode_stations(priv, NULL);
        iwl_dealloc_bcast_stations(priv);
        iwl_clear_driver_stations(priv);