net: ethernet: am65-cpsw: Build am65-cpsw-qos only if required
authorRoger Quadros <rogerq@kernel.org>
Tue, 19 Dec 2023 10:57:58 +0000 (12:57 +0200)
committerDavid S. Miller <davem@davemloft.net>
Sat, 23 Dec 2023 01:01:19 +0000 (01:01 +0000)
Build am65-cpsw-qos only if CONFIG_TI_AM65_CPSW_TAS is enabled.

Signed-off-by: Roger Quadros <rogerq@kernel.org>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/ti/Makefile
drivers/net/ethernet/ti/am65-cpsw-qos.c
drivers/net/ethernet/ti/am65-cpsw-qos.h

index 27de1d6971344367b2a9f29c1f227be413ca1567..9d7cd84d1e2d0f5bf6d429b931d699dcf54f2bd0 100644 (file)
@@ -26,7 +26,8 @@ keystone_netcp_ethss-y := netcp_ethss.o netcp_sgmii.o netcp_xgbepcsr.o cpsw_ale.
 obj-$(CONFIG_TI_K3_CPPI_DESC_POOL) += k3-cppi-desc-pool.o
 
 obj-$(CONFIG_TI_K3_AM65_CPSW_NUSS) += ti-am65-cpsw-nuss.o
-ti-am65-cpsw-nuss-y := am65-cpsw-nuss.o cpsw_sl.o am65-cpsw-ethtool.o cpsw_ale.o am65-cpsw-qos.o
+ti-am65-cpsw-nuss-y := am65-cpsw-nuss.o cpsw_sl.o am65-cpsw-ethtool.o cpsw_ale.o
+ti-am65-cpsw-nuss-$(CONFIG_TI_AM65_CPSW_TAS) += am65-cpsw-qos.o
 ti-am65-cpsw-nuss-$(CONFIG_TI_K3_AM65_CPSW_SWITCHDEV) += am65-cpsw-switchdev.o
 obj-$(CONFIG_TI_K3_AM65_CPTS) += am65-cpts.o
 
index 9ac2ff05d50171b279b6314f00bcbe3f177ed189..4bc611cc4aadb0a3dc40a42f85eeac1883faf401 100644 (file)
@@ -571,9 +571,6 @@ static int am65_cpsw_setup_taprio(struct net_device *ndev, void *type_data)
            taprio->cmd != TAPRIO_CMD_DESTROY)
                return -EOPNOTSUPP;
 
-       if (!IS_ENABLED(CONFIG_TI_AM65_CPSW_TAS))
-               return -ENODEV;
-
        if (!netif_running(ndev)) {
                dev_err(&ndev->dev, "interface is down, link speed unknown\n");
                return -ENETDOWN;
@@ -599,9 +596,6 @@ static int am65_cpsw_tc_query_caps(struct net_device *ndev, void *type_data)
        case TC_SETUP_QDISC_TAPRIO: {
                struct tc_taprio_caps *caps = base->caps;
 
-               if (!IS_ENABLED(CONFIG_TI_AM65_CPSW_TAS))
-                       return -EOPNOTSUPP;
-
                caps->gate_mask_per_txq = true;
 
                return 0;
@@ -806,9 +800,6 @@ void am65_cpsw_qos_link_up(struct net_device *ndev, int link_speed)
 {
        struct am65_cpsw_port *port = am65_ndev_to_port(ndev);
 
-       if (!IS_ENABLED(CONFIG_TI_AM65_CPSW_TAS))
-               return;
-
        am65_cpsw_est_link_up(ndev, link_speed);
        port->qos.link_down_time = 0;
 }
@@ -817,9 +808,6 @@ void am65_cpsw_qos_link_down(struct net_device *ndev)
 {
        struct am65_cpsw_port *port = am65_ndev_to_port(ndev);
 
-       if (!IS_ENABLED(CONFIG_TI_AM65_CPSW_TAS))
-               return;
-
        if (!port->qos.link_down_time)
                port->qos.link_down_time = ktime_get();
 
index 0cc2a3b3d7f9e3a28fe6fdb51512470d43971299..898f13a4a112ef329c82835d9c9706fa9d47e55e 100644 (file)
@@ -31,11 +31,37 @@ struct am65_cpsw_qos {
        struct am65_cpsw_ale_ratelimit ale_mc_ratelimit;
 };
 
+#if IS_ENABLED(CONFIG_TI_AM65_CPSW_TAS)
 int am65_cpsw_qos_ndo_setup_tc(struct net_device *ndev, enum tc_setup_type type,
                               void *type_data);
 void am65_cpsw_qos_link_up(struct net_device *ndev, int link_speed);
 void am65_cpsw_qos_link_down(struct net_device *ndev);
 int am65_cpsw_qos_ndo_tx_p0_set_maxrate(struct net_device *ndev, int queue, u32 rate_mbps);
 void am65_cpsw_qos_tx_p0_rate_init(struct am65_cpsw_common *common);
+#else
+static inline int am65_cpsw_qos_ndo_setup_tc(struct net_device *ndev,
+                                            enum tc_setup_type type,
+                                            void *type_data)
+{
+       return -EOPNOTSUPP;
+}
+
+static inline void am65_cpsw_qos_link_up(struct net_device *ndev,
+                                        int link_speed)
+{ }
+
+static inline void am65_cpsw_qos_link_down(struct net_device *ndev)
+{ }
+
+static inline int am65_cpsw_qos_ndo_tx_p0_set_maxrate(struct net_device *ndev,
+                                                     int queue,
+                                                     u32 rate_mbps)
+{
+       return 0;
+}
+
+static inline void am65_cpsw_qos_tx_p0_rate_init(struct am65_cpsw_common *common)
+{ }
+#endif
 
 #endif /* AM65_CPSW_QOS_H_ */