android_kernel_xiaomi_sm8350/offload/rmnet_offload_main.c

196 lines
13 KiB
C
Raw Normal View History

/* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include <linux/compiler.h>
#include <linux/rcupdate.h>
#include <linux/jhash.h>
#include <linux/spinlock.h>
#include "rmnet_descriptor.h"
#include "rmnet_handlers.h"
#include "rmnet_map.h"
#include "rmnet_offload_main.h"
#include "rmnet_offload_state.h"
#include "rmnet_offload_engine.h"
#include "rmnet_offload_stats.h"
static const char*DATARMNET9be3ddbe97[]__always_unused={
"\x49\x37\x32\x31\x62\x64\x36\x39\x35\x32\x31\x66\x65\x34\x61\x61\x38\x64\x61\x65\x62\x65\x66\x62\x32\x38\x30\x64\x38\x64\x31\x35\x30\x39\x66\x39\x31\x65\x36\x37\x33"
,
"\x49\x36\x64\x36\x66\x39\x32\x35\x66\x33\x65\x33\x32\x31\x65\x31\x32\x32\x38\x64\x33\x38\x37\x33\x66\x63\x37\x38\x32\x31\x38\x62\x61\x39\x30\x65\x39\x34\x35\x30\x36"
,
"\x49\x36\x61\x62\x39\x37\x30\x65\x36\x62\x65\x65\x34\x33\x39\x34\x63\x36\x31\x30\x33\x38\x31\x62\x62\x38\x39\x66\x36\x33\x36\x31\x61\x34\x66\x30\x33\x36\x63\x66\x30"
,
"\x49\x38\x63\x31\x65\x62\x39\x62\x63\x35\x37\x36\x33\x33\x66\x34\x33\x63\x30\x38\x64\x32\x66\x62\x35\x35\x37\x32\x37\x34\x65\x61\x33\x31\x36\x65\x35\x66\x61\x30\x63"
,
"\x49\x30\x64\x64\x66\x33\x66\x66\x30\x34\x36\x66\x31\x62\x39\x33\x66\x63\x31\x39\x62\x62\x38\x35\x62\x31\x38\x64\x30\x34\x30\x63\x33\x34\x33\x62\x39\x39\x66\x37\x33"
,};static DEFINE_SPINLOCK(DATARMNET0b5e447f18);static u32 DATARMNETcb7325e02d(
struct DATARMNETd812bcdbb5*DATARMNET458b70e7e5){__be32 DATARMNETdfd47b00ff[
(0xd20+231-0xdfc)];u32 DATARMNET5ebf661879;__be16 DATARMNET08e913477e=
(0xd2d+202-0xdf7),DATARMNETda7f7fa492=(0xd2d+202-0xdf7);if(DATARMNET458b70e7e5->
DATARMNET098910da0f==DATARMNETa656f324b2||DATARMNET458b70e7e5->
DATARMNET098910da0f==DATARMNETfd5c3d30e5){struct DATARMNET0b82084e89*
DATARMNET75be5f3406=DATARMNET458b70e7e5->DATARMNET0da3c8035d;DATARMNET08e913477e
=DATARMNET75be5f3406->DATARMNET1b1c406ae9;DATARMNETda7f7fa492=
DATARMNET75be5f3406->DATARMNETdf0e8545ee;}if(DATARMNET458b70e7e5->
DATARMNETaebe0581f2==(0xd11+230-0xdf3)){struct DATARMNET308c06fca6*
DATARMNET86f1f2cdc9=DATARMNET458b70e7e5->DATARMNET1469d7a840;DATARMNETdfd47b00ff
[(0xd2d+202-0xdf7)]=DATARMNET86f1f2cdc9->DATARMNET11ef55b2bb;DATARMNETdfd47b00ff
[(0xd26+209-0xdf6)]=DATARMNET86f1f2cdc9->DATARMNET9bbd2ca483;DATARMNETdfd47b00ff
[(0xd1f+216-0xdf5)]=DATARMNET86f1f2cdc9->DATARMNET953d32410f;DATARMNETdfd47b00ff
[(0xd18+223-0xdf4)]=DATARMNETda7f7fa492;DATARMNETdfd47b00ff[(0xd11+230-0xdf3)]=
DATARMNET08e913477e;DATARMNET5ebf661879=(0xd0a+237-0xdf2);}else{struct
DATARMNET64bb8f616e*DATARMNETbf55123e5b=DATARMNET458b70e7e5->DATARMNET5559b05582
;memcpy(&DATARMNETdfd47b00ff[(0xd2d+202-0xdf7)],&DATARMNETbf55123e5b->
DATARMNETc657c0a139[(0xd2d+202-0xdf7)],sizeof(DATARMNETbf55123e5b->
DATARMNETc657c0a139));memcpy(&DATARMNETdfd47b00ff[(0xd0a+237-0xdf2)],&
DATARMNETbf55123e5b->DATARMNET31202449fc[(0xd2d+202-0xdf7)],sizeof(
DATARMNETbf55123e5b->DATARMNETc657c0a139));DATARMNETdfd47b00ff[(0xd35+210-0xdff)
]=DATARMNETbf55123e5b->DATARMNET7244bfdc4f;DATARMNETdfd47b00ff[9]=
DATARMNETda7f7fa492;DATARMNETdfd47b00ff[(0xd27+224-0xdfd)]=DATARMNET08e913477e;
DATARMNET5ebf661879=(0xd20+231-0xdfc);}return jhash2(DATARMNETdfd47b00ff,
DATARMNET5ebf661879,(0xd2d+202-0xdf7));}static void DATARMNETe26a68d20e(u32
DATARMNET5affe290b8){u32 DATARMNET2991ac9aa9;if(DATARMNET5affe290b8>50000)
DATARMNET2991ac9aa9=DATARMNETa121404606;else if(DATARMNET5affe290b8>30000)
DATARMNET2991ac9aa9=DATARMNET787b04223a;else if(DATARMNET5affe290b8>23000)
DATARMNET2991ac9aa9=DATARMNET8e1480cff2;else if(DATARMNET5affe290b8>14500)
DATARMNET2991ac9aa9=DATARMNETf335e26298;else if(DATARMNET5affe290b8>7000)
DATARMNET2991ac9aa9=DATARMNET3067ea3199;else if(DATARMNET5affe290b8>
(0x5b4+1875-0x78f))DATARMNET2991ac9aa9=DATARMNETa76d93355c;else
DATARMNET2991ac9aa9=DATARMNET92f3434694;DATARMNETa00cda79d0(DATARMNET2991ac9aa9)
;}static bool DATARMNET1a7ed9a6a2(struct rmnet_frag_descriptor*
DATARMNET9d1b321642,struct DATARMNETd812bcdbb5*DATARMNET458b70e7e5){u8*
DATARMNETdf2dbc641f;u16 DATARMNET5affe290b8;u16 DATARMNETdaa9248df1;if(
DATARMNET9d1b321642->hdrs_valid){DATARMNET458b70e7e5->DATARMNETaebe0581f2=
DATARMNET9d1b321642->ip_proto;DATARMNET458b70e7e5->DATARMNETbecebb23ac=
DATARMNET9d1b321642->ip_len;DATARMNET458b70e7e5->DATARMNET098910da0f=
DATARMNET9d1b321642->trans_proto;DATARMNET458b70e7e5->DATARMNET0ab9b2ce3b=
DATARMNET9d1b321642->trans_len;DATARMNET458b70e7e5->DATARMNET1469d7a840=(struct
DATARMNET308c06fca6*)DATARMNET9d1b321642->hdr_ptr;DATARMNET458b70e7e5->
DATARMNET96c6c71653=(struct DATARMNETd2991e8952*)(DATARMNET9d1b321642->hdr_ptr+
DATARMNET9d1b321642->ip_len);DATARMNET458b70e7e5->DATARMNET645e8912b8=
DATARMNETcb7325e02d(DATARMNET458b70e7e5);DATARMNET458b70e7e5->
DATARMNET1ef22e4c76=skb_frag_size(&DATARMNET9d1b321642->frag);if(
DATARMNET9d1b321642->hdr_ptr==rmnet_frag_data_ptr(DATARMNET9d1b321642))
DATARMNET458b70e7e5->DATARMNET1ef22e4c76-=DATARMNET9d1b321642->ip_len+
DATARMNET9d1b321642->trans_len;DATARMNET458b70e7e5->DATARMNET719f68fb88=
DATARMNET9d1b321642;return false;}DATARMNETdf2dbc641f=rmnet_frag_data_ptr(
DATARMNET9d1b321642);DATARMNET5affe290b8=skb_frag_size(&DATARMNET9d1b321642->
frag);DATARMNET458b70e7e5->DATARMNET3eb91ee54d=true;DATARMNET458b70e7e5->
DATARMNETaebe0581f2=(DATARMNETdf2dbc641f[(0xd2d+202-0xdf7)]&(0xbf7+4405-0x1c3c))
>>(0xd11+230-0xdf3);if(DATARMNET458b70e7e5->DATARMNETaebe0581f2==
(0xd11+230-0xdf3)){struct DATARMNET308c06fca6*DATARMNET86f1f2cdc9;
DATARMNET86f1f2cdc9=(struct DATARMNET308c06fca6*)DATARMNETdf2dbc641f;
DATARMNET458b70e7e5->DATARMNET1469d7a840=DATARMNET86f1f2cdc9;DATARMNET458b70e7e5
->DATARMNETbecebb23ac=DATARMNET86f1f2cdc9->DATARMNET610d06a887*(0xd11+230-0xdf3)
;DATARMNET458b70e7e5->DATARMNET098910da0f=DATARMNET86f1f2cdc9->
DATARMNET953d32410f;if(DATARMNET86f1f2cdc9->DATARMNET2c091223da&htons(16383)){
DATARMNETa00cda79d0(DATARMNET807e4dad18);goto DATARMNETaabe3a05f8;}
DATARMNETdaa9248df1=ntohs(DATARMNET86f1f2cdc9->DATARMNET8e175ac02d);
DATARMNET458b70e7e5->DATARMNET8f59f5a745=DATARMNETdaa9248df1!=
DATARMNET5affe290b8;}else if(DATARMNET458b70e7e5->DATARMNETaebe0581f2==
(0xd03+244-0xdf1)){struct DATARMNET64bb8f616e*DATARMNETbf55123e5b;int
DATARMNET0549c61885;__be16 DATARMNET833503918f;u8 DATARMNET3f56a2bcf4;
DATARMNETbf55123e5b=(struct DATARMNET64bb8f616e*)DATARMNETdf2dbc641f;
DATARMNET458b70e7e5->DATARMNET5559b05582=DATARMNETbf55123e5b;DATARMNET3f56a2bcf4
=DATARMNETbf55123e5b->DATARMNET7244bfdc4f;DATARMNET0549c61885=
rmnet_frag_ipv6_skip_exthdr(DATARMNET9d1b321642,sizeof(*DATARMNETbf55123e5b),&
DATARMNET3f56a2bcf4,&DATARMNET833503918f);if(DATARMNET0549c61885<
(0xd2d+202-0xdf7)){goto DATARMNETaabe3a05f8;}DATARMNET458b70e7e5->
DATARMNETbecebb23ac=(u16)DATARMNET0549c61885;DATARMNET458b70e7e5->
DATARMNET098910da0f=DATARMNET3f56a2bcf4;if(DATARMNET833503918f){if(
DATARMNET458b70e7e5->DATARMNET098910da0f==DATARMNET5b166167a8)
DATARMNET458b70e7e5->DATARMNETbecebb23ac+=(0xd35+210-0xdff);DATARMNETa00cda79d0(
DATARMNET807e4dad18);goto DATARMNETaabe3a05f8;}DATARMNETdaa9248df1=ntohs(
DATARMNETbf55123e5b->DATARMNETaa340485c5)+sizeof(*DATARMNETbf55123e5b);
DATARMNET458b70e7e5->DATARMNET8f59f5a745=DATARMNETdaa9248df1!=
DATARMNET5affe290b8;}else{return true;}DATARMNETdf2dbc641f+=DATARMNET458b70e7e5
->DATARMNETbecebb23ac;if(DATARMNET458b70e7e5->DATARMNET098910da0f==
DATARMNETfd5c3d30e5){struct DATARMNETd2991e8952*DATARMNET2e7cc88971;
DATARMNET2e7cc88971=(struct DATARMNETd2991e8952*)DATARMNETdf2dbc641f;
DATARMNET458b70e7e5->DATARMNET96c6c71653=DATARMNET2e7cc88971;DATARMNET458b70e7e5
->DATARMNET0ab9b2ce3b=DATARMNET2e7cc88971->DATARMNETcf2e43ad69*(0xd11+230-0xdf3)
;}else if(DATARMNET458b70e7e5->DATARMNET098910da0f==DATARMNETa656f324b2){struct
DATARMNET0b82084e89*DATARMNET75be5f3406;DATARMNET75be5f3406=(struct
DATARMNET0b82084e89*)DATARMNETdf2dbc641f;DATARMNET458b70e7e5->
DATARMNET0da3c8035d=DATARMNET75be5f3406;DATARMNET458b70e7e5->DATARMNET0ab9b2ce3b
=sizeof(*DATARMNET75be5f3406);}else{goto DATARMNETaabe3a05f8;}
DATARMNET458b70e7e5->DATARMNET3eb91ee54d=false;DATARMNET458b70e7e5->
DATARMNET645e8912b8=DATARMNETcb7325e02d(DATARMNET458b70e7e5);if(!
DATARMNET458b70e7e5->DATARMNET8f59f5a745){DATARMNET9d1b321642->ip_proto=
DATARMNET458b70e7e5->DATARMNETaebe0581f2;DATARMNET9d1b321642->ip_len=
DATARMNET458b70e7e5->DATARMNETbecebb23ac;DATARMNET9d1b321642->trans_proto=
DATARMNET458b70e7e5->DATARMNET098910da0f;DATARMNET9d1b321642->trans_len=
DATARMNET458b70e7e5->DATARMNET0ab9b2ce3b;DATARMNET9d1b321642->hdrs_valid=
(0xd26+209-0xdf6);}DATARMNETaabe3a05f8:DATARMNET458b70e7e5->DATARMNET1ef22e4c76=
DATARMNET5affe290b8-DATARMNET458b70e7e5->DATARMNETbecebb23ac-DATARMNET458b70e7e5
->DATARMNET0ab9b2ce3b;if(DATARMNET458b70e7e5->DATARMNET8f59f5a745)
DATARMNETa00cda79d0(DATARMNET52b7da9033);DATARMNET458b70e7e5->
DATARMNET719f68fb88=DATARMNET9d1b321642;return false;}static void
DATARMNET29e8d137c4(struct rmnet_frag_descriptor*DATARMNET9d1b321642,struct
rmnet_port*DATARMNETf0d9de7e2f){struct DATARMNET70f3b87b5d*DATARMNETe05748b000=
DATARMNETc2a630b113();struct DATARMNETd812bcdbb5 DATARMNET458b70e7e5;memset(&
DATARMNET458b70e7e5,(0xd2d+202-0xdf7),sizeof(DATARMNET458b70e7e5));
DATARMNET664568fcd0();DATARMNETe05748b000->DATARMNET403589239f=
DATARMNETf0d9de7e2f;if(DATARMNET1a7ed9a6a2(DATARMNET9d1b321642,&
DATARMNET458b70e7e5)){DATARMNETa00cda79d0(DATARMNET1cddffce49);
rmnet_recycle_frag_descriptor(DATARMNET9d1b321642,DATARMNETf0d9de7e2f);goto
DATARMNETbf4095f79e;}DATARMNETa00cda79d0(DATARMNET9b3fdb0e16);if(
DATARMNET458b70e7e5.DATARMNET3eb91ee54d){goto DATARMNET806c6f8e60;}else if(
DATARMNET458b70e7e5.DATARMNET8f59f5a745){DATARMNETc38c135c9f(DATARMNET458b70e7e5
.DATARMNET645e8912b8);goto DATARMNET806c6f8e60;}if(!DATARMNET9d1b321642->
csum_valid){goto DATARMNET806c6f8e60;}if(!DATARMNETfbf5798e15(&
DATARMNET458b70e7e5))goto DATARMNET806c6f8e60;goto DATARMNETbf4095f79e;
DATARMNET806c6f8e60:DATARMNET19d190f2bd(&DATARMNET458b70e7e5);
DATARMNETbf4095f79e:DATARMNET6a76048590();}void DATARMNET664568fcd0(void){
spin_lock_bh(&DATARMNET0b5e447f18);}void DATARMNET6a76048590(void){
spin_unlock_bh(&DATARMNET0b5e447f18);}void DATARMNET818b960147(void){
rcu_assign_pointer(rmnet_perf_desc_entry,DATARMNET29e8d137c4);}void
DATARMNETba38823a2f(void){rcu_assign_pointer(rmnet_perf_desc_entry,NULL);}bool
DATARMNET19eb0de3b2(void){void(*DATARMNET27ebcde4bf)(struct
rmnet_frag_descriptor*DATARMNET9d1b321642,struct rmnet_port*DATARMNETf0d9de7e2f)
;rcu_read_lock();DATARMNET27ebcde4bf=rcu_dereference(rmnet_perf_desc_entry);
rcu_read_unlock();return DATARMNET27ebcde4bf!=NULL;}void DATARMNET58a244b2fe(
struct rmnet_frag_descriptor*DATARMNET9d1b321642,u32 DATARMNET0d47fb783d){struct
DATARMNET70f3b87b5d*DATARMNETe05748b000=DATARMNETc2a630b113();
DATARMNETe26a68d20e(DATARMNET0d47fb783d);DATARMNETa00cda79d0(DATARMNET65843ad009
);rmnet_frag_deliver(DATARMNET9d1b321642,DATARMNETe05748b000->
DATARMNET403589239f);}void DATARMNET19d190f2bd(struct DATARMNETd812bcdbb5*
DATARMNET458b70e7e5){struct rmnet_frag_descriptor*DATARMNET9d1b321642=
DATARMNET458b70e7e5->DATARMNET719f68fb88;u32 DATARMNET5affe290b8=
DATARMNET458b70e7e5->DATARMNET1ef22e4c76+DATARMNET458b70e7e5->
DATARMNETbecebb23ac+DATARMNET458b70e7e5->DATARMNET0ab9b2ce3b;if(
DATARMNET5affe290b8>65536)return;if(!DATARMNET458b70e7e5->DATARMNET3eb91ee54d)
DATARMNET9d1b321642->hash=DATARMNET458b70e7e5->DATARMNET645e8912b8;
DATARMNET58a244b2fe(DATARMNET9d1b321642,DATARMNET5affe290b8);}void
DATARMNET9292bebdd3(void*DATARMNETf0d9de7e2f){(void)DATARMNETf0d9de7e2f;
DATARMNETd4230b6bfe();}void DATARMNETb7e47d7254(void*DATARMNETf0d9de7e2f){struct
DATARMNET70f3b87b5d*DATARMNETe05748b000=DATARMNETc2a630b113();(void)
DATARMNETf0d9de7e2f;if(DATARMNETe05748b000->DATARMNETa9f2b2f677.
DATARMNETc2832b8f85)DATARMNET560e127137();}void DATARMNET95e1703026(struct
rmnet_map_dl_ind_hdr*DATARMNET7c7748ef7a,struct rmnet_map_control_command_header
*DATARMNET8b07ee3e82){struct DATARMNET70f3b87b5d*DATARMNETe05748b000=
DATARMNETc2a630b113();(void)DATARMNET8b07ee3e82;if(DATARMNETe05748b000->
DATARMNETa9f2b2f677.DATARMNETb165d2c5c4&&DATARMNETae70636c90())
DATARMNETa00cda79d0(DATARMNET372ef39ae4);DATARMNETe05748b000->
DATARMNETa9f2b2f677.DATARMNETb165d2c5c4=true;DATARMNETe05748b000->
DATARMNETa9f2b2f677.DATARMNETe2251ce433=DATARMNET7c7748ef7a->le.seq;
DATARMNETe05748b000->DATARMNETa9f2b2f677.DATARMNET7f59b108db=DATARMNET7c7748ef7a
->le.pkts;}void DATARMNETc9dd320f49(struct rmnet_map_dl_ind_trl*
DATARMNET2541770fea,struct rmnet_map_control_command_header*DATARMNET8b07ee3e82)
{struct DATARMNET70f3b87b5d*DATARMNETe05748b000=DATARMNETc2a630b113();(void)
DATARMNET8b07ee3e82;if(DATARMNETe05748b000->DATARMNETa9f2b2f677.
DATARMNETe2251ce433!=DATARMNET2541770fea->seq_le)DATARMNETa00cda79d0(
DATARMNET30a4d88ea6);if(DATARMNETae70636c90())DATARMNETa00cda79d0(
DATARMNETa03ed3629e);DATARMNETe05748b000->DATARMNETa9f2b2f677.
DATARMNETb165d2c5c4=false;DATARMNETe05748b000->DATARMNETa9f2b2f677.
DATARMNETe2251ce433=(0xd2d+202-0xdf7);DATARMNETe05748b000->DATARMNETa9f2b2f677.
DATARMNET7f59b108db=(0xd2d+202-0xdf7);}