Skip to content

Commit b084444

Browse files
Eran Ben Elishadavem330
authored andcommitted
net/mlx5_core: Introduce access function to read internal timer
A preparation step which adds support for reading the hardware internal timer and the hardware timestamping from the CQE. In addition, advertize device_frequency_khz HCA capability. Signed-off-by: Eran Ben Elisha <eranbe@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 34802a4 commit b084444

File tree

4 files changed

+34
-6
lines changed

4 files changed

+34
-6
lines changed

drivers/net/ethernet/mellanox/mlx5/core/main.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,19 @@ int mlx5_core_disable_hca(struct mlx5_core_dev *dev, u16 func_id)
504504
return mlx5_cmd_status_to_err_v2(out);
505505
}
506506

507+
cycle_t mlx5_read_internal_timer(struct mlx5_core_dev *dev)
508+
{
509+
u32 timer_h, timer_h1, timer_l;
510+
511+
timer_h = ioread32be(&dev->iseg->internal_timer_h);
512+
timer_l = ioread32be(&dev->iseg->internal_timer_l);
513+
timer_h1 = ioread32be(&dev->iseg->internal_timer_h);
514+
if (timer_h != timer_h1) /* wrap around */
515+
timer_l = ioread32be(&dev->iseg->internal_timer_l);
516+
517+
return (cycle_t)timer_l | (cycle_t)timer_h1 << 32;
518+
}
519+
507520
static int mlx5_irq_set_affinity_hint(struct mlx5_core_dev *mdev, int i)
508521
{
509522
struct mlx5_priv *priv = &mdev->priv;

drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ int mlx5_core_sriov_configure(struct pci_dev *dev, int num_vfs);
9898
int mlx5_core_enable_hca(struct mlx5_core_dev *dev, u16 func_id);
9999
int mlx5_core_disable_hca(struct mlx5_core_dev *dev, u16 func_id);
100100
int mlx5_wait_for_vf_pages(struct mlx5_core_dev *dev);
101+
cycle_t mlx5_read_internal_timer(struct mlx5_core_dev *dev);
101102

102103
void mlx5e_init(void);
103104
void mlx5e_cleanup(void);

include/linux/mlx5/device.h

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -443,9 +443,12 @@ struct mlx5_init_seg {
443443
__be32 rsvd1[120];
444444
__be32 initializing;
445445
struct health_buffer health;
446-
__be32 rsvd2[884];
446+
__be32 rsvd2[880];
447+
__be32 internal_timer_h;
448+
__be32 internal_timer_l;
449+
__be32 rsrv3[2];
447450
__be32 health_counter;
448-
__be32 rsvd3[1019];
451+
__be32 rsvd4[1019];
449452
__be64 ieee1588_clk;
450453
__be32 ieee1588_clk_type;
451454
__be32 clr_intx;
@@ -601,7 +604,8 @@ struct mlx5_cqe64 {
601604
__be32 imm_inval_pkey;
602605
u8 rsvd40[4];
603606
__be32 byte_cnt;
604-
__be64 timestamp;
607+
__be32 timestamp_h;
608+
__be32 timestamp_l;
605609
__be32 sop_drop_qpn;
606610
__be16 wqe_counter;
607611
u8 signature;
@@ -623,6 +627,16 @@ static inline int cqe_has_vlan(struct mlx5_cqe64 *cqe)
623627
return !!(cqe->l4_hdr_type_etc & 0x1);
624628
}
625629

630+
static inline u64 get_cqe_ts(struct mlx5_cqe64 *cqe)
631+
{
632+
u32 hi, lo;
633+
634+
hi = be32_to_cpu(cqe->timestamp_h);
635+
lo = be32_to_cpu(cqe->timestamp_l);
636+
637+
return (u64)lo | ((u64)hi << 32);
638+
}
639+
626640
enum {
627641
CQE_L4_HDR_TYPE_NONE = 0x0,
628642
CQE_L4_HDR_TYPE_TCP_NO_ACK = 0x1,

include/linux/mlx5/mlx5_ifc.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -829,9 +829,9 @@ struct mlx5_ifc_cmd_hca_cap_bits {
829829
u8 reserved_66[0x8];
830830
u8 log_uar_page_sz[0x10];
831831

832-
u8 reserved_67[0xe0];
833-
834-
u8 reserved_68[0x1f];
832+
u8 reserved_67[0x40];
833+
u8 device_frequency_khz[0x20];
834+
u8 reserved_68[0x5f];
835835
u8 cqe_zip[0x1];
836836

837837
u8 cqe_zip_timeout[0x10];

0 commit comments

Comments
 (0)