Commit c3c0c836 authored by Eran Ben Elisha's avatar Eran Ben Elisha Committed by Doug Ledford

IB/mlx4: Add support for extended counters over RoCE ports

When attribute IB_PMA_PORT_COUNTERS_EXT is set, we now return 64 bit
values for the counters.
Signed-off-by: default avatarEran Ben Elisha <eranbe@mellanox.com>
Signed-off-by: default avatarMatan Barak <matanb@mellanox.com>
Reviewed-by: default avatarOr Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent b41f7852
...@@ -817,9 +817,15 @@ static int ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num, ...@@ -817,9 +817,15 @@ static int ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
return IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY; return IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY;
} }
static void edit_counter(struct mlx4_counter *cnt, static void edit_counter(struct mlx4_counter *cnt, void *counters,
struct ib_pma_portcounters *pma_cnt) __be16 attr_id)
{ {
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, ASSIGN_32BIT_COUNTER(pma_cnt->port_xmit_data,
(be64_to_cpu(cnt->tx_bytes) >> 2)); (be64_to_cpu(cnt->tx_bytes) >> 2));
ASSIGN_32BIT_COUNTER(pma_cnt->port_rcv_data, ASSIGN_32BIT_COUNTER(pma_cnt->port_rcv_data,
...@@ -828,6 +834,22 @@ static void edit_counter(struct mlx4_counter *cnt, ...@@ -828,6 +834,22 @@ static void edit_counter(struct mlx4_counter *cnt,
be64_to_cpu(cnt->tx_frames)); be64_to_cpu(cnt->tx_frames));
ASSIGN_32BIT_COUNTER(pma_cnt->port_rcv_packets, ASSIGN_32BIT_COUNTER(pma_cnt->port_rcv_packets,
be64_to_cpu(cnt->rx_frames)); 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 =
cpu_to_be64(be64_to_cpu(cnt->tx_bytes) >> 2);
pma_cnt_ext->port_rcv_data =
cpu_to_be64(be64_to_cpu(cnt->rx_bytes) >> 2);
pma_cnt_ext->port_xmit_packets = cnt->tx_frames;
pma_cnt_ext->port_rcv_packets = cnt->rx_frames;
break;
}
}
} }
static int iboe_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num, static int iboe_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
...@@ -863,7 +885,8 @@ static int iboe_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num, ...@@ -863,7 +885,8 @@ static int iboe_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
switch (counter_stats.counter_mode & 0xf) { switch (counter_stats.counter_mode & 0xf) {
case 0: case 0:
edit_counter(&counter_stats, edit_counter(&counter_stats,
(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; err = IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY;
break; break;
default: default:
...@@ -894,8 +917,9 @@ int mlx4_ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num, ...@@ -894,8 +917,9 @@ int mlx4_ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
*/ */
if (link == IB_LINK_LAYER_INFINIBAND) { if (link == IB_LINK_LAYER_INFINIBAND) {
if (mlx4_is_slave(dev->dev) && if (mlx4_is_slave(dev->dev) &&
in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_PERF_MGMT && (in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_PERF_MGMT &&
in_mad->mad_hdr.attr_id == IB_PMA_PORT_COUNTERS) (in_mad->mad_hdr.attr_id == IB_PMA_PORT_COUNTERS ||
in_mad->mad_hdr.attr_id == IB_PMA_PORT_COUNTERS_EXT)))
return iboe_process_mad(ibdev, mad_flags, port_num, in_wc, return iboe_process_mad(ibdev, mad_flags, port_num, in_wc,
in_grh, in_mad, out_mad); in_grh, in_mad, out_mad);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment