P2P: Handle extension of wait period during p2p send action frames

Wait period has to get extended when an action frame is requested
to send on a channel in which the device already remains.
Currently support to extend the existing remain on channel duration
is not supported by the design and hence the same is achieved by a
sequence of cancellation and request for a remain on channel.
Host driver hides the notification of such sequence to the supplicant.

Change-Id: I4708637acc71c731ae806abc48d2e7071143275b
CRs-fixed: 586076
diff --git a/CORE/HDD/src/wlan_hdd_p2p.c b/CORE/HDD/src/wlan_hdd_p2p.c
index 433bd72..7997b03 100644
--- a/CORE/HDD/src/wlan_hdd_p2p.c
+++ b/CORE/HDD/src/wlan_hdd_p2p.c
@@ -118,6 +118,17 @@
                                                tANI_U32 nFrameLength, 
                                                tANI_U8* pbFrames,
                                                tANI_U8 frameType );
+static bool hdd_p2p_is_action_type_rsp( tActionFrmType actionFrmType )
+{
+        if ( actionFrmType <= MAX_P2P_ACTION_FRAME_TYPE &&
+            actionFrmType != WLAN_HDD_GO_NEG_REQ &&
+            actionFrmType != WLAN_HDD_INVITATION_REQ &&
+            actionFrmType != WLAN_HDD_DEV_DIS_REQ &&
+            actionFrmType != WLAN_HDD_PROV_DIS_REQ )
+            return TRUE;
+        else
+            return FALSE;
+}
 
 eHalStatus wlan_hdd_remain_on_channel_callback( tHalHandle hHal, void* pCtx,
                                                 eHalStatus status )
@@ -136,8 +147,8 @@
     hddLog( LOG1, "Received remain on channel rsp");
 
     cfgState->remain_on_chan_ctx = NULL;
-
-    if( REMAIN_ON_CHANNEL_REQUEST == pRemainChanCtx->rem_on_chan_request )
+    if( REMAIN_ON_CHANNEL_REQUEST == pRemainChanCtx->rem_on_chan_request &&
+        !pAdapter->internalCancelRemainOnChReq )
     {
         if( cfgState->buf )
         {
@@ -159,6 +170,7 @@
                               GFP_KERNEL);
     }
 
+    pAdapter->internalCancelRemainOnChReq = VOS_FALSE;
 
     if ( ( WLAN_HDD_INFRA_STATION == pAdapter->device_mode ) ||
          ( WLAN_HDD_P2P_CLIENT == pAdapter->device_mode ) ||
@@ -737,6 +749,20 @@
         // In case of P2P Client mode if we are already
         // on the same channel then send the frame directly
 
+        //For remain on channel we issue a passive scan to firmware
+        //but currently there is no provision for dynamically extending
+        //the dwell time therefore cancelling the ongoing remain on channel
+        //and requesting for new one.
+        //The below logic will be extended for request type action frames if
+        //needed in future.
+        if ( hdd_p2p_is_action_type_rsp(actionFrmType) &&
+            cfgState->remain_on_chan_ctx &&
+            cfgState->current_freq == chan->center_freq ) {
+            status = wlan_hdd_check_remain_on_channel(pAdapter);
+            if ( !status )
+                pAdapter->internalCancelRemainOnChReq = VOS_TRUE;
+        }
+
         if((cfgState->remain_on_chan_ctx != NULL) &&
            (cfgState->current_freq == chan->center_freq)
           )