aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/staging/bcm/IPv6Protocol.c93
1 files changed, 60 insertions, 33 deletions
diff --git a/drivers/staging/bcm/IPv6Protocol.c b/drivers/staging/bcm/IPv6Protocol.c
index 01ad11f866c4..27f3f416f184 100644
--- a/drivers/staging/bcm/IPv6Protocol.c
+++ b/drivers/staging/bcm/IPv6Protocol.c
@@ -151,7 +151,9 @@ static UCHAR GetIpv6ProtocolPorts(UCHAR *pucPayload, USHORT *pusSrcPort,
151 ucHeaderType = ucNextHeader; 151 ucHeaderType = ucNextHeader;
152 while (!bDone) { 152 while (!bDone) {
153 pucNextHeader = GetNextIPV6ChainedHeader(&pIpv6HdrScanContext, 153 pucNextHeader = GetNextIPV6ChainedHeader(&pIpv6HdrScanContext,
154 &ucHeaderType, &bDone, &usPayloadLength); 154 &ucHeaderType,
155 &bDone,
156 &usPayloadLength);
155 if (bDone) { 157 if (bDone) {
156 if ((ucHeaderType == TCP_HEADER_TYPE) || 158 if ((ucHeaderType == TCP_HEADER_TYPE) ||
157 (ucHeaderType == UDP_HEADER_TYPE)) { 159 (ucHeaderType == UDP_HEADER_TYPE)) {
@@ -172,11 +174,12 @@ static UCHAR GetIpv6ProtocolPorts(UCHAR *pucPayload, USHORT *pusSrcPort,
172 174
173 175
174/* 176/*
175 * Arg 1 struct bcm_mini_adapter *Adapter is a pointer ot the driver contorl structure 177 * Arg 1 struct bcm_mini_adapter *Adapter is a pointer ot the driver control
178 * structure
176 * Arg 2 PVOID pcIpHeader is a pointer to the IP header of the packet 179 * Arg 2 PVOID pcIpHeader is a pointer to the IP header of the packet
177 */ 180 */
178USHORT IpVersion6(struct bcm_mini_adapter *Adapter, PVOID pcIpHeader, 181USHORT IpVersion6(struct bcm_mini_adapter *Adapter, PVOID pcIpHeader,
179 struct bcm_classifier_rule *pstClassifierRule) 182 struct bcm_classifier_rule *pstClassifierRule)
180{ 183{
181 USHORT ushDestPort = 0; 184 USHORT ushDestPort = 0;
182 USHORT ushSrcPort = 0; 185 USHORT ushSrcPort = 0;
@@ -195,11 +198,12 @@ USHORT IpVersion6(struct bcm_mini_adapter *Adapter, PVOID pcIpHeader,
195 * Try to get the next higher layer protocol 198 * Try to get the next higher layer protocol
196 * and the Ports Nos if TCP or UDP 199 * and the Ports Nos if TCP or UDP
197 */ 200 */
198 ucNextProtocolAboveIP = GetIpv6ProtocolPorts((UCHAR *)(pcIpHeader + sizeof(struct bcm_ipv6_hdr)), 201 ucNextProtocolAboveIP = GetIpv6ProtocolPorts((UCHAR *)(pcIpHeader +
199 &ushSrcPort, 202 sizeof(struct bcm_ipv6_hdr)),
200 &ushDestPort, 203 &ushSrcPort,
201 pstIpv6Header->usPayloadLength, 204 &ushDestPort,
202 pstIpv6Header->ucNextHeader); 205 pstIpv6Header->usPayloadLength,
206 pstIpv6Header->ucNextHeader);
203 207
204 do { 208 do {
205 if (pstClassifierRule->ucDirection == 0) { 209 if (pstClassifierRule->ucDirection == 0) {
@@ -219,12 +223,12 @@ USHORT IpVersion6(struct bcm_mini_adapter *Adapter, PVOID pcIpHeader,
219 } 223 }
220 224
221 bClassificationSucceed = MatchSrcIpv6Address(pstClassifierRule, 225 bClassificationSucceed = MatchSrcIpv6Address(pstClassifierRule,
222 pstIpv6Header); 226 pstIpv6Header);
223 if (!bClassificationSucceed) 227 if (!bClassificationSucceed)
224 break; 228 break;
225 229
226 bClassificationSucceed = MatchDestIpv6Address(pstClassifierRule, 230 bClassificationSucceed = MatchDestIpv6Address(pstClassifierRule,
227 pstIpv6Header); 231 pstIpv6Header);
228 if (!bClassificationSucceed) 232 if (!bClassificationSucceed)
229 break; 233 break;
230 234
@@ -234,7 +238,7 @@ USHORT IpVersion6(struct bcm_mini_adapter *Adapter, PVOID pcIpHeader,
234 * Chain of IPv6 prot headers 238 * Chain of IPv6 prot headers
235 */ 239 */
236 bClassificationSucceed = MatchProtocol(pstClassifierRule, 240 bClassificationSucceed = MatchProtocol(pstClassifierRule,
237 ucNextProtocolAboveIP); 241 ucNextProtocolAboveIP);
238 if (!bClassificationSucceed) 242 if (!bClassificationSucceed)
239 break; 243 break;
240 244
@@ -248,7 +252,7 @@ USHORT IpVersion6(struct bcm_mini_adapter *Adapter, PVOID pcIpHeader,
248 DBG_LVL_ALL, "\nIPv6 Source Port:%x\n", 252 DBG_LVL_ALL, "\nIPv6 Source Port:%x\n",
249 ntohs(ushSrcPort)); 253 ntohs(ushSrcPort));
250 bClassificationSucceed = MatchSrcPort(pstClassifierRule, 254 bClassificationSucceed = MatchSrcPort(pstClassifierRule,
251 ntohs(ushSrcPort)); 255 ntohs(ushSrcPort));
252 if (!bClassificationSucceed) 256 if (!bClassificationSucceed)
253 break; 257 break;
254 258
@@ -257,21 +261,24 @@ USHORT IpVersion6(struct bcm_mini_adapter *Adapter, PVOID pcIpHeader,
257 261
258 /* Match Dest Port */ 262 /* Match Dest Port */
259 BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, 263 BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG,
260 DBG_LVL_ALL, "\nIPv6 Destination Port:%x\n", 264 DBG_LVL_ALL,
265 "\nIPv6 Destination Port:%x\n",
261 ntohs(ushDestPort)); 266 ntohs(ushDestPort));
262 bClassificationSucceed = MatchDestPort(pstClassifierRule, 267 bClassificationSucceed = MatchDestPort(pstClassifierRule,
263 ntohs(ushDestPort)); 268 ntohs(ushDestPort));
264 if (!bClassificationSucceed) 269 if (!bClassificationSucceed)
265 break; 270 break;
266 BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, 271 BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG,
267 DBG_LVL_ALL, "\nIPv6 Dest Port Matched"); 272 DBG_LVL_ALL,
273 "\nIPv6 Dest Port Matched");
268 } 274 }
269 } while (0); 275 } while (0);
270 276
271 if (bClassificationSucceed == TRUE) { 277 if (bClassificationSucceed == TRUE) {
272 INT iMatchedSFQueueIndex = 0; 278 INT iMatchedSFQueueIndex = 0;
273 279
274 iMatchedSFQueueIndex = SearchSfid(Adapter, pstClassifierRule->ulSFID); 280 iMatchedSFQueueIndex = SearchSfid(Adapter,
281 pstClassifierRule->ulSFID);
275 if ((iMatchedSFQueueIndex >= NO_OF_QUEUES) || 282 if ((iMatchedSFQueueIndex >= NO_OF_QUEUES) ||
276 (Adapter->PackInfo[iMatchedSFQueueIndex].bActive == false)) 283 (Adapter->PackInfo[iMatchedSFQueueIndex].bActive == false))
277 bClassificationSucceed = false; 284 bClassificationSucceed = false;
@@ -295,7 +302,8 @@ static bool MatchSrcIpv6Address(struct bcm_classifier_rule *pstClassifierRule,
295 * This is the no. of Src Addresses ie Range of IP Addresses contained 302 * This is the no. of Src Addresses ie Range of IP Addresses contained
296 * in the classifier rule for which we need to match 303 * in the classifier rule for which we need to match
297 */ 304 */
298 UINT uiCountIPSrcAddresses = (UINT)pstClassifierRule->ucIPSourceAddressLength; 305 UINT uiCountIPSrcAddresses =
306 (UINT)pstClassifierRule->ucIPSourceAddressLength;
299 307
300 308
301 if (uiCountIPSrcAddresses == 0) 309 if (uiCountIPSrcAddresses == 0)
@@ -303,10 +311,15 @@ static bool MatchSrcIpv6Address(struct bcm_classifier_rule *pstClassifierRule,
303 311
304 312
305 /* First Convert the Ip Address in the packet to Host Endian order */ 313 /* First Convert the Ip Address in the packet to Host Endian order */
306 for (uiIpv6AddIndex = 0; uiIpv6AddIndex < uiIpv6AddrNoLongWords; uiIpv6AddIndex++) 314 for (uiIpv6AddIndex = 0;
307 aulSrcIP[uiIpv6AddIndex] = ntohl(pstIpv6Header->ulSrcIpAddress[uiIpv6AddIndex]); 315 uiIpv6AddIndex < uiIpv6AddrNoLongWords;
308 316 uiIpv6AddIndex++)
309 for (uiLoopIndex = 0; uiLoopIndex < uiCountIPSrcAddresses; uiLoopIndex += uiIpv6AddrNoLongWords) { 317 aulSrcIP[uiIpv6AddIndex] =
318 ntohl(pstIpv6Header->ulSrcIpAddress[uiIpv6AddIndex]);
319
320 for (uiLoopIndex = 0;
321 uiLoopIndex < uiCountIPSrcAddresses;
322 uiLoopIndex += uiIpv6AddrNoLongWords) {
310 BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, 323 BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL,
311 "\n Src Ipv6 Address In Received Packet :\n "); 324 "\n Src Ipv6 Address In Received Packet :\n ");
312 DumpIpv6Address(aulSrcIP); 325 DumpIpv6Address(aulSrcIP);
@@ -317,9 +330,12 @@ static bool MatchSrcIpv6Address(struct bcm_classifier_rule *pstClassifierRule,
317 "\n Src Ipv6 Address In Classifier Rule :\n"); 330 "\n Src Ipv6 Address In Classifier Rule :\n");
318 DumpIpv6Address(&src_addr->ulIpv6Addr[uiLoopIndex]); 331 DumpIpv6Address(&src_addr->ulIpv6Addr[uiLoopIndex]);
319 332
320 for (uiIpv6AddIndex = 0; uiIpv6AddIndex < uiIpv6AddrNoLongWords; uiIpv6AddIndex++) { 333 for (uiIpv6AddIndex = 0;
321 if ((src_addr->ulIpv6Mask[uiLoopIndex+uiIpv6AddIndex] & aulSrcIP[uiIpv6AddIndex]) 334 uiIpv6AddIndex < uiIpv6AddrNoLongWords;
322 != src_addr->ulIpv6Addr[uiLoopIndex+uiIpv6AddIndex]) { 335 uiIpv6AddIndex++) {
336 if ((src_addr->ulIpv6Mask[uiLoopIndex+uiIpv6AddIndex] &
337 aulSrcIP[uiIpv6AddIndex]) !=
338 src_addr->ulIpv6Addr[uiLoopIndex+uiIpv6AddIndex]) {
323 /* 339 /*
324 * Match failed for current Ipv6 Address 340 * Match failed for current Ipv6 Address
325 * Try next Ipv6 Address 341 * Try next Ipv6 Address
@@ -354,17 +370,23 @@ static bool MatchDestIpv6Address(struct bcm_classifier_rule *pstClassifierRule,
354 * ie Range of IP Addresses contained in the classifier rule 370 * ie Range of IP Addresses contained in the classifier rule
355 * for which we need to match 371 * for which we need to match
356 */ 372 */
357 UINT uiCountIPDestinationAddresses = (UINT)pstClassifierRule->ucIPDestinationAddressLength; 373 UINT uiCountIPDestinationAddresses =
374 (UINT)pstClassifierRule->ucIPDestinationAddressLength;
358 375
359 if (uiCountIPDestinationAddresses == 0) 376 if (uiCountIPDestinationAddresses == 0)
360 return TRUE; 377 return TRUE;
361 378
362 379
363 /* First Convert the Ip Address in the packet to Host Endian order */ 380 /* First Convert the Ip Address in the packet to Host Endian order */
364 for (uiIpv6AddIndex = 0; uiIpv6AddIndex < uiIpv6AddrNoLongWords; uiIpv6AddIndex++) 381 for (uiIpv6AddIndex = 0;
365 aulDestIP[uiIpv6AddIndex] = ntohl(pstIpv6Header->ulDestIpAddress[uiIpv6AddIndex]); 382 uiIpv6AddIndex < uiIpv6AddrNoLongWords;
366 383 uiIpv6AddIndex++)
367 for (uiLoopIndex = 0; uiLoopIndex < uiCountIPDestinationAddresses; uiLoopIndex += uiIpv6AddrNoLongWords) { 384 aulDestIP[uiIpv6AddIndex] =
385 ntohl(pstIpv6Header->ulDestIpAddress[uiIpv6AddIndex]);
386
387 for (uiLoopIndex = 0;
388 uiLoopIndex < uiCountIPDestinationAddresses;
389 uiLoopIndex += uiIpv6AddrNoLongWords) {
368 BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, 390 BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL,
369 "\n Destination Ipv6 Address In Received Packet :\n "); 391 "\n Destination Ipv6 Address In Received Packet :\n ");
370 DumpIpv6Address(aulDestIP); 392 DumpIpv6Address(aulDestIP);
@@ -375,9 +397,12 @@ static bool MatchDestIpv6Address(struct bcm_classifier_rule *pstClassifierRule,
375 "\n Destination Ipv6 Address In Classifier Rule :\n"); 397 "\n Destination Ipv6 Address In Classifier Rule :\n");
376 DumpIpv6Address(&dest_addr->ulIpv6Addr[uiLoopIndex]); 398 DumpIpv6Address(&dest_addr->ulIpv6Addr[uiLoopIndex]);
377 399
378 for (uiIpv6AddIndex = 0; uiIpv6AddIndex < uiIpv6AddrNoLongWords; uiIpv6AddIndex++) { 400 for (uiIpv6AddIndex = 0;
379 if ((dest_addr->ulIpv6Mask[uiLoopIndex+uiIpv6AddIndex] & aulDestIP[uiIpv6AddIndex]) 401 uiIpv6AddIndex < uiIpv6AddrNoLongWords;
380 != dest_addr->ulIpv6Addr[uiLoopIndex+uiIpv6AddIndex]) { 402 uiIpv6AddIndex++) {
403 if ((dest_addr->ulIpv6Mask[uiLoopIndex+uiIpv6AddIndex] &
404 aulDestIP[uiIpv6AddIndex]) !=
405 dest_addr->ulIpv6Addr[uiLoopIndex+uiIpv6AddIndex]) {
381 /* 406 /*
382 * Match failed for current Ipv6 Address. 407 * Match failed for current Ipv6 Address.
383 * Try next Ipv6 Address 408 * Try next Ipv6 Address
@@ -404,7 +429,9 @@ VOID DumpIpv6Address(ULONG *puIpv6Address)
404 UINT uiIpv6AddIndex = 0; 429 UINT uiIpv6AddIndex = 0;
405 struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); 430 struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev);
406 431
407 for (uiIpv6AddIndex = 0; uiIpv6AddIndex < uiIpv6AddrNoLongWords; uiIpv6AddIndex++) { 432 for (uiIpv6AddIndex = 0;
433 uiIpv6AddIndex < uiIpv6AddrNoLongWords;
434 uiIpv6AddIndex++) {
408 BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, 435 BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL,
409 ":%lx", puIpv6Address[uiIpv6AddIndex]); 436 ":%lx", puIpv6Address[uiIpv6AddIndex]);
410 } 437 }