fix cleanup flow for memfree devices
authorelic307 <elic307>
Thu, 27 Apr 2006 16:59:06 +0000 (16:59 +0000)
committerelic307 <elic307>
Thu, 27 Apr 2006 16:59:06 +0000 (16:59 +0000)
src/drivers/net/mlx_ipoib/cmdif_mt25218.c
src/drivers/net/mlx_ipoib/ib_driver.c
src/drivers/net/mlx_ipoib/ib_mt23108.c
src/drivers/net/mlx_ipoib/ib_mt25218.c
src/drivers/net/mlx_ipoib/mt25218.h

index fb95edb..704fb1f 100644 (file)
 #include "cmdif_priv.h"
 #include "mt25218.h"
 
-/*
- *  cmd_sys_dis
- */
-static int cmd_sys_dis(void)
-{
-       return 0;
-}
-
 /*
  *  cmd_write_mgm
  */
@@ -325,6 +317,24 @@ static int cmd_map_icm_aux(struct map_icm_st *map_icm_aux_p)
        return rc;
 }
 
+
+/*
+ *  cmd_unmap_icm_aux
+ */
+static int cmd_unmap_icm_aux(void)
+{
+       int rc;
+       command_fields_t cmd_desc;
+
+       memset(&cmd_desc, 0, sizeof cmd_desc);
+
+       cmd_desc.opcode = MEMFREE_CMD_UNMAP_ICM_AUX;
+
+       rc = cmd_invoke(&cmd_desc);
+
+       return rc;
+}
+
 /*
  *  cmd_map_icm
  */
@@ -371,6 +381,31 @@ static int cmd_map_icm(struct map_icm_st *map_icm_p)
        return rc;
 }
 
+
+
+/*
+ *  cmd_unmap_icm
+ */
+static int cmd_unmap_icm(struct map_icm_st *map_icm_p)
+{
+       int rc;
+       command_fields_t cmd_desc;
+       __u32 iprm[2];
+
+       memset(&cmd_desc, 0, sizeof cmd_desc);
+
+       cmd_desc.opcode = MEMFREE_CMD_UNMAP_ICM;
+       iprm[0] = map_icm_p->vpm_arr[0].va_h;
+       iprm[1] = map_icm_p->vpm_arr[0].va_l;
+       cmd_desc.in_param = iprm;
+       cmd_desc.in_trans = TRANS_IMMEDIATE;
+       cmd_desc.input_modifier = 1 << map_icm_p->vpm_arr[0].log2_size;
+
+       rc = cmd_invoke(&cmd_desc);
+
+       return rc;
+}
+
 /*
  *  cmd_query_dev_lim
  */
index a46db7f..a3015ba 100644 (file)
@@ -248,12 +248,10 @@ static int ib_driver_close(int fw_fatal)
                ret = 1;
        }
 
-       if (!fw_fatal) {
-               rc = cmd_sys_dis();
-               if (rc) {
-                       eprintf("");
-                       ret = 1;
-               }
+       rc = unset_hca();
+       if (rc) {
+               eprintf("");
+               ret = 1;
        }
 
        return ret;
index 0291f46..e09eabf 100644 (file)
@@ -799,6 +799,20 @@ static int setup_hca(__u8 port, void **eq_p)
        return ret;
 }
 
+
+static int unset_hca(void)
+{
+       int rc = 0;
+
+       if (!fw_fatal) {
+               rc = cmd_sys_dis();
+               if (rc)
+                       eprintf("");
+       }
+
+       return rc;
+}
+
 static void *get_inprm_buf(void)
 {
        return dev_buffers_p->inprm_buf;
index 11b25d4..8b6b994 100644 (file)
@@ -89,6 +89,10 @@ static struct dev_pci_struct memfree_pci_dev;
 static struct device_buffers_st *dev_buffers_p;
 static struct device_ib_data_st dev_ib_data;
 
+
+
+struct map_icm_st icm_map_obj;
+
 static int gw_write_cr(__u32 addr, __u32 data)
 {
        writel(htonl(data), memfree_pci_dev.cr_space + addr);
@@ -850,6 +854,8 @@ static int setup_hca(__u8 port, void **eq_p)
                eprintf("");
                goto undo_map_fa;
        }
+       icm_map_obj = map_obj;
+
        phys_mem.offset += (1 << (map_obj.vpm_arr[0].log2_size + 12));
 
        init_hca.log_max_uars = log_max_uars;
@@ -978,6 +984,30 @@ static int setup_hca(__u8 port, void **eq_p)
        return ret;
 }
 
+
+static int unset_hca(void)
+{
+       int rc, ret = 0;
+
+       rc = cmd_unmap_icm(&icm_map_obj);
+       if (rc)
+               eprintf("");
+       ret |= rc;
+
+
+       rc = cmd_unmap_icm_aux();
+       if (rc)
+               eprintf("");
+       ret |= rc;
+
+       rc = cmd_unmap_fa();
+       if (rc)
+               eprintf("");
+       ret |= rc;
+
+       return ret;
+}
+
 static void *get_inprm_buf(void)
 {
        return dev_buffers_p->inprm_buf;
index 15a3fea..1e7c8d8 100644 (file)
@@ -26,7 +26,9 @@
 #define MEMFREE_CMD_RUN_FW                     0xff6
 #define MEMFREE_CMD_SET_ICM_SIZE       0xffd
 #define MEMFREE_CMD_MAP_ICM_AUX                0xffc
+#define MEMFREE_CMD_UNMAP_ICM_AUX              0xffb
 #define MEMFREE_CMD_MAP_ICM                    0xffa
+#define MEMFREE_CMD_UNMAP_ICM                  0xff9
 #define MEMFREE_CMD_QUERY_DEV_LIM   0x003
 
 /*