// SPDX-License-Identifier: GPL-2.0 /****************************************************************************** * * Copyright (c) 2020 Intel Corporation * *****************************************************************************/ #include #include #include "pon_qos_tc_main.h" #include "pon_qos_tc_qos.h" #include "pon_qos_tc_debugfs.h" #if IS_ENABLED(CONFIG_QOS_MGR) #include #endif #define DRV_NAME "mod_pon_qos" int pon_qos_setup_tc(struct net_device *dev, u32 handle, __be16 protocol, struct tc_to_netdev *tc, int port_id, int deq_idx) { int ret = 0; ASSERT_RTNL(); netdev_dbg(dev, "%s: start\n", __func__); switch (tc->type) { case TC_SETUP_CLSFLOWER: return pon_qos_tc_flower_offload(dev, handle, tc->cls_flower); case TC_SETUP_MQPRIO: return pon_qos_tc_mqprio_offload(dev, handle, tc, port_id, deq_idx); case TC_SETUP_QDISC_PRIO: return pon_qos_tc_prio_offload(dev, handle, tc, port_id, deq_idx); case TC_SETUP_DRR: return pon_qos_tc_drr_offload(dev, handle, tc, port_id, deq_idx); case TC_SETUP_QDISC_RED: return pon_qos_tc_red_offload(dev, handle, tc); case TC_SETUP_TBF: return pon_qos_tc_tbf_offload(dev, handle, tc); default: netdev_err(dev, "offload type:%d not supported\n", tc->type); ret = -EOPNOTSUPP; break; } return ret; } EXPORT_SYMBOL(pon_qos_setup_tc); int pon_qos_setup_tc_gen(struct net_device *dev, u32 handle, __be16 protocol, struct tc_to_netdev *tc) { int ret; ret = pon_qos_setup_tc(dev, handle, protocol, tc, -1, -1); if (!ret) return ret; /* TODO: this has to be removed when all features are implemented in this * driver */ #if IS_ENABLED(CONFIG_QOS_MGR) if (qos_mgr_hook_setup_tc) return qos_mgr_hook_setup_tc(dev, handle, protocol, tc); #endif return ret; } EXPORT_SYMBOL(pon_qos_setup_tc_gen); static int __init pon_qos_init(void) { int ret = 0; ret = pon_qos_tc_debugfs_init(); if (ret) return ret; rtnl_lock(); pon_qos_setup_tc_fn = pon_qos_setup_tc; ret = pon_qos_tc_mappings_init(); rtnl_unlock(); if (ret) { pon_qos_tc_debugfs_exit(); return ret; } return ret; } static void __exit pon_qos_destroy(void) { pon_qos_tc_debugfs_exit(); rtnl_lock(); pon_qos_ports_cleanup(); pon_qos_setup_tc_fn = NULL; rtnl_unlock(); } module_init(pon_qos_init); module_exit(pon_qos_destroy); MODULE_LICENSE("GPL"); MODULE_ALIAS_RTNL_LINK(DRV_NAME);