#!/bin/sh /etc/rc.common
# Copyright (C) 2017 lean <coolsnowwolf@gmail.com>

START=99

start()
{
  rfc=4096  
  cc=$(grep -c processor /proc/cpuinfo)  
  rsfe=$(echo $cc*$rfc | bc)  
  sysctl -w net.core.rps_sock_flow_entries=$rsfe  
  for fileRps in $(ls /sys/class/net/eth*/queues/rx-*/rps_cpus)  
  do
      echo $cc > $fileRps  
  done
        
  for fileRfc in $(ls /sys/class/net/eth*/queues/rx-*/rps_flow_cnt)  
  do
      echo $rfc > $fileRfc  
  done

  for fileRps in $(ls /sys/class/net/eth*/queues/tx-*/xps_cpus)  
  do
      echo $cc > $fileRps  
  done
  
  a=$(cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq)
  b=$(echo -n ' : ')
  c=$(cat /proc/cpuinfo | grep 'core id' | sort -u | wc -l)
  d=$(echo -n ' Core ')
  e=$(cat /proc/cpuinfo | grep 'processor' | wc -l)
  f=$(echo -n ' Thread ')
  g=${a}${b}${c}${d}${e}${f}
  echo $g > /tmp/sysinfo/model
  
  ethtool -K eth0 rx-checksum on >/dev/null 2>&1
  ethtool -K eth0 tx-checksum-ip-generic on >/dev/null 2>&1
  ethtool -K eth0 tso on >/dev/null 2>&1
  ethtool -K eth0 ufo on >/dev/null 2>&1
  ethtool -K eth0 gso on >/dev/null 2>&1
  
  ethtool -K eth1 rx-checksum on >/dev/null 2>&1
  ethtool -K eth1 tx-checksum-ip-generic on >/dev/null 2>&1
  ethtool -K eth1 tso on >/dev/null 2>&1
  ethtool -K eth1 ufo on >/dev/null 2>&1
  ethtool -K eth1 gso on >/dev/null 2>&1
  
  ethtool -K eth2 rx-checksum on >/dev/null 2>&1
  ethtool -K eth2 tx-checksum-ip-generic on >/dev/null 2>&1
  ethtool -K eth2 tso on >/dev/null 2>&1
  ethtool -K eth2 ufo on >/dev/null 2>&1
  ethtool -K eth2 gso on >/dev/null 2>&1
  
  ethtool -K eth3 rx-checksum on >/dev/null 2>&1
  ethtool -K eth3 tx-checksum-ip-generic on >/dev/null 2>&1
  ethtool -K eth3 tso on >/dev/null 2>&1
  ethtool -K eth3 ufo on >/dev/null 2>&1
  ethtool -K eth3 gso on >/dev/null 2>&1
  
  [ -f /etc/index.htm ] && mv /etc/index.htm /usr/lib/lua/luci/view/admin_status/index.htm
}



