Skip to content

Commit

Permalink
netdev-offload: Use per packet tunnel metadata restore flag.
Browse files Browse the repository at this point in the history
DPDK now provides a per packet flag that indicates if a call to the
optional (yet potentially heavy) call to rte_flow_restore_tunnel_info()
is necessary.
Using it, there is no need to discover if a driver supports this feature.

Signed-off-by: David Marchand <[email protected]>
  • Loading branch information
david-marchand committed Sep 26, 2023
1 parent e3a3fa2 commit 4abca5d
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 29 deletions.
15 changes: 5 additions & 10 deletions lib/dpif-netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -8207,16 +8207,11 @@ dp_netdev_hw_flow(const struct dp_netdev_pmd_thread *pmd,
#ifdef ALLOW_EXPERIMENTAL_API /* Packet restoration API required. */
/* Restore the packet if HW processing was terminated before completion. */
struct dp_netdev_rxq *rxq = pmd->ctx.last_rxq;
bool miss_api_supported;

atomic_read_relaxed(&rxq->port->netdev->hw_info.miss_api_supported,
&miss_api_supported);
if (miss_api_supported) {
int err = netdev_hw_miss_packet_recover(rxq->port->netdev, packet);
if (err && err != EOPNOTSUPP) {
COVERAGE_INC(datapath_drop_hw_miss_recover);
return -1;
}
int err = netdev_hw_miss_packet_recover(rxq->port->netdev, packet);

if (err && err != EOPNOTSUPP) {
COVERAGE_INC(datapath_drop_hw_miss_recover);
return -1;
}
#endif

Expand Down
4 changes: 4 additions & 0 deletions lib/netdev-dpdk.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ typedef uint16_t dpdk_port_t;
| RTE_ETH_TX_OFFLOAD_UDP_CKSUM \
| RTE_ETH_TX_OFFLOAD_IPV4_CKSUM)

uint64_t netdev_dpdk_restore_info_flag;

static const struct rte_eth_conf port_conf = {
.rxmode = {
Expand Down Expand Up @@ -1251,6 +1252,9 @@ dpdk_eth_dev_init_rx_metadata(struct netdev_dpdk *dev)
if (!(rx_metadata & RTE_ETH_RX_METADATA_TUNNEL_ID)) {
VLOG_DBG("%s: The NIC will not provide per-packet TUNNEL_ID",
netdev_get_name(&dev->up));
} else if (!netdev_dpdk_restore_info_flag) {
atomic_store_relaxed(&netdev_dpdk_restore_info_flag,
rte_flow_restore_info_dynflag());
}
#endif /* ALLOW_EXPERIMENTAL_API */
} else {
Expand Down
4 changes: 4 additions & 0 deletions lib/netdev-dpdk.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ set_error(struct rte_flow_error *error, enum rte_flow_error_type type)
error->message = NULL;
}

/* Flag indicating that a call to rte_flow_get_restore_info() is necessary. */
extern uint64_t netdev_dpdk_restore_info_flag;

#ifdef ALLOW_EXPERIMENTAL_API

int netdev_dpdk_rte_flow_tunnel_decap_set(struct netdev *,
Expand All @@ -75,6 +78,7 @@ int netdev_dpdk_rte_flow_tunnel_match(struct netdev *,
struct rte_flow_item **,
uint32_t *num_of_items,
struct rte_flow_error *);

int netdev_dpdk_rte_flow_get_restore_info(struct netdev *,
struct dp_packet *,
struct rte_flow_restore_info *,
Expand Down
6 changes: 6 additions & 0 deletions lib/netdev-offload-dpdk.c
Original file line number Diff line number Diff line change
Expand Up @@ -2630,11 +2630,17 @@ netdev_offload_dpdk_hw_miss_packet_recover(struct netdev *netdev,
struct rte_flow_restore_info rte_restore_info;
struct rte_flow_tunnel *rte_tnl;
struct netdev *vport_netdev;
uint64_t need_restore_info;
struct pkt_metadata *md;
struct flow_tnl *md_tnl;
odp_port_t vport_odp;
int ret = 0;

atomic_read_relaxed(&netdev_dpdk_restore_info_flag, &need_restore_info);
if (!(packet->mbuf.ol_flags & need_restore_info)) {
return 0;
}

ret = netdev_dpdk_rte_flow_get_restore_info(netdev, packet,
&rte_restore_info, NULL);
if (ret) {
Expand Down
18 changes: 1 addition & 17 deletions lib/netdev-offload.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ netdev_assign_flow_api(struct netdev *netdev)
CMAP_FOR_EACH (rfa, cmap_node, &netdev_flow_apis) {
if (!rfa->flow_api->init_flow_api(netdev)) {
ovs_refcount_ref(&rfa->refcnt);
atomic_store_relaxed(&netdev->hw_info.miss_api_supported, true);
ovsrcu_set(&netdev->flow_api, rfa->flow_api);
VLOG_INFO("%s: Assigned flow API '%s'.",
netdev_get_name(netdev), rfa->flow_api->type);
Expand All @@ -192,7 +191,6 @@ netdev_assign_flow_api(struct netdev *netdev)
VLOG_DBG("%s: flow API '%s' is not suitable.",
netdev_get_name(netdev), rfa->flow_api->type);
}
atomic_store_relaxed(&netdev->hw_info.miss_api_supported, false);
VLOG_INFO("%s: No suitable flow API found.", netdev_get_name(netdev));

return -1;
Expand Down Expand Up @@ -325,27 +323,13 @@ netdev_hw_miss_packet_recover(struct netdev *netdev,
struct dp_packet *packet)
{
const struct netdev_flow_api *flow_api;
bool miss_api_supported;
int rv;

atomic_read_relaxed(&netdev->hw_info.miss_api_supported,
&miss_api_supported);
if (!miss_api_supported) {
return EOPNOTSUPP;
}

flow_api = ovsrcu_get(const struct netdev_flow_api *, &netdev->flow_api);
if (!flow_api || !flow_api->hw_miss_packet_recover) {
return EOPNOTSUPP;
}

rv = flow_api->hw_miss_packet_recover(netdev, packet);
if (rv == EOPNOTSUPP) {
/* API unsupported by the port; avoid subsequent calls. */
atomic_store_relaxed(&netdev->hw_info.miss_api_supported, false);
}

return rv;
return flow_api->hw_miss_packet_recover(netdev, packet);
}

int
Expand Down
1 change: 0 additions & 1 deletion lib/netdev-offload.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ struct ovs_action_push_tnl;
/* Offload-capable (HW) netdev information */
struct netdev_hw_info {
bool oor; /* Out of Offload Resources ? */
atomic_bool miss_api_supported; /* hw_miss_packet_recover() supported.*/
int offload_count; /* Pending (non-offloaded) flow count */
int pending_count; /* Offloaded flow count */
OVSRCU_TYPE(void *) offload_data; /* Offload metadata. */
Expand Down
1 change: 0 additions & 1 deletion lib/netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,6 @@ netdev_open(const char *name, const char *type, struct netdev **netdevp)
seq_read(netdev->reconfigure_seq);
ovsrcu_set(&netdev->flow_api, NULL);
netdev->hw_info.oor = false;
atomic_init(&netdev->hw_info.miss_api_supported, false);
netdev->node = shash_add(&netdev_shash, name, netdev);

/* By default enable one tx and rx queue per netdev. */
Expand Down

0 comments on commit 4abca5d

Please sign in to comment.