#include "openvswitch/vlog.h"
#include "flow.h"
#include "util.h"
+#ifdef __linux__
+#include "tc.h"
+#endif
VLOG_DEFINE_THIS_MODULE(netdev);
VLOG_INFO("netdev: Flow API Enabled");
+ tc_set_policy(smap_get_def(ovs_other_config, "tc-policy",
+ TC_POLICY_DEFAULT));
+
ovsthread_once_done(&once);
}
}
static struct vlog_rate_limit error_rl = VLOG_RATE_LIMIT_INIT(60, 5);
+enum tc_offload_policy {
+ TC_POLICY_NONE,
+ TC_POLICY_SKIP_SW,
+ TC_POLICY_SKIP_HW
+};
+
+static enum tc_offload_policy tc_policy = TC_POLICY_NONE;
+
struct tcmsg *
tc_make_request(int ifindex, int type, unsigned int flags,
struct ofpbuf *request)
return error;
}
+static int
+tc_get_tc_cls_policy(enum tc_offload_policy policy)
+{
+ if (policy == TC_POLICY_SKIP_HW) {
+ return TCA_CLS_FLAGS_SKIP_HW;
+ } else if (policy == TC_POLICY_SKIP_SW) {
+ return TCA_CLS_FLAGS_SKIP_SW;
+ }
+
+ return 0;
+}
+
static void
nl_msg_put_act_push_vlan(struct ofpbuf *request, uint16_t vid, uint8_t prio)
{
}
}
- nl_msg_put_u32(request, TCA_FLOWER_FLAGS, 0);
+ nl_msg_put_u32(request, TCA_FLOWER_FLAGS, tc_get_tc_cls_policy(tc_policy));
if (flower->tunnel.tunnel) {
nl_msg_put_flower_tunnel(request, flower);
return error;
}
+
+void
+tc_set_policy(const char *policy)
+{
+ if (!policy) {
+ return;
+ }
+
+ if (!strcmp(policy, "skip_sw")) {
+ tc_policy = TC_POLICY_SKIP_SW;
+ } else if (!strcmp(policy, "skip_hw")) {
+ tc_policy = TC_POLICY_SKIP_HW;
+ } else if (!strcmp(policy, "none")) {
+ tc_policy = TC_POLICY_NONE;
+ } else {
+ VLOG_WARN("tc: Invalid policy '%s'", policy);
+ return;
+ }
+
+ VLOG_INFO("tc: Using policy '%s'", policy);
+}
#define TC_INGRESS_PARENT TC_H_MAKE(TC_H_CLSACT, TC_H_MIN_INGRESS)
+#define TC_POLICY_DEFAULT "none"
+
/* Returns tc handle 'major':'minor'. */
static inline unsigned int
tc_make_handle(unsigned int major, unsigned int minor)
int tc_dump_flower_start(int ifindex, struct nl_dump *dump);
int parse_netlink_to_tc_flower(struct ofpbuf *reply,
struct tc_flower *flower);
+void tc_set_policy(const char *policy);
#endif /* tc.h */
</p>
</column>
+ <column name="other_config" key="tc-policy"
+ type='{"type": "string"}'>
+ <p>
+ Specified the policy used with HW offloading.
+ Options:
+ <code>none</code> - Add software rule and offload rule to HW.
+ <code>skip_sw</code> - Offload rule to HW only.
+ <code>skip_hw</code> - Add software rule without offloading rule to HW.
+ </p>
+ <p>
+ This is only relevant if HW offloading is enabled (hw-offload).
+ </p>
+ <p>
+ The default value is <code>none</code>.
+ </p>
+ </column>
+
<column name="other_config" key="dpdk-init"
type='{"type": "boolean"}'>
<p>