]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mlx4_core: supporting 64b counters
authorVu Pham <vu@mellanox.com>
Fri, 18 May 2012 22:01:29 +0000 (15:01 -0700)
committerMukesh Kacker <mukesh.kacker@oracle.com>
Tue, 7 Jul 2015 21:45:23 +0000 (14:45 -0700)
Support 64b counters using PMA_COUNTERS_EXT mad:
. Sending the mad to fw for IB transport using MAD_IFC
. Sending mailbox command QUERY_IF_STAT to fw for EN transport

Note: Ported from Mellanox OFED 2.4.
     64-bit counters can wrap around. 32-bit counters saturate at UINT_MAX
     (as in upstream code but unlike in Mellanox OFED 2.4 code where they
      can wrap around!)

Orabug: 21094165

Signed-off-by: Vu Pham <vu@mellanox.com>
Signed-off-by: Mukesh Kacker <mukesh.kacker@oracle.com>
Reviewed-by: Ajaykumar Hotchandani <ajaykumar.hotchandani@oracle.com>
drivers/infiniband/hw/mlx4/mad.c

index 9cd2b002d7ae57fb4f33944cbaa14a3e2a27dedd..48017336cc4c717bcd6a66356056f4f2dafc9473 100644 (file)
@@ -811,17 +811,40 @@ static int ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
        return IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY;
 }
 
-static void edit_counter(struct mlx4_counter *cnt,
-                                       struct ib_pma_portcounters *pma_cnt)
+static void edit_counter(struct mlx4_counter *cnt, void *counters,
+                        __be16 attr_id)
 {
-       ASSIGN_32BIT_COUNTER(pma_cnt->port_xmit_data,
-                            (be64_to_cpu(cnt->tx_bytes) >> 2));
-       ASSIGN_32BIT_COUNTER(pma_cnt->port_rcv_data,
-                            (be64_to_cpu(cnt->rx_bytes) >> 2));
-       ASSIGN_32BIT_COUNTER(pma_cnt->port_xmit_packets,
-                            be64_to_cpu(cnt->tx_frames));
-       ASSIGN_32BIT_COUNTER(pma_cnt->port_rcv_packets,
-                            be64_to_cpu(cnt->rx_frames));
+       switch (attr_id) {
+       case IB_PMA_PORT_COUNTERS:
+       {
+               struct ib_pma_portcounters *pma_cnt =
+                               (struct ib_pma_portcounters *) counters;
+
+               ASSIGN_32BIT_COUNTER(pma_cnt->port_xmit_data,
+                                    (be64_to_cpu(cnt->tx_bytes) >> 2));
+               ASSIGN_32BIT_COUNTER(pma_cnt->port_rcv_data,
+                                    (be64_to_cpu(cnt->rx_bytes) >> 2));
+               ASSIGN_32BIT_COUNTER(pma_cnt->port_xmit_packets,
+                                    be64_to_cpu(cnt->tx_frames));
+               ASSIGN_32BIT_COUNTER(pma_cnt->port_rcv_packets,
+                                    be64_to_cpu(cnt->rx_frames));
+               break;
+       }
+       case IB_PMA_PORT_COUNTERS_EXT:
+       {
+               struct ib_pma_portcounters_ext *pma_cnt_ext =
+                               (struct ib_pma_portcounters_ext *) counters;
+
+               pma_cnt_ext->port_xmit_data = cnt->tx_bytes >> 2;
+               pma_cnt_ext->port_rcv_data  = cnt->rx_bytes >> 2;
+               pma_cnt_ext->port_xmit_packets = cnt->tx_frames;
+               pma_cnt_ext->port_rcv_packets  = cnt->rx_frames;
+               break;
+       }
+       default:
+               pr_warn("Unsupported attr_id 0x%x\n", attr_id);
+               break;
+       }
 }
 
 static int iboe_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
@@ -852,7 +875,8 @@ static int iboe_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
                switch (mode & 0xf) {
                case 0:
                        edit_counter(mailbox->buf,
-                                               (void *)(out_mad->data + 40));
+                                    (void *)(out_mad->data + 40),
+                                    in_mad->mad_hdr.attr_id);
                        err = IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY;
                        break;
                default: