]> rtime.felk.cvut.cz Git - lisovros/linux_canprio.git/commitdiff
canprio: speed up sff match add
authorOliver Hartkopp <oliver@hartkopp.net>
Wed, 7 Sep 2011 18:15:22 +0000 (20:15 +0200)
committerRostislav Lisovy <lisovy@gmail.com>
Thu, 8 Sep 2011 13:44:26 +0000 (15:44 +0200)
Before going through all 2048 SFF CAN IDs to set bits in the SFF match
bitmap, we can check for two (likely) special cases:

- check for a single ID (mask = CAN_SFF_MASK)
- check for all IDs (mask = zero)

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
net/sched/cls_canprio.c

index 09964e8991695e03f9271d2b08906cd7df957639..31512ed1028e93073f992094b4a5cf90daf9ae96 100644 (file)
@@ -106,12 +106,22 @@ static void canprio_sff_match_add(struct canprio_rules *rls, u32 can_id, u32 can
 
        pr_debug("%s() invoked\n", __FUNCTION__);
        can_mask &= CAN_SFF_MASK;
-       can_id &= can_mask;
 
+       /* single frame */
        if (can_mask == CAN_SFF_MASK) {
                set_bit(can_id, rls->match_sff);
                return;
        }
+
+       /* all frames */
+       if (can_mask == 0) {
+               bitmap_fill(rls->match_sff, (1 << CAN_SFF_ID_BITS));
+               return;
+       }
+
+       /* individual frame filter: reduce runtime operations */
+       can_id &= can_mask;
+
        /* Add record (set bit to 1) for each ID that conforms particular rule */
        for (i = 0; i < (1 << CAN_SFF_ID_BITS); i++) {
                if ((i & can_mask) == can_id)