[MLX4] 1) added support for sending large multi-parameter messages to System Event...
authorleonidk <leonidk@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 13 Jul 2009 18:24:01 +0000 (18:24 +0000)
committerleonidk <leonidk@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 13 Jul 2009 18:24:01 +0000 (18:24 +0000)
2) improved the wording of several most popular messages.

To print to Event Log, one has to use the new function WriteEventLogEntryData().

git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@2291 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

hw/mlx4/kernel/bus/core/ev_log.mc
hw/mlx4/kernel/bus/core/l2w_debug.c
hw/mlx4/kernel/bus/drv/drv.c
hw/mlx4/kernel/bus/net/main.c
hw/mlx4/kernel/inc/l2w.h
hw/mlx4/kernel/inc/l2w_debug.h

index 7eb7f3a..a00094a 100644 (file)
@@ -48,9 +48,88 @@ MessageId=0x0002 Facility=MLX4 Severity=Warning SymbolicName=EVENT_MLX4_ANY_WARN
 Language=English\r
 %2\r
 .\r
-\r
 MessageId=0x0003 Facility=MLX4 Severity=Error SymbolicName=EVENT_MLX4_ANY_ERROR\r
 Language=English\r
 %2\r
 .\r
 \r
+MessageId=0x0004 Facility=MLX4 Severity=Error SymbolicName=EVENT_MLX4_ERROR_LIFEFISH_OK\r
+Language=English\r
+mlx4_bus has started in non-operational mode. \r
+.\r
+\r
+MessageId=0x0005 Facility=MLX4 Severity=Error SymbolicName=EVENT_MLX4_ERROR_LIFEFISH_FAIL\r
+Language=English\r
+mlx4_bus has failed to start even in non-operational mode.%n\r
+Look into the the previous error messages.\r
+.\r
+\r
+MessageId=0x0006 Facility=MLX4 Severity=Informational SymbolicName=EVENT_MLX4_INFO_DEV_STARTED\r
+Language=English\r
+mlx4_bus has been successfully started.%n\r
+The device parameters are:%n\r
+   vendor_id      %t%2%n\r
+   device_id      %t%3%n\r
+   subvendor_id   %t%4%n\r
+   subsystem_id   %t%5%n\r
+   HW revision    %t%6%n\r
+   FW version     %t%7.%8.%9%n\r
+   HCA guid       %t%10%11%n\r
+   HCA location   %t'%12'\r
+.\r
+\r
+MessageId=0x0007 Facility=MLX4 Severity=Error SymbolicName=EVENT_MLX4_ERROR_MAP_FA\r
+Language=English\r
+MAP_FA command failed with error %2.%n \r
+The adapter card is non-functional.%n\r
+Most likely a FW problem.%n\r
+Please burn the last FW and restart the mlx4_bus driver.\r
+.\r
+\r
+MessageId=0x0008 Facility=MLX4 Severity=Error SymbolicName=EVENT_MLX4_ERROR_RUN_FW\r
+Language=English\r
+RUN_FW command failed with error %2.%n\r
+The adapter card is non-functional.%n\r
+Most likely a FW problem.%n\r
+Please burn the last FW and restart the mlx4_bus driver.\r
+.\r
+\r
+MessageId=0x0009 Facility=MLX4 Severity=Error SymbolicName=EVENT_MLX4_ERROR_QUERY_FW\r
+Language=English\r
+QUERY_FW command failed with error %2.%n\r
+The adapter card is non-functional.%n\r
+Most likely a FW problem.%n\r
+Please burn the last FW and restart the mlx4_bus driver.\r
+.\r
+\r
+MessageId=0x000a Facility=MLX4 Severity=Warning SymbolicName=EVENT_MLX4_WARN_QUERY_FW\r
+Language=English\r
+Function disabled.%n\r
+This device is multi-functional.%n\r
+Please upgrade to a multi-function driver.\r
+.\r
+\r
+MessageId=0x000b Facility=MLX4 Severity=Error SymbolicName=EVENT_MLX4_ERROR_QUERY_DEV_CAP\r
+Language=English\r
+QUERY_DEV_CAP command failed with error %2.%n\r
+The adapter card is non-functional.%n\r
+Most likely a FW problem.%n\r
+Please burn the last FW and restart the mlx4_bus driver.\r
+.\r
+\r
+MessageId=0x000c Facility=MLX4 Severity=Error SymbolicName=EVENT_MLX4_ERROR_QUERY_ADAPTER\r
+Language=English\r
+QUERY_ADAPTER command failed with error %2.%n\r
+The adapter card is non-functional.%n\r
+Most likely a FW problem.%n\r
+Please burn the last FW and restart the mlx4_bus driver.\r
+.\r
+\r
+MessageId=0x000d Facility=MLX4 Severity=Error SymbolicName=EVENT_MLX4_ERROR_NOT_ENOUGH_QPS\r
+Language=English\r
+Too few QPs were requested (requested %2, reserved for FW %3).%n\r
+The adapter card is non-functional.%n\r
+Please increase the Registry LogNumQp parameter under HKLM\System\CurrentControlSet\Services\mlx4_bus\Parameters.\r
+.\r
+\r
+\r
index 3780b26..02c66dd 100644 (file)
@@ -3,6 +3,12 @@
 
 #define MAX_BUFFER_SIZE                256
 
+/* 
+ * This function sends to Event Log messages with one WCHAR string and several binary parameters.
+ * The string will be inserted instead of %2 parameter of the message.
+ * Binary parameters will be shown in Dump Area of the message.
+ * Binary parameters should be of type LONG.
+ */
 VOID
 WriteEventLogEntryStr(
        PVOID   pi_pIoObject,
@@ -112,6 +118,172 @@ Return Value:
 
 } /* WriteEventLogEntry */
 
+/* 
+ * This function sends to Event Log messages with various parameters.
+ * Every parameter should be coded as a pair: a format specifier and the value.
+ * 'pi_nDataItems' presents the number of the pairs.
+ *
+ * Here is an example:
+ *
+ * To print a message (from MC file) like:
+ *
+ *             MessageId=0x0006 Facility=MLX4 Severity=Informational SymbolicName=EVENT_MLX4_INFO_TEST
+ *             Language=English
+ *             some_long %2, some_short %3, some_byte %4, some_wide_char_str %5, some_ansii_str %6
+ *
+ * you have to code:
+ *
+ *             WriteEventLogEntryData( pdev->p_self_do, (ULONG)EVENT_MLX4_INFO_TEST, 0, 0, 5,
+ *                     L"%d", long_int,                                                        // LONG
+ *                     L"%04x", (ULONG)short_int,                                      // SHORT
+ *                     L"%02x", (ULONG)byte_int,                                       // CHAR
+ *                     L"%s", wide_char_str,                                           // PWCHAR
+ *                     L"%S", ansii_str                                                        // PCHAR
+ *             );
+ */
+VOID
+WriteEventLogEntryData(
+       PVOID   pi_pIoObject,
+       ULONG   pi_ErrorCode,
+       ULONG   pi_UniqueErrorCode,
+       ULONG   pi_FinalStatus,
+       ULONG   pi_nDataItems,
+       ...
+       )
+/*++
+
+Routine Description:
+    Writes an event log entry to the event log.
+
+Arguments:
+
+       pi_pIoObject......... The IO object ( driver object or device object ).
+       pi_ErrorCode......... The error code.
+       pi_UniqueErrorCode... A specific error code.
+       pi_FinalStatus....... The final status.
+       pi_nDataItems........ Number of data items (i.e. pairs of data parameters).
+       .
+       . data items values
+       .
+
+Return Value:
+
+       None .
+
+--*/
+{ /* WriteEventLogEntryData */
+
+       /* Variable argument list */    
+       va_list                                 l_Argptr;
+       /* Pointer to an error log entry */
+       PIO_ERROR_LOG_PACKET    l_pErrorLogEntry; 
+       /* sizeof insertion string */
+       int     l_Size = 0;     
+       /* temp buffer */
+       UCHAR l_Buf[ERROR_LOG_MAXIMUM_SIZE - 2];
+       /* position in buffer */
+       UCHAR * l_Ptr = l_Buf;
+       /* Data item index */
+       USHORT l_nDataItem ;
+       /* total packet size */
+       int l_TotalSize;
+
+       if (pi_pIoObject == NULL) {
+               ASSERT(pi_pIoObject != NULL);
+               return;
+       }
+
+       /* Init the variable argument list */   
+       va_start(l_Argptr, pi_nDataItems);
+
+       /* Create the insertion strings Insert the data items */
+       memset( l_Buf, 0, sizeof(l_Buf) );
+       for (l_nDataItem = 0; l_nDataItem < pi_nDataItems; l_nDataItem++) 
+       { 
+               NTSTATUS status;
+               /* Current binary data item */
+               int l_CurDataItem ;
+               /* Current pointer data item */
+               void* l_CurPtrDataItem ;
+               /* format specifier */
+               WCHAR* l_FormatStr;
+               /* the rest of the buffer */
+               int l_BufSize = (int)(l_Buf + sizeof(l_Buf)- l_Ptr);
+               /* size of insertion string */
+               size_t l_StrSize;
+
+               /* print as much as we can */
+               if ( l_BufSize < 4 )
+                       break;
+               
+               /* Get format specifier */
+               l_FormatStr = va_arg( l_Argptr, PWCHAR);
+       
+               /* Get next data item */
+               if ( !wcscmp( l_FormatStr, L"%s" ) || !wcscmp( l_FormatStr, L"%S" ) ) {
+                       l_CurPtrDataItem = va_arg( l_Argptr, PWCHAR);
+                       /* convert to string */ 
+                       status = RtlStringCchPrintfW( (NTSTRSAFE_PWSTR)l_Ptr, l_BufSize>>1, l_FormatStr , l_CurPtrDataItem );
+               }
+               else {
+                       l_CurDataItem = va_arg( l_Argptr, int);
+                       /* convert to string */ 
+                       status = RtlStringCchPrintfW( (NTSTRSAFE_PWSTR)l_Ptr, l_BufSize>>1, l_FormatStr , l_CurDataItem );
+               }
+
+               if (!NT_SUCCESS(status))
+                       return;
+
+               /* prepare the next loop */
+               status = RtlStringCbLengthW( (NTSTRSAFE_PWSTR)l_Ptr, l_BufSize, &l_StrSize );
+               if (!NT_SUCCESS(status))
+                       return;
+               *(WCHAR*)&l_Ptr[l_StrSize] = (WCHAR)0;
+               l_StrSize += 2;
+               l_Size = l_Size + (int)l_StrSize;
+               l_Ptr = l_Buf + l_Size;
+               l_BufSize = (int)(l_Buf + sizeof(l_Buf)- l_Ptr);
+       
+       } /* Inset a data item */
+
+       /* Term the variable argument list */   
+       va_end(l_Argptr);
+
+       /* Allocate an error log entry */ 
+       l_TotalSize =sizeof(IO_ERROR_LOG_PACKET) +l_Size;
+       if (l_TotalSize >= ERROR_LOG_MAXIMUM_SIZE - 2) {
+               l_TotalSize = ERROR_LOG_MAXIMUM_SIZE - 2;
+               l_Size = l_TotalSize - sizeof(IO_ERROR_LOG_PACKET);
+       }
+       l_pErrorLogEntry = (PIO_ERROR_LOG_PACKET)IoAllocateErrorLogEntry(
+               pi_pIoObject,  (UCHAR)l_TotalSize );
+
+       /* Check allocation */
+       if ( l_pErrorLogEntry != NULL) 
+       { /* OK */
+
+               /* Set the error log entry header */
+               l_pErrorLogEntry->ErrorCode                     = pi_ErrorCode; 
+               l_pErrorLogEntry->DumpDataSize          = 0; 
+               l_pErrorLogEntry->SequenceNumber        = 0; 
+               l_pErrorLogEntry->MajorFunctionCode = 0; 
+               l_pErrorLogEntry->IoControlCode         = 0; 
+               l_pErrorLogEntry->RetryCount            = 0; 
+               l_pErrorLogEntry->UniqueErrorValue      = pi_UniqueErrorCode; 
+               l_pErrorLogEntry->FinalStatus           = pi_FinalStatus; 
+               l_pErrorLogEntry->NumberOfStrings = l_nDataItem;
+               l_pErrorLogEntry->StringOffset = sizeof(IO_ERROR_LOG_PACKET) + l_pErrorLogEntry->DumpDataSize;
+               l_Ptr = (UCHAR*)l_pErrorLogEntry + l_pErrorLogEntry->StringOffset;
+               if ( l_Size )
+                       memcpy( l_Ptr, l_Buf, l_Size );
+
+               /* Write the packet */
+               IoWriteErrorLogEntry(l_pErrorLogEntry);
+
+       } /* OK */
+
+} /* WriteEventLogEntry */
+
 // bsize is to be a strlen(src)
 // dest has to have enough place, i.e at least (2*strlen(src) + 2)
 void __ansi_to_wchar( USHORT *dest, UCHAR *src, int bsize)
index f88b2d1..a4ca954 100644 (file)
@@ -430,6 +430,8 @@ EvtDeviceD0Entry(
        PFDO_DEVICE_DATA p_fdo  = FdoGetData(Device);\r
        struct pci_dev *pdev    = &p_fdo->pci_dev;\r
        struct mlx4_dev *mdev;\r
+       struct ib_device_attr props;\r
+       struct ib_device *p_ibdev;\r
 \r
        MLX4_ENTER(MLX4_DBG_DRV);\r
 \r
@@ -450,7 +452,7 @@ EvtDeviceD0Entry(
                }\r
 \r
        // Log Success Message\r
-       MLX4_PRINT_EV(TRACE_LEVEL_INFORMATION ,MLX4_DBG_DRV ,\r
+       MLX4_PRINT(TRACE_LEVEL_INFORMATION ,MLX4_DBG_DRV ,\r
                ("Ven %x Dev %d Fw %d.%d.%d, IsBurnDevice %s\n", \r
                (unsigned)pdev->ven_id, (unsigned)pdev->dev_id,\r
                (int) (mdev->caps.fw_ver >> 32),\r
@@ -458,6 +460,24 @@ EvtDeviceD0Entry(
                (int) (mdev->caps.fw_ver & 0xffff),\r
                mlx4_is_livefish(mdev) ? "Y" : "N"\r
                ));\r
+       if (!mlx4_is_livefish(mdev)) {\r
+               memset ( &props, 0, sizeof( props) );\r
+               p_ibdev = pdev->ib_dev;\r
+               (p_ibdev->query_device)( p_ibdev, &props );\r
+               WriteEventLogEntryData( pdev->p_self_do, (ULONG)EVENT_MLX4_INFO_DEV_STARTED, 0, 0, 11,\r
+                       L"%04x", (ULONG)pdev->ven_id, \r
+                       L"%04x", (ULONG)pdev->dev_id,\r
+                       L"%04x", (ULONG)pdev->sub_vendor_id,\r
+                       L"%04x", (ULONG)pdev->sub_system_id,\r
+                       L"%02x", (ULONG)pdev->revision_id,\r
+                       L"%d", (int) (mdev->caps.fw_ver >> 32),\r
+                       L"%d", (int) (mdev->caps.fw_ver >> 16) & 0xffff, \r
+                       L"%d", (int) (mdev->caps.fw_ver & 0xffff),\r
+                       L"%08x", *(PULONG)((PUCHAR)&p_ibdev->node_guid + 0), \r
+                       L"%08x", *(PULONG)((PUCHAR)&p_ibdev->node_guid + 4), \r
+                       L"%s", pdev->location\r
+                       ); \r
+       }\r
 \r
 err:\r
        MLX4_EXIT( MLX4_DBG_DRV );\r
@@ -728,6 +748,7 @@ __get_resources(
        pdev->dev_id = pdev->pci_cfg_space.DeviceID;\r
        pdev->sub_vendor_id = pdev->pci_cfg_space.u.type0.SubVendorID;\r
        pdev->sub_system_id = pdev->pci_cfg_space.u.type0.SubSystemID;\r
+       pdev->revision_id = pdev->pci_cfg_space.RevisionID;\r
        pdev->p_self_do = WdfDeviceWdmGetDeviceObject(p_fdo->FdoDevice);\r
        pdev->pdo = WdfDeviceWdmGetPhysicalDevice(p_fdo->FdoDevice);\r
        \r
index f8782fe..61215ee 100644 (file)
@@ -239,6 +239,7 @@ static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap)
        dev->caps.log_num_vlans = ilog2(roundup_pow_of_two
                                        (g.mod_num_vlan + 2));
        dev->caps.log_num_prios = (g.mod_use_prio)? 3: 0;
+       dev->caps.num_fc_exch = g.mod_num_fc_exch;
 
        err = mlx4_check_port_params(dev, port_type);
        if (err)
@@ -292,7 +293,7 @@ static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap)
                (1 << dev->caps.log_num_vlans)*
                (1 << dev->caps.log_num_prios)*
                num_eth_ports;
-       dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FC_EXCH] = MLX4_NUM_FEXCH;
+       dev->caps.reserved_qps_cnt[MLX4_QP_REGION_FC_EXCH] = dev->caps.num_fc_exch;
 
        return 0;
 }
@@ -311,13 +312,17 @@ static int __devinit mlx4_load_fw(struct mlx4_dev *dev)
 
        err = mlx4_MAP_FA(dev, priv->fw.fw_icm);
        if (err) {
-               mlx4_err(dev, "MAP_FA command failed, aborting.\n");
+               mlx4_dbg(dev, "MAP_FA command failed, aborting.\n");
+               WriteEventLogEntryData( dev->pdev->p_self_do, (ULONG)EVENT_MLX4_ERROR_MAP_FA, 0, 0, 1,
+                       L"%d", err );
                goto err_free;
        }
 
        err = mlx4_RUN_FW(dev);
        if (err) {
-               mlx4_err(dev, "RUN_FW command failed, aborting.\n");
+               mlx4_dbg(dev, "RUN_FW command failed, aborting.\n");
+               WriteEventLogEntryData( dev->pdev->p_self_do, (ULONG)EVENT_MLX4_ERROR_RUN_FW, 0, 0, 1,
+                       L"%d", err );
                goto err_unmap_fa;
        }
 
@@ -638,23 +643,30 @@ static int mlx4_init_hca(struct mlx4_dev *dev)
        if (err) {
                if (err == -EACCES) {
                        static int print_it = 1;
-                       if (print_it-- > 0)
-                               mlx4_warn(dev, "Function disabled, please upgrade to multi function driver.\n");
+                       if (print_it-- > 0) {
+                               mlx4_info(dev, "Function disabled, please upgrade to multi function driver.\n");
+                               WriteEventLogEntryData( dev->pdev->p_self_do, (ULONG)EVENT_MLX4_WARN_QUERY_FW, 0, 0, 0 );
+                       }
+               }
+               else {
+                       mlx4_dbg(dev, "QUERY_FW command failed, aborting.\n");
+                       WriteEventLogEntryData( dev->pdev->p_self_do, (ULONG)EVENT_MLX4_ERROR_QUERY_FW, 0, 0, 1,
+                               L"%d", err );
                }
-               else
-                       mlx4_err(dev, "QUERY_FW command failed, aborting.\n");
                return err;
        }
 
        err = mlx4_load_fw(dev);
        if (err) {
-               mlx4_err(dev, "Failed to start FW, aborting.\n");
+               mlx4_dbg(dev, "Failed to start FW, aborting.\n");
                return err;
        }
 
        err = mlx4_dev_cap(dev, &dev_cap);
        if (err) {
-               mlx4_err(dev, "QUERY_DEV_CAP command failed, aborting.\n");
+               mlx4_dbg(dev, "QUERY_DEV_CAP command failed, aborting.\n");
+               WriteEventLogEntryData( dev->pdev->p_self_do, (ULONG)EVENT_MLX4_ERROR_QUERY_DEV_CAP, 0, 0, 1,
+                       L"%d", err );
                goto err_stop_fw;
        }
 
@@ -682,6 +694,8 @@ static int mlx4_init_hca(struct mlx4_dev *dev)
        err = mlx4_QUERY_ADAPTER(dev, &adapter);
        if (err) {
                mlx4_err(dev, "QUERY_ADAPTER command failed, aborting.\n");
+               WriteEventLogEntryData( dev->pdev->p_self_do, (ULONG)EVENT_MLX4_ERROR_QUERY_ADAPTER, 0, 0, 1,
+                       L"%d", err );
                goto err_close;
        }
 
@@ -964,12 +978,16 @@ run_as_livefish:
                if (err) {
                        MLX4_PRINT(TRACE_LEVEL_INFORMATION ,MLX4_DBG_LOW ,
                                ("mlx4_register_device for livefish failed, return with error.\n"));
+                       WriteEventLogEntryData( pdev->p_self_do, (ULONG)EVENT_MLX4_ERROR_LIFEFISH_FAIL, 
+                               0, errno_to_ntstatus(err), 0 ); 
                        pdev->dev = NULL;
                        kfree(priv);
                } 
                else {
                MLX4_PRINT(TRACE_LEVEL_ERROR ,MLX4_DBG_LOW ,
                        ("MLX4_BUS started in \"livefish\" mode !!!.\n"));
+                       WriteEventLogEntryData( pdev->p_self_do, (ULONG)EVENT_MLX4_ERROR_LIFEFISH_OK, 
+                               0, errno_to_ntstatus(err), 0 ); 
                }
                goto end;
        }
index 57f8b34..c437887 100644 (file)
@@ -172,6 +172,7 @@ struct pci_dev
        USHORT                                                  dev_id;
        USHORT                                                  sub_vendor_id;
        USHORT                                                  sub_system_id;
+       UCHAR                                                   revision_id;
        DMA_ADAPTER             *                               p_dma_adapter;  /* HCA adapter object */
        DEVICE_OBJECT   *                               p_self_do;              /* mlx4_bus's FDO */
        DEVICE_OBJECT   *                               pdo;                    /* mlx4_bus's PDO */
index 022f28a..896643e 100644 (file)
@@ -11,6 +11,16 @@ WriteEventLogEntryStr(
        ...
        );
 
+VOID
+WriteEventLogEntryData(
+       PVOID   pi_pIoObject,
+       ULONG   pi_ErrorCode,
+       ULONG   pi_UniqueErrorCode,
+       ULONG   pi_FinalStatus,
+       ULONG   pi_nDataItems,
+       ...
+       );
+
 void
 mlx4_err(
        IN struct mlx4_dev *    mdev,