qed: Add support for NCSI statistics.
authorSudarsana Reddy Kalluru <sudarsana.kalluru@qlogic.com>
Tue, 16 Aug 2016 14:51:03 +0000 (10:51 -0400)
committerDavid S. Miller <davem@davemloft.net>
Fri, 19 Aug 2016 04:11:45 +0000 (21:11 -0700)
The patch adds driver support for sending the NCSI statistics to the
MFW. This is an asynchronous request from MFW. Upon receiving this, driver
populates the required data and send it to MFW.

Signed-off-by: Sudarsana Reddy Kalluru <sudarsana.kalluru@qlogic.com>
Signed-off-by: Yuval Mintz <Yuval.Mintz@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/qlogic/qed/qed.h
drivers/net/ethernet/qlogic/qed/qed_hsi.h
drivers/net/ethernet/qlogic/qed/qed_l2.h
drivers/net/ethernet/qlogic/qed/qed_main.c
drivers/net/ethernet/qlogic/qed/qed_mcp.c
drivers/net/ethernet/qlogic/qed/qed_mcp.h

index 35e53771533fb31ddd7100b4e7931f6aba70b4f1..d0beb5d10a02304dbb20b87908b1dfe2142a9540 100644 (file)
@@ -42,6 +42,8 @@ enum qed_coalescing_mode {
 
 struct qed_eth_cb_ops;
 struct qed_dev_info;
+union qed_mcp_protocol_stats;
+enum qed_mcp_protocol_type;
 
 /* helpers */
 static inline u32 qed_db_addr(u32 cid, u32 DEMS)
@@ -597,7 +599,9 @@ void qed_link_update(struct qed_hwfn *hwfn);
 u32 qed_unzip_data(struct qed_hwfn *p_hwfn,
                   u32 input_len, u8 *input_buf,
                   u32 max_size, u8 *unzip_buf);
-
+void qed_get_protocol_stats(struct qed_dev *cdev,
+                           enum qed_mcp_protocol_type type,
+                           union qed_mcp_protocol_stats *stats);
 int qed_slowpath_irq_req(struct qed_hwfn *hwfn);
 
 #endif /* _QED_H */
index 6f9d3b831a2a0d545ef44b3dc6247ae5f141f3d0..acf5da39ecb0d835fd1e9e41f65b1922082b52f5 100644 (file)
@@ -7239,6 +7239,12 @@ struct public_drv_mb {
 #define DRV_MSG_CODE_MCP_RESET                 0x00090000
 #define DRV_MSG_CODE_SET_VERSION               0x000f0000
 
+#define DRV_MSG_CODE_GET_STATS                  0x00130000
+#define DRV_MSG_CODE_STATS_TYPE_LAN             1
+#define DRV_MSG_CODE_STATS_TYPE_FCOE            2
+#define DRV_MSG_CODE_STATS_TYPE_ISCSI           3
+#define DRV_MSG_CODE_STATS_TYPE_RDMA            4
+
 #define DRV_MSG_CODE_BIST_TEST                 0x001e0000
 #define DRV_MSG_CODE_SET_LED_MODE              0x00200000
 
@@ -7315,10 +7321,10 @@ enum MFW_DRV_MSG_TYPE {
        MFW_DRV_MSG_RESERVED4,
        MFW_DRV_MSG_BW_UPDATE,
        MFW_DRV_MSG_BW_UPDATE5,
-       MFW_DRV_MSG_BW_UPDATE6,
-       MFW_DRV_MSG_BW_UPDATE7,
-       MFW_DRV_MSG_BW_UPDATE8,
-       MFW_DRV_MSG_BW_UPDATE9,
+       MFW_DRV_MSG_GET_LAN_STATS,
+       MFW_DRV_MSG_GET_FCOE_STATS,
+       MFW_DRV_MSG_GET_ISCSI_STATS,
+       MFW_DRV_MSG_GET_RDMA_STATS,
        MFW_DRV_MSG_BW_UPDATE10,
        MFW_DRV_MSG_TRANSCEIVER_STATE_CHANGE,
        MFW_DRV_MSG_BW_UPDATE11,
index 0021145434511f445c8c973d8df963fe29fc9f35..ff3a198d08d7529b320696bcd3b1bcda71e8f4f4 100644 (file)
@@ -213,6 +213,8 @@ qed_sp_eth_rx_queues_update(struct qed_hwfn *p_hwfn,
                            enum spq_mode comp_mode,
                            struct qed_spq_comp_cb *p_comp_data);
 
+void qed_get_vport_stats(struct qed_dev *cdev, struct qed_eth_stats *stats);
+
 int qed_sp_eth_vport_start(struct qed_hwfn *p_hwfn,
                           struct qed_sp_vport_start_params *p_params);
 
index 54976cc2747d599612e64a4dce53f3e96f93cd4b..32f71ee571918a8d0981c9a659cc34edc966e1fd 100644 (file)
@@ -1402,3 +1402,24 @@ const struct qed_common_ops qed_common_ops_pass = {
        .set_coalesce = &qed_set_coalesce,
        .set_led = &qed_set_led,
 };
+
+void qed_get_protocol_stats(struct qed_dev *cdev,
+                           enum qed_mcp_protocol_type type,
+                           union qed_mcp_protocol_stats *stats)
+{
+       struct qed_eth_stats eth_stats;
+
+       memset(stats, 0, sizeof(*stats));
+
+       switch (type) {
+       case QED_MCP_LAN_STATS:
+               qed_get_vport_stats(cdev, &eth_stats);
+               stats->lan_stats.ucast_rx_pkts = eth_stats.rx_ucast_pkts;
+               stats->lan_stats.ucast_tx_pkts = eth_stats.tx_ucast_pkts;
+               stats->lan_stats.fcs_err = -1;
+               break;
+       default:
+               DP_ERR(cdev, "Invalid protocol type = %d\n", type);
+               return;
+       }
+}
index 88b448bb2949234fd3273b662b165ec15477bb70..b07bc810af92419c947dc5b57f96e1e8a59a756e 100644 (file)
@@ -713,6 +713,48 @@ int qed_mcp_set_link(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt, bool b_up)
        return 0;
 }
 
+static void qed_mcp_send_protocol_stats(struct qed_hwfn *p_hwfn,
+                                       struct qed_ptt *p_ptt,
+                                       enum MFW_DRV_MSG_TYPE type)
+{
+       enum qed_mcp_protocol_type stats_type;
+       union qed_mcp_protocol_stats stats;
+       struct qed_mcp_mb_params mb_params;
+       union drv_union_data union_data;
+       u32 hsi_param;
+
+       switch (type) {
+       case MFW_DRV_MSG_GET_LAN_STATS:
+               stats_type = QED_MCP_LAN_STATS;
+               hsi_param = DRV_MSG_CODE_STATS_TYPE_LAN;
+               break;
+       case MFW_DRV_MSG_GET_FCOE_STATS:
+               stats_type = QED_MCP_FCOE_STATS;
+               hsi_param = DRV_MSG_CODE_STATS_TYPE_FCOE;
+               break;
+       case MFW_DRV_MSG_GET_ISCSI_STATS:
+               stats_type = QED_MCP_ISCSI_STATS;
+               hsi_param = DRV_MSG_CODE_STATS_TYPE_ISCSI;
+               break;
+       case MFW_DRV_MSG_GET_RDMA_STATS:
+               stats_type = QED_MCP_RDMA_STATS;
+               hsi_param = DRV_MSG_CODE_STATS_TYPE_RDMA;
+               break;
+       default:
+               DP_NOTICE(p_hwfn, "Invalid protocol type %d\n", type);
+               return;
+       }
+
+       qed_get_protocol_stats(p_hwfn->cdev, stats_type, &stats);
+
+       memset(&mb_params, 0, sizeof(mb_params));
+       mb_params.cmd = DRV_MSG_CODE_GET_STATS;
+       mb_params.param = hsi_param;
+       memcpy(&union_data, &stats, sizeof(stats));
+       mb_params.p_data_src = &union_data;
+       qed_mcp_cmd_and_union(p_hwfn, p_ptt, &mb_params);
+}
+
 static void qed_read_pf_bandwidth(struct qed_hwfn *p_hwfn,
                                  struct public_func *p_shmem_info)
 {
@@ -854,6 +896,12 @@ int qed_mcp_handle_events(struct qed_hwfn *p_hwfn,
                case MFW_DRV_MSG_TRANSCEIVER_STATE_CHANGE:
                        qed_mcp_handle_transceiver_change(p_hwfn, p_ptt);
                        break;
+               case MFW_DRV_MSG_GET_LAN_STATS:
+               case MFW_DRV_MSG_GET_FCOE_STATS:
+               case MFW_DRV_MSG_GET_ISCSI_STATS:
+               case MFW_DRV_MSG_GET_RDMA_STATS:
+                       qed_mcp_send_protocol_stats(p_hwfn, p_ptt, i);
+                       break;
                case MFW_DRV_MSG_BW_UPDATE:
                        qed_mcp_update_bw(p_hwfn, p_ptt);
                        break;
index 013d1b92ed63e6a2783868f2cd1ae9f41cc465c6..3324ef06f35817716e4857493d6a22ad1242cd1f 100644 (file)
@@ -106,6 +106,47 @@ struct qed_mcp_drv_version {
        u8      name[MCP_DRV_VER_STR_SIZE - 4];
 };
 
+struct qed_mcp_lan_stats {
+       u64 ucast_rx_pkts;
+       u64 ucast_tx_pkts;
+       u32 fcs_err;
+};
+
+struct qed_mcp_fcoe_stats {
+       u64 rx_pkts;
+       u64 tx_pkts;
+       u32 fcs_err;
+       u32 login_failure;
+};
+
+struct qed_mcp_iscsi_stats {
+       u64 rx_pdus;
+       u64 tx_pdus;
+       u64 rx_bytes;
+       u64 tx_bytes;
+};
+
+struct qed_mcp_rdma_stats {
+       u64 rx_pkts;
+       u64 tx_pkts;
+       u64 rx_bytes;
+       u64 tx_byts;
+};
+
+enum qed_mcp_protocol_type {
+       QED_MCP_LAN_STATS,
+       QED_MCP_FCOE_STATS,
+       QED_MCP_ISCSI_STATS,
+       QED_MCP_RDMA_STATS
+};
+
+union qed_mcp_protocol_stats {
+       struct qed_mcp_lan_stats lan_stats;
+       struct qed_mcp_fcoe_stats fcoe_stats;
+       struct qed_mcp_iscsi_stats iscsi_stats;
+       struct qed_mcp_rdma_stats rdma_stats;
+};
+
 /**
  * @brief - returns the link params of the hw function
  *