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 acfbad0
Show file tree
Hide file tree
Showing 5 changed files with 14 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
8 changes: 8 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)

static uint64_t netdev_dpdk_restore_info_flag;

static const struct rte_eth_conf port_conf = {
.rxmode = {
Expand Down Expand Up @@ -1251,6 +1252,8 @@ 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) {
netdev_dpdk_restore_info_flag = rte_flow_restore_info_dynflag();
}
#endif /* ALLOW_EXPERIMENTAL_API */
} else {
Expand Down Expand Up @@ -6223,13 +6226,18 @@ netdev_dpdk_rte_flow_get_restore_info(struct netdev *netdev,
struct rte_flow_error *error)
{
struct rte_mbuf *m = (struct rte_mbuf *) p;
uint64_t need_restore_info;
struct netdev_dpdk *dev;
int ret;

if (!is_dpdk_class(netdev->netdev_class)) {
return -1;
}

if (!(p->mbuf.ol_flags & netdev_dpdk_restore_info_flag)) {
return -EOPNOTSUPP;
}

dev = netdev_dpdk_cast(netdev);
ovs_mutex_lock(&dev->mutex);
ret = rte_flow_get_restore_info(dev->port_id, m, info, error);
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 acfbad0

Please sign in to comment.