Commit ca89a295 authored by Matthias Beyer's avatar Matthias Beyer Committed by Greg Kroah-Hartman

Staging: bcm: PHSModule.c: Whitespace & Indentation cleanup

Signed-off-by: default avatarMatthias Beyer <mail@beyermatthias.de>
Reviewed-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 495e2be7
#include "headers.h" #include "headers.h"
static UINT CreateSFToClassifierRuleMapping(B_UINT16 uiVcid, B_UINT16 uiClsId, struct bcm_phs_table *psServiceFlowTable, struct bcm_phs_rule *psPhsRule, B_UINT8 u8AssociatedPHSI); static UINT CreateSFToClassifierRuleMapping(B_UINT16 uiVcid,
B_UINT16 uiClsId,
static UINT CreateClassiferToPHSRuleMapping(B_UINT16 uiVcid, B_UINT16 uiClsId, struct bcm_phs_entry *pstServiceFlowEntry, struct bcm_phs_rule *psPhsRule, B_UINT8 u8AssociatedPHSI); struct bcm_phs_table *psServiceFlowTable,
struct bcm_phs_rule *psPhsRule,
static UINT CreateClassifierPHSRule(B_UINT16 uiClsId, struct bcm_phs_classifier_table *psaClassifiertable, struct bcm_phs_rule *psPhsRule, enum bcm_phs_classifier_context eClsContext, B_UINT8 u8AssociatedPHSI); B_UINT8 u8AssociatedPHSI);
static UINT UpdateClassifierPHSRule(B_UINT16 uiClsId, struct bcm_phs_classifier_entry *pstClassifierEntry, struct bcm_phs_classifier_table *psaClassifiertable, struct bcm_phs_rule *psPhsRule, B_UINT8 u8AssociatedPHSI); static UINT CreateClassiferToPHSRuleMapping(B_UINT16 uiVcid,
B_UINT16 uiClsId,
struct bcm_phs_entry *pstServiceFlowEntry,
struct bcm_phs_rule *psPhsRule,
B_UINT8 u8AssociatedPHSI);
static UINT CreateClassifierPHSRule(B_UINT16 uiClsId,
struct bcm_phs_classifier_table *psaClassifiertable,
struct bcm_phs_rule *psPhsRule,
enum bcm_phs_classifier_context eClsContext,
B_UINT8 u8AssociatedPHSI);
static UINT UpdateClassifierPHSRule(B_UINT16 uiClsId,
struct bcm_phs_classifier_entry *pstClassifierEntry,
struct bcm_phs_classifier_table *psaClassifiertable,
struct bcm_phs_rule *psPhsRule,
B_UINT8 u8AssociatedPHSI);
static bool ValidatePHSRuleComplete(struct bcm_phs_rule *psPhsRule); static bool ValidatePHSRuleComplete(struct bcm_phs_rule *psPhsRule);
static bool DerefPhsRule(B_UINT16 uiClsId, struct bcm_phs_classifier_table *psaClassifiertable, struct bcm_phs_rule *pstPhsRule); static bool DerefPhsRule(B_UINT16 uiClsId,
struct bcm_phs_classifier_table *psaClassifiertable,
struct bcm_phs_rule *pstPhsRule);
static UINT GetClassifierEntry(struct bcm_phs_classifier_table *pstClassifierTable, B_UINT32 uiClsid, enum bcm_phs_classifier_context eClsContext, struct bcm_phs_classifier_entry **ppstClassifierEntry); static UINT GetClassifierEntry(struct bcm_phs_classifier_table *pstClassifierTable,
B_UINT32 uiClsid,
enum bcm_phs_classifier_context eClsContext,
struct bcm_phs_classifier_entry **ppstClassifierEntry);
static UINT GetPhsRuleEntry(struct bcm_phs_classifier_table *pstClassifierTable, B_UINT32 uiPHSI, enum bcm_phs_classifier_context eClsContext, struct bcm_phs_rule **ppstPhsRule); static UINT GetPhsRuleEntry(struct bcm_phs_classifier_table *pstClassifierTable,
B_UINT32 uiPHSI,
enum bcm_phs_classifier_context eClsContext,
struct bcm_phs_rule **ppstPhsRule);
static void free_phs_serviceflow_rules(struct bcm_phs_table *psServiceFlowRulesTable); static void free_phs_serviceflow_rules(struct bcm_phs_table *psServiceFlowRulesTable);
static int phs_compress(struct bcm_phs_rule *phs_members, unsigned char *in_buf, static int phs_compress(struct bcm_phs_rule *phs_members,
unsigned char *out_buf, unsigned int *header_size, UINT *new_header_size); unsigned char *in_buf,
unsigned char *out_buf,
unsigned int *header_size,
UINT *new_header_size);
static int verify_suppress_phsf(unsigned char *in_buffer, unsigned char *out_buffer, static int verify_suppress_phsf(unsigned char *in_buffer,
unsigned char *phsf, unsigned char *phsm, unsigned int phss, unsigned int phsv, UINT *new_header_size); unsigned char *out_buffer,
unsigned char *phsf,
unsigned char *phsm,
unsigned int phss,
unsigned int phsv,
UINT *new_header_size);
static int phs_decompress(unsigned char *in_buf, unsigned char *out_buf, static int phs_decompress(unsigned char *in_buf,
struct bcm_phs_rule *phs_rules, UINT *header_size); unsigned char *out_buf,
struct bcm_phs_rule *phs_rules,
UINT *header_size);
static ULONG PhsCompress(void *pvContext, static ULONG PhsCompress(void *pvContext,
B_UINT16 uiVcid, B_UINT16 uiVcid,
B_UINT16 uiClsId, B_UINT16 uiClsId,
void *pvInputBuffer, void *pvInputBuffer,
void *pvOutputBuffer, void *pvOutputBuffer,
UINT *pOldHeaderSize, UINT *pOldHeaderSize,
UINT *pNewHeaderSize); UINT *pNewHeaderSize);
static ULONG PhsDeCompress(void *pvContext, static ULONG PhsDeCompress(void *pvContext,
B_UINT16 uiVcid, B_UINT16 uiVcid,
void *pvInputBuffer, void *pvInputBuffer,
void *pvOutputBuffer, void *pvOutputBuffer,
UINT *pInHeaderSize, UINT *pInHeaderSize,
UINT *pOutHeaderSize); UINT *pOutHeaderSize);
#define IN #define IN
#define OUT #define OUT
...@@ -87,7 +121,8 @@ int PHSTransmit(struct bcm_mini_adapter *Adapter, ...@@ -87,7 +121,8 @@ int PHSTransmit(struct bcm_mini_adapter *Adapter,
struct sk_buff *newPacket = NULL; struct sk_buff *newPacket = NULL;
struct sk_buff *Packet = *pPacket; struct sk_buff *Packet = *pPacket;
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, "In PHSTransmit"); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,
"In PHSTransmit");
if (!bEthCSSupport) if (!bEthCSSupport)
BytesToRemove = ETH_HLEN; BytesToRemove = ETH_HLEN;
...@@ -116,16 +151,22 @@ int PHSTransmit(struct bcm_mini_adapter *Adapter, ...@@ -116,16 +151,22 @@ int PHSTransmit(struct bcm_mini_adapter *Adapter,
(usPacketType == ETHERNET_FRAMETYPE_IPV6)) && (usPacketType == ETHERNET_FRAMETYPE_IPV6)) &&
(bHeaderSuppressionEnabled)) { (bHeaderSuppressionEnabled)) {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, "\nTrying to PHS Compress Using Classifier rule 0x%X", uiClassifierRuleID); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND,
DBG_LVL_ALL,
"\nTrying to PHS Compress Using Classifier rule 0x%X",
uiClassifierRuleID);
unPHSNewPktHeaderLen = unPHSPktHdrBytesCopied; unPHSNewPktHeaderLen = unPHSPktHdrBytesCopied;
ulPhsStatus = PhsCompress(&Adapter->stBCMPhsContext, ulPhsStatus = PhsCompress(&Adapter->stBCMPhsContext,
Vcid, Vcid,
uiClassifierRuleID, uiClassifierRuleID,
pucPHSPktHdrInBuf, pucPHSPktHdrInBuf,
pucPHSPktHdrOutBuf, pucPHSPktHdrOutBuf,
&unPhsOldHdrSize, &unPhsOldHdrSize,
&unPHSNewPktHeaderLen); &unPHSNewPktHeaderLen);
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, "\nPHS Old header Size : %d New Header Size %d\n", unPhsOldHdrSize, unPHSNewPktHeaderLen); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND,
DBG_LVL_ALL,
"\nPHS Old header Size : %d New Header Size %d\n",
unPhsOldHdrSize, unPHSNewPktHeaderLen);
if (unPHSNewPktHeaderLen == unPhsOldHdrSize) { if (unPHSNewPktHeaderLen == unPhsOldHdrSize) {
...@@ -137,7 +178,9 @@ int PHSTransmit(struct bcm_mini_adapter *Adapter, ...@@ -137,7 +178,9 @@ int PHSTransmit(struct bcm_mini_adapter *Adapter,
if (ulPhsStatus == STATUS_PHS_COMPRESSED) { if (ulPhsStatus == STATUS_PHS_COMPRESSED) {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, "PHS Sending packet Compressed"); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS,
PHS_SEND, DBG_LVL_ALL,
"PHS Sending packet Compressed");
if (skb_cloned(Packet)) { if (skb_cloned(Packet)) {
newPacket = skb_copy(Packet, GFP_ATOMIC); newPacket = skb_copy(Packet, GFP_ATOMIC);
...@@ -147,22 +190,32 @@ int PHSTransmit(struct bcm_mini_adapter *Adapter, ...@@ -147,22 +190,32 @@ int PHSTransmit(struct bcm_mini_adapter *Adapter,
dev_kfree_skb(Packet); dev_kfree_skb(Packet);
*pPacket = Packet = newPacket; *pPacket = Packet = newPacket;
pucPHSPktHdrInBuf = Packet->data + BytesToRemove; pucPHSPktHdrInBuf =
Packet->data + BytesToRemove;
} }
numBytesCompressed = unPhsOldHdrSize - (unPHSNewPktHeaderLen + PHSI_LEN); numBytesCompressed = unPhsOldHdrSize -
(unPHSNewPktHeaderLen + PHSI_LEN);
memcpy(pucPHSPktHdrInBuf + numBytesCompressed, pucPHSPktHdrOutBuf, unPHSNewPktHeaderLen + PHSI_LEN); memcpy(pucPHSPktHdrInBuf + numBytesCompressed,
memcpy(Packet->data + numBytesCompressed, Packet->data, BytesToRemove); pucPHSPktHdrOutBuf,
unPHSNewPktHeaderLen + PHSI_LEN);
memcpy(Packet->data + numBytesCompressed,
Packet->data, BytesToRemove);
skb_pull(Packet, numBytesCompressed); skb_pull(Packet, numBytesCompressed);
return STATUS_SUCCESS; return STATUS_SUCCESS;
} else { } else {
/* if one byte headroom is not available, increase it through skb_cow */ /* if one byte headroom is not available,
* increase it through skb_cow
*/
if (!(skb_headroom(Packet) > 0)) { if (!(skb_headroom(Packet) > 0)) {
if (skb_cow(Packet, 1)) { if (skb_cow(Packet, 1)) {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "SKB Cow Failed\n"); BCM_DEBUG_PRINT(Adapter,
DBG_TYPE_PRINTK,
0, 0,
"SKB Cow Failed\n");
return STATUS_FAILURE; return STATUS_FAILURE;
} }
} }
...@@ -179,7 +232,9 @@ int PHSTransmit(struct bcm_mini_adapter *Adapter, ...@@ -179,7 +232,9 @@ int PHSTransmit(struct bcm_mini_adapter *Adapter,
} else { } else {
if (!bHeaderSuppressionEnabled) if (!bHeaderSuppressionEnabled)
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, "\nHeader Suppression Disabled For SF: No PHS\n"); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS,
PHS_SEND, DBG_LVL_ALL,
"\nHeader Suppression Disabled For SF: No PHS\n");
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
...@@ -190,11 +245,11 @@ int PHSTransmit(struct bcm_mini_adapter *Adapter, ...@@ -190,11 +245,11 @@ int PHSTransmit(struct bcm_mini_adapter *Adapter,
} }
int PHSReceive(struct bcm_mini_adapter *Adapter, int PHSReceive(struct bcm_mini_adapter *Adapter,
USHORT usVcid, USHORT usVcid,
struct sk_buff *packet, struct sk_buff *packet,
UINT *punPacketLen, UINT *punPacketLen,
UCHAR *pucEthernetHdr, UCHAR *pucEthernetHdr,
UINT bHeaderSuppressionEnabled) UINT bHeaderSuppressionEnabled)
{ {
u32 nStandardPktHdrLen = 0; u32 nStandardPktHdrLen = 0;
u32 nTotalsuppressedPktHdrBytes = 0; u32 nTotalsuppressedPktHdrBytes = 0;
...@@ -203,7 +258,9 @@ int PHSReceive(struct bcm_mini_adapter *Adapter, ...@@ -203,7 +258,9 @@ int PHSReceive(struct bcm_mini_adapter *Adapter,
UINT TotalBytesAdded = 0; UINT TotalBytesAdded = 0;
if (!bHeaderSuppressionEnabled) { if (!bHeaderSuppressionEnabled) {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, DBG_LVL_ALL, "\nPhs Disabled for incoming packet"); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE,
DBG_LVL_ALL,
"\nPhs Disabled for incoming packet");
return ulPhsStatus; return ulPhsStatus;
} }
...@@ -212,27 +269,31 @@ int PHSReceive(struct bcm_mini_adapter *Adapter, ...@@ -212,27 +269,31 @@ int PHSReceive(struct bcm_mini_adapter *Adapter,
/* Restore PHS suppressed header */ /* Restore PHS suppressed header */
nStandardPktHdrLen = packet->len; nStandardPktHdrLen = packet->len;
ulPhsStatus = PhsDeCompress(&Adapter->stBCMPhsContext, ulPhsStatus = PhsDeCompress(&Adapter->stBCMPhsContext,
usVcid, usVcid,
pucInBuff, pucInBuff,
Adapter->ucaPHSPktRestoreBuf, Adapter->ucaPHSPktRestoreBuf,
&nTotalsuppressedPktHdrBytes, &nTotalsuppressedPktHdrBytes,
&nStandardPktHdrLen); &nStandardPktHdrLen);
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, DBG_LVL_ALL, "\nSuppressed PktHdrLen : 0x%x Restored PktHdrLen : 0x%x", BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, DBG_LVL_ALL,
"\nSuppressed PktHdrLen : 0x%x Restored PktHdrLen : 0x%x",
nTotalsuppressedPktHdrBytes, nStandardPktHdrLen); nTotalsuppressedPktHdrBytes, nStandardPktHdrLen);
if (ulPhsStatus != STATUS_PHS_COMPRESSED) { if (ulPhsStatus != STATUS_PHS_COMPRESSED) {
skb_pull(packet, 1); skb_pull(packet, 1);
return STATUS_SUCCESS; return STATUS_SUCCESS;
} else { } else {
TotalBytesAdded = nStandardPktHdrLen - nTotalsuppressedPktHdrBytes - PHSI_LEN; TotalBytesAdded = nStandardPktHdrLen -
nTotalsuppressedPktHdrBytes - PHSI_LEN;
if (TotalBytesAdded) { if (TotalBytesAdded) {
if (skb_headroom(packet) >= (SKB_RESERVE_ETHERNET_HEADER + TotalBytesAdded)) if (skb_headroom(packet) >= (SKB_RESERVE_ETHERNET_HEADER + TotalBytesAdded))
skb_push(packet, TotalBytesAdded); skb_push(packet, TotalBytesAdded);
else { else {
if (skb_cow(packet, skb_headroom(packet) + TotalBytesAdded)) { if (skb_cow(packet, skb_headroom(packet) + TotalBytesAdded)) {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "cow failed in receive\n"); BCM_DEBUG_PRINT(Adapter,
DBG_TYPE_PRINTK, 0, 0,
"cow failed in receive\n");
return STATUS_FAILURE; return STATUS_FAILURE;
} }
...@@ -240,7 +301,8 @@ int PHSReceive(struct bcm_mini_adapter *Adapter, ...@@ -240,7 +301,8 @@ int PHSReceive(struct bcm_mini_adapter *Adapter,
} }
} }
memcpy(packet->data, Adapter->ucaPHSPktRestoreBuf, nStandardPktHdrLen); memcpy(packet->data, Adapter->ucaPHSPktRestoreBuf,
nStandardPktHdrLen);
} }
return STATUS_SUCCESS; return STATUS_SUCCESS;
...@@ -250,8 +312,10 @@ void DumpFullPacket(UCHAR *pBuf, UINT nPktLen) ...@@ -250,8 +312,10 @@ void DumpFullPacket(UCHAR *pBuf, UINT nPktLen)
{ {
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Dumping Data Packet"); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,
BCM_DEBUG_PRINT_BUFFER(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, pBuf, nPktLen); "Dumping Data Packet");
BCM_DEBUG_PRINT_BUFFER(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,
pBuf, nPktLen);
} }
/* /*
...@@ -267,30 +331,38 @@ void DumpFullPacket(UCHAR *pBuf, UINT nPktLen) ...@@ -267,30 +331,38 @@ void DumpFullPacket(UCHAR *pBuf, UINT nPktLen)
* TRUE(1) -If allocation of memory was successful. * TRUE(1) -If allocation of memory was successful.
* FALSE -If allocation of memory fails. * FALSE -If allocation of memory fails.
*/ */
int phs_init(struct bcm_phs_extension *pPhsdeviceExtension, struct bcm_mini_adapter *Adapter) int phs_init(struct bcm_phs_extension *pPhsdeviceExtension,
struct bcm_mini_adapter *Adapter)
{ {
int i; int i;
struct bcm_phs_table *pstServiceFlowTable; struct bcm_phs_table *pstServiceFlowTable;
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nPHS:phs_init function"); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,
"\nPHS:phs_init function");
if (pPhsdeviceExtension->pstServiceFlowPhsRulesTable) if (pPhsdeviceExtension->pstServiceFlowPhsRulesTable)
return -EINVAL; return -EINVAL;
pPhsdeviceExtension->pstServiceFlowPhsRulesTable = kzalloc(sizeof(struct bcm_phs_table), GFP_KERNEL); pPhsdeviceExtension->pstServiceFlowPhsRulesTable =
kzalloc(sizeof(struct bcm_phs_table), GFP_KERNEL);
if (!pPhsdeviceExtension->pstServiceFlowPhsRulesTable) { if (!pPhsdeviceExtension->pstServiceFlowPhsRulesTable) {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nAllocation ServiceFlowPhsRulesTable failed"); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH,
DBG_LVL_ALL,
"\nAllocation ServiceFlowPhsRulesTable failed");
return -ENOMEM; return -ENOMEM;
} }
pstServiceFlowTable = pPhsdeviceExtension->pstServiceFlowPhsRulesTable; pstServiceFlowTable = pPhsdeviceExtension->pstServiceFlowPhsRulesTable;
for (i = 0; i < MAX_SERVICEFLOWS; i++) { for (i = 0; i < MAX_SERVICEFLOWS; i++) {
struct bcm_phs_entry sServiceFlow = pstServiceFlowTable->stSFList[i]; struct bcm_phs_entry sServiceFlow =
pstServiceFlowTable->stSFList[i];
sServiceFlow.pstClassifierTable = kzalloc(sizeof(struct bcm_phs_classifier_table), GFP_KERNEL); sServiceFlow.pstClassifierTable =
kzalloc(sizeof(struct bcm_phs_classifier_table),
GFP_KERNEL);
if (!sServiceFlow.pstClassifierTable) { if (!sServiceFlow.pstClassifierTable) {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nAllocation failed"); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH,
DBG_LVL_ALL, "\nAllocation failed");
free_phs_serviceflow_rules(pPhsdeviceExtension->pstServiceFlowPhsRulesTable); free_phs_serviceflow_rules(pPhsdeviceExtension->pstServiceFlowPhsRulesTable);
pPhsdeviceExtension->pstServiceFlowPhsRulesTable = NULL; pPhsdeviceExtension->pstServiceFlowPhsRulesTable = NULL;
return -ENOMEM; return -ENOMEM;
...@@ -299,22 +371,26 @@ int phs_init(struct bcm_phs_extension *pPhsdeviceExtension, struct bcm_mini_adap ...@@ -299,22 +371,26 @@ int phs_init(struct bcm_phs_extension *pPhsdeviceExtension, struct bcm_mini_adap
pPhsdeviceExtension->CompressedTxBuffer = kmalloc(PHS_BUFFER_SIZE, GFP_KERNEL); pPhsdeviceExtension->CompressedTxBuffer = kmalloc(PHS_BUFFER_SIZE, GFP_KERNEL);
if (pPhsdeviceExtension->CompressedTxBuffer == NULL) { if (pPhsdeviceExtension->CompressedTxBuffer == NULL) {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nAllocation failed"); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH,
DBG_LVL_ALL, "\nAllocation failed");
free_phs_serviceflow_rules(pPhsdeviceExtension->pstServiceFlowPhsRulesTable); free_phs_serviceflow_rules(pPhsdeviceExtension->pstServiceFlowPhsRulesTable);
pPhsdeviceExtension->pstServiceFlowPhsRulesTable = NULL; pPhsdeviceExtension->pstServiceFlowPhsRulesTable = NULL;
return -ENOMEM; return -ENOMEM;
} }
pPhsdeviceExtension->UnCompressedRxBuffer = kmalloc(PHS_BUFFER_SIZE, GFP_KERNEL); pPhsdeviceExtension->UnCompressedRxBuffer =
kmalloc(PHS_BUFFER_SIZE, GFP_KERNEL);
if (pPhsdeviceExtension->UnCompressedRxBuffer == NULL) { if (pPhsdeviceExtension->UnCompressedRxBuffer == NULL) {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nAllocation failed"); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH,
DBG_LVL_ALL, "\nAllocation failed");
kfree(pPhsdeviceExtension->CompressedTxBuffer); kfree(pPhsdeviceExtension->CompressedTxBuffer);
free_phs_serviceflow_rules(pPhsdeviceExtension->pstServiceFlowPhsRulesTable); free_phs_serviceflow_rules(pPhsdeviceExtension->pstServiceFlowPhsRulesTable);
pPhsdeviceExtension->pstServiceFlowPhsRulesTable = NULL; pPhsdeviceExtension->pstServiceFlowPhsRulesTable = NULL;
return -ENOMEM; return -ENOMEM;
} }
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\n phs_init Successful"); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,
"\n phs_init Successful");
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
...@@ -353,10 +429,10 @@ int PhsCleanup(IN struct bcm_phs_extension *pPHSDeviceExt) ...@@ -353,10 +429,10 @@ int PhsCleanup(IN struct bcm_phs_extension *pPHSDeviceExt)
* >0 Error. * >0 Error.
*/ */
ULONG PhsUpdateClassifierRule(IN void *pvContext, ULONG PhsUpdateClassifierRule(IN void *pvContext,
IN B_UINT16 uiVcid , IN B_UINT16 uiVcid ,
IN B_UINT16 uiClsId , IN B_UINT16 uiClsId ,
IN struct bcm_phs_rule *psPhsRule, IN struct bcm_phs_rule *psPhsRule,
IN B_UINT8 u8AssociatedPHSI) IN B_UINT8 u8AssociatedPHSI)
{ {
ULONG lStatus = 0; ULONG lStatus = 0;
UINT nSFIndex = 0; UINT nSFIndex = 0;
...@@ -364,10 +440,12 @@ ULONG PhsUpdateClassifierRule(IN void *pvContext, ...@@ -364,10 +440,12 @@ ULONG PhsUpdateClassifierRule(IN void *pvContext,
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
struct bcm_phs_extension *pDeviceExtension = (struct bcm_phs_extension *)pvContext; struct bcm_phs_extension *pDeviceExtension = (struct bcm_phs_extension *)pvContext;
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "PHS With Corr2 Changes\n"); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,
"PHS With Corr2 Changes\n");
if (pDeviceExtension == NULL) { if (pDeviceExtension == NULL) {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "Invalid Device Extension\n"); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH,
DBG_LVL_ALL, "Invalid Device Extension\n");
return ERR_PHS_INVALID_DEVICE_EXETENSION; return ERR_PHS_INVALID_DEVICE_EXETENSION;
} }
...@@ -376,18 +454,22 @@ ULONG PhsUpdateClassifierRule(IN void *pvContext, ...@@ -376,18 +454,22 @@ ULONG PhsUpdateClassifierRule(IN void *pvContext,
/* Retrieve the SFID Entry Index for requested Service Flow */ /* Retrieve the SFID Entry Index for requested Service Flow */
nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable, nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable,
uiVcid, &pstServiceFlowEntry); uiVcid, &pstServiceFlowEntry);
if (nSFIndex == PHS_INVALID_TABLE_INDEX) { if (nSFIndex == PHS_INVALID_TABLE_INDEX) {
/* This is a new SF. Create a mapping entry for this */ /* This is a new SF. Create a mapping entry for this */
lStatus = CreateSFToClassifierRuleMapping(uiVcid, uiClsId, lStatus = CreateSFToClassifierRuleMapping(uiVcid, uiClsId,
pDeviceExtension->pstServiceFlowPhsRulesTable, psPhsRule, u8AssociatedPHSI); pDeviceExtension->pstServiceFlowPhsRulesTable,
psPhsRule,
u8AssociatedPHSI);
return lStatus; return lStatus;
} }
/* SF already Exists Add PHS Rule to existing SF */ /* SF already Exists Add PHS Rule to existing SF */
lStatus = CreateClassiferToPHSRuleMapping(uiVcid, uiClsId, lStatus = CreateClassiferToPHSRuleMapping(uiVcid, uiClsId,
pstServiceFlowEntry, psPhsRule, u8AssociatedPHSI); pstServiceFlowEntry,
psPhsRule,
u8AssociatedPHSI);
return lStatus; return lStatus;
} }
...@@ -408,7 +490,9 @@ ULONG PhsUpdateClassifierRule(IN void *pvContext, ...@@ -408,7 +490,9 @@ ULONG PhsUpdateClassifierRule(IN void *pvContext,
* 0 if successful, * 0 if successful,
* >0 Error. * >0 Error.
*/ */
ULONG PhsDeletePHSRule(IN void *pvContext, IN B_UINT16 uiVcid, IN B_UINT8 u8PHSI) ULONG PhsDeletePHSRule(IN void *pvContext,
IN B_UINT16 uiVcid,
IN B_UINT8 u8PHSI)
{ {
UINT nSFIndex = 0, nClsidIndex = 0; UINT nSFIndex = 0, nClsidIndex = 0;
struct bcm_phs_entry *pstServiceFlowEntry = NULL; struct bcm_phs_entry *pstServiceFlowEntry = NULL;
...@@ -416,14 +500,17 @@ ULONG PhsDeletePHSRule(IN void *pvContext, IN B_UINT16 uiVcid, IN B_UINT8 u8PHSI ...@@ -416,14 +500,17 @@ ULONG PhsDeletePHSRule(IN void *pvContext, IN B_UINT16 uiVcid, IN B_UINT8 u8PHSI
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
struct bcm_phs_extension *pDeviceExtension = (struct bcm_phs_extension *)pvContext; struct bcm_phs_extension *pDeviceExtension = (struct bcm_phs_extension *)pvContext;
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "======>\n"); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,
"======>\n");
if (pDeviceExtension) { if (pDeviceExtension) {
/* Retrieve the SFID Entry Index for requested Service Flow */ /* Retrieve the SFID Entry Index for requested Service Flow */
nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable, uiVcid, &pstServiceFlowEntry); nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable,
uiVcid, &pstServiceFlowEntry);
if (nSFIndex == PHS_INVALID_TABLE_INDEX) { if (nSFIndex == PHS_INVALID_TABLE_INDEX) {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "SFID Match Failed\n"); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH,
DBG_LVL_ALL, "SFID Match Failed\n");
return ERR_SF_MATCH_FAIL; return ERR_SF_MATCH_FAIL;
} }
...@@ -439,8 +526,9 @@ ULONG PhsDeletePHSRule(IN void *pvContext, IN B_UINT16 uiVcid, IN B_UINT8 u8PHSI ...@@ -439,8 +526,9 @@ ULONG PhsDeletePHSRule(IN void *pvContext, IN B_UINT16 uiVcid, IN B_UINT8 u8PHSI
if (0 == pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule->u8RefCnt) if (0 == pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule->u8RefCnt)
kfree(pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule); kfree(pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule);
memset(&pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex], 0, memset(&pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex],
sizeof(struct bcm_phs_classifier_entry)); 0,
sizeof(struct bcm_phs_classifier_entry));
} }
} }
} }
...@@ -471,18 +559,23 @@ ULONG PhsDeleteClassifierRule(IN void *pvContext, IN B_UINT16 uiVcid, IN B_UINT1 ...@@ -471,18 +559,23 @@ ULONG PhsDeleteClassifierRule(IN void *pvContext, IN B_UINT16 uiVcid, IN B_UINT1
struct bcm_phs_entry *pstServiceFlowEntry = NULL; struct bcm_phs_entry *pstServiceFlowEntry = NULL;
struct bcm_phs_classifier_entry *pstClassifierEntry = NULL; struct bcm_phs_classifier_entry *pstClassifierEntry = NULL;
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
struct bcm_phs_extension *pDeviceExtension = (struct bcm_phs_extension *)pvContext; struct bcm_phs_extension *pDeviceExtension =
(struct bcm_phs_extension *)pvContext;
if (pDeviceExtension) { if (pDeviceExtension) {
/* Retrieve the SFID Entry Index for requested Service Flow */ /* Retrieve the SFID Entry Index for requested Service Flow */
nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable, uiVcid, &pstServiceFlowEntry); nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable,
uiVcid, &pstServiceFlowEntry);
if (nSFIndex == PHS_INVALID_TABLE_INDEX) { if (nSFIndex == PHS_INVALID_TABLE_INDEX) {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "SFID Match Failed\n"); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH,
DBG_LVL_ALL, "SFID Match Failed\n");
return ERR_SF_MATCH_FAIL; return ERR_SF_MATCH_FAIL;
} }
nClsidIndex = GetClassifierEntry(pstServiceFlowEntry->pstClassifierTable, nClsidIndex = GetClassifierEntry(pstServiceFlowEntry->pstClassifierTable,
uiClsId, eActiveClassifierRuleContext, &pstClassifierEntry); uiClsId,
eActiveClassifierRuleContext,
&pstClassifierEntry);
if ((nClsidIndex != PHS_INVALID_TABLE_INDEX) && (!pstClassifierEntry->bUnclassifiedPHSRule)) { if ((nClsidIndex != PHS_INVALID_TABLE_INDEX) && (!pstClassifierEntry->bUnclassifiedPHSRule)) {
if (pstClassifierEntry->pstPhsRule) { if (pstClassifierEntry->pstPhsRule) {
...@@ -492,15 +585,19 @@ ULONG PhsDeleteClassifierRule(IN void *pvContext, IN B_UINT16 uiVcid, IN B_UINT1 ...@@ -492,15 +585,19 @@ ULONG PhsDeleteClassifierRule(IN void *pvContext, IN B_UINT16 uiVcid, IN B_UINT1
if (0 == pstClassifierEntry->pstPhsRule->u8RefCnt) if (0 == pstClassifierEntry->pstPhsRule->u8RefCnt)
kfree(pstClassifierEntry->pstPhsRule); kfree(pstClassifierEntry->pstPhsRule);
} }
memset(pstClassifierEntry, 0, sizeof(struct bcm_phs_classifier_entry)); memset(pstClassifierEntry, 0,
sizeof(struct bcm_phs_classifier_entry));
} }
nClsidIndex = GetClassifierEntry(pstServiceFlowEntry->pstClassifierTable, nClsidIndex = GetClassifierEntry(pstServiceFlowEntry->pstClassifierTable,
uiClsId, eOldClassifierRuleContext, &pstClassifierEntry); uiClsId,
eOldClassifierRuleContext,
&pstClassifierEntry);
if ((nClsidIndex != PHS_INVALID_TABLE_INDEX) && (!pstClassifierEntry->bUnclassifiedPHSRule)) { if ((nClsidIndex != PHS_INVALID_TABLE_INDEX) && (!pstClassifierEntry->bUnclassifiedPHSRule)) {
kfree(pstClassifierEntry->pstPhsRule); kfree(pstClassifierEntry->pstPhsRule);
memset(pstClassifierEntry, 0, sizeof(struct bcm_phs_classifier_entry)); memset(pstClassifierEntry, 0,
sizeof(struct bcm_phs_classifier_entry));
} }
} }
return 0; return 0;
...@@ -527,16 +624,19 @@ ULONG PhsDeleteSFRules(IN void *pvContext, IN B_UINT16 uiVcid) ...@@ -527,16 +624,19 @@ ULONG PhsDeleteSFRules(IN void *pvContext, IN B_UINT16 uiVcid)
struct bcm_phs_entry *pstServiceFlowEntry = NULL; struct bcm_phs_entry *pstServiceFlowEntry = NULL;
struct bcm_phs_classifier_table *pstClassifierRulesTable = NULL; struct bcm_phs_classifier_table *pstClassifierRulesTable = NULL;
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
struct bcm_phs_extension *pDeviceExtension = (struct bcm_phs_extension *)pvContext; struct bcm_phs_extension *pDeviceExtension =
(struct bcm_phs_extension *)pvContext;
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "====>\n"); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,
"====>\n");
if (pDeviceExtension) { if (pDeviceExtension) {
/* Retrieve the SFID Entry Index for requested Service Flow */ /* Retrieve the SFID Entry Index for requested Service Flow */
nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable, nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable,
uiVcid, &pstServiceFlowEntry); uiVcid, &pstServiceFlowEntry);
if (nSFIndex == PHS_INVALID_TABLE_INDEX) { if (nSFIndex == PHS_INVALID_TABLE_INDEX) {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "SFID Match Failed\n"); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH,
DBG_LVL_ALL, "SFID Match Failed\n");
return ERR_SF_MATCH_FAIL; return ERR_SF_MATCH_FAIL;
} }
...@@ -553,7 +653,8 @@ ULONG PhsDeleteSFRules(IN void *pvContext, IN B_UINT16 uiVcid) ...@@ -553,7 +653,8 @@ ULONG PhsDeleteSFRules(IN void *pvContext, IN B_UINT16 uiVcid)
pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule = NULL; pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule = NULL;
} }
memset(&pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex], 0, sizeof(struct bcm_phs_classifier_entry)); memset(&pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex],
0, sizeof(struct bcm_phs_classifier_entry));
if (pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex].pstPhsRule) { if (pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex].pstPhsRule) {
if (pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex].pstPhsRule->u8RefCnt) if (pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex].pstPhsRule->u8RefCnt)
...@@ -564,7 +665,8 @@ ULONG PhsDeleteSFRules(IN void *pvContext, IN B_UINT16 uiVcid) ...@@ -564,7 +665,8 @@ ULONG PhsDeleteSFRules(IN void *pvContext, IN B_UINT16 uiVcid)
pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex].pstPhsRule = NULL; pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex].pstPhsRule = NULL;
} }
memset(&pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex], 0, sizeof(struct bcm_phs_classifier_entry)); memset(&pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex],
0, sizeof(struct bcm_phs_classifier_entry));
} }
} }
pstServiceFlowEntry->bUsed = false; pstServiceFlowEntry->bUsed = false;
...@@ -595,12 +697,12 @@ ULONG PhsDeleteSFRules(IN void *pvContext, IN B_UINT16 uiVcid) ...@@ -595,12 +697,12 @@ ULONG PhsDeleteSFRules(IN void *pvContext, IN B_UINT16 uiVcid)
* >0 Error. * >0 Error.
*/ */
static ULONG PhsCompress(IN void *pvContext, static ULONG PhsCompress(IN void *pvContext,
IN B_UINT16 uiVcid, IN B_UINT16 uiVcid,
IN B_UINT16 uiClsId, IN B_UINT16 uiClsId,
IN void *pvInputBuffer, IN void *pvInputBuffer,
OUT void *pvOutputBuffer, OUT void *pvOutputBuffer,
OUT UINT *pOldHeaderSize, OUT UINT *pOldHeaderSize,
OUT UINT *pNewHeaderSize) OUT UINT *pNewHeaderSize)
{ {
UINT nSFIndex = 0, nClsidIndex = 0; UINT nSFIndex = 0, nClsidIndex = 0;
struct bcm_phs_entry *pstServiceFlowEntry = NULL; struct bcm_phs_entry *pstServiceFlowEntry = NULL;
...@@ -608,30 +710,36 @@ static ULONG PhsCompress(IN void *pvContext, ...@@ -608,30 +710,36 @@ static ULONG PhsCompress(IN void *pvContext,
struct bcm_phs_rule *pstPhsRule = NULL; struct bcm_phs_rule *pstPhsRule = NULL;
ULONG lStatus = 0; ULONG lStatus = 0;
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
struct bcm_phs_extension *pDeviceExtension = (struct bcm_phs_extension *)pvContext; struct bcm_phs_extension *pDeviceExtension =
(struct bcm_phs_extension *)pvContext;
if (pDeviceExtension == NULL) { if (pDeviceExtension == NULL) {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, "Invalid Device Extension\n"); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,
"Invalid Device Extension\n");
lStatus = STATUS_PHS_NOCOMPRESSION; lStatus = STATUS_PHS_NOCOMPRESSION;
return lStatus; return lStatus;
} }
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, "Suppressing header\n"); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,
"Suppressing header\n");
/* Retrieve the SFID Entry Index for requested Service Flow */ /* Retrieve the SFID Entry Index for requested Service Flow */
nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable, nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable,
uiVcid, &pstServiceFlowEntry); uiVcid, &pstServiceFlowEntry);
if (nSFIndex == PHS_INVALID_TABLE_INDEX) { if (nSFIndex == PHS_INVALID_TABLE_INDEX) {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, "SFID Match Failed\n"); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,
"SFID Match Failed\n");
lStatus = STATUS_PHS_NOCOMPRESSION; lStatus = STATUS_PHS_NOCOMPRESSION;
return lStatus; return lStatus;
} }
nClsidIndex = GetClassifierEntry(pstServiceFlowEntry->pstClassifierTable, nClsidIndex = GetClassifierEntry(pstServiceFlowEntry->pstClassifierTable,
uiClsId, eActiveClassifierRuleContext, &pstClassifierEntry); uiClsId, eActiveClassifierRuleContext,
&pstClassifierEntry);
if (nClsidIndex == PHS_INVALID_TABLE_INDEX) { if (nClsidIndex == PHS_INVALID_TABLE_INDEX) {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, "No PHS Rule Defined For Classifier\n"); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,
"No PHS Rule Defined For Classifier\n");
lStatus = STATUS_PHS_NOCOMPRESSION; lStatus = STATUS_PHS_NOCOMPRESSION;
return lStatus; return lStatus;
} }
...@@ -639,7 +747,8 @@ static ULONG PhsCompress(IN void *pvContext, ...@@ -639,7 +747,8 @@ static ULONG PhsCompress(IN void *pvContext,
/* get rule from SF id,Cls ID pair and proceed */ /* get rule from SF id,Cls ID pair and proceed */
pstPhsRule = pstClassifierEntry->pstPhsRule; pstPhsRule = pstClassifierEntry->pstPhsRule;
if (!ValidatePHSRuleComplete(pstPhsRule)) { if (!ValidatePHSRuleComplete(pstPhsRule)) {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "PHS Rule Defined For Classifier But Not Complete\n"); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,
"PHS Rule Defined For Classifier But Not Complete\n");
lStatus = STATUS_PHS_NOCOMPRESSION; lStatus = STATUS_PHS_NOCOMPRESSION;
return lStatus; return lStatus;
} }
...@@ -649,7 +758,8 @@ static ULONG PhsCompress(IN void *pvContext, ...@@ -649,7 +758,8 @@ static ULONG PhsCompress(IN void *pvContext,
(PUCHAR)pvOutputBuffer, pOldHeaderSize, pNewHeaderSize); (PUCHAR)pvOutputBuffer, pOldHeaderSize, pNewHeaderSize);
if (lStatus == STATUS_PHS_COMPRESSED) { if (lStatus == STATUS_PHS_COMPRESSED) {
pstPhsRule->PHSModifiedBytes += *pOldHeaderSize - *pNewHeaderSize - 1; pstPhsRule->PHSModifiedBytes +=
*pOldHeaderSize - *pNewHeaderSize - 1;
pstPhsRule->PHSModifiedNumPackets++; pstPhsRule->PHSModifiedNumPackets++;
} else } else
pstPhsRule->PHSErrorNumPackets++; pstPhsRule->PHSErrorNumPackets++;
...@@ -676,52 +786,64 @@ static ULONG PhsCompress(IN void *pvContext, ...@@ -676,52 +786,64 @@ static ULONG PhsCompress(IN void *pvContext,
* >0 Error. * >0 Error.
*/ */
static ULONG PhsDeCompress(IN void *pvContext, static ULONG PhsDeCompress(IN void *pvContext,
IN B_UINT16 uiVcid, IN B_UINT16 uiVcid,
IN void *pvInputBuffer, IN void *pvInputBuffer,
OUT void *pvOutputBuffer, OUT void *pvOutputBuffer,
OUT UINT *pInHeaderSize, OUT UINT *pInHeaderSize,
OUT UINT *pOutHeaderSize) OUT UINT *pOutHeaderSize)
{ {
UINT nSFIndex = 0, nPhsRuleIndex = 0; UINT nSFIndex = 0, nPhsRuleIndex = 0;
struct bcm_phs_entry *pstServiceFlowEntry = NULL; struct bcm_phs_entry *pstServiceFlowEntry = NULL;
struct bcm_phs_rule *pstPhsRule = NULL; struct bcm_phs_rule *pstPhsRule = NULL;
UINT phsi; UINT phsi;
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
struct bcm_phs_extension *pDeviceExtension = (struct bcm_phs_extension *)pvContext; struct bcm_phs_extension *pDeviceExtension =
(struct bcm_phs_extension *)pvContext;
*pInHeaderSize = 0; *pInHeaderSize = 0;
if (pDeviceExtension == NULL) { if (pDeviceExtension == NULL) {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, DBG_LVL_ALL, "Invalid Device Extension\n"); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE,
DBG_LVL_ALL, "Invalid Device Extension\n");
return ERR_PHS_INVALID_DEVICE_EXETENSION; return ERR_PHS_INVALID_DEVICE_EXETENSION;
} }
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, DBG_LVL_ALL, "Restoring header\n"); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, DBG_LVL_ALL,
"Restoring header\n");
phsi = *((unsigned char *)(pvInputBuffer)); phsi = *((unsigned char *)(pvInputBuffer));
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, DBG_LVL_ALL, "PHSI To Be Used For restore : %x\n", phsi); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, DBG_LVL_ALL,
"PHSI To Be Used For restore : %x\n", phsi);
if (phsi == UNCOMPRESSED_PACKET) if (phsi == UNCOMPRESSED_PACKET)
return STATUS_PHS_NOCOMPRESSION; return STATUS_PHS_NOCOMPRESSION;
/* Retrieve the SFID Entry Index for requested Service Flow */ /* Retrieve the SFID Entry Index for requested Service Flow */
nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable, nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable,
uiVcid, &pstServiceFlowEntry); uiVcid, &pstServiceFlowEntry);
if (nSFIndex == PHS_INVALID_TABLE_INDEX) { if (nSFIndex == PHS_INVALID_TABLE_INDEX) {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, DBG_LVL_ALL, "SFID Match Failed During Lookup\n"); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE,
DBG_LVL_ALL,
"SFID Match Failed During Lookup\n");
return ERR_SF_MATCH_FAIL; return ERR_SF_MATCH_FAIL;
} }
nPhsRuleIndex = GetPhsRuleEntry(pstServiceFlowEntry->pstClassifierTable, phsi, nPhsRuleIndex = GetPhsRuleEntry(pstServiceFlowEntry->pstClassifierTable,
eActiveClassifierRuleContext, &pstPhsRule); phsi,
eActiveClassifierRuleContext,
&pstPhsRule);
if (nPhsRuleIndex == PHS_INVALID_TABLE_INDEX) { if (nPhsRuleIndex == PHS_INVALID_TABLE_INDEX) {
/* Phs Rule does not exist in active rules table. Lets try in the old rules table. */ /* Phs Rule does not exist in active rules table. Lets try in the old rules table. */
nPhsRuleIndex = GetPhsRuleEntry(pstServiceFlowEntry->pstClassifierTable, nPhsRuleIndex = GetPhsRuleEntry(pstServiceFlowEntry->pstClassifierTable,
phsi, eOldClassifierRuleContext, &pstPhsRule); phsi,
eOldClassifierRuleContext,
&pstPhsRule);
if (nPhsRuleIndex == PHS_INVALID_TABLE_INDEX) if (nPhsRuleIndex == PHS_INVALID_TABLE_INDEX)
return ERR_PHSRULE_MATCH_FAIL; return ERR_PHSRULE_MATCH_FAIL;
} }
*pInHeaderSize = phs_decompress((PUCHAR)pvInputBuffer, *pInHeaderSize = phs_decompress((PUCHAR)pvInputBuffer,
(PUCHAR)pvOutputBuffer, pstPhsRule, pOutHeaderSize); (PUCHAR)pvOutputBuffer,
pstPhsRule,
pOutHeaderSize);
pstPhsRule->PHSModifiedBytes += *pOutHeaderSize - *pInHeaderSize - 1; pstPhsRule->PHSModifiedBytes += *pOutHeaderSize - *pInHeaderSize - 1;
...@@ -745,12 +867,15 @@ static void free_phs_serviceflow_rules(struct bcm_phs_table *psServiceFlowRulesT ...@@ -745,12 +867,15 @@ static void free_phs_serviceflow_rules(struct bcm_phs_table *psServiceFlowRulesT
int i, j; int i, j;
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "=======>\n"); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,
"=======>\n");
if (psServiceFlowRulesTable) { if (psServiceFlowRulesTable) {
for (i = 0; i < MAX_SERVICEFLOWS; i++) { for (i = 0; i < MAX_SERVICEFLOWS; i++) {
struct bcm_phs_entry stServiceFlowEntry = psServiceFlowRulesTable->stSFList[i]; struct bcm_phs_entry stServiceFlowEntry =
struct bcm_phs_classifier_table *pstClassifierRulesTable = stServiceFlowEntry.pstClassifierTable; psServiceFlowRulesTable->stSFList[i];
struct bcm_phs_classifier_table *pstClassifierRulesTable =
stServiceFlowEntry.pstClassifierTable;
if (pstClassifierRulesTable) { if (pstClassifierRulesTable) {
for (j = 0; j < MAX_PHSRULE_PER_SF; j++) { for (j = 0; j < MAX_PHSRULE_PER_SF; j++) {
...@@ -777,7 +902,8 @@ static void free_phs_serviceflow_rules(struct bcm_phs_table *psServiceFlowRulesT ...@@ -777,7 +902,8 @@ static void free_phs_serviceflow_rules(struct bcm_phs_table *psServiceFlowRulesT
} }
} }
kfree(pstClassifierRulesTable); kfree(pstClassifierRulesTable);
stServiceFlowEntry.pstClassifierTable = pstClassifierRulesTable = NULL; stServiceFlowEntry.pstClassifierTable =
pstClassifierRulesTable = NULL;
} }
} }
} }
...@@ -809,15 +935,16 @@ static bool ValidatePHSRuleComplete(IN struct bcm_phs_rule *psPhsRule) ...@@ -809,15 +935,16 @@ static bool ValidatePHSRuleComplete(IN struct bcm_phs_rule *psPhsRule)
} }
UINT GetServiceFlowEntry(IN struct bcm_phs_table *psServiceFlowTable, UINT GetServiceFlowEntry(IN struct bcm_phs_table *psServiceFlowTable,
IN B_UINT16 uiVcid, IN B_UINT16 uiVcid,
struct bcm_phs_entry **ppstServiceFlowEntry) struct bcm_phs_entry **ppstServiceFlowEntry)
{ {
int i; int i;
for (i = 0; i < MAX_SERVICEFLOWS; i++) { for (i = 0; i < MAX_SERVICEFLOWS; i++) {
if (psServiceFlowTable->stSFList[i].bUsed) { if (psServiceFlowTable->stSFList[i].bUsed) {
if (psServiceFlowTable->stSFList[i].uiVcid == uiVcid) { if (psServiceFlowTable->stSFList[i].uiVcid == uiVcid) {
*ppstServiceFlowEntry = &psServiceFlowTable->stSFList[i]; *ppstServiceFlowEntry =
&psServiceFlowTable->stSFList[i];
return i; return i;
} }
} }
...@@ -828,8 +955,9 @@ UINT GetServiceFlowEntry(IN struct bcm_phs_table *psServiceFlowTable, ...@@ -828,8 +955,9 @@ UINT GetServiceFlowEntry(IN struct bcm_phs_table *psServiceFlowTable,
} }
static UINT GetClassifierEntry(IN struct bcm_phs_classifier_table *pstClassifierTable, static UINT GetClassifierEntry(IN struct bcm_phs_classifier_table *pstClassifierTable,
IN B_UINT32 uiClsid, enum bcm_phs_classifier_context eClsContext, IN B_UINT32 uiClsid,
OUT struct bcm_phs_classifier_entry **ppstClassifierEntry) enum bcm_phs_classifier_context eClsContext,
OUT struct bcm_phs_classifier_entry **ppstClassifierEntry)
{ {
int i; int i;
struct bcm_phs_classifier_entry *psClassifierRules = NULL; struct bcm_phs_classifier_entry *psClassifierRules = NULL;
...@@ -837,9 +965,11 @@ static UINT GetClassifierEntry(IN struct bcm_phs_classifier_table *pstClassifier ...@@ -837,9 +965,11 @@ static UINT GetClassifierEntry(IN struct bcm_phs_classifier_table *pstClassifier
for (i = 0; i < MAX_PHSRULE_PER_SF; i++) { for (i = 0; i < MAX_PHSRULE_PER_SF; i++) {
if (eClsContext == eActiveClassifierRuleContext) if (eClsContext == eActiveClassifierRuleContext)
psClassifierRules = &pstClassifierTable->stActivePhsRulesList[i]; psClassifierRules =
&pstClassifierTable->stActivePhsRulesList[i];
else else
psClassifierRules = &pstClassifierTable->stOldPhsRulesList[i]; psClassifierRules =
&pstClassifierTable->stOldPhsRulesList[i];
if (psClassifierRules->bUsed) { if (psClassifierRules->bUsed) {
if (psClassifierRules->uiClassifierRuleId == uiClsid) { if (psClassifierRules->uiClassifierRuleId == uiClsid) {
...@@ -854,17 +984,20 @@ static UINT GetClassifierEntry(IN struct bcm_phs_classifier_table *pstClassifier ...@@ -854,17 +984,20 @@ static UINT GetClassifierEntry(IN struct bcm_phs_classifier_table *pstClassifier
} }
static UINT GetPhsRuleEntry(IN struct bcm_phs_classifier_table *pstClassifierTable, static UINT GetPhsRuleEntry(IN struct bcm_phs_classifier_table *pstClassifierTable,
IN B_UINT32 uiPHSI, enum bcm_phs_classifier_context eClsContext, IN B_UINT32 uiPHSI,
OUT struct bcm_phs_rule **ppstPhsRule) enum bcm_phs_classifier_context eClsContext,
OUT struct bcm_phs_rule **ppstPhsRule)
{ {
int i; int i;
struct bcm_phs_classifier_entry *pstClassifierRule = NULL; struct bcm_phs_classifier_entry *pstClassifierRule = NULL;
for (i = 0; i < MAX_PHSRULE_PER_SF; i++) { for (i = 0; i < MAX_PHSRULE_PER_SF; i++) {
if (eClsContext == eActiveClassifierRuleContext) if (eClsContext == eActiveClassifierRuleContext)
pstClassifierRule = &pstClassifierTable->stActivePhsRulesList[i]; pstClassifierRule =
&pstClassifierTable->stActivePhsRulesList[i];
else else
pstClassifierRule = &pstClassifierTable->stOldPhsRulesList[i]; pstClassifierRule =
&pstClassifierTable->stOldPhsRulesList[i];
if (pstClassifierRule->bUsed) { if (pstClassifierRule->bUsed) {
if (pstClassifierRule->u8PHSI == uiPHSI) { if (pstClassifierRule->u8PHSI == uiPHSI) {
...@@ -878,10 +1011,11 @@ static UINT GetPhsRuleEntry(IN struct bcm_phs_classifier_table *pstClassifierTab ...@@ -878,10 +1011,11 @@ static UINT GetPhsRuleEntry(IN struct bcm_phs_classifier_table *pstClassifierTab
return PHS_INVALID_TABLE_INDEX; return PHS_INVALID_TABLE_INDEX;
} }
static UINT CreateSFToClassifierRuleMapping(IN B_UINT16 uiVcid, IN B_UINT16 uiClsId, static UINT CreateSFToClassifierRuleMapping(IN B_UINT16 uiVcid,
IN struct bcm_phs_table *psServiceFlowTable, IN B_UINT16 uiClsId,
struct bcm_phs_rule *psPhsRule, IN struct bcm_phs_table *psServiceFlowTable,
B_UINT8 u8AssociatedPHSI) struct bcm_phs_rule *psPhsRule,
B_UINT8 u8AssociatedPHSI)
{ {
struct bcm_phs_classifier_table *psaClassifiertable = NULL; struct bcm_phs_classifier_table *psaClassifiertable = NULL;
UINT uiStatus = 0; UINT uiStatus = 0;
...@@ -899,8 +1033,10 @@ static UINT CreateSFToClassifierRuleMapping(IN B_UINT16 uiVcid, IN B_UINT16 uiC ...@@ -899,8 +1033,10 @@ static UINT CreateSFToClassifierRuleMapping(IN B_UINT16 uiVcid, IN B_UINT16 uiC
if (!bFreeEntryFound) if (!bFreeEntryFound)
return ERR_SFTABLE_FULL; return ERR_SFTABLE_FULL;
psaClassifiertable = psServiceFlowTable->stSFList[iSfIndex].pstClassifierTable; psaClassifiertable =
uiStatus = CreateClassifierPHSRule(uiClsId, psaClassifiertable, psPhsRule, psServiceFlowTable->stSFList[iSfIndex].pstClassifierTable;
uiStatus =
CreateClassifierPHSRule(uiClsId, psaClassifiertable, psPhsRule,
eActiveClassifierRuleContext, u8AssociatedPHSI); eActiveClassifierRuleContext, u8AssociatedPHSI);
if (uiStatus == PHS_SUCCESS) { if (uiStatus == PHS_SUCCESS) {
/* Add entry at free index to the SF */ /* Add entry at free index to the SF */
...@@ -912,10 +1048,10 @@ static UINT CreateSFToClassifierRuleMapping(IN B_UINT16 uiVcid, IN B_UINT16 uiC ...@@ -912,10 +1048,10 @@ static UINT CreateSFToClassifierRuleMapping(IN B_UINT16 uiVcid, IN B_UINT16 uiC
} }
static UINT CreateClassiferToPHSRuleMapping(IN B_UINT16 uiVcid, static UINT CreateClassiferToPHSRuleMapping(IN B_UINT16 uiVcid,
IN B_UINT16 uiClsId, IN B_UINT16 uiClsId,
IN struct bcm_phs_entry *pstServiceFlowEntry, IN struct bcm_phs_entry *pstServiceFlowEntry,
struct bcm_phs_rule *psPhsRule, struct bcm_phs_rule *psPhsRule,
B_UINT8 u8AssociatedPHSI) B_UINT8 u8AssociatedPHSI)
{ {
struct bcm_phs_classifier_entry *pstClassifierEntry = NULL; struct bcm_phs_classifier_entry *pstClassifierEntry = NULL;
UINT uiStatus = PHS_SUCCESS; UINT uiStatus = PHS_SUCCESS;
...@@ -925,7 +1061,8 @@ static UINT CreateClassiferToPHSRuleMapping(IN B_UINT16 uiVcid, ...@@ -925,7 +1061,8 @@ static UINT CreateClassiferToPHSRuleMapping(IN B_UINT16 uiVcid,
psaClassifiertable = pstServiceFlowEntry->pstClassifierTable; psaClassifiertable = pstServiceFlowEntry->pstClassifierTable;
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "==>"); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,
"==>");
/* Check if the supplied Classifier already exists */ /* Check if the supplied Classifier already exists */
nClassifierIndex = GetClassifierEntry( nClassifierIndex = GetClassifierEntry(
...@@ -941,9 +1078,9 @@ static UINT CreateClassiferToPHSRuleMapping(IN B_UINT16 uiVcid, ...@@ -941,9 +1078,9 @@ static UINT CreateClassiferToPHSRuleMapping(IN B_UINT16 uiVcid,
*/ */
uiStatus = CreateClassifierPHSRule(uiClsId, psaClassifiertable, uiStatus = CreateClassifierPHSRule(uiClsId, psaClassifiertable,
psPhsRule, psPhsRule,
eActiveClassifierRuleContext, eActiveClassifierRuleContext,
u8AssociatedPHSI); u8AssociatedPHSI);
return uiStatus; return uiStatus;
} }
...@@ -964,18 +1101,21 @@ static UINT CreateClassiferToPHSRuleMapping(IN B_UINT16 uiVcid, ...@@ -964,18 +1101,21 @@ static UINT CreateClassiferToPHSRuleMapping(IN B_UINT16 uiVcid,
if (psPhsRule->u8PHSFLength) { if (psPhsRule->u8PHSFLength) {
/* update PHSF */ /* update PHSF */
memcpy(pstClassifierEntry->pstPhsRule->u8PHSF, memcpy(pstClassifierEntry->pstPhsRule->u8PHSF,
psPhsRule->u8PHSF, MAX_PHS_LENGTHS); psPhsRule->u8PHSF,
MAX_PHS_LENGTHS);
} }
if (psPhsRule->u8PHSFLength) { if (psPhsRule->u8PHSFLength) {
/* update PHSFLen */ /* update PHSFLen */
pstClassifierEntry->pstPhsRule->u8PHSFLength = psPhsRule->u8PHSFLength; pstClassifierEntry->pstPhsRule->u8PHSFLength =
psPhsRule->u8PHSFLength;
} }
if (psPhsRule->u8PHSMLength) { if (psPhsRule->u8PHSMLength) {
/* update PHSM */ /* update PHSM */
memcpy(pstClassifierEntry->pstPhsRule->u8PHSM, memcpy(pstClassifierEntry->pstPhsRule->u8PHSM,
psPhsRule->u8PHSM, MAX_PHS_LENGTHS); psPhsRule->u8PHSM,
MAX_PHS_LENGTHS);
} }
if (psPhsRule->u8PHSMLength) { if (psPhsRule->u8PHSMLength) {
...@@ -986,25 +1126,29 @@ static UINT CreateClassiferToPHSRuleMapping(IN B_UINT16 uiVcid, ...@@ -986,25 +1126,29 @@ static UINT CreateClassiferToPHSRuleMapping(IN B_UINT16 uiVcid,
if (psPhsRule->u8PHSS) { if (psPhsRule->u8PHSS) {
/* update PHSS */ /* update PHSS */
pstClassifierEntry->pstPhsRule->u8PHSS = psPhsRule->u8PHSS; pstClassifierEntry->pstPhsRule->u8PHSS =
psPhsRule->u8PHSS;
} }
/* update PHSV */ /* update PHSV */
pstClassifierEntry->pstPhsRule->u8PHSV = psPhsRule->u8PHSV; pstClassifierEntry->pstPhsRule->u8PHSV = psPhsRule->u8PHSV;
} else { } else {
/* A new rule is being set for this classifier. */ /* A new rule is being set for this classifier. */
uiStatus = UpdateClassifierPHSRule(uiClsId, pstClassifierEntry, uiStatus = UpdateClassifierPHSRule(uiClsId,
psaClassifiertable, psPhsRule, u8AssociatedPHSI); pstClassifierEntry,
psaClassifiertable,
psPhsRule,
u8AssociatedPHSI);
} }
return uiStatus; return uiStatus;
} }
static UINT CreateClassifierPHSRule(IN B_UINT16 uiClsId, static UINT CreateClassifierPHSRule(IN B_UINT16 uiClsId,
struct bcm_phs_classifier_table *psaClassifiertable, struct bcm_phs_classifier_table *psaClassifiertable,
struct bcm_phs_rule *psPhsRule, struct bcm_phs_rule *psPhsRule,
enum bcm_phs_classifier_context eClsContext, enum bcm_phs_classifier_context eClsContext,
B_UINT8 u8AssociatedPHSI) B_UINT8 u8AssociatedPHSI)
{ {
UINT iClassifierIndex = 0; UINT iClassifierIndex = 0;
bool bFreeEntryFound = false; bool bFreeEntryFound = false;
...@@ -1012,7 +1156,8 @@ static UINT CreateClassifierPHSRule(IN B_UINT16 uiClsId, ...@@ -1012,7 +1156,8 @@ static UINT CreateClassifierPHSRule(IN B_UINT16 uiClsId,
UINT nStatus = PHS_SUCCESS; UINT nStatus = PHS_SUCCESS;
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "Inside CreateClassifierPHSRule"); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,
"Inside CreateClassifierPHSRule");
if (psaClassifiertable == NULL) if (psaClassifiertable == NULL)
return ERR_INVALID_CLASSIFIERTABLE_FOR_SF; return ERR_INVALID_CLASSIFIERTABLE_FOR_SF;
...@@ -1023,9 +1168,10 @@ static UINT CreateClassifierPHSRule(IN B_UINT16 uiClsId, ...@@ -1023,9 +1168,10 @@ static UINT CreateClassifierPHSRule(IN B_UINT16 uiClsId,
* old rules table replace it. * old rules table replace it.
*/ */
iClassifierIndex = iClassifierIndex = GetClassifierEntry(psaClassifiertable,
GetClassifierEntry(psaClassifiertable, uiClsId, uiClsId,
eClsContext, &psClassifierRules); eClsContext,
&psClassifierRules);
if (iClassifierIndex != PHS_INVALID_TABLE_INDEX) { if (iClassifierIndex != PHS_INVALID_TABLE_INDEX) {
/* /*
...@@ -1061,8 +1207,10 @@ static UINT CreateClassifierPHSRule(IN B_UINT16 uiClsId, ...@@ -1061,8 +1207,10 @@ static UINT CreateClassifierPHSRule(IN B_UINT16 uiClsId,
if (psaClassifiertable->uiOldestPhsRuleIndex >= MAX_PHSRULE_PER_SF) if (psaClassifiertable->uiOldestPhsRuleIndex >= MAX_PHSRULE_PER_SF)
psaClassifiertable->uiOldestPhsRuleIndex = 0; psaClassifiertable->uiOldestPhsRuleIndex = 0;
iClassifierIndex = psaClassifiertable->uiOldestPhsRuleIndex; iClassifierIndex =
psClassifierRules = &psaClassifiertable->stOldPhsRulesList[iClassifierIndex]; psaClassifiertable->uiOldestPhsRuleIndex;
psClassifierRules =
&psaClassifiertable->stOldPhsRulesList[iClassifierIndex];
(psaClassifiertable->uiOldestPhsRuleIndex)++; (psaClassifiertable->uiOldestPhsRuleIndex)++;
} }
...@@ -1072,7 +1220,9 @@ static UINT CreateClassifierPHSRule(IN B_UINT16 uiClsId, ...@@ -1072,7 +1220,9 @@ static UINT CreateClassifierPHSRule(IN B_UINT16 uiClsId,
if (psClassifierRules->pstPhsRule == NULL) { if (psClassifierRules->pstPhsRule == NULL) {
psClassifierRules->pstPhsRule = kmalloc(sizeof(struct bcm_phs_rule), GFP_KERNEL); psClassifierRules->pstPhsRule =
kmalloc(sizeof(struct bcm_phs_rule),
GFP_KERNEL);
if (NULL == psClassifierRules->pstPhsRule) if (NULL == psClassifierRules->pstPhsRule)
return ERR_PHSRULE_MEMALLOC_FAIL; return ERR_PHSRULE_MEMALLOC_FAIL;
...@@ -1081,22 +1231,27 @@ static UINT CreateClassifierPHSRule(IN B_UINT16 uiClsId, ...@@ -1081,22 +1231,27 @@ static UINT CreateClassifierPHSRule(IN B_UINT16 uiClsId,
psClassifierRules->bUsed = TRUE; psClassifierRules->bUsed = TRUE;
psClassifierRules->uiClassifierRuleId = uiClsId; psClassifierRules->uiClassifierRuleId = uiClsId;
psClassifierRules->u8PHSI = psPhsRule->u8PHSI; psClassifierRules->u8PHSI = psPhsRule->u8PHSI;
psClassifierRules->bUnclassifiedPHSRule = psPhsRule->bUnclassifiedPHSRule; psClassifierRules->bUnclassifiedPHSRule =
psPhsRule->bUnclassifiedPHSRule;
/* Update The PHS rule */ /* Update The PHS rule */
memcpy(psClassifierRules->pstPhsRule, psPhsRule, sizeof(struct bcm_phs_rule)); memcpy(psClassifierRules->pstPhsRule, psPhsRule,
sizeof(struct bcm_phs_rule));
} else } else
nStatus = UpdateClassifierPHSRule(uiClsId, psClassifierRules, nStatus = UpdateClassifierPHSRule(uiClsId,
psaClassifiertable, psPhsRule, u8AssociatedPHSI); psClassifierRules,
psaClassifiertable,
psPhsRule,
u8AssociatedPHSI);
return nStatus; return nStatus;
} }
static UINT UpdateClassifierPHSRule(IN B_UINT16 uiClsId, static UINT UpdateClassifierPHSRule(IN B_UINT16 uiClsId,
IN struct bcm_phs_classifier_entry *pstClassifierEntry, IN struct bcm_phs_classifier_entry *pstClassifierEntry,
struct bcm_phs_classifier_table *psaClassifiertable, struct bcm_phs_classifier_table *psaClassifiertable,
struct bcm_phs_rule *psPhsRule, struct bcm_phs_rule *psPhsRule,
B_UINT8 u8AssociatedPHSI) B_UINT8 u8AssociatedPHSI)
{ {
struct bcm_phs_rule *pstAddPhsRule = NULL; struct bcm_phs_rule *pstAddPhsRule = NULL;
UINT nPhsRuleIndex = 0; UINT nPhsRuleIndex = 0;
...@@ -1111,27 +1266,36 @@ static UINT UpdateClassifierPHSRule(IN B_UINT16 uiClsId, ...@@ -1111,27 +1266,36 @@ static UINT UpdateClassifierPHSRule(IN B_UINT16 uiClsId,
/* Step 2 Search if there is a PHS Rule with u8AssociatedPHSI in Classifier table for this SF */ /* Step 2 Search if there is a PHS Rule with u8AssociatedPHSI in Classifier table for this SF */
nPhsRuleIndex = GetPhsRuleEntry(psaClassifiertable, u8AssociatedPHSI, nPhsRuleIndex = GetPhsRuleEntry(psaClassifiertable, u8AssociatedPHSI,
eActiveClassifierRuleContext, &pstAddPhsRule); eActiveClassifierRuleContext,
&pstAddPhsRule);
if (PHS_INVALID_TABLE_INDEX == nPhsRuleIndex) { if (PHS_INVALID_TABLE_INDEX == nPhsRuleIndex) {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nAdding New PHSRuleEntry For Classifier"); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH,
DBG_LVL_ALL,
"\nAdding New PHSRuleEntry For Classifier");
if (psPhsRule->u8PHSI == 0) { if (psPhsRule->u8PHSI == 0) {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nError PHSI is Zero\n"); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH,
DBG_LVL_ALL, "\nError PHSI is Zero\n");
return ERR_PHS_INVALID_PHS_RULE; return ERR_PHS_INVALID_PHS_RULE;
} }
/* Step 2.a PHS Rule Does Not Exist .Create New PHS Rule for uiClsId */ /* Step 2.a PHS Rule Does Not Exist .Create New PHS Rule for uiClsId */
if (false == bPHSRuleOrphaned) { if (false == bPHSRuleOrphaned) {
pstClassifierEntry->pstPhsRule = kmalloc(sizeof(struct bcm_phs_rule), GFP_KERNEL); pstClassifierEntry->pstPhsRule =
kmalloc(sizeof(struct bcm_phs_rule),
GFP_KERNEL);
if (NULL == pstClassifierEntry->pstPhsRule) if (NULL == pstClassifierEntry->pstPhsRule)
return ERR_PHSRULE_MEMALLOC_FAIL; return ERR_PHSRULE_MEMALLOC_FAIL;
} }
memcpy(pstClassifierEntry->pstPhsRule, psPhsRule, sizeof(struct bcm_phs_rule)); memcpy(pstClassifierEntry->pstPhsRule, psPhsRule,
sizeof(struct bcm_phs_rule));
} else { } else {
/* Step 2.b PHS Rule Exists Tie uiClsId with the existing PHS Rule */ /* Step 2.b PHS Rule Exists Tie uiClsId with the existing PHS Rule */
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nTying Classifier to Existing PHS Rule"); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH,
DBG_LVL_ALL,
"\nTying Classifier to Existing PHS Rule");
if (bPHSRuleOrphaned) { if (bPHSRuleOrphaned) {
kfree(pstClassifierEntry->pstPhsRule); kfree(pstClassifierEntry->pstPhsRule);
pstClassifierEntry->pstPhsRule = NULL; pstClassifierEntry->pstPhsRule = NULL;
...@@ -1143,12 +1307,15 @@ static UINT UpdateClassifierPHSRule(IN B_UINT16 uiClsId, ...@@ -1143,12 +1307,15 @@ static UINT UpdateClassifierPHSRule(IN B_UINT16 uiClsId,
pstClassifierEntry->u8PHSI = pstClassifierEntry->pstPhsRule->u8PHSI; pstClassifierEntry->u8PHSI = pstClassifierEntry->pstPhsRule->u8PHSI;
pstClassifierEntry->uiClassifierRuleId = uiClsId; pstClassifierEntry->uiClassifierRuleId = uiClsId;
pstClassifierEntry->pstPhsRule->u8RefCnt++; pstClassifierEntry->pstPhsRule->u8RefCnt++;
pstClassifierEntry->bUnclassifiedPHSRule = pstClassifierEntry->pstPhsRule->bUnclassifiedPHSRule; pstClassifierEntry->bUnclassifiedPHSRule =
pstClassifierEntry->pstPhsRule->bUnclassifiedPHSRule;
return PHS_SUCCESS; return PHS_SUCCESS;
} }
static bool DerefPhsRule(IN B_UINT16 uiClsId, struct bcm_phs_classifier_table *psaClassifiertable, struct bcm_phs_rule *pstPhsRule) static bool DerefPhsRule(IN B_UINT16 uiClsId,
struct bcm_phs_classifier_table *psaClassifiertable,
struct bcm_phs_rule *pstPhsRule)
{ {
if (pstPhsRule == NULL) if (pstPhsRule == NULL)
return false; return false;
...@@ -1172,7 +1339,8 @@ void DumpPhsRules(struct bcm_phs_extension *pDeviceExtension) ...@@ -1172,7 +1339,8 @@ void DumpPhsRules(struct bcm_phs_extension *pDeviceExtension)
int i, j, k, l; int i, j, k, l;
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\n Dumping PHS Rules :\n"); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,
"\n Dumping PHS Rules :\n");
for (i = 0; i < MAX_SERVICEFLOWS; i++) { for (i = 0; i < MAX_SERVICEFLOWS; i++) {
...@@ -1238,9 +1406,9 @@ void DumpPhsRules(struct bcm_phs_extension *pDeviceExtension) ...@@ -1238,9 +1406,9 @@ void DumpPhsRules(struct bcm_phs_extension *pDeviceExtension)
* 0 -If PHS rule is NULL.If PHSI is 0 indicateing packet as uncompressed. * 0 -If PHS rule is NULL.If PHSI is 0 indicateing packet as uncompressed.
*/ */
static int phs_decompress(unsigned char *in_buf, static int phs_decompress(unsigned char *in_buf,
unsigned char *out_buf, unsigned char *out_buf,
struct bcm_phs_rule *decomp_phs_rules, struct bcm_phs_rule *decomp_phs_rules,
UINT *header_size) UINT *header_size)
{ {
int phss, size = 0; int phss, size = 0;
struct bcm_phs_rule *tmp_memb; struct bcm_phs_rule *tmp_memb;
...@@ -1251,7 +1419,8 @@ static int phs_decompress(unsigned char *in_buf, ...@@ -1251,7 +1419,8 @@ static int phs_decompress(unsigned char *in_buf,
in_buf++; in_buf++;
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, DBG_LVL_ALL, "====>\n"); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, DBG_LVL_ALL,
"====>\n");
*header_size = 0; *header_size = 0;
if (decomp_phs_rules == NULL) if (decomp_phs_rules == NULL)
...@@ -1278,11 +1447,15 @@ static int phs_decompress(unsigned char *in_buf, ...@@ -1278,11 +1447,15 @@ static int phs_decompress(unsigned char *in_buf,
if (bit == SUPPRESS) { if (bit == SUPPRESS) {
*out_buf = *phsf; *out_buf = *phsf;
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, DBG_LVL_ALL, "\nDECOMP:In phss %d phsf %d output %d", BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE,
DBG_LVL_ALL,
"\nDECOMP:In phss %d phsf %d output %d",
phss, *phsf, *out_buf); phss, *phsf, *out_buf);
} else { } else {
*out_buf = *in_buf; *out_buf = *in_buf;
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, DBG_LVL_ALL, "\nDECOMP:In phss %d input %d output %d", BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE,
DBG_LVL_ALL,
"\nDECOMP:In phss %d input %d output %d",
phss, *in_buf, *out_buf); phss, *in_buf, *out_buf);
in_buf++; in_buf++;
size++; size++;
...@@ -1333,7 +1506,8 @@ static int phs_compress(struct bcm_phs_rule *phs_rule, ...@@ -1333,7 +1506,8 @@ static int phs_compress(struct bcm_phs_rule *phs_rule,
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
if (phs_rule == NULL) { if (phs_rule == NULL) {
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, "\nphs_compress(): phs_rule null!"); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,
"\nphs_compress(): phs_rule null!");
*out_buf = ZERO_PHSI; *out_buf = ZERO_PHSI;
return STATUS_PHS_NOCOMPRESSION; return STATUS_PHS_NOCOMPRESSION;
} }
...@@ -1351,10 +1525,13 @@ static int phs_compress(struct bcm_phs_rule *phs_rule, ...@@ -1351,10 +1525,13 @@ static int phs_compress(struct bcm_phs_rule *phs_rule,
if (suppress == STATUS_PHS_COMPRESSED) { if (suppress == STATUS_PHS_COMPRESSED) {
*old_addr = (unsigned char)phs_rule->u8PHSI; *old_addr = (unsigned char)phs_rule->u8PHSI;
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, "\nCOMP:In phs_compress phsi %d", phs_rule->u8PHSI); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,
"\nCOMP:In phs_compress phsi %d",
phs_rule->u8PHSI);
} else { } else {
*old_addr = ZERO_PHSI; *old_addr = ZERO_PHSI;
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, "\nCOMP:In phs_compress PHSV Verification failed"); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,
"\nCOMP:In phs_compress PHSV Verification failed");
} }
return suppress; return suppress;
...@@ -1391,7 +1568,8 @@ static int verify_suppress_phsf(unsigned char *in_buffer, ...@@ -1391,7 +1568,8 @@ static int verify_suppress_phsf(unsigned char *in_buffer,
int bit, i = 0; int bit, i = 0;
struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, "\nCOMP:In verify_phsf PHSM - 0x%X", *phsm); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,
"\nCOMP:In verify_phsf PHSM - 0x%X", *phsm);
if (phss > (*new_header_size)) if (phss > (*new_header_size))
phss = *new_header_size; phss = *new_header_size;
...@@ -1443,7 +1621,8 @@ static int verify_suppress_phsf(unsigned char *in_buffer, ...@@ -1443,7 +1621,8 @@ static int verify_suppress_phsf(unsigned char *in_buffer,
phsm++; phsm++;
} }
} }
BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, "\nCOMP:In verify_phsf success"); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,
"\nCOMP:In verify_phsf success");
*new_header_size = size; *new_header_size = size;
return STATUS_PHS_COMPRESSED; return STATUS_PHS_COMPRESSED;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment