qed: Provide iSCSI statistics to management
authorMintz, Yuval <Yuval.Mintz@cavium.com>
Thu, 6 Apr 2017 12:58:34 +0000 (15:58 +0300)
committerDavid S. Miller <davem@davemloft.net>
Thu, 6 Apr 2017 21:26:31 +0000 (14:26 -0700)
Management firmware can query for some basic iSCSI-related statistics.
Provide those just as we do for other protocols.

Signed-off-by: Yuval Mintz <Yuval.Mintz@cavium.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/qlogic/qed/qed_iscsi.c
drivers/net/ethernet/qlogic/qed/qed_iscsi.h
drivers/net/ethernet/qlogic/qed/qed_main.c

index 417691cf4fd6eee8988982517eaf940255211f72..339c91dfa658e700a570ba55408c9c1a4a445fb6 100644 (file)
@@ -1324,6 +1324,26 @@ static int qed_iscsi_stats(struct qed_dev *cdev, struct qed_iscsi_stats *stats)
        return qed_iscsi_get_stats(QED_LEADING_HWFN(cdev), stats);
 }
 
+void qed_get_protocol_stats_iscsi(struct qed_dev *cdev,
+                                 struct qed_mcp_iscsi_stats *stats)
+{
+       struct qed_iscsi_stats proto_stats;
+
+       /* Retrieve FW statistics */
+       memset(&proto_stats, 0, sizeof(proto_stats));
+       if (qed_iscsi_stats(cdev, &proto_stats)) {
+               DP_VERBOSE(cdev, QED_MSG_STORAGE,
+                          "Failed to collect ISCSI statistics\n");
+               return;
+       }
+
+       /* Translate FW statistics into struct */
+       stats->rx_pdus = proto_stats.iscsi_rx_total_pdu_cnt;
+       stats->tx_pdus = proto_stats.iscsi_tx_total_pdu_cnt;
+       stats->rx_bytes = proto_stats.iscsi_rx_bytes_cnt;
+       stats->tx_bytes = proto_stats.iscsi_tx_bytes_cnt;
+}
+
 static const struct qed_iscsi_ops qed_iscsi_ops_pass = {
        .common = &qed_common_ops_pass,
        .ll2 = &qed_ll2_ops_pass,
index 20c187f4ed0b8aa8ff2125633f81aa19a1ca546b..ae98f772cbc0e0b3542d693252aaa0c066cde864 100644 (file)
@@ -64,13 +64,25 @@ void qed_iscsi_setup(struct qed_hwfn *p_hwfn,
 
 void qed_iscsi_free(struct qed_hwfn *p_hwfn,
                    struct qed_iscsi_info *p_iscsi_info);
+
+/**
+ * @brief - Fills provided statistics struct with statistics.
+ *
+ * @param cdev
+ * @param stats - points to struct that will be filled with statistics.
+ */
+void qed_get_protocol_stats_iscsi(struct qed_dev *cdev,
+                                 struct qed_mcp_iscsi_stats *stats);
 #else /* IS_ENABLED(CONFIG_QED_ISCSI) */
 static inline struct qed_iscsi_info *qed_iscsi_alloc(
                struct qed_hwfn *p_hwfn) { return NULL; }
 static inline void qed_iscsi_setup(struct qed_hwfn *p_hwfn,
                                   struct qed_iscsi_info *p_iscsi_info) {}
 static inline void qed_iscsi_free(struct qed_hwfn *p_hwfn,
-                                 struct qed_iscsi_info *p_iscsi_info) {}
+                                struct qed_iscsi_info *p_iscsi_info) {}
+static inline void
+qed_get_protocol_stats_iscsi(struct qed_dev *cdev,
+                            struct qed_mcp_iscsi_stats *stats) {}
 #endif /* IS_ENABLED(CONFIG_QED_ISCSI) */
 
 #endif
index aab89ded3aa4be3d8da56900d5dc1b6e85b934aa..029f431e89ecaa01343c8b4ae523f64ec38fffde 100644 (file)
@@ -55,6 +55,8 @@
 #include "qed_dev_api.h"
 #include "qed_ll2.h"
 #include "qed_fcoe.h"
+#include "qed_iscsi.h"
+
 #include "qed_mcp.h"
 #include "qed_hw.h"
 #include "qed_selftest.h"
@@ -1679,6 +1681,9 @@ void qed_get_protocol_stats(struct qed_dev *cdev,
        case QED_MCP_FCOE_STATS:
                qed_get_protocol_stats_fcoe(cdev, &stats->fcoe_stats);
                break;
+       case QED_MCP_ISCSI_STATS:
+               qed_get_protocol_stats_iscsi(cdev, &stats->iscsi_stats);
+               break;
        default:
                DP_ERR(cdev, "Invalid protocol type = %d\n", type);
                return;