shortcut-fe-simulated-driver: support to accelerate in only one direction

Change-Id: I90ecc70c4023a130b1d4492723edbdab3c5f3efe
Signed-off-by: Xiaoping Fan <xfan@codeaurora.org>
diff --git a/simulated-driver/sfe_drv.c b/simulated-driver/sfe_drv.c
index 17f9582..15bdddb 100644
--- a/simulated-driver/sfe_drv.c
+++ b/simulated-driver/sfe_drv.c
@@ -527,6 +527,15 @@
 		sic.flags |= SFE_CREATE_FLAG_REMARK_DSCP;
 	}
 
+#ifdef CONFIG_XFRM
+	if (msg->msg.rule_create.valid_flags & SFE_RULE_CREATE_DIRECTION_VALID) {
+		sic.original_accel = msg->msg.rule_create.direction_rule.flow_accel;
+		sic.reply_accel = msg->msg.rule_create.direction_rule.return_accel;
+	} else {
+		sic.original_accel = sic.reply_accel = 1;
+	}
+#endif
+
 	if (!sfe_ipv4_create_rule(&sic)) {
 		/* success */
 		ret = SFE_CMN_RESPONSE_ACK;
@@ -902,6 +911,15 @@
 		sic.dest_dscp = msg->msg.rule_create.dscp_rule.return_dscp;
 	}
 
+#ifdef CONFIG_XFRM
+	if (msg->msg.rule_create.valid_flags & SFE_RULE_CREATE_DIRECTION_VALID) {
+		sic.original_accel = msg->msg.rule_create.direction_rule.flow_accel;
+		sic.reply_accel = msg->msg.rule_create.direction_rule.return_accel;
+	} else {
+		sic.original_accel = sic.reply_accel = 1;
+	}
+#endif
+
 	if (!sfe_ipv6_create_rule(&sic)) {
 		/* success */
 		ret = SFE_CMN_RESPONSE_ACK;
diff --git a/simulated-driver/sfe_drv.h b/simulated-driver/sfe_drv.h
index 5222fb8..1c89e5c 100644
--- a/simulated-driver/sfe_drv.h
+++ b/simulated-driver/sfe_drv.h
@@ -52,6 +52,7 @@
 #define SFE_RULE_CREATE_DSCP_MARKING_VALID (1<<5) /**< DSCP marking fields are valid */
 #define SFE_RULE_CREATE_VLAN_MARKING_VALID (1<<6) /**< VLAN marking fields are valid */
 #define SFE_RULE_CREATE_MC_NAT_VALID       (1<<7) /**< Interface is configured with Source-NAT */
+#define SFE_RULE_CREATE_DIRECTION_VALID    (1<<8) /**< specify acceleration directions */
 
 typedef enum sfe_rule_sync_reason {
 	SFE_RULE_SYNC_REASON_DESTROY,	/* Sync is to synchronize stats */
@@ -221,6 +222,16 @@
 };
 
 /**
+ * Acceleration direction rule structure
+ * 	Sometimes we just want to accelerate traffic in one direction but not in another.
+ */
+struct sfe_acceleration_direction_rule {
+	uint8_t flow_accel;		/**< Accelerate in flow direction */
+	uint8_t return_accel;		/**< Accelerate in return direction */
+	uint8_t reserved[2];		/**< Padded for alignment */
+};
+
+/**
  * The IPv4 rule create sub-message structure.
  */
 struct sfe_ipv4_rule_create_msg {
@@ -237,7 +248,9 @@
 	struct sfe_dscp_rule dscp_rule;			/**< DSCP related accleration parameters */
 	struct sfe_vlan_rule vlan_primary_rule;		/**< Primary VLAN related accleration parameters */
 	struct sfe_vlan_rule vlan_secondary_rule;	/**< Secondary VLAN related accleration parameters */
-
+#ifdef CONFIG_XFRM
+	struct sfe_acceleration_direction_rule direction_rule;/* Direction related accleration parameters*/
+#endif
 	/* Response */
 	uint32_t index;					/**< Slot ID for cache stats to host OS */
 };
@@ -328,7 +341,9 @@
 	struct sfe_dscp_rule dscp_rule;			/**< DSCP related accleration parameters */
 	struct sfe_vlan_rule vlan_primary_rule;		/**< VLAN related accleration parameters */
 	struct sfe_vlan_rule vlan_secondary_rule;	/**< VLAN related accleration parameters */
-
+#ifdef CONFIG_XFRM
+	struct sfe_acceleration_direction_rule direction_rule;/* Direction related accleration parameters*/
+#endif
 	/*
 	 * Response
 	 */