# Copyright (c) 2019-2021 Qualcomm Technologies, Inc.
# All Rights Reserved.
# Confidential and Proprietary - Qualcomm Technologies, Inc.
#

on boot
    #Create NETMGR daemon socket area
    mkdir /dev/socket/netmgr 0750 radio radio

    #Assign TCP buffer thresholds to be ceiling value of technology maximums
    #Increased technology maximums should be reflected here.
    write /proc/sys/net/core/rmem_max  16777216
    write /proc/sys/net/core/wmem_max  8388608

    #Load rmnet_core driver
    exec u:r:vendor_modprobe:s0 -- /vendor/bin/modprobe -a -d /vendor/lib/modules rmnet_ctl
    exec u:r:vendor_modprobe:s0 -- /vendor/bin/modprobe -a -d /vendor/lib/modules rmnet_core
    exec u:r:vendor_modprobe:s0 -- /vendor/bin/modprobe -a -d /vendor/lib/modules/5.4-gki rmnet_ctl
    exec u:r:vendor_modprobe:s0 -- /vendor/bin/modprobe -a -d /vendor/lib/modules/5.4-gki rmnet_core

# msm specific files that need to be created on /data
on post-fs-data
    #Create NETMGR daemon log dir
    mkdir /data/vendor/netmgr 0770 radio radio
    chmod 0770 /data/vendor/netmgr

    # Create netmgr recovery folder
    mkdir /data/vendor/netmgr/recovery 0700 radio radio
    chmod 0770 /data/vendor/netmgr/recovery
    write /data/vendor/netmgr/recovery/recovery_info ""
    chown radio radio /data/vendor/netmgr/recovery/recovery_info

# Manage netmgrd based on value of property
on property:persist.vendor.data.mode=disabled
    stop vendor.netmgrd

service vendor.netmgrd /system/vendor/bin/netmgrd
    class main

on property:ro.vendor.use_data_netmgrd=false
    # netmgr not supported on specific target
    stop vendor.netmgrd

on property:ro.baseband=apq
    stop vendor.netmgrd

on property:persist.vendor.data.shs_ko_load=1
    exec u:r:vendor_modprobe:s0 -- /vendor/bin/modprobe -a -d /vendor/lib/modules rmnet_shs
    exec u:r:vendor_modprobe:s0 -- /vendor/bin/modprobe -a -d /vendor/lib/modules/5.4-gki rmnet_shs

on property:persist.vendor.data.shs_ko_load=0
    exec u:r:vendor_modprobe:s0 -- /vendor/bin/modprobe -r -d /vendor/lib/modules rmnet_shs
    exec u:r:vendor_modprobe:s0 -- /vendor/bin/modprobe -r -d /vendor/lib/modules/5.4-gki rmnet_shs

on property:persist.vendor.data.perf_ko_load=3
    exec u:r:vendor_modprobe:s0 -- /vendor/bin/modprobe -d /vendor/lib/modules rmnet_perf rmnet_perf_ingress_deag=N
    exec u:r:vendor_modprobe:s0 -- /vendor/bin/modprobe -d /vendor/lib/modules/5.4-gki rmnet_perf rmnet_perf_ingress_deag=N

on property:persist.vendor.data.perf_ko_load=2
    exec u:r:vendor_modprobe:s0 -- /vendor/bin/modprobe -d /vendor/lib/modules rmnet_perf rmnet_perf_opt_mode="udp"
    exec u:r:vendor_modprobe:s0 -- /vendor/bin/modprobe -d /vendor/lib/modules/5.4-gki rmnet_perf rmnet_perf_opt_mode="udp"

on property:persist.vendor.data.perf_ko_load=1
    exec u:r:vendor_modprobe:s0 -- /vendor/bin/modprobe -a -d /vendor/lib/modules rmnet_perf
    exec u:r:vendor_modprobe:s0 -- /vendor/bin/modprobe -a -d /vendor/lib/modules/5.4-gki rmnet_perf

on property:persist.vendor.data.perf_ko_load=0
    exec u:r:vendor_modprobe:s0 -- /vendor/bin/modprobe -r -d /vendor/lib/modules rmnet_perf
    exec u:r:vendor_modprobe:s0 -- /vendor/bin/modprobe -r -d /vendor/lib/modules/5.4-gki rmnet_perf

on property:persist.vendor.data.offload_ko_load=1
    exec u:r:vendor_modprobe:s0 -- /vendor/bin/modprobe -a -d /vendor/lib/modules rmnet_offload
    exec u:r:vendor_modprobe:s0 -- /vendor/bin/modprobe -a -d /vendor/lib/modules/5.4-gki rmnet_offload

on property:persist.vendor.data.offload_ko_load=0
    exec u:r:vendor_modprobe:s0 -- /vendor/bin/modprobe -r -d /vendor/lib/modules rmnet_offload
    exec u:r:vendor_modprobe:s0 -- /vendor/bin/modprobe -r -d /vendor/lib/modules/5.4-gki rmnet_offload
