From 857743a47b460febecdb808e41076e8e0740d8f6 Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Sat, 20 Oct 2007 11:10:50 +0000 Subject: [PATCH] - Change some comment's style - White space changes - Use POSIX int types --- sys/net/dummynet/ip_dummynet.h | 282 ++++++++++++++++++++--------------------- 1 file changed, 140 insertions(+), 142 deletions(-) diff --git a/sys/net/dummynet/ip_dummynet.h b/sys/net/dummynet/ip_dummynet.h index cb176defd4..ac1b23b49e 100644 --- a/sys/net/dummynet/ip_dummynet.h +++ b/sys/net/dummynet/ip_dummynet.h @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/netinet/ip_dummynet.h,v 1.10.2.9 2003/05/13 09:31:06 maxim Exp $ - * $DragonFly: src/sys/net/dummynet/ip_dummynet.h,v 1.7 2007/10/20 09:08:28 sephe Exp $ + * $DragonFly: src/sys/net/dummynet/ip_dummynet.h,v 1.8 2007/10/20 11:10:50 sephe Exp $ */ #ifndef _IP_DUMMYNET_H @@ -58,12 +58,12 @@ * MY_M is used as a shift count when doing fixed point arithmetic * (a better name would be useful...). */ -typedef u_int64_t dn_key ; /* sorting key */ -#define DN_KEY_LT(a,b) ((int64_t)((a)-(b)) < 0) -#define DN_KEY_LEQ(a,b) ((int64_t)((a)-(b)) <= 0) -#define DN_KEY_GT(a,b) ((int64_t)((a)-(b)) > 0) -#define DN_KEY_GEQ(a,b) ((int64_t)((a)-(b)) >= 0) -#define MAX64(x,y) (( (int64_t) ( (y)-(x) )) > 0 ) ? (y) : (x) +typedef uint64_t dn_key; /* sorting key */ +#define DN_KEY_LT(a,b) ((int64_t)((a)-(b)) < 0) +#define DN_KEY_LEQ(a,b) ((int64_t)((a)-(b)) <= 0) +#define DN_KEY_GT(a,b) ((int64_t)((a)-(b)) > 0) +#define DN_KEY_GEQ(a,b) ((int64_t)((a)-(b)) >= 0) +#define MAX64(x,y) (((int64_t)((y) - (x))) > 0) ? (y) : (x) #define MY_M 16 /* number of left shift to obtain a larger precision */ /* @@ -93,16 +93,16 @@ typedef u_int64_t dn_key ; /* sorting key */ * is non-zero if we want to support extract from the middle. */ struct dn_heap_entry { - dn_key key ; /* sorting key. Topmost element is smallest one */ - void *object ; /* object pointer */ -} ; + dn_key key; /* sorting key. Topmost element is smallest one */ + void *object; /* object pointer */ +}; struct dn_heap { - int size ; - int elements ; - int offset ; /* XXX if > 0 this is the offset of direct ptr to obj */ - struct dn_heap_entry *p ; /* really an array of "size" entries */ -} ; + int size; + int elements; + int offset; /* XXX if > 0 this is the offset of direct ptr to obj */ + struct dn_heap_entry *p; /* really an array of "size" entries */ +}; #if defined(_KERNEL) || defined(_KERNEL_STRUCTURES) @@ -132,73 +132,71 @@ struct dn_pkt { #define DN_TO_ETH_DEMUX 4 #define DN_TO_ETH_OUT 5 - dn_key output_time; /* when the pkt is due for delivery */ - struct ifnet *ifp; /* interface, for ip_output */ + dn_key output_time; /* when the pkt is due for delivery */ + struct ifnet *ifp; /* interface, for ip_output */ struct sockaddr_in *dn_dst; - struct route ro; /* route, for ip_output. MUST COPY */ - int flags; /* flags, for ip_output (IPv6 ?) */ + struct route ro; /* route, for ip_output. MUST COPY */ + int flags; /* flags, for ip_output (IPv6 ?) */ }; #endif /* * Overall structure of dummynet (with WF2Q+): - -In dummynet, packets are selected with the firewall rules, and passed -to two different objects: PIPE or QUEUE. - -A QUEUE is just a queue with configurable size and queue management -policy. It is also associated with a mask (to discriminate among -different flows), a weight (used to give different shares of the -bandwidth to different flows) and a "pipe", which essentially -supplies the transmit clock for all queues associated with that -pipe. - -A PIPE emulates a fixed-bandwidth link, whose bandwidth is -configurable. The "clock" for a pipe can come from either an -internal timer, or from the transmit interrupt of an interface. -A pipe is also associated with one (or more, if masks are used) -queue, where all packets for that pipe are stored. - -The bandwidth available on the pipe is shared by the queues -associated with that pipe (only one in case the packet is sent -to a PIPE) according to the WF2Q+ scheduling algorithm and the -configured weights. - -In general, incoming packets are stored in the appropriate queue, -which is then placed into one of a few heaps managed by a scheduler -to decide when the packet should be extracted. -The scheduler (a function called dummynet()) is run at every timer -tick, and grabs queues from the head of the heaps when they are -ready for processing. - -There are three data structures definining a pipe and associated queues: - - + dn_pipe, which contains the main configuration parameters related - to delay and bandwidth; - + dn_flow_set, which contains WF2Q+ configuration, flow - masks, plr and RED configuration; - + dn_flow_queue, which is the per-flow queue (containing the packets) - -Multiple dn_flow_set can be linked to the same pipe, and multiple -dn_flow_queue can be linked to the same dn_flow_set. -All data structures are linked in a linear list which is used for -housekeeping purposes. - -During configuration, we create and initialize the dn_flow_set -and dn_pipe structures (a dn_pipe also contains a dn_flow_set). - -At runtime: packets are sent to the appropriate dn_flow_set (either -WFQ ones, or the one embedded in the dn_pipe for fixed-rate flows), -which in turn dispatches them to the appropriate dn_flow_queue -(created dynamically according to the masks). - -The transmit clock for fixed rate flows (ready_event()) selects the -dn_flow_queue to be used to transmit the next packet. For WF2Q, -wfq_ready_event() extract a pipe which in turn selects the right -flow using a number of heaps defined into the pipe itself. - - * + * + * In dummynet, packets are selected with the firewall rules, and passed + * to two different objects: PIPE or QUEUE. + * + * A QUEUE is just a queue with configurable size and queue management + * policy. It is also associated with a mask (to discriminate among + * different flows), a weight (used to give different shares of the + * bandwidth to different flows) and a "pipe", which essentially + * supplies the transmit clock for all queues associated with that + * pipe. + * + * A PIPE emulates a fixed-bandwidth link, whose bandwidth is + * configurable. The "clock" for a pipe can come from either an + * internal timer, or from the transmit interrupt of an interface. + * A pipe is also associated with one (or more, if masks are used) + * queue, where all packets for that pipe are stored. + * + * The bandwidth available on the pipe is shared by the queues + * associated with that pipe (only one in case the packet is sent + * to a PIPE) according to the WF2Q+ scheduling algorithm and the + * configured weights. + * + * In general, incoming packets are stored in the appropriate queue, + * which is then placed into one of a few heaps managed by a scheduler + * to decide when the packet should be extracted. + * The scheduler (a function called dummynet()) is run at every timer + * tick, and grabs queues from the head of the heaps when they are + * ready for processing. + * + * There are three data structures definining a pipe and associated queues: + * + * + dn_pipe, which contains the main configuration parameters related + * to delay and bandwidth; + * + dn_flow_set, which contains WF2Q+ configuration, flow + * masks, plr and RED configuration; + * + dn_flow_queue, which is the per-flow queue (containing the packets) + * + * Multiple dn_flow_set can be linked to the same pipe, and multiple + * dn_flow_queue can be linked to the same dn_flow_set. + * All data structures are linked in a linear list which is used for + * housekeeping purposes. + * + * During configuration, we create and initialize the dn_flow_set + * and dn_pipe structures (a dn_pipe also contains a dn_flow_set). + * + * At runtime: packets are sent to the appropriate dn_flow_set (either + * WFQ ones, or the one embedded in the dn_pipe for fixed-rate flows), + * which in turn dispatches them to the appropriate dn_flow_queue + * (created dynamically according to the masks). + * + * The transmit clock for fixed rate flows (ready_event()) selects the + * dn_flow_queue to be used to transmit the next packet. For WF2Q, + * wfq_ready_event() extract a pipe which in turn selects the right + * flow using a number of heaps defined into the pipe itself. */ /* @@ -210,37 +208,37 @@ flow using a number of heaps defined into the pipe itself. * a new flow arrives. */ struct dn_flow_queue { - struct dn_flow_queue *next ; - struct ipfw_flow_id id ; + struct dn_flow_queue *next; + struct ipfw_flow_id id; - struct dn_pkt *head, *tail ; /* queue of packets */ - u_int len ; - u_int len_bytes ; - u_long numbytes ; /* credit for transmission (dynamic queues) */ + struct dn_pkt *head, *tail; /* queue of packets */ + u_int len; + u_int len_bytes; + u_long numbytes; /* credit for transmission (dynamic queues) */ - u_int64_t tot_pkts ; /* statistics counters */ - u_int64_t tot_bytes ; - u_int32_t drops ; + uint64_t tot_pkts; /* statistics counters */ + uint64_t tot_bytes; + uint32_t drops; - int hash_slot ; /* debugging/diagnostic */ + int hash_slot; /* debugging/diagnostic */ /* RED parameters */ - int avg ; /* average queue length est. (scaled) */ - int count ; /* arrivals since last RED drop */ - int random ; /* random value (scaled) */ - u_int32_t q_time ; /* start of queue idle time */ + int avg; /* average queue length est. (scaled) */ + int count; /* arrivals since last RED drop */ + int random; /* random value (scaled) */ + uint32_t q_time; /* start of queue idle time */ /* WF2Q+ support */ - struct dn_flow_set *fs ; /* parent flow set */ - int heap_pos ; /* position (index) of struct in heap */ - dn_key sched_time ; /* current time when queue enters ready_heap */ + struct dn_flow_set *fs; /* parent flow set */ + int heap_pos; /* position (index) of struct in heap */ + dn_key sched_time; /* current time when queue enters ready_heap */ - dn_key S,F ; /* start time, finish time */ + dn_key S, F; /* start time, finish time */ /* * Setting F < S means the timestamp is invalid. We only need * to test this when the queue is empty. */ -} ; +}; /* * flow_set descriptor. Contains the "template" parameters for the @@ -255,55 +253,55 @@ struct dn_flow_queue { * latter case, the structure is located inside the struct dn_pipe). */ struct dn_flow_set { - struct dn_flow_set *next; /* next flow set in all_flow_sets list */ + struct dn_flow_set *next; /* next flow set in all_flow_sets list */ - u_short fs_nr ; /* flow_set number */ + u_short fs_nr; /* flow_set number */ u_short flags_fs; #define DN_HAVE_FLOW_MASK 0x0001 #define DN_IS_RED 0x0002 #define DN_IS_GENTLE_RED 0x0004 #define DN_QSIZE_IS_BYTES 0x0008 /* queue size is measured in bytes */ -#define DN_NOERROR 0x0010 /* do not report ENOBUFS on drops */ +#define DN_NOERROR 0x0010 /* do not report ENOBUFS on drops */ #define DN_IS_PIPE 0x4000 #define DN_IS_QUEUE 0x8000 - struct dn_pipe *pipe ; /* pointer to parent pipe */ - u_short parent_nr ; /* parent pipe#, 0 if local to a pipe */ + struct dn_pipe *pipe; /* pointer to parent pipe */ + u_short parent_nr; /* parent pipe#, 0 if local to a pipe */ - int weight ; /* WFQ queue weight */ - int qsize ; /* queue size in slots or bytes */ - int plr ; /* pkt loss rate (2^31-1 means 100%) */ + int weight; /* WFQ queue weight */ + int qsize; /* queue size in slots or bytes */ + int plr; /* pkt loss rate (2^31-1 means 100%) */ - struct ipfw_flow_id flow_mask ; + struct ipfw_flow_id flow_mask; /* hash table of queues onto this flow_set */ - int rq_size ; /* number of slots */ - int rq_elements ; /* active elements */ + int rq_size; /* number of slots */ + int rq_elements; /* active elements */ struct dn_flow_queue **rq; /* array of rq_size entries */ - u_int32_t last_expired ; /* do not expire too frequently */ - int backlogged ; /* #active queues for this flowset */ - - /* RED parameters */ -#define SCALE_RED 16 -#define SCALE(x) ( (x) << SCALE_RED ) -#define SCALE_VAL(x) ( (x) >> SCALE_RED ) -#define SCALE_MUL(x,y) ( ( (x) * (y) ) >> SCALE_RED ) - int w_q ; /* queue weight (scaled) */ - int max_th ; /* maximum threshold for queue (scaled) */ - int min_th ; /* minimum threshold for queue (scaled) */ - int max_p ; /* maximum value for p_b (scaled) */ - u_int c_1 ; /* max_p/(max_th-min_th) (scaled) */ - u_int c_2 ; /* max_p*min_th/(max_th-min_th) (scaled) */ - u_int c_3 ; /* for GRED, (1-max_p)/max_th (scaled) */ - u_int c_4 ; /* for GRED, 1 - 2*max_p (scaled) */ - u_int * w_q_lookup ; /* lookup table for computing (1-w_q)^t */ - u_int lookup_depth ; /* depth of lookup table */ - int lookup_step ; /* granularity inside the lookup table */ - int lookup_weight ; /* equal to (1-w_q)^t / (1-w_q)^(t+1) */ - int avg_pkt_size ; /* medium packet size */ - int max_pkt_size ; /* max packet size */ -} ; + uint32_t last_expired; /* do not expire too frequently */ + int backlogged; /* #active queues for this flowset */ + + /* RED parameters */ +#define SCALE_RED 16 +#define SCALE(x) ((x) << SCALE_RED) +#define SCALE_VAL(x) ((x) >> SCALE_RED) +#define SCALE_MUL(x, y) (((x) * (y)) >> SCALE_RED) + int w_q; /* queue weight (scaled) */ + int max_th; /* maximum threshold for queue (scaled) */ + int min_th; /* minimum threshold for queue (scaled) */ + int max_p; /* maximum value for p_b (scaled) */ + u_int c_1; /* max_p/(max_th-min_th) (scaled) */ + u_int c_2; /* max_p*min_th/(max_th-min_th) (scaled) */ + u_int c_3; /* for GRED, (1-max_p)/max_th (scaled) */ + u_int c_4; /* for GRED, 1 - 2*max_p (scaled) */ + u_int *w_q_lookup; /* lookup table for computing (1-w_q)^t */ + u_int lookup_depth; /* depth of lookup table */ + int lookup_step; /* granularity inside the lookup table */ + int lookup_weight; /* equal to (1-w_q)^t / (1-w_q)^(t+1) */ + int avg_pkt_size; /* medium packet size */ + int max_pkt_size; /* max packet size */ +}; /* * Pipe descriptor. Contains global parameters, delay-line queue, @@ -320,39 +318,39 @@ struct dn_flow_set { * */ struct dn_pipe { /* a pipe */ - struct dn_pipe *next ; + struct dn_pipe *next; - int pipe_nr ; /* number */ - int bandwidth; /* really, bytes/tick. */ - int delay ; /* really, ticks */ + int pipe_nr; /* number */ + int bandwidth; /* really, bytes/tick. */ + int delay; /* really, ticks */ - struct dn_pkt *head, *tail ; /* packets in delay line */ + struct dn_pkt *head, *tail; /* packets in delay line */ /* WF2Q+ */ - struct dn_heap scheduler_heap ; /* top extract - key Finish time*/ + struct dn_heap scheduler_heap; /* top extract - key Finish time*/ struct dn_heap not_eligible_heap; /* top extract- key Start time */ - struct dn_heap idle_heap ; /* random extract - key Start=Finish time */ + struct dn_heap idle_heap; /* random extract - key Start=Finish time */ - dn_key V ; /* virtual time */ + dn_key V; /* virtual time */ int sum; /* sum of weights of all active sessions */ int numbytes; /* bits I can transmit (more or less). */ - dn_key sched_time ; /* time pipe was scheduled in ready_heap */ + dn_key sched_time; /* time pipe was scheduled in ready_heap */ /* * When the tx clock come from an interface (if_name[0] != '\0'), its name * is stored below, whereas the ifp is filled when the rule is configured. */ char if_name[IFNAMSIZ]; - struct ifnet *ifp ; - int ready ; /* set if ifp != NULL and we got a signal from it */ + struct ifnet *ifp; + int ready; /* set if ifp != NULL and we got a signal from it */ - struct dn_flow_set fs ; /* used with fixed-rate flows */ + struct dn_flow_set fs; /* used with fixed-rate flows */ }; #ifdef _KERNEL typedef int ip_dn_ctl_t(struct sockopt *); /* raw_ip.c */ -typedef void ip_dn_ruledel_t(void *); /* ip_fw.c */ +typedef void ip_dn_ruledel_t(void *); /* ip_fw2.c */ typedef int ip_dn_io_t(struct mbuf *m, int pipe_nr, int dir, struct ip_fw_args *fwa); extern ip_dn_ctl_t *ip_dn_ctl_ptr; @@ -361,4 +359,4 @@ extern ip_dn_io_t *ip_dn_io_ptr; #define DUMMYNET_LOADED (ip_dn_io_ptr != NULL) #endif -#endif /* _IP_DUMMYNET_H */ +#endif /* !_IP_DUMMYNET_H */ -- 2.11.4.GIT