blob: 5f891fa90a6212461e5dbbde1e654e2242e0c841 [file] [log] [blame]
Stephen Hemmingerf8942e02010-09-08 14:46:36 -07001#include "headers.h"
Chris Forbes49184c52011-07-03 16:38:20 +12002#include <linux/sort.h>
Stephen Hemmingerf8942e02010-09-08 14:46:36 -07003
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 Forbes49184c52011-07-03 16:38:20 +120014static int compare_packet_info(void const *a, void const *b)
15{
Kevin McKinney0b3edf72012-05-26 12:05:01 -040016 struct bcm_packet_info const *pa = a;
17 struct bcm_packet_info const *pb = b;
Chris Forbes49184c52011-07-03 16:38:20 +120018
19 if (!pa->bValid || !pb->bValid)
20 return 0;
21
22 return pa->u8TrafficPriority - pb->u8TrafficPriority;
23}
24
Stephen Hemmingerf8942e02010-09-08 14:46:36 -070025VOID SortPackInfo(PMINI_ADAPTER Adapter)
26{
Chris Forbes49184c52011-07-03 16:38:20 +120027 BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG,
28 DBG_LVL_ALL, "<=======");
Stephen Hemmingerf8942e02010-09-08 14:46:36 -070029
Kevin McKinney0b3edf72012-05-26 12:05:01 -040030 sort(Adapter->PackInfo, NO_OF_QUEUES, sizeof(struct bcm_packet_info),
Chris Forbes49184c52011-07-03 16:38:20 +120031 compare_packet_info, NULL);
32}
Stephen Hemmingerf8942e02010-09-08 14:46:36 -070033
Chris Forbes49184c52011-07-03 16:38:20 +120034static int compare_classifiers(void const *a, void const *b)
35{
Kevin McKinney92562ae2012-05-26 12:05:03 -040036 struct bcm_classifier_rule const *pa = a;
37 struct bcm_classifier_rule const *pb = b;
Stephen Hemmingerf8942e02010-09-08 14:46:36 -070038
Chris Forbes49184c52011-07-03 16:38:20 +120039 if (!pa->bUsed || !pb->bUsed)
40 return 0;
41
42 return pa->u8ClassifierRulePriority - pb->u8ClassifierRulePriority;
Stephen Hemmingerf8942e02010-09-08 14:46:36 -070043}
44
45VOID SortClassifiers(PMINI_ADAPTER Adapter)
46{
Chris Forbes49184c52011-07-03 16:38:20 +120047 BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG,
48 DBG_LVL_ALL, "<=======");
Stephen Hemmingerf8942e02010-09-08 14:46:36 -070049
Chris Forbes49184c52011-07-03 16:38:20 +120050 sort(Adapter->astClassifierTable, MAX_CLASSIFIERS,
Kevin McKinney92562ae2012-05-26 12:05:03 -040051 sizeof(struct bcm_classifier_rule), compare_classifiers, NULL);
Stephen Hemmingerf8942e02010-09-08 14:46:36 -070052}