Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 85 additions & 5 deletions userspace/dpdk/ena/base/ena_com.c
Original file line number Diff line number Diff line change
Expand Up @@ -420,11 +420,16 @@ static int ena_com_init_io_cq(struct ena_com_dev *ena_dev,

memset(&io_cq->cdesc_addr, 0x0, sizeof(io_cq->cdesc_addr));

/* Use the basic completion descriptor for Rx */
io_cq->cdesc_entry_size_in_bytes =
(io_cq->direction == ENA_COM_IO_QUEUE_DIRECTION_TX) ?
sizeof(struct ena_eth_io_tx_cdesc) :
sizeof(struct ena_eth_io_rx_cdesc_base);
if (ctx->use_extended_cdesc)
io_cq->cdesc_entry_size_in_bytes =
(io_cq->direction == ENA_COM_IO_QUEUE_DIRECTION_TX) ?
sizeof(struct ena_eth_io_tx_cdesc_ext) :
sizeof(struct ena_eth_io_rx_cdesc_ext);
else
io_cq->cdesc_entry_size_in_bytes =
(io_cq->direction == ENA_COM_IO_QUEUE_DIRECTION_TX) ?
sizeof(struct ena_eth_io_tx_cdesc) :
sizeof(struct ena_eth_io_rx_cdesc_base);

size = io_cq->cdesc_entry_size_in_bytes * io_cq->q_depth;
io_cq->bus = ena_dev->bus;
Expand Down Expand Up @@ -2007,6 +2012,81 @@ int ena_com_phc_get_error_bound(struct ena_com_dev *ena_dev, u32 *error_bound)
return ENA_COM_OK;
}

bool ena_com_hw_timestamping_supported(struct ena_com_dev *ena_dev)
{
return ena_com_check_supported_feature_id(ena_dev,
ENA_ADMIN_HW_TIMESTAMP);
}

int ena_com_get_hw_timestamping_support(struct ena_com_dev *ena_dev,
uint8_t *tx_support,
uint8_t *rx_support)
{
struct ena_admin_get_feat_resp get_resp;
int ret;

*tx_support = ENA_ADMIN_HW_TIMESTAMP_TX_SUPPORT_NONE;
*rx_support = ENA_ADMIN_HW_TIMESTAMP_RX_SUPPORT_NONE;

if (!ena_com_hw_timestamping_supported(ena_dev)) {
ena_trc_dbg(ena_dev, "HW timestamping is not supported\n");
return ENA_COM_UNSUPPORTED;
}

ret = ena_com_get_feature(ena_dev,
&get_resp,
ENA_ADMIN_HW_TIMESTAMP,
ENA_ADMIN_HW_TIMESTAMP_FEATURE_VERSION_1);
if (unlikely(ret)) {
ena_trc_err(ena_dev,
"Failed to get HW timestamp configuration, error: %d\n",
ret);
return ret;
}

*tx_support = get_resp.u.hw_ts.tx;
*rx_support = get_resp.u.hw_ts.rx;

return 0;
}

int ena_com_set_hw_timestamping_configuration(struct ena_com_dev *ena_dev,
uint8_t tx_enable,
uint8_t rx_enable)
{
struct ena_admin_set_feat_resp resp;
struct ena_admin_set_feat_cmd cmd;
int ret;

if (!ena_com_hw_timestamping_supported(ena_dev)) {
ena_trc_dbg(ena_dev, "HW timestamping is not supported\n");
return ENA_COM_UNSUPPORTED;
}

memset(&cmd, 0x0, sizeof(cmd));

cmd.aq_common_descriptor.opcode = ENA_ADMIN_SET_FEATURE;
cmd.feat_common.feature_id = ENA_ADMIN_HW_TIMESTAMP;
cmd.u.hw_ts.tx = tx_enable ? ENA_ADMIN_HW_TIMESTAMP_TX_SUPPORT_ALL :
ENA_ADMIN_HW_TIMESTAMP_TX_SUPPORT_NONE;
cmd.u.hw_ts.rx = rx_enable ? ENA_ADMIN_HW_TIMESTAMP_RX_SUPPORT_ALL :
ENA_ADMIN_HW_TIMESTAMP_RX_SUPPORT_NONE;

ret = ena_com_execute_admin_command(&ena_dev->admin_queue,
(struct ena_admin_aq_entry *)&cmd,
sizeof(cmd),
(struct ena_admin_acq_entry *)&resp,
sizeof(resp));
if (unlikely(ret)) {
ena_trc_err(ena_dev,
"Failed to set HW timestamping configuration, error: %d\n",
ret);
return ret;
}

return 0;
}

int ena_com_mmio_reg_read_request_init(struct ena_com_dev *ena_dev)
{
struct ena_com_mmio_read *mmio_read = &ena_dev->mmio_read;
Expand Down
30 changes: 30 additions & 0 deletions userspace/dpdk/ena/base/ena_com.h
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,9 @@ struct ena_com_dev {
struct ena_com_mmio_read mmio_read;
struct ena_com_phc_info phc;

bool use_extended_tx_cdesc;
bool use_extended_rx_cdesc;

struct ena_rss rss;
u32 supported_features;
u32 capabilities;
Expand Down Expand Up @@ -421,6 +424,7 @@ struct ena_com_create_io_ctx {
u32 msix_vector;
u16 queue_size;
u16 qid;
bool use_extended_cdesc;
};

typedef void (*ena_aenq_handler)(void *data,
Expand Down Expand Up @@ -490,6 +494,32 @@ int ena_com_phc_get_timestamp(struct ena_com_dev *ena_dev, u64 *timestamp);
*/
int ena_com_phc_get_error_bound(struct ena_com_dev *ena_dev, u32 *error_bound);

/* ena_com_hw_timestamping_supported - Check if HW timestamping is supported
* @ena_dev: ENA communication layer struct
* @return - true if supported
*/
bool ena_com_hw_timestamping_supported(struct ena_com_dev *ena_dev);

/* ena_com_get_hw_timestamping_support - Query HW timestamp TX/RX support
* @ena_dev: ENA communication layer struct
* @tx_support: returned TX support level
* @rx_support: returned RX support level
* @return - 0 on success, negative value on failure
*/
int ena_com_get_hw_timestamping_support(struct ena_com_dev *ena_dev,
uint8_t *tx_support,
uint8_t *rx_support);

/* ena_com_set_hw_timestamping_configuration - Enable/disable HW timestamps
* @ena_dev: ENA communication layer struct
* @tx_enable: enable TX timestamps
* @rx_enable: enable RX timestamps
* @return - 0 on success, negative value on failure
*/
int ena_com_set_hw_timestamping_configuration(struct ena_com_dev *ena_dev,
uint8_t tx_enable,
uint8_t rx_enable);

/* ena_com_set_mmio_read_mode - Enable/disable the indirect mmio reg read mechanism
* @ena_dev: ENA communication layer struct
* @readless_supported: readless mode (enable/disable)
Expand Down
26 changes: 26 additions & 0 deletions userspace/dpdk/ena/base/ena_defs/ena_admin_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ enum ena_admin_aq_feature_id {
ENA_ADMIN_LINK_CONFIG = 27,
ENA_ADMIN_HOST_ATTR_CONFIG = 28,
ENA_ADMIN_PHC_CONFIG = 29,
ENA_ADMIN_HW_TIMESTAMP = 31,
ENA_ADMIN_FEATURES_OPCODE_NUM = 32,
};

Expand Down Expand Up @@ -155,6 +156,20 @@ enum ena_admin_phc_error_flags {
ENA_ADMIN_PHC_ERROR_FLAG_ERROR_BOUND = BIT(1),
};

enum ena_admin_hw_timestamp_feature_version {
ENA_ADMIN_HW_TIMESTAMP_FEATURE_VERSION_1 = 1,
};

enum ena_admin_hw_timestamp_tx_support {
ENA_ADMIN_HW_TIMESTAMP_TX_SUPPORT_NONE = 0,
ENA_ADMIN_HW_TIMESTAMP_TX_SUPPORT_ALL = 1,
};

enum ena_admin_hw_timestamp_rx_support {
ENA_ADMIN_HW_TIMESTAMP_RX_SUPPORT_NONE = 0,
ENA_ADMIN_HW_TIMESTAMP_RX_SUPPORT_ALL = 1,
};

/* ENA SRD configuration for ENI */
enum ena_admin_ena_srd_flags {
/* Feature enabled */
Expand Down Expand Up @@ -1106,6 +1121,12 @@ struct ena_admin_feature_phc_desc {
uint32_t output_length;
};

struct ena_admin_feature_hw_ts_desc {
uint8_t version;
uint8_t tx;
uint8_t rx;
};

struct ena_admin_get_feat_resp {
struct ena_admin_acq_common_desc acq_common_desc;

Expand Down Expand Up @@ -1138,6 +1159,8 @@ struct ena_admin_get_feat_resp {

struct ena_admin_feature_phc_desc phc;

struct ena_admin_feature_hw_ts_desc hw_ts;

struct ena_admin_get_extra_properties_strings_desc extra_properties_strings;

struct ena_admin_get_extra_properties_flags_desc extra_properties_flags;
Expand Down Expand Up @@ -1177,6 +1200,9 @@ struct ena_admin_set_feat_cmd {

/* PHC configuration */
struct ena_admin_feature_phc_desc phc;

/* HW timestamp configuration */
struct ena_admin_feature_hw_ts_desc hw_ts;
} u;
};

Expand Down
12 changes: 10 additions & 2 deletions userspace/dpdk/ena/base/ena_defs/ena_eth_io_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,14 @@ struct ena_eth_io_tx_cdesc {
uint16_t sq_head_idx;
};

struct ena_eth_io_tx_cdesc_ext {
struct ena_eth_io_tx_cdesc base;

uint32_t timestamp_low;

uint32_t timestamp_high;
};

struct ena_eth_io_rx_desc {
/* In bytes. 0 means 64KB */
uint16_t length;
Expand Down Expand Up @@ -255,9 +263,9 @@ struct ena_eth_io_rx_cdesc_ext {

uint16_t reserved16;

uint32_t reserved_w6;
uint32_t timestamp_low;

uint32_t reserved_w7;
uint32_t timestamp_high;
};

struct ena_eth_io_intr_reg {
Expand Down
8 changes: 8 additions & 0 deletions userspace/dpdk/ena/base/ena_eth_com.c
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,14 @@ int ena_com_rx_pkt(struct ena_com_io_cq *io_cq,
/* Get rx flags from the last pkt */
ena_com_rx_set_flags(ena_rx_ctx, cdesc);

if (ena_com_is_extended_rx_cdesc(io_cq)) {
struct ena_eth_io_rx_cdesc_ext *ext =
(struct ena_eth_io_rx_cdesc_ext *)cdesc;
ena_rx_ctx->timestamp = (u64)ext->timestamp_low |
((u64)ext->timestamp_high << 32);
ena_rx_ctx->has_timestamp = true;
}

ena_trc_dbg(ena_com_io_cq_to_ena_dev(io_cq),
"l3_proto %d l4_proto %d l3_csum_err %d l4_csum_err %d hash %d frag %d cdesc_status %x\n",
ena_rx_ctx->l3_proto,
Expand Down
14 changes: 14 additions & 0 deletions userspace/dpdk/ena/base/ena_eth_com.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,22 @@ struct ena_com_rx_ctx {
u16 descs;
u16 max_bufs;
u8 pkt_offset;
bool has_timestamp;
u64 timestamp;
};

static inline bool ena_com_is_extended_rx_cdesc(struct ena_com_io_cq *io_cq)
{
return io_cq->cdesc_entry_size_in_bytes ==
sizeof(struct ena_eth_io_rx_cdesc_ext);
}

static inline bool ena_com_is_extended_tx_cdesc(struct ena_com_io_cq *io_cq)
{
return io_cq->cdesc_entry_size_in_bytes ==
sizeof(struct ena_eth_io_tx_cdesc_ext);
}

int ena_com_prepare_tx(struct ena_com_io_sq *io_sq,
struct ena_com_tx_ctx *ena_tx_ctx,
int *nb_hw_desc);
Expand Down
Loading