Lines Matching refs:block
201 static struct tcf_chain *tcf_chain_create(struct tcf_block *block, in tcf_chain_create() argument
209 list_add_tail(&chain->list, &block->chain_list); in tcf_chain_create()
210 chain->block = block; in tcf_chain_create()
214 block->chain0.chain = chain; in tcf_chain_create()
229 struct tcf_block *block = chain->block; in tcf_chain0_head_change() local
233 list_for_each_entry(item, &block->chain0.filter_chain_list, list) in tcf_chain0_head_change()
239 struct tcf_block *block = chain->block; in tcf_chain_destroy() local
243 block->chain0.chain = NULL; in tcf_chain_destroy()
245 if (list_empty(&block->chain_list) && block->refcnt == 0) in tcf_chain_destroy()
246 kfree(block); in tcf_chain_destroy()
262 static struct tcf_chain *tcf_chain_lookup(struct tcf_block *block, in tcf_chain_lookup() argument
267 list_for_each_entry(chain, &block->chain_list, list) { in tcf_chain_lookup()
277 static struct tcf_chain *__tcf_chain_get(struct tcf_block *block, in __tcf_chain_get() argument
281 struct tcf_chain *chain = tcf_chain_lookup(block, chain_index); in __tcf_chain_get()
288 chain = tcf_chain_create(block, chain_index); in __tcf_chain_get()
308 static struct tcf_chain *tcf_chain_get(struct tcf_block *block, u32 chain_index, in tcf_chain_get() argument
311 return __tcf_chain_get(block, chain_index, create, false); in tcf_chain_get()
314 struct tcf_chain *tcf_chain_get_by_act(struct tcf_block *block, u32 chain_index) in tcf_chain_get_by_act() argument
316 return __tcf_chain_get(block, chain_index, true, true); in tcf_chain_get_by_act()
368 static bool tcf_block_offload_in_use(struct tcf_block *block) in tcf_block_offload_in_use() argument
370 return block->offloadcnt; in tcf_block_offload_in_use()
373 static int tcf_block_offload_cmd(struct tcf_block *block, in tcf_block_offload_cmd() argument
383 bo.block = block; in tcf_block_offload_cmd()
388 static int tcf_block_offload_bind(struct tcf_block *block, struct Qdisc *q, in tcf_block_offload_bind() argument
401 if (!tc_can_offload(dev) && tcf_block_offload_in_use(block)) { in tcf_block_offload_bind()
406 err = tcf_block_offload_cmd(block, dev, ei, TC_BLOCK_BIND, extack); in tcf_block_offload_bind()
412 if (tcf_block_offload_in_use(block)) in tcf_block_offload_bind()
414 block->nooffloaddevcnt++; in tcf_block_offload_bind()
418 static void tcf_block_offload_unbind(struct tcf_block *block, struct Qdisc *q, in tcf_block_offload_unbind() argument
426 err = tcf_block_offload_cmd(block, dev, ei, TC_BLOCK_UNBIND, NULL); in tcf_block_offload_unbind()
432 WARN_ON(block->nooffloaddevcnt-- == 0); in tcf_block_offload_unbind()
436 tcf_chain0_head_change_cb_add(struct tcf_block *block, in tcf_chain0_head_change_cb_add() argument
440 struct tcf_chain *chain0 = block->chain0.chain; in tcf_chain0_head_change_cb_add()
452 list_add(&item->list, &block->chain0.filter_chain_list); in tcf_chain0_head_change_cb_add()
457 tcf_chain0_head_change_cb_del(struct tcf_block *block, in tcf_chain0_head_change_cb_del() argument
460 struct tcf_chain *chain0 = block->chain0.chain; in tcf_chain0_head_change_cb_del()
463 list_for_each_entry(item, &block->chain0.filter_chain_list, list) { in tcf_chain0_head_change_cb_del()
483 static int tcf_block_insert(struct tcf_block *block, struct net *net, in tcf_block_insert() argument
488 return idr_alloc_u32(&tn->idr, block, &block->index, block->index, in tcf_block_insert()
492 static void tcf_block_remove(struct tcf_block *block, struct net *net) in tcf_block_remove() argument
496 idr_remove(&tn->idr, block->index); in tcf_block_remove()
503 struct tcf_block *block; in tcf_block_create() local
505 block = kzalloc(sizeof(*block), GFP_KERNEL); in tcf_block_create()
506 if (!block) { in tcf_block_create()
510 INIT_LIST_HEAD(&block->chain_list); in tcf_block_create()
511 INIT_LIST_HEAD(&block->cb_list); in tcf_block_create()
512 INIT_LIST_HEAD(&block->owner_list); in tcf_block_create()
513 INIT_LIST_HEAD(&block->chain0.filter_chain_list); in tcf_block_create()
515 block->refcnt = 1; in tcf_block_create()
516 block->net = net; in tcf_block_create()
517 block->index = block_index; in tcf_block_create()
520 if (!tcf_block_shared(block)) in tcf_block_create()
521 block->q = q; in tcf_block_create()
522 return block; in tcf_block_create()
541 struct tcf_block *block; in tcf_block_find() local
544 block = tcf_block_lookup(net, block_index); in tcf_block_find()
545 if (!block) { in tcf_block_find()
592 block = cops->tcf_block(*q, *cl, extack); in tcf_block_find()
593 if (!block) in tcf_block_find()
595 if (tcf_block_shared(block)) { in tcf_block_find()
601 return block; in tcf_block_find()
611 tcf_block_owner_netif_keep_dst(struct tcf_block *block, in tcf_block_owner_netif_keep_dst() argument
615 if (block->keep_dst && in tcf_block_owner_netif_keep_dst()
621 void tcf_block_netif_keep_dst(struct tcf_block *block) in tcf_block_netif_keep_dst() argument
625 block->keep_dst = true; in tcf_block_netif_keep_dst()
626 list_for_each_entry(item, &block->owner_list, list) in tcf_block_netif_keep_dst()
627 tcf_block_owner_netif_keep_dst(block, item->q, in tcf_block_netif_keep_dst()
632 static int tcf_block_owner_add(struct tcf_block *block, in tcf_block_owner_add() argument
643 list_add(&item->list, &block->owner_list); in tcf_block_owner_add()
647 static void tcf_block_owner_del(struct tcf_block *block, in tcf_block_owner_del() argument
653 list_for_each_entry(item, &block->owner_list, list) { in tcf_block_owner_del()
668 struct tcf_block *block = NULL; in tcf_block_get_ext() local
674 block = tcf_block_lookup(net, ei->block_index); in tcf_block_get_ext()
675 if (block) in tcf_block_get_ext()
676 block->refcnt++; in tcf_block_get_ext()
679 if (!block) { in tcf_block_get_ext()
680 block = tcf_block_create(net, q, ei->block_index, extack); in tcf_block_get_ext()
681 if (IS_ERR(block)) in tcf_block_get_ext()
682 return PTR_ERR(block); in tcf_block_get_ext()
684 if (tcf_block_shared(block)) { in tcf_block_get_ext()
685 err = tcf_block_insert(block, net, extack); in tcf_block_get_ext()
691 err = tcf_block_owner_add(block, q, ei->binder_type); in tcf_block_get_ext()
695 tcf_block_owner_netif_keep_dst(block, q, ei->binder_type); in tcf_block_get_ext()
697 err = tcf_chain0_head_change_cb_add(block, ei, extack); in tcf_block_get_ext()
701 err = tcf_block_offload_bind(block, q, ei, extack); in tcf_block_get_ext()
705 *p_block = block; in tcf_block_get_ext()
709 tcf_chain0_head_change_cb_del(block, ei); in tcf_block_get_ext()
711 tcf_block_owner_del(block, q, ei->binder_type); in tcf_block_get_ext()
714 if (tcf_block_shared(block)) in tcf_block_get_ext()
715 tcf_block_remove(block, net); in tcf_block_get_ext()
717 kfree(block); in tcf_block_get_ext()
719 block->refcnt--; in tcf_block_get_ext()
749 void tcf_block_put_ext(struct tcf_block *block, struct Qdisc *q, in tcf_block_put_ext() argument
754 if (!block) in tcf_block_put_ext()
756 tcf_chain0_head_change_cb_del(block, ei); in tcf_block_put_ext()
757 tcf_block_owner_del(block, q, ei->binder_type); in tcf_block_put_ext()
759 if (block->refcnt == 1) { in tcf_block_put_ext()
760 if (tcf_block_shared(block)) in tcf_block_put_ext()
761 tcf_block_remove(block, block->net); in tcf_block_put_ext()
766 list_for_each_entry(chain, &block->chain_list, list) in tcf_block_put_ext()
769 list_for_each_entry(chain, &block->chain_list, list) in tcf_block_put_ext()
773 tcf_block_offload_unbind(block, q, ei); in tcf_block_put_ext()
775 if (block->refcnt == 1) { in tcf_block_put_ext()
777 list_for_each_entry_safe(chain, tmp, &block->chain_list, list) { in tcf_block_put_ext()
782 block->refcnt--; in tcf_block_put_ext()
783 if (list_empty(&block->chain_list)) in tcf_block_put_ext()
784 kfree(block); in tcf_block_put_ext()
786 block->refcnt--; in tcf_block_put_ext()
791 void tcf_block_put(struct tcf_block *block) in tcf_block_put() argument
795 if (!block) in tcf_block_put()
797 tcf_block_put_ext(block, block->q, &ei); in tcf_block_put()
816 struct tcf_block_cb *tcf_block_cb_lookup(struct tcf_block *block, in tcf_block_cb_lookup() argument
820 list_for_each_entry(block_cb, &block->cb_list, list) in tcf_block_cb_lookup()
840 tcf_block_playback_offloads(struct tcf_block *block, tc_setup_cb_t *cb, in tcf_block_playback_offloads() argument
848 list_for_each_entry(chain, &block->chain_list, list) { in tcf_block_playback_offloads()
867 tcf_block_playback_offloads(block, cb, cb_priv, false, offload_in_use, in tcf_block_playback_offloads()
872 struct tcf_block_cb *__tcf_block_cb_register(struct tcf_block *block, in __tcf_block_cb_register() argument
881 err = tcf_block_playback_offloads(block, cb, cb_priv, true, in __tcf_block_cb_register()
882 tcf_block_offload_in_use(block), in __tcf_block_cb_register()
893 list_add(&block_cb->list, &block->cb_list); in __tcf_block_cb_register()
898 int tcf_block_cb_register(struct tcf_block *block, in tcf_block_cb_register() argument
904 block_cb = __tcf_block_cb_register(block, cb, cb_ident, cb_priv, in tcf_block_cb_register()
910 void __tcf_block_cb_unregister(struct tcf_block *block, in __tcf_block_cb_unregister() argument
913 tcf_block_playback_offloads(block, block_cb->cb, block_cb->cb_priv, in __tcf_block_cb_unregister()
914 false, tcf_block_offload_in_use(block), in __tcf_block_cb_unregister()
921 void tcf_block_cb_unregister(struct tcf_block *block, in tcf_block_cb_unregister() argument
926 block_cb = tcf_block_cb_lookup(block, cb, cb_ident); in tcf_block_cb_unregister()
929 __tcf_block_cb_unregister(block, block_cb); in tcf_block_cb_unregister()
933 static int tcf_block_cb_call(struct tcf_block *block, enum tc_setup_type type, in tcf_block_cb_call() argument
941 if (block->nooffloaddevcnt && err_stop) in tcf_block_cb_call()
944 list_for_each_entry(block_cb, &block->cb_list, list) { in tcf_block_cb_call()
998 tp->chain->block->index, in tcf_classify()
1072 struct tcf_proto *tp, struct tcf_block *block, in tcf_fill_node() argument
1092 tcm->tcm_block_index = block->index; in tcf_fill_node()
1116 struct tcf_block *block, struct Qdisc *q, in tfilter_notify() argument
1126 if (tcf_fill_node(net, skb, tp, block, q, parent, fh, portid, in tfilter_notify()
1141 struct tcf_block *block, struct Qdisc *q, in tfilter_del_notify() argument
1153 if (tcf_fill_node(net, skb, tp, block, q, parent, fh, portid, in tfilter_del_notify()
1177 struct tcf_block *block, struct Qdisc *q, in tfilter_notify_chain() argument
1185 tfilter_notify(net, oskb, n, tp, block, in tfilter_notify_chain()
1203 struct tcf_block *block; in tc_new_tfilter() local
1242 block = tcf_block_find(net, &q, &parent, &cl, in tc_new_tfilter()
1244 if (IS_ERR(block)) { in tc_new_tfilter()
1245 err = PTR_ERR(block); in tc_new_tfilter()
1255 chain = tcf_chain_get(block, chain_index, true); in tc_new_tfilter()
1327 tfilter_notify(net, skb, n, tp, block, q, parent, fh, in tc_new_tfilter()
1356 struct tcf_block *block; in tc_del_tfilter() local
1381 block = tcf_block_find(net, &q, &parent, &cl, in tc_del_tfilter()
1383 if (IS_ERR(block)) { in tc_del_tfilter()
1384 err = PTR_ERR(block); in tc_del_tfilter()
1394 chain = tcf_chain_get(block, chain_index, false); in tc_del_tfilter()
1409 tfilter_notify_chain(net, skb, block, q, parent, n, in tc_del_tfilter()
1433 tfilter_notify(net, skb, n, tp, block, q, parent, fh, in tc_del_tfilter()
1444 err = tfilter_del_notify(net, skb, n, tp, block, in tc_del_tfilter()
1474 struct tcf_block *block; in tc_get_tfilter() local
1496 block = tcf_block_find(net, &q, &parent, &cl, in tc_get_tfilter()
1498 if (IS_ERR(block)) { in tc_get_tfilter()
1499 err = PTR_ERR(block); in tc_get_tfilter()
1509 chain = tcf_chain_get(block, chain_index, false); in tc_get_tfilter()
1534 err = tfilter_notify(net, skb, n, tp, block, q, parent, in tc_get_tfilter()
1550 struct tcf_block *block; member
1560 return tcf_fill_node(net, a->skb, tp, a->block, a->q, a->parent, in tcf_node_dump()
1571 struct tcf_block *block = chain->block; in tcf_chain_dump() local
1590 if (tcf_fill_node(net, skb, tp, block, q, parent, NULL, in tcf_chain_dump()
1603 arg.block = block; in tcf_chain_dump()
1625 struct tcf_block *block; in tc_dump_tfilter() local
1641 block = tcf_block_lookup(net, tcm->tcm_block_index); in tc_dump_tfilter()
1642 if (!block) in tc_dump_tfilter()
1679 block = cops->tcf_block(q, cl, NULL); in tc_dump_tfilter()
1680 if (!block) in tc_dump_tfilter()
1682 if (tcf_block_shared(block)) in tc_dump_tfilter()
1689 list_for_each_entry(chain, &block->chain_list, list) { in tc_dump_tfilter()
1710 struct sk_buff *skb, struct tcf_block *block, in tc_chain_fill_node() argument
1730 if (block->q) { in tc_chain_fill_node()
1731 tcm->tcm_ifindex = qdisc_dev(block->q)->ifindex; in tc_chain_fill_node()
1732 tcm->tcm_parent = block->q->handle; in tc_chain_fill_node()
1735 tcm->tcm_block_index = block->index; in tc_chain_fill_node()
1761 struct tcf_block *block = chain->block; in tc_chain_notify() local
1762 struct net *net = block->net; in tc_chain_notify()
1769 if (tc_chain_fill_node(chain, net, skb, block, portid, in tc_chain_notify()
1834 struct tcf_block *block; in tc_ctl_chain() local
1851 block = tcf_block_find(net, &q, &parent, &cl, in tc_ctl_chain()
1853 if (IS_ERR(block)) in tc_ctl_chain()
1854 return PTR_ERR(block); in tc_ctl_chain()
1861 chain = tcf_chain_lookup(block, chain_index); in tc_ctl_chain()
1878 chain = tcf_chain_create(block, chain_index); in tc_ctl_chain()
1907 tfilter_notify_chain(net, skb, block, q, parent, n, in tc_ctl_chain()
1943 struct tcf_block *block; in tc_dump_chain() local
1960 block = tcf_block_lookup(net, tcm->tcm_block_index); in tc_dump_chain()
1961 if (!block) in tc_dump_chain()
1998 block = cops->tcf_block(q, cl, NULL); in tc_dump_chain()
1999 if (!block) in tc_dump_chain()
2001 if (tcf_block_shared(block)) in tc_dump_chain()
2008 list_for_each_entry(chain, &block->chain_list, list) { in tc_dump_chain()
2018 err = tc_chain_fill_node(chain, net, skb, block, in tc_dump_chain()
2193 int tc_setup_cb_call(struct tcf_block *block, struct tcf_exts *exts, in tc_setup_cb_call() argument
2199 ret = tcf_block_cb_call(block, type, type_data, err_stop); in tc_setup_cb_call()