|
39 | 39 |
|
40 | 40 | #include <linux/types.h> |
41 | 41 | #include <linux/pci.h> |
| 42 | +#include <rdma/ib_mad.h> |
| 43 | +#include <rdma/ib_pma.h> |
42 | 44 |
|
43 | 45 | #include "roce_hsi.h" |
44 | 46 | #include "qplib_res.h" |
@@ -285,6 +287,96 @@ static void bnxt_re_copy_db_pacing_stats(struct bnxt_re_dev *rdev, |
285 | 287 | readl(rdev->en_dev->bar0 + rdev->pacing.dbr_db_fifo_reg_off); |
286 | 288 | } |
287 | 289 |
|
| 290 | +int bnxt_re_assign_pma_port_ext_counters(struct bnxt_re_dev *rdev, struct ib_mad *out_mad) |
| 291 | +{ |
| 292 | + struct ib_pma_portcounters_ext *pma_cnt_ext; |
| 293 | + struct bnxt_qplib_ext_stat *estat = &rdev->stats.rstat.ext_stat; |
| 294 | + struct ctx_hw_stats *hw_stats = NULL; |
| 295 | + int rc; |
| 296 | + |
| 297 | + hw_stats = rdev->qplib_ctx.stats.dma; |
| 298 | + |
| 299 | + pma_cnt_ext = (struct ib_pma_portcounters_ext *)(out_mad->data + 40); |
| 300 | + if (_is_ext_stats_supported(rdev->dev_attr->dev_cap_flags)) { |
| 301 | + u32 fid = PCI_FUNC(rdev->en_dev->pdev->devfn); |
| 302 | + |
| 303 | + rc = bnxt_qplib_qext_stat(&rdev->rcfw, fid, estat); |
| 304 | + if (rc) |
| 305 | + return rc; |
| 306 | + } |
| 307 | + |
| 308 | + pma_cnt_ext = (struct ib_pma_portcounters_ext *)(out_mad->data + 40); |
| 309 | + if ((bnxt_qplib_is_chip_gen_p5(rdev->chip_ctx) && rdev->is_virtfn) || |
| 310 | + !bnxt_qplib_is_chip_gen_p5(rdev->chip_ctx)) { |
| 311 | + pma_cnt_ext->port_xmit_data = |
| 312 | + cpu_to_be64(le64_to_cpu(hw_stats->tx_ucast_bytes) / 4); |
| 313 | + pma_cnt_ext->port_rcv_data = |
| 314 | + cpu_to_be64(le64_to_cpu(hw_stats->rx_ucast_bytes) / 4); |
| 315 | + pma_cnt_ext->port_xmit_packets = |
| 316 | + cpu_to_be64(le64_to_cpu(hw_stats->tx_ucast_pkts)); |
| 317 | + pma_cnt_ext->port_rcv_packets = |
| 318 | + cpu_to_be64(le64_to_cpu(hw_stats->rx_ucast_pkts)); |
| 319 | + pma_cnt_ext->port_unicast_rcv_packets = |
| 320 | + cpu_to_be64(le64_to_cpu(hw_stats->rx_ucast_pkts)); |
| 321 | + pma_cnt_ext->port_unicast_xmit_packets = |
| 322 | + cpu_to_be64(le64_to_cpu(hw_stats->tx_ucast_pkts)); |
| 323 | + |
| 324 | + } else { |
| 325 | + pma_cnt_ext->port_rcv_packets = cpu_to_be64(estat->rx_roce_good_pkts); |
| 326 | + pma_cnt_ext->port_rcv_data = cpu_to_be64(estat->rx_roce_good_bytes / 4); |
| 327 | + pma_cnt_ext->port_xmit_packets = cpu_to_be64(estat->tx_roce_pkts); |
| 328 | + pma_cnt_ext->port_xmit_data = cpu_to_be64(estat->tx_roce_bytes / 4); |
| 329 | + pma_cnt_ext->port_unicast_rcv_packets = cpu_to_be64(estat->rx_roce_good_pkts); |
| 330 | + pma_cnt_ext->port_unicast_xmit_packets = cpu_to_be64(estat->tx_roce_pkts); |
| 331 | + } |
| 332 | + return 0; |
| 333 | +} |
| 334 | + |
| 335 | +int bnxt_re_assign_pma_port_counters(struct bnxt_re_dev *rdev, struct ib_mad *out_mad) |
| 336 | +{ |
| 337 | + struct bnxt_qplib_ext_stat *estat = &rdev->stats.rstat.ext_stat; |
| 338 | + struct ib_pma_portcounters *pma_cnt; |
| 339 | + struct ctx_hw_stats *hw_stats = NULL; |
| 340 | + int rc; |
| 341 | + |
| 342 | + hw_stats = rdev->qplib_ctx.stats.dma; |
| 343 | + |
| 344 | + pma_cnt = (struct ib_pma_portcounters *)(out_mad->data + 40); |
| 345 | + if (_is_ext_stats_supported(rdev->dev_attr->dev_cap_flags)) { |
| 346 | + u32 fid = PCI_FUNC(rdev->en_dev->pdev->devfn); |
| 347 | + |
| 348 | + rc = bnxt_qplib_qext_stat(&rdev->rcfw, fid, estat); |
| 349 | + if (rc) |
| 350 | + return rc; |
| 351 | + } |
| 352 | + if ((bnxt_qplib_is_chip_gen_p5(rdev->chip_ctx) && rdev->is_virtfn) || |
| 353 | + !bnxt_qplib_is_chip_gen_p5(rdev->chip_ctx)) { |
| 354 | + pma_cnt->port_rcv_packets = |
| 355 | + cpu_to_be32((u32)(le64_to_cpu(hw_stats->rx_ucast_pkts)) & 0xFFFFFFFF); |
| 356 | + pma_cnt->port_rcv_data = |
| 357 | + cpu_to_be32((u32)((le64_to_cpu(hw_stats->rx_ucast_bytes) & |
| 358 | + 0xFFFFFFFF) / 4)); |
| 359 | + pma_cnt->port_xmit_packets = |
| 360 | + cpu_to_be32((u32)(le64_to_cpu(hw_stats->tx_ucast_pkts)) & 0xFFFFFFFF); |
| 361 | + pma_cnt->port_xmit_data = |
| 362 | + cpu_to_be32((u32)((le64_to_cpu(hw_stats->tx_ucast_bytes) |
| 363 | + & 0xFFFFFFFF) / 4)); |
| 364 | + } else { |
| 365 | + pma_cnt->port_rcv_packets = cpu_to_be32(estat->rx_roce_good_pkts); |
| 366 | + pma_cnt->port_rcv_data = cpu_to_be32((estat->rx_roce_good_bytes / 4)); |
| 367 | + pma_cnt->port_xmit_packets = cpu_to_be32(estat->tx_roce_pkts); |
| 368 | + pma_cnt->port_xmit_data = cpu_to_be32((estat->tx_roce_bytes / 4)); |
| 369 | + } |
| 370 | + pma_cnt->port_rcv_constraint_errors = (u8)(le64_to_cpu(hw_stats->rx_discard_pkts) & 0xFF); |
| 371 | + pma_cnt->port_rcv_errors = cpu_to_be16((u16)(le64_to_cpu(hw_stats->rx_error_pkts) |
| 372 | + & 0xFFFF)); |
| 373 | + pma_cnt->port_xmit_constraint_errors = (u8)(le64_to_cpu(hw_stats->tx_error_pkts) & 0xFF); |
| 374 | + pma_cnt->port_xmit_discards = cpu_to_be16((u16)(le64_to_cpu(hw_stats->tx_discard_pkts) |
| 375 | + & 0xFFFF)); |
| 376 | + |
| 377 | + return 0; |
| 378 | +} |
| 379 | + |
288 | 380 | int bnxt_re_ib_get_hw_stats(struct ib_device *ibdev, |
289 | 381 | struct rdma_hw_stats *stats, |
290 | 382 | u32 port, int index) |
|
0 commit comments