2 creating time stamping completion queue, 3 polling a completion queue – Dell Mellanox Family of Adapters User Manual
Page 37

User Manual for Mellanox ConnectX®-3 10/40 Gigabit Ethernet Adapters for Dell PowerEdge Servers
Rev 1.1
Mellanox Technologies
37
For example:
4.2.5.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_create_cq_ex
verb.
4.2.5.3 Polling a Completion Queue
Polling a CQ for time stamp is done via the
ibv_poll_cq_ex
verb.
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 */
}
}
cq_init_attr.flags = IBV_CQ_TIMESTAMP;
cq_init_attr.comp_mask = IBV_CQ_INIT_ATTR_FLAGS;
cq = ibv_create_cq_ex(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_wc_ex
are invalid. Only the fields indicated by the
wc_flags
field in
struct ibv_wc_ex
contains a valid and usable value.
When using Time Stamping, several fields of
struct ibv_wc_ex
are not available
resulting in RoCE UD / RoCE traffic with VLANs failure.
ret = ibv_poll_cq_ex(cq, 1, &wc_ex, sizeof(wc_ex));
if (ret > 0) {
/* CQ returned a wc */
if (wc_ex.wc_flags & IBV_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_create_cq_ex
versb should be always be polled with
the
ibv_poll_cq_ex
verb.