NSS API changes for VLAN 802.1p marking, DSCP marking, and per-direction QoS for a rule

CRs-Fixed: 661976

Description:

a.) Two new fields in structure nss_ipv4/6_qos_rule, to have qos_tag per
    flow direction. Older qos_tag field removed.
b.) Two new fields in structure nss_ipv4/6_dscp_rule to have egress
    DSCP setting per direction
c.) Remoevd older 802.1p and DSCP fields from nss_ipv4/6_dscp_rule
    and nss_ipv4/6_vlan_rule
c.) Corresponding changes in nss_api.h and nss_tx_rx_ipv4/6.c

Change-Id: I60a9310d4b904efd6da353a61f1843db17638e59
Signed-off-by: Kiran Kumar C.  S. K <kkumarcs@codeaurora.org>
diff --git a/exports/nss_api_if.h b/exports/nss_api_if.h
index 8b3e595..b08cb85 100644
--- a/exports/nss_api_if.h
+++ b/exports/nss_api_if.h
@@ -228,7 +228,9 @@
 	uint32_t param_a2;		/**< Custom extra parameter 2 */
 	uint32_t param_a3;		/**< Custom extra parameter 3 */
 	uint32_t param_a4;		/**< Custom extra parameter 4 */
-	uint32_t qos_tag;		/**< QoS tag value */
+	uint32_t qos_tag;		/**< Deprecated, will be removed soon */
+	uint32_t flow_qos_tag;		/**< QoS tag value for flow direction */
+	uint32_t return_qos_tag;	/**< QoS tag value for return direction */
 	uint8_t dscp_itag;		/**< DSCP marking tag */
 	uint8_t dscp_imask;		/**< DSCP marking input mask */
 	uint8_t dscp_omask;		/**< DSCP marking output mask */
@@ -239,6 +241,8 @@
 	uint16_t vlan_oval;		/**< VLAN marking output val */
 	uint32_t in_vlan_tag[MAX_VLAN_DEPTH];	/**< Ingress VLAN tag expected for this flow */
 	uint32_t out_vlan_tag[MAX_VLAN_DEPTH];	/**< Egress VLAN tag expected for this flow */
+	uint8_t flow_dscp;		/**< IP DSCP value for flow direction */
+	uint8_t return_dscp;		/**< IP DSCP value for return direction */
 };
 
 /**
@@ -321,7 +325,9 @@
 	uint16_t return_pppoe_session_id;		/**< PPPoE session associated with return */
 	uint8_t return_pppoe_remote_mac[ETH_ALEN];	/**< Remote PPPoE peer MAC address for return */
 	uint16_t egress_vlan_tag;	/**< Egress VLAN tag expected for this flow */
-	uint32_t qos_tag;		/**< QoS tag value */
+	uint32_t qos_tag;		/**< Deprecated, will be removed soon */
+	uint32_t flow_qos_tag;		/**< QoS tag value for flow direction */
+	uint32_t return_qos_tag;	/**< QoS tag value for return direction */
 	uint8_t dscp_itag;		/**< DSCP marking tag */
 	uint8_t dscp_imask;		/**< DSCP marking input mask */
 	uint8_t dscp_omask;		/**< DSCP marking output mask */
@@ -332,6 +338,8 @@
 	uint16_t vlan_oval;		/**< VLAN marking output val */
 	uint32_t in_vlan_tag[MAX_VLAN_DEPTH];	/**< Ingress VLAN tag expected for this flow */
 	uint32_t out_vlan_tag[MAX_VLAN_DEPTH];	/**< Egress VLAN tag expected for this flow */
+	uint8_t flow_dscp;		/**< IP DSCP value for flow direction */
+	uint8_t return_dscp;		/**< IP DSCP value for return direction */
 };
 
 /**
@@ -403,7 +411,7 @@
 	uint32_t param_a4;		/**< Custom extra parameter 4 */
 
 	uint8_t flags;			/**< Flags */
-	uint32_t qos_tag;		/**< Qos Tag */
+	uint32_t qos_tag;		/**< QoS Tag */
 };
 
 /**
@@ -441,7 +449,7 @@
 					/**< Return direction's PPPoE Server MAC address */
 	uint16_t egress_vlan_tag;	/**< Egress VLAN tag */
 	uint8_t flags;			/**< Flags */
-	uint32_t qos_tag;		/**< Qos Tag */
+	uint32_t qos_tag;		/**< QoS Tag */
 };
 
 /**
@@ -502,7 +510,7 @@
 	uint8_t evicted;		/**< Non-zero if connection evicted */
 
 	uint8_t flags;			/**< Flags */
-	uint32_t qos_tag;		/**< Qos Tag */
+	uint32_t qos_tag;		/**< QoS Tag */
 };
 
 /**
@@ -533,7 +541,7 @@
 					/**< Return direction's PPPoE Server MAC address */
 	uint16_t egress_vlan_tag;	/**< Egress VLAN tag */
 	uint8_t flags;			/**< Flags */
-	uint32_t qos_tag;		/**< Qos Tag */
+	uint32_t qos_tag;		/**< QoS Tag */
 };
 
 /**
diff --git a/exports/nss_ipv4.h b/exports/nss_ipv4.h
index 64c13a6..82f8bdf 100644
--- a/exports/nss_ipv4.h
+++ b/exports/nss_ipv4.h
@@ -106,19 +106,9 @@
  * DSCP connection rule structure
  */
 struct nss_ipv4_dscp_rule {
-	uint8_t dscp_itag;		/**< Input tag for DSCP marking */
-	uint8_t dscp_imask;		/**< Input mask for DSCP marking */
-	uint8_t dscp_omask;		/**< Output mask for DSCP marking */
-	uint8_t dscp_oval;		/**< Output value of DSCP marking */
-};
-
-/**
- * Action types for VLAN
- */
-enum nss_ipv4_vlan_action_types {
-	NSS_IPV4_VLAN_MATCH = 0,	/**< Check for VLAN tag match */
-	NSS_IPV4_VLAN_ADD = 1,		/**< Add a VLAN tag */
-	NSS_IPV4_VLAN_REMOVE = 2,	/**< Remove a VLAN tag */
+	uint8_t flow_dscp;		/**< Egress DSCP value for flow direction */
+	uint8_t return_dscp;		/**< Egress DSCP value for return direction */
+	uint8_t reserved[2];		/**< Padded for alignment */
 };
 
 /**
@@ -127,12 +117,6 @@
 struct nss_ipv4_vlan_rule {
 	uint32_t ingress_vlan_tag;	/**< VLAN Tag for the ingress packets */
 	uint32_t egress_vlan_tag;	/**< VLAN Tag for egress packets */
-	uint16_t vlan_itag;		/**< Input tag for VLAN marking */
-	uint16_t vlan_imask;		/**< Input mask for VLAN marking */
-	uint16_t vlan_omask;		/**< Output mask for VLAN marking */
-	uint16_t vlan_oval;		/**< Output value of VLAN marking */
-	uint8_t action;			/**< The type of action to perform */
-	uint8_t reserved[3];		/**< Padded for alignment */
 };
 
 /**
@@ -154,7 +138,8 @@
  * QoS connection rule structure
  */
 struct nss_ipv4_qos_rule {
-	uint32_t qos_tag;		/**< QoS tag associated with this rule */
+	uint32_t flow_qos_tag;		/**< QoS tag associated with this rule for flow direction */
+	uint32_t return_qos_tag;	/**< QoS tag associated with this rule for return direction */
 };
 
 /**
@@ -226,7 +211,7 @@
 	uint16_t return_pppoe_remote_mac[3];	/**< Return direction's PPPoE Server MAC address */
 	uint16_t egress_vlan_tag;		/**< Egress VLAN tag */
 	uint32_t flags;				/**< Bit flags associated with the rule */
-	uint32_t qos_tag;			/**< Qos Tag */
+	uint32_t qos_tag;			/**< QoS Tag */
 };
 
 /**
@@ -284,7 +269,7 @@
 	uint32_t reason;		/**< Reason for the sync */
 
 	uint8_t flags;			/**< Bit flags associated with the rule */
-	uint32_t qos_tag;		/**< Qos Tag */
+	uint32_t qos_tag;		/**< QoS Tag */
 };
 
 /**
diff --git a/exports/nss_ipv6.h b/exports/nss_ipv6.h
index e0ee02a..8791b37 100644
--- a/exports/nss_ipv6.h
+++ b/exports/nss_ipv6.h
@@ -143,37 +143,21 @@
  * DSCP connection rule structure
  */
 struct nss_ipv6_dscp_rule {
-	uint8_t dscp_itag;	/**< Input tag for DSCP marking */
-	uint8_t dscp_imask;	/**< Input mask for DSCP marking */
-	uint8_t dscp_omask;	/**< Output mask for DSCP marking */
-	uint8_t dscp_oval;	/**< Output value of DSCP marking */
-};
-
-/**
- * Action types for VLAN
- */
-enum nss_ipv6_vlan_types {
-	NSS_IPV6_VLAN_MATCH = 0,	/**< Check for VLAN tag match */
-	NSS_IPV6_VLAN_ADD = 1,		/**< Add a VLAN tag */
-	NSS_IPV6_VLAN_REMOVE = 2,	/**< Remove a VLAN tag */
+	uint8_t flow_dscp;		/**< Egress DSCP value for flow direction */
+	uint8_t return_dscp;		/**< Egress DSCP value for return direction */
+	uint8_t reserved[2];		/**< Padded for alignment */
 };
 
 /**
  * VLAN connection rule structure
  */
 struct nss_ipv6_vlan_rule {
-	uint8_t action;			/**< The type of action to perform */
-	uint8_t reserved[3];		/**< Padded for alignment */
 	uint32_t ingress_vlan_tag;	/**< VLAN Tag for the ingress packets */
 	uint32_t egress_vlan_tag;	/**< VLAN Tag for egress packets */
-	uint16_t vlan_itag;		/**< Input tag for VLAN marking */
-	uint16_t vlan_imask;		/**< Input mask for VLAN marking */
-	uint16_t vlan_omask;		/**< Output mask for VLAN marking */
-	uint16_t vlan_oval;		/**< Output value of VLAN marking */
 };
 
 /**
- * TCP connection rulr structure
+ * TCP connection rule structure
  */
 struct nss_ipv6_protocol_tcp_rule {
 	uint32_t flow_max_window;	/**< Flow direction's largest seen window */
@@ -191,7 +175,8 @@
  * QoS connection rule structure
  */
 struct nss_ipv6_qos_rule {
-	uint32_t qos_tag;	/**< QoS tag associated with this rule */
+	uint32_t flow_qos_tag;		/**< QoS tag associated with this rule for flow direction */
+	uint32_t return_qos_tag;	/**< QoS tag associated with this rule for return direction */
 };
 
 /**
@@ -261,7 +246,7 @@
 	uint16_t return_pppoe_remote_mac[3];	/**< Return direction's PPPoE Server MAC address */
 	uint16_t egress_vlan_tag;		/**< Egress VLAN tag */
 	uint8_t flags;				/**< Bit flags associated with the rule */
-	uint32_t qos_tag;			/**< Qos Tag */
+	uint32_t qos_tag;			/**< QoS Tag */
 };
 
 /**
@@ -314,7 +299,7 @@
 	uint32_t inc_ticks;		/**< Number of ticks since the last sync */
 	uint32_t reason;		/**< Reason for the sync */
 	uint8_t flags;			/**< Bit flags associated with the rule */
-	uint32_t qos_tag;		/**< Qos Tag */
+	uint32_t qos_tag;		/**< QoS Tag */
 };
 
 /**
diff --git a/nss_connmgr_ipv4.c b/nss_connmgr_ipv4.c
index 7788a26..7b78110 100644
--- a/nss_connmgr_ipv4.c
+++ b/nss_connmgr_ipv4.c
@@ -771,7 +771,8 @@
 	/*
 	 * Store the skb->priority as the qos tag
 	 */
-	unic.qos_tag = (uint32_t)skb->priority;
+	unic.flow_qos_tag = (uint32_t)skb->priority;
+	unic.return_qos_tag = (uint32_t)skb->priority;
 
 	/*
 	 * Only set the routed flag if the interface from which this packet came
@@ -1748,7 +1749,8 @@
 	/*
 	 * Store the skb->priority as the qos tag
 	 */
-	unic.qos_tag = (uint32_t)skb->priority;
+	unic.flow_qos_tag = (uint32_t)skb->priority;
+	unic.return_qos_tag = (uint32_t)skb->priority;
 
 	/*
 	 * Always a routed path
@@ -2213,7 +2215,7 @@
 			unic.out_vlan_tag[0],
 			unic.flow_pppoe_session_id,
 			unic.return_pppoe_session_id,
-			unic.qos_tag);
+			unic.flow_qos_tag);
 
 	if (!offload_dscpremark_get_target_info(ct, &unic.dscp_imask, &unic.dscp_itag, &unic.dscp_omask, &unic.dscp_oval)) {
 		NSS_CONNMGR_DEBUG_INFO("DSCP remark information is not present\n");
diff --git a/nss_connmgr_ipv6.c b/nss_connmgr_ipv6.c
index 915f3c2..ff12b17 100644
--- a/nss_connmgr_ipv6.c
+++ b/nss_connmgr_ipv6.c
@@ -1030,7 +1030,8 @@
 	/*
 	 * Store the skb->priority as the qos tag
 	 */
-	unic.qos_tag = (uint32_t)skb->priority;
+	unic.flow_qos_tag = (uint32_t)skb->priority;
+	unic.return_qos_tag = (uint32_t)skb->priority;
 
 	/*
 	 * Only set the routed flag if the interface from which this packet came
@@ -1770,7 +1771,8 @@
 	/*
 	 * Store the skb->priority as the qos tag
 	 */
-	unic.qos_tag = (uint32_t)skb->priority;
+	unic.flow_qos_tag = (uint32_t)skb->priority;
+	unic.return_qos_tag = (uint32_t)skb->priority;
 
 	/*
 	 * Always a routed path
@@ -2168,7 +2170,7 @@
 			unic.out_vlan_tag[0],
 			unic.flow_pppoe_session_id,
 			unic.return_pppoe_session_id,
-			unic.qos_tag);
+			unic.return_qos_tag);
 
 	if (!offload_dscpremark_get_target_info(ct, &unic.dscp_imask, &unic.dscp_itag, &unic.dscp_omask, &unic.dscp_oval)) {
 		NSS_CONNMGR_DEBUG_INFO("DSCP remark information is not present\n");
diff --git a/nss_tx_rx_ipv4.c b/nss_tx_rx_ipv4.c
index c49f59d..5994cd0 100644
--- a/nss_tx_rx_ipv4.c
+++ b/nss_tx_rx_ipv4.c
@@ -196,6 +196,9 @@
 	} else {
 		memcpy(nircm->conn_rule.return_mac, unic->dest_mac, 6);
 	}
+	nircm->dscp_rule.flow_dscp = unic->flow_dscp;
+	nircm->dscp_rule.return_dscp = unic->return_dscp;
+
 	nircm->valid_flags |= NSS_IPV4_RULE_CREATE_CONN_VALID;
 
 	/*
@@ -232,7 +235,9 @@
 	/*
 	 * Copy over the qos rules and set the QOS_VALID flag
 	 */
-	nircm->qos_rule.qos_tag = unic->qos_tag;
+	nircm->qos_rule.flow_qos_tag = unic->flow_qos_tag;
+	nircm->qos_rule.return_qos_tag = unic->return_qos_tag;
+
 	nircm->valid_flags |= NSS_IPV4_RULE_CREATE_QOS_VALID;
 
 	if (unic->flags & NSS_IPV4_CREATE_FLAG_NO_SEQ_CHECK) {
@@ -298,6 +303,10 @@
 	} else {
 		memcpy(nircm->conn_rule.return_mac, unic->dest_mac, 6);
 	}
+
+	nircm->dscp_rule.flow_dscp = unic->flow_dscp;
+	nircm->dscp_rule.return_dscp = unic->return_dscp;
+
 	nircm->valid_flags |= NSS_IPV4_RULE_CREATE_CONN_VALID;
 
 	/*
@@ -334,33 +343,10 @@
 	/*
 	 * Copy over the qos rules and set the QOS_VALID flag
 	 */
-	nircm->qos_rule.qos_tag = unic->qos_tag;
+	nircm->qos_rule.flow_qos_tag = unic->flow_qos_tag;
+	nircm->qos_rule.return_qos_tag = unic->return_qos_tag;
 	nircm->valid_flags |= NSS_IPV4_RULE_CREATE_QOS_VALID;
 
-	/*
-	 * Copy over the dscp marking rules and set the DSCP_MARKING_VALID flag.
-	 */
-	nircm->dscp_rule.dscp_itag = unic->dscp_itag ;
-	nircm->dscp_rule.dscp_imask = unic->dscp_imask;
-	nircm->dscp_rule.dscp_omask = unic->dscp_omask;
-	nircm->dscp_rule.dscp_oval = unic->dscp_oval;
-	if (unic->flags & NSS_IPV4_CREATE_FLAG_DSCP_MARKING) {
-		nircm->rule_flags |= NSS_IPV4_RULE_CREATE_FLAG_DSCP_MARKING;
-		nircm->valid_flags |= NSS_IPV4_RULE_CREATE_DSCP_MARKING_VALID;
-	}
-
-	/*
-	 * Copy over the vlan marking rules and set the VLAN_MARKING_VALID flag.
-	 */
-	nircm->vlan_primary_rule.vlan_imask = unic->vlan_imask;
-	nircm->vlan_primary_rule.vlan_itag = unic->vlan_itag;
-	nircm->vlan_primary_rule.vlan_omask = unic->vlan_omask ;
-	nircm->vlan_primary_rule.vlan_oval = unic->vlan_oval ;
-	if (unic->flags & NSS_IPV4_CREATE_FLAG_VLAN_MARKING) {
-		nircm->rule_flags |= NSS_IPV4_RULE_CREATE_FLAG_VLAN_MARKING;
-		nircm->valid_flags |= NSS_IPV4_RULE_CREATE_VLAN_MARKING_VALID;
-	}
-
 	if (unic->flags & NSS_IPV4_CREATE_FLAG_NO_SEQ_CHECK) {
 		nircm->rule_flags |= NSS_IPV4_RULE_CREATE_FLAG_NO_SEQ_CHECK;
 	}
diff --git a/nss_tx_rx_ipv6.c b/nss_tx_rx_ipv6.c
index a3cce27..ea18f87 100644
--- a/nss_tx_rx_ipv6.c
+++ b/nss_tx_rx_ipv6.c
@@ -184,6 +184,8 @@
 	nircm->conn_rule.return_mtu = unic->to_mtu;
 	memcpy(nircm->conn_rule.flow_mac, unic->src_mac, 6);
 	memcpy(nircm->conn_rule.return_mac, unic->dest_mac, 6);
+	nircm->dscp_rule.flow_dscp = unic->flow_dscp;
+	nircm->dscp_rule.return_dscp = unic->return_dscp;
 	nircm->valid_flags |= NSS_IPV6_RULE_CREATE_CONN_VALID;
 
 	/*
@@ -220,7 +222,9 @@
 	/*
 	 * Copy over the qos rules and set the QOS_VALID flag
 	 */
-	nircm->qos_rule.qos_tag = unic->qos_tag;
+	nircm->qos_rule.flow_qos_tag = unic->flow_qos_tag;
+	nircm->qos_rule.return_qos_tag = unic->return_qos_tag;
+
 	nircm->valid_flags |= NSS_IPV6_RULE_CREATE_QOS_VALID;
 
 	if (unic->flags & NSS_IPV6_CREATE_FLAG_NO_SEQ_CHECK) {
@@ -292,6 +296,9 @@
 	memcpy(nircm->conn_rule.return_mac, unic->dest_mac, 6);
 	nircm->valid_flags |= NSS_IPV6_RULE_CREATE_CONN_VALID;
 
+	nircm->dscp_rule.flow_dscp = unic->flow_dscp;
+	nircm->dscp_rule.return_dscp = unic->return_dscp;
+
 	/*
 	 * Copy over the pppoe rules and set PPPOE_VALID flag
 	 */
@@ -326,33 +333,10 @@
 	/*
 	 * Copy over the qos rules and set the QOS_VALID flag
 	 */
-	nircm->qos_rule.qos_tag = unic->qos_tag;
+	nircm->qos_rule.flow_qos_tag = unic->flow_qos_tag;
+	nircm->qos_rule.return_qos_tag = unic->return_qos_tag;
 	nircm->valid_flags |= NSS_IPV6_RULE_CREATE_QOS_VALID;
 
-	/*
-	 * Copy over the dscp marking rules and set the DSCP_MARKING_VALID flag
-	 */
-	nircm->dscp_rule.dscp_itag = unic->dscp_itag ;
-	nircm->dscp_rule.dscp_imask = unic->dscp_imask;
-	nircm->dscp_rule.dscp_omask = unic->dscp_omask;
-	nircm->dscp_rule.dscp_oval = unic->dscp_oval;
-	if (unic->flags & NSS_IPV6_CREATE_FLAG_DSCP_MARKING) {
-		nircm->rule_flags |= NSS_IPV6_RULE_CREATE_FLAG_DSCP_MARKING;
-		nircm->valid_flags |= NSS_IPV6_RULE_CREATE_DSCP_MARKING_VALID;
-	}
-
-	/*
-	 * Copy over the vlan marking rules and set the VLAN_MARKING_VALID flag
-	 */
-	nircm->vlan_primary_rule.vlan_imask = unic->vlan_imask;
-	nircm->vlan_primary_rule.vlan_itag = unic->vlan_itag;
-	nircm->vlan_primary_rule.vlan_omask = unic->vlan_omask;
-	nircm->vlan_primary_rule.vlan_oval = unic->vlan_oval;
-	if (unic->flags & NSS_IPV6_CREATE_FLAG_VLAN_MARKING) {
-		nircm->rule_flags |= NSS_IPV6_RULE_CREATE_FLAG_VLAN_MARKING;
-		nircm->valid_flags |= NSS_IPV6_RULE_CREATE_VLAN_MARKING_VALID;
-	}
-
 	if (unic->flags & NSS_IPV6_CREATE_FLAG_NO_SEQ_CHECK) {
 		nircm->rule_flags |= NSS_IPV6_RULE_CREATE_FLAG_NO_SEQ_CHECK;
 	}