| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: altq_rmclass.h,v 1.8 2006/10/28 11:35:17 peter Exp $ */ | | 1 | /* $NetBSD: altq_rmclass.h,v 1.9 2021/07/13 08:04:31 ozaki-r Exp $ */ |
2 | /* $KAME: altq_rmclass.h,v 1.10 2003/08/20 23:30:23 itojun Exp $ */ | | 2 | /* $KAME: altq_rmclass.h,v 1.10 2003/08/20 23:30:23 itojun Exp $ */ |
3 | | | 3 | |
4 | /* | | 4 | /* |
5 | * Copyright (c) 1991-1997 Regents of the University of California. | | 5 | * Copyright (c) 1991-1997 Regents of the University of California. |
6 | * All rights reserved. | | 6 | * All rights reserved. |
7 | * | | 7 | * |
8 | * Redistribution and use in source and binary forms, with or without | | 8 | * Redistribution and use in source and binary forms, with or without |
9 | * modification, are permitted provided that the following conditions | | 9 | * modification, are permitted provided that the following conditions |
10 | * are met: | | 10 | * are met: |
11 | * 1. Redistributions of source code must retain the above copyright | | 11 | * 1. Redistributions of source code must retain the above copyright |
12 | * notice, this list of conditions and the following disclaimer. | | 12 | * notice, this list of conditions and the following disclaimer. |
13 | * 2. Redistributions in binary form must reproduce the above copyright | | 13 | * 2. Redistributions in binary form must reproduce the above copyright |
14 | * notice, this list of conditions and the following disclaimer in the | | 14 | * notice, this list of conditions and the following disclaimer in the |
| @@ -66,57 +66,57 @@ struct red; | | | @@ -66,57 +66,57 @@ struct red; |
66 | * and discriminate against high bandwidth classes. To remove this bias an | | 66 | * and discriminate against high bandwidth classes. To remove this bias an |
67 | * integrator needs to be added. The simplest integrator uses a history of | | 67 | * integrator needs to be added. The simplest integrator uses a history of |
68 | * 10 * avg.packet.time / min.tick.time packet completion entries. This is | | 68 | * 10 * avg.packet.time / min.tick.time packet completion entries. This is |
69 | * straight forward to add but we don't want to pay the extra memory | | 69 | * straight forward to add but we don't want to pay the extra memory |
70 | * traffic to maintain it if it's not necessary (occasionally a vendor | | 70 | * traffic to maintain it if it's not necessary (occasionally a vendor |
71 | * accidentally builds a workstation with a decent clock - e.g., Sun & HP).) | | 71 | * accidentally builds a workstation with a decent clock - e.g., Sun & HP).) |
72 | */ | | 72 | */ |
73 | | | 73 | |
74 | #define RM_GETTIME(now) microtime(&now) | | 74 | #define RM_GETTIME(now) microtime(&now) |
75 | | | 75 | |
76 | #define TV_LT(a, b) (((a)->tv_sec < (b)->tv_sec) || \ | | 76 | #define TV_LT(a, b) (((a)->tv_sec < (b)->tv_sec) || \ |
77 | (((a)->tv_usec < (b)->tv_usec) && ((a)->tv_sec <= (b)->tv_sec))) | | 77 | (((a)->tv_usec < (b)->tv_usec) && ((a)->tv_sec <= (b)->tv_sec))) |
78 | | | 78 | |
79 | #define TV_DELTA(a, b, delta) { \ | | 79 | #define TV_DELTA(a, b, delta) do { \ |
80 | register int xxs; \ | | 80 | register int xxs; \ |
81 | \ | | 81 | \ |
82 | delta = (a)->tv_usec - (b)->tv_usec; \ | | 82 | delta = (a)->tv_usec - (b)->tv_usec; \ |
83 | if ((xxs = (a)->tv_sec - (b)->tv_sec)) { \ | | 83 | if ((xxs = (a)->tv_sec - (b)->tv_sec)) { \ |
84 | switch (xxs) { \ | | 84 | switch (xxs) { \ |
85 | default: \ | | 85 | default: \ |
86 | /* if (xxs < 0) \ | | 86 | /* if (xxs < 0) \ |
87 | printf("rm_class: bogus time values\n"); */ \ | | 87 | printf("rm_class: bogus time values\n"); */ \ |
88 | delta = 0; \ | | 88 | delta = 0; \ |
89 | /* fall through */ \ | | 89 | /* fall through */ \ |
90 | case 2: \ | | 90 | case 2: \ |
91 | delta += 1000000; \ | | 91 | delta += 1000000; \ |
92 | /* fall through */ \ | | 92 | /* fall through */ \ |
93 | case 1: \ | | 93 | case 1: \ |
94 | delta += 1000000; \ | | 94 | delta += 1000000; \ |
95 | break; \ | | 95 | break; \ |
96 | } \ | | 96 | } \ |
97 | } \ | | 97 | } \ |
98 | } | | 98 | } while (0) |
99 | | | 99 | |
100 | #define TV_ADD_DELTA(a, delta, res) { \ | | 100 | #define TV_ADD_DELTA(a, delta, res) do { \ |
101 | register int xxus = (a)->tv_usec + (delta); \ | | 101 | register int xxus = (a)->tv_usec + (delta); \ |
102 | \ | | 102 | \ |
103 | (res)->tv_sec = (a)->tv_sec; \ | | 103 | (res)->tv_sec = (a)->tv_sec; \ |
104 | while (xxus >= 1000000) { \ | | 104 | while (xxus >= 1000000) { \ |
105 | ++((res)->tv_sec); \ | | 105 | ++((res)->tv_sec); \ |
106 | xxus -= 1000000; \ | | 106 | xxus -= 1000000; \ |
107 | } \ | | 107 | } \ |
108 | (res)->tv_usec = xxus; \ | | 108 | (res)->tv_usec = xxus; \ |
109 | } | | 109 | } while (0) |
110 | | | 110 | |
111 | #define RM_TIMEOUT 2 /* 1 Clock tick. */ | | 111 | #define RM_TIMEOUT 2 /* 1 Clock tick. */ |
112 | | | 112 | |
113 | #if 1 | | 113 | #if 1 |
114 | #define RM_MAXQUEUED 1 /* this isn't used in ALTQ/CBQ */ | | 114 | #define RM_MAXQUEUED 1 /* this isn't used in ALTQ/CBQ */ |
115 | #else | | 115 | #else |
116 | #define RM_MAXQUEUED 16 /* Max number of packets downstream of CBQ */ | | 116 | #define RM_MAXQUEUED 16 /* Max number of packets downstream of CBQ */ |
117 | #endif | | 117 | #endif |
118 | #define RM_MAXQUEUE 64 /* Max queue length */ | | 118 | #define RM_MAXQUEUE 64 /* Max queue length */ |
119 | #define RM_FILTER_GAIN 5 /* log2 of gain, e.g., 5 => 31/32 */ | | 119 | #define RM_FILTER_GAIN 5 /* log2 of gain, e.g., 5 => 31/32 */ |
120 | #define RM_POWER (1 << RM_FILTER_GAIN) | | 120 | #define RM_POWER (1 << RM_FILTER_GAIN) |
121 | #define RM_MAXDEPTH 32 | | 121 | #define RM_MAXDEPTH 32 |
122 | #define RM_NS_PER_SEC (1000000000) | | 122 | #define RM_NS_PER_SEC (1000000000) |