ipq806x: NSS Hardware Offloading NSS qdisc Patches
This commit is contained in:
		| @@ -0,0 +1,28 @@ | |||||||
|  | --- a/include/linux/skbuff.h | ||||||
|  | +++ b/include/linux/skbuff.h | ||||||
|  | @@ -816,6 +816,8 @@ struct sk_buff { | ||||||
|  |  #ifdef CONFIG_NET_CLS_ACT | ||||||
|  |  	__u8			tc_skip_classify:1; | ||||||
|  |  	__u8			tc_at_ingress:1; | ||||||
|  | + | ||||||
|  | +	__u16			tc_verd_qca_nss; /* QCA NSS Qdisc Support */ | ||||||
|  |  #endif | ||||||
|  |  #ifdef CONFIG_NET_REDIRECT | ||||||
|  |  	__u8			redirected:1; | ||||||
|  | --- a/include/uapi/linux/pkt_cls.h | ||||||
|  | +++ b/include/uapi/linux/pkt_cls.h | ||||||
|  | @@ -687,4 +687,14 @@ enum { | ||||||
|  |  	TCF_EM_OPND_LT | ||||||
|  |  }; | ||||||
|  |   | ||||||
|  | +/* QCA NSS Qdisc Support - Start */ | ||||||
|  | +#define _TC_MAKE32(x)		((x)) | ||||||
|  | +#define _TC_MAKEMASK1(n)	(_TC_MAKE32(1) << _TC_MAKE32(n)) | ||||||
|  | + | ||||||
|  | +#define TC_NCLS                 _TC_MAKEMASK1(8) | ||||||
|  | +#define TC_NCLS_NSS		_TC_MAKEMASK1(12) | ||||||
|  | +#define SET_TC_NCLS_NSS(v)	( TC_NCLS_NSS | ((v) & ~TC_NCLS_NSS)) | ||||||
|  | +#define CLR_TC_NCLS_NSS(v)	( (v) & ~TC_NCLS_NSS) | ||||||
|  | +/* QCA NSS Qdisc Support - End */ | ||||||
|  | + | ||||||
|  |  #endif | ||||||
| @@ -0,0 +1,319 @@ | |||||||
|  | --- a/include/net/sch_generic.h | ||||||
|  | +++ b/include/net/sch_generic.h | ||||||
|  | @@ -79,6 +79,7 @@ struct Qdisc { | ||||||
|  |  #define TCQ_F_INVISIBLE		0x80 /* invisible by default in dump */ | ||||||
|  |  #define TCQ_F_NOLOCK		0x100 /* qdisc does not require locking */ | ||||||
|  |  #define TCQ_F_OFFLOADED		0x200 /* qdisc is offloaded to HW */ | ||||||
|  | +#define TCQ_F_NSS		0x1000 /* NSS qdisc flag. */ | ||||||
|  |  	u32			limit; | ||||||
|  |  	const struct Qdisc_ops	*ops; | ||||||
|  |  	struct qdisc_size_table	__rcu *stab; | ||||||
|  | @@ -1295,4 +1296,9 @@ static inline void skb_tc_reinsert(struc | ||||||
|  |  		qstats_overlimit_inc(res->qstats); | ||||||
|  |  } | ||||||
|  |   | ||||||
|  | +/* QCA NSS Qdisc Support - Start */ | ||||||
|  | +void qdisc_destroy(struct Qdisc *qdisc); | ||||||
|  | +void tcf_destroy_chain(struct tcf_proto __rcu **fl); | ||||||
|  | +/* QCA NSS Qdisc Support - End */ | ||||||
|  | + | ||||||
|  |  #endif | ||||||
|  | --- a/include/uapi/linux/pkt_sched.h | ||||||
|  | +++ b/include/uapi/linux/pkt_sched.h | ||||||
|  | @@ -1181,4 +1181,248 @@ enum { | ||||||
|  |   | ||||||
|  |  #define TCA_TAPRIO_ATTR_MAX (__TCA_TAPRIO_ATTR_MAX - 1) | ||||||
|  |   | ||||||
|  | +/* QCA NSS Clients Support - Start */ | ||||||
|  | +enum { | ||||||
|  | +	TCA_NSS_ACCEL_MODE_NSS_FW, | ||||||
|  | +	TCA_NSS_ACCEL_MODE_PPE, | ||||||
|  | +	TCA_NSS_ACCEL_MODE_MAX | ||||||
|  | +}; | ||||||
|  | + | ||||||
|  | +/* NSSFIFO section */ | ||||||
|  | + | ||||||
|  | +enum { | ||||||
|  | +	TCA_NSSFIFO_UNSPEC, | ||||||
|  | +	TCA_NSSFIFO_PARMS, | ||||||
|  | +	__TCA_NSSFIFO_MAX | ||||||
|  | +}; | ||||||
|  | + | ||||||
|  | +#define TCA_NSSFIFO_MAX	(__TCA_NSSFIFO_MAX - 1) | ||||||
|  | + | ||||||
|  | +struct tc_nssfifo_qopt { | ||||||
|  | +	__u32	limit;		/* Queue length: bytes for bfifo, packets for pfifo */ | ||||||
|  | +	__u8	set_default;	/* Sets qdisc to be the default qdisc for enqueue */ | ||||||
|  | +	__u8	accel_mode;	/* Dictates which data plane offloads the qdisc */ | ||||||
|  | +}; | ||||||
|  | + | ||||||
|  | +/* NSSWRED section */ | ||||||
|  | + | ||||||
|  | +enum { | ||||||
|  | +	TCA_NSSWRED_UNSPEC, | ||||||
|  | +	TCA_NSSWRED_PARMS, | ||||||
|  | +	__TCA_NSSWRED_MAX | ||||||
|  | +}; | ||||||
|  | + | ||||||
|  | +#define TCA_NSSWRED_MAX (__TCA_NSSWRED_MAX - 1) | ||||||
|  | +#define NSSWRED_CLASS_MAX 6 | ||||||
|  | +struct tc_red_alg_parameter { | ||||||
|  | +	__u32	min;	/* qlen_avg < min: pkts are all enqueued */ | ||||||
|  | +	__u32	max;	/* qlen_avg > max: pkts are all dropped */ | ||||||
|  | +	__u32	probability;/* Drop probability at qlen_avg = max */ | ||||||
|  | +	__u32	exp_weight_factor;/* exp_weight_factor for calculate qlen_avg */ | ||||||
|  | +}; | ||||||
|  | + | ||||||
|  | +struct tc_nsswred_traffic_class { | ||||||
|  | +	__u32 limit;			/* Queue length */ | ||||||
|  | +	__u32 weight_mode_value;	/* Weight mode value */ | ||||||
|  | +	struct tc_red_alg_parameter rap;/* Parameters for RED alg */ | ||||||
|  | +}; | ||||||
|  | + | ||||||
|  | +/* | ||||||
|  | + * Weight modes for WRED | ||||||
|  | + */ | ||||||
|  | +enum tc_nsswred_weight_modes { | ||||||
|  | +	TC_NSSWRED_WEIGHT_MODE_DSCP = 0,/* Weight mode is DSCP */ | ||||||
|  | +	TC_NSSWRED_WEIGHT_MODES,	/* Must be last */ | ||||||
|  | +}; | ||||||
|  | + | ||||||
|  | +struct tc_nsswred_qopt { | ||||||
|  | +	__u32	limit;			/* Queue length */ | ||||||
|  | +	enum tc_nsswred_weight_modes weight_mode; | ||||||
|  | +					/* Weight mode */ | ||||||
|  | +	__u32	traffic_classes;	/* How many traffic classes: DPs */ | ||||||
|  | +	__u32	def_traffic_class;	/* Default traffic if no match: def_DP */ | ||||||
|  | +	__u32	traffic_id;		/* The traffic id to be configured: DP */ | ||||||
|  | +	__u32	weight_mode_value;	/* Weight mode value */ | ||||||
|  | +	struct tc_red_alg_parameter rap;/* RED algorithm parameters */ | ||||||
|  | +	struct tc_nsswred_traffic_class tntc[NSSWRED_CLASS_MAX]; | ||||||
|  | +					/* Traffic settings for dumpping */ | ||||||
|  | +	__u8	ecn;			/* Setting ECN bit or dropping */ | ||||||
|  | +	__u8	set_default;		/* Sets qdisc to be the default for enqueue */ | ||||||
|  | +	__u8	accel_mode;		/* Dictates which data plane offloads the qdisc */ | ||||||
|  | +}; | ||||||
|  | + | ||||||
|  | +/* NSSCODEL section */ | ||||||
|  | + | ||||||
|  | +enum { | ||||||
|  | +	TCA_NSSCODEL_UNSPEC, | ||||||
|  | +	TCA_NSSCODEL_PARMS, | ||||||
|  | +	__TCA_NSSCODEL_MAX | ||||||
|  | +}; | ||||||
|  | + | ||||||
|  | +#define TCA_NSSCODEL_MAX	(__TCA_NSSCODEL_MAX - 1) | ||||||
|  | + | ||||||
|  | +struct tc_nsscodel_qopt { | ||||||
|  | +	__u32	target;		/* Acceptable queueing delay */ | ||||||
|  | +	__u32	limit;		/* Max number of packets that can be held in the queue */ | ||||||
|  | +	__u32	interval;	/* Monitoring interval */ | ||||||
|  | +	__u32	flows;		/* Number of flow buckets */ | ||||||
|  | +	__u32	quantum;	/* Weight (in bytes) used for DRR of flow buckets */ | ||||||
|  | +	__u8	ecn;		/* 0 - disable ECN, 1 - enable ECN */ | ||||||
|  | +	__u8	set_default;	/* Sets qdisc to be the default qdisc for enqueue */ | ||||||
|  | +	__u8	accel_mode;	/* Dictates which data plane offloads the qdisc */ | ||||||
|  | +}; | ||||||
|  | + | ||||||
|  | +struct tc_nsscodel_xstats { | ||||||
|  | +	__u32 peak_queue_delay;	/* Peak delay experienced by a dequeued packet */ | ||||||
|  | +	__u32 peak_drop_delay;	/* Peak delay experienced by a dropped packet */ | ||||||
|  | +}; | ||||||
|  | + | ||||||
|  | +/* NSSFQ_CODEL section */ | ||||||
|  | + | ||||||
|  | +struct tc_nssfq_codel_xstats { | ||||||
|  | +	__u32 new_flow_count;	/* Total number of new flows seen */ | ||||||
|  | +	__u32 new_flows_len;	/* Current number of new flows */ | ||||||
|  | +	__u32 old_flows_len;	/* Current number of old flows */ | ||||||
|  | +	__u32 ecn_mark;		/* Number of packets marked with ECN */ | ||||||
|  | +	__u32 drop_overlimit;	/* Number of packets dropped due to overlimit */ | ||||||
|  | +	__u32 maxpacket;	/* The largest packet seen so far in the queue */ | ||||||
|  | +}; | ||||||
|  | + | ||||||
|  | +/* NSSTBL section */ | ||||||
|  | + | ||||||
|  | +enum { | ||||||
|  | +	TCA_NSSTBL_UNSPEC, | ||||||
|  | +	TCA_NSSTBL_PARMS, | ||||||
|  | +	__TCA_NSSTBL_MAX | ||||||
|  | +}; | ||||||
|  | + | ||||||
|  | +#define TCA_NSSTBL_MAX	(__TCA_NSSTBL_MAX - 1) | ||||||
|  | + | ||||||
|  | +struct tc_nsstbl_qopt { | ||||||
|  | +	__u32	burst;		/* Maximum burst size */ | ||||||
|  | +	__u32	rate;		/* Limiting rate of TBF */ | ||||||
|  | +	__u32	peakrate;	/* Maximum rate at which TBF is allowed to send */ | ||||||
|  | +	__u32	mtu;		/* Max size of packet, or minumim burst size */ | ||||||
|  | +	__u8	accel_mode;	/* Dictates which data plane offloads the qdisc */ | ||||||
|  | +}; | ||||||
|  | + | ||||||
|  | +/* NSSPRIO section */ | ||||||
|  | + | ||||||
|  | +#define TCA_NSSPRIO_MAX_BANDS 256 | ||||||
|  | + | ||||||
|  | +enum { | ||||||
|  | +	TCA_NSSPRIO_UNSPEC, | ||||||
|  | +	TCA_NSSPRIO_PARMS, | ||||||
|  | +	__TCA_NSSPRIO_MAX | ||||||
|  | +}; | ||||||
|  | + | ||||||
|  | +#define TCA_NSSPRIO_MAX	(__TCA_NSSPRIO_MAX - 1) | ||||||
|  | + | ||||||
|  | +struct tc_nssprio_qopt { | ||||||
|  | +	__u32	bands;		/* Number of bands */ | ||||||
|  | +	__u8	accel_mode;	/* Dictates which data plane offloads the qdisc */ | ||||||
|  | +}; | ||||||
|  | + | ||||||
|  | +/* NSSBF section */ | ||||||
|  | + | ||||||
|  | +enum { | ||||||
|  | +	TCA_NSSBF_UNSPEC, | ||||||
|  | +	TCA_NSSBF_CLASS_PARMS, | ||||||
|  | +	TCA_NSSBF_QDISC_PARMS, | ||||||
|  | +	__TCA_NSSBF_MAX | ||||||
|  | +}; | ||||||
|  | + | ||||||
|  | +#define TCA_NSSBF_MAX	(__TCA_NSSBF_MAX - 1) | ||||||
|  | + | ||||||
|  | +struct tc_nssbf_class_qopt { | ||||||
|  | +	__u32	burst;		/* Maximum burst size */ | ||||||
|  | +	__u32	rate;		/* Allowed bandwidth for this class */ | ||||||
|  | +	__u32	mtu;		/* MTU of the associated interface */ | ||||||
|  | +	__u32	quantum;	/* Quantum allocation for DRR */ | ||||||
|  | +}; | ||||||
|  | + | ||||||
|  | +struct tc_nssbf_qopt { | ||||||
|  | +	__u16	defcls;		/* Default class value */ | ||||||
|  | +	__u8	accel_mode;	/* Dictates which data plane offloads the qdisc */ | ||||||
|  | +}; | ||||||
|  | + | ||||||
|  | +/* NSSWRR section */ | ||||||
|  | + | ||||||
|  | +enum { | ||||||
|  | +	TCA_NSSWRR_UNSPEC, | ||||||
|  | +	TCA_NSSWRR_CLASS_PARMS, | ||||||
|  | +	TCA_NSSWRR_QDISC_PARMS, | ||||||
|  | +	__TCA_NSSWRR_MAX | ||||||
|  | +}; | ||||||
|  | + | ||||||
|  | +#define TCA_NSSWRR_MAX	(__TCA_NSSWRR_MAX - 1) | ||||||
|  | + | ||||||
|  | +struct tc_nsswrr_class_qopt { | ||||||
|  | +	__u32	quantum;	/* Weight associated to this class */ | ||||||
|  | +}; | ||||||
|  | + | ||||||
|  | +struct tc_nsswrr_qopt { | ||||||
|  | +	__u8	accel_mode;	/* Dictates which data plane offloads the qdisc */ | ||||||
|  | +}; | ||||||
|  | + | ||||||
|  | +/* NSSWFQ section */ | ||||||
|  | + | ||||||
|  | +enum { | ||||||
|  | +	TCA_NSSWFQ_UNSPEC, | ||||||
|  | +	TCA_NSSWFQ_CLASS_PARMS, | ||||||
|  | +	TCA_NSSWFQ_QDISC_PARMS, | ||||||
|  | +	__TCA_NSSWFQ_MAX | ||||||
|  | +}; | ||||||
|  | + | ||||||
|  | +#define TCA_NSSWFQ_MAX	(__TCA_NSSWFQ_MAX - 1) | ||||||
|  | + | ||||||
|  | +struct tc_nsswfq_class_qopt { | ||||||
|  | +	__u32	quantum;	/* Weight associated to this class */ | ||||||
|  | +}; | ||||||
|  | + | ||||||
|  | +struct tc_nsswfq_qopt { | ||||||
|  | +	__u8	accel_mode;	/* Dictates which data plane offloads the qdisc */ | ||||||
|  | +}; | ||||||
|  | + | ||||||
|  | +/* NSSHTB section */ | ||||||
|  | + | ||||||
|  | +enum { | ||||||
|  | +	TCA_NSSHTB_UNSPEC, | ||||||
|  | +	TCA_NSSHTB_CLASS_PARMS, | ||||||
|  | +	TCA_NSSHTB_QDISC_PARMS, | ||||||
|  | +	__TCA_NSSHTB_MAX | ||||||
|  | +}; | ||||||
|  | + | ||||||
|  | +#define TCA_NSSHTB_MAX	(__TCA_NSSHTB_MAX - 1) | ||||||
|  | + | ||||||
|  | +struct tc_nsshtb_class_qopt { | ||||||
|  | +	__u32	burst;		/* Allowed burst size */ | ||||||
|  | +	__u32	rate;		/* Allowed bandwidth for this class */ | ||||||
|  | +	__u32	cburst;		/* Maximum burst size */ | ||||||
|  | +	__u32	crate;		/* Maximum bandwidth for this class */ | ||||||
|  | +	__u32	quantum;	/* Quantum allocation for DRR */ | ||||||
|  | +	__u32	priority;	/* Priority value associated with this class */ | ||||||
|  | +	__u32	overhead;	/* Overhead in bytes per packet */ | ||||||
|  | +}; | ||||||
|  | + | ||||||
|  | +struct tc_nsshtb_qopt { | ||||||
|  | +	__u32	r2q;		/* Rate to quantum ratio */ | ||||||
|  | +	__u8	accel_mode;	/* Dictates which data plane offloads the qdisc */ | ||||||
|  | +}; | ||||||
|  | + | ||||||
|  | +/* NSSBLACKHOLE section */ | ||||||
|  | + | ||||||
|  | +enum { | ||||||
|  | +	TCA_NSSBLACKHOLE_UNSPEC, | ||||||
|  | +	TCA_NSSBLACKHOLE_PARMS, | ||||||
|  | +	__TCA_NSSBLACKHOLE_MAX | ||||||
|  | +}; | ||||||
|  | + | ||||||
|  | +#define TCA_NSSBLACKHOLE_MAX	(__TCA_NSSBLACKHOLE_MAX - 1) | ||||||
|  | + | ||||||
|  | +struct tc_nssblackhole_qopt { | ||||||
|  | +	__u8	set_default;	/* Sets qdisc to be the default qdisc for enqueue */ | ||||||
|  | +	__u8	accel_mode;	/* Dictates which data plane offloads the qdisc */ | ||||||
|  | +}; | ||||||
|  | +/* QCA NSS Clients Support - End */ | ||||||
|  |  #endif | ||||||
|  | --- a/net/sched/sch_api.c | ||||||
|  | +++ b/net/sched/sch_api.c | ||||||
|  | @@ -2290,4 +2290,26 @@ static int __init pktsched_init(void) | ||||||
|  |  	return 0; | ||||||
|  |  } | ||||||
|  |   | ||||||
|  | +/* QCA NSS Qdisc Support - Start */ | ||||||
|  | +bool tcf_destroy(struct tcf_proto *tp, bool force) | ||||||
|  | +{ | ||||||
|  | +	tp->ops->destroy(tp, force, NULL); | ||||||
|  | +	module_put(tp->ops->owner); | ||||||
|  | +	kfree_rcu(tp, rcu); | ||||||
|  | + | ||||||
|  | +	return true; | ||||||
|  | +} | ||||||
|  | + | ||||||
|  | +void tcf_destroy_chain(struct tcf_proto __rcu **fl) | ||||||
|  | +{ | ||||||
|  | +	struct tcf_proto *tp; | ||||||
|  | + | ||||||
|  | +	while ((tp = rtnl_dereference(*fl)) != NULL) { | ||||||
|  | +		RCU_INIT_POINTER(*fl, tp->next); | ||||||
|  | +		tcf_destroy(tp, true); | ||||||
|  | +	} | ||||||
|  | +} | ||||||
|  | +EXPORT_SYMBOL(tcf_destroy_chain); | ||||||
|  | +/* QCA NSS Qdisc Support - End */ | ||||||
|  | + | ||||||
|  |  subsys_initcall(pktsched_init); | ||||||
|  | --- a/net/sched/sch_generic.c | ||||||
|  | +++ b/net/sched/sch_generic.c | ||||||
|  | @@ -741,7 +741,7 @@ static void qdisc_free_cb(struct rcu_hea | ||||||
|  |  	qdisc_free(q); | ||||||
|  |  } | ||||||
|  |  | ||||||
|  | -static void qdisc_destroy(struct Qdisc *qdisc) | ||||||
|  | +void qdisc_destroy(struct Qdisc *qdisc) | ||||||
|  |  { | ||||||
|  |  	const struct Qdisc_ops  *ops = qdisc->ops; | ||||||
|  |  	struct sk_buff *skb, *tmp; | ||||||
|  | @@ -772,6 +772,7 @@ static void qdisc_destroy(struct Qdisc * | ||||||
|  |   | ||||||
|  |  	call_rcu(&qdisc->rcu, qdisc_free_cb); | ||||||
|  |  } | ||||||
|  | +EXPORT_SYMBOL(qdisc_destroy); | ||||||
|  |   | ||||||
|  |  void qdisc_put(struct Qdisc *qdisc) | ||||||
|  |  { | ||||||
| @@ -0,0 +1,132 @@ | |||||||
|  | --- a/drivers/net/ppp/ppp_generic.c | ||||||
|  | +++ b/drivers/net/ppp/ppp_generic.c | ||||||
|  | @@ -48,6 +48,7 @@ | ||||||
|  |  #include <net/slhc_vj.h> | ||||||
|  |  #include <linux/atomic.h> | ||||||
|  |  #include <linux/refcount.h> | ||||||
|  | +#include <linux/if_pppox.h> | ||||||
|  |   | ||||||
|  |  #include <linux/nsproxy.h> | ||||||
|  |  #include <net/net_namespace.h> | ||||||
|  | @@ -3207,6 +3208,10 @@ ppp_connect_channel(struct channel *pch, | ||||||
|  |  	struct ppp_net *pn; | ||||||
|  |  	int ret = -ENXIO; | ||||||
|  |  	int hdrlen; | ||||||
|  | +	/* QCA NSS ECM Support - Start */ | ||||||
|  | +	int ppp_proto; | ||||||
|  | +	int version; | ||||||
|  | +	/* QCA NSS ECM Support - End */ | ||||||
|  |   | ||||||
|  |  	pn = ppp_pernet(pch->chan_net); | ||||||
|  |   | ||||||
|  | @@ -3238,6 +3243,26 @@ ppp_connect_channel(struct channel *pch, | ||||||
|  |  	++ppp->n_channels; | ||||||
|  |  	pch->ppp = ppp; | ||||||
|  |  	refcount_inc(&ppp->file.refcnt); | ||||||
|  | + | ||||||
|  | +	/* QCA NSS ECM support - Start */ | ||||||
|  | +	/* Set the netdev priv flag if the prototype | ||||||
|  | +	 * is L2TP or PPTP. Return success in all cases | ||||||
|  | +	 */ | ||||||
|  | +	if (!pch->chan) | ||||||
|  | +		goto out2; | ||||||
|  | + | ||||||
|  | +	ppp_proto = ppp_channel_get_protocol(pch->chan); | ||||||
|  | +	if (ppp_proto == PX_PROTO_PPTP) { | ||||||
|  | +		ppp->dev->priv_flags_qca_ecm |= IFF_QCA_ECM_PPP_PPTP; | ||||||
|  | +	} else if (ppp_proto == PX_PROTO_OL2TP) { | ||||||
|  | +		version = ppp_channel_get_proto_version(pch->chan); | ||||||
|  | +		if (version == 2) | ||||||
|  | +			ppp->dev->priv_flags_qca_ecm |= IFF_QCA_ECM_PPP_L2TPV2; | ||||||
|  | +		else if (version == 3) | ||||||
|  | +			ppp->dev->priv_flags_qca_ecm |= IFF_QCA_ECM_PPP_L2TPV3; | ||||||
|  | +	} | ||||||
|  | +	/* QCA NSS ECM support - End */ | ||||||
|  | + out2: | ||||||
|  |  	ppp_unlock(ppp); | ||||||
|  |  	ret = 0; | ||||||
|  |   | ||||||
|  | @@ -3341,6 +3366,56 @@ | ||||||
|  |  } | ||||||
|  |  EXPORT_SYMBOL(ppp_release_channels); | ||||||
|  |   | ||||||
|  | +/* Return the PPP net device index */ | ||||||
|  | +int ppp_dev_index(struct ppp_channel *chan) | ||||||
|  | +{ | ||||||
|  | +	struct channel *pch = chan->ppp; | ||||||
|  | +	int ifindex = 0; | ||||||
|  | + | ||||||
|  | +	if (pch) { | ||||||
|  | +		read_lock_bh(&pch->upl); | ||||||
|  | +		if (pch->ppp && pch->ppp->dev) | ||||||
|  | +			ifindex = pch->ppp->dev->ifindex; | ||||||
|  | +		read_unlock_bh(&pch->upl); | ||||||
|  | +	} | ||||||
|  | +	return ifindex; | ||||||
|  | +} | ||||||
|  | +EXPORT_SYMBOL(ppp_dev_index); | ||||||
|  | + | ||||||
|  | +/* ppp_channel_get_proto_version() | ||||||
|  | + *	Call this to get channel protocol version | ||||||
|  | + */ | ||||||
|  | +int ppp_channel_get_proto_version(struct ppp_channel *chan) | ||||||
|  | +{ | ||||||
|  | +	if (!chan->ops->get_channel_protocol_ver) | ||||||
|  | +		return -1; | ||||||
|  | + | ||||||
|  | +	return chan->ops->get_channel_protocol_ver(chan); | ||||||
|  | +} | ||||||
|  | +EXPORT_SYMBOL(ppp_channel_get_proto_version); | ||||||
|  | + | ||||||
|  | +/* Check if ppp xmit lock is on hold */ | ||||||
|  | +bool ppp_is_xmit_locked(struct net_device *dev) | ||||||
|  | +{ | ||||||
|  | +	struct ppp *ppp; | ||||||
|  | + | ||||||
|  | +	if (!dev) | ||||||
|  | +		return false; | ||||||
|  | + | ||||||
|  | +	if (dev->type != ARPHRD_PPP) | ||||||
|  | +		return false; | ||||||
|  | + | ||||||
|  | +	ppp = netdev_priv(dev); | ||||||
|  | +	if (!ppp) | ||||||
|  | +		return false; | ||||||
|  | + | ||||||
|  | +	if (spin_is_locked(&(ppp)->wlock)) | ||||||
|  | +		return true; | ||||||
|  | + | ||||||
|  | +	return false; | ||||||
|  | +} | ||||||
|  | +EXPORT_SYMBOL(ppp_is_xmit_locked); | ||||||
|  | + | ||||||
|  |  /* Module/initialization stuff */ | ||||||
|  |   | ||||||
|  |  module_init(ppp_init); | ||||||
|  | --- a/include/linux/ppp_channel.h | ||||||
|  | +++ b/include/linux/ppp_channel.h | ||||||
|  | @@ -32,6 +32,8 @@ struct ppp_channel_ops { | ||||||
|  |  	 * the channel subtype | ||||||
|  |  	 */ | ||||||
|  |  	int (*get_channel_protocol)(struct ppp_channel *); | ||||||
|  | +	/* Get channel protocol version */ | ||||||
|  | +	int (*get_channel_protocol_ver)(struct ppp_channel *); | ||||||
|  | 	/* Hold the channel from being destroyed */ | ||||||
|  | 	void (*hold)(struct ppp_channel *); | ||||||
|  | 	/* Release hold on the channel */ | ||||||
|  | @@ -84,6 +96,15 @@ | ||||||
|  |  /* Test if ppp xmit lock is locked */ | ||||||
|  |  extern bool ppp_is_xmit_locked(struct net_device *dev); | ||||||
|  |   | ||||||
|  | +/* Test if ppp xmit lock is locked */ | ||||||
|  | +extern bool ppp_is_xmit_locked(struct net_device *dev); | ||||||
|  | + | ||||||
|  | +/* Call this get protocol version */ | ||||||
|  | +extern int ppp_channel_get_proto_version(struct ppp_channel *); | ||||||
|  | + | ||||||
|  | +/* Get the device index  associated with a channel, or 0, if none */ | ||||||
|  | +extern int ppp_dev_index(struct ppp_channel *); | ||||||
|  | + | ||||||
|  |  /* Hold PPP channels for the PPP device */ | ||||||
|  |  extern int __ppp_hold_channels(struct net_device *dev, | ||||||
|  |  			       struct ppp_channel *channels[], | ||||||
| @@ -0,0 +1,99 @@ | |||||||
|  | --- a/include/linux/ppp_channel.h | ||||||
|  | +++ b/include/linux/ppp_channel.h | ||||||
|  | @@ -146,5 +146,17 @@ extern void ppp_update_stats(struct net_ | ||||||
|  |  extern int ppp_dev_index(struct ppp_channel *); | ||||||
|  |  /* QCA NSS ECM Support - End */ | ||||||
|  |   | ||||||
|  | +/* QCA NSS Clients Support - Start */ | ||||||
|  | +/* PPP channel connection event types */ | ||||||
|  | +#define PPP_CHANNEL_DISCONNECT	0 | ||||||
|  | +#define PPP_CHANNEL_CONNECT	1 | ||||||
|  | + | ||||||
|  | +/* Register the PPP channel connect notifier */ | ||||||
|  | +extern void ppp_channel_connection_register_notify(struct notifier_block *nb); | ||||||
|  | + | ||||||
|  | +/* Unregister the PPP channel connect notifier */ | ||||||
|  | +extern void ppp_channel_connection_unregister_notify(struct notifier_block *nb); | ||||||
|  | +/* QCA NSS Clients Support - End */ | ||||||
|  | + | ||||||
|  |  #endif /* __KERNEL__ */ | ||||||
|  |  #endif | ||||||
|  | --- a/drivers/net/ppp/ppp_generic.c | ||||||
|  | +++ b/drivers/net/ppp/ppp_generic.c | ||||||
|  | @@ -256,6 +256,26 @@ struct ppp_net { | ||||||
|  |  #define seq_before(a, b)	((s32)((a) - (b)) < 0) | ||||||
|  |  #define seq_after(a, b)		((s32)((a) - (b)) > 0) | ||||||
|  |   | ||||||
|  | +/* QCA NSS Client Support - Start */ | ||||||
|  | +/* | ||||||
|  | + * Registration/Unregistration methods | ||||||
|  | + * for PPP channel connect and disconnect event notifications. | ||||||
|  | + */ | ||||||
|  | +RAW_NOTIFIER_HEAD(ppp_channel_connection_notifier_list); | ||||||
|  | + | ||||||
|  | +void ppp_channel_connection_register_notify(struct notifier_block *nb) | ||||||
|  | +{ | ||||||
|  | +	raw_notifier_chain_register(&ppp_channel_connection_notifier_list, nb); | ||||||
|  | +} | ||||||
|  | +EXPORT_SYMBOL_GPL(ppp_channel_connection_register_notify); | ||||||
|  | + | ||||||
|  | +void ppp_channel_connection_unregister_notify(struct notifier_block *nb) | ||||||
|  | +{ | ||||||
|  | +	raw_notifier_chain_unregister(&ppp_channel_connection_notifier_list, nb); | ||||||
|  | +} | ||||||
|  | +EXPORT_SYMBOL_GPL(ppp_channel_connection_unregister_notify); | ||||||
|  | +/* QCA NSS Client Support - End */ | ||||||
|  | + | ||||||
|  |  /* Prototypes. */ | ||||||
|  |  static int ppp_unattached_ioctl(struct net *net, struct ppp_file *pf, | ||||||
|  |  			struct file *file, unsigned int cmd, unsigned long arg); | ||||||
|  | @@ -3212,6 +3232,7 @@ ppp_connect_channel(struct channel *pch, | ||||||
|  |  	int ppp_proto; | ||||||
|  |  	int version; | ||||||
|  |  	/* QCA NSS ECM Support - End */ | ||||||
|  | +	int notify = 0; /* QCA NSS Client Support */ | ||||||
|  |   | ||||||
|  |  	pn = ppp_pernet(pch->chan_net); | ||||||
|  |   | ||||||
|  | @@ -3262,6 +3283,8 @@ ppp_connect_channel(struct channel *pch, | ||||||
|  |  			ppp->dev->priv_flags_qca_ecm |= IFF_QCA_ECM_PPP_L2TPV3; | ||||||
|  |  	} | ||||||
|  |  	/* QCA NSS ECM support - End */ | ||||||
|  | + | ||||||
|  | +	notify = 1; /* QCA NSS Clients Support */ | ||||||
|  |   out2: | ||||||
|  |  	ppp_unlock(ppp); | ||||||
|  |  	ret = 0; | ||||||
|  | @@ -3270,6 +3293,16 @@ ppp_connect_channel(struct channel *pch, | ||||||
|  |  	write_unlock_bh(&pch->upl); | ||||||
|  |   out: | ||||||
|  |  	mutex_unlock(&pn->all_ppp_mutex); | ||||||
|  | + | ||||||
|  | +	/* QCA NSS Clients Support - Start */ | ||||||
|  | +	if (notify && ppp && ppp->dev) { | ||||||
|  | +		dev_hold(ppp->dev); | ||||||
|  | +		raw_notifier_call_chain(&ppp_channel_connection_notifier_list, | ||||||
|  | +					   PPP_CHANNEL_CONNECT, ppp->dev); | ||||||
|  | +		dev_put(ppp->dev); | ||||||
|  | +	} | ||||||
|  | +	/* QCA NSS Clients Support - End */ | ||||||
|  | + | ||||||
|  |  	return ret; | ||||||
|  |  } | ||||||
|  |   | ||||||
|  | @@ -3287,6 +3320,15 @@ ppp_disconnect_channel(struct channel *p | ||||||
|  |  	pch->ppp = NULL; | ||||||
|  |  	write_unlock_bh(&pch->upl); | ||||||
|  |  	if (ppp) { | ||||||
|  | +		/* QCA NSS Clients Support - Start */ | ||||||
|  | +		if (ppp->dev) { | ||||||
|  | +			dev_hold(ppp->dev); | ||||||
|  | +			raw_notifier_call_chain(&ppp_channel_connection_notifier_list, | ||||||
|  | +					   PPP_CHANNEL_DISCONNECT, ppp->dev); | ||||||
|  | +			dev_put(ppp->dev); | ||||||
|  | +		} | ||||||
|  | +		/* QCA NSS Clients Support - Start */ | ||||||
|  | + | ||||||
|  |  		/* remove it from the ppp unit's list */ | ||||||
|  |  		ppp_lock(ppp); | ||||||
|  |  		list_del(&pch->clist); | ||||||
| @@ -0,0 +1,77 @@ | |||||||
|  | --- a/include/net/ip6_tunnel.h | ||||||
|  | +++ b/include/net/ip6_tunnel.h | ||||||
|  | @@ -36,6 +36,7 @@ struct __ip6_tnl_parm { | ||||||
|  |  	__u8 proto;		/* tunnel protocol */ | ||||||
|  |  	__u8 encap_limit;	/* encapsulation limit for tunnel */ | ||||||
|  |  	__u8 hop_limit;		/* hop limit for tunnel */ | ||||||
|  | +	__u8 draft03;		/* FMR using draft03 of map-e - QCA NSS Clients Support */ | ||||||
|  |  	bool collect_md; | ||||||
|  |  	__be32 flowinfo;	/* traffic class and flowlabel for tunnel */ | ||||||
|  |  	__u32 flags;		/* tunnel flags */ | ||||||
|  | --- a/include/net/ip_tunnels.h | ||||||
|  | +++ b/include/net/ip_tunnels.h | ||||||
|  | @@ -525,4 +525,9 @@ static inline void ip_tunnel_info_opts_s | ||||||
|  |   | ||||||
|  |  #endif /* CONFIG_INET */ | ||||||
|  |   | ||||||
|  | +/* QCA NSS Clients Support - Start */ | ||||||
|  | +void ipip6_update_offload_stats(struct net_device *dev, void *ptr); | ||||||
|  | +void ip6_update_offload_stats(struct net_device *dev, void *ptr); | ||||||
|  | +/* QCA NSS Clients Support - End */ | ||||||
|  | + | ||||||
|  |  #endif /* __NET_IP_TUNNELS_H */ | ||||||
|  | --- a/net/ipv6/ip6_tunnel.c | ||||||
|  | +++ b/net/ipv6/ip6_tunnel.c | ||||||
|  | @@ -2392,6 +2392,26 @@ nla_put_failure: | ||||||
|  |  	return -EMSGSIZE; | ||||||
|  |  } | ||||||
|  |   | ||||||
|  | +/* QCA NSS Client Support - Start */ | ||||||
|  | +/* | ||||||
|  | + * Update offload stats | ||||||
|  | + */ | ||||||
|  | +void ip6_update_offload_stats(struct net_device *dev, void *ptr) | ||||||
|  | +{ | ||||||
|  | +	struct pcpu_sw_netstats *tstats = per_cpu_ptr(dev->tstats, 0); | ||||||
|  | +	const struct pcpu_sw_netstats *offload_stats = | ||||||
|  | +					(struct pcpu_sw_netstats *)ptr; | ||||||
|  | + | ||||||
|  | +	u64_stats_update_begin(&tstats->syncp); | ||||||
|  | +	tstats->tx_packets += offload_stats->tx_packets; | ||||||
|  | +	tstats->tx_bytes   += offload_stats->tx_bytes; | ||||||
|  | +	tstats->rx_packets += offload_stats->rx_packets; | ||||||
|  | +	tstats->rx_bytes   += offload_stats->rx_bytes; | ||||||
|  | +	u64_stats_update_end(&tstats->syncp); | ||||||
|  | +} | ||||||
|  | +EXPORT_SYMBOL(ip6_update_offload_stats); | ||||||
|  | +/* QCA NSS Client Support - End */ | ||||||
|  | + | ||||||
|  |  struct net *ip6_tnl_get_link_net(const struct net_device *dev) | ||||||
|  |  { | ||||||
|  |  	struct ip6_tnl *tunnel = netdev_priv(dev); | ||||||
|  | --- a/net/ipv6/sit.c | ||||||
|  | +++ b/net/ipv6/sit.c | ||||||
|  | @@ -1741,6 +1741,23 @@ nla_put_failure: | ||||||
|  |  	return -EMSGSIZE; | ||||||
|  |  } | ||||||
|  |   | ||||||
|  | +/* QCA NSS Clients Support - Start */ | ||||||
|  | +void ipip6_update_offload_stats(struct net_device *dev, void *ptr) | ||||||
|  | +{ | ||||||
|  | +	struct pcpu_sw_netstats *tstats = per_cpu_ptr(dev->tstats, 0); | ||||||
|  | +	const struct pcpu_sw_netstats *offload_stats = | ||||||
|  | +					(struct pcpu_sw_netstats *)ptr; | ||||||
|  | + | ||||||
|  | +	u64_stats_update_begin(&tstats->syncp); | ||||||
|  | +	tstats->tx_packets += offload_stats->tx_packets; | ||||||
|  | +	tstats->tx_bytes   += offload_stats->tx_bytes; | ||||||
|  | +	tstats->rx_packets += offload_stats->rx_packets; | ||||||
|  | +	tstats->rx_bytes   += offload_stats->rx_bytes; | ||||||
|  | +	u64_stats_update_end(&tstats->syncp); | ||||||
|  | +} | ||||||
|  | +EXPORT_SYMBOL(ipip6_update_offload_stats); | ||||||
|  | +/* QCA NSS Clients Support - End */ | ||||||
|  | + | ||||||
|  |  static const struct nla_policy ipip6_policy[IFLA_IPTUN_MAX + 1] = { | ||||||
|  |  	[IFLA_IPTUN_LINK]		= { .type = NLA_U32 }, | ||||||
|  |  	[IFLA_IPTUN_LOCAL]		= { .type = NLA_U32 }, | ||||||
		Reference in New Issue
	
	Block a user
	 ACwifidude
					ACwifidude