In order to print the action opcode name in the log there was a need
to add it into the macro inside "ovnact_op_to_string()". Make the
macro global one in the header instead, that allows the string
represantation to contain all opcodes because it is taken directly
from the definition in the header file.

Signed-off-by: Ales Musil <[email protected]>
---
 include/ovn/actions.h | 199 ++++++++++++++++++++++--------------------
 lib/actions.c         |  27 ------
 2 files changed, 106 insertions(+), 120 deletions(-)

diff --git a/include/ovn/actions.h b/include/ovn/actions.h
index 93edb6ea6..90366b649 100644
--- a/include/ovn/actions.h
+++ b/include/ovn/actions.h
@@ -608,13 +608,21 @@ void *ovnact_put(struct ofpbuf *, enum ovnact_type, 
size_t len);
 OVNACTS
 #undef OVNACT
 
-enum action_opcode {
+/* List of OVN logical action opcodes.
+ *
+ * This macro is used directly only internally by this header and actions.c,
+ * but the list is still of interest to developers.
+ *
+ * Each ACTION_OPCODE invocation has the <ENUM> parameter, used below in the
+ * enum definition of ACTION_OPCODE_<ENUM>, and elsewhere.
+ */
+#define ACTION_OPCODES                                                        \
     /* "arp { ...actions... }".
      *
      * The actions, in OpenFlow 1.3 format, follow the action_header.
-     */
-    ACTION_OPCODE_ARP,
-
+     */                                                                       \
+    ACTION_OPCODE(ARP)                                                        \
+                                                                              \
     /* "put_arp(port, ip, mac)"
      *
      * Arguments are passed through the packet metadata and data, as follows:
@@ -622,9 +630,9 @@ enum action_opcode {
      *     MFF_REG0 = ip
      *     MFF_LOG_INPORT = port
      *     MFF_ETH_SRC = mac
-     */
-    ACTION_OPCODE_PUT_ARP,
-
+     */                                                                       \
+    ACTION_OPCODE(PUT_ARP)                                                    \
+                                                                              \
     /* "result = put_dhcp_opts(offer_ip, option, ...)".
      *
      * Arguments follow the action_header, in this format:
@@ -632,15 +640,15 @@ enum action_opcode {
      *   - A 32-bit integer specifying a bit offset within the result field.
      *   - The 32-bit DHCP offer IP.
      *   - Any number of DHCP options.
-     */
-    ACTION_OPCODE_PUT_DHCP_OPTS,
-
+     */                                                                       \
+    ACTION_OPCODE(PUT_DHCP_OPTS)                                              \
+                                                                              \
     /* "nd_na { ...actions... }".
      *
      * The actions, in OpenFlow 1.3 format, follow the action_header.
-     */
-    ACTION_OPCODE_ND_NA,
-
+     */                                                                       \
+    ACTION_OPCODE(ND_NA)                                                      \
+                                                                              \
     /* "put_nd(port, ip6, mac)"
      *
      * Arguments are passed through the packet metadata and data, as follows:
@@ -648,160 +656,165 @@ enum action_opcode {
      *     MFF_XXREG0 = ip6
      *     MFF_LOG_INPORT = port
      *     MFF_ETH_SRC = mac
-     */
-    ACTION_OPCODE_PUT_ND,
-
+     */                                                                       \
+    ACTION_OPCODE(PUT_ND)                                                     \
+                                                                              \
     /* "result = put_dhcpv6_opts(option, ...)".
      *
      * Arguments follow the action_header, in this format:
      *   - A 32-bit or 64-bit OXM header designating the result field.
      *   - A 32-bit integer specifying a bit offset within the result field.
      *   - Any number of DHCPv6 options.
-     */
-    ACTION_OPCODE_PUT_DHCPV6_OPTS,
-
+     */                                                                       \
+    ACTION_OPCODE(PUT_DHCPV6_OPTS)                                            \
+                                                                              \
     /* "result = dns_lookup()".
      * Arguments follow the action_header, in this format:
      *   - A 32-bit or 64-bit OXM header designating the result field.
      *   - A 32-bit integer specifying a bit offset within the result field.
      *
-     */
-    ACTION_OPCODE_DNS_LOOKUP,
-
+     */                                                                       \
+    ACTION_OPCODE(DNS_LOOKUP)                                                 \
+                                                                              \
     /* "log(arguments)".
      *
      * Arguments are as follows:
      *   - An 8-bit verdict.
      *   - An 8-bit severity.
      *   - A variable length string containing the name.
-     */
-    ACTION_OPCODE_LOG,
-
+     */                                                                       \
+    ACTION_OPCODE(LOG)                                                        \
+                                                                              \
     /* "result = put_nd_ra_opts(option, ...)".
      * Arguments follow the action_header, in this format:
      *   - A 32-bit or 64-bit OXM header designating the result field.
      *   - A 32-bit integer specifying a bit offset within the result field.
      *   - Any number of ICMPv6 options.
-     */
-    ACTION_OPCODE_PUT_ND_RA_OPTS,
-
+     */                                                                       \
+    ACTION_OPCODE(PUT_ND_RA_OPTS)                                             \
+                                                                              \
     /* "nd_ns { ...actions... }".
      *
      * The actions, in OpenFlow 1.3 format, follow the action_header.
-     */
-    ACTION_OPCODE_ND_NS,
-
+     */                                                                       \
+    ACTION_OPCODE(ND_NS)                                                      \
+                                                                              \
     /* "icmp4 { ...actions... } and icmp6 { ...actions... }".
      *
      * The actions, in OpenFlow 1.3 format, follow the action_header.
-     */
-    ACTION_OPCODE_ICMP,
-
+     */                                                                       \
+    ACTION_OPCODE(ICMP)                                                       \
+                                                                              \
     /* "tcp_reset { ...actions... }".
      *
      * The actions, in OpenFlow 1.3 format, follow the action_header.
-     */
-    ACTION_OPCODE_TCP_RESET,
-
+     */                                                                       \
+    ACTION_OPCODE(TCP_RESET)                                                  \
+                                                                              \
     /* "nd_na_router { ...actions... }" with rso flag 'ND_RSO_ROUTER' set.
-        *
-        * The actions, in OpenFlow 1.3 format, follow the action_header.
-        */
-    ACTION_OPCODE_ND_NA_ROUTER,
-
-     /* MTU value (to put in the icmp4 header field - frag_mtu) follow the
-     * action header. */
-    ACTION_OPCODE_PUT_ICMP4_FRAG_MTU,
-
+     *
+     * The actions, in OpenFlow 1.3 format, follow the action_header.
+     */                                                                       \
+    ACTION_OPCODE(ND_NA_ROUTER)                                               \
+                                                                              \
+    /* MTU value (to put in the icmp4 header field - frag_mtu) follow the
+     * action header. */                                                      \
+    ACTION_OPCODE(PUT_ICMP4_FRAG_MTU)                                         \
+                                                                              \
     /* "icmp4_error { ...actions... }".
      *
      * The actions, in OpenFlow 1.3 format, follow the action_header.
-     */
-    ACTION_OPCODE_ICMP4_ERROR,
-
-    /* "trigger_event (event_type)" */
-    ACTION_OPCODE_EVENT,
-
+     */                                                                       \
+    ACTION_OPCODE(ICMP4_ERROR)                                                \
+                                                                              \
+    /* "trigger_event (event_type)" */                                        \
+    ACTION_OPCODE(EVENT)                                                      \
     /* "igmp".
      *
      * Snoop IGMP, learn the multicast participants
-     */
-    ACTION_OPCODE_IGMP,
-
+     */                                                                       \
+    ACTION_OPCODE(IGMP)                                                       \
+                                                                              \
     /* "bind_vport(vport, vport_parent)".
      *
      *   'vport' follows the action_header, in the format - 32-bit field.
      *   'vport_parent' is passed through the packet metadata as
      *    MFF_LOG_INPORT.
-     */
-    ACTION_OPCODE_BIND_VPORT,
-
+     */                                                                       \
+    ACTION_OPCODE(BIND_VPORT)                                                 \
+                                                                              \
     /* "handle_svc_check(port)"."
      *
      * Arguments are passed through the packet metadata and data, as follows:
      *
      *     MFF_LOG_INPORT = port
-     */
-    ACTION_OPCODE_HANDLE_SVC_CHECK,
+     */                                                                       \
+    ACTION_OPCODE(HANDLE_SVC_CHECK)                                           \
+                                                                              \
     /* handle_dhcpv6_reply { ...actions ...}."
      *
      *  The actions, in OpenFlow 1.3 format, follow the action_header.
-     */
-    ACTION_OPCODE_DHCP6_SERVER,
-
+     */                                                                       \
+    ACTION_OPCODE(DHCP6_SERVER)                                               \
+                                                                              \
     /* "icmp6_error { ...actions... }".
      *
      * The actions, in OpenFlow 1.3 format, follow the action_header.
-     */
-    ACTION_OPCODE_ICMP6_ERROR,
-
+     */                                                                       \
+    ACTION_OPCODE(ICMP6_ERROR)                                                \
+                                                                              \
     /* MTU value (to put in the icmp6 header field - frag_mtu) follow the
-     * action header. */
-    ACTION_OPCODE_PUT_ICMP6_FRAG_MTU,
-
+     * action header. */                                                      \
+    ACTION_OPCODE(PUT_ICMP6_FRAG_MTU)                                         \
+                                                                              \
     /* "reject { ...actions... }".
      *
      * The actions, in OpenFlow 1.3 format, follow the action_header.
-     */
-    ACTION_OPCODE_REJECT,
-
+     */                                                                       \
+    ACTION_OPCODE(REJECT)                                                     \
+                                                                              \
     /* handle_bfd_msg { ...actions ...}."
      *
      *  The actions, in OpenFlow 1.3 format, follow the action_header.
-     */
-    ACTION_OPCODE_BFD_MSG,
-
+     */                                                                       \
+    ACTION_OPCODE(BFD_MSG)                                                    \
+                                                                              \
     /* "sctp_abort { ...actions... }".
      *
      * The actions, in OpenFlow 1.3 format, follow the action_header.
-     */
-    ACTION_OPCODE_SCTP_ABORT,
-
-    /* put_fdb(inport, eth.src).
-     */
-    ACTION_OPCODE_PUT_FDB,
-
-    /* activation_strategy_rarp() */
-    ACTION_OPCODE_ACTIVATION_STRATEGY_RARP,
-
-    /* split buffer action. */
-    ACTION_OPCODE_SPLIT_BUF_ACTION,
-
+     */                                                                       \
+    ACTION_OPCODE(SCTP_ABORT)                                                 \
+                                                                              \
+    /* put_fdb(inport, eth.src). */                                           \
+    ACTION_OPCODE(PUT_FDB)                                                    \
+                                                                              \
+    /* activation_strategy_rarp() */                                          \
+    ACTION_OPCODE(ACTIVATION_STRATEGY_RARP)                                   \
+                                                                              \
+    /* split buffer action. */                                                \
+    ACTION_OPCODE(SPLIT_BUF_ACTION)                                           \
+                                                                              \
     /* "dhcp_relay_req_chk(relay_ip, server_ip)".
      *
      * Arguments follow the action_header, in this format:
      *   - The 32-bit DHCP relay IP.
      *   - The 32-bit DHCP server IP.
-     */
-    ACTION_OPCODE_DHCP_RELAY_REQ_CHK,
-
+     */                                                                       \
+    ACTION_OPCODE(DHCP_RELAY_REQ_CHK)                                         \
+                                                                              \
     /* "dhcp_relay_resp_chk(relay_ip, server_ip)".
      *
      * Arguments follow the action_header, in this format:
      *   - The 32-bit DHCP relay IP.
      *   - The 32-bit DHCP server IP.
-     */
-    ACTION_OPCODE_DHCP_RELAY_RESP_CHK,
+     */                                                                       \
+    ACTION_OPCODE(DHCP_RELAY_RESP_CHK)
+
+
+enum action_opcode {
+#define ACTION_OPCODE(ENUM) ACTION_OPCODE_##ENUM,
+    ACTION_OPCODES
+#undef ACTION_OPCODE
 };
 
 /* Header. */
diff --git a/lib/actions.c b/lib/actions.c
index 7ec481e00..8bc7ebfa6 100644
--- a/lib/actions.c
+++ b/lib/actions.c
@@ -5982,33 +5982,6 @@ char *
 ovnact_op_to_string(uint32_t ovnact_opc)
 {
     switch (ovnact_opc) {
-#define ACTION_OPCODES                              \
-        ACTION_OPCODE(ARP)                          \
-        ACTION_OPCODE(IGMP)                         \
-        ACTION_OPCODE(PUT_ARP)                      \
-        ACTION_OPCODE(PUT_DHCP_OPTS)                \
-        ACTION_OPCODE(ND_NA)                        \
-        ACTION_OPCODE(ND_NA_ROUTER)                 \
-        ACTION_OPCODE(PUT_ND)                       \
-        ACTION_OPCODE(PUT_FDB)                      \
-        ACTION_OPCODE(PUT_DHCPV6_OPTS)              \
-        ACTION_OPCODE(DNS_LOOKUP)                   \
-        ACTION_OPCODE(LOG)                          \
-        ACTION_OPCODE(PUT_ND_RA_OPTS)               \
-        ACTION_OPCODE(ND_NS)                        \
-        ACTION_OPCODE(ICMP)                         \
-        ACTION_OPCODE(ICMP4_ERROR)                  \
-        ACTION_OPCODE(ICMP6_ERROR)                  \
-        ACTION_OPCODE(TCP_RESET)                    \
-        ACTION_OPCODE(SCTP_ABORT)                   \
-        ACTION_OPCODE(REJECT)                       \
-        ACTION_OPCODE(PUT_ICMP4_FRAG_MTU)           \
-        ACTION_OPCODE(PUT_ICMP6_FRAG_MTU)           \
-        ACTION_OPCODE(EVENT)                        \
-        ACTION_OPCODE(BIND_VPORT)                   \
-        ACTION_OPCODE(DHCP6_SERVER)                 \
-        ACTION_OPCODE(HANDLE_SVC_CHECK)             \
-        ACTION_OPCODE(BFD_MSG)
 #define ACTION_OPCODE(ENUM) \
     case ACTION_OPCODE_##ENUM: return xstrdup(#ENUM);
     ACTION_OPCODES
-- 
2.48.1

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to