Lines Matching full:block

61 	struct tcf_block *block = chain->block;  in tcf_proto_signal_destroying()  local
63 mutex_lock(&block->proto_destroy_lock); in tcf_proto_signal_destroying()
64 hash_add_rcu(block->proto_destroy_ht, &tp->destroy_ht_node, in tcf_proto_signal_destroying()
66 mutex_unlock(&block->proto_destroy_lock); in tcf_proto_signal_destroying()
85 hash_for_each_possible_rcu(chain->block->proto_destroy_ht, iter, in tcf_proto_exists_destroying()
100 struct tcf_block *block = chain->block; in tcf_proto_signal_destroyed() local
102 mutex_lock(&block->proto_destroy_lock); in tcf_proto_signal_destroyed()
105 mutex_unlock(&block->proto_destroy_lock); in tcf_proto_signal_destroyed()
339 #define ASSERT_BLOCK_LOCKED(block) \ argument
340 lockdep_assert_held(&(block)->lock)
348 static struct tcf_chain *tcf_chain_create(struct tcf_block *block, in tcf_chain_create() argument
353 ASSERT_BLOCK_LOCKED(block); in tcf_chain_create()
358 list_add_tail_rcu(&chain->list, &block->chain_list); in tcf_chain_create()
360 chain->block = block; in tcf_chain_create()
364 block->chain0.chain = chain; in tcf_chain_create()
379 struct tcf_block *block = chain->block; in tcf_chain0_head_change() local
384 mutex_lock(&block->lock); in tcf_chain0_head_change()
385 list_for_each_entry(item, &block->chain0.filter_chain_list, list) in tcf_chain0_head_change()
387 mutex_unlock(&block->lock); in tcf_chain0_head_change()
390 /* Returns true if block can be safely freed. */
394 struct tcf_block *block = chain->block; in tcf_chain_detach() local
396 ASSERT_BLOCK_LOCKED(block); in tcf_chain_detach()
400 block->chain0.chain = NULL; in tcf_chain_detach()
402 if (list_empty(&block->chain_list) && in tcf_chain_detach()
403 refcount_read(&block->refcnt) == 0) in tcf_chain_detach()
409 static void tcf_block_destroy(struct tcf_block *block) in tcf_block_destroy() argument
411 mutex_destroy(&block->lock); in tcf_block_destroy()
412 mutex_destroy(&block->proto_destroy_lock); in tcf_block_destroy()
413 kfree_rcu(block, rcu); in tcf_block_destroy()
418 struct tcf_block *block = chain->block; in tcf_chain_destroy() local
423 tcf_block_destroy(block); in tcf_chain_destroy()
428 ASSERT_BLOCK_LOCKED(chain->block); in tcf_chain_hold()
435 ASSERT_BLOCK_LOCKED(chain->block); in tcf_chain_held_by_acts_only()
443 static struct tcf_chain *tcf_chain_lookup(struct tcf_block *block, in tcf_chain_lookup() argument
448 ASSERT_BLOCK_LOCKED(block); in tcf_chain_lookup()
450 list_for_each_entry(chain, &block->chain_list, list) { in tcf_chain_lookup()
458 static struct tcf_chain *tcf_chain_lookup_rcu(const struct tcf_block *block, in tcf_chain_lookup_rcu() argument
463 list_for_each_entry_rcu(chain, &block->chain_list, list) { in tcf_chain_lookup_rcu()
474 static struct tcf_chain *__tcf_chain_get(struct tcf_block *block, in __tcf_chain_get() argument
481 mutex_lock(&block->lock); in __tcf_chain_get()
482 chain = tcf_chain_lookup(block, chain_index); in __tcf_chain_get()
488 chain = tcf_chain_create(block, chain_index); in __tcf_chain_get()
496 mutex_unlock(&block->lock); in __tcf_chain_get()
510 mutex_unlock(&block->lock); in __tcf_chain_get()
514 static struct tcf_chain *tcf_chain_get(struct tcf_block *block, u32 chain_index, in tcf_chain_get() argument
517 return __tcf_chain_get(block, chain_index, create, false); in tcf_chain_get()
520 struct tcf_chain *tcf_chain_get_by_act(struct tcf_block *block, u32 chain_index) in tcf_chain_get_by_act() argument
522 return __tcf_chain_get(block, chain_index, true, true); in tcf_chain_get_by_act()
530 struct tcf_block *block, struct sk_buff *oskb,
536 struct tcf_block *block = chain->block; in __tcf_chain_put() local
542 mutex_lock(&block->lock); in __tcf_chain_put()
545 mutex_unlock(&block->lock); in __tcf_chain_put()
554 /* tc_chain_notify_delete can't be called while holding block lock. in __tcf_chain_put()
555 * However, when block is unlocked chain can be changed concurrently, so in __tcf_chain_put()
565 block, NULL, 0, 0, false); in __tcf_chain_put()
572 mutex_unlock(&block->lock); in __tcf_chain_put()
620 static int tcf_block_setup(struct tcf_block *block,
633 bo->block = flow_block; in tcf_block_offload_init()
641 static void tcf_block_unbind(struct tcf_block *block,
646 struct tcf_block *block = block_cb->indr.data; in tc_block_indr_cleanup() local
654 &block->flow_block, tcf_block_shared(block), in tc_block_indr_cleanup()
657 down_write(&block->cb_lock); in tc_block_indr_cleanup()
660 tcf_block_unbind(block, &bo); in tc_block_indr_cleanup()
661 up_write(&block->cb_lock); in tc_block_indr_cleanup()
665 static bool tcf_block_offload_in_use(struct tcf_block *block) in tcf_block_offload_in_use() argument
667 return atomic_read(&block->offloadcnt); in tcf_block_offload_in_use()
670 static int tcf_block_offload_cmd(struct tcf_block *block, in tcf_block_offload_cmd() argument
679 &block->flow_block, tcf_block_shared(block), in tcf_block_offload_cmd()
692 return tcf_block_setup(block, &bo); in tcf_block_offload_cmd()
695 flow_indr_dev_setup_offload(dev, sch, TC_SETUP_BLOCK, block, &bo, in tcf_block_offload_cmd()
697 tcf_block_setup(block, &bo); in tcf_block_offload_cmd()
702 static int tcf_block_offload_bind(struct tcf_block *block, struct Qdisc *q, in tcf_block_offload_bind() argument
709 down_write(&block->cb_lock); in tcf_block_offload_bind()
711 /* If tc offload feature is disabled and the block we try to bind in tcf_block_offload_bind()
716 tcf_block_offload_in_use(block)) { in tcf_block_offload_bind()
717 NL_SET_ERR_MSG(extack, "Bind to offloaded block failed as dev has offload disabled"); in tcf_block_offload_bind()
722 err = tcf_block_offload_cmd(block, dev, q, ei, FLOW_BLOCK_BIND, extack); in tcf_block_offload_bind()
728 up_write(&block->cb_lock); in tcf_block_offload_bind()
732 if (tcf_block_offload_in_use(block)) in tcf_block_offload_bind()
736 block->nooffloaddevcnt++; in tcf_block_offload_bind()
738 up_write(&block->cb_lock); in tcf_block_offload_bind()
742 static void tcf_block_offload_unbind(struct tcf_block *block, struct Qdisc *q, in tcf_block_offload_unbind() argument
748 down_write(&block->cb_lock); in tcf_block_offload_unbind()
749 err = tcf_block_offload_cmd(block, dev, q, ei, FLOW_BLOCK_UNBIND, NULL); in tcf_block_offload_unbind()
752 up_write(&block->cb_lock); in tcf_block_offload_unbind()
756 WARN_ON(block->nooffloaddevcnt-- == 0); in tcf_block_offload_unbind()
757 up_write(&block->cb_lock); in tcf_block_offload_unbind()
761 tcf_chain0_head_change_cb_add(struct tcf_block *block, in tcf_chain0_head_change_cb_add() argument
776 mutex_lock(&block->lock); in tcf_chain0_head_change_cb_add()
777 chain0 = block->chain0.chain; in tcf_chain0_head_change_cb_add()
781 list_add(&item->list, &block->chain0.filter_chain_list); in tcf_chain0_head_change_cb_add()
782 mutex_unlock(&block->lock); in tcf_chain0_head_change_cb_add()
793 mutex_lock(&block->lock); in tcf_chain0_head_change_cb_add()
794 list_add(&item->list, &block->chain0.filter_chain_list); in tcf_chain0_head_change_cb_add()
795 mutex_unlock(&block->lock); in tcf_chain0_head_change_cb_add()
805 tcf_chain0_head_change_cb_del(struct tcf_block *block, in tcf_chain0_head_change_cb_del() argument
810 mutex_lock(&block->lock); in tcf_chain0_head_change_cb_del()
811 list_for_each_entry(item, &block->chain0.filter_chain_list, list) { in tcf_chain0_head_change_cb_del()
815 if (block->chain0.chain) in tcf_chain0_head_change_cb_del()
818 mutex_unlock(&block->lock); in tcf_chain0_head_change_cb_del()
824 mutex_unlock(&block->lock); in tcf_chain0_head_change_cb_del()
835 static int tcf_block_insert(struct tcf_block *block, struct net *net, in tcf_block_insert() argument
843 err = idr_alloc_u32(&tn->idr, block, &block->index, block->index, in tcf_block_insert()
851 static void tcf_block_remove(struct tcf_block *block, struct net *net) in tcf_block_remove() argument
856 idr_remove(&tn->idr, block->index); in tcf_block_remove()
864 struct tcf_block *block; in tcf_block_create() local
866 block = kzalloc(sizeof(*block), GFP_KERNEL); in tcf_block_create()
867 if (!block) { in tcf_block_create()
868 NL_SET_ERR_MSG(extack, "Memory allocation for block failed"); in tcf_block_create()
871 mutex_init(&block->lock); in tcf_block_create()
872 mutex_init(&block->proto_destroy_lock); in tcf_block_create()
873 init_rwsem(&block->cb_lock); in tcf_block_create()
874 flow_block_init(&block->flow_block); in tcf_block_create()
875 INIT_LIST_HEAD(&block->chain_list); in tcf_block_create()
876 INIT_LIST_HEAD(&block->owner_list); in tcf_block_create()
877 INIT_LIST_HEAD(&block->chain0.filter_chain_list); in tcf_block_create()
879 refcount_set(&block->refcnt, 1); in tcf_block_create()
880 block->net = net; in tcf_block_create()
881 block->index = block_index; in tcf_block_create()
884 if (!tcf_block_shared(block)) in tcf_block_create()
885 block->q = q; in tcf_block_create()
886 return block; in tcf_block_create()
898 struct tcf_block *block; in tcf_block_refcnt_get() local
901 block = tcf_block_lookup(net, block_index); in tcf_block_refcnt_get()
902 if (block && !refcount_inc_not_zero(&block->refcnt)) in tcf_block_refcnt_get()
903 block = NULL; in tcf_block_refcnt_get()
906 return block; in tcf_block_refcnt_get()
910 __tcf_get_next_chain(struct tcf_block *block, struct tcf_chain *chain) in __tcf_get_next_chain() argument
912 mutex_lock(&block->lock); in __tcf_get_next_chain()
914 chain = list_is_last(&chain->list, &block->chain_list) ? in __tcf_get_next_chain()
917 chain = list_first_entry_or_null(&block->chain_list, in __tcf_get_next_chain()
922 chain = list_is_last(&chain->list, &block->chain_list) ? in __tcf_get_next_chain()
927 mutex_unlock(&block->lock); in __tcf_get_next_chain()
933 * block. It properly obtains block->lock and takes reference to chain before
942 tcf_get_next_chain(struct tcf_block *block, struct tcf_chain *chain) in tcf_get_next_chain() argument
944 struct tcf_chain *chain_next = __tcf_get_next_chain(block, chain); in tcf_get_next_chain()
1006 static void tcf_block_flush_all_chains(struct tcf_block *block, bool rtnl_held) in tcf_block_flush_all_chains() argument
1010 /* Last reference to block. At this point chains cannot be added or in tcf_block_flush_all_chains()
1013 for (chain = tcf_get_next_chain(block, NULL); in tcf_block_flush_all_chains()
1015 chain = tcf_get_next_chain(block, chain)) { in tcf_block_flush_all_chains()
1125 struct tcf_block *block; in __tcf_block_find() local
1128 block = tcf_block_refcnt_get(net, block_index); in __tcf_block_find()
1129 if (!block) { in __tcf_block_find()
1130 NL_SET_ERR_MSG(extack, "Block of given index was not found"); in __tcf_block_find()
1136 block = cops->tcf_block(q, cl, extack); in __tcf_block_find()
1137 if (!block) in __tcf_block_find()
1140 if (tcf_block_shared(block)) { in __tcf_block_find()
1141 …NL_SET_ERR_MSG(extack, "This filter block is shared. Please use the block index to manipulate the … in __tcf_block_find()
1145 /* Always take reference to block in order to support execution in __tcf_block_find()
1147 * must release block when it is finished using it. 'if' block in __tcf_block_find()
1148 * of this conditional obtain reference to block by calling in __tcf_block_find()
1151 refcount_inc(&block->refcnt); in __tcf_block_find()
1154 return block; in __tcf_block_find()
1157 static void __tcf_block_put(struct tcf_block *block, struct Qdisc *q, in __tcf_block_put() argument
1160 if (refcount_dec_and_mutex_lock(&block->refcnt, &block->lock)) { in __tcf_block_put()
1161 /* Flushing/putting all chains will cause the block to be in __tcf_block_put()
1163 * is empty, block has to be manually deallocated. After block in __tcf_block_put()
1165 * increment it or add new chains to block. in __tcf_block_put()
1167 bool free_block = list_empty(&block->chain_list); in __tcf_block_put()
1169 mutex_unlock(&block->lock); in __tcf_block_put()
1170 if (tcf_block_shared(block)) in __tcf_block_put()
1171 tcf_block_remove(block, block->net); in __tcf_block_put()
1174 tcf_block_offload_unbind(block, q, ei); in __tcf_block_put()
1177 tcf_block_destroy(block); in __tcf_block_put()
1179 tcf_block_flush_all_chains(block, rtnl_held); in __tcf_block_put()
1181 tcf_block_offload_unbind(block, q, ei); in __tcf_block_put()
1185 static void tcf_block_refcnt_put(struct tcf_block *block, bool rtnl_held) in tcf_block_refcnt_put() argument
1187 __tcf_block_put(block, NULL, NULL, rtnl_held); in tcf_block_refcnt_put()
1190 /* Find tcf block.
1199 struct tcf_block *block; in tcf_block_find() local
1212 block = __tcf_block_find(net, *q, *cl, ifindex, block_index, extack); in tcf_block_find()
1213 if (IS_ERR(block)) { in tcf_block_find()
1214 err = PTR_ERR(block); in tcf_block_find()
1218 return block; in tcf_block_find()
1228 static void tcf_block_release(struct Qdisc *q, struct tcf_block *block, in tcf_block_release() argument
1231 if (!IS_ERR_OR_NULL(block)) in tcf_block_release()
1232 tcf_block_refcnt_put(block, rtnl_held); in tcf_block_release()
1249 tcf_block_owner_netif_keep_dst(struct tcf_block *block, in tcf_block_owner_netif_keep_dst() argument
1253 if (block->keep_dst && in tcf_block_owner_netif_keep_dst()
1259 void tcf_block_netif_keep_dst(struct tcf_block *block) in tcf_block_netif_keep_dst() argument
1263 block->keep_dst = true; in tcf_block_netif_keep_dst()
1264 list_for_each_entry(item, &block->owner_list, list) in tcf_block_netif_keep_dst()
1265 tcf_block_owner_netif_keep_dst(block, item->q, in tcf_block_netif_keep_dst()
1270 static int tcf_block_owner_add(struct tcf_block *block, in tcf_block_owner_add() argument
1281 list_add(&item->list, &block->owner_list); in tcf_block_owner_add()
1285 static void tcf_block_owner_del(struct tcf_block *block, in tcf_block_owner_del() argument
1291 list_for_each_entry(item, &block->owner_list, list) { in tcf_block_owner_del()
1306 struct tcf_block *block = NULL; in tcf_block_get_ext() local
1310 /* block_index not 0 means the shared block is requested */ in tcf_block_get_ext()
1311 block = tcf_block_refcnt_get(net, ei->block_index); in tcf_block_get_ext()
1313 if (!block) { in tcf_block_get_ext()
1314 block = tcf_block_create(net, q, ei->block_index, extack); in tcf_block_get_ext()
1315 if (IS_ERR(block)) in tcf_block_get_ext()
1316 return PTR_ERR(block); in tcf_block_get_ext()
1317 if (tcf_block_shared(block)) { in tcf_block_get_ext()
1318 err = tcf_block_insert(block, net, extack); in tcf_block_get_ext()
1324 err = tcf_block_owner_add(block, q, ei->binder_type); in tcf_block_get_ext()
1328 tcf_block_owner_netif_keep_dst(block, q, ei->binder_type); in tcf_block_get_ext()
1330 err = tcf_chain0_head_change_cb_add(block, ei, extack); in tcf_block_get_ext()
1334 err = tcf_block_offload_bind(block, q, ei, extack); in tcf_block_get_ext()
1338 *p_block = block; in tcf_block_get_ext()
1342 tcf_chain0_head_change_cb_del(block, ei); in tcf_block_get_ext()
1344 tcf_block_owner_del(block, q, ei->binder_type); in tcf_block_get_ext()
1347 tcf_block_refcnt_put(block, true); in tcf_block_get_ext()
1376 void tcf_block_put_ext(struct tcf_block *block, struct Qdisc *q, in tcf_block_put_ext() argument
1379 if (!block) in tcf_block_put_ext()
1381 tcf_chain0_head_change_cb_del(block, ei); in tcf_block_put_ext()
1382 tcf_block_owner_del(block, q, ei->binder_type); in tcf_block_put_ext()
1384 __tcf_block_put(block, q, ei, true); in tcf_block_put_ext()
1388 void tcf_block_put(struct tcf_block *block) in tcf_block_put() argument
1392 if (!block) in tcf_block_put()
1394 tcf_block_put_ext(block, block->q, &ei); in tcf_block_put()
1400 tcf_block_playback_offloads(struct tcf_block *block, flow_setup_cb_t *cb, in tcf_block_playback_offloads() argument
1408 lockdep_assert_held(&block->cb_lock); in tcf_block_playback_offloads()
1410 for (chain = __tcf_get_next_chain(block, NULL); in tcf_block_playback_offloads()
1413 chain = __tcf_get_next_chain(block, chain), in tcf_block_playback_offloads()
1437 tcf_block_playback_offloads(block, cb, cb_priv, false, offload_in_use, in tcf_block_playback_offloads()
1442 static int tcf_block_bind(struct tcf_block *block, in tcf_block_bind() argument
1448 lockdep_assert_held(&block->cb_lock); in tcf_block_bind()
1451 err = tcf_block_playback_offloads(block, block_cb->cb, in tcf_block_bind()
1453 tcf_block_offload_in_use(block), in tcf_block_bind()
1458 block->lockeddevcnt++; in tcf_block_bind()
1462 list_splice(&bo->cb_list, &block->flow_block.cb_list); in tcf_block_bind()
1470 tcf_block_playback_offloads(block, block_cb->cb, in tcf_block_bind()
1472 tcf_block_offload_in_use(block), in tcf_block_bind()
1475 block->lockeddevcnt--; in tcf_block_bind()
1483 static void tcf_block_unbind(struct tcf_block *block, in tcf_block_unbind() argument
1488 lockdep_assert_held(&block->cb_lock); in tcf_block_unbind()
1491 tcf_block_playback_offloads(block, block_cb->cb, in tcf_block_unbind()
1493 tcf_block_offload_in_use(block), in tcf_block_unbind()
1498 block->lockeddevcnt--; in tcf_block_unbind()
1502 static int tcf_block_setup(struct tcf_block *block, in tcf_block_setup() argument
1509 err = tcf_block_bind(block, bo); in tcf_block_setup()
1513 tcf_block_unbind(block, bo); in tcf_block_setup()
1570 tp->chain->block->index, in __tcf_classify()
1582 const struct tcf_block *block, in tcf_classify() argument
1597 if (block) { in tcf_classify()
1603 fchain = tcf_chain_lookup_rcu(block, ext->chain); in tcf_classify()
1791 struct tcf_proto *tp, struct tcf_block *block, in tcf_fill_node() argument
1812 tcm->tcm_block_index = block->index; in tcf_fill_node()
1846 struct tcf_block *block, struct Qdisc *q, in tfilter_notify() argument
1858 if (tcf_fill_node(net, skb, tp, block, q, parent, fh, portid, in tfilter_notify()
1875 struct tcf_block *block, struct Qdisc *q, in tfilter_del_notify() argument
1887 if (tcf_fill_node(net, skb, tp, block, q, parent, fh, portid, in tfilter_del_notify()
1913 struct tcf_block *block, struct Qdisc *q, in tfilter_notify_chain() argument
1921 tfilter_notify(net, oskb, n, tp, block, in tfilter_notify_chain()
1946 struct tcf_block *block; in tc_new_tfilter() local
1973 block = NULL; in tc_new_tfilter()
2002 * block is shared (no qdisc found), qdisc is not unlocked, classifier in tc_new_tfilter()
2016 block = __tcf_block_find(net, q, cl, t->tcm_ifindex, t->tcm_block_index, in tc_new_tfilter()
2018 if (IS_ERR(block)) { in tc_new_tfilter()
2019 err = PTR_ERR(block); in tc_new_tfilter()
2022 block->classid = parent; in tc_new_tfilter()
2030 chain = tcf_chain_get(block, chain_index, true); in tc_new_tfilter()
2125 tfilter_notify(net, skb, n, tp, block, q, parent, fh, in tc_new_tfilter()
2143 tcf_block_release(q, block, rtnl_held); in tc_new_tfilter()
2177 struct tcf_block *block = NULL; in tc_del_tfilter() local
2213 /* Take rtnl mutex if flushing whole chain, block is shared (no qdisc in tc_del_tfilter()
2228 block = __tcf_block_find(net, q, cl, t->tcm_ifindex, t->tcm_block_index, in tc_del_tfilter()
2230 if (IS_ERR(block)) { in tc_del_tfilter()
2231 err = PTR_ERR(block); in tc_del_tfilter()
2241 chain = tcf_chain_get(block, chain_index, false); in tc_del_tfilter()
2256 tfilter_notify_chain(net, skb, block, q, parent, n, in tc_del_tfilter()
2280 tfilter_notify(net, skb, n, tp, block, q, parent, fh, in tc_del_tfilter()
2295 err = tfilter_del_notify(net, skb, n, tp, block, in tc_del_tfilter()
2311 tcf_block_release(q, block, rtnl_held); in tc_del_tfilter()
2337 struct tcf_block *block = NULL; in tc_get_tfilter() local
2370 /* Take rtnl mutex if block is shared (no qdisc found), qdisc is not in tc_get_tfilter()
2384 block = __tcf_block_find(net, q, cl, t->tcm_ifindex, t->tcm_block_index, in tc_get_tfilter()
2386 if (IS_ERR(block)) { in tc_get_tfilter()
2387 err = PTR_ERR(block); in tc_get_tfilter()
2397 chain = tcf_chain_get(block, chain_index, false); in tc_get_tfilter()
2424 err = tfilter_notify(net, skb, n, tp, block, q, parent, in tc_get_tfilter()
2437 tcf_block_release(q, block, rtnl_held); in tc_get_tfilter()
2449 struct tcf_block *block; member
2460 return tcf_fill_node(net, a->skb, tp, a->block, a->q, a->parent, in tcf_node_dump()
2471 struct tcf_block *block = chain->block; in tcf_chain_dump() local
2494 if (tcf_fill_node(net, skb, tp, block, q, parent, NULL, in tcf_chain_dump()
2506 arg.block = block; in tcf_chain_dump()
2538 struct tcf_block *block; in tc_dump_tfilter() local
2562 block = tcf_block_refcnt_get(net, tcm->tcm_block_index); in tc_dump_tfilter()
2563 if (!block) in tc_dump_tfilter()
2565 /* If we work with block index, q is NULL and parent value in tc_dump_tfilter()
2598 block = cops->tcf_block(q, cl, NULL); in tc_dump_tfilter()
2599 if (!block) in tc_dump_tfilter()
2601 parent = block->classid; in tc_dump_tfilter()
2602 if (tcf_block_shared(block)) in tc_dump_tfilter()
2609 for (chain = __tcf_get_next_chain(block, NULL); in tc_dump_tfilter()
2612 chain = __tcf_get_next_chain(block, chain), in tc_dump_tfilter()
2626 tcf_block_refcnt_put(block, true); in tc_dump_tfilter()
2639 struct tcf_block *block, in tc_chain_fill_node() argument
2659 if (block->q) { in tc_chain_fill_node()
2660 tcm->tcm_ifindex = qdisc_dev(block->q)->ifindex; in tc_chain_fill_node()
2661 tcm->tcm_parent = block->q->handle; in tc_chain_fill_node()
2664 tcm->tcm_block_index = block->index; in tc_chain_fill_node()
2690 struct tcf_block *block = chain->block; in tc_chain_notify() local
2691 struct net *net = block->net; in tc_chain_notify()
2700 chain->index, net, skb, block, portid, in tc_chain_notify()
2717 struct tcf_block *block, struct sk_buff *oskb, in tc_chain_notify_delete() argument
2721 struct net *net = block->net; in tc_chain_notify_delete()
2729 block, portid, seq, flags, RTM_DELCHAIN) <= 0) { in tc_chain_notify_delete()
2798 struct tcf_block *block; in tc_ctl_chain() local
2816 block = tcf_block_find(net, &q, &parent, &cl, in tc_ctl_chain()
2818 if (IS_ERR(block)) in tc_ctl_chain()
2819 return PTR_ERR(block); in tc_ctl_chain()
2828 mutex_lock(&block->lock); in tc_ctl_chain()
2829 chain = tcf_chain_lookup(block, chain_index); in tc_ctl_chain()
2848 chain = tcf_chain_create(block, chain_index); in tc_ctl_chain()
2865 /* Modifying chain requires holding parent block lock. In case in tc_ctl_chain()
2873 mutex_unlock(&block->lock); in tc_ctl_chain()
2887 tfilter_notify_chain(net, skb, block, q, parent, n, in tc_ctl_chain()
2911 tcf_block_release(q, block, true); in tc_ctl_chain()
2918 mutex_unlock(&block->lock); in tc_ctl_chain()
2928 struct tcf_block *block; in tc_dump_chain() local
2944 block = tcf_block_refcnt_get(net, tcm->tcm_block_index); in tc_dump_chain()
2945 if (!block) in tc_dump_chain()
2973 block = cops->tcf_block(q, cl, NULL); in tc_dump_chain()
2974 if (!block) in tc_dump_chain()
2976 if (tcf_block_shared(block)) in tc_dump_chain()
2983 mutex_lock(&block->lock); in tc_dump_chain()
2984 list_for_each_entry(chain, &block->chain_list, list) { in tc_dump_chain()
2995 chain->index, net, skb, block, in tc_dump_chain()
3003 mutex_unlock(&block->lock); in tc_dump_chain()
3006 tcf_block_refcnt_put(block, true); in tc_dump_chain()
3181 static void tcf_block_offload_inc(struct tcf_block *block, u32 *flags) in tcf_block_offload_inc() argument
3186 atomic_inc(&block->offloadcnt); in tcf_block_offload_inc()
3189 static void tcf_block_offload_dec(struct tcf_block *block, u32 *flags) in tcf_block_offload_dec() argument
3194 atomic_dec(&block->offloadcnt); in tcf_block_offload_dec()
3197 static void tc_cls_offload_cnt_update(struct tcf_block *block, in tc_cls_offload_cnt_update() argument
3201 lockdep_assert_held(&block->cb_lock); in tc_cls_offload_cnt_update()
3206 tcf_block_offload_inc(block, flags); in tc_cls_offload_cnt_update()
3211 tcf_block_offload_dec(block, flags); in tc_cls_offload_cnt_update()
3217 tc_cls_offload_cnt_reset(struct tcf_block *block, struct tcf_proto *tp, in tc_cls_offload_cnt_reset() argument
3220 lockdep_assert_held(&block->cb_lock); in tc_cls_offload_cnt_reset()
3223 tcf_block_offload_dec(block, flags); in tc_cls_offload_cnt_reset()
3229 __tc_setup_cb_call(struct tcf_block *block, enum tc_setup_type type, in __tc_setup_cb_call() argument
3236 list_for_each_entry(block_cb, &block->flow_block.cb_list, list) { in __tc_setup_cb_call()
3248 int tc_setup_cb_call(struct tcf_block *block, enum tc_setup_type type, in tc_setup_cb_call() argument
3251 bool take_rtnl = READ_ONCE(block->lockeddevcnt) && !rtnl_held; in tc_setup_cb_call()
3257 down_read(&block->cb_lock); in tc_setup_cb_call()
3258 /* Need to obtain rtnl lock if block is bound to devs that require it. in tc_setup_cb_call()
3259 * In block bind code cb_lock is obtained while holding rtnl, so we must in tc_setup_cb_call()
3262 if (!rtnl_held && !take_rtnl && block->lockeddevcnt) { in tc_setup_cb_call()
3263 up_read(&block->cb_lock); in tc_setup_cb_call()
3268 ok_count = __tc_setup_cb_call(block, type, type_data, err_stop); in tc_setup_cb_call()
3270 up_read(&block->cb_lock); in tc_setup_cb_call()
3278 * successfully offloaded, increment block offloads counter. On failure,
3283 int tc_setup_cb_add(struct tcf_block *block, struct tcf_proto *tp, in tc_setup_cb_add() argument
3287 bool take_rtnl = READ_ONCE(block->lockeddevcnt) && !rtnl_held; in tc_setup_cb_add()
3293 down_read(&block->cb_lock); in tc_setup_cb_add()
3294 /* Need to obtain rtnl lock if block is bound to devs that require it. in tc_setup_cb_add()
3295 * In block bind code cb_lock is obtained while holding rtnl, so we must in tc_setup_cb_add()
3298 if (!rtnl_held && !take_rtnl && block->lockeddevcnt) { in tc_setup_cb_add()
3299 up_read(&block->cb_lock); in tc_setup_cb_add()
3304 /* Make sure all netdevs sharing this block are offload-capable. */ in tc_setup_cb_add()
3305 if (block->nooffloaddevcnt && err_stop) { in tc_setup_cb_add()
3310 ok_count = __tc_setup_cb_call(block, type, type_data, err_stop); in tc_setup_cb_add()
3317 tc_cls_offload_cnt_update(block, tp, in_hw_count, flags, in tc_setup_cb_add()
3320 up_read(&block->cb_lock); in tc_setup_cb_add()
3328 * successfully offloaded, increment block offload counter. On failure,
3333 int tc_setup_cb_replace(struct tcf_block *block, struct tcf_proto *tp, in tc_setup_cb_replace() argument
3339 bool take_rtnl = READ_ONCE(block->lockeddevcnt) && !rtnl_held; in tc_setup_cb_replace()
3345 down_read(&block->cb_lock); in tc_setup_cb_replace()
3346 /* Need to obtain rtnl lock if block is bound to devs that require it. in tc_setup_cb_replace()
3347 * In block bind code cb_lock is obtained while holding rtnl, so we must in tc_setup_cb_replace()
3350 if (!rtnl_held && !take_rtnl && block->lockeddevcnt) { in tc_setup_cb_replace()
3351 up_read(&block->cb_lock); in tc_setup_cb_replace()
3356 /* Make sure all netdevs sharing this block are offload-capable. */ in tc_setup_cb_replace()
3357 if (block->nooffloaddevcnt && err_stop) { in tc_setup_cb_replace()
3362 tc_cls_offload_cnt_reset(block, tp, old_in_hw_count, old_flags); in tc_setup_cb_replace()
3366 ok_count = __tc_setup_cb_call(block, type, type_data, err_stop); in tc_setup_cb_replace()
3373 tc_cls_offload_cnt_update(block, tp, new_in_hw_count, in tc_setup_cb_replace()
3376 up_read(&block->cb_lock); in tc_setup_cb_replace()
3383 /* Destroy filter and decrement block offload counter, if filter was previously
3387 int tc_setup_cb_destroy(struct tcf_block *block, struct tcf_proto *tp, in tc_setup_cb_destroy() argument
3391 bool take_rtnl = READ_ONCE(block->lockeddevcnt) && !rtnl_held; in tc_setup_cb_destroy()
3397 down_read(&block->cb_lock); in tc_setup_cb_destroy()
3398 /* Need to obtain rtnl lock if block is bound to devs that require it. in tc_setup_cb_destroy()
3399 * In block bind code cb_lock is obtained while holding rtnl, so we must in tc_setup_cb_destroy()
3402 if (!rtnl_held && !take_rtnl && block->lockeddevcnt) { in tc_setup_cb_destroy()
3403 up_read(&block->cb_lock); in tc_setup_cb_destroy()
3408 ok_count = __tc_setup_cb_call(block, type, type_data, err_stop); in tc_setup_cb_destroy()
3410 tc_cls_offload_cnt_reset(block, tp, in_hw_count, flags); in tc_setup_cb_destroy()
3414 up_read(&block->cb_lock); in tc_setup_cb_destroy()
3421 int tc_setup_cb_reoffload(struct tcf_block *block, struct tcf_proto *tp, in tc_setup_cb_reoffload() argument
3432 tc_cls_offload_cnt_update(block, tp, in_hw_count, flags, 1, in tc_setup_cb_reoffload()
3753 NL_SET_ERR_MSG(extack, "Block number may not be zero"); in tcf_qevent_parse_block_index()
3783 return tcf_block_get_ext(&qe->block, sch, &qe->info, extack); in tcf_qevent_init()
3790 tcf_block_put_ext(qe->block, sch, &qe->info); in tcf_qevent_destroy()
3807 /* Bounce newly-configured block or change in block. */ in tcf_qevent_validate_change()