[ovs-dev] [PATCH 4/6] lib/odp-util: Add new ODP actions for recirculation

Andy Zhou azhou at nicira.com
Wed Feb 5 00:36:22 UTC 2014


Signed-off-by: Andy Zhou <azhou at nicira.com>
---
 include/linux/openvswitch.h |   26 ++++++++++++++++++++++++++
 lib/dpif-netdev.c           |    2 ++
 lib/dpif.c                  |    2 ++
 lib/odp-execute.c           |    2 ++
 lib/odp-util.c              |   13 +++++++++++++
 5 files changed, 45 insertions(+)

diff --git a/include/linux/openvswitch.h b/include/linux/openvswitch.h
index 5137c2f..1dea78e 100644
--- a/include/linux/openvswitch.h
+++ b/include/linux/openvswitch.h
@@ -530,6 +530,26 @@ struct ovs_action_push_vlan {
 	__be16 vlan_tci;	/* 802.1Q TCI (VLAN ID and priority). */
 };
 
+/*
+ * struct ovs_action_recirc - %OVS_ACTION_ATTR_RECIRC action argument.
+ * @recirc_id: The Recirculation label, Zero is invalid.
+ */
+struct ovs_action_recirc {
+	uint32_t  recirc_id;	/* Recirculation label. */
+	/* XXX only support output action for now */
+	uint32_t  out_port;	/* Output port for the first packet. */
+};
+
+/**
+ * struct ovs_action_hash - %OVS_ACTION_ATTR_HASH action argument.
+ * @hash_type: The hash function, value of enum ovs_hash_type_attr.
+ * @hash_bias: Bias used for hash computation.
+ */
+struct ovs_action_hash {
+	uint8_t hash_type;	/* enum ovs_hash_type_attr. */
+	uint32_t bias;		/* bias for the hash function. */
+};
+
 /**
  * enum ovs_action_attr - Action types.
  *
@@ -553,6 +573,10 @@ struct ovs_action_push_vlan {
  * indicate the new packet contents This could potentially still be
  * %ETH_P_MPLS_* if the resulting MPLS label stack is not empty.  If there
  * is no MPLS label stack, as determined by ethertype, no action is taken.
+ * @OVS_ACTION_HASH: Compute packet hash and set the hash vlaue into the flow
+ * key.
+ * @OVS_ACTION_RECIRC: Recirculate within the data path.
+ *
  *
  * Only a single header can be set with a single %OVS_ACTION_ATTR_SET.  Not all
  * fields within a header are modifiable, e.g. the IPv4 protocol and fragment
@@ -569,6 +593,8 @@ enum ovs_action_attr {
 	OVS_ACTION_ATTR_SAMPLE,       /* Nested OVS_SAMPLE_ATTR_*. */
 	OVS_ACTION_ATTR_PUSH_MPLS,    /* struct ovs_action_push_mpls. */
 	OVS_ACTION_ATTR_POP_MPLS,     /* __be16 ethertype. */
+	OVS_ACTION_ATTR_HASH,	      /* struct ovs_action_hash. */
+	OVS_ACTION_ATTR_RECIRC,	      /* struct ovs_action_recirc. */
 	__OVS_ACTION_ATTR_MAX
 };
 
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index cb64bdc..cb66c1e 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -1805,6 +1805,8 @@ dp_execute_cb(void *aux_, struct ofpbuf *packet,
     case OVS_ACTION_ATTR_SET:
     case OVS_ACTION_ATTR_SAMPLE:
     case OVS_ACTION_ATTR_UNSPEC:
+    case OVS_ACTION_ATTR_HASH:
+    case OVS_ACTION_ATTR_RECIRC:
     case __OVS_ACTION_ATTR_MAX:
         OVS_NOT_REACHED();
     }
diff --git a/lib/dpif.c b/lib/dpif.c
index 2b79a6e..e934aa0 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -1093,6 +1093,8 @@ dpif_execute_helper_cb(void *aux_, struct ofpbuf *packet,
     case OVS_ACTION_ATTR_SET:
     case OVS_ACTION_ATTR_SAMPLE:
     case OVS_ACTION_ATTR_UNSPEC:
+    case OVS_ACTION_ATTR_HASH:
+    case OVS_ACTION_ATTR_RECIRC:
     case __OVS_ACTION_ATTR_MAX:
         OVS_NOT_REACHED();
     }
diff --git a/lib/odp-execute.c b/lib/odp-execute.c
index 096c113..20c36b8 100644
--- a/lib/odp-execute.c
+++ b/lib/odp-execute.c
@@ -232,6 +232,8 @@ odp_execute_actions__(void *dp, struct ofpbuf *packet, struct pkt_metadata *md,
                                more_actions || left > NLA_ALIGN(a->nla_len));
             break;
 
+        case OVS_ACTION_ATTR_HASH:
+        case OVS_ACTION_ATTR_RECIRC:
         case OVS_ACTION_ATTR_UNSPEC:
         case __OVS_ACTION_ATTR_MAX:
             OVS_NOT_REACHED();
diff --git a/lib/odp-util.c b/lib/odp-util.c
index 873e05a..9aa871c 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -82,6 +82,8 @@ odp_action_len(uint16_t type)
     case OVS_ACTION_ATTR_SET: return -2;
     case OVS_ACTION_ATTR_SAMPLE: return -2;
 
+    case OVS_ACTION_ATTR_HASH: return sizeof(struct ovs_action_hash);
+    case OVS_ACTION_ATTR_RECIRC: return sizeof(struct ovs_action_recirc);
     case OVS_ACTION_ATTR_UNSPEC:
     case __OVS_ACTION_ATTR_MAX:
         return -1;
@@ -424,6 +426,17 @@ format_odp_action(struct ds *ds, const struct nlattr *a)
     case OVS_ACTION_ATTR_SAMPLE:
         format_odp_sample_action(ds, a);
         break;
+    case OVS_ACTION_ATTR_HASH: {
+        const struct ovs_action_hash *hash_act = nl_attr_get(a);
+        ds_put_format(ds, "hash(bias=%#"PRIx32")", hash_act->bias);
+        break;
+    }
+    case OVS_ACTION_ATTR_RECIRC: {
+        const struct ovs_action_recirc *recirc_act = nl_attr_get(a);
+        ds_put_format(ds, "recirc(id=%"PRIu32")", recirc_act->recirc_id);
+        break;
+    }
+
     case OVS_ACTION_ATTR_UNSPEC:
     case __OVS_ACTION_ATTR_MAX:
     default:
-- 
1.7.9.5




More information about the dev mailing list