2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 06:15:47 +00:00

revalidator: Rebalance offloaded flows based on the pps rate

This is the third patch in the patch-set to support dynamic rebalancing
of offloaded flows.

The dynamic rebalancing functionality is implemented in this patch. The
ukeys that are not scheduled for deletion are obtained and passed as input
to the rebalancing routine. The rebalancing is done in the context of
revalidation leader thread, after all other revalidator threads are
done with gathering rebalancing data for flows.

For each netdev that is in OOR state, a list of flows - both offloaded
and non-offloaded (pending) - is obtained using the ukeys. For each netdev
that is in OOR state, the flows are grouped and sorted into offloaded and
pending flows.  The offloaded flows are sorted in descending order of
pps-rate, while pending flows are sorted in ascending order of pps-rate.

The rebalancing is done in two phases. In the first phase, we try to
offload all pending flows and if that succeeds, the OOR state on the device
is cleared. If some (or none) of the pending flows could not be offloaded,
then we start replacing an offloaded flow that has a lower pps-rate than
a pending flow, until there are no more pending flows with a higher rate
than an offloaded flow. The flows that are replaced from the device are
added into kernel datapath.

A new OVS configuration parameter "offload-rebalance", is added to ovsdb.
The default value of this is "false". To enable this feature, set the
value of this parameter to "true", which provides packets-per-second
rate based policy to dynamically offload and un-offload flows.

Note: This option can be enabled only when 'hw-offload' policy is enabled.
It also requires 'tc-policy' to be set to 'skip_sw'; otherwise, flow
offload errors (specifically ENOSPC error this feature depends on) reported
by an offloaded device are supressed by TC-Flower kernel module.

Signed-off-by: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
Co-authored-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Sathya Perla <sathya.perla@broadcom.com>
Reviewed-by: Ben Pfaff <blp@ovn.org>
Signed-off-by: Simon Horman <simon.horman@netronome.com>
This commit is contained in:
Sriharsha Basavapatna via dev
2018-10-18 21:43:14 +05:30
committed by Simon Horman
parent 6bea85266e
commit 57924fc91c
11 changed files with 591 additions and 29 deletions

View File

@@ -2261,11 +2261,23 @@ netdev_get_block_id(struct netdev *netdev)
int
netdev_get_hw_info(struct netdev *netdev, int type)
{
if (type == HW_INFO_TYPE_OOR) {
return netdev->hw_info.oor;
int val = -1;
switch (type) {
case HW_INFO_TYPE_OOR:
val = netdev->hw_info.oor;
break;
case HW_INFO_TYPE_PEND_COUNT:
val = netdev->hw_info.pending_count;
break;
case HW_INFO_TYPE_OFFL_COUNT:
val = netdev->hw_info.offload_count;
break;
default:
break;
}
return -1;
return val;
}
/*
@@ -2274,11 +2286,49 @@ netdev_get_hw_info(struct netdev *netdev, int type)
void
netdev_set_hw_info(struct netdev *netdev, int type, int val)
{
if (type == HW_INFO_TYPE_OOR) {
switch (type) {
case HW_INFO_TYPE_OOR:
if (val == 0) {
VLOG_DBG("Offload rebalance: netdev: %s is not OOR", netdev->name);
}
netdev->hw_info.oor = val;
break;
case HW_INFO_TYPE_PEND_COUNT:
netdev->hw_info.pending_count = val;
break;
case HW_INFO_TYPE_OFFL_COUNT:
netdev->hw_info.offload_count = val;
break;
default:
break;
}
}
/*
* Find if any netdev is in OOR state. Return true if there's at least
* one netdev that's in OOR state; otherwise return false.
*/
bool
netdev_any_oor(void)
OVS_EXCLUDED(netdev_mutex)
{
struct shash_node *node;
bool oor = false;
ovs_mutex_lock(&netdev_mutex);
SHASH_FOR_EACH (node, &netdev_shash) {
struct netdev *dev = node->data;
if (dev->hw_info.oor) {
oor = true;
break;
}
}
ovs_mutex_unlock(&netdev_mutex);
return oor;
}
bool
netdev_is_flow_api_enabled(void)
{
@@ -2550,6 +2600,10 @@ netdev_set_flow_api_enabled(const struct smap *ovs_other_config)
tc_set_policy(smap_get_def(ovs_other_config, "tc-policy",
TC_POLICY_DEFAULT));
if (smap_get_bool(ovs_other_config, "offload-rebalance", false)) {
netdev_offload_rebalance_policy = true;
}
netdev_ports_flow_init();
ovsthread_once_done(&once);