diff options
author | Oz Shlomo <ozsh@mellanox.com> | 2018-11-06 02:58:37 -0500 |
---|---|---|
committer | Saeed Mahameed <saeedm@mellanox.com> | 2018-12-10 18:54:34 -0500 |
commit | 69bd48404f251b9c45a15799fdcfc87a7ad6ab8a (patch) | |
tree | 372527b855938f2336d8f03c4e9c3b3bc350694f | |
parent | df2ef3bff193229973830fd3fd8acf29fa92715e (diff) |
net/sched: Remove egdev mechanism
The egdev mechanism was replaced by the TC indirect block notifications
platform.
Signed-off-by: Oz Shlomo <ozsh@mellanox.com>
Reviewed-by: Eli Britstein <elibr@mellanox.com>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Cc: John Hurley <john.hurley@netronome.com>
Cc: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
-rw-r--r-- | include/net/act_api.h | 30 | ||||
-rw-r--r-- | net/sched/act_api.c | 221 | ||||
-rw-r--r-- | net/sched/cls_api.c | 47 |
3 files changed, 1 insertions, 297 deletions
diff --git a/include/net/act_api.h b/include/net/act_api.h index 05c7df41d737..dbc795ec659e 100644 --- a/include/net/act_api.h +++ b/include/net/act_api.h | |||
@@ -194,35 +194,5 @@ static inline void tcf_action_stats_update(struct tc_action *a, u64 bytes, | |||
194 | #endif | 194 | #endif |
195 | } | 195 | } |
196 | 196 | ||
197 | #ifdef CONFIG_NET_CLS_ACT | ||
198 | int tc_setup_cb_egdev_register(const struct net_device *dev, | ||
199 | tc_setup_cb_t *cb, void *cb_priv); | ||
200 | void tc_setup_cb_egdev_unregister(const struct net_device *dev, | ||
201 | tc_setup_cb_t *cb, void *cb_priv); | ||
202 | int tc_setup_cb_egdev_call(const struct net_device *dev, | ||
203 | enum tc_setup_type type, void *type_data, | ||
204 | bool err_stop); | ||
205 | #else | ||
206 | static inline | ||
207 | int tc_setup_cb_egdev_register(const struct net_device *dev, | ||
208 | tc_setup_cb_t *cb, void *cb_priv) | ||
209 | { | ||
210 | return 0; | ||
211 | } | ||
212 | |||
213 | static inline | ||
214 | void tc_setup_cb_egdev_unregister(const struct net_device *dev, | ||
215 | tc_setup_cb_t *cb, void *cb_priv) | ||
216 | { | ||
217 | } | ||
218 | |||
219 | static inline | ||
220 | int tc_setup_cb_egdev_call(const struct net_device *dev, | ||
221 | enum tc_setup_type type, void *type_data, | ||
222 | bool err_stop) | ||
223 | { | ||
224 | return 0; | ||
225 | } | ||
226 | #endif | ||
227 | 197 | ||
228 | #endif | 198 | #endif |
diff --git a/net/sched/act_api.c b/net/sched/act_api.c index 9c1b0729aebf..d4b8355737d8 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c | |||
@@ -21,8 +21,6 @@ | |||
21 | #include <linux/kmod.h> | 21 | #include <linux/kmod.h> |
22 | #include <linux/err.h> | 22 | #include <linux/err.h> |
23 | #include <linux/module.h> | 23 | #include <linux/module.h> |
24 | #include <linux/rhashtable.h> | ||
25 | #include <linux/list.h> | ||
26 | #include <net/net_namespace.h> | 24 | #include <net/net_namespace.h> |
27 | #include <net/sock.h> | 25 | #include <net/sock.h> |
28 | #include <net/sch_generic.h> | 26 | #include <net/sch_generic.h> |
@@ -1522,227 +1520,8 @@ out_module_put: | |||
1522 | return skb->len; | 1520 | return skb->len; |
1523 | } | 1521 | } |
1524 | 1522 | ||
1525 | struct tcf_action_net { | ||
1526 | struct rhashtable egdev_ht; | ||
1527 | }; | ||
1528 | |||
1529 | static unsigned int tcf_action_net_id; | ||
1530 | |||
1531 | struct tcf_action_egdev_cb { | ||
1532 | struct list_head list; | ||
1533 | tc_setup_cb_t *cb; | ||
1534 | void *cb_priv; | ||
1535 | }; | ||
1536 | |||
1537 | struct tcf_action_egdev { | ||
1538 | struct rhash_head ht_node; | ||
1539 | const struct net_device *dev; | ||
1540 | unsigned int refcnt; | ||
1541 | struct list_head cb_list; | ||
1542 | }; | ||
1543 | |||
1544 | static const struct rhashtable_params tcf_action_egdev_ht_params = { | ||
1545 | .key_offset = offsetof(struct tcf_action_egdev, dev), | ||
1546 | .head_offset = offsetof(struct tcf_action_egdev, ht_node), | ||
1547 | .key_len = sizeof(const struct net_device *), | ||
1548 | }; | ||
1549 | |||
1550 | static struct tcf_action_egdev * | ||
1551 | tcf_action_egdev_lookup(const struct net_device *dev) | ||
1552 | { | ||
1553 | struct net *net = dev_net(dev); | ||
1554 | struct tcf_action_net *tan = net_generic(net, tcf_action_net_id); | ||
1555 | |||
1556 | return rhashtable_lookup_fast(&tan->egdev_ht, &dev, | ||
1557 | tcf_action_egdev_ht_params); | ||
1558 | } | ||
1559 | |||
1560 | static struct tcf_action_egdev * | ||
1561 | tcf_action_egdev_get(const struct net_device *dev) | ||
1562 | { | ||
1563 | struct tcf_action_egdev *egdev; | ||
1564 | struct tcf_action_net *tan; | ||
1565 | |||
1566 | egdev = tcf_action_egdev_lookup(dev); | ||
1567 | if (egdev) | ||
1568 | goto inc_ref; | ||
1569 | |||
1570 | egdev = kzalloc(sizeof(*egdev), GFP_KERNEL); | ||
1571 | if (!egdev) | ||
1572 | return NULL; | ||
1573 | INIT_LIST_HEAD(&egdev->cb_list); | ||
1574 | egdev->dev = dev; | ||
1575 | tan = net_generic(dev_net(dev), tcf_action_net_id); | ||
1576 | rhashtable_insert_fast(&tan->egdev_ht, &egdev->ht_node, | ||
1577 | tcf_action_egdev_ht_params); | ||
1578 | |||
1579 | inc_ref: | ||
1580 | egdev->refcnt++; | ||
1581 | return egdev; | ||
1582 | } | ||
1583 | |||
1584 | static void tcf_action_egdev_put(struct tcf_action_egdev *egdev) | ||
1585 | { | ||
1586 | struct tcf_action_net *tan; | ||
1587 | |||
1588 | if (--egdev->refcnt) | ||
1589 | return; | ||
1590 | tan = net_generic(dev_net(egdev->dev), tcf_action_net_id); | ||
1591 | rhashtable_remove_fast(&tan->egdev_ht, &egdev->ht_node, | ||
1592 | tcf_action_egdev_ht_params); | ||
1593 | kfree(egdev); | ||
1594 | } | ||
1595 | |||
1596 | static struct tcf_action_egdev_cb * | ||
1597 | tcf_action_egdev_cb_lookup(struct tcf_action_egdev *egdev, | ||
1598 | tc_setup_cb_t *cb, void *cb_priv) | ||
1599 | { | ||
1600 | struct tcf_action_egdev_cb *egdev_cb; | ||
1601 | |||
1602 | list_for_each_entry(egdev_cb, &egdev->cb_list, list) | ||
1603 | if (egdev_cb->cb == cb && egdev_cb->cb_priv == cb_priv) | ||
1604 | return egdev_cb; | ||
1605 | return NULL; | ||
1606 | } | ||
1607 | |||
1608 | static int tcf_action_egdev_cb_call(struct tcf_action_egdev *egdev, | ||
1609 | enum tc_setup_type type, | ||
1610 | void *type_data, bool err_stop) | ||
1611 | { | ||
1612 | struct tcf_action_egdev_cb *egdev_cb; | ||
1613 | int ok_count = 0; | ||
1614 | int err; | ||
1615 | |||
1616 | list_for_each_entry(egdev_cb, &egdev->cb_list, list) { | ||
1617 | err = egdev_cb->cb(type, type_data, egdev_cb->cb_priv); | ||
1618 | if (err) { | ||
1619 | if (err_stop) | ||
1620 | return err; | ||
1621 | } else { | ||
1622 | ok_count++; | ||
1623 | } | ||
1624 | } | ||
1625 | return ok_count; | ||
1626 | } | ||
1627 | |||
1628 | static int tcf_action_egdev_cb_add(struct tcf_action_egdev *egdev, | ||
1629 | tc_setup_cb_t *cb, void *cb_priv) | ||
1630 | { | ||
1631 | struct tcf_action_egdev_cb *egdev_cb; | ||
1632 | |||
1633 | egdev_cb = tcf_action_egdev_cb_lookup(egdev, cb, cb_priv); | ||
1634 | if (WARN_ON(egdev_cb)) | ||
1635 | return -EEXIST; | ||
1636 | egdev_cb = kzalloc(sizeof(*egdev_cb), GFP_KERNEL); | ||
1637 | if (!egdev_cb) | ||
1638 | return -ENOMEM; | ||
1639 | egdev_cb->cb = cb; | ||
1640 | egdev_cb->cb_priv = cb_priv; | ||
1641 | list_add(&egdev_cb->list, &egdev->cb_list); | ||
1642 | return 0; | ||
1643 | } | ||
1644 | |||
1645 | static void tcf_action_egdev_cb_del(struct tcf_action_egdev *egdev, | ||
1646 | tc_setup_cb_t *cb, void *cb_priv) | ||
1647 | { | ||
1648 | struct tcf_action_egdev_cb *egdev_cb; | ||
1649 | |||
1650 | egdev_cb = tcf_action_egdev_cb_lookup(egdev, cb, cb_priv); | ||
1651 | if (WARN_ON(!egdev_cb)) | ||
1652 | return; | ||
1653 | list_del(&egdev_cb->list); | ||
1654 | kfree(egdev_cb); | ||
1655 | } | ||
1656 | |||
1657 | static int __tc_setup_cb_egdev_register(const struct net_device *dev, | ||
1658 | tc_setup_cb_t *cb, void *cb_priv) | ||
1659 | { | ||
1660 | struct tcf_action_egdev *egdev = tcf_action_egdev_get(dev); | ||
1661 | int err; | ||
1662 | |||
1663 | if (!egdev) | ||
1664 | return -ENOMEM; | ||
1665 | err = tcf_action_egdev_cb_add(egdev, cb, cb_priv); | ||
1666 | if (err) | ||
1667 | goto err_cb_add; | ||
1668 | return 0; | ||
1669 | |||
1670 | err_cb_add: | ||
1671 | tcf_action_egdev_put(egdev); | ||
1672 | return err; | ||
1673 | } | ||
1674 | int tc_setup_cb_egdev_register(const struct net_device *dev, | ||
1675 | tc_setup_cb_t *cb, void *cb_priv) | ||
1676 | { | ||
1677 | int err; | ||
1678 | |||
1679 | rtnl_lock(); | ||
1680 | err = __tc_setup_cb_egdev_register(dev, cb, cb_priv); | ||
1681 | rtnl_unlock(); | ||
1682 | return err; | ||
1683 | } | ||
1684 | EXPORT_SYMBOL_GPL(tc_setup_cb_egdev_register); | ||
1685 | |||
1686 | static void __tc_setup_cb_egdev_unregister(const struct net_device *dev, | ||
1687 | tc_setup_cb_t *cb, void *cb_priv) | ||
1688 | { | ||
1689 | struct tcf_action_egdev *egdev = tcf_action_egdev_lookup(dev); | ||
1690 | |||
1691 | if (WARN_ON(!egdev)) | ||
1692 | return; | ||
1693 | tcf_action_egdev_cb_del(egdev, cb, cb_priv); | ||
1694 | tcf_action_egdev_put(egdev); | ||
1695 | } | ||
1696 | void tc_setup_cb_egdev_unregister(const struct net_device *dev, | ||
1697 | tc_setup_cb_t *cb, void *cb_priv) | ||
1698 | { | ||
1699 | rtnl_lock(); | ||
1700 | __tc_setup_cb_egdev_unregister(dev, cb, cb_priv); | ||
1701 | rtnl_unlock(); | ||
1702 | } | ||
1703 | EXPORT_SYMBOL_GPL(tc_setup_cb_egdev_unregister); | ||
1704 | |||
1705 | int tc_setup_cb_egdev_call(const struct net_device *dev, | ||
1706 | enum tc_setup_type type, void *type_data, | ||
1707 | bool err_stop) | ||
1708 | { | ||
1709 | struct tcf_action_egdev *egdev = tcf_action_egdev_lookup(dev); | ||
1710 | |||
1711 | if (!egdev) | ||
1712 | return 0; | ||
1713 | return tcf_action_egdev_cb_call(egdev, type, type_data, err_stop); | ||
1714 | } | ||
1715 | EXPORT_SYMBOL_GPL(tc_setup_cb_egdev_call); | ||
1716 | |||
1717 | static __net_init int tcf_action_net_init(struct net *net) | ||
1718 | { | ||
1719 | struct tcf_action_net *tan = net_generic(net, tcf_action_net_id); | ||
1720 | |||
1721 | return rhashtable_init(&tan->egdev_ht, &tcf_action_egdev_ht_params); | ||
1722 | } | ||
1723 | |||
1724 | static void __net_exit tcf_action_net_exit(struct net *net) | ||
1725 | { | ||
1726 | struct tcf_action_net *tan = net_generic(net, tcf_action_net_id); | ||
1727 | |||
1728 | rhashtable_destroy(&tan->egdev_ht); | ||
1729 | } | ||
1730 | |||
1731 | static struct pernet_operations tcf_action_net_ops = { | ||
1732 | .init = tcf_action_net_init, | ||
1733 | .exit = tcf_action_net_exit, | ||
1734 | .id = &tcf_action_net_id, | ||
1735 | .size = sizeof(struct tcf_action_net), | ||
1736 | }; | ||
1737 | |||
1738 | static int __init tc_action_init(void) | 1523 | static int __init tc_action_init(void) |
1739 | { | 1524 | { |
1740 | int err; | ||
1741 | |||
1742 | err = register_pernet_subsys(&tcf_action_net_ops); | ||
1743 | if (err) | ||
1744 | return err; | ||
1745 | |||
1746 | rtnl_register(PF_UNSPEC, RTM_NEWACTION, tc_ctl_action, NULL, 0); | 1525 | rtnl_register(PF_UNSPEC, RTM_NEWACTION, tc_ctl_action, NULL, 0); |
1747 | rtnl_register(PF_UNSPEC, RTM_DELACTION, tc_ctl_action, NULL, 0); | 1526 | rtnl_register(PF_UNSPEC, RTM_DELACTION, tc_ctl_action, NULL, 0); |
1748 | rtnl_register(PF_UNSPEC, RTM_GETACTION, tc_ctl_action, tc_dump_action, | 1527 | rtnl_register(PF_UNSPEC, RTM_GETACTION, tc_ctl_action, tc_dump_action, |
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index d92f44ac4c39..6207f265b87c 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c | |||
@@ -2515,55 +2515,10 @@ int tcf_exts_dump_stats(struct sk_buff *skb, struct tcf_exts *exts) | |||
2515 | } | 2515 | } |
2516 | EXPORT_SYMBOL(tcf_exts_dump_stats); | 2516 | EXPORT_SYMBOL(tcf_exts_dump_stats); |
2517 | 2517 | ||
2518 | static int tc_exts_setup_cb_egdev_call(struct tcf_exts *exts, | ||
2519 | enum tc_setup_type type, | ||
2520 | void *type_data, bool err_stop) | ||
2521 | { | ||
2522 | int ok_count = 0; | ||
2523 | #ifdef CONFIG_NET_CLS_ACT | ||
2524 | const struct tc_action *a; | ||
2525 | struct net_device *dev; | ||
2526 | int i, ret; | ||
2527 | |||
2528 | if (!tcf_exts_has_actions(exts)) | ||
2529 | return 0; | ||
2530 | |||
2531 | for (i = 0; i < exts->nr_actions; i++) { | ||
2532 | a = exts->actions[i]; | ||
2533 | if (!a->ops->get_dev) | ||
2534 | continue; | ||
2535 | dev = a->ops->get_dev(a); | ||
2536 | if (!dev) | ||
2537 | continue; | ||
2538 | ret = tc_setup_cb_egdev_call(dev, type, type_data, err_stop); | ||
2539 | a->ops->put_dev(dev); | ||
2540 | if (ret < 0) | ||
2541 | return ret; | ||
2542 | ok_count += ret; | ||
2543 | } | ||
2544 | #endif | ||
2545 | return ok_count; | ||
2546 | } | ||
2547 | |||
2548 | int tc_setup_cb_call(struct tcf_block *block, struct tcf_exts *exts, | 2518 | int tc_setup_cb_call(struct tcf_block *block, struct tcf_exts *exts, |
2549 | enum tc_setup_type type, void *type_data, bool err_stop) | 2519 | enum tc_setup_type type, void *type_data, bool err_stop) |
2550 | { | 2520 | { |
2551 | int ok_count; | 2521 | return tcf_block_cb_call(block, type, type_data, err_stop); |
2552 | int ret; | ||
2553 | |||
2554 | ret = tcf_block_cb_call(block, type, type_data, err_stop); | ||
2555 | if (ret < 0) | ||
2556 | return ret; | ||
2557 | ok_count = ret; | ||
2558 | |||
2559 | if (!exts || ok_count) | ||
2560 | return ok_count; | ||
2561 | ret = tc_exts_setup_cb_egdev_call(exts, type, type_data, err_stop); | ||
2562 | if (ret < 0) | ||
2563 | return ret; | ||
2564 | ok_count += ret; | ||
2565 | |||
2566 | return ok_count; | ||
2567 | } | 2522 | } |
2568 | EXPORT_SYMBOL(tc_setup_cb_call); | 2523 | EXPORT_SYMBOL(tc_setup_cb_call); |
2569 | 2524 | ||