Skip to content

Commit

Permalink
process hw installation failure during vf start
Browse files Browse the repository at this point in the history
  • Loading branch information
byteocean committed Sep 11, 2023
1 parent bdab795 commit de1e7aa
Show file tree
Hide file tree
Showing 5 changed files with 141 additions and 129 deletions.
12 changes: 8 additions & 4 deletions include/monitoring/dp_graphtrace_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@ extern "C" {
#endif

enum dp_graphtrace_action {
DP_GRAPHTRACE_ACTION_NULL,
DP_GRAPHTRACE_ACTION_START,
DP_GRAPHTRACE_ACTION_STOP,
DP_GRAPHTRACE_ACTION_ENABLE_HW_CAPTURE,
DP_GRAPHTRACE_ACTION_DISABLE_HW_CAPTURE,
};

enum dp_graphtrace_op_type {
DP_GRAPHTRACE_OP_TYPE_SOFTWARE,
DP_GRAPHTRACE_OP_TYPE_OFFLOAD,
};

enum dp_graphtrace_pkt_type {
DP_GRAPHTRACE_PKT_TYPE_UNKNOWN = 0,
DP_GRAPHTRACE_PKT_TYPE_SOFTWARE,
DP_GRAPHTRACE_PKT_TYPE_OFFLOAD,
};
Expand All @@ -48,6 +49,9 @@ struct dp_graphtrace_pktinfo {

struct dp_graphtrace_mp_request {
uint8_t action;
union {
enum dp_graphtrace_op_type op_type;
} action_params;
};

struct dp_graphtrace_mp_reply {
Expand Down
6 changes: 3 additions & 3 deletions src/dp_cntrack.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ static __rte_always_inline int dp_get_flow_val(struct rte_mbuf *m, struct dp_flo
// flow is the same as it was for the previous packet
*p_flow_val = cached_flow_val;
if (dp_capture_offloaded_pkts(m, *p_flow_val, df))
return DP_IS_CAPTURED_HW_PKT; // it is not really an error, but we need to stop processing this pkt
return DP_IS_CAPTURED_HW_PKT;
dp_set_pkt_flow_direction(curr_key, cached_flow_val, df);
dp_set_flow_offload_flag(m, cached_flow_val, df);
return DP_OK;
Expand All @@ -286,7 +286,7 @@ static __rte_always_inline int dp_get_flow_val(struct rte_mbuf *m, struct dp_flo
}

if (dp_capture_offloaded_pkts(m, *p_flow_val, df))
return DP_IS_CAPTURED_HW_PKT; // it is not really an error, but we need to stop processing this pkt
return DP_IS_CAPTURED_HW_PKT;

// already established flow found
dp_set_pkt_flow_direction(curr_key, *p_flow_val, df);
Expand All @@ -306,7 +306,7 @@ int dp_cntrack_handle(struct rte_node *node, struct rte_mbuf *m, struct dp_flow
DPNODE_LOG_WARNING(node, "Cannot establish flow value", DP_LOG_RET(ret));
return ret;
} else if (ret == DP_IS_CAPTURED_HW_PKT)
return ret;
return ret; // it is not really an error, but we need to stop processing this pkt

flow_val->timestamp = rte_rdtsc();

Expand Down
55 changes: 33 additions & 22 deletions src/dp_port.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,11 +448,40 @@ static int dp_port_fill_info(struct dp_port *port)
return DP_OK;
}

static int dp_install_vf_init_rte_rules(uint32_t port_id)
{
bool graphtrace_enabled = dp_graphtrace_is_enabled();
int ret;

if (graphtrace_enabled)
ret = dp_install_jump_rule_in_default_group(port_id, DP_RTE_FLOW_MONITORING_GROUP);
else
ret = dp_install_jump_rule_in_default_group(port_id, DP_RTE_FLOW_VNET_GROUP);

if (DP_FAILED(ret)) {
DPS_LOG_ERR("Cannot install default jump rule", DP_LOG_PORTID(port_id), DP_LOG_RET(ret));
return DP_ERROR;
}

ret = dp_install_default_rule_in_monitoring_group(port_id);
if (DP_FAILED(ret)) {
DPS_LOG_ERR("Cannot install default rule in monitoring group", DP_LOG_PORTID(port_id), DP_LOG_RET(ret));
return DP_ERROR;
}

ret = dp_install_default_capture_rule_in_vnet_group(port_id);
if (DP_FAILED(ret)) {
DPS_LOG_ERR("Cannot install default capture rule in vnet group", DP_LOG_PORTID(port_id), DP_LOG_RET(ret));
return DP_ERROR;
}

return DP_OK;
}

int dp_port_start(uint16_t port_id)
{
struct dp_port *port;
int ret;
bool graphtrace_enabled = dp_graphtrace_is_enabled();

port = dp_port_get(port_id);
if (!port)
Expand Down Expand Up @@ -486,27 +515,9 @@ int dp_port_start(uint16_t port_id)


if (port->port_type == DP_PORT_VF) {
if (graphtrace_enabled)
ret = dp_install_jump_rule_in_default_group(port_id, DP_RTE_FLOW_MONITORING_GROUP);
else
ret = dp_install_jump_rule_in_default_group(port_id, DP_RTE_FLOW_VNET_GROUP);

if (DP_FAILED(ret)) {
DPS_LOG_ERR("Cannot install default jump rule", DP_LOG_PORTID(port_id), DP_LOG_RET(ret));
return DP_ERROR;
}

ret = dp_install_default_rule_in_monitoring_group(port_id);
if (DP_FAILED(ret)) {
DPS_LOG_ERR("Cannot install default rule in monitoring group", DP_LOG_PORTID(port_id), DP_LOG_RET(ret));
return DP_ERROR;
}

ret = dp_install_default_capture_rule_in_vnet_group(port_id);
if (DP_FAILED(ret)) {
DPS_LOG_ERR("Cannot install default capture rule in vnet group", DP_LOG_PORTID(port_id), DP_LOG_RET(ret));
return DP_ERROR;
}
ret = dp_install_vf_init_rte_rules(port_id);
if (DP_FAILED(ret))
assert(0); // if any flow rule failed, stop process running due to possible hw/driver failure
}
}

Expand Down
100 changes: 70 additions & 30 deletions src/monitoring/dp_graphtrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ static enum dp_graphtrace_loglevel graphtrace_loglevel;

static struct dp_graphtrace graphtrace;
bool _dp_graphtrace_enabled = false;
bool _dp_graphtrace_hw_enabled = false;
static bool offload_enabled;

static int dp_graphtrace_init_memzone(void)
Expand Down Expand Up @@ -54,6 +55,71 @@ static void dp_graphtrace_free_memzone(void)
graphtrace.mempool = NULL;
}

static void dp_graphtrace_set_hw_enabled(bool enabled)
{
_dp_graphtrace_hw_enabled = enabled;
}

static int dp_handle_graphtrace_start(const struct dp_graphtrace_mp_request *request)
{
int ret;

switch ((enum dp_graphtrace_op_type)request->action_params.op_type) {
case DP_GRAPHTRACE_OP_TYPE_SOFTWARE:
dp_graphtrace_enable();
DPS_LOG_INFO("Graphtrace enabled only for software path");
return DP_OK;
case DP_GRAPHTRACE_OP_TYPE_OFFLOAD:
if (offload_enabled) {
ret = dp_send_event_hardware_capture_start_msg();
if (DP_FAILED(ret)) {
DPS_LOG_ERR("Cannot send hardware capture start message");
return ret;
}
dp_graphtrace_enable();
dp_graphtrace_set_hw_enabled(true);
DPS_LOG_INFO("Graphtrace enabled for software and offload paths");
return DP_OK;
} else {
DPS_LOG_ERR("Cannot start hardware capture, offload is not enabled");
return -EPERM;
}
default:
DPS_LOG_ERR("Unknown graphtrace op type", DP_LOG_VALUE(request->action_params.op_type));
return -EINVAL;
}

}

static int dp_handle_graphtrace_stop(const struct dp_graphtrace_mp_request *request)
{
int ret;

switch ((enum dp_graphtrace_op_type)request->action_params.op_type) {
case DP_GRAPHTRACE_OP_TYPE_SOFTWARE:
dp_graphtrace_disable();
DPS_LOG_INFO("Graphtrace disabled only for software path");
return DP_OK;
case DP_GRAPHTRACE_OP_TYPE_OFFLOAD:
if (_dp_graphtrace_hw_enabled) {
dp_graphtrace_disable();
ret = dp_send_event_hardware_capture_stop_msg();
if (DP_FAILED(ret)) {
DPS_LOG_ERR("Cannot send hardware capture stop message");
return ret;
}
dp_graphtrace_set_hw_enabled(false);
DPS_LOG_INFO("Graphtrace disabled for software and offload paths");
return DP_OK;
} else {
DPS_LOG_ERR("Cannot stop hardware capture, offload is not enabled");
return -EPERM;
}
default:
DPS_LOG_ERR("Unknown graphtrace op type", DP_LOG_VALUE(request->action_params.op_type));
return -EINVAL;
}
}

static __rte_always_inline
void dp_handle_graphtrace_request(const struct rte_mp_msg *mp_msg, struct dp_graphtrace_mp_reply *reply)
Expand All @@ -69,39 +135,13 @@ void dp_handle_graphtrace_request(const struct rte_mp_msg *mp_msg, struct dp_gra

switch ((enum dp_graphtrace_action)request->action) {
case DP_GRAPHTRACE_ACTION_START:
dp_graphtrace_enable();
reply->error_code = DP_OK;
DPS_LOG_INFO("Graphtrace enabled");
ret = dp_handle_graphtrace_start(request);
reply->error_code = ret;
return;
case DP_GRAPHTRACE_ACTION_STOP:
dp_graphtrace_disable();
reply->error_code = DP_OK;
DPS_LOG_INFO("Graphtrace disabled");
return;
case DP_GRAPHTRACE_ACTION_ENABLE_HW_CAPTURE:
if (offload_enabled) {
if (DP_FAILED(dp_send_event_hardware_capture_start_msg())) {
DPS_LOG_ERR("Cannot send hardware capture start message");
dp_graphtrace_disable(); // roll back if failed on this side, and error code cannot be sent back
reply->error_code = DP_ERROR;
return;
}
}
reply->error_code = DP_OK;
DPS_LOG_INFO("Hardware capture enabled");
return;
case DP_GRAPHTRACE_ACTION_DISABLE_HW_CAPTURE:
if (offload_enabled) {
if (DP_FAILED(dp_send_event_hardware_capture_stop_msg())) {
DPS_LOG_ERR("Cannot send hardware capture stop message");
reply->error_code = DP_ERROR;
return;
}
}
reply->error_code = DP_OK;
DPS_LOG_INFO("Hardware capture disabled");
ret = dp_handle_graphtrace_stop(request);
reply->error_code = ret;
return;
case DP_GRAPHTRACE_ACTION_NULL:
default:
DPS_LOG_WARNING("Unknown graphtrace request action", DP_LOG_VALUE(request->action));
reply->error_code = -EINVAL;
Expand Down
Loading

0 comments on commit de1e7aa

Please sign in to comment.