User Manual
Driver FeaturesRev 2.2-1.0.1
Mellanox Technologies
98
For example:
struct ibv_exp_device_attr attr;
ibv_exp_query_device(context, &attr);
if (attr.comp_mask & IBV_EXP_DEVICE_ATTR_WITH_TIMESTAMP_MASK) {
if (attr.timestamp_mask) {
/* Time stamping is supported with mask attr.timestamp_mask */
}
}
if (attr.comp_mask & IBV_EXP_DEVICE_ATTR_WITH_HCA_CORE_CLOCK) {
if (attr.hca_core_clock) {
/* reporting the device's clock is supported. */
/* attr.hca_core_clock is the frequency in MHZ */
}
}
4.7.2.2 Creating Time Stamping Completion Queue
To get time stamps, a suitable extended Completion Queue (CQ) must be created via a special
call to
ibv_exp_create_cq verb.
cq_init_attr.flags = IBV_EXP_CQ_TIMESTAMP;
cq_init_attr.comp_mask = IBV_EXP_CQ_INIT_ATTR_FLAGS;
cq = ibv_exp_create_cq(context, cqe, node, NULL, 0, &cq_init_attr);
This CQ cannot report SL or SLID information. The value of sl and sl_id fields in
struct ibv_exp_wc are invalid. Only the fields indicated by the exp_wc_flags field
in struct ibv_exp_wc contains a valid and usable value.
When using Time Stamping, several fields of struct ibv_exp_wc are not available
resulting in RoCE UD / RoCE traffic with VLANs failure.
4.7.2.3 Polling a Completion Queue
Polling a CQ for time stamp is done via the
ibv_exp_poll_cq verb.
ret = ibv_exp_poll_cq(cq, 1, &wc_ex, sizeof(wc_ex));
if (ret > 0) {
/* CQ returned a wc */
if (wc_ex.exp_wc_flags & IBV_EXP_WC_WITH_TIMESTAMP) {
/* This wc contains a timestamp */
timestamp = wc_ex.timestamp;
/* Timestamp is given in raw hardware time */
}
}
CQs that are opened with the ibv_exp_create_cq verbs should be always be polled
with the ibv_exp_poll_cq verb.