21 static int phs_compress(
S_PHS_RULE *phs_members,
unsigned char *in_buf,
22 unsigned char *out_buf,
unsigned int *header_size,
UINT *new_header_size );
25 static int verify_suppress_phsf(
unsigned char *in_buffer,
unsigned char *out_buffer,
26 unsigned char *phsf,
unsigned char *phsm,
unsigned int phss,
unsigned int phsv,
UINT *new_header_size );
28 static int phs_decompress(
unsigned char *in_buf,
unsigned char *out_buf,\
38 UINT *pNewHeaderSize );
45 UINT *pOutHeaderSize);
76 BOOLEAN bHeaderSuppressionEnabled,
82 UINT unPHSPktHdrBytesCopied = 0;
83 UINT unPhsOldHdrSize = 0;
84 UINT unPHSNewPktHeaderLen = 0;
89 PUCHAR pucPHSPktHdrOutBuf =
95 UINT numBytesCompressed = 0;
111 pucPHSPktHdrInBuf = Packet->
data + BytesToRemove;
116 unPHSPktHdrBytesCopied = (*PacketLen - BytesToRemove);
123 if( (unPHSPktHdrBytesCopied > 0 ) &&
132 (bHeaderSuppressionEnabled))
137 unPHSNewPktHeaderLen = unPHSPktHdrBytesCopied;
144 &unPHSNewPktHeaderLen);
147 if(unPHSNewPktHeaderLen == unPhsOldHdrSize)
150 bPHSI = *pucPHSPktHdrOutBuf;
158 if(skb_cloned(Packet))
162 if(newPacket ==
NULL)
165 dev_kfree_skb(Packet);
166 *pPacket = Packet = newPacket;
167 pucPHSPktHdrInBuf = Packet->
data + BytesToRemove;
170 numBytesCompressed = unPhsOldHdrSize - (unPHSNewPktHeaderLen+
PHSI_LEN);
172 memcpy(pucPHSPktHdrInBuf + numBytesCompressed, pucPHSPktHdrOutBuf, unPHSNewPktHeaderLen +
PHSI_LEN);
173 memcpy(Packet->
data + numBytesCompressed, Packet->
data, BytesToRemove);
174 skb_pull(Packet, numBytesCompressed);
182 if(!(skb_headroom(Packet) > 0))
184 if(skb_cow(Packet, 1))
193 *(Packet->
data + BytesToRemove) = bPHSI;
199 if(!bHeaderSuppressionEnabled)
216 UCHAR *pucEthernetHdr,
217 UINT bHeaderSuppressionEnabled)
219 u32 nStandardPktHdrLen = 0;
220 u32 nTotalsuppressedPktHdrBytes = 0;
223 UINT TotalBytesAdded = 0;
224 if(!bHeaderSuppressionEnabled)
230 pucInBuff = packet->
data;
233 nStandardPktHdrLen = packet->
len;
238 &nTotalsuppressedPktHdrBytes,
239 &nStandardPktHdrLen);
242 nTotalsuppressedPktHdrBytes,nStandardPktHdrLen);
251 TotalBytesAdded = nStandardPktHdrLen - nTotalsuppressedPktHdrBytes -
PHSI_LEN;
258 if(skb_cow(packet, skb_headroom(packet) + TotalBytesAdded))
320 free_phs_serviceflow_rules(pPhsdeviceExtension->
321 pstServiceFlowPhsRulesTable);
356 if(pPHSDeviceExt->pstServiceFlowPhsRulesTable)
358 free_phs_serviceflow_rules(pPHSDeviceExt->pstServiceFlowPhsRulesTable);
359 pPHSDeviceExt->pstServiceFlowPhsRulesTable =
NULL;
362 kfree(pPHSDeviceExt->CompressedTxBuffer);
363 pPHSDeviceExt->CompressedTxBuffer =
NULL;
365 kfree(pPHSDeviceExt->UnCompressedRxBuffer);
366 pPHSDeviceExt->UnCompressedRxBuffer =
NULL;
409 if(pDeviceExtension ==
NULL)
416 if(u8AssociatedPHSI == 0)
424 uiVcid,&pstServiceFlowEntry);
436 pstServiceFlowEntry, psPhsRule, u8AssociatedPHSI);
462 UINT nSFIndex =0, nClsidIndex =0 ;
477 ->pstServiceFlowPhsRulesTable,uiVcid,&pstServiceFlowEntry);
486 if(pstClassifierRulesTable)
528 UINT nSFIndex =0, nClsidIndex =0 ;
538 ->pstServiceFlowPhsRulesTable, uiVcid, &pstServiceFlowEntry);
592 UINT nSFIndex =0, nClsidIndex =0 ;
603 uiVcid,&pstServiceFlowEntry);
611 if(pstClassifierRulesTable)
636 kfree(pstClassifierRulesTable
637 ->stOldPhsRulesList[nClsidIndex].pstPhsRule);
645 pstServiceFlowEntry->
uiVcid = 0;
677 IN void *pvInputBuffer,
678 OUT void *pvOutputBuffer,
682 UINT nSFIndex =0, nClsidIndex =0 ;
694 if(pDeviceExtension ==
NULL)
707 uiVcid,&pstServiceFlowEntry);
729 if(!ValidatePHSRuleComplete(pstPhsRule))
737 lStatus = phs_compress(pstPhsRule,(
PUCHAR)pvInputBuffer,
738 (
PUCHAR)pvOutputBuffer, pOldHeaderSize,pNewHeaderSize);
772 IN void *pvInputBuffer,
773 OUT void *pvOutputBuffer,
777 UINT nSFIndex =0, nPhsRuleIndex =0 ;
787 if(pDeviceExtension ==
NULL)
795 phsi = *((
unsigned char *)(pvInputBuffer));
804 uiVcid,&pstServiceFlowEntry);
825 *pInHeaderSize = phs_decompress((
PUCHAR)pvInputBuffer,
826 (
PUCHAR)pvOutputBuffer,pstPhsRule,pOutHeaderSize);
853 if(psServiceFlowRulesTable)
862 if(pstClassifierRulesTable)
889 kfree(pstClassifierRulesTable);
895 kfree(psServiceFlowRulesTable);
896 psServiceFlowRulesTable =
NULL;
905 if(!psPhsRule->u8PHSI)
911 if(!psPhsRule->u8PHSS)
918 if(!psPhsRule->u8PHSFLength)
936 if(psServiceFlowTable->stSFList[i].bUsed)
938 if(psServiceFlowTable->stSFList[i].uiVcid == uiVcid)
940 *ppstServiceFlowEntry = &psServiceFlowTable->stSFList[
i];
946 *ppstServiceFlowEntry =
NULL;
962 psClassifierRules = &pstClassifierTable->stActivePhsRulesList[
i];
966 psClassifierRules = &pstClassifierTable->stOldPhsRulesList[
i];
969 if(psClassifierRules->
bUsed)
973 *ppstClassifierEntry = psClassifierRules;
980 *ppstClassifierEntry =
NULL;
994 pstClassifierRule = &pstClassifierTable->stActivePhsRulesList[
i];
998 pstClassifierRule = &pstClassifierTable->stOldPhsRulesList[
i];
1000 if(pstClassifierRule->
bUsed)
1002 if(pstClassifierRule->
u8PHSI == uiPHSI)
1004 *ppstPhsRule = pstClassifierRule->
pstPhsRule;
1011 *ppstPhsRule =
NULL;
1027 if(!psServiceFlowTable->stSFList[iSfIndex].bUsed)
1029 bFreeEntryFound =
TRUE;
1034 if(!bFreeEntryFound)
1038 psaClassifiertable = psServiceFlowTable->stSFList[iSfIndex].pstClassifierTable;
1039 uiStatus = CreateClassifierPHSRule(uiClsId,psaClassifiertable,psPhsRule,
1044 psServiceFlowTable->stSFList[iSfIndex].bUsed =
TRUE;
1045 psServiceFlowTable->stSFList[iSfIndex].uiVcid = uiVcid;
1058 UINT nClassifierIndex = 0;
1061 psaClassifiertable = pstServiceFlowEntry->pstClassifierTable;
1067 pstServiceFlowEntry->pstClassifierTable,uiClsId,
1076 uiStatus = CreateClassifierPHSRule(uiClsId,psaClassifiertable,
1134 uiStatus=UpdateClassifierPHSRule( uiClsId, pstClassifierEntry,
1135 psaClassifiertable, psPhsRule, u8AssociatedPHSI);
1147 UINT iClassifierIndex = 0;
1153 if(psaClassifiertable ==
NULL)
1165 eClsContext,&psClassifierRules);
1172 bFreeEntryFound =
TRUE;
1176 if(!bFreeEntryFound)
1181 for(iClassifierIndex = 0; iClassifierIndex <
1195 if(!psClassifierRules->
bUsed)
1197 bFreeEntryFound =
TRUE;
1203 if(!bFreeEntryFound)
1247 nStatus = UpdateClassifierPHSRule(uiClsId,psClassifierRules,
1248 psaClassifiertable,psPhsRule,u8AssociatedPHSI);
1260 UINT nPhsRuleIndex = 0;
1266 bPHSRuleOrphaned = DerefPhsRule( uiClsId, psaClassifiertable,
1267 pstClassifierEntry->pstPhsRule);
1270 nPhsRuleIndex =GetPhsRuleEntry(psaClassifiertable,u8AssociatedPHSI,
1276 if(psPhsRule->
u8PHSI == 0)
1282 if(
FALSE == bPHSRuleOrphaned)
1285 if(
NULL == pstClassifierEntry->pstPhsRule)
1297 if(bPHSRuleOrphaned)
1299 kfree(pstClassifierEntry->pstPhsRule);
1300 pstClassifierEntry->pstPhsRule =
NULL;
1302 pstClassifierEntry->pstPhsRule = pstAddPhsRule;
1305 pstClassifierEntry->bUsed =
TRUE;
1306 pstClassifierEntry->u8PHSI = pstClassifierEntry->pstPhsRule->u8PHSI;
1307 pstClassifierEntry->uiClassifierRuleId = uiClsId;
1308 pstClassifierEntry->pstPhsRule->u8RefCnt++;
1309 pstClassifierEntry->bUnclassifiedPHSRule = pstClassifierEntry->pstPhsRule->bUnclassifiedPHSRule;
1317 if(pstPhsRule==
NULL)
1343 if(stServFlowEntry.
bUsed)
1353 if(stClsEntry.
bUsed)
1359 if(stClsEntry.
bUsed)
1362 if(stClsEntry.
bUsed)
1410 int phs_decompress(
unsigned char *in_buf,
unsigned char *out_buf,
1416 unsigned char *phsf,*phsm;
1417 int in_buf_len = *header_size-1;
1423 if((decomp_phs_rules ==
NULL ))
1427 tmp_memb = decomp_phs_rules;
1437 while((phss > 0) && (size < in_buf_len))
1445 phss,*phsf,*out_buf);
1451 phss,*in_buf,*out_buf);
1459 *header_size=*header_size + 1;
1493 static int phs_compress(
S_PHS_RULE *phs_rule,
unsigned char *in_buf
1494 ,
unsigned char *out_buf,
UINT *header_size,
UINT *new_header_size)
1496 unsigned char *old_addr = out_buf;
1499 if(phs_rule ==
NULL)
1507 if(phs_rule->
u8PHSS <= *new_header_size)
1509 *header_size = phs_rule->
u8PHSS;
1513 *header_size = *new_header_size;
1517 suppress = verify_suppress_phsf(in_buf,out_buf,phs_rule->
u8PHSF,
1554 static int verify_suppress_phsf(
unsigned char *in_buffer,
unsigned char *out_buffer,
1555 unsigned char *phsf,
unsigned char *phsm,
unsigned int phss,
1556 unsigned int phsv,
UINT* new_header_size)
1558 unsigned int size=0;
1564 if(phss>(*new_header_size))
1566 phss=*new_header_size;
1574 if(*in_buffer != *phsf)
1587 *out_buffer = *in_buffer;
1603 *new_header_size =
size;