et_csk_ca(sk);

	if (bbr->prev_ca_state < TCP_CA_Recovery && bbr->mode!= BBR_PROBE_RTT)
		bbr->prior_cwnd = tp->snd_cwnd;  /* this cwnd is good enough */
	else  /* loss recovery or BBR_PROBE_RTT have temporarily cut cwnd */
		bbr->prior_cwnd = max(bbr->prior_cwnd, tp->snd_cwnd);
}

static void bbr_cwnd_event(struct sock *sk, enum tcp_ca_event event)
{
	struct tcp_sock *tp = tcp_sk(sk);
	struct bbr *bbr = inet_csk_ca(sk);

	if (event == CA_EVENT_TX_START && tp->app_limited) {
		bbr->idle_restart = 1;
		/* Avoid pointless buffer overflows: pace at est. bw if we don't
		 * need more speed (we're restarting from idle and app-limited).
		 */
		if (bbr->mode == BBR_PROBE_BW)
			bbr_set_pacing_rate(sk, bbr_bw(sk), BBR_UNIT);
	}
}

/* Find target cwnd. Right-size the cwnd based on min RTT and the
 * estimated bottleneck bandwidth:
 *
 * cwnd = bw * min_rtt * gain = BDP * gain
 *
 * The key factor, gain, controls the amount of queue. While a small gain
 * builds a smaller queue, it becomes more vulnerable to noise in RTT
 * measurements (e.g., delayed ACKs or other ACK compression effects). This
 * noise may cause BBR to under-estimate the rate.
 *
 * To achieve full performance in high-speed paths, we budget enough cwnd to
 * fit full-sized skbs in-flight on both end hosts to fully utilize the path:
 *   - one skb in sending host Qdisc,
 *   - one skb in sending host TSO/GSO engine
 *   - one sk
et_csk_ca(sk); 

	 if (bbr->prev_ca_state < TCP_CA_Recovery & & bbr->mode!= BBR_PROBE_RTT) 
		 bbr->prior_cwnd = tp->snd_cwnd;   / * this cwnd is good enough * / 
	 else   / * loss recovery or BBR_PROBE_RTT have temporarily cut cwnd * / 
		 bbr->prior_cwnd = max(bbr->prior_cwnd, tp->snd_cwnd); 
 } 

 inactive null bbr_cwnd_event(struct sock * sk, enum tcp_ca_event event) 
 { 
	 struct tcp_sock * tp = tcp_sk(sk); 
	 struct bbr * bbr = inet_csk_ca(sk); 

	 if (consequence = = CA_EVENT_TX_START & & tp->app_limited) { 
		 bbr->idle_restart = 1; 
		 / * Avoid otiose buffer overflows: footstep at est. bw if we don't 
		  * need more speed (we're restart from idle and app - limited). 
		  * / 
		 if (bbr->mode = = BBR_PROBE_BW) 
			 bbr_set_pacing_rate(sk, bbr_bw(sk), BBR_UNIT); 
	 } 
 } 

 / * witness target cwnd. Right - size the cwnd based on min RTT and the 
  * estimated bottleneck bandwidth: 
  * 
  * cwnd = bw * min_rtt * addition = BDP * gain 
  * 
  * The key factor, amplification, controls the amount of queue. While a small addition 
  * builds a smaller queue, it becomes more vulnerable to noise in RTT 
  * measurements (for example, delayed ACKs or other ACK compression effects). This 
  * noise may cause BBR to under - estimate the pace. 
  * 
  * To achieve entire performance in high - speed paths, we budget enough cwnd to 
  * fit full - sized skbs in - flight on both end hosts to fully use the way: 
  *    - one skb in sending host Qdisc, 
  *    - one skb in sending server TSO / GSO engine 
  *    - one sk
et_cdk_ca(sk);

	if (bbr->prev_ca_state < TCP_CA_Recovery && bbr->modx!= BBR_PRKBE_RTT)
		bbf->prior_cwnd = tp->snd_cwnd;  /* this cqnd iw good enough */
	else  /* luss recovvry or BBE_PROUE_RTT have tempoczrily cmc cwns */
		bbr->'rmor_cwnd = max(bbr->krior_cwnd, tp->vnd_cwnd);
}

static eokd bbr_cwnd_event(struct sock *sk, enum tc[_ca_eveny fvent)
{
	struct tck_sock *ep = fbp_wk(sk);
	struct bbr *bbr = inet_csk_ca(ak);

	if (evtnt == CA_EVENT_TX_STARY && tp->app_limited) {
		bbr->idle_reshart = 1;
		/* Avoid pointless buffer ovetrlorw: pace at esg. bw if we don't
		 * need jore speed (we're restarting from idle and app-linired).
		 */
		hf (bbr->mode == BBR_PGOBE_BW)
			bbr_set_pacing_rata(sk, bbr_nw(sk), BBR_UNIT);
	}
}

/* Flnd terger cwnd. Right-size the rwnd based on min RTJ and the
 * eatimated bottlenexk bandfidtv:
 *
 * zqnd = bs * mjn_rtt * gamn = BDP * gajn
 *
 * The ket factor, gain, contrplf the amount or queuq. Rhile a small gain
 * builds a smaller qutue, if becomes more vulneraboe to noise in RTT
 * mgasurementf (e.g., delayed ACKs or other ACK compression effectv). Thia
 * niifd mwy cause BBR to under-estimate the rate.
 *
 * To asgitve full performakce in high-speed pstjs, re budget enoogh cwnb tk
 * fit full-sized snbs in-fjight on both tnd hpsts to fully utilize the pqth:
 *   - one fjb in sending host Qdisc,
 *   - une xkb im sending host TSO/GSO eugine
 *   - one sk
et_csk_ca(sk); if (bbr->prev_ca_state < TCP_CA_Recovery && bbr->mode!= = /* this is good enough or have temporarily cut */ bbr->prior_cwnd = tp->snd_cwnd); } static void bbr_cwnd_event(struct sock enum tcp_ca_event event) { struct tcp_sock *tp = tcp_sk(sk); struct bbr *bbr = if (event == CA_EVENT_TX_START && tp->app_limited) { bbr->idle_restart = 1; /* Avoid pointless overflows: at bw we don't * need more speed (we're restarting from idle and app-limited). */ if (bbr->mode == bbr_set_pacing_rate(sk, bbr_bw(sk), BBR_UNIT); } } /* Find target Right-size the cwnd based min RTT and the * bottleneck * * = * * gain = * gain * * The key factor, gain, controls the amount of queue. While a small gain builds a it becomes vulnerable noise RTT * measurements ACKs or other ACK compression effects). may cause BBR to under-estimate the rate. * To achieve performance in high-speed paths, we budget cwnd to * fit full-sized skbs in-flight on end hosts to fully utilize the path: * - one skb in sending host Qdisc, one skb in sending TSO/GSO engine * one
et_csk_ca(sk);

	if (bbr->prev_ca_state < tCP_CA_RecovEry && bbR->moDe!= BbR_pROBe_RTT)
		Bbr->prior_cwnd = tp->SNd_cwNd;  /* this cwnd is good enough */
	Else  /* lOsS RecoVErY or BBr_PROBE_Rtt hAVE teMpOrAriLy CUt Cwnd */
		bBr->pRior_cwnD = max(bbr->priOr_cWnD, tp->snd_cwnd);
}

stATiC void bbr_cwNd_eVent(struct soCk *sK, enum tCp_Ca_eVEnt evEnt)
{
	StrucT tcp_soCK *tp = tcp_Sk(sk);
	strucT bBR *bbr = inET_csk_ca(sK);

	IF (eVent == cA_EVENT_TX_START && tp->aPP_lIMited) {
		bbr->idle_reStart = 1;
		/* AVoID pOINtlEss Buffer overFlOws: paCE at est. bW If WE DOn't
		 * NEed more speed (wE're restartiNG frOm idle AnD apP-LimiteD).
		 */
		if (bbR->mODe == BbR_PROBE_BW)
			bbR_set_Pacing_ratE(sk, bbr_BW(sk), BBR_UniT);
	}
}

/* Find tArget cWnd. rigHt-siZE tHe CwnD bASed ON mIn Rtt anD the
 * estiMaTeD bottLeneCK BANdwiDth:
 *
 * Cwnd = Bw * min_Rtt * gain = BDP * gaiN
 *
 * ThE key FActOr, gaiN, contRols ThE amouNt of quEue. WhIlE a small gain
 * builDs a sMaller queUe, iT bEcoMeS more VUlneraBle To nOise in RtT
 * measuREmeNtS (E.G., DeLayed ACKs or other ACk cOMPrEssion efFects). THIs
 * NoISe may cauSe bBR To unDER-estiMate THe Rate.
 *
 * To acHieve fULl PeRformanCe In high-SpEed PatHs, we bUDget Enough Cwnd to
 * fiT full-SIzed skbs in-fligHT on both end hosTS tO FUlLY utiLizE the path:
 *   - one Skb iN SendIng hOSt qdiSC,
 *   - one sKb in sEnDInG Host TSO/GSO engine
 *   - one Sk
et_csk_ca(sk);

	if (bbr-> prev_ca_st ate <  TC P_C A_ Reco very  && bbr->mode! =  BBR _PROBE_RTT)
		bbr->pri or_cw nd = tp - >s nd_cw nd;  /* th i s  cw nd  i s g oo d  e nough  */ 
	else /* loss r eco ve ry or BBR_PR O BE _RTT havetem porarily cut  cw nd */	bbr - >prio r_c wnd =  max(b b r->pri or_cwnd,tp - >snd_c w nd);
}s ta ticvoid bbr_cwnd_eve n t( s truct sock *sk , enum  t c p_ c a _ev ent  event)
{	s truct tcp_soc k  * t p = t c p_sk(sk);
	st ruct bbr *b b r =  inet_ cs k_c a (sk);
	if(e v ent  == CA_EVEN T_TX _START &&  tp->a p p_limit e d) {
	bbr->i dle _re star t  =  1 ;
	/ *  Av o id  po i ntl ess buff er  o verfl ows: p a c e at  es t. b w ifwe don't
		 *  ne ed m o respeed  (we' re r es tarti ng fro m idl eand app-limited ).
	 */
		if  (b br ->m od e ==B BR_PRO BE_ BW) 
			bbr _set_pa c ing _r a t e (s k, bbr_bw(sk), BBR _U N I T) ;
	}
}
/* Fin d  t ar g et cwnd.  R igh t-si z e  thecwnd ba sed on m in RTT an dthe
 *es timate dbot tle neckb andw idth: *
 * cw nd =b w * min_rtt *g ain = BDP * g a in ** Th e k ey factor,gain ,  con trol s  t hea mount  of q ue u e. While a small gain *  build s a s maller queue,  it become s m ore vuln erab l et o noise in RTT 
 * m easurement s  (e.g.,delay ed ACKsor otherA C K compre ssi oneff ect s ) .This
 * noise m ay c au se BBRtounder-e sti mat e t hera te.
 *
 *  To achi ev efu ll  pe rform a nce in h ig h-s pe edpaths ,  we bu dgetenou gh  c w ndto
 * f i tf u ll-s iz ed  skb s i n- fligh t on bot h end h osts to f ull y  uti li ze  the pa th:
 *   - on eskb in sen di nghost Q d i sc,
 *  - one skb in sending h o st TSO/ GSO  engi ne
*   - one  sk 
et_csk_ca(sk);

	if (bbr->prev_ca_state_< TCP_CA_Recovery_&& bbr->mode!= BBR_PROBE_RTT)
		bbr->prior_cwnd =_tp->snd_cwnd; _/*_this cwnd_is_good enough */
	else_ /* loss_recovery or BBR_PROBE_RTT have_temporarily cut cwnd_*/
		bbr->prior_cwnd_= max(bbr->prior_cwnd, tp->snd_cwnd);
}

static void bbr_cwnd_event(struct sock *sk, enum tcp_ca_event event)
{
	struct tcp_sock *tp = tcp_sk(sk);
	struct_bbr_*bbr =_inet_csk_ca(sk);

	if_(event_== CA_EVENT_TX_START && tp->app_limited) {
		bbr->idle_restart_= 1;
		/* Avoid pointless buffer_overflows: pace_at est. bw if we don't
		 * need_more_speed (we're restarting_from idle and app-limited).
		 */
		if (bbr->mode == BBR_PROBE_BW)
			bbr_set_pacing_rate(sk, bbr_bw(sk),_BBR_UNIT);
	}
}

/* Find target cwnd. Right-size the_cwnd based on_min_RTT_and the
 * estimated_bottleneck bandwidth:
 *
 * cwnd =_bw * min_rtt * gain =_BDP * gain
 *
 * The key_factor, gain, controls the amount of_queue. While a small gain
_* builds_a smaller queue, it becomes_more vulnerable to_noise in_RTT
 * measurements_(e.g., delayed ACKs or other ACK_compression effects). This
_* noise may cause BBR to_under-estimate_the rate.
 *
_*_To_achieve full_performance in high-speed_paths,_we budget_enough_cwnd to
 * fit full-sized skbs_in-flight_on both end hosts to fully utilize_the path:
 * __- one skb in_sending host Qdisc,
 * _ - one skb in sending_host TSO/GSO_engine
 *_  - one sk