sch_prio.c (20fea08b5fb639c4c175b5c74a2bb346c5c5bc2e) | sch_prio.c (1e90474c377e92db7262a8968a45c1dd980ca9e5) |
---|---|
1/* 2 * net/sched/sch_prio.c Simple 3-band priority "scheduler". 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 7 * 2 of the License, or (at your option) any later version. 8 * --- 210 unchanged lines hidden (view full) --- 219 int prio; 220 struct prio_sched_data *q = qdisc_priv(sch); 221 222 tcf_destroy_chain(q->filter_list); 223 for (prio=0; prio<q->bands; prio++) 224 qdisc_destroy(q->queues[prio]); 225} 226 | 1/* 2 * net/sched/sch_prio.c Simple 3-band priority "scheduler". 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 7 * 2 of the License, or (at your option) any later version. 8 * --- 210 unchanged lines hidden (view full) --- 219 int prio; 220 struct prio_sched_data *q = qdisc_priv(sch); 221 222 tcf_destroy_chain(q->filter_list); 223 for (prio=0; prio<q->bands; prio++) 224 qdisc_destroy(q->queues[prio]); 225} 226 |
227static int prio_tune(struct Qdisc *sch, struct rtattr *opt) | 227static int prio_tune(struct Qdisc *sch, struct nlattr *opt) |
228{ 229 struct prio_sched_data *q = qdisc_priv(sch); 230 struct tc_prio_qopt *qopt; | 228{ 229 struct prio_sched_data *q = qdisc_priv(sch); 230 struct tc_prio_qopt *qopt; |
231 struct rtattr *tb[TCA_PRIO_MAX]; | 231 struct nlattr *tb[TCA_PRIO_MAX + 1]; |
232 int i; 233 | 232 int i; 233 |
234 if (rtattr_parse_nested_compat(tb, TCA_PRIO_MAX, opt, qopt, 235 sizeof(*qopt))) | 234 if (nla_parse_nested_compat(tb, TCA_PRIO_MAX, opt, NULL, qopt, 235 sizeof(*qopt))) |
236 return -EINVAL; 237 q->bands = qopt->bands; 238 /* If we're multiqueue, make sure the number of incoming bands 239 * matches the number of queues on the device we're associating with. 240 * If the number of bands requested is zero, then set q->bands to 241 * dev->egress_subqueue_count. Also, the root qdisc must be the 242 * only one that is enabled for multiqueue, since it's the only one 243 * that interacts with the underlying device. 244 */ | 236 return -EINVAL; 237 q->bands = qopt->bands; 238 /* If we're multiqueue, make sure the number of incoming bands 239 * matches the number of queues on the device we're associating with. 240 * If the number of bands requested is zero, then set q->bands to 241 * dev->egress_subqueue_count. Also, the root qdisc must be the 242 * only one that is enabled for multiqueue, since it's the only one 243 * that interacts with the underlying device. 244 */ |
245 q->mq = RTA_GET_FLAG(tb[TCA_PRIO_MQ - 1]); | 245 q->mq = nla_get_flag(tb[TCA_PRIO_MQ]); |
246 if (q->mq) { 247 if (sch->parent != TC_H_ROOT) 248 return -EINVAL; 249 if (netif_is_multiqueue(sch->dev)) { 250 if (q->bands == 0) 251 q->bands = sch->dev->egress_subqueue_count; 252 else if (q->bands != sch->dev->egress_subqueue_count) 253 return -EINVAL; --- 37 unchanged lines hidden (view full) --- 291 } 292 sch_tree_unlock(sch); 293 } 294 } 295 } 296 return 0; 297} 298 | 246 if (q->mq) { 247 if (sch->parent != TC_H_ROOT) 248 return -EINVAL; 249 if (netif_is_multiqueue(sch->dev)) { 250 if (q->bands == 0) 251 q->bands = sch->dev->egress_subqueue_count; 252 else if (q->bands != sch->dev->egress_subqueue_count) 253 return -EINVAL; --- 37 unchanged lines hidden (view full) --- 291 } 292 sch_tree_unlock(sch); 293 } 294 } 295 } 296 return 0; 297} 298 |
299static int prio_init(struct Qdisc *sch, struct rtattr *opt) | 299static int prio_init(struct Qdisc *sch, struct nlattr *opt) |
300{ 301 struct prio_sched_data *q = qdisc_priv(sch); 302 int i; 303 304 for (i=0; i<TCQ_PRIO_BANDS; i++) 305 q->queues[i] = &noop_qdisc; 306 307 if (opt == NULL) { --- 6 unchanged lines hidden (view full) --- 314 } 315 return 0; 316} 317 318static int prio_dump(struct Qdisc *sch, struct sk_buff *skb) 319{ 320 struct prio_sched_data *q = qdisc_priv(sch); 321 unsigned char *b = skb_tail_pointer(skb); | 300{ 301 struct prio_sched_data *q = qdisc_priv(sch); 302 int i; 303 304 for (i=0; i<TCQ_PRIO_BANDS; i++) 305 q->queues[i] = &noop_qdisc; 306 307 if (opt == NULL) { --- 6 unchanged lines hidden (view full) --- 314 } 315 return 0; 316} 317 318static int prio_dump(struct Qdisc *sch, struct sk_buff *skb) 319{ 320 struct prio_sched_data *q = qdisc_priv(sch); 321 unsigned char *b = skb_tail_pointer(skb); |
322 struct rtattr *nest; | 322 struct nlattr *nest; |
323 struct tc_prio_qopt opt; 324 325 opt.bands = q->bands; 326 memcpy(&opt.priomap, q->prio2band, TC_PRIO_MAX+1); 327 | 323 struct tc_prio_qopt opt; 324 325 opt.bands = q->bands; 326 memcpy(&opt.priomap, q->prio2band, TC_PRIO_MAX+1); 327 |
328 nest = RTA_NEST_COMPAT(skb, TCA_OPTIONS, sizeof(opt), &opt); 329 if (q->mq) 330 RTA_PUT_FLAG(skb, TCA_PRIO_MQ); 331 RTA_NEST_COMPAT_END(skb, nest); | 328 nest = nla_nest_compat_start(skb, TCA_OPTIONS, sizeof(opt), &opt); 329 if (nest == NULL) 330 goto nla_put_failure; 331 if (q->mq) { 332 if (nla_put_flag(skb, TCA_PRIO_MQ) < 0) 333 goto nla_put_failure; 334 } 335 nla_nest_compat_end(skb, nest); |
332 333 return skb->len; 334 | 336 337 return skb->len; 338 |
335rtattr_failure: | 339nla_put_failure: |
336 nlmsg_trim(skb, b); 337 return -1; 338} 339 340static int prio_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new, 341 struct Qdisc **old) 342{ 343 struct prio_sched_data *q = qdisc_priv(sch); --- 43 unchanged lines hidden (view full) --- 387} 388 389 390static void prio_put(struct Qdisc *q, unsigned long cl) 391{ 392 return; 393} 394 | 340 nlmsg_trim(skb, b); 341 return -1; 342} 343 344static int prio_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new, 345 struct Qdisc **old) 346{ 347 struct prio_sched_data *q = qdisc_priv(sch); --- 43 unchanged lines hidden (view full) --- 391} 392 393 394static void prio_put(struct Qdisc *q, unsigned long cl) 395{ 396 return; 397} 398 |
395static int prio_change(struct Qdisc *sch, u32 handle, u32 parent, struct rtattr **tca, unsigned long *arg) | 399static int prio_change(struct Qdisc *sch, u32 handle, u32 parent, struct nlattr **tca, unsigned long *arg) |
396{ 397 unsigned long cl = *arg; 398 struct prio_sched_data *q = qdisc_priv(sch); 399 400 if (cl - 1 > q->bands) 401 return -ENOENT; 402 return 0; 403} --- 140 unchanged lines hidden --- | 400{ 401 unsigned long cl = *arg; 402 struct prio_sched_data *q = qdisc_priv(sch); 403 404 if (cl - 1 > q->bands) 405 return -ENOENT; 406 return 0; 407} --- 140 unchanged lines hidden --- |