Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1 | #include "headers.h" |
| 2 | |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 3 | static UINT CreateSFToClassifierRuleMapping(B_UINT16 uiVcid, |
| 4 | B_UINT16 uiClsId, |
| 5 | struct bcm_phs_table *psServiceFlowTable, |
| 6 | struct bcm_phs_rule *psPhsRule, |
| 7 | B_UINT8 u8AssociatedPHSI); |
Stephen Hemminger | 9dd47ee | 2010-11-01 12:24:00 -0400 | [diff] [blame] | 8 | |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 9 | static UINT CreateClassiferToPHSRuleMapping(B_UINT16 uiVcid, |
| 10 | B_UINT16 uiClsId, |
| 11 | struct bcm_phs_entry *pstServiceFlowEntry, |
| 12 | struct bcm_phs_rule *psPhsRule, |
| 13 | B_UINT8 u8AssociatedPHSI); |
Stephen Hemminger | 9dd47ee | 2010-11-01 12:24:00 -0400 | [diff] [blame] | 14 | |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 15 | static UINT CreateClassifierPHSRule(B_UINT16 uiClsId, |
| 16 | struct bcm_phs_classifier_table *psaClassifiertable, |
| 17 | struct bcm_phs_rule *psPhsRule, |
| 18 | enum bcm_phs_classifier_context eClsContext, |
| 19 | B_UINT8 u8AssociatedPHSI); |
Stephen Hemminger | 9dd47ee | 2010-11-01 12:24:00 -0400 | [diff] [blame] | 20 | |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 21 | static UINT UpdateClassifierPHSRule(B_UINT16 uiClsId, |
| 22 | struct bcm_phs_classifier_entry *pstClassifierEntry, |
| 23 | struct bcm_phs_classifier_table *psaClassifiertable, |
| 24 | struct bcm_phs_rule *psPhsRule, |
| 25 | B_UINT8 u8AssociatedPHSI); |
Stephen Hemminger | 9dd47ee | 2010-11-01 12:24:00 -0400 | [diff] [blame] | 26 | |
Matthias Beyer | 14d8e91 | 2014-07-15 09:43:08 +0200 | [diff] [blame] | 27 | static bool ValidatePHSRuleComplete(const struct bcm_phs_rule *psPhsRule); |
Stephen Hemminger | 9dd47ee | 2010-11-01 12:24:00 -0400 | [diff] [blame] | 28 | |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 29 | static bool DerefPhsRule(B_UINT16 uiClsId, |
| 30 | struct bcm_phs_classifier_table *psaClassifiertable, |
| 31 | struct bcm_phs_rule *pstPhsRule); |
Stephen Hemminger | 9dd47ee | 2010-11-01 12:24:00 -0400 | [diff] [blame] | 32 | |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 33 | static UINT GetClassifierEntry(struct bcm_phs_classifier_table *pstClassifierTable, |
| 34 | B_UINT32 uiClsid, |
| 35 | enum bcm_phs_classifier_context eClsContext, |
| 36 | struct bcm_phs_classifier_entry **ppstClassifierEntry); |
Stephen Hemminger | 9dd47ee | 2010-11-01 12:24:00 -0400 | [diff] [blame] | 37 | |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 38 | static UINT GetPhsRuleEntry(struct bcm_phs_classifier_table *pstClassifierTable, |
| 39 | B_UINT32 uiPHSI, |
| 40 | enum bcm_phs_classifier_context eClsContext, |
| 41 | struct bcm_phs_rule **ppstPhsRule); |
Stephen Hemminger | 9dd47ee | 2010-11-01 12:24:00 -0400 | [diff] [blame] | 42 | |
Kevin McKinney | da4d150 | 2012-12-20 00:31:29 -0500 | [diff] [blame] | 43 | static void free_phs_serviceflow_rules(struct bcm_phs_table *psServiceFlowRulesTable); |
Stephen Hemminger | 9dd47ee | 2010-11-01 12:24:00 -0400 | [diff] [blame] | 44 | |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 45 | static int phs_compress(struct bcm_phs_rule *phs_members, |
| 46 | unsigned char *in_buf, |
| 47 | unsigned char *out_buf, |
| 48 | unsigned int *header_size, |
| 49 | UINT *new_header_size); |
Stephen Hemminger | 9dd47ee | 2010-11-01 12:24:00 -0400 | [diff] [blame] | 50 | |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 51 | static int verify_suppress_phsf(unsigned char *in_buffer, |
| 52 | unsigned char *out_buffer, |
| 53 | unsigned char *phsf, |
| 54 | unsigned char *phsm, |
| 55 | unsigned int phss, |
| 56 | unsigned int phsv, |
| 57 | UINT *new_header_size); |
Stephen Hemminger | 9dd47ee | 2010-11-01 12:24:00 -0400 | [diff] [blame] | 58 | |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 59 | static int phs_decompress(unsigned char *in_buf, |
| 60 | unsigned char *out_buf, |
| 61 | struct bcm_phs_rule *phs_rules, |
| 62 | UINT *header_size); |
Stephen Hemminger | 9dd47ee | 2010-11-01 12:24:00 -0400 | [diff] [blame] | 63 | |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 64 | static ULONG PhsCompress(void *pvContext, |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 65 | B_UINT16 uiVcid, |
| 66 | B_UINT16 uiClsId, |
| 67 | void *pvInputBuffer, |
| 68 | void *pvOutputBuffer, |
| 69 | UINT *pOldHeaderSize, |
| 70 | UINT *pNewHeaderSize); |
Stephen Hemminger | 9dd47ee | 2010-11-01 12:24:00 -0400 | [diff] [blame] | 71 | |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 72 | static ULONG PhsDeCompress(void *pvContext, |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 73 | B_UINT16 uiVcid, |
| 74 | void *pvInputBuffer, |
| 75 | void *pvOutputBuffer, |
| 76 | UINT *pInHeaderSize, |
| 77 | UINT *pOutHeaderSize); |
Stephen Hemminger | 9dd47ee | 2010-11-01 12:24:00 -0400 | [diff] [blame] | 78 | |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 79 | #define IN |
| 80 | #define OUT |
| 81 | |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 82 | /* |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 83 | * Function: PHSTransmit |
| 84 | * Description: This routine handle PHS(Payload Header Suppression for Tx path. |
| 85 | * It extracts a fragment of the NDIS_PACKET containing the header |
| 86 | * to be suppressed. It then suppresses the header by invoking PHS exported compress routine. |
| 87 | * The header data after suppression is copied back to the NDIS_PACKET. |
| 88 | * |
| 89 | * Input parameters: IN struct bcm_mini_adapter *Adapter - Miniport Adapter Context |
| 90 | * IN Packet - NDIS packet containing data to be transmitted |
| 91 | * IN USHORT Vcid - vcid pertaining to connection on which the packet is being sent.Used to |
| 92 | * identify PHS rule to be applied. |
| 93 | * B_UINT16 uiClassifierRuleID - Classifier Rule ID |
| 94 | * BOOLEAN bHeaderSuppressionEnabled - indicates if header suprression is enabled for SF. |
| 95 | * |
| 96 | * Return: STATUS_SUCCESS - If the send was successful. |
| 97 | * Other - If an error occurred. |
| 98 | */ |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 99 | |
Kevin McKinney | 2979460 | 2012-05-26 12:05:12 -0400 | [diff] [blame] | 100 | int PHSTransmit(struct bcm_mini_adapter *Adapter, |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 101 | struct sk_buff **pPacket, |
| 102 | USHORT Vcid, |
| 103 | B_UINT16 uiClassifierRuleID, |
Lisa Nguyen | 3abd6f1 | 2013-10-28 01:35:59 -0700 | [diff] [blame] | 104 | bool bHeaderSuppressionEnabled, |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 105 | UINT *PacketLen, |
| 106 | UCHAR bEthCSSupport) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 107 | { |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 108 | /* PHS Sepcific */ |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 109 | UINT unPHSPktHdrBytesCopied = 0; |
| 110 | UINT unPhsOldHdrSize = 0; |
| 111 | UINT unPHSNewPktHeaderLen = 0; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 112 | /* Pointer to PHS IN Hdr Buffer */ |
Matthias Beyer | e86bd61 | 2014-07-15 09:43:15 +0200 | [diff] [blame] | 113 | PUCHAR pucPHSPktHdrInBuf = |
| 114 | Adapter->stPhsTxContextInfo.ucaHdrSuppressionInBuf; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 115 | /* Pointer to PHS OUT Hdr Buffer */ |
Matthias Beyer | e86bd61 | 2014-07-15 09:43:15 +0200 | [diff] [blame] | 116 | PUCHAR pucPHSPktHdrOutBuf = |
| 117 | Adapter->stPhsTxContextInfo.ucaHdrSuppressionOutBuf; |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 118 | UINT usPacketType; |
| 119 | UINT BytesToRemove = 0; |
Lisa Nguyen | 3abd6f1 | 2013-10-28 01:35:59 -0700 | [diff] [blame] | 120 | bool bPHSI = 0; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 121 | LONG ulPhsStatus = 0; |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 122 | UINT numBytesCompressed = 0; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 123 | struct sk_buff *newPacket = NULL; |
| 124 | struct sk_buff *Packet = *pPacket; |
| 125 | |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 126 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, |
| 127 | "In PHSTransmit"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 128 | |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 129 | if (!bEthCSSupport) |
| 130 | BytesToRemove = ETH_HLEN; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 131 | /* |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 132 | * Accumulate the header upto the size we support suppression |
| 133 | * from NDIS packet |
| 134 | */ |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 135 | |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 136 | usPacketType = ((struct ethhdr *)(Packet->data))->h_proto; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 137 | |
| 138 | pucPHSPktHdrInBuf = Packet->data + BytesToRemove; |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 139 | /* considering data after ethernet header */ |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 140 | if ((*PacketLen - BytesToRemove) < MAX_PHS_LENGTHS) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 141 | unPHSPktHdrBytesCopied = (*PacketLen - BytesToRemove); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 142 | else |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 143 | unPHSPktHdrBytesCopied = MAX_PHS_LENGTHS; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 144 | |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 145 | if ((unPHSPktHdrBytesCopied > 0) && |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 146 | (unPHSPktHdrBytesCopied <= MAX_PHS_LENGTHS)) { |
| 147 | |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 148 | /* |
Matthias Beyer | e86bd61 | 2014-07-15 09:43:15 +0200 | [diff] [blame] | 149 | * Step 2 Suppress Header using PHS and fill into intermediate |
| 150 | * ucaPHSPktHdrOutBuf. |
| 151 | * Suppress only if IP Header and PHS Enabled For the |
| 152 | * Service Flow |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 153 | */ |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 154 | if (((usPacketType == ETHERNET_FRAMETYPE_IPV4) || |
| 155 | (usPacketType == ETHERNET_FRAMETYPE_IPV6)) && |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 156 | (bHeaderSuppressionEnabled)) { |
| 157 | |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 158 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, |
| 159 | DBG_LVL_ALL, |
| 160 | "\nTrying to PHS Compress Using Classifier rule 0x%X", |
| 161 | uiClassifierRuleID); |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 162 | unPHSNewPktHeaderLen = unPHSPktHdrBytesCopied; |
| 163 | ulPhsStatus = PhsCompress(&Adapter->stBCMPhsContext, |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 164 | Vcid, |
| 165 | uiClassifierRuleID, |
| 166 | pucPHSPktHdrInBuf, |
| 167 | pucPHSPktHdrOutBuf, |
| 168 | &unPhsOldHdrSize, |
| 169 | &unPHSNewPktHeaderLen); |
| 170 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, |
| 171 | DBG_LVL_ALL, |
| 172 | "\nPHS Old header Size : %d New Header Size %d\n", |
| 173 | unPhsOldHdrSize, unPHSNewPktHeaderLen); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 174 | |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 175 | if (unPHSNewPktHeaderLen == unPhsOldHdrSize) { |
| 176 | |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 177 | if (ulPhsStatus == STATUS_PHS_COMPRESSED) |
| 178 | bPHSI = *pucPHSPktHdrOutBuf; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 179 | |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 180 | ulPhsStatus = STATUS_PHS_NOCOMPRESSION; |
| 181 | } |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 182 | |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 183 | if (ulPhsStatus == STATUS_PHS_COMPRESSED) { |
| 184 | |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 185 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, |
| 186 | PHS_SEND, DBG_LVL_ALL, |
| 187 | "PHS Sending packet Compressed"); |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 188 | |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 189 | if (skb_cloned(Packet)) { |
Matthias Beyer | e86bd61 | 2014-07-15 09:43:15 +0200 | [diff] [blame] | 190 | newPacket = |
| 191 | skb_copy(Packet, GFP_ATOMIC); |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 192 | |
| 193 | if (newPacket == NULL) |
| 194 | return STATUS_FAILURE; |
| 195 | |
| 196 | dev_kfree_skb(Packet); |
| 197 | *pPacket = Packet = newPacket; |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 198 | pucPHSPktHdrInBuf = |
| 199 | Packet->data + BytesToRemove; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 200 | } |
| 201 | |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 202 | numBytesCompressed = unPhsOldHdrSize - |
| 203 | (unPHSNewPktHeaderLen + PHSI_LEN); |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 204 | |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 205 | memcpy(pucPHSPktHdrInBuf + numBytesCompressed, |
| 206 | pucPHSPktHdrOutBuf, |
| 207 | unPHSNewPktHeaderLen + PHSI_LEN); |
| 208 | memcpy(Packet->data + numBytesCompressed, |
| 209 | Packet->data, BytesToRemove); |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 210 | skb_pull(Packet, numBytesCompressed); |
| 211 | |
| 212 | return STATUS_SUCCESS; |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 213 | } else { |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 214 | /* if one byte headroom is not available, |
| 215 | * increase it through skb_cow |
| 216 | */ |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 217 | if (!(skb_headroom(Packet) > 0)) { |
| 218 | |
| 219 | if (skb_cow(Packet, 1)) { |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 220 | BCM_DEBUG_PRINT(Adapter, |
| 221 | DBG_TYPE_PRINTK, |
| 222 | 0, 0, |
| 223 | "SKB Cow Failed\n"); |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 224 | return STATUS_FAILURE; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 225 | } |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 226 | } |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 227 | skb_push(Packet, 1); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 228 | |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 229 | /* |
| 230 | * CAUTION: The MAC Header is getting corrupted |
| 231 | * here for IP CS - can be saved by copying 14 |
| 232 | * Bytes. not needed .... hence corrupting it. |
| 233 | */ |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 234 | *(Packet->data + BytesToRemove) = bPHSI; |
| 235 | return STATUS_SUCCESS; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 236 | } |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 237 | } else { |
| 238 | |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 239 | if (!bHeaderSuppressionEnabled) |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 240 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, |
| 241 | PHS_SEND, DBG_LVL_ALL, |
| 242 | "\nHeader Suppression Disabled For SF: No PHS\n"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 243 | |
| 244 | return STATUS_SUCCESS; |
| 245 | } |
| 246 | } |
| 247 | |
Matthias Beyer | e86bd61 | 2014-07-15 09:43:15 +0200 | [diff] [blame] | 248 | /* BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, |
| 249 | * "PHSTransmit : Dumping data packet After PHS"); */ |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 250 | return STATUS_SUCCESS; |
| 251 | } |
| 252 | |
Kevin McKinney | 2979460 | 2012-05-26 12:05:12 -0400 | [diff] [blame] | 253 | int PHSReceive(struct bcm_mini_adapter *Adapter, |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 254 | USHORT usVcid, |
| 255 | struct sk_buff *packet, |
| 256 | UINT *punPacketLen, |
| 257 | UCHAR *pucEthernetHdr, |
| 258 | UINT bHeaderSuppressionEnabled) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 259 | { |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 260 | u32 nStandardPktHdrLen = 0; |
| 261 | u32 nTotalsuppressedPktHdrBytes = 0; |
| 262 | int ulPhsStatus = 0; |
| 263 | PUCHAR pucInBuff = NULL; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 264 | UINT TotalBytesAdded = 0; |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 265 | |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 266 | if (!bHeaderSuppressionEnabled) { |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 267 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, |
| 268 | DBG_LVL_ALL, |
| 269 | "\nPhs Disabled for incoming packet"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 270 | return ulPhsStatus; |
| 271 | } |
| 272 | |
| 273 | pucInBuff = packet->data; |
| 274 | |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 275 | /* Restore PHS suppressed header */ |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 276 | nStandardPktHdrLen = packet->len; |
| 277 | ulPhsStatus = PhsDeCompress(&Adapter->stBCMPhsContext, |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 278 | usVcid, |
| 279 | pucInBuff, |
| 280 | Adapter->ucaPHSPktRestoreBuf, |
| 281 | &nTotalsuppressedPktHdrBytes, |
| 282 | &nStandardPktHdrLen); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 283 | |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 284 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, DBG_LVL_ALL, |
| 285 | "\nSuppressed PktHdrLen : 0x%x Restored PktHdrLen : 0x%x", |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 286 | nTotalsuppressedPktHdrBytes, nStandardPktHdrLen); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 287 | |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 288 | if (ulPhsStatus != STATUS_PHS_COMPRESSED) { |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 289 | skb_pull(packet, 1); |
| 290 | return STATUS_SUCCESS; |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 291 | } else { |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 292 | TotalBytesAdded = nStandardPktHdrLen - |
| 293 | nTotalsuppressedPktHdrBytes - PHSI_LEN; |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 294 | |
| 295 | if (TotalBytesAdded) { |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 296 | if (skb_headroom(packet) >= (SKB_RESERVE_ETHERNET_HEADER + TotalBytesAdded)) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 297 | skb_push(packet, TotalBytesAdded); |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 298 | else { |
| 299 | if (skb_cow(packet, skb_headroom(packet) + TotalBytesAdded)) { |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 300 | BCM_DEBUG_PRINT(Adapter, |
| 301 | DBG_TYPE_PRINTK, 0, 0, |
| 302 | "cow failed in receive\n"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 303 | return STATUS_FAILURE; |
| 304 | } |
| 305 | |
| 306 | skb_push(packet, TotalBytesAdded); |
| 307 | } |
| 308 | } |
| 309 | |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 310 | memcpy(packet->data, Adapter->ucaPHSPktRestoreBuf, |
| 311 | nStandardPktHdrLen); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 312 | } |
| 313 | |
| 314 | return STATUS_SUCCESS; |
| 315 | } |
| 316 | |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 317 | void DumpFullPacket(UCHAR *pBuf, UINT nPktLen) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 318 | { |
Kevin McKinney | 2979460 | 2012-05-26 12:05:12 -0400 | [diff] [blame] | 319 | struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 320 | |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 321 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, |
| 322 | "Dumping Data Packet"); |
| 323 | BCM_DEBUG_PRINT_BUFFER(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, |
| 324 | pBuf, nPktLen); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 325 | } |
| 326 | |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 327 | /* |
| 328 | * Procedure: phs_init |
| 329 | * |
Matthias Beyer | e86bd61 | 2014-07-15 09:43:15 +0200 | [diff] [blame] | 330 | * Description: This routine is responsible for allocating memory for classifier |
| 331 | * and PHS rules. |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 332 | * |
| 333 | * Arguments: |
Matthias Beyer | e86bd61 | 2014-07-15 09:43:15 +0200 | [diff] [blame] | 334 | * pPhsdeviceExtension - ptr to Device extension containing PHS Classifier rules |
| 335 | * and PHS Rules , RX, TX buffer etc |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 336 | * |
| 337 | * Returns: |
Kevin McKinney | 175c512 | 2013-02-20 23:25:30 -0500 | [diff] [blame] | 338 | * TRUE(1) -If allocation of memory was successful. |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 339 | * FALSE -If allocation of memory fails. |
| 340 | */ |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 341 | int phs_init(struct bcm_phs_extension *pPhsdeviceExtension, |
| 342 | struct bcm_mini_adapter *Adapter) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 343 | { |
| 344 | int i; |
Kevin McKinney | da4d150 | 2012-12-20 00:31:29 -0500 | [diff] [blame] | 345 | struct bcm_phs_table *pstServiceFlowTable; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 346 | |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 347 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, |
| 348 | "\nPHS:phs_init function"); |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 349 | |
| 350 | if (pPhsdeviceExtension->pstServiceFlowPhsRulesTable) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 351 | return -EINVAL; |
| 352 | |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 353 | pPhsdeviceExtension->pstServiceFlowPhsRulesTable = |
| 354 | kzalloc(sizeof(struct bcm_phs_table), GFP_KERNEL); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 355 | |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 356 | if (!pPhsdeviceExtension->pstServiceFlowPhsRulesTable) { |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 357 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, |
| 358 | DBG_LVL_ALL, |
| 359 | "\nAllocation ServiceFlowPhsRulesTable failed"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 360 | return -ENOMEM; |
| 361 | } |
| 362 | |
| 363 | pstServiceFlowTable = pPhsdeviceExtension->pstServiceFlowPhsRulesTable; |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 364 | for (i = 0; i < MAX_SERVICEFLOWS; i++) { |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 365 | struct bcm_phs_entry sServiceFlow = |
| 366 | pstServiceFlowTable->stSFList[i]; |
| 367 | sServiceFlow.pstClassifierTable = |
| 368 | kzalloc(sizeof(struct bcm_phs_classifier_table), |
| 369 | GFP_KERNEL); |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 370 | if (!sServiceFlow.pstClassifierTable) { |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 371 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, |
| 372 | DBG_LVL_ALL, "\nAllocation failed"); |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 373 | free_phs_serviceflow_rules(pPhsdeviceExtension->pstServiceFlowPhsRulesTable); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 374 | pPhsdeviceExtension->pstServiceFlowPhsRulesTable = NULL; |
| 375 | return -ENOMEM; |
| 376 | } |
| 377 | } |
| 378 | |
Stephen Hemminger | 082e889 | 2010-11-01 09:35:21 -0400 | [diff] [blame] | 379 | pPhsdeviceExtension->CompressedTxBuffer = kmalloc(PHS_BUFFER_SIZE, GFP_KERNEL); |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 380 | if (pPhsdeviceExtension->CompressedTxBuffer == NULL) { |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 381 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, |
| 382 | DBG_LVL_ALL, "\nAllocation failed"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 383 | free_phs_serviceflow_rules(pPhsdeviceExtension->pstServiceFlowPhsRulesTable); |
| 384 | pPhsdeviceExtension->pstServiceFlowPhsRulesTable = NULL; |
| 385 | return -ENOMEM; |
| 386 | } |
| 387 | |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 388 | pPhsdeviceExtension->UnCompressedRxBuffer = |
| 389 | kmalloc(PHS_BUFFER_SIZE, GFP_KERNEL); |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 390 | if (pPhsdeviceExtension->UnCompressedRxBuffer == NULL) { |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 391 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, |
| 392 | DBG_LVL_ALL, "\nAllocation failed"); |
Stephen Hemminger | 082e889 | 2010-11-01 09:35:21 -0400 | [diff] [blame] | 393 | kfree(pPhsdeviceExtension->CompressedTxBuffer); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 394 | free_phs_serviceflow_rules(pPhsdeviceExtension->pstServiceFlowPhsRulesTable); |
| 395 | pPhsdeviceExtension->pstServiceFlowPhsRulesTable = NULL; |
| 396 | return -ENOMEM; |
| 397 | } |
| 398 | |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 399 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, |
| 400 | "\n phs_init Successful"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 401 | return STATUS_SUCCESS; |
| 402 | } |
| 403 | |
Kevin McKinney | 60dadf9 | 2012-12-20 00:31:28 -0500 | [diff] [blame] | 404 | int PhsCleanup(IN struct bcm_phs_extension *pPHSDeviceExt) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 405 | { |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 406 | if (pPHSDeviceExt->pstServiceFlowPhsRulesTable) { |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 407 | free_phs_serviceflow_rules(pPHSDeviceExt->pstServiceFlowPhsRulesTable); |
| 408 | pPHSDeviceExt->pstServiceFlowPhsRulesTable = NULL; |
| 409 | } |
| 410 | |
Stephen Hemminger | 082e889 | 2010-11-01 09:35:21 -0400 | [diff] [blame] | 411 | kfree(pPHSDeviceExt->CompressedTxBuffer); |
| 412 | pPHSDeviceExt->CompressedTxBuffer = NULL; |
| 413 | |
| 414 | kfree(pPHSDeviceExt->UnCompressedRxBuffer); |
| 415 | pPHSDeviceExt->UnCompressedRxBuffer = NULL; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 416 | |
| 417 | return 0; |
| 418 | } |
| 419 | |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 420 | /* |
| 421 | * PHS functions |
| 422 | * PhsUpdateClassifierRule |
| 423 | * |
| 424 | * Routine Description: |
| 425 | * Exported function to add or modify a PHS Rule. |
| 426 | * |
| 427 | * Arguments: |
| 428 | * IN void* pvContext - PHS Driver Specific Context |
| 429 | * IN B_UINT16 uiVcid - The Service Flow ID for which the PHS rule applies |
| 430 | * IN B_UINT16 uiClsId - The Classifier ID within the Service Flow for which the PHS rule applies. |
| 431 | * IN struct bcm_phs_rule *psPhsRule - The PHS Rule strcuture to be added to the PHS Rule table. |
| 432 | * |
| 433 | * Return Value: |
| 434 | * |
| 435 | * 0 if successful, |
| 436 | * >0 Error. |
| 437 | */ |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 438 | ULONG PhsUpdateClassifierRule(IN void *pvContext, |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 439 | IN B_UINT16 uiVcid , |
| 440 | IN B_UINT16 uiClsId , |
| 441 | IN struct bcm_phs_rule *psPhsRule, |
| 442 | IN B_UINT8 u8AssociatedPHSI) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 443 | { |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 444 | ULONG lStatus = 0; |
| 445 | UINT nSFIndex = 0; |
Kevin McKinney | db134a6 | 2012-12-20 00:31:30 -0500 | [diff] [blame] | 446 | struct bcm_phs_entry *pstServiceFlowEntry = NULL; |
Kevin McKinney | 2979460 | 2012-05-26 12:05:12 -0400 | [diff] [blame] | 447 | struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); |
Matthias Beyer | e86bd61 | 2014-07-15 09:43:15 +0200 | [diff] [blame] | 448 | struct bcm_phs_extension *pDeviceExtension = |
| 449 | (struct bcm_phs_extension *)pvContext; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 450 | |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 451 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, |
| 452 | "PHS With Corr2 Changes\n"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 453 | |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 454 | if (pDeviceExtension == NULL) { |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 455 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, |
| 456 | DBG_LVL_ALL, "Invalid Device Extension\n"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 457 | return ERR_PHS_INVALID_DEVICE_EXETENSION; |
| 458 | } |
| 459 | |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 460 | if (u8AssociatedPHSI == 0) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 461 | return ERR_PHS_INVALID_PHS_RULE; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 462 | |
| 463 | /* Retrieve the SFID Entry Index for requested Service Flow */ |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 464 | nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable, |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 465 | uiVcid, &pstServiceFlowEntry); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 466 | |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 467 | if (nSFIndex == PHS_INVALID_TABLE_INDEX) { |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 468 | /* This is a new SF. Create a mapping entry for this */ |
| 469 | lStatus = CreateSFToClassifierRuleMapping(uiVcid, uiClsId, |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 470 | pDeviceExtension->pstServiceFlowPhsRulesTable, |
| 471 | psPhsRule, |
| 472 | u8AssociatedPHSI); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 473 | return lStatus; |
| 474 | } |
| 475 | |
| 476 | /* SF already Exists Add PHS Rule to existing SF */ |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 477 | lStatus = CreateClassiferToPHSRuleMapping(uiVcid, uiClsId, |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 478 | pstServiceFlowEntry, |
| 479 | psPhsRule, |
| 480 | u8AssociatedPHSI); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 481 | |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 482 | return lStatus; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 483 | } |
| 484 | |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 485 | /* |
| 486 | * PhsDeletePHSRule |
| 487 | * |
| 488 | * Routine Description: |
| 489 | * Deletes the specified phs Rule within Vcid |
| 490 | * |
| 491 | * Arguments: |
| 492 | * IN void* pvContext - PHS Driver Specific Context |
| 493 | * IN B_UINT16 uiVcid - The Service Flow ID for which the PHS rule applies |
| 494 | * IN B_UINT8 u8PHSI - the PHS Index identifying PHS rule to be deleted. |
| 495 | * |
| 496 | * Return Value: |
| 497 | * |
| 498 | * 0 if successful, |
| 499 | * >0 Error. |
| 500 | */ |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 501 | ULONG PhsDeletePHSRule(IN void *pvContext, |
| 502 | IN B_UINT16 uiVcid, |
| 503 | IN B_UINT8 u8PHSI) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 504 | { |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 505 | UINT nSFIndex = 0, nClsidIndex = 0; |
Kevin McKinney | db134a6 | 2012-12-20 00:31:30 -0500 | [diff] [blame] | 506 | struct bcm_phs_entry *pstServiceFlowEntry = NULL; |
Kevin McKinney | a700dbd | 2012-12-20 00:31:31 -0500 | [diff] [blame] | 507 | struct bcm_phs_classifier_table *pstClassifierRulesTable = NULL; |
Kevin McKinney | 2979460 | 2012-05-26 12:05:12 -0400 | [diff] [blame] | 508 | struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 509 | struct bcm_phs_extension *pDeviceExtension = (struct bcm_phs_extension *)pvContext; |
Matthias Beyer | 413852b | 2014-07-15 09:42:57 +0200 | [diff] [blame] | 510 | struct bcm_phs_classifier_entry *curr_entry; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 511 | |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 512 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, |
| 513 | "======>\n"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 514 | |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 515 | if (pDeviceExtension) { |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 516 | /* Retrieve the SFID Entry Index for requested Service Flow */ |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 517 | nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable, |
| 518 | uiVcid, &pstServiceFlowEntry); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 519 | |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 520 | if (nSFIndex == PHS_INVALID_TABLE_INDEX) { |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 521 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, |
| 522 | DBG_LVL_ALL, "SFID Match Failed\n"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 523 | return ERR_SF_MATCH_FAIL; |
| 524 | } |
| 525 | |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 526 | pstClassifierRulesTable = pstServiceFlowEntry->pstClassifierTable; |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 527 | if (pstClassifierRulesTable) { |
| 528 | for (nClsidIndex = 0; nClsidIndex < MAX_PHSRULE_PER_SF; nClsidIndex++) { |
Matthias Beyer | 413852b | 2014-07-15 09:42:57 +0200 | [diff] [blame] | 529 | curr_entry = &pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex]; |
Matthias Beyer | 31f4f3f | 2014-07-15 09:42:58 +0200 | [diff] [blame] | 530 | if (curr_entry->bUsed && |
| 531 | curr_entry->pstPhsRule && |
| 532 | (curr_entry->pstPhsRule->u8PHSI == u8PHSI)) { |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 533 | |
Matthias Beyer | 31f4f3f | 2014-07-15 09:42:58 +0200 | [diff] [blame] | 534 | if (curr_entry->pstPhsRule->u8RefCnt) |
| 535 | curr_entry->pstPhsRule->u8RefCnt--; |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 536 | |
Matthias Beyer | 31f4f3f | 2014-07-15 09:42:58 +0200 | [diff] [blame] | 537 | if (0 == curr_entry->pstPhsRule->u8RefCnt) |
| 538 | kfree(curr_entry->pstPhsRule); |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 539 | |
Matthias Beyer | 31f4f3f | 2014-07-15 09:42:58 +0200 | [diff] [blame] | 540 | memset(curr_entry, |
| 541 | 0, |
| 542 | sizeof(struct bcm_phs_classifier_entry)); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 543 | } |
| 544 | } |
| 545 | } |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 546 | } |
Peter Senna Tschudin | 4764ca9 | 2014-05-26 16:08:50 +0200 | [diff] [blame] | 547 | return 0; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 548 | } |
| 549 | |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 550 | /* |
| 551 | * PhsDeleteClassifierRule |
| 552 | * |
| 553 | * Routine Description: |
| 554 | * Exported function to Delete a PHS Rule for the SFID,CLSID Pair. |
| 555 | * |
| 556 | * Arguments: |
| 557 | * IN void* pvContext - PHS Driver Specific Context |
| 558 | * IN B_UINT16 uiVcid - The Service Flow ID for which the PHS rule applies |
| 559 | * IN B_UINT16 uiClsId - The Classifier ID within the Service Flow for which the PHS rule applies. |
| 560 | * |
| 561 | * Return Value: |
| 562 | * |
| 563 | * 0 if successful, |
| 564 | * >0 Error. |
| 565 | */ |
Matthias Beyer | e86bd61 | 2014-07-15 09:43:15 +0200 | [diff] [blame] | 566 | ULONG PhsDeleteClassifierRule(IN void *pvContext, |
| 567 | IN B_UINT16 uiVcid, |
| 568 | IN B_UINT16 uiClsId) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 569 | { |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 570 | UINT nSFIndex = 0, nClsidIndex = 0; |
Kevin McKinney | db134a6 | 2012-12-20 00:31:30 -0500 | [diff] [blame] | 571 | struct bcm_phs_entry *pstServiceFlowEntry = NULL; |
Kevin McKinney | 2212e93 | 2012-12-20 00:31:32 -0500 | [diff] [blame] | 572 | struct bcm_phs_classifier_entry *pstClassifierEntry = NULL; |
Kevin McKinney | 2979460 | 2012-05-26 12:05:12 -0400 | [diff] [blame] | 573 | struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 574 | struct bcm_phs_extension *pDeviceExtension = |
| 575 | (struct bcm_phs_extension *)pvContext; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 576 | |
Matthias Beyer | 525afdd | 2014-07-15 09:42:59 +0200 | [diff] [blame] | 577 | if (!pDeviceExtension) |
| 578 | goto out; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 579 | |
Matthias Beyer | 525afdd | 2014-07-15 09:42:59 +0200 | [diff] [blame] | 580 | /* Retrieve the SFID Entry Index for requested Service Flow */ |
| 581 | nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable, |
| 582 | uiVcid, &pstServiceFlowEntry); |
| 583 | if (nSFIndex == PHS_INVALID_TABLE_INDEX) { |
| 584 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, |
| 585 | DBG_LVL_ALL, "SFID Match Failed\n"); |
| 586 | return ERR_SF_MATCH_FAIL; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 587 | } |
Matthias Beyer | 525afdd | 2014-07-15 09:42:59 +0200 | [diff] [blame] | 588 | |
Matthias Beyer | 93cc6ae | 2014-07-15 09:43:00 +0200 | [diff] [blame] | 589 | nClsidIndex = |
| 590 | GetClassifierEntry(pstServiceFlowEntry->pstClassifierTable, |
| 591 | uiClsId, |
| 592 | eActiveClassifierRuleContext, |
| 593 | &pstClassifierEntry); |
Matthias Beyer | 525afdd | 2014-07-15 09:42:59 +0200 | [diff] [blame] | 594 | |
Matthias Beyer | 93cc6ae | 2014-07-15 09:43:00 +0200 | [diff] [blame] | 595 | if ((nClsidIndex != PHS_INVALID_TABLE_INDEX) && |
| 596 | (!pstClassifierEntry->bUnclassifiedPHSRule)) { |
Matthias Beyer | 525afdd | 2014-07-15 09:42:59 +0200 | [diff] [blame] | 597 | if (pstClassifierEntry->pstPhsRule) { |
| 598 | if (pstClassifierEntry->pstPhsRule->u8RefCnt) |
| 599 | pstClassifierEntry->pstPhsRule->u8RefCnt--; |
| 600 | |
| 601 | if (0 == pstClassifierEntry->pstPhsRule->u8RefCnt) |
| 602 | kfree(pstClassifierEntry->pstPhsRule); |
| 603 | } |
| 604 | memset(pstClassifierEntry, 0, |
| 605 | sizeof(struct bcm_phs_classifier_entry)); |
| 606 | } |
| 607 | |
Matthias Beyer | 93cc6ae | 2014-07-15 09:43:00 +0200 | [diff] [blame] | 608 | nClsidIndex = |
| 609 | GetClassifierEntry(pstServiceFlowEntry->pstClassifierTable, |
| 610 | uiClsId, |
| 611 | eOldClassifierRuleContext, |
| 612 | &pstClassifierEntry); |
Matthias Beyer | 525afdd | 2014-07-15 09:42:59 +0200 | [diff] [blame] | 613 | |
Matthias Beyer | 93cc6ae | 2014-07-15 09:43:00 +0200 | [diff] [blame] | 614 | if ((nClsidIndex != PHS_INVALID_TABLE_INDEX) && |
| 615 | (!pstClassifierEntry->bUnclassifiedPHSRule)) { |
Matthias Beyer | 525afdd | 2014-07-15 09:42:59 +0200 | [diff] [blame] | 616 | kfree(pstClassifierEntry->pstPhsRule); |
| 617 | memset(pstClassifierEntry, 0, |
| 618 | sizeof(struct bcm_phs_classifier_entry)); |
| 619 | } |
| 620 | |
| 621 | out: |
Peter Senna Tschudin | 4764ca9 | 2014-05-26 16:08:50 +0200 | [diff] [blame] | 622 | return 0; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 623 | } |
| 624 | |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 625 | /* |
| 626 | * PhsDeleteSFRules |
| 627 | * |
| 628 | * Routine Description: |
| 629 | * Exported function to Delete a all PHS Rules for the SFID. |
| 630 | * |
| 631 | * Arguments: |
| 632 | * IN void* pvContext - PHS Driver Specific Context |
| 633 | * IN B_UINT16 uiVcid - The Service Flow ID for which the PHS rules need to be deleted |
| 634 | * |
| 635 | * Return Value: |
| 636 | * |
| 637 | * 0 if successful, |
| 638 | * >0 Error. |
| 639 | */ |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 640 | ULONG PhsDeleteSFRules(IN void *pvContext, IN B_UINT16 uiVcid) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 641 | { |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 642 | UINT nSFIndex = 0, nClsidIndex = 0; |
Kevin McKinney | db134a6 | 2012-12-20 00:31:30 -0500 | [diff] [blame] | 643 | struct bcm_phs_entry *pstServiceFlowEntry = NULL; |
Kevin McKinney | a700dbd | 2012-12-20 00:31:31 -0500 | [diff] [blame] | 644 | struct bcm_phs_classifier_table *pstClassifierRulesTable = NULL; |
Kevin McKinney | 2979460 | 2012-05-26 12:05:12 -0400 | [diff] [blame] | 645 | struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 646 | struct bcm_phs_extension *pDeviceExtension = |
| 647 | (struct bcm_phs_extension *)pvContext; |
Matthias Beyer | a984b12 | 2014-07-15 09:43:02 +0200 | [diff] [blame] | 648 | struct bcm_phs_classifier_entry *curr_clsf_entry; |
| 649 | struct bcm_phs_classifier_entry *curr_rules_list; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 650 | |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 651 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, |
| 652 | "====>\n"); |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 653 | |
Matthias Beyer | fc38bc1 | 2014-07-15 09:43:01 +0200 | [diff] [blame] | 654 | if (!pDeviceExtension) |
| 655 | goto out; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 656 | |
Matthias Beyer | fc38bc1 | 2014-07-15 09:43:01 +0200 | [diff] [blame] | 657 | /* Retrieve the SFID Entry Index for requested Service Flow */ |
| 658 | nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable, |
| 659 | uiVcid, &pstServiceFlowEntry); |
| 660 | if (nSFIndex == PHS_INVALID_TABLE_INDEX) { |
| 661 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, |
| 662 | DBG_LVL_ALL, "SFID Match Failed\n"); |
| 663 | return ERR_SF_MATCH_FAIL; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 664 | } |
| 665 | |
Matthias Beyer | fc38bc1 | 2014-07-15 09:43:01 +0200 | [diff] [blame] | 666 | pstClassifierRulesTable = pstServiceFlowEntry->pstClassifierTable; |
| 667 | if (pstClassifierRulesTable) { |
| 668 | for (nClsidIndex = 0; nClsidIndex < MAX_PHSRULE_PER_SF; nClsidIndex++) { |
Matthias Beyer | a984b12 | 2014-07-15 09:43:02 +0200 | [diff] [blame] | 669 | curr_clsf_entry = |
| 670 | &pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex]; |
Matthias Beyer | fc38bc1 | 2014-07-15 09:43:01 +0200 | [diff] [blame] | 671 | |
Matthias Beyer | a984b12 | 2014-07-15 09:43:02 +0200 | [diff] [blame] | 672 | curr_rules_list = |
| 673 | &pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex]; |
Matthias Beyer | fc38bc1 | 2014-07-15 09:43:01 +0200 | [diff] [blame] | 674 | |
Matthias Beyer | a984b12 | 2014-07-15 09:43:02 +0200 | [diff] [blame] | 675 | if (curr_clsf_entry->pstPhsRule) { |
Matthias Beyer | fc38bc1 | 2014-07-15 09:43:01 +0200 | [diff] [blame] | 676 | |
Matthias Beyer | a984b12 | 2014-07-15 09:43:02 +0200 | [diff] [blame] | 677 | if (curr_clsf_entry->pstPhsRule->u8RefCnt) |
| 678 | curr_clsf_entry->pstPhsRule->u8RefCnt--; |
| 679 | |
| 680 | if (0 == curr_clsf_entry->pstPhsRule->u8RefCnt) |
| 681 | kfree(curr_clsf_entry->pstPhsRule); |
| 682 | |
| 683 | curr_clsf_entry->pstPhsRule = NULL; |
Matthias Beyer | fc38bc1 | 2014-07-15 09:43:01 +0200 | [diff] [blame] | 684 | } |
Matthias Beyer | a984b12 | 2014-07-15 09:43:02 +0200 | [diff] [blame] | 685 | memset(curr_clsf_entry, 0, |
| 686 | sizeof(struct bcm_phs_classifier_entry)); |
| 687 | if (curr_rules_list->pstPhsRule) { |
Matthias Beyer | fc38bc1 | 2014-07-15 09:43:01 +0200 | [diff] [blame] | 688 | |
Matthias Beyer | a984b12 | 2014-07-15 09:43:02 +0200 | [diff] [blame] | 689 | if (curr_rules_list->pstPhsRule->u8RefCnt) |
| 690 | curr_rules_list->pstPhsRule->u8RefCnt--; |
Matthias Beyer | fc38bc1 | 2014-07-15 09:43:01 +0200 | [diff] [blame] | 691 | |
Matthias Beyer | a984b12 | 2014-07-15 09:43:02 +0200 | [diff] [blame] | 692 | if (0 == curr_rules_list->pstPhsRule->u8RefCnt) |
| 693 | kfree(curr_rules_list->pstPhsRule); |
Matthias Beyer | fc38bc1 | 2014-07-15 09:43:01 +0200 | [diff] [blame] | 694 | |
Matthias Beyer | a984b12 | 2014-07-15 09:43:02 +0200 | [diff] [blame] | 695 | curr_rules_list->pstPhsRule = NULL; |
Matthias Beyer | fc38bc1 | 2014-07-15 09:43:01 +0200 | [diff] [blame] | 696 | } |
Matthias Beyer | a984b12 | 2014-07-15 09:43:02 +0200 | [diff] [blame] | 697 | memset(curr_rules_list, 0, |
| 698 | sizeof(struct bcm_phs_classifier_entry)); |
Matthias Beyer | fc38bc1 | 2014-07-15 09:43:01 +0200 | [diff] [blame] | 699 | } |
| 700 | } |
| 701 | pstServiceFlowEntry->bUsed = false; |
| 702 | pstServiceFlowEntry->uiVcid = 0; |
| 703 | |
| 704 | out: |
Peter Senna Tschudin | 4764ca9 | 2014-05-26 16:08:50 +0200 | [diff] [blame] | 705 | return 0; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 706 | } |
| 707 | |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 708 | /* |
| 709 | * PhsCompress |
| 710 | * |
| 711 | * Routine Description: |
| 712 | * Exported function to compress the data using PHS. |
| 713 | * |
| 714 | * Arguments: |
Matthias Beyer | e86bd61 | 2014-07-15 09:43:15 +0200 | [diff] [blame] | 715 | * IN void* pvContext - PHS Driver Specific Context. |
| 716 | * IN B_UINT16 uiVcid - The Service Flow ID to which current |
| 717 | * packet header compression applies. |
| 718 | * IN UINT uiClsId - The Classifier ID to which current packet |
| 719 | * header compression applies. |
| 720 | * IN void *pvInputBuffer - The Input buffer containg packet header |
| 721 | * data |
| 722 | * IN void *pvOutputBuffer - The output buffer returned by this |
| 723 | * function after PHS |
| 724 | * IN UINT *pOldHeaderSize - The actual size of the header before PHS |
| 725 | * IN UINT *pNewHeaderSize - The new size of the header after applying |
| 726 | * PHS |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 727 | * |
| 728 | * Return Value: |
| 729 | * |
| 730 | * 0 if successful, |
| 731 | * >0 Error. |
| 732 | */ |
Shalin Mehta | f2be635 | 2013-09-17 00:42:17 -0700 | [diff] [blame] | 733 | static ULONG PhsCompress(IN void *pvContext, |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 734 | IN B_UINT16 uiVcid, |
| 735 | IN B_UINT16 uiClsId, |
| 736 | IN void *pvInputBuffer, |
| 737 | OUT void *pvOutputBuffer, |
| 738 | OUT UINT *pOldHeaderSize, |
| 739 | OUT UINT *pNewHeaderSize) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 740 | { |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 741 | UINT nSFIndex = 0, nClsidIndex = 0; |
Kevin McKinney | db134a6 | 2012-12-20 00:31:30 -0500 | [diff] [blame] | 742 | struct bcm_phs_entry *pstServiceFlowEntry = NULL; |
Kevin McKinney | 2212e93 | 2012-12-20 00:31:32 -0500 | [diff] [blame] | 743 | struct bcm_phs_classifier_entry *pstClassifierEntry = NULL; |
Kevin McKinney | a903d65 | 2012-12-20 00:31:34 -0500 | [diff] [blame] | 744 | struct bcm_phs_rule *pstPhsRule = NULL; |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 745 | ULONG lStatus = 0; |
Kevin McKinney | 2979460 | 2012-05-26 12:05:12 -0400 | [diff] [blame] | 746 | struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 747 | struct bcm_phs_extension *pDeviceExtension = |
| 748 | (struct bcm_phs_extension *)pvContext; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 749 | |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 750 | if (pDeviceExtension == NULL) { |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 751 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, |
| 752 | "Invalid Device Extension\n"); |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 753 | lStatus = STATUS_PHS_NOCOMPRESSION; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 754 | return lStatus; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 755 | } |
| 756 | |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 757 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, |
| 758 | "Suppressing header\n"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 759 | |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 760 | /* Retrieve the SFID Entry Index for requested Service Flow */ |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 761 | nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable, |
Matthias Beyer | babb7f9 | 2014-07-15 09:43:03 +0200 | [diff] [blame] | 762 | uiVcid, &pstServiceFlowEntry); |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 763 | if (nSFIndex == PHS_INVALID_TABLE_INDEX) { |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 764 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, |
| 765 | "SFID Match Failed\n"); |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 766 | lStatus = STATUS_PHS_NOCOMPRESSION; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 767 | return lStatus; |
| 768 | } |
| 769 | |
| 770 | nClsidIndex = GetClassifierEntry(pstServiceFlowEntry->pstClassifierTable, |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 771 | uiClsId, eActiveClassifierRuleContext, |
| 772 | &pstClassifierEntry); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 773 | |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 774 | if (nClsidIndex == PHS_INVALID_TABLE_INDEX) { |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 775 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, |
| 776 | "No PHS Rule Defined For Classifier\n"); |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 777 | lStatus = STATUS_PHS_NOCOMPRESSION; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 778 | return lStatus; |
| 779 | } |
| 780 | |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 781 | /* get rule from SF id,Cls ID pair and proceed */ |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 782 | pstPhsRule = pstClassifierEntry->pstPhsRule; |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 783 | if (!ValidatePHSRuleComplete(pstPhsRule)) { |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 784 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, |
| 785 | "PHS Rule Defined For Classifier But Not Complete\n"); |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 786 | lStatus = STATUS_PHS_NOCOMPRESSION; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 787 | return lStatus; |
| 788 | } |
| 789 | |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 790 | /* Compress Packet */ |
Matthias Beyer | babb7f9 | 2014-07-15 09:43:03 +0200 | [diff] [blame] | 791 | lStatus = phs_compress(pstPhsRule, |
| 792 | (PUCHAR)pvInputBuffer, |
| 793 | (PUCHAR)pvOutputBuffer, |
| 794 | pOldHeaderSize, |
| 795 | pNewHeaderSize); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 796 | |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 797 | if (lStatus == STATUS_PHS_COMPRESSED) { |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 798 | pstPhsRule->PHSModifiedBytes += |
| 799 | *pOldHeaderSize - *pNewHeaderSize - 1; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 800 | pstPhsRule->PHSModifiedNumPackets++; |
Matthias Beyer | b43b245 | 2014-07-15 09:43:04 +0200 | [diff] [blame] | 801 | } else { |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 802 | pstPhsRule->PHSErrorNumPackets++; |
Matthias Beyer | b43b245 | 2014-07-15 09:43:04 +0200 | [diff] [blame] | 803 | } |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 804 | |
| 805 | return lStatus; |
| 806 | } |
| 807 | |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 808 | /* |
| 809 | * PhsDeCompress |
| 810 | * |
| 811 | * Routine Description: |
| 812 | * Exported function to restore the packet header in Rx path. |
| 813 | * |
| 814 | * Arguments: |
Matthias Beyer | e86bd61 | 2014-07-15 09:43:15 +0200 | [diff] [blame] | 815 | * IN void* pvContext - PHS Driver Specific Context. |
| 816 | * IN B_UINT16 uiVcid - The Service Flow ID to which current |
| 817 | * packet header restoration applies. |
| 818 | * IN void *pvInputBuffer - The Input buffer containg suppressed |
| 819 | * packet header data |
| 820 | * OUT void *pvOutputBuffer - The output buffer returned by this |
| 821 | * function after restoration |
| 822 | * OUT UINT *pHeaderSize - The packet header size after restoration |
| 823 | * is returned in this parameter. |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 824 | * |
| 825 | * Return Value: |
| 826 | * |
| 827 | * 0 if successful, |
| 828 | * >0 Error. |
| 829 | */ |
Shalin Mehta | f2be635 | 2013-09-17 00:42:17 -0700 | [diff] [blame] | 830 | static ULONG PhsDeCompress(IN void *pvContext, |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 831 | IN B_UINT16 uiVcid, |
| 832 | IN void *pvInputBuffer, |
| 833 | OUT void *pvOutputBuffer, |
| 834 | OUT UINT *pInHeaderSize, |
| 835 | OUT UINT *pOutHeaderSize) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 836 | { |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 837 | UINT nSFIndex = 0, nPhsRuleIndex = 0; |
Kevin McKinney | db134a6 | 2012-12-20 00:31:30 -0500 | [diff] [blame] | 838 | struct bcm_phs_entry *pstServiceFlowEntry = NULL; |
Kevin McKinney | a903d65 | 2012-12-20 00:31:34 -0500 | [diff] [blame] | 839 | struct bcm_phs_rule *pstPhsRule = NULL; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 840 | UINT phsi; |
Kevin McKinney | 2979460 | 2012-05-26 12:05:12 -0400 | [diff] [blame] | 841 | struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 842 | struct bcm_phs_extension *pDeviceExtension = |
| 843 | (struct bcm_phs_extension *)pvContext; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 844 | |
| 845 | *pInHeaderSize = 0; |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 846 | if (pDeviceExtension == NULL) { |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 847 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, |
| 848 | DBG_LVL_ALL, "Invalid Device Extension\n"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 849 | return ERR_PHS_INVALID_DEVICE_EXETENSION; |
| 850 | } |
| 851 | |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 852 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, DBG_LVL_ALL, |
| 853 | "Restoring header\n"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 854 | |
| 855 | phsi = *((unsigned char *)(pvInputBuffer)); |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 856 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, DBG_LVL_ALL, |
| 857 | "PHSI To Be Used For restore : %x\n", phsi); |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 858 | if (phsi == UNCOMPRESSED_PACKET) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 859 | return STATUS_PHS_NOCOMPRESSION; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 860 | |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 861 | /* Retrieve the SFID Entry Index for requested Service Flow */ |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 862 | nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable, |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 863 | uiVcid, &pstServiceFlowEntry); |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 864 | if (nSFIndex == PHS_INVALID_TABLE_INDEX) { |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 865 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, |
| 866 | DBG_LVL_ALL, |
| 867 | "SFID Match Failed During Lookup\n"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 868 | return ERR_SF_MATCH_FAIL; |
| 869 | } |
| 870 | |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 871 | nPhsRuleIndex = GetPhsRuleEntry(pstServiceFlowEntry->pstClassifierTable, |
| 872 | phsi, |
| 873 | eActiveClassifierRuleContext, |
| 874 | &pstPhsRule); |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 875 | if (nPhsRuleIndex == PHS_INVALID_TABLE_INDEX) { |
Matthias Beyer | e86bd61 | 2014-07-15 09:43:15 +0200 | [diff] [blame] | 876 | /* Phs Rule does not exist in active rules table. Lets try |
| 877 | * in the old rules table. */ |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 878 | nPhsRuleIndex = GetPhsRuleEntry(pstServiceFlowEntry->pstClassifierTable, |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 879 | phsi, |
| 880 | eOldClassifierRuleContext, |
| 881 | &pstPhsRule); |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 882 | if (nPhsRuleIndex == PHS_INVALID_TABLE_INDEX) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 883 | return ERR_PHSRULE_MATCH_FAIL; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 884 | } |
| 885 | |
| 886 | *pInHeaderSize = phs_decompress((PUCHAR)pvInputBuffer, |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 887 | (PUCHAR)pvOutputBuffer, |
| 888 | pstPhsRule, |
| 889 | pOutHeaderSize); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 890 | |
| 891 | pstPhsRule->PHSModifiedBytes += *pOutHeaderSize - *pInHeaderSize - 1; |
| 892 | |
| 893 | pstPhsRule->PHSModifiedNumPackets++; |
| 894 | return STATUS_PHS_COMPRESSED; |
| 895 | } |
| 896 | |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 897 | /* |
| 898 | * Procedure: free_phs_serviceflow_rules |
| 899 | * |
Matthias Beyer | e86bd61 | 2014-07-15 09:43:15 +0200 | [diff] [blame] | 900 | * Description: This routine is responsible for freeing memory allocated for |
| 901 | * PHS rules. |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 902 | * |
| 903 | * Arguments: |
| 904 | * rules - ptr to S_SERVICEFLOW_TABLE structure. |
| 905 | * |
| 906 | * Returns: |
| 907 | * Does not return any value. |
| 908 | */ |
Kevin McKinney | da4d150 | 2012-12-20 00:31:29 -0500 | [diff] [blame] | 909 | static void free_phs_serviceflow_rules(struct bcm_phs_table *psServiceFlowRulesTable) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 910 | { |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 911 | int i, j; |
Kevin McKinney | 2979460 | 2012-05-26 12:05:12 -0400 | [diff] [blame] | 912 | struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); |
Matthias Beyer | 3ed150a | 2014-07-15 09:43:05 +0200 | [diff] [blame] | 913 | struct bcm_phs_classifier_entry *curr_act_rules_list; |
| 914 | struct bcm_phs_classifier_entry *curr_old_rules_list; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 915 | |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 916 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, |
| 917 | "=======>\n"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 918 | |
Matthias Beyer | c8020cc | 2014-07-15 09:43:06 +0200 | [diff] [blame] | 919 | if (!psServiceFlowRulesTable) |
| 920 | goto out; |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 921 | |
Matthias Beyer | c8020cc | 2014-07-15 09:43:06 +0200 | [diff] [blame] | 922 | for (i = 0; i < MAX_SERVICEFLOWS; i++) { |
| 923 | struct bcm_phs_entry stServiceFlowEntry = |
| 924 | psServiceFlowRulesTable->stSFList[i]; |
| 925 | struct bcm_phs_classifier_table *pstClassifierRulesTable = |
| 926 | stServiceFlowEntry.pstClassifierTable; |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 927 | |
Matthias Beyer | c8020cc | 2014-07-15 09:43:06 +0200 | [diff] [blame] | 928 | if (pstClassifierRulesTable) { |
| 929 | for (j = 0; j < MAX_PHSRULE_PER_SF; j++) { |
| 930 | curr_act_rules_list = |
| 931 | &pstClassifierRulesTable->stActivePhsRulesList[j]; |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 932 | |
Matthias Beyer | c8020cc | 2014-07-15 09:43:06 +0200 | [diff] [blame] | 933 | curr_old_rules_list = |
| 934 | &pstClassifierRulesTable->stOldPhsRulesList[j]; |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 935 | |
Matthias Beyer | c8020cc | 2014-07-15 09:43:06 +0200 | [diff] [blame] | 936 | if (curr_act_rules_list->pstPhsRule) { |
Matthias Beyer | 3ed150a | 2014-07-15 09:43:05 +0200 | [diff] [blame] | 937 | |
Matthias Beyer | c8020cc | 2014-07-15 09:43:06 +0200 | [diff] [blame] | 938 | if (curr_act_rules_list->pstPhsRule->u8RefCnt) |
| 939 | curr_act_rules_list->pstPhsRule->u8RefCnt--; |
Matthias Beyer | 3ed150a | 2014-07-15 09:43:05 +0200 | [diff] [blame] | 940 | |
Matthias Beyer | c8020cc | 2014-07-15 09:43:06 +0200 | [diff] [blame] | 941 | if (0 == curr_act_rules_list->pstPhsRule->u8RefCnt) |
| 942 | kfree(curr_act_rules_list->pstPhsRule); |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 943 | |
Matthias Beyer | c8020cc | 2014-07-15 09:43:06 +0200 | [diff] [blame] | 944 | curr_act_rules_list->pstPhsRule = NULL; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 945 | } |
Matthias Beyer | c8020cc | 2014-07-15 09:43:06 +0200 | [diff] [blame] | 946 | |
| 947 | if (curr_old_rules_list->pstPhsRule) { |
| 948 | |
| 949 | if (curr_old_rules_list->pstPhsRule->u8RefCnt) |
| 950 | curr_old_rules_list->pstPhsRule->u8RefCnt--; |
| 951 | |
| 952 | if (0 == curr_old_rules_list->pstPhsRule->u8RefCnt) |
| 953 | kfree(curr_old_rules_list->pstPhsRule); |
| 954 | |
| 955 | curr_old_rules_list->pstPhsRule = NULL; |
| 956 | } |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 957 | } |
Matthias Beyer | c8020cc | 2014-07-15 09:43:06 +0200 | [diff] [blame] | 958 | kfree(pstClassifierRulesTable); |
| 959 | stServiceFlowEntry.pstClassifierTable = |
| 960 | pstClassifierRulesTable = NULL; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 961 | } |
| 962 | } |
| 963 | |
Matthias Beyer | c8020cc | 2014-07-15 09:43:06 +0200 | [diff] [blame] | 964 | out: |
| 965 | |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 966 | kfree(psServiceFlowRulesTable); |
| 967 | psServiceFlowRulesTable = NULL; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 968 | } |
| 969 | |
Matthias Beyer | 14d8e91 | 2014-07-15 09:43:08 +0200 | [diff] [blame] | 970 | static bool ValidatePHSRuleComplete(IN const struct bcm_phs_rule *psPhsRule) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 971 | { |
Matthias Beyer | cc872f8 | 2014-07-15 09:43:07 +0200 | [diff] [blame] | 972 | return (psPhsRule && |
| 973 | psPhsRule->u8PHSI && |
| 974 | psPhsRule->u8PHSS && |
| 975 | psPhsRule->u8PHSFLength); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 976 | } |
| 977 | |
Kevin McKinney | da4d150 | 2012-12-20 00:31:29 -0500 | [diff] [blame] | 978 | UINT GetServiceFlowEntry(IN struct bcm_phs_table *psServiceFlowTable, |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 979 | IN B_UINT16 uiVcid, |
| 980 | struct bcm_phs_entry **ppstServiceFlowEntry) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 981 | { |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 982 | int i; |
Matthias Beyer | cf42356 | 2014-07-15 09:43:09 +0200 | [diff] [blame] | 983 | struct bcm_phs_entry *curr_sf_list; |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 984 | |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 985 | for (i = 0; i < MAX_SERVICEFLOWS; i++) { |
Matthias Beyer | cf42356 | 2014-07-15 09:43:09 +0200 | [diff] [blame] | 986 | curr_sf_list = &psServiceFlowTable->stSFList[i]; |
Matthias Beyer | c842dd2 | 2014-07-15 09:43:10 +0200 | [diff] [blame] | 987 | if (curr_sf_list->bUsed && (curr_sf_list->uiVcid == uiVcid)) { |
| 988 | *ppstServiceFlowEntry = curr_sf_list; |
| 989 | return i; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 990 | } |
| 991 | } |
| 992 | |
| 993 | *ppstServiceFlowEntry = NULL; |
| 994 | return PHS_INVALID_TABLE_INDEX; |
| 995 | } |
| 996 | |
Shalin Mehta | f2be635 | 2013-09-17 00:42:17 -0700 | [diff] [blame] | 997 | static UINT GetClassifierEntry(IN struct bcm_phs_classifier_table *pstClassifierTable, |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 998 | IN B_UINT32 uiClsid, |
| 999 | enum bcm_phs_classifier_context eClsContext, |
| 1000 | OUT struct bcm_phs_classifier_entry **ppstClassifierEntry) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1001 | { |
| 1002 | int i; |
Kevin McKinney | 2212e93 | 2012-12-20 00:31:32 -0500 | [diff] [blame] | 1003 | struct bcm_phs_classifier_entry *psClassifierRules = NULL; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1004 | |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 1005 | for (i = 0; i < MAX_PHSRULE_PER_SF; i++) { |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1006 | |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 1007 | if (eClsContext == eActiveClassifierRuleContext) |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 1008 | psClassifierRules = |
| 1009 | &pstClassifierTable->stActivePhsRulesList[i]; |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 1010 | else |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 1011 | psClassifierRules = |
| 1012 | &pstClassifierTable->stOldPhsRulesList[i]; |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 1013 | |
Matthias Beyer | 1c53f08 | 2014-07-15 09:43:11 +0200 | [diff] [blame] | 1014 | if (psClassifierRules->bUsed && |
| 1015 | (psClassifierRules->uiClassifierRuleId == uiClsid)) { |
| 1016 | *ppstClassifierEntry = psClassifierRules; |
| 1017 | return i; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1018 | } |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1019 | } |
| 1020 | |
| 1021 | *ppstClassifierEntry = NULL; |
| 1022 | return PHS_INVALID_TABLE_INDEX; |
| 1023 | } |
| 1024 | |
Kevin McKinney | a700dbd | 2012-12-20 00:31:31 -0500 | [diff] [blame] | 1025 | static UINT GetPhsRuleEntry(IN struct bcm_phs_classifier_table *pstClassifierTable, |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 1026 | IN B_UINT32 uiPHSI, |
| 1027 | enum bcm_phs_classifier_context eClsContext, |
| 1028 | OUT struct bcm_phs_rule **ppstPhsRule) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1029 | { |
| 1030 | int i; |
Kevin McKinney | 2212e93 | 2012-12-20 00:31:32 -0500 | [diff] [blame] | 1031 | struct bcm_phs_classifier_entry *pstClassifierRule = NULL; |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1032 | |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 1033 | for (i = 0; i < MAX_PHSRULE_PER_SF; i++) { |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1034 | if (eClsContext == eActiveClassifierRuleContext) |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 1035 | pstClassifierRule = |
| 1036 | &pstClassifierTable->stActivePhsRulesList[i]; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1037 | else |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 1038 | pstClassifierRule = |
| 1039 | &pstClassifierTable->stOldPhsRulesList[i]; |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1040 | |
Matthias Beyer | 18002f5 | 2014-07-15 09:43:12 +0200 | [diff] [blame] | 1041 | if (pstClassifierRule->bUsed && |
| 1042 | (pstClassifierRule->u8PHSI == uiPHSI)) { |
| 1043 | *ppstPhsRule = pstClassifierRule->pstPhsRule; |
| 1044 | return i; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1045 | } |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1046 | } |
| 1047 | |
| 1048 | *ppstPhsRule = NULL; |
| 1049 | return PHS_INVALID_TABLE_INDEX; |
| 1050 | } |
| 1051 | |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 1052 | static UINT CreateSFToClassifierRuleMapping(IN B_UINT16 uiVcid, |
| 1053 | IN B_UINT16 uiClsId, |
| 1054 | IN struct bcm_phs_table *psServiceFlowTable, |
| 1055 | struct bcm_phs_rule *psPhsRule, |
| 1056 | B_UINT8 u8AssociatedPHSI) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1057 | { |
Kevin McKinney | a700dbd | 2012-12-20 00:31:31 -0500 | [diff] [blame] | 1058 | struct bcm_phs_classifier_table *psaClassifiertable = NULL; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1059 | UINT uiStatus = 0; |
| 1060 | int iSfIndex; |
Lisa Nguyen | f70c8a9 | 2013-10-28 01:36:19 -0700 | [diff] [blame] | 1061 | bool bFreeEntryFound = false; |
Matthias Beyer | 9128349 | 2014-07-15 09:43:13 +0200 | [diff] [blame] | 1062 | struct bcm_phs_entry *curr_list; |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1063 | |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 1064 | /* Check for a free entry in SFID table */ |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 1065 | for (iSfIndex = 0; iSfIndex < MAX_SERVICEFLOWS; iSfIndex++) { |
Matthias Beyer | 9128349 | 2014-07-15 09:43:13 +0200 | [diff] [blame] | 1066 | curr_list = &psServiceFlowTable->stSFList[iSfIndex]; |
| 1067 | if (!curr_list->bUsed) { |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1068 | bFreeEntryFound = TRUE; |
| 1069 | break; |
| 1070 | } |
| 1071 | } |
| 1072 | |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1073 | if (!bFreeEntryFound) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1074 | return ERR_SFTABLE_FULL; |
| 1075 | |
Matthias Beyer | 9128349 | 2014-07-15 09:43:13 +0200 | [diff] [blame] | 1076 | psaClassifiertable = curr_list->pstClassifierTable; |
| 1077 | uiStatus = CreateClassifierPHSRule(uiClsId, |
| 1078 | psaClassifiertable, |
| 1079 | psPhsRule, |
| 1080 | eActiveClassifierRuleContext, |
| 1081 | u8AssociatedPHSI); |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 1082 | if (uiStatus == PHS_SUCCESS) { |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 1083 | /* Add entry at free index to the SF */ |
Matthias Beyer | 9128349 | 2014-07-15 09:43:13 +0200 | [diff] [blame] | 1084 | curr_list->bUsed = TRUE; |
| 1085 | curr_list->uiVcid = uiVcid; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1086 | } |
| 1087 | |
| 1088 | return uiStatus; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1089 | } |
| 1090 | |
Shalin Mehta | f2be635 | 2013-09-17 00:42:17 -0700 | [diff] [blame] | 1091 | static UINT CreateClassiferToPHSRuleMapping(IN B_UINT16 uiVcid, |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 1092 | IN B_UINT16 uiClsId, |
| 1093 | IN struct bcm_phs_entry *pstServiceFlowEntry, |
| 1094 | struct bcm_phs_rule *psPhsRule, |
| 1095 | B_UINT8 u8AssociatedPHSI) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1096 | { |
Kevin McKinney | 2212e93 | 2012-12-20 00:31:32 -0500 | [diff] [blame] | 1097 | struct bcm_phs_classifier_entry *pstClassifierEntry = NULL; |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1098 | UINT uiStatus = PHS_SUCCESS; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1099 | UINT nClassifierIndex = 0; |
Kevin McKinney | a700dbd | 2012-12-20 00:31:31 -0500 | [diff] [blame] | 1100 | struct bcm_phs_classifier_table *psaClassifiertable = NULL; |
Kevin McKinney | 2979460 | 2012-05-26 12:05:12 -0400 | [diff] [blame] | 1101 | struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1102 | |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1103 | psaClassifiertable = pstServiceFlowEntry->pstClassifierTable; |
| 1104 | |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 1105 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, |
| 1106 | "==>"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1107 | |
| 1108 | /* Check if the supplied Classifier already exists */ |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1109 | nClassifierIndex = GetClassifierEntry( |
| 1110 | pstServiceFlowEntry->pstClassifierTable, |
| 1111 | uiClsId, |
| 1112 | eActiveClassifierRuleContext, |
| 1113 | &pstClassifierEntry); |
| 1114 | |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 1115 | if (nClassifierIndex == PHS_INVALID_TABLE_INDEX) { |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1116 | /* |
Matthias Beyer | e86bd61 | 2014-07-15 09:43:15 +0200 | [diff] [blame] | 1117 | * The Classifier doesn't exist. So its a new classifier being |
| 1118 | * added. |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 1119 | * Add new entry to associate PHS Rule to the Classifier |
| 1120 | */ |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1121 | |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1122 | uiStatus = CreateClassifierPHSRule(uiClsId, psaClassifiertable, |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 1123 | psPhsRule, |
| 1124 | eActiveClassifierRuleContext, |
| 1125 | u8AssociatedPHSI); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1126 | return uiStatus; |
| 1127 | } |
| 1128 | |
| 1129 | /* |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 1130 | * The Classifier exists.The PHS Rule for this classifier |
| 1131 | * is being modified |
| 1132 | */ |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1133 | |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 1134 | if (pstClassifierEntry->u8PHSI == psPhsRule->u8PHSI) { |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1135 | if (pstClassifierEntry->pstPhsRule == NULL) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1136 | return ERR_PHS_INVALID_PHS_RULE; |
| 1137 | |
| 1138 | /* |
Matthias Beyer | e86bd61 | 2014-07-15 09:43:15 +0200 | [diff] [blame] | 1139 | * This rule already exists if any fields are changed for this |
| 1140 | * PHS rule update them. |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 1141 | */ |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1142 | /* If any part of PHSF is valid then we update PHSF */ |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 1143 | if (psPhsRule->u8PHSFLength) { |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 1144 | /* update PHSF */ |
Stephen Hemminger | 082e889 | 2010-11-01 09:35:21 -0400 | [diff] [blame] | 1145 | memcpy(pstClassifierEntry->pstPhsRule->u8PHSF, |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 1146 | psPhsRule->u8PHSF, |
| 1147 | MAX_PHS_LENGTHS); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1148 | } |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1149 | |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 1150 | if (psPhsRule->u8PHSFLength) { |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 1151 | /* update PHSFLen */ |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 1152 | pstClassifierEntry->pstPhsRule->u8PHSFLength = |
| 1153 | psPhsRule->u8PHSFLength; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1154 | } |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1155 | |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 1156 | if (psPhsRule->u8PHSMLength) { |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 1157 | /* update PHSM */ |
Stephen Hemminger | 082e889 | 2010-11-01 09:35:21 -0400 | [diff] [blame] | 1158 | memcpy(pstClassifierEntry->pstPhsRule->u8PHSM, |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 1159 | psPhsRule->u8PHSM, |
| 1160 | MAX_PHS_LENGTHS); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1161 | } |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1162 | |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 1163 | if (psPhsRule->u8PHSMLength) { |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 1164 | /* update PHSM Len */ |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1165 | pstClassifierEntry->pstPhsRule->u8PHSMLength = |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1166 | psPhsRule->u8PHSMLength; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1167 | } |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1168 | |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 1169 | if (psPhsRule->u8PHSS) { |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 1170 | /* update PHSS */ |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 1171 | pstClassifierEntry->pstPhsRule->u8PHSS = |
| 1172 | psPhsRule->u8PHSS; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1173 | } |
| 1174 | |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 1175 | /* update PHSV */ |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1176 | pstClassifierEntry->pstPhsRule->u8PHSV = psPhsRule->u8PHSV; |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 1177 | } else { |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 1178 | /* A new rule is being set for this classifier. */ |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 1179 | uiStatus = UpdateClassifierPHSRule(uiClsId, |
| 1180 | pstClassifierEntry, |
| 1181 | psaClassifiertable, |
| 1182 | psPhsRule, |
| 1183 | u8AssociatedPHSI); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1184 | } |
| 1185 | |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1186 | return uiStatus; |
| 1187 | } |
| 1188 | |
Stephen Hemminger | 9dd47ee | 2010-11-01 12:24:00 -0400 | [diff] [blame] | 1189 | static UINT CreateClassifierPHSRule(IN B_UINT16 uiClsId, |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 1190 | struct bcm_phs_classifier_table *psaClassifiertable, |
| 1191 | struct bcm_phs_rule *psPhsRule, |
| 1192 | enum bcm_phs_classifier_context eClsContext, |
| 1193 | B_UINT8 u8AssociatedPHSI) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1194 | { |
| 1195 | UINT iClassifierIndex = 0; |
Lisa Nguyen | f70c8a9 | 2013-10-28 01:36:19 -0700 | [diff] [blame] | 1196 | bool bFreeEntryFound = false; |
Kevin McKinney | 2212e93 | 2012-12-20 00:31:32 -0500 | [diff] [blame] | 1197 | struct bcm_phs_classifier_entry *psClassifierRules = NULL; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1198 | UINT nStatus = PHS_SUCCESS; |
Kevin McKinney | 2979460 | 2012-05-26 12:05:12 -0400 | [diff] [blame] | 1199 | struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1200 | |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 1201 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, |
| 1202 | "Inside CreateClassifierPHSRule"); |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1203 | |
| 1204 | if (psaClassifiertable == NULL) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1205 | return ERR_INVALID_CLASSIFIERTABLE_FOR_SF; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1206 | |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 1207 | if (eClsContext == eOldClassifierRuleContext) { |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 1208 | /* |
| 1209 | * If An Old Entry for this classifier ID already exists in the |
| 1210 | * old rules table replace it. |
| 1211 | */ |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1212 | |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 1213 | iClassifierIndex = GetClassifierEntry(psaClassifiertable, |
| 1214 | uiClsId, |
| 1215 | eClsContext, |
| 1216 | &psClassifierRules); |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1217 | |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 1218 | if (iClassifierIndex != PHS_INVALID_TABLE_INDEX) { |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1219 | /* |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 1220 | * The Classifier already exists in the old rules table |
| 1221 | * Lets replace the old classifier with the new one. |
| 1222 | */ |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1223 | bFreeEntryFound = TRUE; |
| 1224 | } |
| 1225 | } |
| 1226 | |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 1227 | if (!bFreeEntryFound) { |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 1228 | /* Continue to search for a free location to add the rule */ |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1229 | for (iClassifierIndex = 0; iClassifierIndex < |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 1230 | MAX_PHSRULE_PER_SF; iClassifierIndex++) { |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1231 | if (eClsContext == eActiveClassifierRuleContext) |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1232 | psClassifierRules = &psaClassifiertable->stActivePhsRulesList[iClassifierIndex]; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1233 | else |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1234 | psClassifierRules = &psaClassifiertable->stOldPhsRulesList[iClassifierIndex]; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1235 | |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 1236 | if (!psClassifierRules->bUsed) { |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1237 | bFreeEntryFound = TRUE; |
| 1238 | break; |
| 1239 | } |
| 1240 | } |
| 1241 | } |
| 1242 | |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 1243 | if (!bFreeEntryFound) { |
| 1244 | |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1245 | if (eClsContext == eActiveClassifierRuleContext) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1246 | return ERR_CLSASSIFIER_TABLE_FULL; |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 1247 | else { |
Matthias Beyer | e86bd61 | 2014-07-15 09:43:15 +0200 | [diff] [blame] | 1248 | /* Lets replace the oldest rule if we are looking in |
| 1249 | * old Rule table */ |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1250 | if (psaClassifiertable->uiOldestPhsRuleIndex >= MAX_PHSRULE_PER_SF) |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1251 | psaClassifiertable->uiOldestPhsRuleIndex = 0; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1252 | |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 1253 | iClassifierIndex = |
| 1254 | psaClassifiertable->uiOldestPhsRuleIndex; |
| 1255 | psClassifierRules = |
| 1256 | &psaClassifiertable->stOldPhsRulesList[iClassifierIndex]; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1257 | |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1258 | (psaClassifiertable->uiOldestPhsRuleIndex)++; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1259 | } |
| 1260 | } |
| 1261 | |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 1262 | if (eClsContext == eOldClassifierRuleContext) { |
| 1263 | |
| 1264 | if (psClassifierRules->pstPhsRule == NULL) { |
| 1265 | |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 1266 | psClassifierRules->pstPhsRule = |
| 1267 | kmalloc(sizeof(struct bcm_phs_rule), |
| 1268 | GFP_KERNEL); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1269 | |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1270 | if (NULL == psClassifierRules->pstPhsRule) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1271 | return ERR_PHSRULE_MEMALLOC_FAIL; |
| 1272 | } |
| 1273 | |
| 1274 | psClassifierRules->bUsed = TRUE; |
| 1275 | psClassifierRules->uiClassifierRuleId = uiClsId; |
| 1276 | psClassifierRules->u8PHSI = psPhsRule->u8PHSI; |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 1277 | psClassifierRules->bUnclassifiedPHSRule = |
| 1278 | psPhsRule->bUnclassifiedPHSRule; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1279 | |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1280 | /* Update The PHS rule */ |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 1281 | memcpy(psClassifierRules->pstPhsRule, psPhsRule, |
| 1282 | sizeof(struct bcm_phs_rule)); |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 1283 | } else |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 1284 | nStatus = UpdateClassifierPHSRule(uiClsId, |
| 1285 | psClassifierRules, |
| 1286 | psaClassifiertable, |
| 1287 | psPhsRule, |
| 1288 | u8AssociatedPHSI); |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1289 | |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1290 | return nStatus; |
| 1291 | } |
| 1292 | |
Stephen Hemminger | 9dd47ee | 2010-11-01 12:24:00 -0400 | [diff] [blame] | 1293 | static UINT UpdateClassifierPHSRule(IN B_UINT16 uiClsId, |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 1294 | IN struct bcm_phs_classifier_entry *pstClassifierEntry, |
| 1295 | struct bcm_phs_classifier_table *psaClassifiertable, |
| 1296 | struct bcm_phs_rule *psPhsRule, |
| 1297 | B_UINT8 u8AssociatedPHSI) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1298 | { |
Kevin McKinney | a903d65 | 2012-12-20 00:31:34 -0500 | [diff] [blame] | 1299 | struct bcm_phs_rule *pstAddPhsRule = NULL; |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1300 | UINT nPhsRuleIndex = 0; |
Lisa Nguyen | f70c8a9 | 2013-10-28 01:36:19 -0700 | [diff] [blame] | 1301 | bool bPHSRuleOrphaned = false; |
Kevin McKinney | 2979460 | 2012-05-26 12:05:12 -0400 | [diff] [blame] | 1302 | struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1303 | |
| 1304 | psPhsRule->u8RefCnt = 0; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1305 | |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 1306 | /* Step 1 Deref Any Exisiting PHS Rule in this classifier Entry */ |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1307 | bPHSRuleOrphaned = DerefPhsRule(uiClsId, psaClassifiertable, |
| 1308 | pstClassifierEntry->pstPhsRule); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1309 | |
Matthias Beyer | e86bd61 | 2014-07-15 09:43:15 +0200 | [diff] [blame] | 1310 | /* Step 2 Search if there is a PHS Rule with u8AssociatedPHSI in |
| 1311 | * Classifier table for this SF */ |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1312 | nPhsRuleIndex = GetPhsRuleEntry(psaClassifiertable, u8AssociatedPHSI, |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 1313 | eActiveClassifierRuleContext, |
| 1314 | &pstAddPhsRule); |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 1315 | if (PHS_INVALID_TABLE_INDEX == nPhsRuleIndex) { |
| 1316 | |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 1317 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, |
| 1318 | DBG_LVL_ALL, |
| 1319 | "\nAdding New PHSRuleEntry For Classifier"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1320 | |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 1321 | if (psPhsRule->u8PHSI == 0) { |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 1322 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, |
| 1323 | DBG_LVL_ALL, "\nError PHSI is Zero\n"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1324 | return ERR_PHS_INVALID_PHS_RULE; |
| 1325 | } |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1326 | |
Matthias Beyer | e86bd61 | 2014-07-15 09:43:15 +0200 | [diff] [blame] | 1327 | /* Step 2.a PHS Rule Does Not Exist .Create New PHS Rule for |
| 1328 | * uiClsId */ |
Lisa Nguyen | f70c8a9 | 2013-10-28 01:36:19 -0700 | [diff] [blame] | 1329 | if (false == bPHSRuleOrphaned) { |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 1330 | |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 1331 | pstClassifierEntry->pstPhsRule = |
| 1332 | kmalloc(sizeof(struct bcm_phs_rule), |
| 1333 | GFP_KERNEL); |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1334 | if (NULL == pstClassifierEntry->pstPhsRule) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1335 | return ERR_PHSRULE_MEMALLOC_FAIL; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1336 | } |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 1337 | memcpy(pstClassifierEntry->pstPhsRule, psPhsRule, |
| 1338 | sizeof(struct bcm_phs_rule)); |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 1339 | } else { |
Matthias Beyer | e86bd61 | 2014-07-15 09:43:15 +0200 | [diff] [blame] | 1340 | /* Step 2.b PHS Rule Exists Tie uiClsId with the existing |
| 1341 | * PHS Rule */ |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 1342 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_DISPATCH, |
| 1343 | DBG_LVL_ALL, |
| 1344 | "\nTying Classifier to Existing PHS Rule"); |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 1345 | if (bPHSRuleOrphaned) { |
Stephen Hemminger | 082e889 | 2010-11-01 09:35:21 -0400 | [diff] [blame] | 1346 | kfree(pstClassifierEntry->pstPhsRule); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1347 | pstClassifierEntry->pstPhsRule = NULL; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1348 | } |
| 1349 | pstClassifierEntry->pstPhsRule = pstAddPhsRule; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1350 | } |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1351 | |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1352 | pstClassifierEntry->bUsed = TRUE; |
| 1353 | pstClassifierEntry->u8PHSI = pstClassifierEntry->pstPhsRule->u8PHSI; |
| 1354 | pstClassifierEntry->uiClassifierRuleId = uiClsId; |
| 1355 | pstClassifierEntry->pstPhsRule->u8RefCnt++; |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 1356 | pstClassifierEntry->bUnclassifiedPHSRule = |
| 1357 | pstClassifierEntry->pstPhsRule->bUnclassifiedPHSRule; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1358 | |
| 1359 | return PHS_SUCCESS; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1360 | } |
| 1361 | |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 1362 | static bool DerefPhsRule(IN B_UINT16 uiClsId, |
| 1363 | struct bcm_phs_classifier_table *psaClassifiertable, |
| 1364 | struct bcm_phs_rule *pstPhsRule) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1365 | { |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1366 | if (pstPhsRule == NULL) |
Lisa Nguyen | f70c8a9 | 2013-10-28 01:36:19 -0700 | [diff] [blame] | 1367 | return false; |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1368 | |
| 1369 | if (pstPhsRule->u8RefCnt) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1370 | pstPhsRule->u8RefCnt--; |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1371 | |
Matthias Beyer | 3be738a | 2014-07-15 09:43:14 +0200 | [diff] [blame] | 1372 | return (0 == pstPhsRule->u8RefCnt); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1373 | } |
| 1374 | |
Matthias Beyer | c50e0b5 | 2014-07-15 09:42:56 +0200 | [diff] [blame] | 1375 | static void dbg_print_st_cls_entry(struct bcm_mini_adapter *ad, |
| 1376 | struct bcm_phs_entry *st_serv_flow_entry, |
| 1377 | struct bcm_phs_classifier_entry *st_cls_entry) |
| 1378 | { |
| 1379 | int k; |
| 1380 | |
| 1381 | BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\n VCID : %#X", st_serv_flow_entry->uiVcid); |
| 1382 | BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n ClassifierID : %#X", st_cls_entry->uiClassifierRuleId); |
| 1383 | BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSRuleID : %#X", st_cls_entry->u8PHSI); |
| 1384 | BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n****************PHS Rule********************\n"); |
| 1385 | BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSI : %#X", st_cls_entry->pstPhsRule->u8PHSI); |
| 1386 | BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSFLength : %#X ", st_cls_entry->pstPhsRule->u8PHSFLength); |
| 1387 | BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSF : "); |
| 1388 | |
| 1389 | for (k = 0 ; k < st_cls_entry->pstPhsRule->u8PHSFLength; k++) |
| 1390 | BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "%#X ", st_cls_entry->pstPhsRule->u8PHSF[k]); |
| 1391 | BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSMLength : %#X", st_cls_entry->pstPhsRule->u8PHSMLength); |
| 1392 | BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSM :"); |
| 1393 | |
| 1394 | for (k = 0; k < st_cls_entry->pstPhsRule->u8PHSMLength; k++) |
| 1395 | BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "%#X ", st_cls_entry->pstPhsRule->u8PHSM[k]); |
| 1396 | BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSS : %#X ", st_cls_entry->pstPhsRule->u8PHSS); |
| 1397 | BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSV : %#X", st_cls_entry->pstPhsRule->u8PHSV); |
| 1398 | BCM_DEBUG_PRINT(ad, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\n********************************************\n"); |
| 1399 | } |
| 1400 | |
Matthias Beyer | 20d174e | 2014-07-15 09:42:55 +0200 | [diff] [blame] | 1401 | static void phsrules_per_sf_dbg_print(struct bcm_mini_adapter *ad, |
| 1402 | struct bcm_phs_entry *st_serv_flow_entry) |
| 1403 | { |
| 1404 | int j, l; |
| 1405 | struct bcm_phs_classifier_entry st_cls_entry; |
| 1406 | |
| 1407 | for (j = 0; j < MAX_PHSRULE_PER_SF; j++) { |
| 1408 | |
| 1409 | for (l = 0; l < 2; l++) { |
| 1410 | |
| 1411 | if (l == 0) { |
| 1412 | st_cls_entry = st_serv_flow_entry->pstClassifierTable->stActivePhsRulesList[j]; |
| 1413 | if (st_cls_entry.bUsed) |
| 1414 | BCM_DEBUG_PRINT(ad, |
| 1415 | DBG_TYPE_OTHERS, |
| 1416 | DUMP_INFO, |
| 1417 | (DBG_LVL_ALL | DBG_NO_FUNC_PRINT), |
| 1418 | "\n Active PHS Rule :\n"); |
| 1419 | } else { |
| 1420 | st_cls_entry = st_serv_flow_entry->pstClassifierTable->stOldPhsRulesList[j]; |
| 1421 | if (st_cls_entry.bUsed) |
| 1422 | BCM_DEBUG_PRINT(ad, |
| 1423 | DBG_TYPE_OTHERS, |
| 1424 | DUMP_INFO, |
| 1425 | (DBG_LVL_ALL | DBG_NO_FUNC_PRINT), |
| 1426 | "\n Old PHS Rule :\n"); |
| 1427 | } |
| 1428 | |
| 1429 | if (st_cls_entry.bUsed) { |
Matthias Beyer | c50e0b5 | 2014-07-15 09:42:56 +0200 | [diff] [blame] | 1430 | dbg_print_st_cls_entry(ad, |
| 1431 | st_serv_flow_entry, |
| 1432 | &st_cls_entry); |
Matthias Beyer | 20d174e | 2014-07-15 09:42:55 +0200 | [diff] [blame] | 1433 | } |
| 1434 | } |
| 1435 | } |
| 1436 | } |
| 1437 | |
Kevin McKinney | 60dadf9 | 2012-12-20 00:31:28 -0500 | [diff] [blame] | 1438 | void DumpPhsRules(struct bcm_phs_extension *pDeviceExtension) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1439 | { |
Matthias Beyer | 20d174e | 2014-07-15 09:42:55 +0200 | [diff] [blame] | 1440 | int i; |
Kevin McKinney | 2979460 | 2012-05-26 12:05:12 -0400 | [diff] [blame] | 1441 | struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1442 | |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 1443 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, |
| 1444 | "\n Dumping PHS Rules :\n"); |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1445 | |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 1446 | for (i = 0; i < MAX_SERVICEFLOWS; i++) { |
| 1447 | |
Kevin McKinney | db134a6 | 2012-12-20 00:31:30 -0500 | [diff] [blame] | 1448 | struct bcm_phs_entry stServFlowEntry = |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1449 | pDeviceExtension->pstServiceFlowPhsRulesTable->stSFList[i]; |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 1450 | |
Matthias Beyer | 20d174e | 2014-07-15 09:42:55 +0200 | [diff] [blame] | 1451 | if (!stServFlowEntry.bUsed) |
| 1452 | continue; |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 1453 | |
Matthias Beyer | 20d174e | 2014-07-15 09:42:55 +0200 | [diff] [blame] | 1454 | phsrules_per_sf_dbg_print(Adapter, &stServFlowEntry); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1455 | } |
| 1456 | } |
| 1457 | |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 1458 | /* |
| 1459 | * Procedure: phs_decompress |
| 1460 | * |
| 1461 | * Description: This routine restores the static fields within the packet. |
| 1462 | * |
| 1463 | * Arguments: |
| 1464 | * in_buf - ptr to incoming packet buffer. |
Matthias Beyer | e86bd61 | 2014-07-15 09:43:15 +0200 | [diff] [blame] | 1465 | * out_buf - ptr to output buffer where the suppressed |
| 1466 | * header is copied. |
| 1467 | * decomp_phs_rules - ptr to PHS rule. |
| 1468 | * header_size - ptr to field which holds the phss or |
| 1469 | * phsf_length. |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 1470 | * |
| 1471 | * Returns: |
Matthias Beyer | e86bd61 | 2014-07-15 09:43:15 +0200 | [diff] [blame] | 1472 | * size - The number of bytes of dynamic fields present with in the |
| 1473 | * incoming packet header. |
| 1474 | * 0 - If PHS rule is NULL.If PHSI is 0 indicateing packet as |
| 1475 | * uncompressed. |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 1476 | */ |
Shalin Mehta | f2be635 | 2013-09-17 00:42:17 -0700 | [diff] [blame] | 1477 | static int phs_decompress(unsigned char *in_buf, |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 1478 | unsigned char *out_buf, |
| 1479 | struct bcm_phs_rule *decomp_phs_rules, |
| 1480 | UINT *header_size) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1481 | { |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1482 | int phss, size = 0; |
Kevin McKinney | a903d65 | 2012-12-20 00:31:34 -0500 | [diff] [blame] | 1483 | struct bcm_phs_rule *tmp_memb; |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1484 | int bit, i = 0; |
| 1485 | unsigned char *phsf, *phsm; |
| 1486 | int in_buf_len = *header_size - 1; |
Kevin McKinney | 2979460 | 2012-05-26 12:05:12 -0400 | [diff] [blame] | 1487 | struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1488 | |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1489 | in_buf++; |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1490 | |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 1491 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, DBG_LVL_ALL, |
| 1492 | "====>\n"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1493 | *header_size = 0; |
| 1494 | |
Masanari Iida | a2745cc | 2014-06-17 23:48:54 +0900 | [diff] [blame] | 1495 | if (decomp_phs_rules == NULL) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1496 | return 0; |
| 1497 | |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1498 | tmp_memb = decomp_phs_rules; |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 1499 | /* |
Matthias Beyer | e86bd61 | 2014-07-15 09:43:15 +0200 | [diff] [blame] | 1500 | * BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECEIVE,DBG_LVL_ALL, |
| 1501 | * "\nDECOMP:In phs_decompress PHSI 1 %d",phsi)); |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 1502 | * header_size = tmp_memb->u8PHSFLength; |
| 1503 | */ |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1504 | phss = tmp_memb->u8PHSS; |
| 1505 | phsf = tmp_memb->u8PHSF; |
| 1506 | phsm = tmp_memb->u8PHSM; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1507 | |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1508 | if (phss > MAX_PHS_LENGTHS) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1509 | phss = MAX_PHS_LENGTHS; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1510 | |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 1511 | /* |
Matthias Beyer | e86bd61 | 2014-07-15 09:43:15 +0200 | [diff] [blame] | 1512 | * BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECEIVE,DBG_LVL_ALL, |
| 1513 | * "\nDECOMP: |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 1514 | * In phs_decompress PHSI %d phss %d index %d",phsi,phss,index)); |
| 1515 | */ |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 1516 | while ((phss > 0) && (size < in_buf_len)) { |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1517 | bit = ((*phsm << i) & SUPPRESS); |
| 1518 | |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 1519 | if (bit == SUPPRESS) { |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1520 | *out_buf = *phsf; |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 1521 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, |
| 1522 | DBG_LVL_ALL, |
| 1523 | "\nDECOMP:In phss %d phsf %d output %d", |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1524 | phss, *phsf, *out_buf); |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 1525 | } else { |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1526 | *out_buf = *in_buf; |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 1527 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_RECEIVE, |
| 1528 | DBG_LVL_ALL, |
| 1529 | "\nDECOMP:In phss %d input %d output %d", |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1530 | phss, *in_buf, *out_buf); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1531 | in_buf++; |
| 1532 | size++; |
| 1533 | } |
| 1534 | out_buf++; |
| 1535 | phsf++; |
| 1536 | phss--; |
| 1537 | i++; |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1538 | *header_size = *header_size + 1; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1539 | |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 1540 | if (i > MAX_NO_BIT) { |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1541 | i = 0; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1542 | phsm++; |
| 1543 | } |
| 1544 | } |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1545 | |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1546 | return size; |
| 1547 | } |
| 1548 | |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 1549 | /* |
| 1550 | * Procedure: phs_compress |
| 1551 | * |
Matthias Beyer | e86bd61 | 2014-07-15 09:43:15 +0200 | [diff] [blame] | 1552 | * Description: This routine suppresses the static fields within the packet. |
| 1553 | * Before that it will verify the fields to be suppressed with the corresponding |
| 1554 | * fields in the phsf. For verification it checks the phsv field of PHS rule. |
| 1555 | * If set and verification succeeds it suppresses the field.If any one static |
| 1556 | * field is found different none of the static fields are suppressed then the |
| 1557 | * packet is sent as uncompressed packet with phsi=0. |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 1558 | * |
| 1559 | * Arguments: |
| 1560 | * phs_rule - ptr to PHS rule. |
| 1561 | * in_buf - ptr to incoming packet buffer. |
Matthias Beyer | e86bd61 | 2014-07-15 09:43:15 +0200 | [diff] [blame] | 1562 | * out_buf - ptr to output buffer where the suppressed header is |
| 1563 | * copied. |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 1564 | * header_size - ptr to field which holds the phss. |
| 1565 | * |
| 1566 | * Returns: |
Matthias Beyer | e86bd61 | 2014-07-15 09:43:15 +0200 | [diff] [blame] | 1567 | * size - The number of bytes copied into the output buffer i.e |
| 1568 | * dynamic fields |
| 1569 | * 0 - If PHS rule is NULL.If PHSV field is not set. If the |
| 1570 | * verification fails. |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 1571 | */ |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1572 | static int phs_compress(struct bcm_phs_rule *phs_rule, |
| 1573 | unsigned char *in_buf, |
| 1574 | unsigned char *out_buf, |
| 1575 | UINT *header_size, |
| 1576 | UINT *new_header_size) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1577 | { |
| 1578 | unsigned char *old_addr = out_buf; |
Peter Meerwald | b38e274 | 2012-06-13 20:44:35 +0200 | [diff] [blame] | 1579 | int suppress = 0; |
Kevin McKinney | 2979460 | 2012-05-26 12:05:12 -0400 | [diff] [blame] | 1580 | struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1581 | |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 1582 | if (phs_rule == NULL) { |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 1583 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, |
| 1584 | "\nphs_compress(): phs_rule null!"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1585 | *out_buf = ZERO_PHSI; |
| 1586 | return STATUS_PHS_NOCOMPRESSION; |
| 1587 | } |
| 1588 | |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1589 | if (phs_rule->u8PHSS <= *new_header_size) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1590 | *header_size = phs_rule->u8PHSS; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1591 | else |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1592 | *header_size = *new_header_size; |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1593 | |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 1594 | /* To copy PHSI */ |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1595 | out_buf++; |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1596 | suppress = verify_suppress_phsf(in_buf, out_buf, phs_rule->u8PHSF, |
| 1597 | phs_rule->u8PHSM, phs_rule->u8PHSS, |
| 1598 | phs_rule->u8PHSV, new_header_size); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1599 | |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 1600 | if (suppress == STATUS_PHS_COMPRESSED) { |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1601 | *old_addr = (unsigned char)phs_rule->u8PHSI; |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 1602 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, |
| 1603 | "\nCOMP:In phs_compress phsi %d", |
| 1604 | phs_rule->u8PHSI); |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 1605 | } else { |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1606 | *old_addr = ZERO_PHSI; |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 1607 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, |
| 1608 | "\nCOMP:In phs_compress PHSV Verification failed"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1609 | } |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1610 | |
Peter Meerwald | b38e274 | 2012-06-13 20:44:35 +0200 | [diff] [blame] | 1611 | return suppress; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1612 | } |
| 1613 | |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 1614 | /* |
| 1615 | * Procedure: verify_suppress_phsf |
| 1616 | * |
| 1617 | * Description: This routine verifies the fields of the packet and if all the |
| 1618 | * static fields are equal it adds the phsi of that PHS rule.If any static |
| 1619 | * field differs it woun't suppress any field. |
| 1620 | * |
| 1621 | * Arguments: |
| 1622 | * rules_set - ptr to classifier_rules. |
| 1623 | * in_buffer - ptr to incoming packet buffer. |
| 1624 | * out_buffer - ptr to output buffer where the suppressed header is copied. |
Matthias Beyer | e86bd61 | 2014-07-15 09:43:15 +0200 | [diff] [blame] | 1625 | * phsf - ptr to phsf. |
| 1626 | * phsm - ptr to phsm. |
| 1627 | * phss - variable holding phss. |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 1628 | * |
| 1629 | * Returns: |
Matthias Beyer | e86bd61 | 2014-07-15 09:43:15 +0200 | [diff] [blame] | 1630 | * size - The number of bytes copied into the output buffer i.e dynamic |
| 1631 | * fields. |
| 1632 | * 0 - Packet has failed the verification. |
Kevin McKinney | 14b3a40 | 2013-02-20 23:25:29 -0500 | [diff] [blame] | 1633 | */ |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1634 | static int verify_suppress_phsf(unsigned char *in_buffer, |
| 1635 | unsigned char *out_buffer, |
| 1636 | unsigned char *phsf, |
| 1637 | unsigned char *phsm, |
| 1638 | unsigned int phss, |
| 1639 | unsigned int phsv, |
| 1640 | UINT *new_header_size) |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1641 | { |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1642 | unsigned int size = 0; |
| 1643 | int bit, i = 0; |
Kevin McKinney | 2979460 | 2012-05-26 12:05:12 -0400 | [diff] [blame] | 1644 | struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1645 | |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 1646 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, |
| 1647 | "\nCOMP:In verify_phsf PHSM - 0x%X", *phsm); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1648 | |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1649 | if (phss > (*new_header_size)) |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1650 | phss = *new_header_size; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1651 | |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 1652 | while (phss > 0) { |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1653 | bit = ((*phsm << i) & SUPPRESS); |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 1654 | if (bit == SUPPRESS) { |
| 1655 | if (*in_buffer != *phsf) { |
| 1656 | if (phsv == VERIFY) { |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1657 | BCM_DEBUG_PRINT(Adapter, |
| 1658 | DBG_TYPE_OTHERS, |
| 1659 | PHS_SEND, |
| 1660 | DBG_LVL_ALL, |
| 1661 | "\nCOMP:In verify_phsf failed for field %d buf %d phsf %d", |
| 1662 | phss, |
| 1663 | *in_buffer, |
| 1664 | *phsf); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1665 | return STATUS_PHS_NOCOMPRESSION; |
| 1666 | } |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 1667 | } else |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1668 | BCM_DEBUG_PRINT(Adapter, |
| 1669 | DBG_TYPE_OTHERS, |
| 1670 | PHS_SEND, |
| 1671 | DBG_LVL_ALL, |
| 1672 | "\nCOMP:In verify_phsf success for field %d buf %d phsf %d", |
| 1673 | phss, |
| 1674 | *in_buffer, |
| 1675 | *phsf); |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 1676 | } else { |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1677 | *out_buffer = *in_buffer; |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1678 | BCM_DEBUG_PRINT(Adapter, |
| 1679 | DBG_TYPE_OTHERS, |
| 1680 | PHS_SEND, |
| 1681 | DBG_LVL_ALL, |
| 1682 | "\nCOMP:In copying_header input %d out %d", |
| 1683 | *in_buffer, |
| 1684 | *out_buffer); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1685 | out_buffer++; |
| 1686 | size++; |
| 1687 | } |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1688 | |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1689 | in_buffer++; |
| 1690 | phsf++; |
| 1691 | phss--; |
| 1692 | i++; |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1693 | |
Kevin McKinney | 6949387 | 2013-02-20 23:25:28 -0500 | [diff] [blame] | 1694 | if (i > MAX_NO_BIT) { |
Kevin McKinney | 6c259f4 | 2013-02-20 23:25:27 -0500 | [diff] [blame] | 1695 | i = 0; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1696 | phsm++; |
| 1697 | } |
| 1698 | } |
Matthias Beyer | ca89a29 | 2014-07-15 09:42:54 +0200 | [diff] [blame] | 1699 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, |
| 1700 | "\nCOMP:In verify_phsf success"); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1701 | *new_header_size = size; |
| 1702 | return STATUS_PHS_COMPRESSED; |
| 1703 | } |