116518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal#
216518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal# Copyright (C) 2016 The Android Open Source Project
316518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal#
416518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal# Licensed under the Apache License, Version 2.0 (the "License");
516518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal# you may not use this file except in compliance with the License.
616518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal# You may obtain a copy of the License at
716518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal#
816518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal#      http://www.apache.org/licenses/LICENSE-2.0
916518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal#
1016518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal# Unless required by applicable law or agreed to in writing, software
1116518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal# distributed under the License is distributed on an "AS IS" BASIS,
1216518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1316518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal# See the License for the specific language governing permissions and
1416518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal# limitations under the License.
1516518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal#
1616518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal
17995d663f4fc31d985a4271ef4d13ebb0187baf4fWei Wangon fs
18995d663f4fc31d985a4271ef4d13ebb0187baf4fWei Wang   setprop sys.wifitracing.started 0
19995d663f4fc31d985a4271ef4d13ebb0187baf4fWei Wang
20995d663f4fc31d985a4271ef4d13ebb0187baf4fWei Wangon property:sys.boot_completed=1 && property:sys.wifitracing.started=0
2116518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal   # Create trace buffer, and set basic configuration.
2216518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal   mkdir /sys/kernel/debug/tracing/instances/wifi 711
2316518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal   restorecon_recursive /sys/kernel/debug/tracing/instances/wifi
2416518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal   write /sys/kernel/debug/tracing/instances/wifi/tracing_on 0
2516518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal   write /sys/kernel/debug/tracing/instances/wifi/buffer_size_kb 1
2616518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal   write /sys/kernel/debug/tracing/instances/wifi/trace_options disable_on_free
2716518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal
2816518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal   # Enable cfg80211 events for connection and key management events.
2916518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal   # - Events are not actually logged until WifiService writes "1" to
3016518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal   #   /sys/kernel/debug/tracing/instances/wifi/tracing_on.
3116518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal   # - WifiService is responsible for turning tracing off and on.
3216518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal   write /sys/kernel/debug/tracing/instances/wifi/events/cfg80211/cfg80211_gtk_rekey_notify/enable 1
3316518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal   write /sys/kernel/debug/tracing/instances/wifi/events/cfg80211/rdev_add_key/enable 1
3416518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal   write /sys/kernel/debug/tracing/instances/wifi/events/cfg80211/rdev_assoc/enable 1
3516518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal   write /sys/kernel/debug/tracing/instances/wifi/events/cfg80211/rdev_auth/enable 1
3616518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal   write /sys/kernel/debug/tracing/instances/wifi/events/cfg80211/rdev_connect/enable 1
3716518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal   write /sys/kernel/debug/tracing/instances/wifi/events/cfg80211/rdev_set_default_key/enable 1
3816518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal   write /sys/kernel/debug/tracing/instances/wifi/events/cfg80211/rdev_set_default_mgmt_key/enable 1
3916518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal   write /sys/kernel/debug/tracing/instances/wifi/events/cfg80211/rdev_set_rekey_data/enable 1
4016518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal
4116518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal   # Enable datapath events for Wifi.
4216518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal   # - Events are not actually logged until WifiService writes "1" to
4316518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal   #   /sys/kernel/debug/tracing/instances/wifi/tracing_on.
4416518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal   # - WifiService will ensure that tracing is turned back off,
4516518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal   #   when a connection attempt ends (whether in success or failure)
4616518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal   write /sys/kernel/debug/tracing/instances/wifi/events/net/filter name==${wifi.interface:-wlan0}
4716518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal   write /sys/kernel/debug/tracing/instances/wifi/events/net/net_dev_queue/enable 1
4816518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal   write /sys/kernel/debug/tracing/instances/wifi/events/net/net_dev_xmit/enable 1
4916518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal   write /sys/kernel/debug/tracing/instances/wifi/events/net/netif_rx/enable 1
5016518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal   write /sys/kernel/debug/tracing/instances/wifi/events/net/netif_receive_skb/enable 1
5116518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal
5216518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal   # Set DAC to allow system_server to enable/disable, and read wifi trace
5316518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal   # events.
5416518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal   chown system /sys/kernel/debug/tracing/instances/wifi/tracing_on
5516518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal   chown system /sys/kernel/debug/tracing/instances/wifi/free_buffer
5616518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal   chown system /sys/kernel/debug/tracing/instances/wifi/trace
5716518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal   chmod 200 /sys/kernel/debug/tracing/instances/wifi/tracing_on
5816518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal   chmod 400 /sys/kernel/debug/tracing/instances/wifi/free_buffer
5916518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal   chmod 600 /sys/kernel/debug/tracing/instances/wifi/trace
60995d663f4fc31d985a4271ef4d13ebb0187baf4fWei Wang   setprop sys.wifitracing.started 1
6116518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal
6225dbc28dc8e037a4a840c654c9ed559d2008323bWei Wangon property:sys.boot_completed=1 && property:wifi.interface=* && sys.wifitracing.started=1
6316518e5e207879e9fccd6ccbccb9a720f97ffbe6mukesh agrawal   # Override default value.
64ef75dd759a44224c55d2a15878474c84f257f807Wei Wang   write /sys/kernel/debug/tracing/instances/wifi/events/net/filter name==${wifi.interface}
65