diff mbox series

[ovs-dev,58/62] netdev-offload-dpdk: Add offload mod_tos actions

Message ID 20201228092520.11807-59-taoyunxiang@cmss.chinamobile.com
State Not Applicable
Headers show
Series DPDK Offload API to test | expand

Commit Message

Tao YunXiang Dec. 28, 2020, 9:25 a.m. UTC
From: Taoyunxiang <taoyunxiang@cmss.chinamobile.com>

Code Source From: Self Code
Description:
netdev-offload-dpdk: Add offload mod_tos actions

Jira:  #[Optional]
市场项目编号(名称):[Optional]
---
 lib/netdev-offload-dpdk.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c
index bef2349..3ee4f33 100644
--- a/lib/netdev-offload-dpdk.c
+++ b/lib/netdev-offload-dpdk.c
@@ -647,6 +647,15 @@  dump_flow_action(struct ds *s, const struct rte_flow_action *actions)
         } else {
             ds_put_cstr(s, "  Set-ttl = null\n");
         }
+    } else if (actions->type == RTE_FLOW_ACTION_TYPE_SET_IP_TOS) {
+        const struct rte_flow_action_set_iptos *set_tos = actions->conf;
+
+        ds_put_cstr(s, "rte flow set-tos action:\n");
+        if (set_tos) {
+            ds_put_format(s, "  Set-tos: 0x%02x\n", set_tos->ip_tos);
+        } else {
+            ds_put_cstr(s, "  Set-tos = null\n");
+        }
     } else if (actions->type == RTE_FLOW_ACTION_TYPE_SET_TP_SRC ||
                actions->type == RTE_FLOW_ACTION_TYPE_SET_TP_DST) {
         const struct rte_flow_action_set_tp *set_tp = actions->conf;
@@ -1354,7 +1363,8 @@  add_set_flow_action__(struct flow_actions *actions,
         if (is_all_zeros(mask, size)) {
             return 0;
         }
-        if (!is_all_ones(mask, size)) {
+        if (!is_all_ones(mask, size) &&
+            (attr != RTE_FLOW_ACTION_TYPE_SET_IP_TOS )) {
             VLOG_DBG_RL(&rl, "Partial mask is not supported");
             return -1;
         }
@@ -1377,6 +1387,8 @@  BUILD_ASSERT_DECL(sizeof(struct rte_flow_action_set_mac) ==
                   MEMBER_SIZEOF(struct ovs_key_ethernet, eth_dst));
 BUILD_ASSERT_DECL(sizeof(struct rte_flow_action_set_ipv4) ==
                   MEMBER_SIZEOF(struct ovs_key_ipv4, ipv4_src));
+BUILD_ASSERT_DECL(sizeof(struct rte_flow_action_set_iptos) ==
+                  MEMBER_SIZEOF(struct ovs_key_ipv4, ipv4_tos));
 BUILD_ASSERT_DECL(sizeof(struct rte_flow_action_set_ipv4) ==
                   MEMBER_SIZEOF(struct ovs_key_ipv4, ipv4_dst));
 BUILD_ASSERT_DECL(sizeof(struct rte_flow_action_set_ttl) ==
@@ -1425,6 +1437,7 @@  parse_set_actions(struct flow_actions *actions,
             add_set_flow_action(ipv4_src, RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC);
             add_set_flow_action(ipv4_dst, RTE_FLOW_ACTION_TYPE_SET_IPV4_DST);
             add_set_flow_action(ipv4_ttl, RTE_FLOW_ACTION_TYPE_SET_TTL);
+            add_set_flow_action(ipv4_tos, RTE_FLOW_ACTION_TYPE_SET_IP_TOS);
 
             if (mask && !is_all_zeros(mask, sizeof *mask)) {
                 VLOG_DBG_RL(&rl, "Unsupported IPv4 set action");