--- ./source/private_module/tgt/tgt_drvintf.c	2018-05-08 02:56:50.000000000 +0000
+++ ./source/private_module/tgt/tgt_drvintf.c.hotpatch	2020-04-09 07:25:30.000000000 +0000
@@ -220,18 +220,15 @@
 
     return uiHostLunId;
 }
-
+int32_t tgtGetBondPortIndex(const char* portName,int8_t* idx);
 /* BEGIN: Modified by z00245196, 2014/5/13   For:DTS2014040100685: rtpiŻ*/
 int32_t tgtGetPortNo(int8_t* portName,int8_t* portNo)
 {
     int8_t i = 0;
-    /* BEGIN: Modified by f90006454, 2015/09/12   ??RTPI?????????*/
     uint8_t portNum = 0; 
     int8_t tempPortName[SCSI_PORT_NAME_LEN];    
-
     portNum = (uint8_t)tgtGetRTPITargetNum();
     /* END: Modified by f90006454, 2015/09/12   ??RTPI?????????*/
-
     if (NULL == portName)
     {
         return RETURN_ERROR;    
@@ -254,7 +251,10 @@
         /*modify by x90006290 DTS2014041706566 begin*/
         TGT_LIMIT_PRINT(DBG_LOG_ERROR,LOG_ID_016D,60 * HZ, 3,"Did not find the port no.");
         /*modify by x90006290 DTS2014041706566 end*/
-         return RETURN_ERROR;    
+        if(RETURN_ERROR == tgtGetBondPortIndex(portName,portNo))
+        {
+            return RETURN_ERROR;
+        }
     }
     return RETURN_OK;
 }
@@ -4002,3 +4002,84 @@
     return ret;
 }
 EXPORT_SYMBOL(tgtGetTargetPortOwnerNid);
+
+int32_t tgtGetBondPortIndex(const char* portName,int8_t* idx)
+{
+    struct TGT_BOND_PORT_MAP
+    {
+        const char* portName;
+        int8_t portIdx;
+    } portMap[] =
+    {
+        {"port_0_31_0",77},
+        {"port_0_31_1",78},
+        {"port_0_31_2",79},
+        {"port_0_31_3",80},
+        {"port_0_31_4",81},
+        {"port_0_31_5",82},
+        {"port_0_31_6",83},
+        {"port_0_31_7",84}
+            
+    };
+    uint32_t i = 0;
+    uint32_t size = ARRAY_LEN(portMap);
+
+    for( ; i < size;i++)
+    {
+        if(0 == strcmp(portName, portMap[i].portName))
+        {
+            *idx = portMap[i].portIdx;
+            return RETURN_OK;
+        }
+    }
+
+    return RETURN_ERROR;
+}
+
+#if defined(_PCLINT_)
+spinlock_t g_renewRtpiLock;
+//spin_lock_init(&g_renewRtpiLock);
+#else
+DEFINE_SPINLOCK(g_renewRtpiLock);
+#endif
+
+uint16_t tgtRenewRtpi(void* session)
+{
+    TGT_SESSION_S* tgtSession = (TGT_SESSION_S*)session;
+    TGT_TARGET_PORT_S* targetPort = (TGT_TARGET_PORT_S*)tgtSession->targetPort;
+    uint16_t newRtpi = 0;
+
+    spin_lock(&g_renewRtpiLock);
+    if(tgtSession->rtpi & 0x00ff)
+    {
+        spin_unlock(&g_renewRtpiLock);
+        return tgtSession->rtpi;
+    }
+
+    if(targetPort->rtpi & 0x00ff)
+    {
+        tgtSession->rtpi = targetPort->rtpi;
+        spin_unlock(&g_renewRtpiLock);
+        return tgtSession->rtpi;
+    }
+
+    newRtpi = tgtGetRTPIFromPort((uint32_t) targetPort->targetPortId);
+    if((newRtpi & 0x00ff) == 0)
+    {
+        spin_unlock(&g_renewRtpiLock);
+        return tgtSession->rtpi;
+    }
+
+    targetPort->rtpi = newRtpi;
+    tgtSession->rtpi = newRtpi;
+    
+    if (TGT_GET_CTRLID_FROM_RTPI(targetPort->rtpi) == g_tgtConf.spuId)
+    {
+        (void)tgtSetRtpiStatus((targetPort->rtpi & 0x00ff), B_TRUE);
+    }
+    
+    spin_unlock(&g_renewRtpiLock);
+    return tgtSession->rtpi;
+}
+EXPORT_SYMBOL(tgtRenewRtpi);
+
