From 8606100969dc1aafdef36b08fcbdea59afa03a47 Mon Sep 17 00:00:00 2001 From: Vu Pham Date: Fri, 18 May 2012 15:01:29 -0700 Subject: [PATCH] mlx4_core: supporting 64b counters 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 Signed-off-by: Mukesh Kacker Reviewed-by: Ajaykumar Hotchandani --- drivers/infiniband/hw/mlx4/mad.c | 46 ++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c index 9cd2b002d7ae..48017336cc4c 100644 --- a/drivers/infiniband/hw/mlx4/mad.c +++ b/drivers/infiniband/hw/mlx4/mad.c @@ -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: -- 2.50.1