forked from Minki/linux
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: Eran Ben Elisha <eranbe@mellanox.com> Signed-off-by: Matan Barak <matanb@mellanox.com> Reviewed-by: Or Gerlitz <ogerlitz@mellanox.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
This commit is contained in:
parent
b41f7852f3
commit
c3c0c83667
@ -817,17 +817,39 @@ 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 =
|
||||
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,
|
||||
@ -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) {
|
||||
case 0:
|
||||
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;
|
||||
break;
|
||||
default:
|
||||
@ -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 (mlx4_is_slave(dev->dev) &&
|
||||
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.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_EXT)))
|
||||
return iboe_process_mad(ibdev, mad_flags, port_num, in_wc,
|
||||
in_grh, in_mad, out_mad);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user