Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 1 | #include "headers.h" |
Chris Forbes | 49184c5 | 2011-07-03 16:38:20 +1200 | [diff] [blame] | 2 | #include <linux/sort.h> |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 3 | |
| 4 | /* |
| 5 | * File Name: sort.c |
| 6 | * |
| 7 | * Author: Beceem Communications Pvt. Ltd |
| 8 | * |
| 9 | * Abstract: This file contains the routines sorting the classification rules. |
| 10 | * |
| 11 | * Copyright (c) 2007 Beceem Communications Pvt. Ltd |
| 12 | */ |
| 13 | |
Chris Forbes | 49184c5 | 2011-07-03 16:38:20 +1200 | [diff] [blame] | 14 | static int compare_packet_info(void const *a, void const *b) |
| 15 | { |
Kevin McKinney | 0b3edf7 | 2012-05-26 12:05:01 -0400 | [diff] [blame] | 16 | struct bcm_packet_info const *pa = a; |
| 17 | struct bcm_packet_info const *pb = b; |
Chris Forbes | 49184c5 | 2011-07-03 16:38:20 +1200 | [diff] [blame] | 18 | |
| 19 | if (!pa->bValid || !pb->bValid) |
| 20 | return 0; |
| 21 | |
| 22 | return pa->u8TrafficPriority - pb->u8TrafficPriority; |
| 23 | } |
| 24 | |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 25 | VOID SortPackInfo(PMINI_ADAPTER Adapter) |
| 26 | { |
Chris Forbes | 49184c5 | 2011-07-03 16:38:20 +1200 | [diff] [blame] | 27 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, |
| 28 | DBG_LVL_ALL, "<======="); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 29 | |
Kevin McKinney | 0b3edf7 | 2012-05-26 12:05:01 -0400 | [diff] [blame] | 30 | sort(Adapter->PackInfo, NO_OF_QUEUES, sizeof(struct bcm_packet_info), |
Chris Forbes | 49184c5 | 2011-07-03 16:38:20 +1200 | [diff] [blame] | 31 | compare_packet_info, NULL); |
| 32 | } |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 33 | |
Chris Forbes | 49184c5 | 2011-07-03 16:38:20 +1200 | [diff] [blame] | 34 | static int compare_classifiers(void const *a, void const *b) |
| 35 | { |
Kevin McKinney | 92562ae | 2012-05-26 12:05:03 -0400 | [diff] [blame^] | 36 | struct bcm_classifier_rule const *pa = a; |
| 37 | struct bcm_classifier_rule const *pb = b; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 38 | |
Chris Forbes | 49184c5 | 2011-07-03 16:38:20 +1200 | [diff] [blame] | 39 | if (!pa->bUsed || !pb->bUsed) |
| 40 | return 0; |
| 41 | |
| 42 | return pa->u8ClassifierRulePriority - pb->u8ClassifierRulePriority; |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | VOID SortClassifiers(PMINI_ADAPTER Adapter) |
| 46 | { |
Chris Forbes | 49184c5 | 2011-07-03 16:38:20 +1200 | [diff] [blame] | 47 | BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, |
| 48 | DBG_LVL_ALL, "<======="); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 49 | |
Chris Forbes | 49184c5 | 2011-07-03 16:38:20 +1200 | [diff] [blame] | 50 | sort(Adapter->astClassifierTable, MAX_CLASSIFIERS, |
Kevin McKinney | 92562ae | 2012-05-26 12:05:03 -0400 | [diff] [blame^] | 51 | sizeof(struct bcm_classifier_rule), compare_classifiers, NULL); |
Stephen Hemminger | f8942e0 | 2010-09-08 14:46:36 -0700 | [diff] [blame] | 52 | } |