[ofw] patch: [MLX4_BUS] support ModStatConfg command to query if port is enabled or disabled.

Tzachi Dar tzachid at mellanox.co.il
Sun Nov 15 10:03:04 PST 2009


signed off by: urih
 
Index: Q:/projinf3/trunk/hw/mlx4/kernel/bus/net/fw.c
===================================================================
--- Q:/projinf3/trunk/hw/mlx4/kernel/bus/net/fw.c (revision 4795)
+++ Q:/projinf3/trunk/hw/mlx4/kernel/bus/net/fw.c (revision 4796)
@@ -626,6 +626,54 @@
  return err;
 }
 
+
+static int
+query_port_state(struct mlx4_dev *dev, u8 port)
+{
+ int err = 0;
+    u32 input_modifier = 0;    
+ u64 out_param;
+
+#define MOD_STAT_OPMOD_QUERY_INLINE 0x3
+#define MOD_STAT_OFFSET_PORT_EN 0x8
+
+    input_modifier = (1 << 28) | (port << 8) | MOD_STAT_OFFSET_PORT_EN;
+
+    err = mlx4_cmd_imm(dev, 0, &out_param, input_modifier, 
+                MOD_STAT_OPMOD_QUERY_INLINE, 
+                MLX4_CMD_QUERY_STAT_CFG,
+       MLX4_CMD_TIME_CLASS_A);
+ if (err) {
+  return err;
+ }
+    
+    dev->caps.port_state[port] = (((out_param >> 20) & 1) ?
MLX4_PORT_ENABLED : MLX4_PORT_DISABLED);
+    return 0;
+}
+
+int mlx4_port_state(struct mlx4_dev *dev)
+{
+    u8 i = 0;
+ int err = 0;
+
+    
+    for (i = 1; i <= MLX4_MAX_PORTS; ++i)
+    {
+        dev->caps.port_state[i] = MLX4_PORT_ENABLED;
+    }
+    
+    for (i = 1; i <= MLX4_MAX_PORTS; ++i)
+    {
+        err = query_port_state(dev, i);
+        if (err)
+        {
+            return err;
+        }
+    }
+    
+    return 0;
+}
+
 static void get_board_id(u8 *vsd, char *board_id)
 {
  int i;
Index: Q:/projinf3/trunk/hw/mlx4/kernel/bus/net/fw.h
===================================================================
--- Q:/projinf3/trunk/hw/mlx4/kernel/bus/net/fw.h (revision 4795)
+++ Q:/projinf3/trunk/hw/mlx4/kernel/bus/net/fw.h (revision 4796)
@@ -160,6 +160,7 @@
 int mlx4_UNMAP_FA(struct mlx4_dev *dev);
 int mlx4_RUN_FW(struct mlx4_dev *dev);
 int mlx4_QUERY_FW(struct mlx4_dev *dev);
+int mlx4_port_state(struct mlx4_dev *dev);
 int mlx4_QUERY_ADAPTER(struct mlx4_dev *dev, struct mlx4_adapter
*adapter);
 int mlx4_INIT_HCA(struct mlx4_dev *dev, struct mlx4_init_hca_param
*param);
 int mlx4_CLOSE_HCA(struct mlx4_dev *dev, int panic);
Index: Q:/projinf3/trunk/hw/mlx4/kernel/bus/net/main.c
===================================================================
--- Q:/projinf3/trunk/hw/mlx4/kernel/bus/net/main.c (revision 4795)
+++ Q:/projinf3/trunk/hw/mlx4/kernel/bus/net/main.c (revision 4796)
@@ -146,12 +146,28 @@
 
 BOOLEAN mlx4_is_eth_port(struct mlx4_dev *dev, int port_number)
 {
- if (dev->caps.port_type[port_number+1] == MLX4_PORT_TYPE_ETH) {
+ if (dev->caps.port_type[port_number] == MLX4_PORT_TYPE_ETH) {
   return TRUE;
  }
  return FALSE;
 }
 
+BOOLEAN mlx4_is_ib_port(struct mlx4_dev *dev, int port_number)
+{
+ if (dev->caps.port_type[port_number] == MLX4_PORT_TYPE_IB){
+        return TRUE;
+    }
+    return FALSE;        
+}
+
+BOOLEAN mlx4_is_enabled_port(struct mlx4_dev *dev, int port_number)
+{
+ if (dev->caps.port_state[port_number] == MLX4_PORT_ENABLED) {
+  return TRUE;
+ }
+ return FALSE;
+}
+
 static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap
*dev_cap)
 {
  int err;
@@ -671,6 +687,12 @@
   goto err_stop_fw;
  }
 
+    //
+    // Initilize the port state. It's a new command that is supported
only in FW 2.6.1280. 
+    //If running on earlier FW version the command can fail. Ignore the
error code returned
+    //
+    mlx4_port_state(dev);
+
  process_mod_param_profile();
  profile = default_profile;
 
Index: Q:/projinf3/trunk/hw/mlx4/kernel/bus/net/mlx4.h
===================================================================
--- Q:/projinf3/trunk/hw/mlx4/kernel/bus/net/mlx4.h (revision 4795)
+++ Q:/projinf3/trunk/hw/mlx4/kernel/bus/net/mlx4.h (revision 4796)
@@ -65,6 +65,11 @@
  MLX4_PORT_TYPE_ETH = 1 << 1,
 };
 
+enum mlx4_port_state {
+ MLX4_PORT_ENABLED = 1 << 0,
+ MLX4_PORT_DISABLED = 1 << 1,
+};
+
 #define MAX_HCA_CARDS  8
 
 #pragma warning(disable:4201) // nameless struct/union
@@ -387,6 +392,8 @@
 void mlx4_net_init();
 
 BOOLEAN mlx4_is_eth_port(struct mlx4_dev *dev, int port_number);
+BOOLEAN mlx4_is_ib_port(struct mlx4_dev *dev, int port_number);
+BOOLEAN mlx4_is_enabled_port(struct mlx4_dev *dev, int port_number);
 int mlx4_count_ib_ports(struct mlx4_dev *dev);
 
 struct mlx4_dev_cap;
Index: Q:/projinf3/trunk/hw/mlx4/kernel/bus/inc/device.h
===================================================================
--- Q:/projinf3/trunk/hw/mlx4/kernel/bus/inc/device.h (revision 4795)
+++ Q:/projinf3/trunk/hw/mlx4/kernel/bus/inc/device.h (revision 4796)
@@ -208,7 +208,8 @@
  int   log_num_prios;
  int   num_fc_exch;
  enum mlx4_port_type port_type[MLX4_MAX_PORTS + 1];
- int   reserved_fexch_mpts_base;   
+    enum mlx4_port_state port_state[MLX4_MAX_PORTS + 1];
+    int   reserved_fexch_mpts_base;   
  int   total_reserved_qps;
 };
 
Index: Q:/projinf3/trunk/hw/mlx4/kernel/bus/inc/cmd.h
===================================================================
--- Q:/projinf3/trunk/hw/mlx4/kernel/bus/inc/cmd.h (revision 4795)
+++ Q:/projinf3/trunk/hw/mlx4/kernel/bus/inc/cmd.h (revision 4796)
@@ -114,6 +114,7 @@
  /* miscellaneous commands */
  MLX4_CMD_DIAG_RPRT  = 0x30,
  MLX4_CMD_NOP   = 0x31,
+    MLX4_CMD_QUERY_STAT_CFG  = 0x34,
 
  /* debug commands */
  MLX4_CMD_QUERY_DEBUG_MSG = 0x2a,
Index: Q:/projinf3/trunk/hw/mlx4/kernel/bus/drv/drv.c
===================================================================
--- Q:/projinf3/trunk/hw/mlx4/kernel/bus/drv/drv.c (revision 4795)
+++ Q:/projinf3/trunk/hw/mlx4/kernel/bus/drv/drv.c (revision 4796)
@@ -221,7 +221,9 @@
  int number_of_ib_ports;
  PFDO_DEVICE_DATA p_fdo  = FdoGetData(Device);
  struct mlx4_dev *mdev = p_fdo->pci_dev.dev;
-
+    BOOLEAN ib_created = FALSE;
+    BOOLEAN eth_created = FALSE;
+    
  MLX4_ENTER(MLX4_DBG_DRV);
 
  if ( p_fdo->children_created )
@@ -232,22 +234,38 @@
  // this routine will create all the children on base on this info
  number_of_ib_ports = mlx4_count_ib_ports(mdev);
  ASSERT(number_of_ib_ports >=0 && number_of_ib_ports <=2);
- 
- if(number_of_ib_ports > 0) {
-  status = __create_child(Device, BUS_HARDWARE_IDS,
BUS_HARDWARE_DESCRIPTION, 0 );
-  if (!NT_SUCCESS(status)) {
-    MLX4_PRINT_EV(TRACE_LEVEL_ERROR, MLX4_DBG_DRV, ("__create_child
(ib)failed with 0x%x\n", status));
-  }
- }
 
- // Create ethernet ports if needed
- for (i = 0; i < MLX4_MAX_PORTS; i++) {
-  if(mlx4_is_eth_port(mdev, i)) {
-   status = __create_child(Device, ETH_HARDWARE_IDS,
ETH_HARDWARE_DESCRIPTION, i+1 );
-   if (!NT_SUCCESS(status)) {
-     MLX4_PRINT_EV(TRACE_LEVEL_ERROR, MLX4_DBG_DRV, ("__create_child
(eth) failed with 0x%x\n", status));
-   }
-  }
+ for (i = 1; i <= MLX4_MAX_PORTS; i++) {
+        if (mlx4_is_enabled_port(mdev, i)) {
+            if(mlx4_is_eth_port(mdev, i)) {
+                status = __create_child(Device, ETH_HARDWARE_IDS,
ETH_HARDWARE_DESCRIPTION, i);
+                if (!NT_SUCCESS(status)) {
+                     MLX4_PRINT_EV(TRACE_LEVEL_ERROR, MLX4_DBG_DRV,
("__create_child (eth) failed with 0x%x\n", status));
+                     break;
+                }
+                eth_created = TRUE;
+            } else {
+                if (eth_created){
+                    //
+                    // Illegal configuration the IB should be the first
port
+                    //
+                    status = STATUS_INVALID_PARAMETER;
+                    MLX4_PRINT_EV(TRACE_LEVEL_ERROR, MLX4_DBG_DRV,
("__create_child (IB) failed. Invalid configuration, IB should be the
first port."));
+                    break;                    
+                }
+                
+                if (ib_created){
+                    continue;
+                }
+
+                status = __create_child(Device, BUS_HARDWARE_IDS,
BUS_HARDWARE_DESCRIPTION, 0 );
+                if (!NT_SUCCESS(status)) {
+                     MLX4_PRINT_EV(TRACE_LEVEL_ERROR, MLX4_DBG_DRV,
("__create_child (ib)failed with 0x%x\n", status));
+                     break;
+                }
+                ib_created = TRUE;
+            }
+        }
  }
 
  p_fdo->children_created = TRUE;

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20091115/1a3a0b22/attachment.html>


More information about the ofw mailing list