[MTHCA] improve the time of handling events like port state change
[mirror/winof/.git] / hw / mthca / kernel / mt_cache.c
index a05b601..daff934 100644 (file)
@@ -230,22 +230,30 @@ static void ib_cache_update(struct ib_device *device,
 
        gid_cache->table_len = tprops->gid_tbl_len;
 
-       for (i = 0; i < pkey_cache->table_len; ++i) {
-               ret = ib_query_pkey(device, port, (u16)i, pkey_cache->table + i);
+       for (i = 0; i < pkey_cache->table_len; i+=32) {
+               u16 pkey_chunk[32];
+               int size;
+               ret = ib_query_pkey_chunk(device, port, (u16)i, pkey_chunk);
                if (ret) {
-                       HCA_PRINT(TRACE_LEVEL_WARNING ,HCA_DBG_LOW,("ib_query_pkey failed (%d) for %s (index %d)\n",
+                       HCA_PRINT(TRACE_LEVEL_WARNING ,HCA_DBG_LOW,("ib_query_pkey_chunk failed (%d) for %s (index %d)\n",
                               ret, device->name, i));
                        goto err;
                }
+               size = min(32, pkey_cache->table_len - i);
+               RtlCopyMemory(pkey_cache->table + i, pkey_chunk, size*sizeof(u16));
        }
 
-       for (i = 0; i < gid_cache->table_len; ++i) {
-               ret = ib_query_gid(device, port, i, gid_cache->table + i);
+       for (i = 0; i < gid_cache->table_len; i+=8) {
+               union ib_gid gid_chunk[8];
+               int size;
+               ret = ib_query_gid_chunk(device, port, i, gid_chunk);
                if (ret) {
-                       HCA_PRINT(TRACE_LEVEL_WARNING ,HCA_DBG_LOW,("ib_query_gid failed (%d) for %s (index %d)\n",
+                       HCA_PRINT(TRACE_LEVEL_WARNING ,HCA_DBG_LOW,("ib_query_gid_chunk failed (%d) for %s (index %d)\n",
                               ret, device->name, i));
                        goto err;
                }
+               size = min(8, gid_cache->table_len - i);
+               RtlCopyMemory(gid_cache->table + i, gid_chunk, size*sizeof(union ib_gid));
        }
 
        write_lock_irq(&device->cache.lock, &lh);