From 5357cc04939baaea0f24687860624b472f763bec Mon Sep 17 00:00:00 2001 From: Ratheesh Kannoth Date: Fri, 6 Nov 2020 12:56:12 +0530 Subject: [PATCH 252/281] net: ppp: API to check compression enabled on PPP device Change-Id: I574c688a9299531263061534a51cc88fef5e069f Signed-off-by: Ratheesh Kannoth --- drivers/net/ppp/ppp_generic.c | 22 ++++++++++++++++++++++ include/linux/ppp_channel.h | 2 ++ 2 files changed, 24 insertions(+) diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c index 3230c5cb7483..be55c30b4a6e 100644 --- a/drivers/net/ppp/ppp_generic.c +++ b/drivers/net/ppp/ppp_generic.c @@ -3660,6 +3660,28 @@ void ppp_update_stats(struct net_device *dev, unsigned long rx_packets, ppp_recv_unlock(ppp); } +/* Returns true if Compression is enabled on PPP device + */ +bool ppp_is_cp_enabled(struct net_device *dev) +{ + struct ppp *ppp; + bool flag = false; + + if (!dev) + return false; + + if (dev->type != ARPHRD_PPP) + return false; + + ppp = netdev_priv(dev); + ppp_lock(ppp); + flag = !!ppp->xcomp || !!ppp->rcomp; + ppp_unlock(ppp); + + return flag; +} +EXPORT_SYMBOL(ppp_is_cp_enabled); + /* Returns >0 if the device is a multilink PPP netdevice, 0 if not or < 0 if * the device is not PPP. */ diff --git a/include/linux/ppp_channel.h b/include/linux/ppp_channel.h index 4f32f6f19e6e..1347b8fcd1c7 100644 --- a/include/linux/ppp_channel.h +++ b/include/linux/ppp_channel.h @@ -81,6 +81,8 @@ extern int ppp_hold_channels(struct net_device *dev, struct ppp_channel *channels[], unsigned int chan_sz); +bool ppp_is_cp_enabled(struct net_device *dev); + /* Test if the ppp device is a multi-link ppp device */ extern int ppp_is_multilink(struct net_device *dev); -- 2.17.1