9 Description: This routine handle PHS(Payload Header Suppression for Tx path.
10 It extracts a fragment of the NDIS_PACKET containing the header
11 to be suppressed.It then supresses the header by invoking PHS exported compress routine.
12 The header data after supression is copied back to the NDIS_PACKET.
15 Input parameters: IN PMINI_ADAPTER Adapter - Miniport Adapter Context
16 IN Packet - NDIS packet containing data to be transmitted
17 IN USHORT Vcid - vcid pertaining to connection on which the packet is being sent.Used to
18 identify PHS rule to be applied.
19 B_UINT16 uiClassifierRuleID - Classifier Rule ID
20 BOOLEAN bHeaderSuppressionEnabled - indicates if header suprression is enabled for SF.
22 Return: STATUS_SUCCESS - If the send was successful.
23 Other - If an error occured.
26 int PHSTransmit(PMINI_ADAPTER Adapter,
27 struct sk_buff **pPacket,
29 B_UINT16 uiClassifierRuleID,
30 BOOLEAN bHeaderSuppressionEnabled,
36 UINT unPHSPktHdrBytesCopied = 0;
37 UINT unPhsOldHdrSize = 0;
38 UINT unPHSNewPktHeaderLen = 0;
39 /* Pointer to PHS IN Hdr Buffer */
40 PUCHAR pucPHSPktHdrInBuf =
41 Adapter->stPhsTxContextInfo.ucaHdrSupressionInBuf;
42 /* Pointer to PHS OUT Hdr Buffer */
43 PUCHAR pucPHSPktHdrOutBuf =
44 Adapter->stPhsTxContextInfo.ucaHdrSupressionOutBuf;
49 UINT numBytesCompressed = 0;
50 struct sk_buff *newPacket = NULL;
51 struct sk_buff *Packet = *pPacket;
53 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, "In PHSTransmit");
56 BytesToRemove=ETH_HLEN;
58 Accumulate the header upto the size we support supression
62 usPacketType=((struct ethhdr *)(Packet->data))->h_proto;
65 pucPHSPktHdrInBuf = Packet->data + BytesToRemove;
66 //considering data after ethernet header
67 if((*PacketLen - BytesToRemove) < MAX_PHS_LENGTHS)
70 unPHSPktHdrBytesCopied = (*PacketLen - BytesToRemove);
74 unPHSPktHdrBytesCopied = MAX_PHS_LENGTHS;
77 if( (unPHSPktHdrBytesCopied > 0 ) &&
78 (unPHSPktHdrBytesCopied <= MAX_PHS_LENGTHS))
82 // Step 2 Supress Header using PHS and fill into intermediate ucaPHSPktHdrOutBuf.
83 // Suppress only if IP Header and PHS Enabled For the Service Flow
84 if(((usPacketType == ETHERNET_FRAMETYPE_IPV4) ||
85 (usPacketType == ETHERNET_FRAMETYPE_IPV6)) &&
86 (bHeaderSuppressionEnabled))
88 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nTrying to PHS Compress Using Classifier rule 0x%X",uiClassifierRuleID);
91 unPHSNewPktHeaderLen = unPHSPktHdrBytesCopied;
92 ulPhsStatus = PhsCompress(&Adapter->stBCMPhsContext,
98 &unPHSNewPktHeaderLen);
99 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nPHS Old header Size : %d New Header Size %d\n",unPhsOldHdrSize,unPHSNewPktHeaderLen);
101 if(unPHSNewPktHeaderLen == unPhsOldHdrSize)
103 if( ulPhsStatus == STATUS_PHS_COMPRESSED)
104 bPHSI = *pucPHSPktHdrOutBuf;
105 ulPhsStatus = STATUS_PHS_NOCOMPRESSION;
108 if( ulPhsStatus == STATUS_PHS_COMPRESSED)
110 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"PHS Sending packet Compressed");
112 if(skb_cloned(Packet))
114 newPacket = skb_copy(Packet, GFP_ATOMIC);
116 if(newPacket == NULL)
117 return STATUS_FAILURE;
119 dev_kfree_skb(Packet);
120 *pPacket = Packet = newPacket;
121 pucPHSPktHdrInBuf = Packet->data + BytesToRemove;
124 numBytesCompressed = unPhsOldHdrSize - (unPHSNewPktHeaderLen+PHSI_LEN);
126 memcpy(pucPHSPktHdrInBuf + numBytesCompressed, pucPHSPktHdrOutBuf, unPHSNewPktHeaderLen + PHSI_LEN);
127 memcpy(Packet->data + numBytesCompressed, Packet->data, BytesToRemove);
128 skb_pull(Packet, numBytesCompressed);
130 return STATUS_SUCCESS;
135 //if one byte headroom is not available, increase it through skb_cow
136 if(!(skb_headroom(Packet) > 0))
138 if(skb_cow(Packet, 1))
140 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "SKB Cow Failed\n");
141 return STATUS_FAILURE;
146 // CAUTION: The MAC Header is getting corrupted here for IP CS - can be saved by copying 14 Bytes. not needed .... hence corrupting it.
147 *(Packet->data + BytesToRemove) = bPHSI;
148 return STATUS_SUCCESS;
153 if(!bHeaderSuppressionEnabled)
155 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nHeader Suppression Disabled For SF: No PHS\n");
158 return STATUS_SUCCESS;
162 //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"PHSTransmit : Dumping data packet After PHS");
163 return STATUS_SUCCESS;
166 int PHSRecieve(PMINI_ADAPTER Adapter,
168 struct sk_buff *packet,
170 UCHAR *pucEthernetHdr,
171 UINT bHeaderSuppressionEnabled)
173 u32 nStandardPktHdrLen = 0;
174 u32 nTotalsupressedPktHdrBytes = 0;
176 PUCHAR pucInBuff = NULL ;
177 UINT TotalBytesAdded = 0;
178 if(!bHeaderSuppressionEnabled)
180 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECIEVE,DBG_LVL_ALL,"\nPhs Disabled for incoming packet");
184 pucInBuff = packet->data;
186 //Restore PHS suppressed header
187 nStandardPktHdrLen = packet->len;
188 ulPhsStatus = PhsDeCompress(&Adapter->stBCMPhsContext,
191 Adapter->ucaPHSPktRestoreBuf,
192 &nTotalsupressedPktHdrBytes,
193 &nStandardPktHdrLen);
195 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECIEVE,DBG_LVL_ALL,"\nSupressed PktHdrLen : 0x%x Restored PktHdrLen : 0x%x",
196 nTotalsupressedPktHdrBytes,nStandardPktHdrLen);
198 if(ulPhsStatus != STATUS_PHS_COMPRESSED)
201 return STATUS_SUCCESS;
205 TotalBytesAdded = nStandardPktHdrLen - nTotalsupressedPktHdrBytes - PHSI_LEN;
208 if(skb_headroom(packet) >= (SKB_RESERVE_ETHERNET_HEADER + TotalBytesAdded))
209 skb_push(packet, TotalBytesAdded);
212 if(skb_cow(packet, skb_headroom(packet) + TotalBytesAdded))
214 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "cow failed in receive\n");
215 return STATUS_FAILURE;
218 skb_push(packet, TotalBytesAdded);
222 memcpy(packet->data, Adapter->ucaPHSPktRestoreBuf, nStandardPktHdrLen);
225 return STATUS_SUCCESS;
228 void DumpFullPacket(UCHAR *pBuf,UINT nPktLen)
230 PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
231 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,"Dumping Data Packet");
232 BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,pBuf,nPktLen);
235 //-----------------------------------------------------------------------------
236 // Procedure: phs_init
238 // Description: This routine is responsible for allocating memory for classifier and
242 // pPhsdeviceExtension - ptr to Device extension containing PHS Classifier rules and PHS Rules , RX, TX buffer etc
245 // TRUE(1) -If allocation of memory was success full.
246 // FALSE -If allocation of memory fails.
247 //-----------------------------------------------------------------------------
248 int phs_init(PPHS_DEVICE_EXTENSION pPhsdeviceExtension,PMINI_ADAPTER Adapter)
251 S_SERVICEFLOW_TABLE *pstServiceFlowTable;
252 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nPHS:phs_init function ");
254 if(pPhsdeviceExtension->pstServiceFlowPhsRulesTable)
257 pPhsdeviceExtension->pstServiceFlowPhsRulesTable =
258 kzalloc(sizeof(S_SERVICEFLOW_TABLE), GFP_KERNEL);
260 if(!pPhsdeviceExtension->pstServiceFlowPhsRulesTable)
262 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nAllocation ServiceFlowPhsRulesTable failed");
266 pstServiceFlowTable = pPhsdeviceExtension->pstServiceFlowPhsRulesTable;
267 for(i=0;i<MAX_SERVICEFLOWS;i++)
269 S_SERVICEFLOW_ENTRY sServiceFlow = pstServiceFlowTable->stSFList[i];
270 sServiceFlow.pstClassifierTable = kzalloc(sizeof(S_CLASSIFIER_TABLE), GFP_KERNEL);
271 if(!sServiceFlow.pstClassifierTable)
273 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nAllocation failed");
274 free_phs_serviceflow_rules(pPhsdeviceExtension->
275 pstServiceFlowPhsRulesTable);
276 pPhsdeviceExtension->pstServiceFlowPhsRulesTable = NULL;
281 pPhsdeviceExtension->CompressedTxBuffer = kmalloc(PHS_BUFFER_SIZE, GFP_KERNEL);
283 if(pPhsdeviceExtension->CompressedTxBuffer == NULL)
285 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nAllocation failed");
286 free_phs_serviceflow_rules(pPhsdeviceExtension->pstServiceFlowPhsRulesTable);
287 pPhsdeviceExtension->pstServiceFlowPhsRulesTable = NULL;
291 pPhsdeviceExtension->UnCompressedRxBuffer = kmalloc(PHS_BUFFER_SIZE, GFP_KERNEL);
292 if(pPhsdeviceExtension->UnCompressedRxBuffer == NULL)
294 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nAllocation failed");
295 kfree(pPhsdeviceExtension->CompressedTxBuffer);
296 free_phs_serviceflow_rules(pPhsdeviceExtension->pstServiceFlowPhsRulesTable);
297 pPhsdeviceExtension->pstServiceFlowPhsRulesTable = NULL;
303 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\n phs_init Successfull");
304 return STATUS_SUCCESS;
308 int PhsCleanup(IN PPHS_DEVICE_EXTENSION pPHSDeviceExt)
310 if(pPHSDeviceExt->pstServiceFlowPhsRulesTable)
312 free_phs_serviceflow_rules(pPHSDeviceExt->pstServiceFlowPhsRulesTable);
313 pPHSDeviceExt->pstServiceFlowPhsRulesTable = NULL;
316 kfree(pPHSDeviceExt->CompressedTxBuffer);
317 pPHSDeviceExt->CompressedTxBuffer = NULL;
319 kfree(pPHSDeviceExt->UnCompressedRxBuffer);
320 pPHSDeviceExt->UnCompressedRxBuffer = NULL;
329 PhsUpdateClassifierRule
332 Exported function to add or modify a PHS Rule.
335 IN void* pvContext - PHS Driver Specific Context
336 IN B_UINT16 uiVcid - The Service Flow ID for which the PHS rule applies
337 IN B_UINT16 uiClsId - The Classifier ID within the Service Flow for which the PHS rule applies.
338 IN S_PHS_RULE *psPhsRule - The PHS Rule strcuture to be added to the PHS Rule table.
346 ULONG PhsUpdateClassifierRule(IN void* pvContext,
348 IN B_UINT16 uiClsId ,
349 IN S_PHS_RULE *psPhsRule,
350 IN B_UINT8 u8AssociatedPHSI)
354 S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL;
355 PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
359 PPHS_DEVICE_EXTENSION pDeviceExtension= (PPHS_DEVICE_EXTENSION)pvContext;
361 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,"PHS With Corr2 Changes \n");
363 if(pDeviceExtension == NULL)
365 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,"Invalid Device Extension\n");
366 return ERR_PHS_INVALID_DEVICE_EXETENSION;
370 if(u8AssociatedPHSI == 0)
372 return ERR_PHS_INVALID_PHS_RULE;
375 /* Retrieve the SFID Entry Index for requested Service Flow */
377 nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable,
378 uiVcid,&pstServiceFlowEntry);
380 if(nSFIndex == PHS_INVALID_TABLE_INDEX)
382 /* This is a new SF. Create a mapping entry for this */
383 lStatus = CreateSFToClassifierRuleMapping(uiVcid, uiClsId,
384 pDeviceExtension->pstServiceFlowPhsRulesTable, psPhsRule, u8AssociatedPHSI);
388 /* SF already Exists Add PHS Rule to existing SF */
389 lStatus = CreateClassiferToPHSRuleMapping(uiVcid, uiClsId,
390 pstServiceFlowEntry, psPhsRule, u8AssociatedPHSI);
399 Deletes the specified phs Rule within Vcid
402 IN void* pvContext - PHS Driver Specific Context
403 IN B_UINT16 uiVcid - The Service Flow ID for which the PHS rule applies
404 IN B_UINT8 u8PHSI - the PHS Index identifying PHS rule to be deleted.
413 ULONG PhsDeletePHSRule(IN void* pvContext,IN B_UINT16 uiVcid,IN B_UINT8 u8PHSI)
416 UINT nSFIndex =0, nClsidIndex =0 ;
417 S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL;
418 S_CLASSIFIER_TABLE *pstClassifierRulesTable = NULL;
419 PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
422 PPHS_DEVICE_EXTENSION pDeviceExtension= (PPHS_DEVICE_EXTENSION)pvContext;
424 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "======>\n");
429 //Retrieve the SFID Entry Index for requested Service Flow
430 nSFIndex = GetServiceFlowEntry(pDeviceExtension
431 ->pstServiceFlowPhsRulesTable,uiVcid,&pstServiceFlowEntry);
433 if(nSFIndex == PHS_INVALID_TABLE_INDEX)
435 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "SFID Match Failed\n");
436 return ERR_SF_MATCH_FAIL;
439 pstClassifierRulesTable=pstServiceFlowEntry->pstClassifierTable;
440 if(pstClassifierRulesTable)
442 for(nClsidIndex=0;nClsidIndex<MAX_PHSRULE_PER_SF;nClsidIndex++)
444 if(pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].bUsed && pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule)
446 if(pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule->u8PHSI == u8PHSI) {
447 if(pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule->u8RefCnt)
448 pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule->u8RefCnt--;
449 if(0 == pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule->u8RefCnt)
450 kfree(pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule);
451 memset(&pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex], 0,
452 sizeof(S_CLASSIFIER_ENTRY));
463 PhsDeleteClassifierRule
466 Exported function to Delete a PHS Rule for the SFID,CLSID Pair.
469 IN void* pvContext - PHS Driver Specific Context
470 IN B_UINT16 uiVcid - The Service Flow ID for which the PHS rule applies
471 IN B_UINT16 uiClsId - The Classifier ID within the Service Flow for which the PHS rule applies.
479 ULONG PhsDeleteClassifierRule(IN void* pvContext,IN B_UINT16 uiVcid ,IN B_UINT16 uiClsId)
482 UINT nSFIndex =0, nClsidIndex =0 ;
483 S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL;
484 S_CLASSIFIER_ENTRY *pstClassifierEntry = NULL;
485 PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
486 PPHS_DEVICE_EXTENSION pDeviceExtension= (PPHS_DEVICE_EXTENSION)pvContext;
490 //Retrieve the SFID Entry Index for requested Service Flow
491 nSFIndex = GetServiceFlowEntry(pDeviceExtension
492 ->pstServiceFlowPhsRulesTable, uiVcid, &pstServiceFlowEntry);
493 if(nSFIndex == PHS_INVALID_TABLE_INDEX)
495 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,"SFID Match Failed\n");
496 return ERR_SF_MATCH_FAIL;
499 nClsidIndex = GetClassifierEntry(pstServiceFlowEntry->pstClassifierTable,
500 uiClsId, eActiveClassifierRuleContext, &pstClassifierEntry);
501 if((nClsidIndex != PHS_INVALID_TABLE_INDEX) && (!pstClassifierEntry->bUnclassifiedPHSRule))
503 if(pstClassifierEntry->pstPhsRule)
505 if(pstClassifierEntry->pstPhsRule->u8RefCnt)
506 pstClassifierEntry->pstPhsRule->u8RefCnt--;
507 if(0==pstClassifierEntry->pstPhsRule->u8RefCnt)
508 kfree(pstClassifierEntry->pstPhsRule);
511 memset(pstClassifierEntry, 0, sizeof(S_CLASSIFIER_ENTRY));
514 nClsidIndex = GetClassifierEntry(pstServiceFlowEntry->pstClassifierTable,
515 uiClsId,eOldClassifierRuleContext,&pstClassifierEntry);
517 if((nClsidIndex != PHS_INVALID_TABLE_INDEX) && (!pstClassifierEntry->bUnclassifiedPHSRule))
519 kfree(pstClassifierEntry->pstPhsRule);
520 memset(pstClassifierEntry, 0, sizeof(S_CLASSIFIER_ENTRY));
530 Exported function to Delete a all PHS Rules for the SFID.
533 IN void* pvContext - PHS Driver Specific Context
534 IN B_UINT16 uiVcid - The Service Flow ID for which the PHS rules need to be deleted
542 ULONG PhsDeleteSFRules(IN void* pvContext,IN B_UINT16 uiVcid)
546 UINT nSFIndex =0, nClsidIndex =0 ;
547 S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL;
548 S_CLASSIFIER_TABLE *pstClassifierRulesTable = NULL;
549 PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
550 PPHS_DEVICE_EXTENSION pDeviceExtension= (PPHS_DEVICE_EXTENSION)pvContext;
551 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,"====> \n");
555 //Retrieve the SFID Entry Index for requested Service Flow
556 nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable,
557 uiVcid,&pstServiceFlowEntry);
558 if(nSFIndex == PHS_INVALID_TABLE_INDEX)
560 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "SFID Match Failed\n");
561 return ERR_SF_MATCH_FAIL;
564 pstClassifierRulesTable=pstServiceFlowEntry->pstClassifierTable;
565 if(pstClassifierRulesTable)
567 for(nClsidIndex=0;nClsidIndex<MAX_PHSRULE_PER_SF;nClsidIndex++)
569 if(pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule)
571 if(pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex]
572 .pstPhsRule->u8RefCnt)
573 pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex]
574 .pstPhsRule->u8RefCnt--;
575 if(0==pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex]
576 .pstPhsRule->u8RefCnt)
577 kfree(pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule);
578 pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex]
581 memset(&pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex], 0, sizeof(S_CLASSIFIER_ENTRY));
582 if(pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex].pstPhsRule)
584 if(pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex]
585 .pstPhsRule->u8RefCnt)
586 pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex]
587 .pstPhsRule->u8RefCnt--;
588 if(0 == pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex]
589 .pstPhsRule->u8RefCnt)
590 kfree(pstClassifierRulesTable
591 ->stOldPhsRulesList[nClsidIndex].pstPhsRule);
592 pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex]
595 memset(&pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex], 0, sizeof(S_CLASSIFIER_ENTRY));
598 pstServiceFlowEntry->bUsed = FALSE;
599 pstServiceFlowEntry->uiVcid = 0;
611 Exported function to compress the data using PHS.
614 IN void* pvContext - PHS Driver Specific Context.
615 IN B_UINT16 uiVcid - The Service Flow ID to which current packet header compression applies.
616 IN UINT uiClsId - The Classifier ID to which current packet header compression applies.
617 IN void *pvInputBuffer - The Input buffer containg packet header data
618 IN void *pvOutputBuffer - The output buffer returned by this function after PHS
619 IN UINT *pOldHeaderSize - The actual size of the header before PHS
620 IN UINT *pNewHeaderSize - The new size of the header after applying PHS
628 ULONG PhsCompress(IN void* pvContext,
631 IN void *pvInputBuffer,
632 OUT void *pvOutputBuffer,
633 OUT UINT *pOldHeaderSize,
634 OUT UINT *pNewHeaderSize )
636 UINT nSFIndex =0, nClsidIndex =0 ;
637 S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL;
638 S_CLASSIFIER_ENTRY *pstClassifierEntry = NULL;
639 S_PHS_RULE *pstPhsRule = NULL;
641 PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
645 PPHS_DEVICE_EXTENSION pDeviceExtension= (PPHS_DEVICE_EXTENSION)pvContext;
648 if(pDeviceExtension == NULL)
650 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"Invalid Device Extension\n");
651 lStatus = STATUS_PHS_NOCOMPRESSION ;
656 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"Suppressing header \n");
659 //Retrieve the SFID Entry Index for requested Service Flow
660 nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable,
661 uiVcid,&pstServiceFlowEntry);
662 if(nSFIndex == PHS_INVALID_TABLE_INDEX)
664 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"SFID Match Failed\n");
665 lStatus = STATUS_PHS_NOCOMPRESSION ;
669 nClsidIndex = GetClassifierEntry(pstServiceFlowEntry->pstClassifierTable,
670 uiClsId,eActiveClassifierRuleContext,&pstClassifierEntry);
672 if(nClsidIndex == PHS_INVALID_TABLE_INDEX)
674 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"No PHS Rule Defined For Classifier\n");
675 lStatus = STATUS_PHS_NOCOMPRESSION ;
680 //get rule from SF id,Cls ID pair and proceed
681 pstPhsRule = pstClassifierEntry->pstPhsRule;
683 if(!ValidatePHSRuleComplete(pstPhsRule))
685 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,"PHS Rule Defined For Classifier But Not Complete\n");
686 lStatus = STATUS_PHS_NOCOMPRESSION ;
691 lStatus = phs_compress(pstPhsRule,(PUCHAR)pvInputBuffer,
692 (PUCHAR)pvOutputBuffer, pOldHeaderSize,pNewHeaderSize);
694 if(lStatus == STATUS_PHS_COMPRESSED)
696 pstPhsRule->PHSModifiedBytes += *pOldHeaderSize - *pNewHeaderSize - 1;
697 pstPhsRule->PHSModifiedNumPackets++;
700 pstPhsRule->PHSErrorNumPackets++;
709 Exported function to restore the packet header in Rx path.
712 IN void* pvContext - PHS Driver Specific Context.
713 IN B_UINT16 uiVcid - The Service Flow ID to which current packet header restoration applies.
714 IN void *pvInputBuffer - The Input buffer containg suppressed packet header data
715 OUT void *pvOutputBuffer - The output buffer returned by this function after restoration
716 OUT UINT *pHeaderSize - The packet header size after restoration is returned in this parameter.
724 ULONG PhsDeCompress(IN void* pvContext,
726 IN void *pvInputBuffer,
727 OUT void *pvOutputBuffer,
728 OUT UINT *pInHeaderSize,
729 OUT UINT *pOutHeaderSize )
731 UINT nSFIndex =0, nPhsRuleIndex =0 ;
732 S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL;
733 S_PHS_RULE *pstPhsRule = NULL;
735 PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
736 PPHS_DEVICE_EXTENSION pDeviceExtension=
737 (PPHS_DEVICE_EXTENSION)pvContext;
741 if(pDeviceExtension == NULL)
743 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECIEVE,DBG_LVL_ALL,"Invalid Device Extension\n");
744 return ERR_PHS_INVALID_DEVICE_EXETENSION;
747 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECIEVE,DBG_LVL_ALL,"Restoring header \n");
749 phsi = *((unsigned char *)(pvInputBuffer));
750 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECIEVE,DBG_LVL_ALL,"PHSI To Be Used For restore : %x \n",phsi);
751 if(phsi == UNCOMPRESSED_PACKET )
753 return STATUS_PHS_NOCOMPRESSION;
756 //Retrieve the SFID Entry Index for requested Service Flow
757 nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable,
758 uiVcid,&pstServiceFlowEntry);
759 if(nSFIndex == PHS_INVALID_TABLE_INDEX)
761 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECIEVE,DBG_LVL_ALL,"SFID Match Failed During Lookup\n");
762 return ERR_SF_MATCH_FAIL;
765 nPhsRuleIndex = GetPhsRuleEntry(pstServiceFlowEntry->pstClassifierTable,phsi,
766 eActiveClassifierRuleContext,&pstPhsRule);
767 if(nPhsRuleIndex == PHS_INVALID_TABLE_INDEX)
769 //Phs Rule does not exist in active rules table. Lets try in the old rules table.
770 nPhsRuleIndex = GetPhsRuleEntry(pstServiceFlowEntry->pstClassifierTable,
771 phsi,eOldClassifierRuleContext,&pstPhsRule);
772 if(nPhsRuleIndex == PHS_INVALID_TABLE_INDEX)
774 return ERR_PHSRULE_MATCH_FAIL;
779 *pInHeaderSize = phs_decompress((PUCHAR)pvInputBuffer,
780 (PUCHAR)pvOutputBuffer,pstPhsRule,pOutHeaderSize);
782 pstPhsRule->PHSModifiedBytes += *pOutHeaderSize - *pInHeaderSize - 1;
784 pstPhsRule->PHSModifiedNumPackets++;
785 return STATUS_PHS_COMPRESSED;
789 //-----------------------------------------------------------------------------
790 // Procedure: free_phs_serviceflow_rules
792 // Description: This routine is responsible for freeing memory allocated for PHS rules.
795 // rules - ptr to S_SERVICEFLOW_TABLE structure.
798 // Does not return any value.
799 //-----------------------------------------------------------------------------
801 void free_phs_serviceflow_rules(S_SERVICEFLOW_TABLE *psServiceFlowRulesTable)
804 PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
806 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "=======>\n");
807 if(psServiceFlowRulesTable)
809 for(i=0;i<MAX_SERVICEFLOWS;i++)
811 S_SERVICEFLOW_ENTRY stServiceFlowEntry =
812 psServiceFlowRulesTable->stSFList[i];
813 S_CLASSIFIER_TABLE *pstClassifierRulesTable =
814 stServiceFlowEntry.pstClassifierTable;
816 if(pstClassifierRulesTable)
818 for(j=0;j<MAX_PHSRULE_PER_SF;j++)
820 if(pstClassifierRulesTable->stActivePhsRulesList[j].pstPhsRule)
822 if(pstClassifierRulesTable->stActivePhsRulesList[j].pstPhsRule
824 pstClassifierRulesTable->stActivePhsRulesList[j].pstPhsRule
826 if(0==pstClassifierRulesTable->stActivePhsRulesList[j].pstPhsRule
828 kfree(pstClassifierRulesTable->stActivePhsRulesList[j].pstPhsRule);
829 pstClassifierRulesTable->stActivePhsRulesList[j].pstPhsRule = NULL;
831 if(pstClassifierRulesTable->stOldPhsRulesList[j].pstPhsRule)
833 if(pstClassifierRulesTable->stOldPhsRulesList[j].pstPhsRule
835 pstClassifierRulesTable->stOldPhsRulesList[j].pstPhsRule
837 if(0==pstClassifierRulesTable->stOldPhsRulesList[j].pstPhsRule
839 kfree(pstClassifierRulesTable->stOldPhsRulesList[j].pstPhsRule);
840 pstClassifierRulesTable->stOldPhsRulesList[j].pstPhsRule = NULL;
843 kfree(pstClassifierRulesTable);
844 stServiceFlowEntry.pstClassifierTable = pstClassifierRulesTable = NULL;
849 kfree(psServiceFlowRulesTable);
850 psServiceFlowRulesTable = NULL;
855 BOOLEAN ValidatePHSRuleComplete(IN S_PHS_RULE *psPhsRule)
859 if(!psPhsRule->u8PHSI)
865 if(!psPhsRule->u8PHSS)
871 //Check if PHSF is defines for the PHS Rule
872 if(!psPhsRule->u8PHSFLength) // If any part of PHSF is valid then Rule contains valid PHSF
884 UINT GetServiceFlowEntry(IN S_SERVICEFLOW_TABLE *psServiceFlowTable,
885 IN B_UINT16 uiVcid,S_SERVICEFLOW_ENTRY **ppstServiceFlowEntry)
888 for(i=0;i<MAX_SERVICEFLOWS;i++)
890 if(psServiceFlowTable->stSFList[i].bUsed)
892 if(psServiceFlowTable->stSFList[i].uiVcid == uiVcid)
894 *ppstServiceFlowEntry = &psServiceFlowTable->stSFList[i];
900 *ppstServiceFlowEntry = NULL;
901 return PHS_INVALID_TABLE_INDEX;
905 UINT GetClassifierEntry(IN S_CLASSIFIER_TABLE *pstClassifierTable,
906 IN B_UINT32 uiClsid,E_CLASSIFIER_ENTRY_CONTEXT eClsContext,
907 OUT S_CLASSIFIER_ENTRY **ppstClassifierEntry)
910 S_CLASSIFIER_ENTRY *psClassifierRules = NULL;
911 for(i=0;i<MAX_PHSRULE_PER_SF;i++)
914 if(eClsContext == eActiveClassifierRuleContext)
916 psClassifierRules = &pstClassifierTable->stActivePhsRulesList[i];
920 psClassifierRules = &pstClassifierTable->stOldPhsRulesList[i];
923 if(psClassifierRules->bUsed)
925 if(psClassifierRules->uiClassifierRuleId == uiClsid)
927 *ppstClassifierEntry = psClassifierRules;
934 *ppstClassifierEntry = NULL;
935 return PHS_INVALID_TABLE_INDEX;
938 UINT GetPhsRuleEntry(IN S_CLASSIFIER_TABLE *pstClassifierTable,
939 IN B_UINT32 uiPHSI,E_CLASSIFIER_ENTRY_CONTEXT eClsContext,
940 OUT S_PHS_RULE **ppstPhsRule)
943 S_CLASSIFIER_ENTRY *pstClassifierRule = NULL;
944 for(i=0;i<MAX_PHSRULE_PER_SF;i++)
946 if(eClsContext == eActiveClassifierRuleContext)
948 pstClassifierRule = &pstClassifierTable->stActivePhsRulesList[i];
952 pstClassifierRule = &pstClassifierTable->stOldPhsRulesList[i];
954 if(pstClassifierRule->bUsed)
956 if(pstClassifierRule->u8PHSI == uiPHSI)
958 *ppstPhsRule = pstClassifierRule->pstPhsRule;
966 return PHS_INVALID_TABLE_INDEX;
969 UINT CreateSFToClassifierRuleMapping(IN B_UINT16 uiVcid,IN B_UINT16 uiClsId,
970 IN S_SERVICEFLOW_TABLE *psServiceFlowTable,S_PHS_RULE *psPhsRule,
971 B_UINT8 u8AssociatedPHSI)
974 S_CLASSIFIER_TABLE *psaClassifiertable = NULL;
977 BOOLEAN bFreeEntryFound =FALSE;
978 //Check for a free entry in SFID table
979 for(iSfIndex=0;iSfIndex < MAX_SERVICEFLOWS;iSfIndex++)
981 if(!psServiceFlowTable->stSFList[iSfIndex].bUsed)
983 bFreeEntryFound = TRUE;
989 return ERR_SFTABLE_FULL;
992 psaClassifiertable = psServiceFlowTable->stSFList[iSfIndex].pstClassifierTable;
993 uiStatus = CreateClassifierPHSRule(uiClsId,psaClassifiertable,psPhsRule,
994 eActiveClassifierRuleContext,u8AssociatedPHSI);
995 if(uiStatus == PHS_SUCCESS)
997 //Add entry at free index to the SF
998 psServiceFlowTable->stSFList[iSfIndex].bUsed = TRUE;
999 psServiceFlowTable->stSFList[iSfIndex].uiVcid = uiVcid;
1006 UINT CreateClassiferToPHSRuleMapping(IN B_UINT16 uiVcid,
1007 IN B_UINT16 uiClsId,IN S_SERVICEFLOW_ENTRY *pstServiceFlowEntry,
1008 S_PHS_RULE *psPhsRule,B_UINT8 u8AssociatedPHSI)
1010 S_CLASSIFIER_ENTRY *pstClassifierEntry = NULL;
1011 UINT uiStatus =PHS_SUCCESS;
1012 UINT nClassifierIndex = 0;
1013 S_CLASSIFIER_TABLE *psaClassifiertable = NULL;
1014 PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
1015 psaClassifiertable = pstServiceFlowEntry->pstClassifierTable;
1017 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "==>");
1019 /* Check if the supplied Classifier already exists */
1020 nClassifierIndex =GetClassifierEntry(
1021 pstServiceFlowEntry->pstClassifierTable,uiClsId,
1022 eActiveClassifierRuleContext,&pstClassifierEntry);
1023 if(nClassifierIndex == PHS_INVALID_TABLE_INDEX)
1026 The Classifier doesn't exist. So its a new classifier being added.
1027 Add new entry to associate PHS Rule to the Classifier
1030 uiStatus = CreateClassifierPHSRule(uiClsId,psaClassifiertable,
1031 psPhsRule,eActiveClassifierRuleContext,u8AssociatedPHSI);
1036 The Classifier exists.The PHS Rule for this classifier
1039 if(pstClassifierEntry->u8PHSI == psPhsRule->u8PHSI)
1041 if(pstClassifierEntry->pstPhsRule == NULL)
1042 return ERR_PHS_INVALID_PHS_RULE;
1045 This rule already exists if any fields are changed for this PHS
1048 /* If any part of PHSF is valid then we update PHSF */
1049 if(psPhsRule->u8PHSFLength)
1052 memcpy(pstClassifierEntry->pstPhsRule->u8PHSF,
1053 psPhsRule->u8PHSF , MAX_PHS_LENGTHS);
1055 if(psPhsRule->u8PHSFLength)
1058 pstClassifierEntry->pstPhsRule->u8PHSFLength =
1059 psPhsRule->u8PHSFLength;
1061 if(psPhsRule->u8PHSMLength)
1064 memcpy(pstClassifierEntry->pstPhsRule->u8PHSM,
1065 psPhsRule->u8PHSM, MAX_PHS_LENGTHS);
1067 if(psPhsRule->u8PHSMLength)
1070 pstClassifierEntry->pstPhsRule->u8PHSMLength =
1071 psPhsRule->u8PHSMLength;
1073 if(psPhsRule->u8PHSS)
1076 pstClassifierEntry->pstPhsRule->u8PHSS = psPhsRule->u8PHSS;
1080 pstClassifierEntry->pstPhsRule->u8PHSV = psPhsRule->u8PHSV;
1086 A new rule is being set for this classifier.
1088 uiStatus=UpdateClassifierPHSRule( uiClsId, pstClassifierEntry,
1089 psaClassifiertable, psPhsRule, u8AssociatedPHSI);
1097 UINT CreateClassifierPHSRule(IN B_UINT16 uiClsId,
1098 S_CLASSIFIER_TABLE *psaClassifiertable ,S_PHS_RULE *psPhsRule,
1099 E_CLASSIFIER_ENTRY_CONTEXT eClsContext,B_UINT8 u8AssociatedPHSI)
1101 UINT iClassifierIndex = 0;
1102 BOOLEAN bFreeEntryFound = FALSE;
1103 S_CLASSIFIER_ENTRY *psClassifierRules = NULL;
1104 UINT nStatus = PHS_SUCCESS;
1105 PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
1106 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,"Inside CreateClassifierPHSRule");
1107 if(psaClassifiertable == NULL)
1109 return ERR_INVALID_CLASSIFIERTABLE_FOR_SF;
1112 if(eClsContext == eOldClassifierRuleContext)
1114 /* If An Old Entry for this classifier ID already exists in the
1115 old rules table replace it. */
1118 GetClassifierEntry(psaClassifiertable, uiClsId,
1119 eClsContext,&psClassifierRules);
1120 if(iClassifierIndex != PHS_INVALID_TABLE_INDEX)
1123 The Classifier already exists in the old rules table
1124 Lets replace the old classifier with the new one.
1126 bFreeEntryFound = TRUE;
1130 if(!bFreeEntryFound)
1133 Continue to search for a free location to add the rule
1135 for(iClassifierIndex = 0; iClassifierIndex <
1136 MAX_PHSRULE_PER_SF; iClassifierIndex++)
1138 if(eClsContext == eActiveClassifierRuleContext)
1141 &psaClassifiertable->stActivePhsRulesList[iClassifierIndex];
1146 &psaClassifiertable->stOldPhsRulesList[iClassifierIndex];
1149 if(!psClassifierRules->bUsed)
1151 bFreeEntryFound = TRUE;
1157 if(!bFreeEntryFound)
1159 if(eClsContext == eActiveClassifierRuleContext)
1161 return ERR_CLSASSIFIER_TABLE_FULL;
1165 //Lets replace the oldest rule if we are looking in old Rule table
1166 if(psaClassifiertable->uiOldestPhsRuleIndex >=
1169 psaClassifiertable->uiOldestPhsRuleIndex =0;
1172 iClassifierIndex = psaClassifiertable->uiOldestPhsRuleIndex;
1174 &psaClassifiertable->stOldPhsRulesList[iClassifierIndex];
1176 (psaClassifiertable->uiOldestPhsRuleIndex)++;
1180 if(eClsContext == eOldClassifierRuleContext)
1182 if(psClassifierRules->pstPhsRule == NULL)
1184 psClassifierRules->pstPhsRule = kmalloc(sizeof(S_PHS_RULE),GFP_KERNEL);
1186 if(NULL == psClassifierRules->pstPhsRule)
1187 return ERR_PHSRULE_MEMALLOC_FAIL;
1190 psClassifierRules->bUsed = TRUE;
1191 psClassifierRules->uiClassifierRuleId = uiClsId;
1192 psClassifierRules->u8PHSI = psPhsRule->u8PHSI;
1193 psClassifierRules->bUnclassifiedPHSRule = psPhsRule->bUnclassifiedPHSRule;
1195 /* Update The PHS rule */
1196 memcpy(psClassifierRules->pstPhsRule,
1197 psPhsRule, sizeof(S_PHS_RULE));
1201 nStatus = UpdateClassifierPHSRule(uiClsId,psClassifierRules,
1202 psaClassifiertable,psPhsRule,u8AssociatedPHSI);
1208 UINT UpdateClassifierPHSRule(IN B_UINT16 uiClsId,
1209 IN S_CLASSIFIER_ENTRY *pstClassifierEntry,
1210 S_CLASSIFIER_TABLE *psaClassifiertable ,S_PHS_RULE *psPhsRule,
1211 B_UINT8 u8AssociatedPHSI)
1213 S_PHS_RULE *pstAddPhsRule = NULL;
1214 UINT nPhsRuleIndex = 0;
1215 BOOLEAN bPHSRuleOrphaned = FALSE;
1216 PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
1217 psPhsRule->u8RefCnt =0;
1219 /* Step 1 Deref Any Exisiting PHS Rule in this classifier Entry*/
1220 bPHSRuleOrphaned = DerefPhsRule( uiClsId, psaClassifiertable,
1221 pstClassifierEntry->pstPhsRule);
1223 //Step 2 Search if there is a PHS Rule with u8AssociatedPHSI in Classifier table for this SF
1224 nPhsRuleIndex =GetPhsRuleEntry(psaClassifiertable,u8AssociatedPHSI,
1225 eActiveClassifierRuleContext, &pstAddPhsRule);
1226 if(PHS_INVALID_TABLE_INDEX == nPhsRuleIndex)
1228 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nAdding New PHSRuleEntry For Classifier");
1230 if(psPhsRule->u8PHSI == 0)
1232 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nError PHSI is Zero\n");
1233 return ERR_PHS_INVALID_PHS_RULE;
1235 //Step 2.a PHS Rule Does Not Exist .Create New PHS Rule for uiClsId
1236 if(FALSE == bPHSRuleOrphaned)
1238 pstClassifierEntry->pstPhsRule = kmalloc(sizeof(S_PHS_RULE), GFP_KERNEL);
1239 if(NULL == pstClassifierEntry->pstPhsRule)
1241 return ERR_PHSRULE_MEMALLOC_FAIL;
1244 memcpy(pstClassifierEntry->pstPhsRule, psPhsRule, sizeof(S_PHS_RULE));
1249 //Step 2.b PHS Rule Exists Tie uiClsId with the existing PHS Rule
1250 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nTying Classifier to Existing PHS Rule");
1251 if(bPHSRuleOrphaned)
1253 kfree(pstClassifierEntry->pstPhsRule);
1254 pstClassifierEntry->pstPhsRule = NULL;
1256 pstClassifierEntry->pstPhsRule = pstAddPhsRule;
1259 pstClassifierEntry->bUsed = TRUE;
1260 pstClassifierEntry->u8PHSI = pstClassifierEntry->pstPhsRule->u8PHSI;
1261 pstClassifierEntry->uiClassifierRuleId = uiClsId;
1262 pstClassifierEntry->pstPhsRule->u8RefCnt++;
1263 pstClassifierEntry->bUnclassifiedPHSRule = pstClassifierEntry->pstPhsRule->bUnclassifiedPHSRule;
1269 BOOLEAN DerefPhsRule(IN B_UINT16 uiClsId,S_CLASSIFIER_TABLE *psaClassifiertable,S_PHS_RULE *pstPhsRule)
1271 if(pstPhsRule==NULL)
1273 if(pstPhsRule->u8RefCnt)
1274 pstPhsRule->u8RefCnt--;
1275 if(0==pstPhsRule->u8RefCnt)
1277 /*if(pstPhsRule->u8PHSI)
1278 //Store the currently active rule into the old rules list
1279 CreateClassifierPHSRule(uiClsId,psaClassifiertable,pstPhsRule,eOldClassifierRuleContext,pstPhsRule->u8PHSI);*/
1288 void DumpPhsRules(PPHS_DEVICE_EXTENSION pDeviceExtension)
1291 PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
1292 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\n Dumping PHS Rules : \n");
1293 for(i=0;i<MAX_SERVICEFLOWS;i++)
1295 S_SERVICEFLOW_ENTRY stServFlowEntry =
1296 pDeviceExtension->pstServiceFlowPhsRulesTable->stSFList[i];
1297 if(stServFlowEntry.bUsed)
1299 for(j=0;j<MAX_PHSRULE_PER_SF;j++)
1303 S_CLASSIFIER_ENTRY stClsEntry;
1306 stClsEntry = stServFlowEntry.pstClassifierTable->stActivePhsRulesList[j];
1307 if(stClsEntry.bUsed)
1308 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n Active PHS Rule : \n");
1312 stClsEntry = stServFlowEntry.pstClassifierTable->stOldPhsRulesList[j];
1313 if(stClsEntry.bUsed)
1314 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n Old PHS Rule : \n");
1316 if(stClsEntry.bUsed)
1319 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\n VCID : %#X",stServFlowEntry.uiVcid);
1320 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n ClassifierID : %#X",stClsEntry.uiClassifierRuleId);
1321 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSRuleID : %#X",stClsEntry.u8PHSI);
1322 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n****************PHS Rule********************\n");
1323 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSI : %#X",stClsEntry.pstPhsRule->u8PHSI);
1324 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSFLength : %#X ",stClsEntry.pstPhsRule->u8PHSFLength);
1325 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSF : ");
1326 for(k=0;k<stClsEntry.pstPhsRule->u8PHSFLength;k++)
1328 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "%#X ",stClsEntry.pstPhsRule->u8PHSF[k]);
1330 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSMLength : %#X",stClsEntry.pstPhsRule->u8PHSMLength);
1331 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSM :");
1332 for(k=0;k<stClsEntry.pstPhsRule->u8PHSMLength;k++)
1334 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "%#X ",stClsEntry.pstPhsRule->u8PHSM[k]);
1336 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSS : %#X ",stClsEntry.pstPhsRule->u8PHSS);
1337 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSV : %#X",stClsEntry.pstPhsRule->u8PHSV);
1338 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\n********************************************\n");
1347 //-----------------------------------------------------------------------------
1348 // Procedure: phs_decompress
1350 // Description: This routine restores the static fields within the packet.
1353 // in_buf - ptr to incoming packet buffer.
1354 // out_buf - ptr to output buffer where the suppressed header is copied.
1355 // decomp_phs_rules - ptr to PHS rule.
1356 // header_size - ptr to field which holds the phss or phsf_length.
1359 // size -The number of bytes of dynamic fields present with in the incoming packet
1361 // 0 -If PHS rule is NULL.If PHSI is 0 indicateing packet as uncompressed.
1362 //-----------------------------------------------------------------------------
1364 int phs_decompress(unsigned char *in_buf,unsigned char *out_buf,
1365 S_PHS_RULE *decomp_phs_rules,UINT *header_size)
1368 S_PHS_RULE *tmp_memb;
1370 unsigned char *phsf,*phsm;
1371 int in_buf_len = *header_size-1;
1372 PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
1374 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECIEVE,DBG_LVL_ALL,"====>\n");
1377 if((decomp_phs_rules == NULL ))
1381 tmp_memb = decomp_phs_rules;
1382 //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECIEVE,DBG_LVL_ALL,"\nDECOMP:In phs_decompress PHSI 1 %d",phsi));
1383 //*header_size = tmp_memb->u8PHSFLength;
1384 phss = tmp_memb->u8PHSS;
1385 phsf = tmp_memb->u8PHSF;
1386 phsm = tmp_memb->u8PHSM;
1388 if(phss > MAX_PHS_LENGTHS)
1389 phss = MAX_PHS_LENGTHS;
1390 //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECIEVE,DBG_LVL_ALL,"\nDECOMP:In phs_decompress PHSI %d phss %d index %d",phsi,phss,index));
1391 while((phss > 0) && (size < in_buf_len))
1393 bit = ((*phsm << i)& SUPPRESS);
1398 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECIEVE,DBG_LVL_ALL,"\nDECOMP:In phss %d phsf %d ouput %d",
1399 phss,*phsf,*out_buf);
1404 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECIEVE,DBG_LVL_ALL,"\nDECOMP:In phss %d input %d ouput %d",
1405 phss,*in_buf,*out_buf);
1413 *header_size=*header_size + 1;
1427 //-----------------------------------------------------------------------------
1428 // Procedure: phs_compress
1430 // Description: This routine suppresses the static fields within the packet.Before
1431 // that it will verify the fields to be suppressed with the corresponding fields in the
1432 // phsf. For verification it checks the phsv field of PHS rule. If set and verification
1433 // succeeds it suppresses the field.If any one static field is found different none of
1434 // the static fields are suppressed then the packet is sent as uncompressed packet with
1438 // phs_rule - ptr to PHS rule.
1439 // in_buf - ptr to incoming packet buffer.
1440 // out_buf - ptr to output buffer where the suppressed header is copied.
1441 // header_size - ptr to field which holds the phss.
1444 // size-The number of bytes copied into the output buffer i.e dynamic fields
1445 // 0 -If PHS rule is NULL.If PHSV field is not set.If the verification fails.
1446 //-----------------------------------------------------------------------------
1447 int phs_compress(S_PHS_RULE *phs_rule,unsigned char *in_buf
1448 ,unsigned char *out_buf,UINT *header_size,UINT *new_header_size)
1450 unsigned char *old_addr = out_buf;
1452 PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
1453 if(phs_rule == NULL)
1455 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nphs_compress(): phs_rule null!");
1456 *out_buf = ZERO_PHSI;
1457 return STATUS_PHS_NOCOMPRESSION;
1461 if(phs_rule->u8PHSS <= *new_header_size)
1463 *header_size = phs_rule->u8PHSS;
1467 *header_size = *new_header_size;
1471 supress = verify_suppress_phsf(in_buf,out_buf,phs_rule->u8PHSF,
1472 phs_rule->u8PHSM, phs_rule->u8PHSS, phs_rule->u8PHSV,new_header_size);
1474 if(supress == STATUS_PHS_COMPRESSED)
1476 *old_addr = (unsigned char)phs_rule->u8PHSI;
1477 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nCOMP:In phs_compress phsi %d",phs_rule->u8PHSI);
1481 *old_addr = ZERO_PHSI;
1482 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nCOMP:In phs_compress PHSV Verification failed");
1488 //-----------------------------------------------------------------------------
1489 // Procedure: verify_suppress_phsf
1491 // Description: This routine verifies the fields of the packet and if all the
1492 // static fields are equal it adds the phsi of that PHS rule.If any static
1493 // field differs it woun't suppress any field.
1496 // rules_set - ptr to classifier_rules.
1497 // in_buffer - ptr to incoming packet buffer.
1498 // out_buffer - ptr to output buffer where the suppressed header is copied.
1499 // phsf - ptr to phsf.
1500 // phsm - ptr to phsm.
1501 // phss - variable holding phss.
1504 // size-The number of bytes copied into the output buffer i.e dynamic fields.
1505 // 0 -Packet has failed the verification.
1506 //-----------------------------------------------------------------------------
1508 int verify_suppress_phsf(unsigned char *in_buffer,unsigned char *out_buffer,
1509 unsigned char *phsf,unsigned char *phsm,unsigned int phss,
1510 unsigned int phsv,UINT* new_header_size)
1512 unsigned int size=0;
1514 PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
1515 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nCOMP:In verify_phsf PHSM - 0x%X",*phsm);
1518 if(phss>(*new_header_size))
1520 phss=*new_header_size;
1524 bit = ((*phsm << i)& SUPPRESS);
1528 if(*in_buffer != *phsf)
1532 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nCOMP:In verify_phsf failed for field %d buf %d phsf %d",phss,*in_buffer,*phsf);
1533 return STATUS_PHS_NOCOMPRESSION;
1537 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nCOMP:In verify_phsf success for field %d buf %d phsf %d",phss,*in_buffer,*phsf);
1541 *out_buffer = *in_buffer;
1542 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nCOMP:In copying_header input %d out %d",*in_buffer,*out_buffer);
1556 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nCOMP:In verify_phsf success");
1557 *new_header_size = size;
1558 return STATUS_PHS_COMPRESSED;