Skip to content
Merged
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
3 changes: 1 addition & 2 deletions include/dp_port.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ struct dp_port_async_template {
enum dp_port_async_template_type {
DP_PORT_ASYNC_TEMPLATE_PF_ISOLATION,
#ifdef ENABLE_VIRTSVC
DP_PORT_ASYNC_TEMPLATE_VIRTSVC_TCP_ISOLATION,
DP_PORT_ASYNC_TEMPLATE_VIRTSVC_UDP_ISOLATION,
DP_PORT_ASYNC_TEMPLATE_VIRTSVC_ISOLATION,
#endif
DP_PORT_ASYNC_TEMPLATE_COUNT,
};
Expand Down
3 changes: 1 addition & 2 deletions include/dp_virtsvc.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ size_t dp_virtsvc_get_count(void);

int dp_install_virtsvc_sync_isolation_rules(uint16_t port_id);
uint16_t dp_create_virtsvc_async_isolation_rules(uint16_t port_id,
struct rte_flow_template_table *tcp_template_table,
struct rte_flow_template_table *udp_template_table);
struct rte_flow_template_table *template_table);
void dp_destroy_virtsvc_async_isolation_rules(uint16_t port_id);

int dp_virtsvc_get_pf_route(struct dp_virtsvc *virtsvc,
Expand Down
5 changes: 2 additions & 3 deletions include/rte_flow/dp_rte_async_flow_isolation.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ int dp_create_pf_async_isolation_templates(struct dp_port *port);
int dp_create_pf_async_isolation_rules(struct dp_port *port);

#ifdef ENABLE_VIRTSVC
int dp_create_virtsvc_async_isolation_templates(struct dp_port *port, uint8_t proto_id);
int dp_create_virtsvc_async_isolation_templates(struct dp_port *port);

struct rte_flow *dp_create_virtsvc_async_isolation_rule(uint16_t port_id, uint8_t proto_id,
const union dp_ipv6 *svc_ipv6, rte_be16_t svc_port,
struct rte_flow *dp_create_virtsvc_async_isolation_rule(uint16_t port_id,
struct rte_flow_template_table *template_table,
const union dp_ipv6 *ul_addr);
#endif
Expand Down
4 changes: 1 addition & 3 deletions include/rte_flow/dp_rte_flow_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,8 @@ static const struct rte_flow_item_ipv6 dp_flow_item_ipv6_dst_mask = {
.hdr.proto = 0xff,
};
#ifdef ENABLE_VIRTSVC
static const struct rte_flow_item_ipv6 dp_flow_item_ipv6_src_dst_mask = {
.hdr.src_addr.a = "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff",
static const struct rte_flow_item_ipv6 dp_flow_item_ipv6_dst_only_mask = {
.hdr.dst_addr.a = "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff",
.hdr.proto = 0xff,
};
#endif

Expand Down
4 changes: 1 addition & 3 deletions src/dp_port.c
Original file line number Diff line number Diff line change
Expand Up @@ -479,9 +479,7 @@ static int dp_port_create_default_pf_async_templates(struct dp_port *port)
return DP_ERROR;
}
#ifdef ENABLE_VIRTSVC
if (DP_FAILED(dp_create_virtsvc_async_isolation_templates(port, IPPROTO_TCP))
|| DP_FAILED(dp_create_virtsvc_async_isolation_templates(port, IPPROTO_UDP))
) {
if (DP_FAILED(dp_create_virtsvc_async_isolation_templates(port))) {
DPS_LOG_ERR("Failed to create virtsvc async isolation templates", DP_LOG_PORT(port));
return DP_ERROR;
}
Expand Down
12 changes: 2 additions & 10 deletions src/dp_virtsvc.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,7 @@ int dp_install_virtsvc_sync_isolation_rules(uint16_t port_id)
}

uint16_t dp_create_virtsvc_async_isolation_rules(uint16_t port_id,
struct rte_flow_template_table *tcp_template_table,
struct rte_flow_template_table *udp_template_table)
struct rte_flow_template_table *template_table)
{
struct rte_flow *flow;
uint16_t rule_count = 0;
Expand All @@ -259,14 +258,7 @@ uint16_t dp_create_virtsvc_async_isolation_rules(uint16_t port_id,
}

DP_FOREACH_VIRTSVC(&dp_virtservices, service) {
flow = dp_create_virtsvc_async_isolation_rule(port_id,
service->proto,
&service->service_addr,
service->service_port,
service->proto == IPPROTO_TCP
? tcp_template_table
: udp_template_table,
&service->ul_addr);
flow = dp_create_virtsvc_async_isolation_rule(port_id, template_table, &service->ul_addr);
if (!flow) {
DPS_LOG_ERR("Cannot create async virtsvc isolation rule", DP_LOG_VIRTSVC(service));
break;
Expand Down
29 changes: 5 additions & 24 deletions src/rte_flow/dp_rte_async_flow_isolation.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,28 +77,22 @@ int dp_create_pf_async_isolation_templates(struct dp_port *port)
}

#ifdef ENABLE_VIRTSVC
int dp_create_virtsvc_async_isolation_templates(struct dp_port *port, uint8_t proto_id)
int dp_create_virtsvc_async_isolation_templates(struct dp_port *port)
{
struct dp_port_async_template *tmpl;

tmpl = dp_alloc_async_template(DP_ISOLATION_PATTERN_COUNT, DP_ISOLATION_ACTIONS_COUNT);
if (!tmpl)
return DP_ERROR;

if (proto_id == IPPROTO_TCP)
port->default_async_rules.default_templates[DP_PORT_ASYNC_TEMPLATE_VIRTSVC_TCP_ISOLATION] = tmpl;
else
port->default_async_rules.default_templates[DP_PORT_ASYNC_TEMPLATE_VIRTSVC_UDP_ISOLATION] = tmpl;
port->default_async_rules.default_templates[DP_PORT_ASYNC_TEMPLATE_VIRTSVC_ISOLATION] = tmpl;

const struct rte_flow_item tcp_src_pattern[] = {
{ .type = RTE_FLOW_ITEM_TYPE_ETH,
.mask = &dp_flow_item_eth_mask,
},
{ .type = RTE_FLOW_ITEM_TYPE_IPV6,
.mask = &dp_flow_item_ipv6_src_dst_mask,
},
{ .type = proto_id == IPPROTO_TCP ? RTE_FLOW_ITEM_TYPE_TCP : RTE_FLOW_ITEM_TYPE_UDP,
.mask = proto_id == IPPROTO_TCP ? (const void *)&dp_flow_item_tcp_src_mask : (const void *)&dp_flow_item_udp_src_mask,
.mask = &dp_flow_item_ipv6_dst_only_mask,
},
{ .type = RTE_FLOW_ITEM_TYPE_END },
};
Expand Down Expand Up @@ -153,35 +147,23 @@ static struct rte_flow *dp_create_pf_async_isolation_rule(uint16_t port_id, uint
}

#ifdef ENABLE_VIRTSVC
struct rte_flow *dp_create_virtsvc_async_isolation_rule(uint16_t port_id, uint8_t proto_id,
const union dp_ipv6 *svc_ipv6, rte_be16_t svc_port,
struct rte_flow *dp_create_virtsvc_async_isolation_rule(uint16_t port_id,
struct rte_flow_template_table *template_table,
const union dp_ipv6 *ul_addr)
{
const struct rte_flow_item_eth eth_spec = {
.hdr.ether_type = htons(RTE_ETHER_TYPE_IPV6),
};
const struct rte_flow_item_ipv6 ipv6_spec = {
.hdr.proto = proto_id,
.hdr.src_addr = svc_ipv6->addr,
.hdr.dst_addr = ul_addr->addr,
};
const struct rte_flow_item_tcp tcp_spec = {
.hdr.src_port = svc_port,
};
const struct rte_flow_item_udp udp_spec = {
.hdr.src_port = svc_port,
};
const struct rte_flow_item pattern[] = {
{ .type = RTE_FLOW_ITEM_TYPE_ETH,
.spec = &eth_spec,
},
{ .type = RTE_FLOW_ITEM_TYPE_IPV6,
.spec = &ipv6_spec,
},
{ .type = proto_id == IPPROTO_TCP ? RTE_FLOW_ITEM_TYPE_TCP : RTE_FLOW_ITEM_TYPE_UDP,
.spec = proto_id == IPPROTO_TCP ? (const void *)&tcp_spec : (const void *)&udp_spec,
},
{ .type = RTE_FLOW_ITEM_TYPE_END },
};

Expand Down Expand Up @@ -231,8 +213,7 @@ int dp_create_pf_async_isolation_rules(struct dp_port *port)
#ifdef ENABLE_VIRTSVC
rules_required += dp_virtsvc_get_count();
rule_count += dp_create_virtsvc_async_isolation_rules(port->port_id,
templates[DP_PORT_ASYNC_TEMPLATE_VIRTSVC_TCP_ISOLATION]->template_table,
templates[DP_PORT_ASYNC_TEMPLATE_VIRTSVC_UDP_ISOLATION]->template_table);
templates[DP_PORT_ASYNC_TEMPLATE_VIRTSVC_ISOLATION]->template_table);
// cannot return, need to push all previous rules and then return error
#endif

Expand Down
Loading