diff options
Diffstat (limited to 'drivers/infiniband/hw/mlx4/mad.c')
-rw-r--r-- | drivers/infiniband/hw/mlx4/mad.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c index c7619716c31d..59040265e361 100644 --- a/drivers/infiniband/hw/mlx4/mad.c +++ b/drivers/infiniband/hw/mlx4/mad.c | |||
@@ -64,6 +64,14 @@ enum { | |||
64 | #define GUID_TBL_BLK_NUM_ENTRIES 8 | 64 | #define GUID_TBL_BLK_NUM_ENTRIES 8 |
65 | #define GUID_TBL_BLK_SIZE (GUID_TBL_ENTRY_SIZE * GUID_TBL_BLK_NUM_ENTRIES) | 65 | #define GUID_TBL_BLK_SIZE (GUID_TBL_ENTRY_SIZE * GUID_TBL_BLK_NUM_ENTRIES) |
66 | 66 | ||
67 | /* Counters should be saturate once they reach their maximum value */ | ||
68 | #define ASSIGN_32BIT_COUNTER(counter, value) do {\ | ||
69 | if ((value) > U32_MAX) \ | ||
70 | counter = cpu_to_be32(U32_MAX); \ | ||
71 | else \ | ||
72 | counter = cpu_to_be32(value); \ | ||
73 | } while (0) | ||
74 | |||
67 | struct mlx4_mad_rcv_buf { | 75 | struct mlx4_mad_rcv_buf { |
68 | struct ib_grh grh; | 76 | struct ib_grh grh; |
69 | u8 payload[256]; | 77 | u8 payload[256]; |
@@ -806,10 +814,14 @@ static int ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num, | |||
806 | static void edit_counter(struct mlx4_counter *cnt, | 814 | static void edit_counter(struct mlx4_counter *cnt, |
807 | struct ib_pma_portcounters *pma_cnt) | 815 | struct ib_pma_portcounters *pma_cnt) |
808 | { | 816 | { |
809 | pma_cnt->port_xmit_data = cpu_to_be32((be64_to_cpu(cnt->tx_bytes)>>2)); | 817 | ASSIGN_32BIT_COUNTER(pma_cnt->port_xmit_data, |
810 | pma_cnt->port_rcv_data = cpu_to_be32((be64_to_cpu(cnt->rx_bytes)>>2)); | 818 | (be64_to_cpu(cnt->tx_bytes) >> 2)); |
811 | pma_cnt->port_xmit_packets = cpu_to_be32(be64_to_cpu(cnt->tx_frames)); | 819 | ASSIGN_32BIT_COUNTER(pma_cnt->port_rcv_data, |
812 | pma_cnt->port_rcv_packets = cpu_to_be32(be64_to_cpu(cnt->rx_frames)); | 820 | (be64_to_cpu(cnt->rx_bytes) >> 2)); |
821 | ASSIGN_32BIT_COUNTER(pma_cnt->port_xmit_packets, | ||
822 | be64_to_cpu(cnt->tx_frames)); | ||
823 | ASSIGN_32BIT_COUNTER(pma_cnt->port_rcv_packets, | ||
824 | be64_to_cpu(cnt->rx_frames)); | ||
813 | } | 825 | } |
814 | 826 | ||
815 | static int iboe_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num, | 827 | static int iboe_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num, |